From d8d816f8dc9c84962fc00e79368332742f89d0a8 Mon Sep 17 00:00:00 2001 From: lotodore Date: Fri, 7 Mar 2008 21:45:26 +0000 Subject: [PATCH] Do not kick the player from the server on game admin timeout - just remove the player from the game. --- docs/net_protocol.txt | 1 + src/gui/qt/mainwindow/mainwindowimpl.cpp | 8 +++++++- src/net/common/netpacket.cpp | 7 +++++++ src/net/common/servergamestate.cpp | 2 +- src/net/socket_msg.h | 11 ++++++----- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/docs/net_protocol.txt b/docs/net_protocol.txt index 30b1c6e1..42ecdcda 100644 --- a/docs/net_protocol.txt +++ b/docs/net_protocol.txt @@ -811,6 +811,7 @@ Remove Reason: 0x0001 - Game is full 0x0002 - Game is already running 0x0003 - Kicked from the game + 0x0004 - Timeout 0xFFFF - Other reason diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index 1d2351e7..8bb2dc99 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -3060,6 +3060,7 @@ void mainWindowImpl::paintStartSplash() { void mainWindowImpl::networkError(int errorID, int /*osErrorID*/) { + hideTimeoutDialog(); switch (errorID) { case ERR_SOCK_SERVERADDR_NOT_SET: {QMessageBox::warning(this, tr("Network Error"), @@ -3272,7 +3273,6 @@ void mainWindowImpl::networkError(int errorID, int /*osErrorID*/) { QMessageBox::Close); } } // close dialogs - hideTimeoutDialog(); myGameLobbyDialog->reject(); myConnectToServerDialog->reject(); myStartNetworkGameDialog->reject(); @@ -3280,6 +3280,7 @@ void mainWindowImpl::networkError(int errorID, int /*osErrorID*/) { void mainWindowImpl::networkNotification(int notificationId) { + hideTimeoutDialog(); switch (notificationId) { case NTF_NET_REMOVED_KICKED: @@ -3299,6 +3300,11 @@ void mainWindowImpl::networkNotification(int notificationId) tr("Unable to join - the server has already started the game."), QMessageBox::Close); } break; + case NTF_NET_REMOVED_TIMEOUT: + { QMessageBox::warning(this, tr("Network Notification"), + tr("Your admin state timed out due to inactivity. Feel free to create a new game!"), + QMessageBox::Close); } + break; case NTF_NET_JOIN_INVALID_PASSWORD: { QMessageBox::warning(this, tr("Network Notification"), tr("Invalid password when joining the game.\nPlease reenter the password and try again."), diff --git a/src/net/common/netpacket.cpp b/src/net/common/netpacket.cpp index 02a451ec..b7a517c6 100644 --- a/src/net/common/netpacket.cpp +++ b/src/net/common/netpacket.cpp @@ -97,6 +97,7 @@ using namespace std; #define NET_REMOVED_GAME_FULL 0x0001 #define NET_REMOVED_GAME_ALREADY_RUNNING 0x0002 #define NET_REMOVED_KICKED 0x0003 +#define NET_REMOVED_TIMEOUT 0x0004 #define NET_REMOVED_OTHER_REASON 0xFFFF // Reasons for timeout warning @@ -4268,6 +4269,9 @@ NetPacketRemovedFromGame::SetData(const NetPacketRemovedFromGame::Data &inData) case NTF_NET_REMOVED_KICKED : tmpData->removeReason = htons(NET_REMOVED_KICKED); break; + case NTF_NET_REMOVED_TIMEOUT : + tmpData->removeReason = htons(NET_REMOVED_TIMEOUT); + break; default : tmpData->removeReason = htons(NET_REMOVED_OTHER_REASON); break; @@ -4297,6 +4301,9 @@ NetPacketRemovedFromGame::GetData(NetPacketRemovedFromGame::Data &outData) const case NET_REMOVED_KICKED : outData.removeReason = NTF_NET_REMOVED_KICKED; break; + case NET_REMOVED_TIMEOUT : + outData.removeReason = NTF_NET_REMOVED_TIMEOUT; + break; default : outData.removeReason = NTF_NET_INTERNAL; break; diff --git a/src/net/common/servergamestate.cpp b/src/net/common/servergamestate.cpp index 4f5d546b..d975ee83 100644 --- a/src/net/common/servergamestate.cpp +++ b/src/net/common/servergamestate.cpp @@ -340,7 +340,7 @@ ServerGameStateInit::Process(ServerGameThread &server) SessionWrapper session = server.GetSessionManager().GetSessionByUniquePlayerId(server.GetAdminPlayerId()); if (session.sessionData.get()) { - server.RemovePlayer(session.playerData->GetUniqueId(), ERR_NET_SESSION_TIMED_OUT); + server.MoveSessionToLobby(session, NTF_NET_REMOVED_TIMEOUT); } } return AbstractServerGameStateReceiving::Process(server); diff --git a/src/net/socket_msg.h b/src/net/socket_msg.h index f8378fc2..454d2eb5 100644 --- a/src/net/socket_msg.h +++ b/src/net/socket_msg.h @@ -90,15 +90,16 @@ #define NTF_NET_REMOVED_GAME_FULL 203 #define NTF_NET_REMOVED_ALREADY_RUNNING 204 #define NTF_NET_REMOVED_KICKED 205 +#define NTF_NET_REMOVED_TIMEOUT 206 // Notifications - join failed -#define NTF_NET_JOIN_GAME_FULL 206 -#define NTF_NET_JOIN_ALREADY_RUNNING 207 -#define NTF_NET_JOIN_INVALID_PASSWORD 208 +#define NTF_NET_JOIN_GAME_FULL 210 +#define NTF_NET_JOIN_ALREADY_RUNNING 211 +#define NTF_NET_JOIN_INVALID_PASSWORD 212 // Notifications - version -#define NTF_NET_NEW_RELEASE_AVAILABLE 209 -#define NTF_NET_OUTDATED_BETA 210 +#define NTF_NET_NEW_RELEASE_AVAILABLE 220 +#define NTF_NET_OUTDATED_BETA 221 // This is an internal message which is not reported. #define MSG_SOCK_INTERNAL_PENDING 0