boost timer: total_seconds instead of just seconds. Fixed bug where an invalid hand object was accessed. Only set action to "fold" for leaving players if they are active and are not fold.
This commit is contained in:
@@ -41,9 +41,7 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
|
||||
|
||||
|
||||
for(i=0; i<startQuantityPlayers; i++) {
|
||||
if(playerArray[i]->getMyActiveStatus() != 0) {
|
||||
playerArray[i]->setHand(this);
|
||||
}
|
||||
playerArray[i]->setHand(this);
|
||||
// myFlipCards auf 0 setzen
|
||||
playerArray[i]->setMyCardsFlip(0, 0);
|
||||
}
|
||||
|
||||
@@ -103,16 +103,16 @@ public:
|
||||
void setMyCardsValueInt(int theValue) { myCardsValueInt = theValue;}
|
||||
int getMyCardsValueInt() const { return myCardsValueInt; }
|
||||
|
||||
void setMyBestHandPosition(int* theValue)
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
myBestHandPosition[i] = theValue[i];
|
||||
}
|
||||
void getMyBestHandPosition(int* theValue) const
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
theValue[i] = myBestHandPosition[i];
|
||||
}
|
||||
void setMyBestHandPosition(int* theValue)
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
myBestHandPosition[i] = theValue[i];
|
||||
}
|
||||
void getMyBestHandPosition(int* theValue) const
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
theValue[i] = myBestHandPosition[i];
|
||||
}
|
||||
|
||||
void setMyRoundStartCash(int theValue) { myRoundStartCash = theValue;}
|
||||
int getMyRoundStartCash() const { return myRoundStartCash; }
|
||||
|
||||
@@ -34,9 +34,7 @@ ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, Boar
|
||||
|
||||
|
||||
for(i=0; i<startQuantityPlayers; i++) {
|
||||
if(playerArray[i]->getMyActiveStatus() != 0) {
|
||||
playerArray[i]->setHand(this);
|
||||
}
|
||||
playerArray[i]->setHand(this);
|
||||
// myFlipCards auf 0 setzen
|
||||
playerArray[i]->setMyCardsFlip(0, 0);
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ ClientStateConnecting::Process(ClientThread &client)
|
||||
}
|
||||
else if (selectResult == 0) // timeout
|
||||
{
|
||||
if (m_connectTimer.elapsed().seconds() >= CLIENT_CONNECT_TIMEOUT_SEC)
|
||||
if (m_connectTimer.elapsed().total_seconds() >= CLIENT_CONNECT_TIMEOUT_SEC)
|
||||
throw ClientException(ERR_SOCK_CONNECT_TIMEOUT, 0);
|
||||
else
|
||||
retVal = MSG_SOCK_INTERNAL_PENDING;
|
||||
|
||||
@@ -147,7 +147,6 @@ ServerRecvStateReceiving::Process(ServerRecvThread &server)
|
||||
{
|
||||
if (session.sessionData.get())
|
||||
{
|
||||
// TODO: Deactivate player.
|
||||
server.CloseSessionDelayed(session);
|
||||
return retVal;
|
||||
}
|
||||
@@ -737,7 +736,7 @@ ServerRecvStateWaitPlayerAction::Process(ServerRecvThread &server)
|
||||
server.SetState(ServerRecvStateStartRound::Instance());
|
||||
retVal = MSG_NET_GAME_SERVER_ACTION;
|
||||
}
|
||||
else if (GetTimer().elapsed().seconds() >= server.GetGameData().playerActionTimeoutSec + SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC)
|
||||
else if (GetTimer().elapsed().total_seconds() >= server.GetGameData().playerActionTimeoutSec + SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC)
|
||||
{
|
||||
// Player did not act fast enough. Act for him.
|
||||
if (GetHighestSet(server.GetGame()) == tmpPlayer->getMySet())
|
||||
@@ -896,7 +895,7 @@ ServerRecvStateDealCardsDelay::Process(ServerRecvThread &server)
|
||||
delay = SERVER_DEAL_RIVER_CARD_DELAY_SEC;
|
||||
break;
|
||||
}
|
||||
if (!delay || GetTimer().elapsed().seconds() >= delay)
|
||||
if (!delay || GetTimer().elapsed().total_seconds() >= delay)
|
||||
server.SetState(ServerRecvStateStartRound::Instance());
|
||||
|
||||
return retVal;
|
||||
@@ -930,7 +929,7 @@ ServerRecvStateShowCardsDelay::Process(ServerRecvThread &server)
|
||||
{
|
||||
int retVal = ServerRecvStateReceiving::Process(server);
|
||||
|
||||
if (GetTimer().elapsed().seconds() >= SERVER_SHOW_CARDS_DELAY_SEC)
|
||||
if (GetTimer().elapsed().total_seconds() >= SERVER_SHOW_CARDS_DELAY_SEC)
|
||||
{
|
||||
Game &curGame = server.GetGame();
|
||||
SendNewRoundCards(server, curGame, curGame.getCurrentHand()->getActualRound());
|
||||
@@ -970,7 +969,7 @@ ServerRecvStateNextHandDelay::Process(ServerRecvThread &server)
|
||||
{
|
||||
int retVal = ServerRecvStateReceiving::Process(server);
|
||||
|
||||
if (GetTimer().elapsed().seconds() >= SERVER_DELAY_NEXT_HAND_SEC)
|
||||
if (GetTimer().elapsed().total_seconds() >= SERVER_DELAY_NEXT_HAND_SEC)
|
||||
server.SetState(ServerRecvStateStartHand::Instance());
|
||||
|
||||
return retVal;
|
||||
@@ -1004,7 +1003,7 @@ ServerRecvStateNextGameDelay::Process(ServerRecvThread &server)
|
||||
{
|
||||
int retVal = ServerRecvStateReceiving::Process(server);
|
||||
|
||||
if (GetTimer().elapsed().seconds() >= SERVER_DELAY_NEXT_GAME_SEC)
|
||||
if (GetTimer().elapsed().total_seconds() >= SERVER_DELAY_NEXT_GAME_SEC)
|
||||
{
|
||||
Game &curGame = server.GetGame();
|
||||
// The game has ended. Notify all clients.
|
||||
|
||||
@@ -162,7 +162,7 @@ ServerRecvThread::CloseSessionLoop()
|
||||
{
|
||||
CloseSessionList::iterator cur = i++;
|
||||
|
||||
if (cur->first.elapsed().seconds() >= SERVER_CLOSE_SESSION_DELAY_SEC)
|
||||
if (cur->first.elapsed().total_seconds() >= SERVER_CLOSE_SESSION_DELAY_SEC)
|
||||
m_closeSessionList.erase(cur);
|
||||
}
|
||||
}
|
||||
@@ -396,9 +396,14 @@ ServerRecvThread::CloseSessionDelayed(SessionWrapper session)
|
||||
PlayerInterface *player = GetGame().getPlayerByUniqueId(tmpPlayerData->GetUniqueId());
|
||||
if (player)
|
||||
{
|
||||
player->setMyAction(PLAYER_ACTION_FOLD);
|
||||
player->setMyCash(0);
|
||||
player->setMyActiveStatus(false);
|
||||
// Deactivate player (if active).
|
||||
if (player->getMyActiveStatus())
|
||||
{
|
||||
if (player->getMyAction() != PLAYER_ACTION_FOLD)
|
||||
player->setMyAction(PLAYER_ACTION_FOLD);
|
||||
player->setMyCash(0);
|
||||
player->setMyActiveStatus(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user