diff options
author | rubidium <rubidium@openttd.org> | 2009-05-06 15:06:57 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-05-06 15:06:57 +0000 |
commit | 2664f2a2d95dbc2122ff1f9b96e8569ae401892f (patch) | |
tree | fb2112ce7a51edd259190186790bf00319a53510 /src/network | |
parent | bb121a1510fbd3faea71b794b1f6bdaba1641665 (diff) | |
download | openttd-2664f2a2d95dbc2122ff1f9b96e8569ae401892f.tar.xz |
(svn r16242) -Codechange: rework pausing
-Fix [FS#2864]: autopause and manual pausing conflict with eachother
-Fix: new game + pause on new game + autopause make the game not unpause on the first join
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/network.cpp | 20 | ||||
-rw-r--r-- | src/network/network_server.cpp | 7 |
2 files changed, 11 insertions, 16 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp index cb49c1ea0..dc025dad1 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -345,24 +345,20 @@ 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 */ static void CheckMinActiveClients() { - if (!_network_dedicated) return; + if (!_network_dedicated || _settings_client.network.min_active_clients == 0) return; if (NetworkCountActiveClients() < _settings_client.network.min_active_clients) { - if (_min_active_clients_paused) return; + if ((_pause_mode & PM_PAUSED_NORMAL) != 0) return; - _min_active_clients_paused = true; - DoCommandP(0, 1, 0, CMD_PAUSE); + DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE); NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "", CLIENT_ID_SERVER, NETWORK_SERVER_MESSAGE_GAME_PAUSED_PLAYERS); } else { - if (!_min_active_clients_paused) return; + if (_pause_mode == PM_UNPAUSED) return; - _min_active_clients_paused = false; - DoCommandP(0, 0, 0, CMD_PAUSE); + DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE); NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "", CLIENT_ID_SERVER, NETWORK_SERVER_MESSAGE_GAME_UNPAUSED_PLAYERS); } } @@ -464,8 +460,8 @@ void NetworkCloseClient(NetworkClientSocket *cs) } /* When the client was PRE_ACTIVE, the server was in pause mode, so unpause */ - if (cs->status == STATUS_PRE_ACTIVE && _settings_client.network.pause_on_join) { - DoCommandP(0, 0, 0, CMD_PAUSE); + if (cs->status == STATUS_PRE_ACTIVE && _pause_mode & PM_PAUSED_JOIN) { + DoCommandP(0, PM_PAUSED_JOIN, 0, CMD_PAUSE); NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "", CLIENT_ID_SERVER, NETWORK_SERVER_MESSAGE_GAME_UNPAUSED_CONNECT_FAIL); } @@ -794,8 +790,6 @@ bool NetworkServerStart() /* 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; diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 4597b2c71..2b8f44ffc 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -23,6 +23,7 @@ #include "../company_gui.h" #include "../settings_type.h" #include "../window_func.h" +#include "../openttd.h" #include "table/strings.h" @@ -820,7 +821,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_MAP_OK) if (_settings_client.network.pause_on_join) { /* Now pause the game till the client is in sync */ - DoCommandP(0, 1, 0, CMD_PAUSE); + DoCommandP(0, PM_PAUSED_JOIN, 1, CMD_PAUSE); NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "", CLIENT_ID_SERVER, NETWORK_SERVER_MESSAGE_GAME_PAUSED_CONNECT); } @@ -1013,8 +1014,8 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_ACK) /* Now he is! Unpause the game */ cs->status = STATUS_ACTIVE; - if (_settings_client.network.pause_on_join) { - DoCommandP(0, 0, 0, CMD_PAUSE); + if (_pause_mode & PM_PAUSED_JOIN) { + DoCommandP(0, PM_PAUSED_JOIN, 0, CMD_PAUSE); NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "", CLIENT_ID_SERVER, NETWORK_SERVER_MESSAGE_GAME_UNPAUSED_CONNECT); } |