Disable rejoin for players who have been kicked.
This commit is contained in:
@@ -849,7 +849,7 @@ LocalPlayer::LocalPlayer(ConfigFile *c, int id, unsigned uniqueId, PlayerType ty
|
||||
: PlayerInterface(), myConfig(c), currentHand(0), myID(id), myUniqueID(uniqueId), myType(type), myName(name), myAvatar(avatar),
|
||||
myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), logHoleCardsDone(false), myCash(sC), mySet(0), myLastRelativeSet(0), myAction(PLAYER_ACTION_NONE),
|
||||
myButton(mB), myActiveStatus(aS), myStayOnTableStatus(1), myTurn(0), myCardsFlip(0), myRoundStartCash(0), lastMoneyWon(0),
|
||||
sBluff(0), sBluffStatus(false), m_actionTimeoutCounter(0), m_isConnected(false)
|
||||
sBluff(0), sBluffStatus(false), m_actionTimeoutCounter(0), m_isConnected(false), m_isKicked(false)
|
||||
{
|
||||
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!! testing !!!!!!!!!!!!!!!!!!!!!!!!
|
||||
@@ -5104,6 +5104,16 @@ bool LocalPlayer::isConnected() const
|
||||
return m_isConnected;
|
||||
}
|
||||
|
||||
void LocalPlayer::setIsKicked(bool kicked)
|
||||
{
|
||||
m_isKicked = kicked;
|
||||
}
|
||||
|
||||
bool LocalPlayer::isKicked() const
|
||||
{
|
||||
return m_isKicked;
|
||||
}
|
||||
|
||||
bool LocalPlayer::checkIfINeedToShowCards()
|
||||
{
|
||||
std::list<unsigned> playerNeedToShowCardsList = currentHand->getBoard()->getPlayerNeedToShowCards();
|
||||
|
||||
@@ -282,6 +282,8 @@ public:
|
||||
|
||||
void setIsConnected(bool connected);
|
||||
bool isConnected() const;
|
||||
void setIsKicked(bool kicked);
|
||||
bool isKicked() const;
|
||||
|
||||
unsigned getActionTimeoutCounter() const;
|
||||
void incrementActionTimeoutCounter();
|
||||
@@ -333,6 +335,7 @@ private:
|
||||
|
||||
unsigned m_actionTimeoutCounter;
|
||||
bool m_isConnected;
|
||||
bool m_isKicked;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -26,7 +26,7 @@ ClientPlayer::ClientPlayer(ConfigFile *c, int id, unsigned uniqueId, PlayerType
|
||||
: PlayerInterface(), myConfig(c), currentHand(0), myID(id), myUniqueID(uniqueId), myType(type),
|
||||
myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), logHoleCardsDone(false), myCash(sC), mySet(0), myLastRelativeSet(0),
|
||||
myAction(PLAYER_ACTION_NONE), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(true), myTurn(false), myCardsFlip(false), myRoundStartCash(0),
|
||||
lastMoneyWon(0), sBluff(0), sBluffStatus(false), m_isConnected(false)
|
||||
lastMoneyWon(0), sBluff(0), sBluffStatus(false), m_isConnected(false), m_isKicked(false)
|
||||
{
|
||||
myBestHandPosition[0] = myBestHandPosition[1] = myBestHandPosition[2] = myBestHandPosition[3] = myBestHandPosition[4] = 0;
|
||||
myNiveau[0] = myNiveau[1] = myNiveau[2] = 0;
|
||||
@@ -549,6 +549,20 @@ ClientPlayer::isConnected() const
|
||||
return m_isConnected;
|
||||
}
|
||||
|
||||
void
|
||||
ClientPlayer::setIsKicked(bool kicked)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
m_isKicked = kicked;
|
||||
}
|
||||
|
||||
bool
|
||||
ClientPlayer::isKicked() const
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
return m_isKicked;
|
||||
}
|
||||
|
||||
bool ClientPlayer::checkIfINeedToShowCards()
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
|
||||
@@ -135,6 +135,8 @@ public:
|
||||
|
||||
void setIsConnected(bool connected);
|
||||
bool isConnected() const;
|
||||
void setIsKicked(bool kicked);
|
||||
bool isKicked() const;
|
||||
|
||||
bool checkIfINeedToShowCards();
|
||||
|
||||
@@ -182,6 +184,7 @@ private:
|
||||
bool sBluffStatus;
|
||||
|
||||
bool m_isConnected;
|
||||
bool m_isKicked;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -120,6 +120,8 @@ public:
|
||||
|
||||
virtual void setIsConnected(bool connected) =0;
|
||||
virtual bool isConnected() const=0;
|
||||
virtual void setIsKicked(bool kicked) =0;
|
||||
virtual bool isKicked() const=0;
|
||||
|
||||
virtual bool checkIfINeedToShowCards() =0;
|
||||
};
|
||||
|
||||
@@ -375,10 +375,19 @@ ServerGame::InternalEndGame()
|
||||
void
|
||||
ServerGame::InternalKickPlayer(unsigned playerId)
|
||||
{
|
||||
boost::shared_ptr<SessionData> tmpSession = GetSessionManager().GetSessionByUniquePlayerId(playerId);
|
||||
boost::shared_ptr<SessionData> tmpSession(GetSessionManager().GetSessionByUniquePlayerId(playerId));
|
||||
// Only kick if the player was found.
|
||||
if (tmpSession)
|
||||
if (tmpSession) {
|
||||
if (m_game) {
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer(m_game->getPlayerByUniqueId(playerId));
|
||||
if (tmpPlayer) {
|
||||
// Mark the player as kicked, so that he is not allowed to rejoin.
|
||||
tmpPlayer->setIsKicked(true);
|
||||
tmpPlayer->setMyGuid("");
|
||||
}
|
||||
}
|
||||
MoveSessionToLobby(tmpSession, NTF_NET_REMOVED_KICKED);
|
||||
}
|
||||
// KICKING COMPUTER PLAYERS IS BUGGY AND OCCASIONALLY CAUSES A CRASH
|
||||
// Disabled for now.
|
||||
//else
|
||||
@@ -811,7 +820,10 @@ ServerGame::RemoveDisconnectedPlayers()
|
||||
if ((tmpPlayer->getMyType() == PLAYER_TYPE_HUMAN && !GetSessionManager().IsPlayerConnected(tmpPlayer->getMyUniqueID()))
|
||||
|| (tmpPlayer->getMyType() == PLAYER_TYPE_COMPUTER && !IsComputerPlayerActive(tmpPlayer->getMyUniqueID()))) {
|
||||
// Setting player cash to 0 will deactivate the player.
|
||||
//tmpPlayer->setMyCash(0);
|
||||
// The player should only be deactivated if rejoin is not possible.
|
||||
if (tmpPlayer->isKicked() || tmpPlayer->getMyGuid().empty()) {
|
||||
tmpPlayer->setMyCash(0);
|
||||
}
|
||||
tmpPlayer->setIsConnected(false);
|
||||
}
|
||||
++i;
|
||||
|
||||
@@ -905,7 +905,7 @@ ServerLobbyThread::HandlePacket(boost::shared_ptr<SessionData> session, boost::s
|
||||
else if (packet->GetMsg()->present == PokerTHMessage_PR_avatarRequestMessage)
|
||||
HandleNetPacketRetrieveAvatar(session, packet->GetMsg()->choice.avatarRequestMessage);
|
||||
else if (packet->GetMsg()->present == PokerTHMessage_PR_resetTimeoutMessage)
|
||||
{}
|
||||
{}
|
||||
else if (packet->GetMsg()->present == PokerTHMessage_PR_subscriptionRequestMessage) {
|
||||
SubscriptionRequestMessage_t *subscriptionRequest = &packet->GetMsg()->choice.subscriptionRequestMessage;
|
||||
if (subscriptionRequest->subscriptionAction == subscriptionAction_resubscribeGameList)
|
||||
@@ -2207,17 +2207,19 @@ u_int32_t
|
||||
ServerLobbyThread::GetRejoinGameIdForPlayer(const std::string &playerName, const std::string &guid, unsigned &outPlayerUniqueId)
|
||||
{
|
||||
u_int32_t retGameId = 0;
|
||||
GameMap::iterator i = m_gameMap.begin();
|
||||
GameMap::iterator end = m_gameMap.end();
|
||||
while (i != end) {
|
||||
boost::shared_ptr<ServerGame> tmpGame = i->second;
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer = tmpGame->GetPlayerInterfaceFromGame(playerName);
|
||||
if (tmpPlayer && tmpPlayer->getMyGuid() == guid) {
|
||||
retGameId = tmpGame->GetId();
|
||||
outPlayerUniqueId = tmpPlayer->getMyUniqueID();
|
||||
break;
|
||||
if (!guid.empty()) {
|
||||
GameMap::iterator i = m_gameMap.begin();
|
||||
GameMap::iterator end = m_gameMap.end();
|
||||
while (i != end) {
|
||||
boost::shared_ptr<ServerGame> tmpGame = i->second;
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer = tmpGame->GetPlayerInterfaceFromGame(playerName);
|
||||
if (tmpPlayer && tmpPlayer->getMyGuid() == guid) {
|
||||
retGameId = tmpGame->GetId();
|
||||
outPlayerUniqueId = tmpPlayer->getMyUniqueID();
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return retGameId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user