Fixed id bug in networking code. Dealer id is now set correctly. Phew.

This commit is contained in:
lotodore
2007-05-22 23:27:21 +00:00
parent b83c86d887
commit 2e12f1bc25
7 changed files with 106 additions and 84 deletions
+3
View File
@@ -51,15 +51,18 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
PlayerDataList::const_iterator player_i = playerDataList.begin();
PlayerDataList::const_iterator player_end = playerDataList.end();
bool dealerFound = false;
while (player_i != player_end)
{
if ((*player_i)->GetUniqueId() == startData.startDealerPlayerId)
{
dealerPosition = (*player_i)->GetNumber();
dealerFound = true;
break;
}
++player_i;
}
assert(dealerFound);
// Board erstellen
actualBoard = myFactory->createBoard();
-2
View File
@@ -61,8 +61,6 @@ public:
void setStartCash(const int& theValue) { startCash = theValue; }
int getStartCash() const { return startCash; }
int getDealerPosition() const { return dealerPosition; }
int getMyGameID() const { return myGameID; }
//Zufgriff Laufvariablen
+2 -2
View File
@@ -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();
+20 -1
View File
@@ -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++));
+2
View File
@@ -26,6 +26,8 @@
#include <net/clientthread.h>
#include <net/serverthread.h>
#include <sstream>
#define NET_CLIENT_TERMINATE_TIMEOUT_MSEC 1000
#define NET_SERVER_TERMINATE_TIMEOUT_MSEC 1000