fixed server crash bug
This commit is contained in:
parent
b1e8f08ebe
commit
9c4264b491
5 changed files with 7 additions and 3 deletions
|
@ -65,7 +65,7 @@ void GameSelector::checkResponse(ResponseCode response)
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case RespWrongPassword: QMessageBox::critical(this, tr("Error"), tr("Wrong password.")); break;
|
case RespWrongPassword: QMessageBox::critical(this, tr("Error"), tr("Wrong password.")); break;
|
||||||
case RespSpectatorsNotAllowed: QMessageBox::critical(this, tr("Error"), tr("Spectators are not allowed in this game.")); break;
|
case RespSpectatorsNotAllowed: QMessageBox::critical(this, tr("Error"), tr("Spectators are not allowed in this game.")); break;
|
||||||
case RespContextError: QMessageBox::critical(this, tr("Error"), tr("The game is already full.")); break;
|
case RespGameFull: QMessageBox::critical(this, tr("Error"), tr("The game is already full.")); break;
|
||||||
case RespNameNotFound: QMessageBox::critical(this, tr("Error"), tr("The game does not exist any more.")); break;
|
case RespNameNotFound: QMessageBox::critical(this, tr("Error"), tr("The game does not exist any more.")); break;
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,6 +144,7 @@ void ProtocolResponse::initializeHash()
|
||||||
responseHash.insert("login_needed", RespLoginNeeded);
|
responseHash.insert("login_needed", RespLoginNeeded);
|
||||||
responseHash.insert("function_not_allowed", RespFunctionNotAllowed);
|
responseHash.insert("function_not_allowed", RespFunctionNotAllowed);
|
||||||
responseHash.insert("game_not_started", RespGameNotStarted);
|
responseHash.insert("game_not_started", RespGameNotStarted);
|
||||||
|
responseHash.insert("game_full", RespGameFull);
|
||||||
responseHash.insert("context_error", RespContextError);
|
responseHash.insert("context_error", RespContextError);
|
||||||
responseHash.insert("wrong_password", RespWrongPassword);
|
responseHash.insert("wrong_password", RespWrongPassword);
|
||||||
responseHash.insert("spectators_not_allowed", RespSpectatorsNotAllowed);
|
responseHash.insert("spectators_not_allowed", RespSpectatorsNotAllowed);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
class DeckList;
|
class DeckList;
|
||||||
|
|
||||||
enum ResponseCode { RespNothing, RespOk, RespInvalidCommand, RespInvalidData, RespNameNotFound, RespLoginNeeded, RespFunctionNotAllowed, RespGameNotStarted, RespContextError, RespWrongPassword, RespSpectatorsNotAllowed };
|
enum ResponseCode { RespNothing, RespOk, RespInvalidCommand, RespInvalidData, RespNameNotFound, RespLoginNeeded, RespFunctionNotAllowed, RespGameNotStarted, RespGameFull, RespContextError, RespWrongPassword, RespSpectatorsNotAllowed };
|
||||||
|
|
||||||
// PrivateZone: Contents of the zone are always visible to the owner,
|
// PrivateZone: Contents of the zone are always visible to the owner,
|
||||||
// but not to anyone else.
|
// but not to anyone else.
|
||||||
|
|
|
@ -156,7 +156,7 @@ ResponseCode Server_Game::checkJoin(const QString &_password, bool spectator)
|
||||||
if (!spectatorsAllowed)
|
if (!spectatorsAllowed)
|
||||||
return RespSpectatorsNotAllowed;
|
return RespSpectatorsNotAllowed;
|
||||||
} else if (gameStarted || (getPlayerCount() >= getMaxPlayers()))
|
} else if (gameStarted || (getPlayerCount() >= getMaxPlayers()))
|
||||||
return RespContextError;
|
return RespGameFull;
|
||||||
|
|
||||||
return RespOk;
|
return RespOk;
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,6 +274,9 @@ ResponseCode Server_ProtocolHandler::cmdCreateGame(Command_CreateGame *cmd)
|
||||||
|
|
||||||
ResponseCode Server_ProtocolHandler::cmdJoinGame(Command_JoinGame *cmd)
|
ResponseCode Server_ProtocolHandler::cmdJoinGame(Command_JoinGame *cmd)
|
||||||
{
|
{
|
||||||
|
if (games.contains(cmd->getGameId()))
|
||||||
|
return RespContextError;
|
||||||
|
|
||||||
Server_Game *g = server->getGame(cmd->getGameId());
|
Server_Game *g = server->getGame(cmd->getGameId());
|
||||||
if (!g)
|
if (!g)
|
||||||
return RespNameNotFound;
|
return RespNameNotFound;
|
||||||
|
|
Loading…
Reference in a new issue