From 4bc902b22961051a99af5d89c98b284e96b95041 Mon Sep 17 00:00:00 2001 From: lotodore Date: Thu, 6 Mar 2008 21:48:14 +0000 Subject: [PATCH] New error messages. --- docs/net_protocol.txt | 3 +++ src/gui/qt/mainwindow/mainwindowimpl.cpp | 17 +++++++++++++ .../qt/timeoutmsgbox/timeoutmsgboximpl.cpp | 3 +-- src/net/common/netpacket.cpp | 21 ++++++++++++++++ src/net/common/servergamestate.cpp | 2 +- src/net/common/serverlobbythread.cpp | 4 +-- src/net/socket_msg.h | 25 +++++++++++-------- 7 files changed, 59 insertions(+), 16 deletions(-) diff --git a/docs/net_protocol.txt b/docs/net_protocol.txt index 716348bf..30b1c6e1 100644 --- a/docs/net_protocol.txt +++ b/docs/net_protocol.txt @@ -897,10 +897,13 @@ Error Reason: 0x0007 - Init - Server Maintenance 0x0010 - Avatar - Too large 0x0011 - Avatar - Wrong size + 0x0012 - Avatar - Upload blocked 0x0020 - Join Game - Unknown Game 0xFF01 - General Error - Invalid packet 0xFF02 - General Error - Invalid state 0xFF03 - General Error - Kicked from the server + 0xFF04 - General Error - Banned from the server + 0xFF05 - General Error - Session timeout 0xFFFF - Other reason diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index 7dd37910..1d2351e7 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -3214,6 +3214,18 @@ void mainWindowImpl::networkError(int errorID, int /*osErrorID*/) { tr("You were kicked from the server."), QMessageBox::Close); } break; + case ERR_NET_PLAYER_BANNED: + { mySession->terminateNetworkClient(); + QMessageBox::warning(this, tr("Network Error"), + tr("You were temporarily banned from the server."), + QMessageBox::Close); } + break; + case ERR_NET_SESSION_TIMED_OUT: + { mySession->terminateNetworkClient(); + QMessageBox::warning(this, tr("Network Error"), + tr("Your server connection timed out due to inactivity. You are very welcome to reconnect!"), + QMessageBox::Close); } + break; case ERR_NET_INVALID_PLAYER_COUNT: { QMessageBox::warning(this, tr("Network Error"), tr("The client player count is invalid."), @@ -3235,6 +3247,11 @@ void mainWindowImpl::networkError(int errorID, int /*osErrorID*/) { tr("The selected avatar file is too large. Please choose a different avatar."), QMessageBox::Close); } break; + case ERR_NET_AVATAR_UPLOAD_BLOCKED: + { QMessageBox::warning(this, tr("Network Error"), + tr("You cannot upload a new avatar file at this time. Please try again in a few seconds."), + QMessageBox::Close); } + break; case ERR_NET_INVALID_REQUEST_ID: { QMessageBox::warning(this, tr("Network Error"), tr("An internal avatar error occured. Please report this to an admin in the lobby chat."), diff --git a/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.cpp b/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.cpp index d24eb81e..deb096e1 100644 --- a/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.cpp +++ b/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.cpp @@ -48,13 +48,12 @@ void timeoutMsgBoxImpl::timerRefresh() { if (sec < 0) sec = 0; switch (msgID) { case NETWORK_TIMEOUT_GAME_ADMIN_IDLE: - this->setText(tr("Your open game reaches timeout in %1 seconds.").arg(sec,0,10)); + this->setText(tr("Your open game will time out in %1 seconds.").arg(sec,0,10)); break; default: this->setText(tr("Your connection is about to time out due to inactivity in %1 seconds.").arg(sec,0,10)); break; } - } void timeoutMsgBoxImpl::stopTimeout() { diff --git a/src/net/common/netpacket.cpp b/src/net/common/netpacket.cpp index 0e5487cc..02a451ec 100644 --- a/src/net/common/netpacket.cpp +++ b/src/net/common/netpacket.cpp @@ -114,10 +114,13 @@ using namespace std; #define NET_ERR_INIT_SERVER_MAINTENANCE 0x0007 #define NET_ERR_AVATAR_TOO_LARGE 0x0010 #define NET_ERR_AVATAR_WRONG_SIZE 0x0011 +#define NET_ERR_AVATAR_UPLOAD_BLOCKED 0x0012 #define NET_ERR_JOIN_GAME_UNKNOWN_GAME 0x0020 #define NET_ERR_GENERAL_INVALID_PACKET 0xFF01 #define NET_ERR_GENERAL_INVALID_STATE 0xFF02 #define NET_ERR_GENERAL_PLAYER_KICKED 0xFF03 +#define NET_ERR_GENERAL_PLAYER_BANNED 0xFF04 +#define NET_ERR_GENERAL_SESSION_TIMED_OUT 0xFF05 #define NET_ERR_OTHER 0xFFFF // Statistics types @@ -4663,6 +4666,9 @@ NetPacketError::SetData(const NetPacketError::Data &inData) case ERR_NET_WRONG_AVATAR_SIZE : tmpData->errorReason = htons(NET_ERR_AVATAR_WRONG_SIZE); break; + case ERR_NET_AVATAR_UPLOAD_BLOCKED : + tmpData->errorReason = htons(NET_ERR_AVATAR_UPLOAD_BLOCKED); + break; case ERR_NET_UNKNOWN_GAME : tmpData->errorReason = htons(NET_ERR_JOIN_GAME_UNKNOWN_GAME); break; @@ -4677,6 +4683,12 @@ NetPacketError::SetData(const NetPacketError::Data &inData) case ERR_NET_PLAYER_KICKED : tmpData->errorReason = htons(NET_ERR_GENERAL_PLAYER_KICKED); break; + case ERR_NET_PLAYER_BANNED : + tmpData->errorReason = htons(NET_ERR_GENERAL_PLAYER_BANNED); + break; + case ERR_NET_SESSION_TIMED_OUT : + tmpData->errorReason = htons(NET_ERR_GENERAL_SESSION_TIMED_OUT); + break; default : tmpData->errorReason = htons(NET_ERR_OTHER); break; @@ -4718,6 +4730,9 @@ NetPacketError::GetData(NetPacketError::Data &outData) const case NET_ERR_AVATAR_WRONG_SIZE : outData.errorCode = ERR_NET_WRONG_AVATAR_SIZE; break; + case NET_ERR_AVATAR_UPLOAD_BLOCKED : + outData.errorCode = ERR_NET_AVATAR_UPLOAD_BLOCKED; + break; case NET_ERR_JOIN_GAME_UNKNOWN_GAME : outData.errorCode = ERR_NET_UNKNOWN_GAME; break; @@ -4732,6 +4747,12 @@ NetPacketError::GetData(NetPacketError::Data &outData) const case NET_ERR_GENERAL_PLAYER_KICKED : outData.errorCode = ERR_NET_PLAYER_KICKED; break; + case NET_ERR_GENERAL_PLAYER_BANNED : + outData.errorCode = ERR_NET_PLAYER_BANNED; + break; + case NET_ERR_GENERAL_SESSION_TIMED_OUT : + outData.errorCode = ERR_NET_SESSION_TIMED_OUT; + break; default : outData.errorCode = ERR_SOCK_INTERNAL; break; diff --git a/src/net/common/servergamestate.cpp b/src/net/common/servergamestate.cpp index 76c5f633..4f5d546b 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_PLAYER_KICKED); // TODO use proper error code. + server.RemovePlayer(session.playerData->GetUniqueId(), ERR_NET_SESSION_TIMED_OUT); } } return AbstractServerGameStateReceiving::Process(server); diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index bf5e3d3b..fea3cf77 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -469,7 +469,7 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const NetPacketIn avatarRecentlyRequested = true; } if (avatarRecentlyRequested) - SessionError(session, ERR_NET_INVALID_AVATAR_FILE); + SessionError(session, ERR_NET_AVATAR_UPLOAD_BLOCKED); else RequestPlayerAvatar(session); } @@ -1014,7 +1014,7 @@ ServerLobbyThread::InternalCheckSessionTimeouts(SessionWrapper session) } } if (closeSession) - RemovePlayer(session.playerData->GetUniqueId(), ERR_NET_PLAYER_KICKED); // TODO new error code + RemovePlayer(session.playerData->GetUniqueId(), ERR_NET_SESSION_TIMED_OUT); } void diff --git a/src/net/socket_msg.h b/src/net/socket_msg.h index f6f992fa..f8378fc2 100644 --- a/src/net/socket_msg.h +++ b/src/net/socket_msg.h @@ -60,17 +60,20 @@ #define ERR_NET_NO_CURRENT_PLAYER 116 #define ERR_NET_PLAYER_NOT_ACTIVE 117 #define ERR_NET_PLAYER_KICKED 118 -#define ERR_NET_INVALID_PLAYER_COUNT 119 -#define ERR_NET_TOO_MANY_MANUAL_BLINDS 120 -#define ERR_NET_INVALID_AVATAR_FILE 121 -#define ERR_NET_AVATAR_TOO_LARGE 122 -#define ERR_NET_BUF_INVALID_SIZE 123 -#define ERR_NET_INVALID_REQUEST_ID 124 -#define ERR_NET_WRONG_AVATAR_SIZE 125 -#define ERR_NET_START_TIMEOUT 126 -#define ERR_NET_GAME_TERMINATION_FAILED 127 -#define ERR_NET_INTERNAL_GAME_ERROR 128 -#define ERR_NET_DEALER_NOT_FOUND 129 +#define ERR_NET_PLAYER_BANNED 119 +#define ERR_NET_SESSION_TIMED_OUT 120 +#define ERR_NET_INVALID_PLAYER_COUNT 121 +#define ERR_NET_TOO_MANY_MANUAL_BLINDS 122 +#define ERR_NET_INVALID_AVATAR_FILE 123 +#define ERR_NET_AVATAR_TOO_LARGE 124 +#define ERR_NET_BUF_INVALID_SIZE 125 +#define ERR_NET_INVALID_REQUEST_ID 126 +#define ERR_NET_WRONG_AVATAR_SIZE 127 +#define ERR_NET_START_TIMEOUT 128 +#define ERR_NET_GAME_TERMINATION_FAILED 129 +#define ERR_NET_INTERNAL_GAME_ERROR 130 +#define ERR_NET_DEALER_NOT_FOUND 131 +#define ERR_NET_AVATAR_UPLOAD_BLOCKED 132 #define ERR_IRC_INTERNAL 151 #define ERR_IRC_CONNECT_FAILED 152