1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

add stay_connected config option

This commit is contained in:
IntelOrca
2015-09-05 18:46:13 +01:00
parent 6901c04f24
commit 85181b5ed3
4 changed files with 13 additions and 2 deletions

View File

@@ -238,6 +238,7 @@ config_property_definition _twitchDefinitions[] = {
config_property_definition _networkDefinitions[] = {
{ offsetof(network_configuration, player_name), "player_name", CONFIG_VALUE_TYPE_STRING, {.value_string = "Player" }, NULL },
{ offsetof(network_configuration, default_port), "default_port", CONFIG_VALUE_TYPE_UINT32, NETWORK_DEFAULT_PORT, NULL },
{ offsetof(network_configuration, stay_connected), "stay_connected", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL },
};
config_section_definition _sectionDefinitions[] = {

View File

@@ -212,6 +212,7 @@ typedef struct {
typedef struct {
utf8string player_name;
uint32 default_port;
uint8 stay_connected;
} network_configuration;
typedef struct theme_window {

View File

@@ -298,6 +298,8 @@ void Network::Close()
WSACleanup();
wsa_initialized = false;
}
gfx_invalidate_screen();
}
bool Network::BeginClient(const char* host, unsigned short port)
@@ -467,9 +469,14 @@ void Network::UpdateClient()
Close();
}
ProcessGameCommandQueue();
if (!CheckSRAND(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32), RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_SRAND_0, uint32))) {
// Check synchronisation
if (!_desynchronised && !CheckSRAND(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32), RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_SRAND_0, uint32))) {
_desynchronised = true;
window_network_status_open("Network desync detected");
Close();
if (!gConfigNetwork.stay_connected) {
Close();
}
}
}
@@ -834,6 +841,7 @@ int Network::Client_Handle_MAP(NetworkConnection& connection, NetworkPacket& pac
server_tick = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32);
server_srand0_tick = 0;
// window_network_status_open("Loaded new map from network");
_desynchronised = false;
}
SDL_RWclose(rw);
}

View File

@@ -194,6 +194,7 @@ private:
std::multiset<GameCommand> game_command_queue;
std::vector<uint8> chunk_buffer;
char password[33];
bool _desynchronised;
void UpdateServer();
void UpdateClient();