Changed network code for new player lists.
This commit is contained in:
@@ -33,7 +33,6 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
|
|||||||
|
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
PlayerListIterator it;
|
PlayerListIterator it;
|
||||||
PlayerListConstIterator it_c;
|
|
||||||
|
|
||||||
CardsValue myCardsValue;
|
CardsValue myCardsValue;
|
||||||
|
|
||||||
@@ -72,19 +71,19 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
|
|||||||
|
|
||||||
k = 0;
|
k = 0;
|
||||||
myBoard->setMyCards(tempBoardArray);
|
myBoard->setMyCards(tempBoardArray);
|
||||||
for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); it_c++, k++) {
|
for(it=activePlayerList->begin(); it!=activePlayerList->end(); it++, k++) {
|
||||||
|
|
||||||
(*it_c)->getMyBestHandPosition(bestHandPos);
|
(*it)->getMyBestHandPosition(bestHandPos);
|
||||||
|
|
||||||
for(j=0; j<2; j++) {
|
for(j=0; j<2; j++) {
|
||||||
tempPlayerArray[j] = cardsArray[2*k+j+5];
|
tempPlayerArray[j] = cardsArray[2*k+j+5];
|
||||||
tempPlayerAndBoardArray[j] = cardsArray[2*k+j+5];
|
tempPlayerAndBoardArray[j] = cardsArray[2*k+j+5];
|
||||||
}
|
}
|
||||||
|
|
||||||
(*it_c)->setMyCards(tempPlayerArray);
|
(*it)->setMyCards(tempPlayerArray);
|
||||||
(*it_c)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray, bestHandPos));
|
(*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray, bestHandPos));
|
||||||
(*it_c)->setMyBestHandPosition(bestHandPos);
|
(*it)->setMyBestHandPosition(bestHandPos);
|
||||||
(*it_c)->setMyRoundStartCash((*it_c)->getMyCash());
|
(*it)->setMyRoundStartCash((*it)->getMyCash());
|
||||||
|
|
||||||
// myBestHandPosition auf Fehler ueberpruefen
|
// myBestHandPosition auf Fehler ueberpruefen
|
||||||
for(j=0; j<5; j++) {
|
for(j=0; j<5; j++) {
|
||||||
@@ -94,10 +93,10 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sBluff für alle aktiver Spieler außer human player setzen --> TODO for ai-player in internet
|
// sBluff für alle aktiver Spieler außer human player setzen --> TODO for ai-player in internet
|
||||||
if((*it_c)->getMyID() != 0) {
|
if((*it)->getMyID() != 0) {
|
||||||
Tools::getRandNumber(1,100,1,&sBluff,0);
|
Tools::getRandNumber(1,100,1,&sBluff,0);
|
||||||
(*it_c)->setSBluff(sBluff);
|
(*it)->setSBluff(sBluff);
|
||||||
(*it_c)->setSBluffStatus(0);
|
(*it)->setSBluffStatus(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,7 +431,6 @@ void LocalHand::switchRounds() {
|
|||||||
|
|
||||||
// cout << "playerID begin switchRounds(): " << getCurrentBeRo()->get
|
// cout << "playerID begin switchRounds(): " << getCurrentBeRo()->get
|
||||||
|
|
||||||
int i;
|
|
||||||
PlayerListIterator it, it_1;
|
PlayerListIterator it, it_1;
|
||||||
PlayerListConstIterator it_c;
|
PlayerListConstIterator it_c;
|
||||||
|
|
||||||
|
|||||||
@@ -44,12 +44,14 @@ ClientBeRo::setHighestCardsValue(int theValue)
|
|||||||
void
|
void
|
||||||
ClientBeRo::setLastActionPlayer ( int theValue )
|
ClientBeRo::setLastActionPlayer ( int theValue )
|
||||||
{
|
{
|
||||||
|
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||||
lastActionPlayer = theValue;
|
lastActionPlayer = theValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ClientBeRo::getLastActionPlayer() const
|
ClientBeRo::getLastActionPlayer() const
|
||||||
{
|
{
|
||||||
|
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||||
return lastActionPlayer;
|
return lastActionPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,48 +72,56 @@ ClientBeRo::getPlayersTurn() const
|
|||||||
void
|
void
|
||||||
ClientBeRo::setCurrentPlayersTurnIt(PlayerListIterator theValue)
|
ClientBeRo::setCurrentPlayersTurnIt(PlayerListIterator theValue)
|
||||||
{
|
{
|
||||||
|
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||||
currentPlayersTurnIt = theValue;
|
currentPlayersTurnIt = theValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerListIterator
|
PlayerListIterator
|
||||||
ClientBeRo::getCurrentPlayersTurnIt() const
|
ClientBeRo::getCurrentPlayersTurnIt() const
|
||||||
{
|
{
|
||||||
|
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||||
return currentPlayersTurnIt;
|
return currentPlayersTurnIt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientBeRo::setLastPlayersTurnIt(PlayerListIterator theValue)
|
ClientBeRo::setLastPlayersTurnIt(PlayerListIterator theValue)
|
||||||
{
|
{
|
||||||
|
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||||
lastPlayersTurnIt = theValue;
|
lastPlayersTurnIt = theValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerListIterator
|
PlayerListIterator
|
||||||
ClientBeRo::getLastPlayersTurnIt() const
|
ClientBeRo::getLastPlayersTurnIt() const
|
||||||
{
|
{
|
||||||
|
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||||
return lastPlayersTurnIt;
|
return lastPlayersTurnIt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientBeRo::setCurrentPlayersTurnId(unsigned theValue)
|
ClientBeRo::setCurrentPlayersTurnId(unsigned theValue)
|
||||||
{
|
{
|
||||||
|
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||||
currentPlayersTurnId = theValue;
|
currentPlayersTurnId = theValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
ClientBeRo::getCurrentPlayersTurnId() const
|
ClientBeRo::getCurrentPlayersTurnId() const
|
||||||
{
|
{
|
||||||
|
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||||
return currentPlayersTurnId;
|
return currentPlayersTurnId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientBeRo::setFirstRoundLastPlayersTurnId(unsigned theValue)
|
ClientBeRo::setFirstRoundLastPlayersTurnId(unsigned theValue)
|
||||||
{
|
{
|
||||||
|
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||||
firstRoundLastPlayersTurnId = theValue;
|
firstRoundLastPlayersTurnId = theValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
ClientBeRo::getFirstRoundLastPlayersTurnId() const
|
ClientBeRo::getFirstRoundLastPlayersTurnId() const
|
||||||
{
|
{
|
||||||
|
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||||
return firstRoundLastPlayersTurnId;
|
return firstRoundLastPlayersTurnId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,12 +184,14 @@ ClientBeRo::getSmallBlind() const
|
|||||||
void
|
void
|
||||||
ClientBeRo::setMinimumRaise ( int theValue )
|
ClientBeRo::setMinimumRaise ( int theValue )
|
||||||
{
|
{
|
||||||
|
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||||
minimumRaise = theValue;
|
minimumRaise = theValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ClientBeRo::getMinimumRaise() const
|
ClientBeRo::getMinimumRaise() const
|
||||||
{
|
{
|
||||||
|
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||||
return minimumRaise;
|
return minimumRaise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,32 +26,29 @@ ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, Boar
|
|||||||
smallBlind(sB), startCash(sC), lastPlayersTurn(0), allInCondition(0),
|
smallBlind(sB), startCash(sC), lastPlayersTurn(0), allInCondition(0),
|
||||||
cardsShown(false), bettingRoundsPlayed(0)
|
cardsShown(false), bettingRoundsPlayed(0)
|
||||||
{
|
{
|
||||||
activePlayersCounter = activePlayerList->size();
|
PlayerListIterator it;
|
||||||
|
|
||||||
int i;
|
|
||||||
lastPlayersTurn = 0;
|
|
||||||
|
|
||||||
myBoard->setHand(this);
|
myBoard->setHand(this);
|
||||||
|
|
||||||
|
for(it=seatsList->begin(); it!=seatsList->end(); it++) {
|
||||||
for(i=0; i<startQuantityPlayers; i++) {
|
(*it)->setHand(this);
|
||||||
playerArray[i]->setHand(this);
|
|
||||||
// myFlipCards auf 0 setzen
|
// myFlipCards auf 0 setzen
|
||||||
playerArray[i]->setMyCardsFlip(0, 0);
|
(*it)->setMyCardsFlip(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// roundStartCashArray fuellen
|
// roundStartCashArray fuellen
|
||||||
// cardsvalue zuruecksetzen
|
// cardsvalue zuruecksetzen
|
||||||
// remove all buttons
|
// remove all buttons
|
||||||
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
for(it=activePlayerList->begin(); it!=activePlayerList->end(); it++) {
|
||||||
playerArray[i]->setMyRoundStartCash(playerArray[i]->getMyCash());
|
|
||||||
playerArray[i]->setMyCardsValueInt(0);
|
|
||||||
playerArray[i]->setMyButton(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// assign dealer button
|
boost::shared_ptr<PlayerInterface> tmpPlayer = *it;
|
||||||
playerArray[dealerPosition]->setMyButton(1);
|
|
||||||
|
tmpPlayer->setMyRoundStartCash(tmpPlayer->getMyCash());
|
||||||
|
tmpPlayer->setMyCardsValueInt(0);
|
||||||
|
tmpPlayer->setMyButton(0);
|
||||||
|
if (tmpPlayer->getMyUniqueID() == dealerPosition)
|
||||||
|
tmpPlayer->setMyButton(1);
|
||||||
|
}
|
||||||
|
|
||||||
// the rest of the buttons are assigned later as received from the server.
|
// the rest of the buttons are assigned later as received from the server.
|
||||||
|
|
||||||
@@ -127,25 +124,25 @@ ClientHand::getBoard() const
|
|||||||
boost::shared_ptr<BeRoInterface>
|
boost::shared_ptr<BeRoInterface>
|
||||||
ClientHand::getPreflop() const
|
ClientHand::getPreflop() const
|
||||||
{
|
{
|
||||||
return myBeRo[actualRound];
|
return myBeRo[GAME_STATE_PREFLOP];
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<BeRoInterface>
|
boost::shared_ptr<BeRoInterface>
|
||||||
ClientHand::getFlop() const
|
ClientHand::getFlop() const
|
||||||
{
|
{
|
||||||
return myBeRo[actualRound];
|
return myBeRo[GAME_STATE_FLOP];
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<BeRoInterface>
|
boost::shared_ptr<BeRoInterface>
|
||||||
ClientHand::getTurn() const
|
ClientHand::getTurn() const
|
||||||
{
|
{
|
||||||
return myBeRo[actualRound];
|
return myBeRo[GAME_STATE_TURN];
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<BeRoInterface>
|
boost::shared_ptr<BeRoInterface>
|
||||||
ClientHand::getRiver() const
|
ClientHand::getRiver() const
|
||||||
{
|
{
|
||||||
return myBeRo[actualRound];
|
return myBeRo[GAME_STATE_RIVER];
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<BeRoInterface>
|
boost::shared_ptr<BeRoInterface>
|
||||||
@@ -305,10 +302,24 @@ void
|
|||||||
ClientHand::switchRounds()
|
ClientHand::switchRounds()
|
||||||
{
|
{
|
||||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||||
// update active players counter.
|
|
||||||
activePlayersCounter = 0;
|
PlayerListIterator it, it_1;
|
||||||
for (int i = 0; i < MAX_NUMBER_OF_PLAYERS; i++) {
|
|
||||||
if (playerArray[i]->getMyAction() != 1 && playerArray[i]->getMyActiveStatus() == 1) activePlayersCounter++;
|
// refresh runningPlayerList
|
||||||
|
for(it=runningPlayerList->begin(); it!=runningPlayerList->end(); ) {
|
||||||
|
if((*it)->getMyAction() == PLAYER_ACTION_FOLD || (*it)->getMyAction() == PLAYER_ACTION_ALLIN) {
|
||||||
|
it = runningPlayerList->erase(it);
|
||||||
|
if(!(runningPlayerList->empty())) {
|
||||||
|
|
||||||
|
it_1 = it;
|
||||||
|
if(it_1 == runningPlayerList->begin()) it_1 = runningPlayerList->end();
|
||||||
|
it_1--;
|
||||||
|
getCurrentBeRo()->setCurrentPlayersTurnId((*it_1)->getMyUniqueID());
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
it++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,6 @@ class ClientHand : public HandInterface
|
|||||||
int actualRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river
|
int actualRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river
|
||||||
int smallBlind;
|
int smallBlind;
|
||||||
int startCash;
|
int startCash;
|
||||||
int activePlayersCounter;
|
|
||||||
|
|
||||||
int lastPlayersTurn;
|
int lastPlayersTurn;
|
||||||
|
|
||||||
|
|||||||
+11
-16
@@ -50,20 +50,14 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
|||||||
PlayerDataList::const_iterator player_i = playerDataList.begin();
|
PlayerDataList::const_iterator player_i = playerDataList.begin();
|
||||||
PlayerDataList::const_iterator player_end = playerDataList.end();
|
PlayerDataList::const_iterator player_end = playerDataList.end();
|
||||||
|
|
||||||
bool dealerFound = false;
|
|
||||||
i = 0;
|
|
||||||
while (player_i != player_end)
|
while (player_i != player_end)
|
||||||
{
|
{
|
||||||
if ((*player_i)->GetUniqueId() == startData.startDealerPlayerId)
|
if ((*player_i)->GetUniqueId() == startData.startDealerPlayerId)
|
||||||
{
|
|
||||||
dealerPosition = i;
|
|
||||||
dealerFound = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
++player_i;
|
++player_i;
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
assert(dealerFound);
|
assert(player_i != player_end);
|
||||||
|
dealerPosition = startData.startDealerPlayerId;
|
||||||
|
|
||||||
// Board erstellen
|
// Board erstellen
|
||||||
actualBoard = myFactory->createBoard();
|
actualBoard = myFactory->createBoard();
|
||||||
@@ -227,24 +221,25 @@ void Game::startHand()
|
|||||||
|
|
||||||
boost::shared_ptr<PlayerInterface> Game::getPlayerByUniqueId(unsigned id)
|
boost::shared_ptr<PlayerInterface> Game::getPlayerByUniqueId(unsigned id)
|
||||||
{
|
{
|
||||||
// TODO playerLists
|
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer;
|
boost::shared_ptr<PlayerInterface> tmpPlayer;
|
||||||
for (int i = 0; i < startQuantityPlayers; i++)
|
PlayerListIterator i = getSeatsList()->begin();
|
||||||
|
PlayerListIterator end = getSeatsList()->end();
|
||||||
|
while (i != end)
|
||||||
{
|
{
|
||||||
if (playerArray[i]->getMyUniqueID() == id)
|
if ((*i)->getMyUniqueID() == id)
|
||||||
{
|
{
|
||||||
tmpPlayer = playerArray[i];
|
tmpPlayer = *i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
return tmpPlayer;
|
return tmpPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<PlayerInterface> Game::getCurrentPlayer()
|
boost::shared_ptr<PlayerInterface> Game::getCurrentPlayer()
|
||||||
{
|
{
|
||||||
// TODO playerLists
|
boost::shared_ptr<PlayerInterface> tmpPlayer = getPlayerByUniqueId(getCurrentHand()->getCurrentBeRo()->getCurrentPlayersTurnId());
|
||||||
int curPlayerNum = getCurrentHand()->getCurrentBeRo()->getPlayersTurn();
|
assert(tmpPlayer.get());
|
||||||
assert(curPlayerNum < getStartQuantityPlayers());
|
return tmpPlayer;
|
||||||
return getPlayerArray()[curPlayerNum];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -267,11 +267,8 @@ protected:
|
|||||||
|
|
||||||
virtual int InternalProcess(ClientThread &client, boost::shared_ptr<NetPacket> packet);
|
virtual int InternalProcess(ClientThread &client, boost::shared_ptr<NetPacket> packet);
|
||||||
|
|
||||||
static int GetHighestSet(Game &curGame);
|
|
||||||
static void SetHighestSet(Game &curGame, int highestSet);
|
|
||||||
static int GetPlayersTurn(Game &curGame);
|
|
||||||
static void SetPlayersTurn(Game &curGame, int playersTurn);
|
|
||||||
static void ResetPlayerActions(Game &curGame);
|
static void ResetPlayerActions(Game &curGame);
|
||||||
|
static void ResetPlayerSets(Game &curGame);
|
||||||
};
|
};
|
||||||
|
|
||||||
// State: Final (just for testing, should not be used).
|
// State: Final (just for testing, should not be used).
|
||||||
|
|||||||
+28
-109
@@ -694,7 +694,7 @@ ClientStateWaitHand::InternalProcess(ClientThread &client, boost::shared_ptr<Net
|
|||||||
int myCards[2];
|
int myCards[2];
|
||||||
myCards[0] = (int)tmpData.yourCards[0];
|
myCards[0] = (int)tmpData.yourCards[0];
|
||||||
myCards[1] = (int)tmpData.yourCards[1];
|
myCards[1] = (int)tmpData.yourCards[1];
|
||||||
client.GetGame()->getPlayerArray()[0]->setMyCards(myCards);
|
client.GetGame()->getSeatsList()->front()->setMyCards(myCards);
|
||||||
client.GetGame()->initHand();
|
client.GetGame()->initHand();
|
||||||
client.GetGame()->startHand();
|
client.GetGame()->startHand();
|
||||||
client.GetGui().dealHoleCards();
|
client.GetGui().dealHoleCards();
|
||||||
@@ -780,8 +780,8 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
|||||||
curGame->getCurrentHand()->switchRounds();
|
curGame->getCurrentHand()->switchRounds();
|
||||||
|
|
||||||
// Update highest set
|
// Update highest set
|
||||||
if (tmpPlayer->getMySet() > GetHighestSet(*curGame))
|
if (tmpPlayer->getMySet() > curGame->getCurrentHand()->getCurrentBeRo()->getHighestSet())
|
||||||
SetHighestSet(*curGame, tmpPlayer->getMySet());
|
curGame->getCurrentHand()->getCurrentBeRo()->setHighestSet(tmpPlayer->getMySet());
|
||||||
|
|
||||||
// Stop the timeout for the player.
|
// Stop the timeout for the player.
|
||||||
client.GetGui().stopTimeoutAnimation(tmpPlayer->getMyID());
|
client.GetGui().stopTimeoutAnimation(tmpPlayer->getMyID());
|
||||||
@@ -817,7 +817,9 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Next player's turn.
|
// Next player's turn.
|
||||||
SetPlayersTurn(*curGame, tmpPlayer->getMyID());
|
curGame->getCurrentHand()->getCurrentBeRo()->setCurrentPlayersTurnId(tmpPlayer->getMyID());
|
||||||
|
// TODO: remove this
|
||||||
|
curGame->getCurrentHand()->getCurrentBeRo()->setPlayersTurn(tmpPlayer->getMyID());
|
||||||
|
|
||||||
// Mark current player in GUI.
|
// Mark current player in GUI.
|
||||||
int guiStatus = 2;
|
int guiStatus = 2;
|
||||||
@@ -910,8 +912,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
|||||||
{
|
{
|
||||||
curGame->getCurrentHand()->getBoard()->collectPot();
|
curGame->getCurrentHand()->getBoard()->collectPot();
|
||||||
// Reset player sets
|
// Reset player sets
|
||||||
for (int i = 0; i < MAX_NUMBER_OF_PLAYERS; i++)
|
ResetPlayerSets(*curGame);
|
||||||
curGame->getPlayerArray()[i]->setMySetNull();
|
|
||||||
client.GetGui().refreshPot();
|
client.GetGui().refreshPot();
|
||||||
client.GetGui().refreshSet();
|
client.GetGui().refreshSet();
|
||||||
// Synchronize with GUI.
|
// Synchronize with GUI.
|
||||||
@@ -939,8 +940,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
|||||||
{
|
{
|
||||||
curGame->getCurrentHand()->getBoard()->collectPot();
|
curGame->getCurrentHand()->getBoard()->collectPot();
|
||||||
// Reset player sets
|
// Reset player sets
|
||||||
for (int i = 0; i < MAX_NUMBER_OF_PLAYERS; i++)
|
ResetPlayerSets(*curGame);
|
||||||
curGame->getPlayerArray()[i]->setMySetNull();
|
|
||||||
client.GetGui().refreshPot();
|
client.GetGui().refreshPot();
|
||||||
client.GetGui().refreshSet();
|
client.GetGui().refreshSet();
|
||||||
// Synchronize with GUI.
|
// Synchronize with GUI.
|
||||||
@@ -994,113 +994,32 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
ClientStateRunHand::GetHighestSet(Game &curGame)
|
|
||||||
{
|
|
||||||
int highestSet = 0;
|
|
||||||
// TODO: no switch needed here if game states are polymorphic
|
|
||||||
switch(curGame.getCurrentHand()->getActualRound()) {
|
|
||||||
case GAME_STATE_PREFLOP: {
|
|
||||||
highestSet = curGame.getCurrentHand()->getPreflop()->getHighestSet();
|
|
||||||
} break;
|
|
||||||
case GAME_STATE_FLOP: {
|
|
||||||
highestSet = curGame.getCurrentHand()->getFlop()->getHighestSet();
|
|
||||||
} break;
|
|
||||||
case GAME_STATE_TURN: {
|
|
||||||
highestSet = curGame.getCurrentHand()->getTurn()->getHighestSet();
|
|
||||||
} break;
|
|
||||||
case GAME_STATE_RIVER: {
|
|
||||||
highestSet = curGame.getCurrentHand()->getRiver()->getHighestSet();
|
|
||||||
} break;
|
|
||||||
default: {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return highestSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ClientStateRunHand::SetHighestSet(Game &curGame, int highestSet)
|
|
||||||
{
|
|
||||||
// TODO: no switch needed here if game states are polymorphic
|
|
||||||
switch(curGame.getCurrentHand()->getActualRound()) {
|
|
||||||
case GAME_STATE_PREFLOP: {
|
|
||||||
curGame.getCurrentHand()->getPreflop()->setHighestSet(highestSet);
|
|
||||||
} break;
|
|
||||||
case GAME_STATE_FLOP: {
|
|
||||||
curGame.getCurrentHand()->getFlop()->setHighestSet(highestSet);
|
|
||||||
} break;
|
|
||||||
case GAME_STATE_TURN: {
|
|
||||||
curGame.getCurrentHand()->getTurn()->setHighestSet(highestSet);
|
|
||||||
} break;
|
|
||||||
case GAME_STATE_RIVER: {
|
|
||||||
curGame.getCurrentHand()->getRiver()->setHighestSet(highestSet);
|
|
||||||
} break;
|
|
||||||
default: {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
ClientStateRunHand::GetPlayersTurn(Game &curGame)
|
|
||||||
{
|
|
||||||
int playersTurn = 0;
|
|
||||||
// TODO: no switch needed here if game states are polymorphic
|
|
||||||
switch(curGame.getCurrentHand()->getActualRound()) {
|
|
||||||
case GAME_STATE_PREFLOP: {
|
|
||||||
playersTurn = curGame.getCurrentHand()->getPreflop()->getPlayersTurn();
|
|
||||||
} break;
|
|
||||||
case GAME_STATE_FLOP: {
|
|
||||||
playersTurn = curGame.getCurrentHand()->getFlop()->getPlayersTurn();
|
|
||||||
} break;
|
|
||||||
case GAME_STATE_TURN: {
|
|
||||||
playersTurn = curGame.getCurrentHand()->getTurn()->getPlayersTurn();
|
|
||||||
} break;
|
|
||||||
case GAME_STATE_RIVER: {
|
|
||||||
playersTurn = curGame.getCurrentHand()->getRiver()->getPlayersTurn();
|
|
||||||
} break;
|
|
||||||
default: {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return playersTurn;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ClientStateRunHand::SetPlayersTurn(Game &curGame, int playersTurn)
|
|
||||||
{
|
|
||||||
// TODO: no switch needed here if game states are polymorphic
|
|
||||||
switch(curGame.getCurrentHand()->getActualRound()) {
|
|
||||||
case GAME_STATE_PREFLOP: {
|
|
||||||
curGame.getCurrentHand()->getPreflop()->setPlayersTurn(playersTurn);
|
|
||||||
} break;
|
|
||||||
case GAME_STATE_FLOP: {
|
|
||||||
curGame.getCurrentHand()->getFlop()->setPlayersTurn(playersTurn);
|
|
||||||
} break;
|
|
||||||
case GAME_STATE_TURN: {
|
|
||||||
curGame.getCurrentHand()->getTurn()->setPlayersTurn(playersTurn);
|
|
||||||
} break;
|
|
||||||
case GAME_STATE_RIVER: {
|
|
||||||
curGame.getCurrentHand()->getRiver()->setPlayersTurn(playersTurn);
|
|
||||||
} break;
|
|
||||||
default: {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientStateRunHand::ResetPlayerActions(Game &curGame)
|
ClientStateRunHand::ResetPlayerActions(Game &curGame)
|
||||||
{
|
{
|
||||||
// Reset player actions
|
// Reset player actions
|
||||||
for (int i = 0; i < MAX_NUMBER_OF_PLAYERS; i++)
|
PlayerListIterator i = curGame.getSeatsList()->begin();
|
||||||
|
PlayerListIterator end = curGame.getSeatsList()->end();
|
||||||
|
|
||||||
|
while (i != end)
|
||||||
{
|
{
|
||||||
int action = curGame.getPlayerArray()[i]->getMyAction();
|
int action = (*i)->getMyAction();
|
||||||
if (action != 1 && action != 6)
|
if (action != 1 && action != 6)
|
||||||
curGame.getPlayerArray()[i]->setMyAction(0);
|
(*i)->setMyAction(0);
|
||||||
curGame.getPlayerArray()[i]->setMySetNull();
|
(*i)->setMySetNull();
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ClientStateRunHand::ResetPlayerSets(Game &curGame)
|
||||||
|
{
|
||||||
|
PlayerListIterator i = curGame.getSeatsList()->begin();
|
||||||
|
PlayerListIterator end = curGame.getSeatsList()->end();
|
||||||
|
while (i != end)
|
||||||
|
{
|
||||||
|
(*i)->setMySetNull();
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -134,11 +134,12 @@ ClientThread::SendPlayerAction()
|
|||||||
// Create a network packet containing the current player action.
|
// Create a network packet containing the current player action.
|
||||||
boost::shared_ptr<NetPacket> action(new NetPacketPlayersAction);
|
boost::shared_ptr<NetPacket> action(new NetPacketPlayersAction);
|
||||||
NetPacketPlayersAction::Data actionData;
|
NetPacketPlayersAction::Data actionData;
|
||||||
|
boost::shared_ptr<PlayerInterface> myPlayer = GetGame()->getSeatsList()->front();
|
||||||
actionData.gameState = static_cast<GameState>(GetGame()->getCurrentHand()->getActualRound());
|
actionData.gameState = static_cast<GameState>(GetGame()->getCurrentHand()->getActualRound());
|
||||||
actionData.playerAction = static_cast<PlayerAction>(GetGame()->getPlayerArray()[0]->getMyAction());
|
actionData.playerAction = static_cast<PlayerAction>(myPlayer->getMyAction());
|
||||||
// Only send last bet if not fold/checked.
|
// Only send last bet if not fold/checked.
|
||||||
if (actionData.playerAction != PLAYER_ACTION_FOLD && actionData.playerAction != PLAYER_ACTION_CHECK)
|
if (actionData.playerAction != PLAYER_ACTION_FOLD && actionData.playerAction != PLAYER_ACTION_CHECK)
|
||||||
actionData.playerBet = GetGame()->getPlayerArray()[0]->getMyLastRelativeSet();
|
actionData.playerBet = myPlayer->getMyLastRelativeSet();
|
||||||
else
|
else
|
||||||
actionData.playerBet = 0;
|
actionData.playerBet = 0;
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -455,61 +455,75 @@ ServerGameStateStartHand::Process(ServerGameThread &server)
|
|||||||
curGame.getCurrentHand()->getTurn()->resetFirstRun();
|
curGame.getCurrentHand()->getTurn()->resetFirstRun();
|
||||||
curGame.getCurrentHand()->getRiver()->resetFirstRun();
|
curGame.getCurrentHand()->getRiver()->resetFirstRun();
|
||||||
|
|
||||||
std::vector<boost::shared_ptr<PlayerInterface> >playerArray = curGame.getPlayerArray();
|
// Consider all players, even inactive.
|
||||||
|
PlayerListIterator i = curGame.getSeatsList()->begin();
|
||||||
|
PlayerListIterator end = curGame.getSeatsList()->end();
|
||||||
|
|
||||||
// Send cards to all players.
|
// Send cards to all players.
|
||||||
for (int i = 0; i < curGame.getStartQuantityPlayers(); i++)
|
while (i != end)
|
||||||
{
|
{
|
||||||
// also send to inactive players, but not to disconnected players.
|
// also send to inactive players, but not to disconnected players.
|
||||||
if (playerArray[i]->getNetSessionData().get())
|
boost::shared_ptr<PlayerInterface> tmpPlayer = *i;
|
||||||
|
if (tmpPlayer->getNetSessionData().get())
|
||||||
{
|
{
|
||||||
int cards[2];
|
int cards[2];
|
||||||
playerArray[i]->getMyCards(cards);
|
tmpPlayer->getMyCards(cards);
|
||||||
boost::shared_ptr<NetPacket> notifyCards(new NetPacketHandStart);
|
boost::shared_ptr<NetPacket> notifyCards(new NetPacketHandStart);
|
||||||
NetPacketHandStart::Data handStartData;
|
NetPacketHandStart::Data handStartData;
|
||||||
handStartData.yourCards[0] = static_cast<unsigned>(cards[0]);
|
handStartData.yourCards[0] = static_cast<unsigned>(cards[0]);
|
||||||
handStartData.yourCards[1] = static_cast<unsigned>(cards[1]);
|
handStartData.yourCards[1] = static_cast<unsigned>(cards[1]);
|
||||||
static_cast<NetPacketHandStart *>(notifyCards.get())->SetData(handStartData);
|
static_cast<NetPacketHandStart *>(notifyCards.get())->SetData(handStartData);
|
||||||
|
|
||||||
server.GetSender().Send(playerArray[i]->getNetSessionData()->GetSocket(), notifyCards);
|
server.GetSender().Send(tmpPlayer->getNetSessionData()->GetSocket(), notifyCards);
|
||||||
}
|
}
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start hand.
|
// Start hand.
|
||||||
curGame.startHand();
|
curGame.startHand();
|
||||||
|
|
||||||
// Auto small blind / big blind at the beginning of hand.
|
// Auto small blind / big blind at the beginning of hand.
|
||||||
for (int i = 0; i < curGame.getStartQuantityPlayers(); i++)
|
i = curGame.getActivePlayerList()->begin();
|
||||||
|
end = curGame.getActivePlayerList()->end();
|
||||||
|
|
||||||
|
while (i != end)
|
||||||
{
|
{
|
||||||
if(playerArray[i]->getMyButton() == BUTTON_SMALL_BLIND)
|
boost::shared_ptr<PlayerInterface> tmpPlayer = *i;
|
||||||
|
if (tmpPlayer->getMyButton() == BUTTON_SMALL_BLIND)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NetPacket> notifySmallBlind(new NetPacketPlayersActionDone);
|
boost::shared_ptr<NetPacket> notifySmallBlind(new NetPacketPlayersActionDone);
|
||||||
NetPacketPlayersActionDone::Data actionDoneData;
|
NetPacketPlayersActionDone::Data actionDoneData;
|
||||||
actionDoneData.gameState = GAME_STATE_PREFLOP_SMALL_BLIND;
|
actionDoneData.gameState = GAME_STATE_PREFLOP_SMALL_BLIND;
|
||||||
actionDoneData.playerId = playerArray[i]->getMyUniqueID();
|
actionDoneData.playerId = tmpPlayer->getMyUniqueID();
|
||||||
actionDoneData.playerAction = (PlayerAction)playerArray[i]->getMyAction();
|
actionDoneData.playerAction = (PlayerAction)tmpPlayer->getMyAction();
|
||||||
actionDoneData.totalPlayerBet = playerArray[i]->getMySet();
|
actionDoneData.totalPlayerBet = tmpPlayer->getMySet();
|
||||||
actionDoneData.playerMoney = playerArray[i]->getMyCash();
|
actionDoneData.playerMoney = tmpPlayer->getMyCash();
|
||||||
static_cast<NetPacketPlayersActionDone *>(notifySmallBlind.get())->SetData(actionDoneData);
|
static_cast<NetPacketPlayersActionDone *>(notifySmallBlind.get())->SetData(actionDoneData);
|
||||||
server.SendToAllPlayers(notifySmallBlind, SessionData::Game);
|
server.SendToAllPlayers(notifySmallBlind, SessionData::Game);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < curGame.getStartQuantityPlayers(); i++)
|
|
||||||
|
i = curGame.getActivePlayerList()->begin();
|
||||||
|
end = curGame.getActivePlayerList()->end();
|
||||||
|
while (i != end)
|
||||||
{
|
{
|
||||||
if(playerArray[i]->getMyButton() == BUTTON_BIG_BLIND)
|
boost::shared_ptr<PlayerInterface> tmpPlayer = *i;
|
||||||
|
if (tmpPlayer->getMyButton() == BUTTON_BIG_BLIND)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NetPacket> notifyBigBlind(new NetPacketPlayersActionDone);
|
boost::shared_ptr<NetPacket> notifyBigBlind(new NetPacketPlayersActionDone);
|
||||||
NetPacketPlayersActionDone::Data actionDoneData;
|
NetPacketPlayersActionDone::Data actionDoneData;
|
||||||
actionDoneData.gameState = GAME_STATE_PREFLOP_BIG_BLIND;
|
actionDoneData.gameState = GAME_STATE_PREFLOP_BIG_BLIND;
|
||||||
actionDoneData.playerId = playerArray[i]->getMyUniqueID();
|
actionDoneData.playerId = tmpPlayer->getMyUniqueID();
|
||||||
actionDoneData.playerAction = (PlayerAction)playerArray[i]->getMyAction();
|
actionDoneData.playerAction = (PlayerAction)tmpPlayer->getMyAction();
|
||||||
actionDoneData.totalPlayerBet = playerArray[i]->getMySet();
|
actionDoneData.totalPlayerBet = tmpPlayer->getMySet();
|
||||||
actionDoneData.playerMoney = playerArray[i]->getMyCash();
|
actionDoneData.playerMoney = tmpPlayer->getMyCash();
|
||||||
static_cast<NetPacketPlayersActionDone *>(notifyBigBlind.get())->SetData(actionDoneData);
|
static_cast<NetPacketPlayersActionDone *>(notifyBigBlind.get())->SetData(actionDoneData);
|
||||||
server.SendToAllPlayers(notifyBigBlind, SessionData::Game);
|
server.SendToAllPlayers(notifyBigBlind, SessionData::Game);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
server.SetState(ServerGameStateStartRound::Instance());
|
server.SetState(ServerGameStateStartRound::Instance());
|
||||||
@@ -555,19 +569,19 @@ ServerGameStateStartRound::Process(ServerGameThread &server)
|
|||||||
if (newRound != curRound && newRound != GAME_STATE_POST_RIVER)
|
if (newRound != curRound && newRound != GAME_STATE_POST_RIVER)
|
||||||
{
|
{
|
||||||
assert(newRound > curRound);
|
assert(newRound > curRound);
|
||||||
// Retrieve active players. If only one player is left, no cards are shown.
|
// Retrieve non-fold players. If only one player is left, no cards are shown.
|
||||||
std::list<boost::shared_ptr<PlayerInterface> > activePlayers = GetActivePlayers(curGame);
|
PlayerList runningPlayers = curGame.getRunningPlayerList();
|
||||||
|
|
||||||
if (curGame.getCurrentHand()->getAllInCondition()
|
if (curGame.getCurrentHand()->getAllInCondition()
|
||||||
&& !curGame.getCurrentHand()->getCardsShown()
|
&& !curGame.getCurrentHand()->getCardsShown()
|
||||||
&& activePlayers.size() > 1)
|
&& runningPlayers->size() > 1)
|
||||||
{
|
{
|
||||||
// Send cards of all active players to all players (all in).
|
// Send cards of all active players to all players (all in).
|
||||||
boost::shared_ptr<NetPacket> allIn(new NetPacketAllInShowCards);
|
boost::shared_ptr<NetPacket> allIn(new NetPacketAllInShowCards);
|
||||||
NetPacketAllInShowCards::Data allInData;
|
NetPacketAllInShowCards::Data allInData;
|
||||||
|
|
||||||
std::list<boost::shared_ptr<PlayerInterface> >::iterator i = activePlayers.begin();
|
PlayerListConstIterator i = runningPlayers->begin();
|
||||||
std::list<boost::shared_ptr<PlayerInterface> >::iterator end = activePlayers.end();
|
PlayerListConstIterator end = runningPlayers->end();
|
||||||
|
|
||||||
while (i != end)
|
while (i != end)
|
||||||
{
|
{
|
||||||
@@ -625,14 +639,14 @@ ServerGameStateStartRound::Process(ServerGameThread &server)
|
|||||||
// Engine will find out who won.
|
// Engine will find out who won.
|
||||||
curGame.getCurrentHand()->getCurrentBeRo()->postRiverRun();
|
curGame.getCurrentHand()->getCurrentBeRo()->postRiverRun();
|
||||||
|
|
||||||
// Retrieve active players. If only one player is left, no cards are shown.
|
// Retrieve non-fold players. If only one player is left, no cards are shown.
|
||||||
std::list<boost::shared_ptr<PlayerInterface> > activePlayers = GetActivePlayers(curGame);
|
PlayerList runningPlayers = curGame.getRunningPlayerList();
|
||||||
// if (activePlayers.empty()) TODO throw exception
|
// if (runningPlayers.empty()) TODO throw exception
|
||||||
|
|
||||||
if (activePlayers.size() == 1)
|
if (runningPlayers->size() == 1)
|
||||||
{
|
{
|
||||||
// End of Hand, but keep cards hidden.
|
// End of Hand, but keep cards hidden.
|
||||||
boost::shared_ptr<PlayerInterface> player = activePlayers.front();
|
boost::shared_ptr<PlayerInterface> player = runningPlayers->front();
|
||||||
boost::shared_ptr<NetPacket> endHand(new NetPacketEndOfHandHideCards);
|
boost::shared_ptr<NetPacket> endHand(new NetPacketEndOfHandHideCards);
|
||||||
NetPacketEndOfHandHideCards::Data endHandData;
|
NetPacketEndOfHandHideCards::Data endHandData;
|
||||||
endHandData.playerId = player->getMyUniqueID();
|
endHandData.playerId = player->getMyUniqueID();
|
||||||
@@ -648,8 +662,8 @@ ServerGameStateStartRound::Process(ServerGameThread &server)
|
|||||||
boost::shared_ptr<NetPacket> endHand(new NetPacketEndOfHandShowCards);
|
boost::shared_ptr<NetPacket> endHand(new NetPacketEndOfHandShowCards);
|
||||||
NetPacketEndOfHandShowCards::Data endHandData;
|
NetPacketEndOfHandShowCards::Data endHandData;
|
||||||
|
|
||||||
std::list<boost::shared_ptr<PlayerInterface> >::iterator i = activePlayers.begin();
|
PlayerListConstIterator i = runningPlayers->begin();
|
||||||
std::list<boost::shared_ptr<PlayerInterface> >::iterator end = activePlayers.end();
|
PlayerListConstIterator end = runningPlayers->end();
|
||||||
|
|
||||||
while (i != end)
|
while (i != end)
|
||||||
{
|
{
|
||||||
@@ -683,10 +697,15 @@ ServerGameStateStartRound::Process(ServerGameThread &server)
|
|||||||
|
|
||||||
// Start next hand - if enough players are left.
|
// Start next hand - if enough players are left.
|
||||||
int playersPositiveCashCounter = 0;
|
int playersPositiveCashCounter = 0;
|
||||||
for (int i = 0; i < curGame.getStartQuantityPlayers(); i++)
|
|
||||||
|
PlayerListIterator i = curGame.getSeatsList()->begin();
|
||||||
|
PlayerListIterator end = curGame.getSeatsList()->end();
|
||||||
|
|
||||||
|
while (i != end)
|
||||||
{
|
{
|
||||||
if (curGame.getCurrentHand()->getPlayerArray()[i]->getMyCash() > 0)
|
if ((*i)->getMyCash() > 0)
|
||||||
playersPositiveCashCounter++;
|
playersPositiveCashCounter++;
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
if (!playersPositiveCashCounter)
|
if (!playersPositiveCashCounter)
|
||||||
{
|
{
|
||||||
@@ -710,21 +729,6 @@ ServerGameStateStartRound::Process(ServerGameThread &server)
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<boost::shared_ptr<PlayerInterface> >
|
|
||||||
ServerGameStateStartRound::GetActivePlayers(Game &curGame)
|
|
||||||
{
|
|
||||||
std::list<boost::shared_ptr<PlayerInterface> > activePlayers;
|
|
||||||
for (int i = 0; i < curGame.getStartQuantityPlayers() ; i++)
|
|
||||||
{
|
|
||||||
if (curGame.getPlayerArray()[i]->getMyActiveStatus()
|
|
||||||
&& curGame.getPlayerArray()[i]->getMyAction() != PLAYER_ACTION_FOLD)
|
|
||||||
{
|
|
||||||
activePlayers.push_back(curGame.getPlayerArray()[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return activePlayers;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
boost::thread_specific_ptr<ServerGameStateWaitPlayerAction> ServerGameStateWaitPlayerAction::Ptr;
|
boost::thread_specific_ptr<ServerGameStateWaitPlayerAction> ServerGameStateWaitPlayerAction::Ptr;
|
||||||
@@ -1045,11 +1049,14 @@ ServerGameStateNextGameDelay::Process(ServerGameThread &server)
|
|||||||
Game &curGame = server.GetGame();
|
Game &curGame = server.GetGame();
|
||||||
// The game has ended. Notify all clients.
|
// The game has ended. Notify all clients.
|
||||||
boost::shared_ptr<PlayerInterface> winnerPlayer;
|
boost::shared_ptr<PlayerInterface> winnerPlayer;
|
||||||
for (int i = 0; i < curGame.getStartQuantityPlayers(); i++)
|
PlayerListIterator i = curGame.getActivePlayerList()->begin();
|
||||||
|
PlayerListIterator end = curGame.getActivePlayerList()->end();
|
||||||
|
while (i != end)
|
||||||
{
|
{
|
||||||
winnerPlayer = curGame.getCurrentHand()->getPlayerArray()[i];
|
winnerPlayer = *i;
|
||||||
if (winnerPlayer->getMyCash() > 0)
|
if (winnerPlayer->getMyCash() > 0)
|
||||||
break;
|
break;
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<NetPacket> endGame(new NetPacketEndOfGame);
|
boost::shared_ptr<NetPacket> endGame(new NetPacketEndOfGame);
|
||||||
|
|||||||
@@ -302,15 +302,18 @@ ServerGameThread::RemoveDisconnectedPlayers()
|
|||||||
// This should only be called between hands.
|
// This should only be called between hands.
|
||||||
if (m_game.get())
|
if (m_game.get())
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_game->getStartQuantityPlayers(); i++)
|
PlayerListIterator i = m_game->getSeatsList()->begin();
|
||||||
|
PlayerListIterator end = m_game->getSeatsList()->end();
|
||||||
|
while (i != end)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer = m_game->getPlayerArray()[i];
|
boost::shared_ptr<PlayerInterface> tmpPlayer = *i;
|
||||||
if (!GetSessionManager().IsPlayerConnected(tmpPlayer->getMyUniqueID()) && tmpPlayer->getMyType() == PLAYER_TYPE_HUMAN)
|
if (!GetSessionManager().IsPlayerConnected(tmpPlayer->getMyUniqueID()) && tmpPlayer->getMyType() == PLAYER_TYPE_HUMAN)
|
||||||
{
|
{
|
||||||
|
// Setting player cash to 0 will deactivate the player.
|
||||||
tmpPlayer->setMyCash(0);
|
tmpPlayer->setMyCash(0);
|
||||||
tmpPlayer->setMyActiveStatus(false);
|
|
||||||
tmpPlayer->setNetSessionData(boost::shared_ptr<SessionData>());
|
tmpPlayer->setNetSessionData(boost::shared_ptr<SessionData>());
|
||||||
}
|
}
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,8 +196,6 @@ protected:
|
|||||||
// Protected constructor - this is a singleton.
|
// Protected constructor - this is a singleton.
|
||||||
ServerGameStateStartRound();
|
ServerGameStateStartRound();
|
||||||
|
|
||||||
static std::list<boost::shared_ptr<PlayerInterface> > GetActivePlayers(Game &curGame);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static boost::thread_specific_ptr<ServerGameStateStartRound> Ptr;
|
static boost::thread_specific_ptr<ServerGameStateStartRound> Ptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user