Also check ranking game restrictions on server.

This commit is contained in:
lotodore
2010-08-01 20:15:49 +00:00
parent 002defcead
commit 9e039182ec
7 changed files with 44 additions and 7 deletions
+6 -1
View File
@@ -875,7 +875,12 @@ void startWindowImpl::networkNotification(int notificationId)
tr("You cannot join this type of game as guest."),
QMessageBox::Close); }
break;
case NTF_NET_NEW_RELEASE_AVAILABLE:
case NTF_NET_JOIN_INVALID_SETTINGS:
{ QMessageBox::warning(this, tr("Network Notification"),
tr("The settings are invalid for this type of game."),
QMessageBox::Close); }
break;
case NTF_NET_NEW_RELEASE_AVAILABLE:
{ QMessageBox msgBox(QMessageBox::Information, tr("Network Notification"),
tr("A new release of PokerTH is available.<br>Please go to <a href=\"http://www.pokerth.net/\" target=\"_blank\">http://www.pokerth.net</a> and download the latest version."),
QMessageBox::Close, this);
+3
View File
@@ -1400,6 +1400,9 @@ ClientStateWaitJoin::InternalHandlePacket(boost::shared_ptr<ClientThread> client
case joinGameFailureReason_gameNameInUse :
failureCode = NTF_NET_JOIN_GAME_NAME_IN_USE;
break;
case joinGameFailureReason_invalidSettings :
failureCode = NTF_NET_JOIN_INVALID_SETTINGS;
break;
default :
failureCode = NTF_NET_INTERNAL;
break;
+19
View File
@@ -837,6 +837,25 @@ ServerGame::CheckPassword(const string &password) const
return (password == m_password);
}
bool
ServerGame::CheckSettings(const GameData &data)
{
bool retVal = true;
if (data.gameType == GAME_TYPE_RANKING)
{
if ((data.startMoney != RANKING_GAME_START_CASH)
|| (data.maxNumberOfPlayers != RANKING_GAME_NUMBER_OF_PLAYERS)
|| (data.firstSmallBlind != RANKING_GAME_START_SBLIND)
|| (data.raiseIntervalMode != RAISE_ON_HANDNUMBER)
|| (data.raiseMode != DOUBLE_BLINDS)
|| (data.raiseSmallBlindEveryHandsValue != RANKING_GAME_RAISE_EVERY_HAND))
{
retVal = false;
}
}
return retVal;
}
GuiInterface &
ServerGame::GetGui()
{
+4 -1
View File
@@ -498,7 +498,10 @@ ServerGameStateInit::InternalProcessPacket(boost::shared_ptr<ServerGame> server,
{
StartEventMessage_t *netStartEvent = &packet->GetMsg()->choice.startEventMessage;
// Only admins are allowed to start the game.
if (session.playerData->IsGameAdmin() && netStartEvent->gameId == server->GetId())
if (session.playerData->IsGameAdmin()
&& netStartEvent->gameId == server->GetId()
&& (server->GetGameData().gameType != GAME_TYPE_RANKING // ranking games need to be full
|| server->GetGameData().maxNumberOfPlayers == server->GetCurNumberOfPlayers()))
{
SendStartEvent(*server, netStartEvent->fillWithComputerPlayers);
}
+10 -5
View File
@@ -1331,6 +1331,10 @@ ServerLobbyThread::HandleNetPacketCreateGame(SessionWrapper session, const std::
{
SendJoinGameFailed(session.sessionData, gameId, NTF_NET_JOIN_GUEST_FORBIDDEN);
}
else if (!ServerGame::CheckSettings(tmpData))
{
SendJoinGameFailed(session.sessionData, gameId, NTF_NET_JOIN_INVALID_SETTINGS);
}
else
{
boost::shared_ptr<ServerGame> game(
@@ -1360,28 +1364,26 @@ ServerLobbyThread::HandleNetPacketJoinGame(SessionWrapper session, const std::st
if (pos != m_gameMap.end())
{
bool doJoin = true;
ServerGame &game = *pos->second;
const GameData &tmpData = game.GetGameData();
if (session.playerData->GetRights() == PLAYER_RIGHTS_GUEST
&& tmpData.gameType != GAME_TYPE_NORMAL)
{
SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_GUEST_FORBIDDEN);
doJoin = false;
}
else if (tmpData.gameType == GAME_TYPE_INVITE_ONLY
&& !game.IsPlayerInvited(session.playerData->GetUniqueId()))
{
SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_NOT_INVITED);
doJoin = false;
}
else if (!game.CheckPassword(password))
{
SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_INVALID_PASSWORD);
doJoin = false;
}
if (doJoin)
else
{
MoveSessionToGame(game, session);
}
}
else
{
@@ -1925,6 +1927,9 @@ ServerLobbyThread::SendJoinGameFailed(boost::shared_ptr<SessionData> s, unsigned
case NTF_NET_JOIN_GAME_NAME_IN_USE :
joinFailed->joinGameFailureReason = joinGameFailureReason_gameNameInUse;
break;
case NTF_NET_JOIN_INVALID_SETTINGS :
joinFailed->joinGameFailureReason = joinGameFailureReason_invalidSettings;
break;
default :
joinFailed->joinGameFailureReason = joinGameFailureReason_invalidGame;
break;
+1
View File
@@ -68,6 +68,7 @@ public:
bool IsPasswordProtected() const;
bool CheckPassword(const std::string &password) const;
static bool CheckSettings(const GameData &data);
const GameData &GetGameData() const;
boost::shared_ptr<PlayerData> GetPlayerDataByUniqueId(unsigned playerId) const;
+1
View File
@@ -115,6 +115,7 @@
#define NTF_NET_JOIN_GUEST_FORBIDDEN 214
#define NTF_NET_JOIN_NOT_INVITED 215
#define NTF_NET_JOIN_GAME_NAME_IN_USE 216
#define NTF_NET_JOIN_INVALID_SETTINGS 217
// Notifications - version
#define NTF_NET_NEW_RELEASE_AVAILABLE 220