Transfer small blind and minimum raise amount to client.

This commit is contained in:
lotodore
2007-10-07 22:49:07 +00:00
parent 0547b7b37f
commit d11b35a1a7
7 changed files with 36 additions and 4 deletions
+6 -2
View File
@@ -489,10 +489,12 @@ Server Notification: Hand Start
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 = 81 | Message Length = 8 |
| Message Type = 81 | Message Length = 12 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Your 1st Card | Your 2nd Card |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Small Blind |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Card:
0 to 51
@@ -503,10 +505,12 @@ Server Request/Notification: Player's Turn
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 = 82 | Message Length = 8 |
| Message Type = 82 | Message Length = 16 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Player ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Minimum Raise |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Game State | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+2
View File
@@ -815,6 +815,7 @@ ClientStateWaitHand::InternalProcess(ClientThread &client, boost::shared_ptr<Net
myCards[1] = (int)tmpData.yourCards[1];
client.GetGame()->getSeatsList()->front()->setMyCards(myCards);
client.GetGame()->initHand();
client.GetGame()->getCurrentHand()->setSmallBlind(tmpData.smallBlind);
client.GetGame()->startHand();
client.GetGui().dealHoleCards();
client.GetGui().refreshGameLabels(GAME_STATE_PREFLOP);
@@ -952,6 +953,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptr<NetP
// Next player's turn.
curGame->getCurrentHand()->getCurrentBeRo()->setCurrentPlayersTurnId(tmpPlayer->getMyID());
curGame->getCurrentHand()->getCurrentBeRo()->setMinimumRaise(turnData.minimumRaise);
// TODO: remove this
curGame->getCurrentHand()->getCurrentBeRo()->setPlayersTurn(tmpPlayer->getMyID());
+6
View File
@@ -322,12 +322,14 @@ struct GCC_PACKED NetPacketHandStartData
NetPacketHeader head;
u_int16_t yourCard1;
u_int16_t yourCard2;
u_int32_t smallBlind;
};
struct GCC_PACKED NetPacketPlayersTurnData
{
NetPacketHeader head;
u_int32_t playerId;
u_int32_t minimumRaise;
u_int16_t gameState;
u_int16_t reserved;
};
@@ -2923,6 +2925,7 @@ NetPacketHandStart::SetData(const NetPacketHandStart::Data &inData)
tmpData->yourCard1 = htons(inData.yourCards[0]);
tmpData->yourCard2 = htons(inData.yourCards[1]);
tmpData->smallBlind = htonl(inData.smallBlind);
// Check the packet - just in case.
Check(GetRawData());
@@ -2935,6 +2938,7 @@ NetPacketHandStart::GetData(NetPacketHandStart::Data &outData) const
outData.yourCards[0] = ntohs(tmpData->yourCard1);
outData.yourCards[1] = ntohs(tmpData->yourCard2);
outData.smallBlind = ntohl(tmpData->smallBlind);
}
const NetPacketHandStart *
@@ -2985,6 +2989,7 @@ NetPacketPlayersTurn::SetData(const NetPacketPlayersTurn::Data &inData)
tmpData->playerId = htonl(inData.playerId);
tmpData->gameState = htons(inData.gameState);
tmpData->minimumRaise = htonl(inData.minimumRaise);
// Check the packet - just in case.
Check(GetRawData());
@@ -2997,6 +3002,7 @@ NetPacketPlayersTurn::GetData(NetPacketPlayersTurn::Data &outData) const
outData.playerId = ntohl(tmpData->playerId);
outData.gameState = static_cast<GameState>(ntohs(tmpData->gameState));
outData.minimumRaise = ntohl(tmpData->minimumRaise);
}
const NetPacketPlayersTurn *
+3 -2
View File
@@ -419,6 +419,7 @@ ServerGameStateWaitAck::InternalProcess(ServerGameThread &server, SessionWrapper
if (server.GetSessionManager().CountReadySessions() == server.GetSessionManager().GetRawSessionCount())
{
// Everyone is ready.
server.GetSessionManager().ResetAllReadyFlags();
server.SetState(SERVER_START_GAME_STATE::Instance());
retVal = MSG_SOCK_INIT_DONE;
}
@@ -505,8 +506,6 @@ ServerGameStateStartHand::~ServerGameStateStartHand()
int
ServerGameStateStartHand::Process(ServerGameThread &server)
{
boost::shared_ptr<NetPacket> answer(new NetPacketHandStart);
// Initialize hand.
Game &curGame = server.GetGame();
curGame.initHand();
@@ -533,6 +532,7 @@ ServerGameStateStartHand::Process(ServerGameThread &server)
NetPacketHandStart::Data handStartData;
handStartData.yourCards[0] = static_cast<unsigned>(cards[0]);
handStartData.yourCards[1] = static_cast<unsigned>(cards[1]);
handStartData.smallBlind = curGame.getCurrentHand()->getSmallBlind();
static_cast<NetPacketHandStart *>(notifyCards.get())->SetData(handStartData);
server.GetSender().Send(tmpPlayer->getNetSessionData()->GetSocket(), notifyCards);
@@ -690,6 +690,7 @@ ServerGameStateStartRound::Process(ServerGameThread &server)
NetPacketPlayersTurn::Data playersTurnData;
playersTurnData.gameState = (GameState)curGame.getCurrentHand()->getActualRound();
playersTurnData.playerId = curPlayer->getMyUniqueID();
playersTurnData.minimumRaise = curGame.getCurrentHand()->getCurrentBeRo()->getMinimumRaise();
static_cast<NetPacketPlayersTurn *>(notification.get())->SetData(playersTurnData);
server.SendToAllPlayers(notification, SessionData::Game);
+15
View File
@@ -310,6 +310,21 @@ SessionManager::CountReadySessions() const
return counter;
}
void
SessionManager::ResetAllReadyFlags()
{
boost::mutex::scoped_lock lock(m_sessionMapMutex);
SessionMap::iterator i = m_sessionMap.begin();
SessionMap::iterator end = m_sessionMap.end();
while (i != end)
{
(*i).second.sessionData->ResetReadyFlag();
++i;
}
}
void
SessionManager::Clear()
{
+2
View File
@@ -737,6 +737,7 @@ public:
struct Data
{
u_int16_t yourCards[2];
u_int32_t smallBlind;
};
NetPacketHandStart();
@@ -761,6 +762,7 @@ public:
{
GameState gameState;
u_int32_t playerId;
u_int32_t minimumRaise;
};
NetPacketPlayersTurn();
+2
View File
@@ -64,7 +64,9 @@ public:
bool IsPlayerConnected(unsigned uniqueId) const;
void ForEach(boost::function<void (SessionWrapper)> func);
unsigned CountReadySessions() const;
void ResetAllReadyFlags();
void Clear();
unsigned GetRawSessionCount();