diff options
author | rubidium <rubidium@openttd.org> | 2009-06-19 20:26:18 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-06-19 20:26:18 +0000 |
commit | 9b156c1bd433fd231868a70dad719c6972858072 (patch) | |
tree | f60f2169c27f97bee6ccd6f37ce4fc4bc25702ef /src/network/network.cpp | |
parent | 83f8d52a6770634f503282e4c9407a54f1825255 (diff) | |
download | openttd-9b156c1bd433fd231868a70dad719c6972858072.tar.xz |
(svn r16601) -Fix [FS#2880]: try 2... hopefully better this time
Diffstat (limited to 'src/network/network.cpp')
-rw-r--r-- | src/network/network.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp index 09ae9b7ae..cff0f456c 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -278,7 +278,7 @@ static void NetworkClientError(NetworkRecvStatus res, NetworkClientSocket *cs) /* We just want to close the connection.. */ if (res == NETWORK_RECV_STATUS_CLOSE_QUERY) { cs->NetworkSocketHandler::CloseConnection(); - NetworkCloseClient(cs); + NetworkCloseClient(cs, true); _networking = false; DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0); @@ -291,6 +291,7 @@ static void NetworkClientError(NetworkRecvStatus res, NetworkClientSocket *cs) case NETWORK_RECV_STATUS_NEWGRF_MISMATCH: errorno = NETWORK_ERROR_NEWGRF_MISMATCH; break; default: errorno = NETWORK_ERROR_GENERAL; break; } + /* This means we fucked up and the server closed the connection */ if (res != NETWORK_RECV_STATUS_SERVER_ERROR && res != NETWORK_RECV_STATUS_SERVER_FULL && res != NETWORK_RECV_STATUS_SERVER_BANNED) { @@ -298,7 +299,7 @@ static void NetworkClientError(NetworkRecvStatus res, NetworkClientSocket *cs) } _switch_mode = SM_MENU; - NetworkCloseClient(cs); + NetworkCloseClient(cs, true); _networking = false; } @@ -437,7 +438,7 @@ static NetworkClientSocket *NetworkAllocClient(SOCKET s) } /* Close a connection */ -void NetworkCloseClient(NetworkClientSocket *cs) +void NetworkCloseClient(NetworkClientSocket *cs, bool error) { /* * Sending a message just before leaving the game calls cs->Send_Packets. @@ -448,9 +449,7 @@ void NetworkCloseClient(NetworkClientSocket *cs) */ if (cs->sock == INVALID_SOCKET) return; - DEBUG(net, 1, "Closed client connection %d", cs->client_id); - - if (!cs->HasClientQuit() && _network_server && cs->status > STATUS_INACTIVE) { + if (error && !cs->HasClientQuit() && _network_server && cs->status > STATUS_INACTIVE) { /* We did not receive a leave message from this client... */ char client_name[NETWORK_CLIENT_NAME_LENGTH]; NetworkClientSocket *new_cs; @@ -467,6 +466,8 @@ void NetworkCloseClient(NetworkClientSocket *cs) } } + DEBUG(net, 1, "Closed client connection %d", cs->client_id); + /* When the client was PRE_ACTIVE, the server was in pause mode, so unpause */ if (cs->status == STATUS_PRE_ACTIVE && (_pause_mode & PM_PAUSED_JOIN)) { DoCommandP(0, PM_PAUSED_JOIN, 0, CMD_PAUSE); @@ -579,7 +580,7 @@ static void NetworkClose() SEND_COMMAND(PACKET_CLIENT_QUIT)(); cs->Send_Packets(); } - NetworkCloseClient(cs); + NetworkCloseClient(cs, false); } if (_network_server) { |