Fixed id bug in networking code. Dealer id is now set correctly. Phew.
This commit is contained in:
@@ -527,7 +527,7 @@ ClientStateWaitHand::Process(ClientThread &client)
|
||||
{
|
||||
if (tmpData.gameState == GAME_STATE_PREFLOP_SMALL_BLIND)
|
||||
{
|
||||
tmpPlayer->setMyButton(BUTTON_SMALL_BLIND);
|
||||
assert(tmpPlayer->getMyButton() == BUTTON_SMALL_BLIND);
|
||||
tmpPlayer->setMyAction(tmpData.playerAction);
|
||||
tmpPlayer->setMySet(tmpData.cashValue);
|
||||
client.GetGui().refreshSet();
|
||||
@@ -535,7 +535,7 @@ ClientStateWaitHand::Process(ClientThread &client)
|
||||
}
|
||||
else if (tmpData.gameState == GAME_STATE_PREFLOP_BIG_BLIND)
|
||||
{
|
||||
tmpPlayer->setMyButton(BUTTON_BIG_BLIND);
|
||||
assert(tmpPlayer->getMyButton() == BUTTON_BIG_BLIND);
|
||||
tmpPlayer->setMyAction(tmpData.playerAction);
|
||||
tmpPlayer->setMySet(tmpData.cashValue);
|
||||
client.GetGui().refreshSet();
|
||||
|
||||
@@ -291,33 +291,33 @@ ServerRecvStateStartHand::Process(ServerRecvThread &server)
|
||||
// Auto small blind / big blind at the beginning of preflop.
|
||||
for (int i = 0; i < curGame.getActualQuantityPlayers(); i++)
|
||||
{
|
||||
if(playerArray[i]->getMyButton() == BUTTON_SMALL_BLIND)
|
||||
{
|
||||
boost::shared_ptr<NetPacket> notifySmallBlind(new NetPacketPlayersActionDone);
|
||||
NetPacketPlayersActionDone::Data actionDoneData;
|
||||
actionDoneData.gameState = GAME_STATE_PREFLOP_SMALL_BLIND;
|
||||
actionDoneData.playerId = playerArray[i]->getMyUniqueID();
|
||||
actionDoneData.playerAction = (PlayerAction)playerArray[i]->getMyAction();
|
||||
actionDoneData.cashValue = playerArray[i]->getMySet();
|
||||
static_cast<NetPacketPlayersActionDone *>(notifySmallBlind.get())->SetData(actionDoneData);
|
||||
server.SendToAllPlayers(notifySmallBlind);
|
||||
break;
|
||||
}
|
||||
if(playerArray[i]->getMyButton() == BUTTON_SMALL_BLIND)
|
||||
{
|
||||
boost::shared_ptr<NetPacket> notifySmallBlind(new NetPacketPlayersActionDone);
|
||||
NetPacketPlayersActionDone::Data actionDoneData;
|
||||
actionDoneData.gameState = GAME_STATE_PREFLOP_SMALL_BLIND;
|
||||
actionDoneData.playerId = playerArray[i]->getMyUniqueID();
|
||||
actionDoneData.playerAction = (PlayerAction)playerArray[i]->getMyAction();
|
||||
actionDoneData.cashValue = playerArray[i]->getMySet();
|
||||
static_cast<NetPacketPlayersActionDone *>(notifySmallBlind.get())->SetData(actionDoneData);
|
||||
server.SendToAllPlayers(notifySmallBlind);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < curGame.getActualQuantityPlayers(); i++)
|
||||
{
|
||||
if(playerArray[i]->getMyButton() == BUTTON_BIG_BLIND)
|
||||
{
|
||||
boost::shared_ptr<NetPacket> notifyBigBlind(new NetPacketPlayersActionDone);
|
||||
NetPacketPlayersActionDone::Data actionDoneData;
|
||||
actionDoneData.gameState = GAME_STATE_PREFLOP_BIG_BLIND;
|
||||
actionDoneData.playerId = playerArray[i]->getMyUniqueID();
|
||||
actionDoneData.playerAction = (PlayerAction)playerArray[i]->getMyAction();
|
||||
actionDoneData.cashValue = playerArray[i]->getMySet();
|
||||
static_cast<NetPacketPlayersActionDone *>(notifyBigBlind.get())->SetData(actionDoneData);
|
||||
server.SendToAllPlayers(notifyBigBlind);
|
||||
break;
|
||||
}
|
||||
if(playerArray[i]->getMyButton() == BUTTON_BIG_BLIND)
|
||||
{
|
||||
boost::shared_ptr<NetPacket> notifyBigBlind(new NetPacketPlayersActionDone);
|
||||
NetPacketPlayersActionDone::Data actionDoneData;
|
||||
actionDoneData.gameState = GAME_STATE_PREFLOP_BIG_BLIND;
|
||||
actionDoneData.playerId = playerArray[i]->getMyUniqueID();
|
||||
actionDoneData.playerAction = (PlayerAction)playerArray[i]->getMyAction();
|
||||
actionDoneData.cashValue = playerArray[i]->getMySet();
|
||||
static_cast<NetPacketPlayersActionDone *>(notifyBigBlind.get())->SetData(actionDoneData);
|
||||
server.SendToAllPlayers(notifyBigBlind);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
server.SetState(ServerRecvStateStartRound::Instance());
|
||||
|
||||
@@ -256,7 +256,26 @@ ServerRecvThread::InternalStartGame()
|
||||
StartData startData;
|
||||
int tmpDealerPos = 0;
|
||||
Tools::getRandNumber(0, GetGameData().numberOfPlayers-1, 1, &tmpDealerPos, 0);
|
||||
startData.startDealerPlayerId = static_cast<unsigned>(tmpDealerPos);
|
||||
// The Player Id is not continuous. Therefore, the start dealer position
|
||||
// needs to be converted to a player Id, and cannot be directly generated
|
||||
// as player Id.
|
||||
PlayerDataList::const_iterator player_i = playerData.begin();
|
||||
PlayerDataList::const_iterator player_end = playerData.end();
|
||||
|
||||
bool randDealerFound = false;
|
||||
while (player_i != player_end)
|
||||
{
|
||||
if ((*player_i)->GetNumber() == tmpDealerPos)
|
||||
{
|
||||
// Get ID of the dealer.
|
||||
startData.startDealerPlayerId = static_cast<unsigned>((*player_i)->GetUniqueId());
|
||||
randDealerFound = true;
|
||||
break;
|
||||
}
|
||||
++player_i;
|
||||
}
|
||||
assert(randDealerFound);
|
||||
|
||||
SetStartData(startData);
|
||||
|
||||
m_game.reset(new Game(&gui, factory, playerData, GetGameData(), GetStartData(), m_curGameId++));
|
||||
|
||||
Reference in New Issue
Block a user