mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
improve game info json
This commit is contained in:
@@ -243,6 +243,7 @@ config_property_definition _networkDefinitions[] = {
|
||||
{ offsetof(network_configuration, advertise), "advertise", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL },
|
||||
{ offsetof(network_configuration, maxplayers), "maxplayers", CONFIG_VALUE_TYPE_UINT8, 16, NULL },
|
||||
{ offsetof(network_configuration, server_name), "server_name", CONFIG_VALUE_TYPE_STRING, {.value_string = "Server" }, NULL },
|
||||
{ offsetof(network_configuration, server_description), "server_description", CONFIG_VALUE_TYPE_STRING, {.value_string = "" }, NULL },
|
||||
{ offsetof(network_configuration, master_url), "master_url", CONFIG_VALUE_TYPE_STRING, {.value_string = OPENRCT2_MASTER_URL }, NULL }
|
||||
};
|
||||
|
||||
|
||||
@@ -217,6 +217,7 @@ typedef struct {
|
||||
uint8 advertise;
|
||||
uint8 maxplayers;
|
||||
utf8string server_name;
|
||||
utf8string server_description;
|
||||
utf8string master_url;
|
||||
} network_configuration;
|
||||
|
||||
|
||||
@@ -940,11 +940,11 @@ void Network::Server_Send_GAMEINFO(NetworkConnection& connection)
|
||||
#ifndef DISABLE_HTTP
|
||||
json_t* obj = json_object();
|
||||
json_object_set(obj, "name", json_string(gConfigNetwork.server_name));
|
||||
json_object_set(obj, "haspassword", json_integer(password.size() > 0 ? 1 : 0));
|
||||
json_object_set(obj, "description", json_string(""));
|
||||
json_object_set(obj, "requiresPassword", json_boolean(password.size() > 0));
|
||||
json_object_set(obj, "version", json_string(OPENRCT2_VERSION));
|
||||
json_object_set(obj, "players", json_integer(player_list.size()));
|
||||
json_object_set(obj, "maxplayers", json_integer(gConfigNetwork.maxplayers));
|
||||
json_object_set(obj, "maxPlayers", json_integer(gConfigNetwork.maxplayers));
|
||||
json_object_set(obj, "description", json_string(gConfigNetwork.server_description));
|
||||
packet->WriteString(json_dumps(obj, 0));
|
||||
json_object_clear(obj);
|
||||
#endif
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
typedef struct {
|
||||
char *address;
|
||||
utf8 *name;
|
||||
bool haspassword;
|
||||
bool requiresPassword;
|
||||
utf8 *description;
|
||||
char *version;
|
||||
bool favorite;
|
||||
@@ -479,7 +479,7 @@ static void server_list_load_saved_servers()
|
||||
|
||||
serverInfo->address = freadstralloc(file);
|
||||
serverInfo->name = freadstralloc(file);
|
||||
serverInfo->haspassword = false;
|
||||
serverInfo->requiresPassword = false;
|
||||
serverInfo->description = freadstralloc(file);
|
||||
serverInfo->version = _strdup("");
|
||||
serverInfo->favorite = true;
|
||||
@@ -573,7 +573,7 @@ static saved_server* add_saved_server(char *address)
|
||||
saved_server* newserver = &_savedServers[index];
|
||||
newserver->address = _strdup(address);
|
||||
newserver->name = _strdup(address);
|
||||
newserver->haspassword = false;
|
||||
newserver->requiresPassword = false;
|
||||
newserver->description = _strdup("");
|
||||
newserver->version = _strdup("");
|
||||
newserver->favorite = false;
|
||||
@@ -664,17 +664,17 @@ static void fetch_servers_callback(http_json_response* response)
|
||||
|
||||
json_t *address = json_object_get(server, "address");
|
||||
json_t *name = json_object_get(server, "name");
|
||||
json_t *haspassword = json_object_get(server, "haspassword");
|
||||
json_t *description = json_object_get(server, "description");
|
||||
json_t *requiresPassword = json_object_get(server, "requiresPassword");
|
||||
json_t *version = json_object_get(server, "version");
|
||||
json_t *players = json_object_get(server, "players");
|
||||
json_t *maxplayers = json_object_get(server, "maxplayers");
|
||||
json_t *maxplayers = json_object_get(server, "maxPlayers");
|
||||
json_t *description = json_object_get(server, "description");
|
||||
|
||||
SDL_LockMutex(_mutex);
|
||||
saved_server* newserver = add_saved_server((char*)json_string_value(address));
|
||||
SafeFree(newserver->name);
|
||||
newserver->name = _strdup(json_string_value(name));
|
||||
newserver->haspassword = (uint8)json_integer_value(haspassword);
|
||||
newserver->requiresPassword = json_boolean_value(requiresPassword);
|
||||
SafeFree(newserver->description);
|
||||
newserver->description = _strdup(json_string_value(description));
|
||||
SafeFree(newserver->version);
|
||||
|
||||
Reference in New Issue
Block a user