More shared_ptr in engine to prevent race conditions when accessing client engine from gui. Still incomplete.

This commit is contained in:
lotodore
2011-01-09 14:16:20 +00:00
parent 54bc7aaa8d
commit 3974e7cac5
17 changed files with 95 additions and 94 deletions
+4 -15
View File
@@ -33,8 +33,7 @@ using namespace std;
Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
const PlayerDataList &playerDataList, const GameData &gameData,
const StartData &startData, int gameId, Log* log)
: myFactory(factory), myGui(gui), myLog(log), currentHand(0), currentBoard(0),
startQuantityPlayers(startData.numberOfPlayers),
: myFactory(factory), myGui(gui), myLog(log), startQuantityPlayers(startData.numberOfPlayers),
startCash(gameData.startMoney), startSmallBlind(gameData.firstSmallBlind),
myGameID(gameId), currentSmallBlind(gameData.firstSmallBlind), currentHandID(0), dealerPosition(0), lastHandBlindsRaised(1), lastTimeBlindsRaised(0), myGameData(gameData)
{
@@ -94,7 +93,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
}
// create player objects
boost::shared_ptr<PlayerInterface> tmpPlayer = myFactory->createPlayer(currentBoard, i, uniqueId, type, myName, myAvatarFile, startCash, startQuantityPlayers > i, 0);
boost::shared_ptr<PlayerInterface> tmpPlayer = myFactory->createPlayer(currentBoard.get(), i, uniqueId, type, myName, myAvatarFile, startCash, startQuantityPlayers > i, 0);
tmpPlayer->setNetSessionData(myNetSession);
@@ -119,18 +118,14 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
Game::~Game()
{
delete currentBoard;
currentBoard = 0;
delete currentHand;
currentHand = 0;
}
HandInterface *Game::getCurrentHand()
boost::shared_ptr<HandInterface> Game::getCurrentHand()
{
return currentHand;
}
const HandInterface *Game::getCurrentHand() const
const boost::shared_ptr<HandInterface> Game::getCurrentHand() const
{
return currentHand;
}
@@ -164,12 +159,6 @@ void Game::initHand()
}
}
// delete possible existing hands
if(currentHand) {
delete currentHand;
currentHand = 0;
}
runningPlayerList->clear();
(*runningPlayerList) = (*activePlayerList);