Also check ranking game restrictions on server.
This commit is contained in:
@@ -875,6 +875,11 @@ void startWindowImpl::networkNotification(int notificationId)
|
|||||||
tr("You cannot join this type of game as guest."),
|
tr("You cannot join this type of game as guest."),
|
||||||
QMessageBox::Close); }
|
QMessageBox::Close); }
|
||||||
break;
|
break;
|
||||||
|
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:
|
case NTF_NET_NEW_RELEASE_AVAILABLE:
|
||||||
{ QMessageBox msgBox(QMessageBox::Information, tr("Network Notification"),
|
{ 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."),
|
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."),
|
||||||
|
|||||||
@@ -1400,6 +1400,9 @@ ClientStateWaitJoin::InternalHandlePacket(boost::shared_ptr<ClientThread> client
|
|||||||
case joinGameFailureReason_gameNameInUse :
|
case joinGameFailureReason_gameNameInUse :
|
||||||
failureCode = NTF_NET_JOIN_GAME_NAME_IN_USE;
|
failureCode = NTF_NET_JOIN_GAME_NAME_IN_USE;
|
||||||
break;
|
break;
|
||||||
|
case joinGameFailureReason_invalidSettings :
|
||||||
|
failureCode = NTF_NET_JOIN_INVALID_SETTINGS;
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
failureCode = NTF_NET_INTERNAL;
|
failureCode = NTF_NET_INTERNAL;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -837,6 +837,25 @@ ServerGame::CheckPassword(const string &password) const
|
|||||||
return (password == m_password);
|
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 &
|
GuiInterface &
|
||||||
ServerGame::GetGui()
|
ServerGame::GetGui()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -498,7 +498,10 @@ ServerGameStateInit::InternalProcessPacket(boost::shared_ptr<ServerGame> server,
|
|||||||
{
|
{
|
||||||
StartEventMessage_t *netStartEvent = &packet->GetMsg()->choice.startEventMessage;
|
StartEventMessage_t *netStartEvent = &packet->GetMsg()->choice.startEventMessage;
|
||||||
// Only admins are allowed to start the game.
|
// 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);
|
SendStartEvent(*server, netStartEvent->fillWithComputerPlayers);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1331,6 +1331,10 @@ ServerLobbyThread::HandleNetPacketCreateGame(SessionWrapper session, const std::
|
|||||||
{
|
{
|
||||||
SendJoinGameFailed(session.sessionData, gameId, NTF_NET_JOIN_GUEST_FORBIDDEN);
|
SendJoinGameFailed(session.sessionData, gameId, NTF_NET_JOIN_GUEST_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
else if (!ServerGame::CheckSettings(tmpData))
|
||||||
|
{
|
||||||
|
SendJoinGameFailed(session.sessionData, gameId, NTF_NET_JOIN_INVALID_SETTINGS);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
boost::shared_ptr<ServerGame> game(
|
boost::shared_ptr<ServerGame> game(
|
||||||
@@ -1360,29 +1364,27 @@ ServerLobbyThread::HandleNetPacketJoinGame(SessionWrapper session, const std::st
|
|||||||
|
|
||||||
if (pos != m_gameMap.end())
|
if (pos != m_gameMap.end())
|
||||||
{
|
{
|
||||||
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, joinGame.gameId, NTF_NET_JOIN_GUEST_FORBIDDEN);
|
SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_GUEST_FORBIDDEN);
|
||||||
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, joinGame.gameId, NTF_NET_JOIN_NOT_INVITED);
|
SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_NOT_INVITED);
|
||||||
doJoin = false;
|
|
||||||
}
|
}
|
||||||
else if (!game.CheckPassword(password))
|
else if (!game.CheckPassword(password))
|
||||||
{
|
{
|
||||||
SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_INVALID_PASSWORD);
|
SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_INVALID_PASSWORD);
|
||||||
doJoin = false;
|
|
||||||
}
|
}
|
||||||
if (doJoin)
|
else
|
||||||
|
{
|
||||||
MoveSessionToGame(game, session);
|
MoveSessionToGame(game, session);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_GAME_INVALID);
|
SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_GAME_INVALID);
|
||||||
@@ -1925,6 +1927,9 @@ ServerLobbyThread::SendJoinGameFailed(boost::shared_ptr<SessionData> s, unsigned
|
|||||||
case NTF_NET_JOIN_GAME_NAME_IN_USE :
|
case NTF_NET_JOIN_GAME_NAME_IN_USE :
|
||||||
joinFailed->joinGameFailureReason = joinGameFailureReason_gameNameInUse;
|
joinFailed->joinGameFailureReason = joinGameFailureReason_gameNameInUse;
|
||||||
break;
|
break;
|
||||||
|
case NTF_NET_JOIN_INVALID_SETTINGS :
|
||||||
|
joinFailed->joinGameFailureReason = joinGameFailureReason_invalidSettings;
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
joinFailed->joinGameFailureReason = joinGameFailureReason_invalidGame;
|
joinFailed->joinGameFailureReason = joinGameFailureReason_invalidGame;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ public:
|
|||||||
|
|
||||||
bool IsPasswordProtected() const;
|
bool IsPasswordProtected() const;
|
||||||
bool CheckPassword(const std::string &password) const;
|
bool CheckPassword(const std::string &password) const;
|
||||||
|
static bool CheckSettings(const GameData &data);
|
||||||
const GameData &GetGameData() const;
|
const GameData &GetGameData() const;
|
||||||
|
|
||||||
boost::shared_ptr<PlayerData> GetPlayerDataByUniqueId(unsigned playerId) const;
|
boost::shared_ptr<PlayerData> GetPlayerDataByUniqueId(unsigned playerId) const;
|
||||||
|
|||||||
@@ -115,6 +115,7 @@
|
|||||||
#define NTF_NET_JOIN_GUEST_FORBIDDEN 214
|
#define NTF_NET_JOIN_GUEST_FORBIDDEN 214
|
||||||
#define NTF_NET_JOIN_NOT_INVITED 215
|
#define NTF_NET_JOIN_NOT_INVITED 215
|
||||||
#define NTF_NET_JOIN_GAME_NAME_IN_USE 216
|
#define NTF_NET_JOIN_GAME_NAME_IN_USE 216
|
||||||
|
#define NTF_NET_JOIN_INVALID_SETTINGS 217
|
||||||
|
|
||||||
// Notifications - version
|
// Notifications - version
|
||||||
#define NTF_NET_NEW_RELEASE_AVAILABLE 220
|
#define NTF_NET_NEW_RELEASE_AVAILABLE 220
|
||||||
|
|||||||
Reference in New Issue
Block a user