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 :
|
case joinGameFailureReason_invalidPassword :
|
||||||
failureCode = NTF_NET_JOIN_INVALID_PASSWORD;
|
failureCode = NTF_NET_JOIN_INVALID_PASSWORD;
|
||||||
break;
|
break;
|
||||||
|
case joinGameFailureReason_notAllowedAsGuest :
|
||||||
|
failureCode = NTF_NET_JOIN_GUEST_FORBIDDEN;
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
failureCode = NTF_NET_INTERNAL;
|
failureCode = NTF_NET_INTERNAL;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1261,22 +1261,31 @@ ServerLobbyThread::HandleNetPacketCreateGame(SessionWrapper session, const std::
|
|||||||
// Create a new game.
|
// Create a new game.
|
||||||
GameData tmpData;
|
GameData tmpData;
|
||||||
NetPacket::GetGameData(&newGame.gameInfo, tmpData);
|
NetPacket::GetGameData(&newGame.gameInfo, tmpData);
|
||||||
boost::shared_ptr<ServerGame> game(
|
|
||||||
new ServerGame(
|
|
||||||
shared_from_this(),
|
|
||||||
GetNextGameId(),
|
|
||||||
STL_STRING_FROM_OCTET_STRING(newGame.gameInfo.gameName),
|
|
||||||
password,
|
|
||||||
tmpData,
|
|
||||||
session.playerData->GetUniqueId(),
|
|
||||||
GetGui(),
|
|
||||||
m_playerConfig));
|
|
||||||
game->Init();
|
|
||||||
|
|
||||||
// Add game to list of games.
|
if (session.playerData->GetRights() == PLAYER_RIGHTS_GUEST
|
||||||
InternalAddGame(game);
|
&& tmpData.gameType != GAME_TYPE_NORMAL)
|
||||||
|
{
|
||||||
|
SendJoinGameFailed(session.sessionData, NTF_NET_JOIN_GUEST_FORBIDDEN);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
boost::shared_ptr<ServerGame> game(
|
||||||
|
new ServerGame(
|
||||||
|
shared_from_this(),
|
||||||
|
GetNextGameId(),
|
||||||
|
STL_STRING_FROM_OCTET_STRING(newGame.gameInfo.gameName),
|
||||||
|
password,
|
||||||
|
tmpData,
|
||||||
|
session.playerData->GetUniqueId(),
|
||||||
|
GetGui(),
|
||||||
|
m_playerConfig));
|
||||||
|
game->Init();
|
||||||
|
|
||||||
MoveSessionToGame(*game, session);
|
// Add game to list of games.
|
||||||
|
InternalAddGame(game);
|
||||||
|
|
||||||
|
MoveSessionToGame(*game, session);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1287,15 +1296,22 @@ ServerLobbyThread::HandleNetPacketJoinGame(SessionWrapper session, const std::st
|
|||||||
|
|
||||||
if (pos != m_gameMap.end())
|
if (pos != m_gameMap.end())
|
||||||
{
|
{
|
||||||
|
bool joinGame = true;
|
||||||
ServerGame &game = *pos->second;
|
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);
|
SendJoinGameFailed(session.sessionData, NTF_NET_JOIN_INVALID_PASSWORD);
|
||||||
|
joinGame = false;
|
||||||
}
|
}
|
||||||
|
if (joinGame)
|
||||||
|
MoveSessionToGame(game, session);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1779,6 +1795,9 @@ ServerLobbyThread::SendJoinGameFailed(boost::shared_ptr<SessionData> s, int reas
|
|||||||
case NTF_NET_JOIN_INVALID_PASSWORD :
|
case NTF_NET_JOIN_INVALID_PASSWORD :
|
||||||
joinFailed->joinGameFailureReason = joinGameFailureReason_invalidPassword;
|
joinFailed->joinGameFailureReason = joinGameFailureReason_invalidPassword;
|
||||||
break;
|
break;
|
||||||
|
case NTF_NET_JOIN_GUEST_FORBIDDEN :
|
||||||
|
joinFailed->joinGameFailureReason = joinGameFailureReason_notAllowedAsGuest;
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
joinFailed->joinGameFailureReason = joinGameFailureReason_invalidGame;
|
joinFailed->joinGameFailureReason = joinGameFailureReason_invalidGame;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user