From 4e649450b22b32847b846d6f6abdff0711a67fd6 Mon Sep 17 00:00:00 2001 From: lotodore Date: Sat, 6 Oct 2007 14:16:36 +0000 Subject: [PATCH] The server is now sending the highest set, and the client is no longer calculating it on his own. This should fix some bugs when someone goes all in with the big/small blind. --- docs/net_protocol.txt | 4 +++- src/net/common/clientstate.cpp | 4 +--- src/net/common/netpacket.cpp | 3 +++ src/net/common/servergamestate.cpp | 3 +++ src/net/netpacket.h | 1 + src/net/servergamethread.h | 7 ++++--- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/net_protocol.txt b/docs/net_protocol.txt index 55ab4456..651d9549 100644 --- a/docs/net_protocol.txt +++ b/docs/net_protocol.txt @@ -534,7 +534,7 @@ Server Notification: Player's Action Done 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Message Type = 84 | Message Length = 20 | + | Message Type = 84 | Message Length = 24 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Player ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ @@ -544,6 +544,8 @@ Server Notification: Player's Action Done +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Player Money | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Highest Set | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Additional Game States: 0xF0 - Preflop Small Blind (no action requested) diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index 56f7bab4..f04528a8 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -813,12 +813,10 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptrsetMyAction(actionDoneData.playerAction); tmpPlayer->setMySetAbsolute(actionDoneData.totalPlayerBet); tmpPlayer->setMyCash(actionDoneData.playerMoney); + curGame->getCurrentHand()->getCurrentBeRo()->setHighestSet(actionDoneData.highestSet); curGame->getCurrentHand()->getBoard()->collectSets(); curGame->getCurrentHand()->switchRounds(); - // Update highest set - if (tmpPlayer->getMySet() > curGame->getCurrentHand()->getCurrentBeRo()->getHighestSet()) - curGame->getCurrentHand()->getCurrentBeRo()->setHighestSet(tmpPlayer->getMySet()); //log blinds sets after setting bigblind-button if (isBigBlind) { diff --git a/src/net/common/netpacket.cpp b/src/net/common/netpacket.cpp index 5da475af..58801488 100644 --- a/src/net/common/netpacket.cpp +++ b/src/net/common/netpacket.cpp @@ -341,6 +341,7 @@ struct GCC_PACKED NetPacketPlayersActionDoneData u_int16_t playerAction; u_int32_t totalPlayerBet; u_int32_t playerMoney; + u_int32_t highestSet; }; struct GCC_PACKED NetPacketPlayersActionRejectedData @@ -3067,6 +3068,7 @@ NetPacketPlayersActionDone::SetData(const NetPacketPlayersActionDone::Data &inDa tmpData->playerAction = htons(inData.playerAction); tmpData->totalPlayerBet = htonl(inData.totalPlayerBet); tmpData->playerMoney = htonl(inData.playerMoney); + tmpData->highestSet = htonl(inData.highestSet); // Check the packet - just in case. Check(GetRawData()); @@ -3082,6 +3084,7 @@ NetPacketPlayersActionDone::GetData(NetPacketPlayersActionDone::Data &outData) c outData.playerAction = static_cast(ntohs(tmpData->playerAction)); outData.totalPlayerBet = ntohl(tmpData->totalPlayerBet); outData.playerMoney = ntohl(tmpData->playerMoney); + outData.highestSet = ntohl(tmpData->highestSet); } const NetPacketPlayersActionDone * diff --git a/src/net/common/servergamestate.cpp b/src/net/common/servergamestate.cpp index 95a846b6..52dc8c09 100644 --- a/src/net/common/servergamestate.cpp +++ b/src/net/common/servergamestate.cpp @@ -63,6 +63,7 @@ static void SendPlayerAction(ServerGameThread &server, boost::shared_ptr(player->getMyAction()); actionDoneData.totalPlayerBet = player->getMySet(); actionDoneData.playerMoney = player->getMyCash(); + actionDoneData.highestSet = server.GetGame().getCurrentHand()->getCurrentBeRo()->getHighestSet(); static_cast(notifyActionDone.get())->SetData(actionDoneData); server.SendToAllPlayers(notifyActionDone, SessionData::Game); } @@ -486,6 +487,7 @@ ServerGameStateStartHand::Process(ServerGameThread &server) actionDoneData.playerAction = (PlayerAction)tmpPlayer->getMyAction(); actionDoneData.totalPlayerBet = tmpPlayer->getMySet(); actionDoneData.playerMoney = tmpPlayer->getMyCash(); + actionDoneData.highestSet = server.GetGame().getCurrentHand()->getCurrentBeRo()->getHighestSet(); static_cast(notifySmallBlind.get())->SetData(actionDoneData); server.SendToAllPlayers(notifySmallBlind, SessionData::Game); break; @@ -507,6 +509,7 @@ ServerGameStateStartHand::Process(ServerGameThread &server) actionDoneData.playerAction = (PlayerAction)tmpPlayer->getMyAction(); actionDoneData.totalPlayerBet = tmpPlayer->getMySet(); actionDoneData.playerMoney = tmpPlayer->getMyCash(); + actionDoneData.highestSet = server.GetGame().getCurrentHand()->getCurrentBeRo()->getHighestSet(); static_cast(notifyBigBlind.get())->SetData(actionDoneData); server.SendToAllPlayers(notifyBigBlind, SessionData::Game); break; diff --git a/src/net/netpacket.h b/src/net/netpacket.h index 1300be41..79fdf14d 100644 --- a/src/net/netpacket.h +++ b/src/net/netpacket.h @@ -795,6 +795,7 @@ public: PlayerAction playerAction; u_int32_t totalPlayerBet; u_int32_t playerMoney; + u_int32_t highestSet; }; NetPacketPlayersActionDone(); diff --git a/src/net/servergamethread.h b/src/net/servergamethread.h index c664be57..ea4807e2 100644 --- a/src/net/servergamethread.h +++ b/src/net/servergamethread.h @@ -68,6 +68,10 @@ public: bool IsRunning() const; + // should be protected, but is needed in function. + const Game &GetGame() const; + Game &GetGame(); + protected: typedef std::deque SessionQueue; @@ -100,9 +104,6 @@ protected: SenderThread &GetSender(); ReceiverHelper &GetReceiver(); - Game &GetGame(); - const Game &GetGame() const; - const StartData &GetStartData() const; void SetStartData(const StartData &startData);