Automatically set internal and public hosts for shards in database

Untested, but I don't see why it wouldn't work.
This commit is contained in:
riperiperi 2024-12-23 03:01:18 +00:00
parent 04334790c8
commit 0b6807a0de
5 changed files with 12 additions and 16 deletions

View file

@ -55,13 +55,3 @@ When database scripts are run, they are registered in the `fso_db_changes` table
**This means that the command can (and should) be rerun whenever there are any changes to the database made in the codebase**, so that the database remains compatible with the game.
Database scripts are registered on the `manifest.json` file with unique ids, dependencies and associated script files. If you aim to modify the database structure, you should add your own scripts to this manifest file so that anyone using your codebase can update their database to work with your changes. Similarly, if you're using someone else's codebase, you'll need to be wary of database changes and rerun this command when they occur.
## fso_shards correction
![](./media/shards.png)
When you initialize the database, `fso_shards` will already contain an entry for a city (in technical terms, a "shard")... but you will quickly find that it doesn't seem to work. This is because the internal and external host for the shard _must_ be set to match the city server hosting the shard - so it should match what you put in config.json in a later section. The game automatically adds `100` to the host provided, so `192.168.0.174:33` is actually telling the game to connect to `192.168.0.174:33100`.
This could be changed in the code to force the city to initialize the hosts from the configuration, as each city server has an associated shard id. It already uses this to update the shard's version, though it can have a delayed update...

View file

@ -61,3 +61,7 @@ That should be the long and short of it. After this, your server can be started
![](./media/debugurl.png)
To connect to your custom server, press F1 on the login screen and change the URL in the text box to match your API server endpoint. This will update your client configuration to connect to this server every time. If you want to distribute a client made for a specific server, you should overwrite this URL in the default config.
## Bogus Update Request
If your client version string is different from the server, it will ask you to update. You can ignore this by holding shift and clicking "No" on the dialog. See the Updates documentation for more information on properly configuring updates.

View file

@ -10,6 +10,6 @@ namespace FSO.Server.Database.DA.Shards
void DeleteTicket(string ticket_id);
ShardTicket GetTicket(string ticket_id);
void PurgeTickets(uint time);
void UpdateVersion(int shard_id, string name, string number, int? update_id);
void UpdateStatus(int shard_id, string internal_host, string public_host, string name, string number, int? update_id);
}
}

View file

@ -35,14 +35,16 @@ namespace FSO.Server.Database.DA.Shards
Context.Connection.Query("DELETE FROM fso_shard_tickets WHERE date < @time", new { time = time });
}
public void UpdateVersion(int shard_id, string name, string number, int? update_id)
public void UpdateStatus(int shard_id, string internal_host, string public_host, string name, string number, int? update_id)
{
Context.Connection.Query("UPDATE fso_shards SET version_name = @version_name, version_number = @version_number, update_id = @update_id WHERE shard_id = @shard_id", new
Context.Connection.Query("UPDATE fso_shards SET internal_host = @internal_host, public_host = @public_host, version_name = @version_name, version_number = @version_number, update_id = @update_id WHERE shard_id = @shard_id", new
{
internal_host,
public_host,
version_name = name,
version_number = number,
update_id = update_id,
shard_id = shard_id
update_id,
shard_id
});
}
}

View file

@ -75,7 +75,7 @@ namespace FSO.Server.Servers.City
IDAFactory da = Kernel.Get<IDAFactory>();
using (var db = da.Get()){
var version = ServerVersion.Get();
db.Shards.UpdateVersion(shard.Id, version.Name, version.Number, version.UpdateID);
db.Shards.UpdateStatus(shard.Id, Config.Internal_Host, Config.Public_Host, version.Name, version.Number, version.UpdateID);
((Shards)shards).Update();
var oldClaims = db.LotClaims.GetAllByOwner(context.Config.Call_Sign).ToList();