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:
lotodore
2007-06-14 20:29:59 +00:00
parent 322dc3460b
commit 7345630c0d
6 changed files with 27 additions and 27 deletions
+1 -3
View File
@@ -41,9 +41,7 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardI
for(i=0; i<startQuantityPlayers; i++) { for(i=0; i<startQuantityPlayers; i++) {
if(playerArray[i]->getMyActiveStatus() != 0) { playerArray[i]->setHand(this);
playerArray[i]->setHand(this);
}
// myFlipCards auf 0 setzen // myFlipCards auf 0 setzen
playerArray[i]->setMyCardsFlip(0, 0); playerArray[i]->setMyCardsFlip(0, 0);
} }
+10 -10
View File
@@ -103,16 +103,16 @@ public:
void setMyCardsValueInt(int theValue) { myCardsValueInt = theValue;} void setMyCardsValueInt(int theValue) { myCardsValueInt = theValue;}
int getMyCardsValueInt() const { return myCardsValueInt; } int getMyCardsValueInt() const { return myCardsValueInt; }
void setMyBestHandPosition(int* theValue) void setMyBestHandPosition(int* theValue)
{ {
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
myBestHandPosition[i] = theValue[i]; myBestHandPosition[i] = theValue[i];
} }
void getMyBestHandPosition(int* theValue) const void getMyBestHandPosition(int* theValue) const
{ {
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
theValue[i] = myBestHandPosition[i]; theValue[i] = myBestHandPosition[i];
} }
void setMyRoundStartCash(int theValue) { myRoundStartCash = theValue;} void setMyRoundStartCash(int theValue) { myRoundStartCash = theValue;}
int getMyRoundStartCash() const { return myRoundStartCash; } int getMyRoundStartCash() const { return myRoundStartCash; }
+1 -3
View File
@@ -34,9 +34,7 @@ ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, Boar
for(i=0; i<startQuantityPlayers; i++) { for(i=0; i<startQuantityPlayers; i++) {
if(playerArray[i]->getMyActiveStatus() != 0) { playerArray[i]->setHand(this);
playerArray[i]->setHand(this);
}
// myFlipCards auf 0 setzen // myFlipCards auf 0 setzen
playerArray[i]->setMyCardsFlip(0, 0); playerArray[i]->setMyCardsFlip(0, 0);
} }
+1 -1
View File
@@ -310,7 +310,7 @@ ClientStateConnecting::Process(ClientThread &client)
} }
else if (selectResult == 0) // timeout 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); throw ClientException(ERR_SOCK_CONNECT_TIMEOUT, 0);
else else
retVal = MSG_SOCK_INTERNAL_PENDING; retVal = MSG_SOCK_INTERNAL_PENDING;
+5 -6
View File
@@ -147,7 +147,6 @@ ServerRecvStateReceiving::Process(ServerRecvThread &server)
{ {
if (session.sessionData.get()) if (session.sessionData.get())
{ {
// TODO: Deactivate player.
server.CloseSessionDelayed(session); server.CloseSessionDelayed(session);
return retVal; return retVal;
} }
@@ -737,7 +736,7 @@ ServerRecvStateWaitPlayerAction::Process(ServerRecvThread &server)
server.SetState(ServerRecvStateStartRound::Instance()); server.SetState(ServerRecvStateStartRound::Instance());
retVal = MSG_NET_GAME_SERVER_ACTION; 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. // Player did not act fast enough. Act for him.
if (GetHighestSet(server.GetGame()) == tmpPlayer->getMySet()) if (GetHighestSet(server.GetGame()) == tmpPlayer->getMySet())
@@ -896,7 +895,7 @@ ServerRecvStateDealCardsDelay::Process(ServerRecvThread &server)
delay = SERVER_DEAL_RIVER_CARD_DELAY_SEC; delay = SERVER_DEAL_RIVER_CARD_DELAY_SEC;
break; break;
} }
if (!delay || GetTimer().elapsed().seconds() >= delay) if (!delay || GetTimer().elapsed().total_seconds() >= delay)
server.SetState(ServerRecvStateStartRound::Instance()); server.SetState(ServerRecvStateStartRound::Instance());
return retVal; return retVal;
@@ -930,7 +929,7 @@ ServerRecvStateShowCardsDelay::Process(ServerRecvThread &server)
{ {
int retVal = ServerRecvStateReceiving::Process(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(); Game &curGame = server.GetGame();
SendNewRoundCards(server, curGame, curGame.getCurrentHand()->getActualRound()); SendNewRoundCards(server, curGame, curGame.getCurrentHand()->getActualRound());
@@ -970,7 +969,7 @@ ServerRecvStateNextHandDelay::Process(ServerRecvThread &server)
{ {
int retVal = ServerRecvStateReceiving::Process(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()); server.SetState(ServerRecvStateStartHand::Instance());
return retVal; return retVal;
@@ -1004,7 +1003,7 @@ ServerRecvStateNextGameDelay::Process(ServerRecvThread &server)
{ {
int retVal = ServerRecvStateReceiving::Process(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(); Game &curGame = server.GetGame();
// The game has ended. Notify all clients. // The game has ended. Notify all clients.
+9 -4
View File
@@ -162,7 +162,7 @@ ServerRecvThread::CloseSessionLoop()
{ {
CloseSessionList::iterator cur = i++; 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); m_closeSessionList.erase(cur);
} }
} }
@@ -396,9 +396,14 @@ ServerRecvThread::CloseSessionDelayed(SessionWrapper session)
PlayerInterface *player = GetGame().getPlayerByUniqueId(tmpPlayerData->GetUniqueId()); PlayerInterface *player = GetGame().getPlayerByUniqueId(tmpPlayerData->GetUniqueId());
if (player) if (player)
{ {
player->setMyAction(PLAYER_ACTION_FOLD); // Deactivate player (if active).
player->setMyCash(0); if (player->getMyActiveStatus())
player->setMyActiveStatus(false); {
if (player->getMyAction() != PLAYER_ACTION_FOLD)
player->setMyAction(PLAYER_ACTION_FOLD);
player->setMyCash(0);
player->setMyActiveStatus(false);
}
} }
} }