Fixing problems with join game error messages.
This commit is contained in:
@@ -1276,18 +1276,19 @@ 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);
|
||||||
|
unsigned gameId = GetNextGameId();
|
||||||
|
|
||||||
if (session.playerData->GetRights() == PLAYER_RIGHTS_GUEST
|
if (session.playerData->GetRights() == PLAYER_RIGHTS_GUEST
|
||||||
&& tmpData.gameType != GAME_TYPE_NORMAL)
|
&& tmpData.gameType != GAME_TYPE_NORMAL)
|
||||||
{
|
{
|
||||||
SendJoinGameFailed(session.sessionData, NTF_NET_JOIN_GUEST_FORBIDDEN);
|
SendJoinGameFailed(session.sessionData, gameId, NTF_NET_JOIN_GUEST_FORBIDDEN);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
boost::shared_ptr<ServerGame> game(
|
boost::shared_ptr<ServerGame> game(
|
||||||
new ServerGame(
|
new ServerGame(
|
||||||
shared_from_this(),
|
shared_from_this(),
|
||||||
GetNextGameId(),
|
gameId,
|
||||||
STL_STRING_FROM_OCTET_STRING(newGame.gameInfo.gameName),
|
STL_STRING_FROM_OCTET_STRING(newGame.gameInfo.gameName),
|
||||||
password,
|
password,
|
||||||
tmpData,
|
tmpData,
|
||||||
@@ -1311,32 +1312,32 @@ ServerLobbyThread::HandleNetPacketJoinGame(SessionWrapper session, const std::st
|
|||||||
|
|
||||||
if (pos != m_gameMap.end())
|
if (pos != m_gameMap.end())
|
||||||
{
|
{
|
||||||
bool joinGame = true;
|
bool doJoin = true;
|
||||||
ServerGame &game = *pos->second;
|
ServerGame &game = *pos->second;
|
||||||
const GameData &tmpData = game.GetGameData();
|
const GameData &tmpData = game.GetGameData();
|
||||||
if (session.playerData->GetRights() == PLAYER_RIGHTS_GUEST
|
if (session.playerData->GetRights() == PLAYER_RIGHTS_GUEST
|
||||||
&& tmpData.gameType != GAME_TYPE_NORMAL)
|
&& tmpData.gameType != GAME_TYPE_NORMAL)
|
||||||
{
|
{
|
||||||
SendJoinGameFailed(session.sessionData, NTF_NET_JOIN_GUEST_FORBIDDEN);
|
SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_GUEST_FORBIDDEN);
|
||||||
joinGame = false;
|
doJoin = false;
|
||||||
}
|
}
|
||||||
else if (tmpData.gameType == GAME_TYPE_INVITE_ONLY
|
else if (tmpData.gameType == GAME_TYPE_INVITE_ONLY
|
||||||
&& !game.IsPlayerInvited(session.playerData->GetUniqueId()))
|
&& !game.IsPlayerInvited(session.playerData->GetUniqueId()))
|
||||||
{
|
{
|
||||||
SendJoinGameFailed(session.sessionData, NTF_NET_JOIN_NOT_INVITED);
|
SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_NOT_INVITED);
|
||||||
joinGame = false;
|
doJoin = false;
|
||||||
}
|
}
|
||||||
else if (!game.CheckPassword(password))
|
else if (!game.CheckPassword(password))
|
||||||
{
|
{
|
||||||
SendJoinGameFailed(session.sessionData, NTF_NET_JOIN_INVALID_PASSWORD);
|
SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_INVALID_PASSWORD);
|
||||||
joinGame = false;
|
doJoin = false;
|
||||||
}
|
}
|
||||||
if (joinGame)
|
if (doJoin)
|
||||||
MoveSessionToGame(game, session);
|
MoveSessionToGame(game, session);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SendJoinGameFailed(session.sessionData, NTF_NET_JOIN_GAME_INVALID);
|
SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_GAME_INVALID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1820,12 +1821,12 @@ ServerLobbyThread::SendError(boost::shared_ptr<SessionData> s, int errorCode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerLobbyThread::SendJoinGameFailed(boost::shared_ptr<SessionData> s, int reason)
|
ServerLobbyThread::SendJoinGameFailed(boost::shared_ptr<SessionData> s, unsigned gameId, int reason)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket(NetPacket::Alloc));
|
boost::shared_ptr<NetPacket> packet(new NetPacket(NetPacket::Alloc));
|
||||||
packet->GetMsg()->present = PokerTHMessage_PR_joinGameReplyMessage;
|
packet->GetMsg()->present = PokerTHMessage_PR_joinGameReplyMessage;
|
||||||
JoinGameReplyMessage_t *netJoinReply = &packet->GetMsg()->choice.joinGameReplyMessage;
|
JoinGameReplyMessage_t *netJoinReply = &packet->GetMsg()->choice.joinGameReplyMessage;
|
||||||
netJoinReply->gameId = s->GetGameId();
|
netJoinReply->gameId = gameId;
|
||||||
|
|
||||||
netJoinReply->joinGameResult.present = joinGameResult_PR_joinGameFailed;
|
netJoinReply->joinGameResult.present = joinGameResult_PR_joinGameFailed;
|
||||||
JoinGameFailed_t *joinFailed = &netJoinReply->joinGameResult.choice.joinGameFailed;
|
JoinGameFailed_t *joinFailed = &netJoinReply->joinGameResult.choice.joinGameFailed;
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ protected:
|
|||||||
|
|
||||||
void CloseSession(SessionWrapper session);
|
void CloseSession(SessionWrapper session);
|
||||||
void SendError(boost::shared_ptr<SessionData> s, int errorCode);
|
void SendError(boost::shared_ptr<SessionData> s, int errorCode);
|
||||||
void SendJoinGameFailed(boost::shared_ptr<SessionData> s, int reason);
|
void SendJoinGameFailed(boost::shared_ptr<SessionData> s, unsigned gameId, int reason);
|
||||||
void SendPlayerList(boost::shared_ptr<SessionData> s);
|
void SendPlayerList(boost::shared_ptr<SessionData> s);
|
||||||
void SendGameList(boost::shared_ptr<SessionData> s);
|
void SendGameList(boost::shared_ptr<SessionData> s);
|
||||||
void UpdateStatisticsNumberOfPlayers();
|
void UpdateStatisticsNumberOfPlayers();
|
||||||
|
|||||||
Reference in New Issue
Block a user