@@ -343,13 +343,13 @@ static uint NetworkCountActiveClients()
return count;
}
static bool _min_active_clients_paused = false;
/* Check if the minimum number of active clients has been reached and pause or unpause the game as appropriate */
void CheckMinActiveClients()
static void CheckMinActiveClients()
{
if (!_network_dedicated) return;
if (NetworkCountActiveClients() < _settings_client.network.min_active_clients) {
if (_min_active_clients_paused) return;
@@ -463,14 +463,12 @@ void NetworkCloseClient(NetworkClientSoc
InvalidateWindow(WC_CLIENT_LIST, 0);
delete cs->GetInfo();
delete cs;
CheckMinActiveClients();
/* For the server, to accept new clients */
static void NetworkAcceptClients()
struct sockaddr_in sin;
@@ -817,13 +815,12 @@ bool NetworkServerStart()
/* execute server initialization script */
IConsoleCmdExec("exec scripts/on_server.scr 0");
/* if the server is dedicated ... add some other script */
if (_network_dedicated) IConsoleCmdExec("exec scripts/on_dedicated.scr 0");
_min_active_clients_paused = false;
/* Try to register us to the master server */
_network_last_advertise_frame = 0;
_network_need_advertise = true;
NetworkUDPAdvertise();
return true;
@@ -1025,12 +1022,13 @@ void NetworkGameLoop()
cp = MallocT<CommandPacket>(1);
int company;
sscanf(&buff[8], "%d; %d; %d; %d; %d; %d; %d; %s", &next_date, &next_date_fract, &company, &cp->tile, &cp->p1, &cp->p2, &cp->cmd, cp->text);
cp->company = (CompanyID)company;
#endif /* DEBUG_DUMP_COMMANDS */
bool send_frame = false;
/* We first increase the _frame_counter */
_frame_counter++;
/* Update max-frame-counter */
@@ -21,13 +21,12 @@ extern bool _network_need_advertise;
extern uint32 _network_last_advertise_frame;
extern uint8 _network_reconnect;
extern char *_network_host_list[10];
extern char *_network_ban_list[25];
byte NetworkSpectatorCount();
void CheckMinActiveClients();
void NetworkUpdateClientName();
bool NetworkCompanyHasClients(CompanyID company);
bool NetworkChangeCompanyPassword(byte argc, char *argv[]);
void NetworkReboot();
void NetworkDisconnect();
void NetworkGameLoop();
@@ -1015,14 +1015,12 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
if (_settings_client.network.pause_on_join) {
DoCommandP(0, 0, 0, CMD_PAUSE);
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "", CLIENT_ID_SERVER, NETWORK_SERVER_MESSAGE_GAME_UNPAUSED_CONNECT);
/* Execute script for, e.g. MOTD */
IConsoleCmdExec("exec scripts/on_server_connect.scr 0");
/* The client received the frame, make note of it */
cs->last_frame = frame;
@@ -1749,14 +1747,12 @@ void NetworkServerDoMove(ClientID client
/* announce the client's move */
NetworkUpdateClientInfo(client_id);
NetworkAction action = (company_id == COMPANY_SPECTATOR) ? NETWORK_ACTION_COMPANY_SPECTATOR : NETWORK_ACTION_COMPANY_JOIN;
NetworkServerSendChat(action, DESTTYPE_BROADCAST, 0, "", client_id, company_id + 1);
void NetworkServerSendRcon(ClientID client_id, ConsoleColour colour_code, const char *string)
SEND_COMMAND(PACKET_SERVER_RCON)(NetworkFindClientStateFromClientID(client_id), colour_code, string);
@@ -1161,18 +1161,12 @@ static bool ChangeDynamicEngines(int32 p
#ifdef ENABLE_NETWORK
static bool UpdateMinActiveClients(int32 p1)
static bool UpdateClientName(int32 p1)
NetworkUpdateClientName();
@@ -1575,13 +1569,13 @@ const SettingDesc _settings[] = {
SDTC_VAR(network.autoclean_unprotected, SLE_UINT8, S,D0|NO, 12, 0, 240, 0, STR_NULL, NULL),
SDTC_VAR(network.autoclean_protected, SLE_UINT8, S,D0|NO, 36, 0, 240, 0, STR_NULL, NULL),
SDTC_VAR(network.max_companies, SLE_UINT8, S, NO, 8, 1,MAX_COMPANIES,0, STR_NULL, UpdateClientConfigValues),
SDTC_VAR(network.max_clients, SLE_UINT8, S, NO, 16, 2, MAX_CLIENTS, 0, STR_NULL, NULL),
SDTC_VAR(network.max_spectators, SLE_UINT8, S, NO, 8, 0, MAX_CLIENTS, 0, STR_NULL, UpdateClientConfigValues),
SDTC_VAR(network.restart_game_year, SLE_INT32, S,D0|NO|NC,0, MIN_YEAR, MAX_YEAR, 1, STR_NULL, NULL),
SDTC_VAR(network.min_active_clients, SLE_UINT8, S, NO, 0, 0, MAX_CLIENTS, 0, STR_NULL, UpdateMinActiveClients),
SDTC_VAR(network.min_active_clients, SLE_UINT8, S, NO, 0, 0, MAX_CLIENTS, 0, STR_NULL, NULL),
SDTC_OMANY(network.server_lang, SLE_UINT8, S, NO, 0, 35, "ANY|ENGLISH|GERMAN|FRENCH|BRAZILIAN|BULGARIAN|CHINESE|CZECH|DANISH|DUTCH|ESPERANTO|FINNISH|HUNGARIAN|ICELANDIC|ITALIAN|JAPANESE|KOREAN|LITHUANIAN|NORWEGIAN|POLISH|PORTUGUESE|ROMANIAN|RUSSIAN|SLOVAK|SLOVENIAN|SPANISH|SWEDISH|TURKISH|UKRAINIAN|AFRIKAANS|CROATIAN|CATALAN|ESTONIAN|GALICIAN|GREEK|LATVIAN", STR_NULL, NULL),
SDTC_BOOL(network.reload_cfg, S, NO, false, STR_NULL, NULL),
SDTC_STR(network.last_host, SLE_STRB, S, 0, "0.0.0.0", STR_NULL, NULL),
SDTC_VAR(network.last_port, SLE_UINT16, S, 0, 0, 0, UINT16_MAX, 0, STR_NULL, NULL),
#endif /* ENABLE_NETWORK */
Status change: