Sending error if guest tries to join non-standard game.
This commit is contained in:
@@ -1387,6 +1387,9 @@ ClientStateWaitJoin::InternalHandlePacket(boost::shared_ptr<ClientThread> client
|
||||
case joinGameFailureReason_invalidPassword :
|
||||
failureCode = NTF_NET_JOIN_INVALID_PASSWORD;
|
||||
break;
|
||||
case joinGameFailureReason_notAllowedAsGuest :
|
||||
failureCode = NTF_NET_JOIN_GUEST_FORBIDDEN;
|
||||
break;
|
||||
default :
|
||||
failureCode = NTF_NET_INTERNAL;
|
||||
break;
|
||||
|
||||
@@ -1261,6 +1261,14 @@ ServerLobbyThread::HandleNetPacketCreateGame(SessionWrapper session, const std::
|
||||
// Create a new game.
|
||||
GameData tmpData;
|
||||
NetPacket::GetGameData(&newGame.gameInfo, tmpData);
|
||||
|
||||
if (session.playerData->GetRights() == PLAYER_RIGHTS_GUEST
|
||||
&& tmpData.gameType != GAME_TYPE_NORMAL)
|
||||
{
|
||||
SendJoinGameFailed(session.sessionData, NTF_NET_JOIN_GUEST_FORBIDDEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
boost::shared_ptr<ServerGame> game(
|
||||
new ServerGame(
|
||||
shared_from_this(),
|
||||
@@ -1278,6 +1286,7 @@ ServerLobbyThread::HandleNetPacketCreateGame(SessionWrapper session, const std::
|
||||
|
||||
MoveSessionToGame(*game, session);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::HandleNetPacketJoinGame(SessionWrapper session, const std::string &password, const JoinExistingGame_t &joinGame)
|
||||
@@ -1287,15 +1296,22 @@ ServerLobbyThread::HandleNetPacketJoinGame(SessionWrapper session, const std::st
|
||||
|
||||
if (pos != m_gameMap.end())
|
||||
{
|
||||
bool joinGame = true;
|
||||
ServerGame &game = *pos->second;
|
||||
if (game.CheckPassword(password))
|
||||
const GameData &tmpData = game.GetGameData();
|
||||
if (session.playerData->GetRights() == PLAYER_RIGHTS_GUEST
|
||||
&& tmpData.gameType != GAME_TYPE_NORMAL)
|
||||
{
|
||||
MoveSessionToGame(game, session);
|
||||
SendJoinGameFailed(session.sessionData, NTF_NET_JOIN_GUEST_FORBIDDEN);
|
||||
joinGame = false;
|
||||
}
|
||||
else
|
||||
else if (!game.CheckPassword(password))
|
||||
{
|
||||
SendJoinGameFailed(session.sessionData, NTF_NET_JOIN_INVALID_PASSWORD);
|
||||
joinGame = false;
|
||||
}
|
||||
if (joinGame)
|
||||
MoveSessionToGame(game, session);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1779,6 +1795,9 @@ ServerLobbyThread::SendJoinGameFailed(boost::shared_ptr<SessionData> s, int reas
|
||||
case NTF_NET_JOIN_INVALID_PASSWORD :
|
||||
joinFailed->joinGameFailureReason = joinGameFailureReason_invalidPassword;
|
||||
break;
|
||||
case NTF_NET_JOIN_GUEST_FORBIDDEN :
|
||||
joinFailed->joinGameFailureReason = joinGameFailureReason_notAllowedAsGuest;
|
||||
break;
|
||||
default :
|
||||
joinFailed->joinGameFailureReason = joinGameFailureReason_invalidGame;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user