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
+3 -3
View File
@@ -31,10 +31,10 @@ public:
virtual ~EngineFactory(); virtual ~EngineFactory();
virtual HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) =0; virtual boost::shared_ptr<HandInterface> createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) =0;
virtual BoardInterface* createBoard(unsigned dp) =0; virtual boost::shared_ptr<BoardInterface> createBoard(unsigned dp) =0;
virtual boost::shared_ptr<PlayerInterface> createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) =0; virtual boost::shared_ptr<PlayerInterface> createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) =0;
virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface* hi, int id, unsigned dP, int sB) =0; virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface *hi, int id, unsigned dP, int sB) =0;
}; };
#endif #endif
+3 -3
View File
@@ -40,7 +40,7 @@ public:
virtual PlayerListIterator getActivePlayerIt(unsigned) const =0; virtual PlayerListIterator getActivePlayerIt(unsigned) const =0;
virtual PlayerListIterator getRunningPlayerIt(unsigned) const =0; virtual PlayerListIterator getRunningPlayerIt(unsigned) const =0;
virtual BoardInterface* getBoard() const =0; virtual boost::shared_ptr<BoardInterface> getBoard() const =0;
virtual boost::shared_ptr<BeRoInterface> getPreflop() const =0; virtual boost::shared_ptr<BeRoInterface> getPreflop() const =0;
virtual boost::shared_ptr<BeRoInterface> getFlop() const =0; virtual boost::shared_ptr<BeRoInterface> getFlop() const =0;
virtual boost::shared_ptr<BeRoInterface> getTurn() const =0; virtual boost::shared_ptr<BeRoInterface> getTurn() const =0;
@@ -75,8 +75,8 @@ public:
virtual void setLastPlayersTurn(int theValue) =0; virtual void setLastPlayersTurn(int theValue) =0;
virtual int getLastPlayersTurn() const =0; virtual int getLastPlayersTurn() const =0;
virtual void setLastActionPlayer( unsigned theValue ) =0; virtual void setLastActionPlayer( unsigned theValue ) =0;
virtual unsigned getLastActionPlayer() const =0; virtual unsigned getLastActionPlayer() const =0;
virtual void setCardsShown(bool theValue) =0; virtual void setCardsShown(bool theValue) =0;
virtual bool getCardsShown() const =0; virtual bool getCardsShown() const =0;
+16 -7
View File
@@ -42,18 +42,27 @@ LocalEngineFactory::~LocalEngineFactory()
} }
HandInterface* boost::shared_ptr<HandInterface>
LocalEngineFactory::createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) LocalEngineFactory::createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC)
{ {
return new LocalHand(f, g, b, l, sl, apl, rpl, id, sP, dP, sB, sC); return boost::shared_ptr<HandInterface>(new LocalHand(f, g, b, l, sl, apl, rpl, id, sP, dP, sB, sC));
} }
BoardInterface* LocalEngineFactory::createBoard(unsigned dp) { return new LocalBoard(dp); } boost::shared_ptr<BoardInterface>
LocalEngineFactory::createBoard(unsigned dp)
{
return boost::shared_ptr<BoardInterface>(new LocalBoard(dp));
}
boost::shared_ptr<PlayerInterface> LocalEngineFactory::createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) { return boost::shared_ptr<PlayerInterface> (new LocalPlayer(myConfig, b, id, uniqueId, type, name, avatar, sC, aS, mB)); } boost::shared_ptr<PlayerInterface>
LocalEngineFactory::createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB)
std::vector<boost::shared_ptr<BeRoInterface> > LocalEngineFactory::createBeRo(HandInterface* hi, int id, unsigned dP, int sB) { {
return boost::shared_ptr<PlayerInterface> (new LocalPlayer(myConfig, b, id, uniqueId, type, name, avatar, sC, aS, mB));
}
std::vector<boost::shared_ptr<BeRoInterface> >
LocalEngineFactory::createBeRo(HandInterface *hi, int id, unsigned dP, int sB)
{
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo; std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new LocalBeRoPreflop(hi, id, dP, sB))); myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new LocalBeRoPreflop(hi, id, dP, sB)));
+4 -4
View File
@@ -37,10 +37,10 @@ public:
LocalEngineFactory(ConfigFile*); LocalEngineFactory(ConfigFile*);
~LocalEngineFactory(); ~LocalEngineFactory();
HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC); virtual boost::shared_ptr<HandInterface> createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC);
BoardInterface* createBoard(unsigned dp); virtual boost::shared_ptr<BoardInterface> createBoard(unsigned dp);
boost::shared_ptr<PlayerInterface> createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); virtual boost::shared_ptr<PlayerInterface> createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB);
std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface* hi, int id, unsigned dP, int sB); virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface *hi, int id, unsigned dP, int sB);
private: private:
ConfigFile *myConfig; ConfigFile *myConfig;
+1 -1
View File
@@ -30,7 +30,7 @@
using namespace std; using namespace std;
LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, unsigned dP, int sB,int sC) LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, unsigned dP, int sB,int sC)
: myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), smallBlindPosition(dP), bigBlindPosition(dP), currentRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(-1), lastActionPlayer(0), allInCondition(false), : myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), smallBlindPosition(dP), bigBlindPosition(dP), currentRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(-1), lastActionPlayer(0), allInCondition(false),
cardsShown(false), bettingRoundsPlayed(0) cardsShown(false), bettingRoundsPlayed(0)
{ {
+5 -5
View File
@@ -33,7 +33,7 @@ class Log;
class LocalHand : public HandInterface{ class LocalHand : public HandInterface{
public: public:
LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, Log*, PlayerList, PlayerList, PlayerList, int, int, unsigned, int, int); LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface*, boost::shared_ptr<BoardInterface>, Log*, PlayerList, PlayerList, PlayerList, int, int, unsigned, int, int);
~LocalHand(); ~LocalHand();
void start(); void start();
@@ -46,7 +46,7 @@ public:
PlayerListIterator getActivePlayerIt(unsigned) const; PlayerListIterator getActivePlayerIt(unsigned) const;
PlayerListIterator getRunningPlayerIt(unsigned) const; PlayerListIterator getRunningPlayerIt(unsigned) const;
BoardInterface* getBoard() const { return myBoard; } boost::shared_ptr<BoardInterface> getBoard() const { return myBoard; }
boost::shared_ptr<BeRoInterface> getPreflop() const { return myBeRo[GAME_STATE_PREFLOP]; } boost::shared_ptr<BeRoInterface> getPreflop() const { return myBeRo[GAME_STATE_PREFLOP]; }
boost::shared_ptr<BeRoInterface> getFlop() const { return myBeRo[GAME_STATE_FLOP]; } boost::shared_ptr<BeRoInterface> getFlop() const { return myBeRo[GAME_STATE_FLOP]; }
boost::shared_ptr<BeRoInterface> getTurn() const { return myBeRo[GAME_STATE_TURN]; } boost::shared_ptr<BeRoInterface> getTurn() const { return myBeRo[GAME_STATE_TURN]; }
@@ -81,8 +81,8 @@ public:
void setLastPlayersTurn(int theValue) { lastPlayersTurn = theValue; } void setLastPlayersTurn(int theValue) { lastPlayersTurn = theValue; }
int getLastPlayersTurn() const { return lastPlayersTurn; } int getLastPlayersTurn() const { return lastPlayersTurn; }
void setLastActionPlayer ( unsigned theValue ); void setLastActionPlayer ( unsigned theValue );
unsigned getLastActionPlayer() const { return lastActionPlayer; } unsigned getLastActionPlayer() const { return lastActionPlayer; }
void setCardsShown(bool theValue) { cardsShown = theValue; } void setCardsShown(bool theValue) { cardsShown = theValue; }
bool getCardsShown() const { return cardsShown; } bool getCardsShown() const { return cardsShown; }
@@ -96,7 +96,7 @@ private:
boost::shared_ptr<EngineFactory> myFactory; boost::shared_ptr<EngineFactory> myFactory;
GuiInterface *myGui; GuiInterface *myGui;
BoardInterface *myBoard; boost::shared_ptr<BoardInterface> myBoard;
Log *myLog; Log *myLog;
PlayerList seatsList; // all player PlayerList seatsList; // all player
+3 -3
View File
@@ -37,7 +37,7 @@ public:
~LocalPlayer(); ~LocalPlayer();
void setHand(HandInterface*); void setHand(HandInterface *);
int getMyID() const { return myID; } int getMyID() const { return myID; }
unsigned getMyUniqueID() const { return myUniqueID; } unsigned getMyUniqueID() const { return myUniqueID; }
@@ -77,8 +77,8 @@ public:
void setMyActiveStatus(bool theValue) { myActiveStatus = theValue; } void setMyActiveStatus(bool theValue) { myActiveStatus = theValue; }
bool getMyActiveStatus() const { return myActiveStatus; } bool getMyActiveStatus() const { return myActiveStatus; }
void setMyStayOnTableStatus(bool theValue) { myStayOnTableStatus = theValue; } void setMyStayOnTableStatus(bool theValue) { myStayOnTableStatus = theValue; }
bool getMyStayOnTableStatus() const { return myStayOnTableStatus; } bool getMyStayOnTableStatus() const { return myStayOnTableStatus; }
void setMyCards(int* theValue) { int i; for(i=0; i<2; i++) myCards[i] = theValue[i]; } void setMyCards(int* theValue) { int i; for(i=0; i<2; i++) myCards[i] = theValue[i]; }
void getMyCards(int* theValue) const { int i; for(i=0; i<2; i++) theValue[i] = myCards[i]; } void getMyCards(int* theValue) const { int i; for(i=0; i<2; i++) theValue[i] = myCards[i]; }
@@ -35,23 +35,27 @@ ClientEngineFactory::~ClientEngineFactory()
} }
HandInterface* ClientEngineFactory::createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) boost::shared_ptr<HandInterface>
ClientEngineFactory::createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC)
{ {
return new ClientHand(f, g, b, l, sl, apl, rpl, id, sP, dP, sB, sC); return boost::shared_ptr<HandInterface>(new ClientHand(f, g, b, l, sl, apl, rpl, id, sP, dP, sB, sC));
} }
BoardInterface* ClientEngineFactory::createBoard(unsigned dp) boost::shared_ptr<BoardInterface>
ClientEngineFactory::createBoard(unsigned dp)
{ {
return new ClientBoard(dp); return boost::shared_ptr<BoardInterface>(new ClientBoard(dp));
} }
boost::shared_ptr<PlayerInterface> ClientEngineFactory::createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) boost::shared_ptr<PlayerInterface>
ClientEngineFactory::createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB)
{ {
return boost::shared_ptr<PlayerInterface> (new ClientPlayer(NULL, b, id, uniqueId, type, name, avatar, sC, aS, mB)); return boost::shared_ptr<PlayerInterface>(new ClientPlayer(NULL, b, id, uniqueId, type, name, avatar, sC, aS, mB));
} }
std::vector<boost::shared_ptr<BeRoInterface> > ClientEngineFactory::createBeRo(HandInterface* hi, int id, unsigned dP, int sB) { std::vector<boost::shared_ptr<BeRoInterface> >
ClientEngineFactory::createBeRo(HandInterface *hi, int id, unsigned dP, int sB)
{
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo; std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRo(hi, id, dP, sB, GAME_STATE_PREFLOP))); myBeRo.push_back(boost::shared_ptr<BeRoInterface>(new ClientBeRo(hi, id, dP, sB, GAME_STATE_PREFLOP)));
@@ -38,11 +38,10 @@ public:
ClientEngineFactory(); ClientEngineFactory();
~ClientEngineFactory(); ~ClientEngineFactory();
HandInterface* createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC); virtual boost::shared_ptr<HandInterface> createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC);
BoardInterface* createBoard(unsigned dp); virtual boost::shared_ptr<BoardInterface> createBoard(unsigned dp);
boost::shared_ptr<PlayerInterface> createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); virtual boost::shared_ptr<PlayerInterface> createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB);
std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface* hi, int id, unsigned dP, int sB); virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface *hi, int id, unsigned dP, int sB);
}; };
#endif #endif
+2 -2
View File
@@ -21,7 +21,7 @@
using namespace std; using namespace std;
ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, BoardInterface *b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC)
: myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myID(id), startQuantityPlayers(sP), dealerPosition(dP), currentRound(0), : myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myID(id), startQuantityPlayers(sP), dealerPosition(dP), currentRound(0),
smallBlind(sB), startCash(sC), lastPlayersTurn(-1), allInCondition(0), smallBlind(sB), startCash(sC), lastPlayersTurn(-1), allInCondition(0),
cardsShown(false), bettingRoundsPlayed(0) cardsShown(false), bettingRoundsPlayed(0)
@@ -125,7 +125,7 @@ ClientHand::getRunningPlayerIt(unsigned uniqueId) const
return it; return it;
} }
BoardInterface* boost::shared_ptr<BoardInterface>
ClientHand::getBoard() const ClientHand::getBoard() const
{ {
return myBoard; return myBoard;
+3 -3
View File
@@ -33,7 +33,7 @@
class ClientHand : public HandInterface class ClientHand : public HandInterface
{ {
public: public:
ClientHand ( boost::shared_ptr<EngineFactory> f, GuiInterface*, BoardInterface*, Log*, PlayerList, PlayerList, PlayerList , int, int, int, int, int ); ClientHand ( boost::shared_ptr<EngineFactory> f, GuiInterface*, boost::shared_ptr<BoardInterface>, Log*, PlayerList, PlayerList, PlayerList , int, int, int, int, int );
~ClientHand(); ~ClientHand();
void start(); void start();
@@ -46,7 +46,7 @@ class ClientHand : public HandInterface
PlayerListIterator getActivePlayerIt(unsigned) const; PlayerListIterator getActivePlayerIt(unsigned) const;
PlayerListIterator getRunningPlayerIt(unsigned) const; PlayerListIterator getRunningPlayerIt(unsigned) const;
BoardInterface* getBoard() const; boost::shared_ptr<BoardInterface> getBoard() const;
boost::shared_ptr<BeRoInterface> getPreflop() const; boost::shared_ptr<BeRoInterface> getPreflop() const;
boost::shared_ptr<BeRoInterface> getFlop() const; boost::shared_ptr<BeRoInterface> getFlop() const;
boost::shared_ptr<BeRoInterface> getTurn() const; boost::shared_ptr<BeRoInterface> getTurn() const;
@@ -98,7 +98,7 @@ class ClientHand : public HandInterface
boost::shared_ptr<EngineFactory> myFactory; boost::shared_ptr<EngineFactory> myFactory;
GuiInterface *myGui; GuiInterface *myGui;
BoardInterface *myBoard; boost::shared_ptr<BoardInterface> myBoard;
Log *myLog; Log *myLog;
PlayerList seatsList; PlayerList seatsList;
+1 -1
View File
@@ -35,7 +35,7 @@ public:
ClientPlayer(ConfigFile*, BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); ClientPlayer(ConfigFile*, BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB);
~ClientPlayer(); ~ClientPlayer();
void setHand(HandInterface*); void setHand(HandInterface *);
int getMyID() const; int getMyID() const;
unsigned getMyUniqueID() const; unsigned getMyUniqueID() const;
+1 -1
View File
@@ -30,7 +30,7 @@ public:
virtual ~PlayerInterface() =0; virtual ~PlayerInterface() =0;
virtual void setHand(HandInterface*) =0; virtual void setHand(HandInterface *) =0;
virtual int getMyID() const =0; virtual int getMyID() const =0;
virtual unsigned getMyUniqueID() const =0; virtual unsigned getMyUniqueID() const =0;
+4 -15
View File
@@ -33,8 +33,7 @@ using namespace std;
Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory, Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
const PlayerDataList &playerDataList, const GameData &gameData, const PlayerDataList &playerDataList, const GameData &gameData,
const StartData &startData, int gameId, Log* log) const StartData &startData, int gameId, Log* log)
: myFactory(factory), myGui(gui), myLog(log), currentHand(0), currentBoard(0), : myFactory(factory), myGui(gui), myLog(log), startQuantityPlayers(startData.numberOfPlayers),
startQuantityPlayers(startData.numberOfPlayers),
startCash(gameData.startMoney), startSmallBlind(gameData.firstSmallBlind), startCash(gameData.startMoney), startSmallBlind(gameData.firstSmallBlind),
myGameID(gameId), currentSmallBlind(gameData.firstSmallBlind), currentHandID(0), dealerPosition(0), lastHandBlindsRaised(1), lastTimeBlindsRaised(0), myGameData(gameData) 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 // 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); tmpPlayer->setNetSessionData(myNetSession);
@@ -119,18 +118,14 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
Game::~Game() Game::~Game()
{ {
delete currentBoard;
currentBoard = 0;
delete currentHand;
currentHand = 0;
} }
HandInterface *Game::getCurrentHand() boost::shared_ptr<HandInterface> Game::getCurrentHand()
{ {
return currentHand; return currentHand;
} }
const HandInterface *Game::getCurrentHand() const const boost::shared_ptr<HandInterface> Game::getCurrentHand() const
{ {
return currentHand; return currentHand;
} }
@@ -164,12 +159,6 @@ void Game::initHand()
} }
} }
// delete possible existing hands
if(currentHand) {
delete currentHand;
currentHand = 0;
}
runningPlayerList->clear(); runningPlayerList->clear();
(*runningPlayerList) = (*activePlayerList); (*runningPlayerList) = (*activePlayerList);
+4 -4
View File
@@ -47,8 +47,8 @@ public:
void initHand(); void initHand();
void startHand(); void startHand();
HandInterface *getCurrentHand(); boost::shared_ptr<HandInterface> getCurrentHand();
const HandInterface *getCurrentHand() const; const boost::shared_ptr<HandInterface> getCurrentHand() const;
PlayerList getSeatsList() const {return seatsList;} PlayerList getSeatsList() const {return seatsList;}
PlayerList getActivePlayerList() const {return activePlayerList;} PlayerList getActivePlayerList() const {return activePlayerList;}
@@ -83,8 +83,8 @@ private:
GuiInterface *myGui; GuiInterface *myGui;
Log *myLog; Log *myLog;
HandInterface *currentHand; boost::shared_ptr<HandInterface> currentHand;
BoardInterface *currentBoard; boost::shared_ptr<BoardInterface> currentBoard;
PlayerList seatsList; PlayerList seatsList;
PlayerList activePlayerList; // used seats PlayerList activePlayerList; // used seats
+26 -26
View File
@@ -779,7 +779,7 @@ void gameTableImpl::refreshButton() {
void gameTableImpl::refreshPlayerName() { void gameTableImpl::refreshPlayerName() {
if(myStartWindow->getSession()->getCurrentGame()) { if(myStartWindow->getSession()->getCurrentGame()) {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
for (it_c=currentHand->getSeatsList()->begin(); it_c!=currentHand->getSeatsList()->end(); it_c++) { for (it_c=currentHand->getSeatsList()->begin(); it_c!=currentHand->getSeatsList()->end(); it_c++) {
@@ -821,7 +821,7 @@ void gameTableImpl::refreshPlayerAvatar() {
QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png")); QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png"));
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
int seatPlace; int seatPlace;
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
for (it_c=currentHand->getSeatsList()->begin(), seatPlace=0; it_c!=currentHand->getSeatsList()->end(); it_c++, seatPlace++) { for (it_c=currentHand->getSeatsList()->begin(), seatPlace=0; it_c!=currentHand->getSeatsList()->end(); it_c++, seatPlace++) {
@@ -889,7 +889,7 @@ void gameTableImpl::refreshAction(int playerID, int playerAction) {
QStringList actionArray; QStringList actionArray;
actionArray << "" << "fold" << "check" << "call" << "bet" << "raise" << "allin"; actionArray << "" << "fold" << "check" << "call" << "bet" << "raise" << "allin";
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
if(playerID == -1 || playerAction == -1) { if(playerID == -1 || playerAction == -1) {
@@ -945,7 +945,7 @@ void gameTableImpl::refreshAction(int playerID, int playerAction) {
void gameTableImpl::refreshCash() { void gameTableImpl::refreshCash() {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
for (it_c=currentHand->getSeatsList()->begin(); it_c!=currentHand->getSeatsList()->end(); it_c++) { for (it_c=currentHand->getSeatsList()->begin(); it_c!=currentHand->getSeatsList()->end(); it_c++) {
@@ -965,7 +965,7 @@ void gameTableImpl::refreshGroupbox(int playerID, int status) {
if(playerID == -1 || status == -1) { if(playerID == -1 || status == -1) {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
for (it_c=currentHand->getSeatsList()->begin(); it_c!=currentHand->getSeatsList()->end(); it_c++) { for (it_c=currentHand->getSeatsList()->begin(); it_c!=currentHand->getSeatsList()->end(); it_c++) {
@@ -1075,7 +1075,7 @@ void gameTableImpl::refreshAll() {
refreshSet(); refreshSet();
refreshButton(); refreshButton();
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
for (it_c=currentHand->getSeatsList()->begin(); it_c!=currentHand->getSeatsList()->end(); it_c++) { for (it_c=currentHand->getSeatsList()->begin(); it_c!=currentHand->getSeatsList()->end(); it_c++) {
refreshAction( (*it_c)->getMyID(), (*it_c)->getMyAction()); refreshAction( (*it_c)->getMyID(), (*it_c)->getMyAction());
@@ -1091,7 +1091,7 @@ void gameTableImpl::refreshChangePlayer() {
refreshSet(); refreshSet();
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
for (it_c=currentHand->getSeatsList()->begin(); it_c!=currentHand->getSeatsList()->end(); it_c++) { for (it_c=currentHand->getSeatsList()->begin(); it_c!=currentHand->getSeatsList()->end(); it_c++) {
refreshAction( (*it_c)->getMyID(), (*it_c)->getMyAction()); refreshAction( (*it_c)->getMyID(), (*it_c)->getMyAction());
@@ -1101,7 +1101,7 @@ void gameTableImpl::refreshChangePlayer() {
} }
void gameTableImpl::refreshPot() { void gameTableImpl::refreshPot() {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
textLabel_Sets->setText("$"+QString("%L1").arg(currentHand->getBoard()->getSets())); textLabel_Sets->setText("$"+QString("%L1").arg(currentHand->getBoard()->getSets()));
textLabel_Pot->setText("$"+QString("%L1").arg(currentHand->getBoard()->getPot())); textLabel_Pot->setText("$"+QString("%L1").arg(currentHand->getBoard()->getPot()));
@@ -1371,7 +1371,7 @@ void gameTableImpl::provideMyActions(int mode) {
Game *currentGame = myStartWindow->getSession()->getCurrentGame(); Game *currentGame = myStartWindow->getSession()->getCurrentGame();
HandInterface *currentHand = currentGame->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = currentGame->getCurrentHand();
//really disabled buttons if human player is fold/all-in or ... and not called from dealberocards //really disabled buttons if human player is fold/all-in or ... and not called from dealberocards
if(/*pushButton_BetRaise->isCheckable() && */mode != 0 && (currentHand->getSeatsList()->front()->getMyAction() == PLAYER_ACTION_ALLIN || currentHand->getSeatsList()->front()->getMyAction() == PLAYER_ACTION_FOLD || (currentGame->getSeatsList()->front()->getMySet() == currentHand->getCurrentBeRo()->getHighestSet() && (currentGame->getSeatsList()->front()->getMyAction() != PLAYER_ACTION_NONE)))) { if(/*pushButton_BetRaise->isCheckable() && */mode != 0 && (currentHand->getSeatsList()->front()->getMyAction() == PLAYER_ACTION_ALLIN || currentHand->getSeatsList()->front()->getMyAction() == PLAYER_ACTION_FOLD || (currentGame->getSeatsList()->front()->getMySet() == currentHand->getCurrentBeRo()->getHighestSet() && (currentGame->getSeatsList()->front()->getMyAction() != PLAYER_ACTION_NONE)))) {
@@ -1610,7 +1610,7 @@ void gameTableImpl::stopTimeoutAnimation(int playerId) {
void gameTableImpl::disableMyButtons() { void gameTableImpl::disableMyButtons() {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
clearMyButtons(); clearMyButtons();
@@ -1641,7 +1641,7 @@ void gameTableImpl::myFold(){
if(pushButton_Fold->text() == FoldString) { if(pushButton_Fold->text() == FoldString) {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
currentHand->getSeatsList()->front()->setMyAction(1); currentHand->getSeatsList()->front()->setMyAction(1);
currentHand->getSeatsList()->front()->setMyTurn(0); currentHand->getSeatsList()->front()->setMyTurn(0);
@@ -1656,7 +1656,7 @@ void gameTableImpl::myFold(){
} }
void gameTableImpl::myCheck() { void gameTableImpl::myCheck() {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
currentHand->getSeatsList()->front()->setMyTurn(0); currentHand->getSeatsList()->front()->setMyTurn(0);
currentHand->getSeatsList()->front()->setMyAction(2); currentHand->getSeatsList()->front()->setMyAction(2);
@@ -1672,7 +1672,7 @@ void gameTableImpl::myCheck() {
int gameTableImpl::getMyCallAmount() { int gameTableImpl::getMyCallAmount() {
int tempHighestSet = 0; int tempHighestSet = 0;
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
tempHighestSet = currentHand->getCurrentBeRo()->getHighestSet(); tempHighestSet = currentHand->getCurrentBeRo()->getHighestSet();
@@ -1693,7 +1693,7 @@ int gameTableImpl::getBetRaisePushButtonValue() {
int gameTableImpl::getMyBetAmount() { int gameTableImpl::getMyBetAmount() {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
int betValue = getBetRaisePushButtonValue(); int betValue = getBetRaisePushButtonValue();
int minimum; int minimum;
@@ -1711,7 +1711,7 @@ int gameTableImpl::getMyBetAmount() {
void gameTableImpl::myCall(){ void gameTableImpl::myCall(){
int tempHighestSet = 0; int tempHighestSet = 0;
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
tempHighestSet = currentHand->getCurrentBeRo()->getHighestSet(); tempHighestSet = currentHand->getCurrentBeRo()->getHighestSet();
@@ -1743,7 +1743,7 @@ void gameTableImpl::mySet(){
if(pushButton_BetRaise->text() != "") { if(pushButton_BetRaise->text() != "") {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
int tempCash = currentHand->getSeatsList()->front()->getMyCash(); int tempCash = currentHand->getSeatsList()->front()->getMyCash();
// cout << "Set-Value " << getBetRaisePushButtonValue() << endl; // cout << "Set-Value " << getBetRaisePushButtonValue() << endl;
@@ -1805,7 +1805,7 @@ void gameTableImpl::myAllIn(){
if(pushButton_AllIn->text() == AllInString) { if(pushButton_AllIn->text() == AllInString) {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
currentHand->getSeatsList()->front()->setMySet(currentHand->getSeatsList()->front()->getMyCash()); currentHand->getSeatsList()->front()->setMySet(currentHand->getSeatsList()->front()->getMyCash());
currentHand->getSeatsList()->front()->setMyCash(0); currentHand->getSeatsList()->front()->setMyCash(0);
@@ -1967,7 +1967,7 @@ void gameTableImpl::myActionDone() {
void gameTableImpl::nextPlayerAnimation() { void gameTableImpl::nextPlayerAnimation() {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
//refresh Change Player //refresh Change Player
refreshSet(); refreshSet();
@@ -2045,7 +2045,7 @@ void gameTableImpl::postRiverRunAnimation2() {
horizontalSlider_bet->setDisabled(TRUE); horizontalSlider_bet->setDisabled(TRUE);
spinBox_betValue->setDisabled(TRUE); spinBox_betValue->setDisabled(TRUE);
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
bool internetOrNetworkGame = (myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK); bool internetOrNetworkGame = (myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK);
@@ -2101,7 +2101,7 @@ void gameTableImpl::postRiverRunAnimation2() {
void gameTableImpl::postRiverRunAnimation3() { void gameTableImpl::postRiverRunAnimation3() {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
int nonfoldPlayerCounter = 0; int nonfoldPlayerCounter = 0;
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
@@ -2229,7 +2229,7 @@ void gameTableImpl::postRiverRunAnimation4() {
void gameTableImpl::postRiverRunAnimation5() { void gameTableImpl::postRiverRunAnimation5() {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
@@ -2273,7 +2273,7 @@ void gameTableImpl::postRiverRunAnimation6() {
playerNameLabelArray[i]->show(); playerNameLabelArray[i]->show();
} }
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
refreshCash(); refreshCash();
refreshPot(); refreshPot();
@@ -2325,7 +2325,7 @@ void gameTableImpl::postRiverRunAnimation6() {
void gameTableImpl::showHoleCards(unsigned playerId, bool allIn) void gameTableImpl::showHoleCards(unsigned playerId, bool allIn)
{ {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
//TempArrays //TempArrays
QPixmap tempCardsPixmapArray[2]; QPixmap tempCardsPixmapArray[2];
int tempCardsIntArray[2]; int tempCardsIntArray[2];
@@ -2359,7 +2359,7 @@ void gameTableImpl::showHoleCards(unsigned playerId, bool allIn)
void gameTableImpl::flipHolecardsAllIn() { void gameTableImpl::flipHolecardsAllIn() {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
if(!flipHolecardsAllInAlreadyDone) { if(!flipHolecardsAllInAlreadyDone) {
//Aktive Spieler zählen --> wenn nur noch einer nicht-folded dann keine Karten umdrehen //Aktive Spieler zählen --> wenn nur noch einer nicht-folded dann keine Karten umdrehen
@@ -2876,7 +2876,7 @@ void gameTableImpl::mouseOverFlipCards(bool front) {
void gameTableImpl::updateMyButtonsState(int mode) { void gameTableImpl::updateMyButtonsState(int mode) {
HandInterface *currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand();
if(currentHand->getLastPlayersTurn() == 0) { if(currentHand->getLastPlayersTurn() == 0) {
myButtonsCheckable(FALSE); myButtonsCheckable(FALSE);
@@ -2920,7 +2920,7 @@ void gameTableImpl::clearMyButtons() {
void gameTableImpl::myButtonsCheckable(bool state) { void gameTableImpl::myButtonsCheckable(bool state) {
Game *currentGame = myStartWindow->getSession()->getCurrentGame(); Game *currentGame = myStartWindow->getSession()->getCurrentGame();
HandInterface *currentHand = currentGame->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = currentGame->getCurrentHand();
if(state) { if(state) {
//checkable //checkable
+3 -3
View File
@@ -201,7 +201,7 @@ void guiLog::logPlayerActionMsg(QString msg, int playerID, int action, int setVa
void guiLog::logNewGameHandMsg(int gameID, int handID) { void guiLog::logNewGameHandMsg(int gameID, int handID) {
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
HandInterface *currentHand = myW->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myW->getSession()->getCurrentGame()->getCurrentHand();
myW->textBrowser_Log->append("<span style=\"color:#"+myStyle->getChatLogTextColor()+"; font-size:large; font-weight:bold\">## Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+" ##</span>"); myW->textBrowser_Log->append("<span style=\"color:#"+myStyle->getChatLogTextColor()+"; font-size:large; font-weight:bold\">## Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+" ##</span>");
@@ -391,7 +391,7 @@ void guiLog::logNewBlindsSetsMsg(int sbSet, int bbSet, QString sbName, QString b
logFileStreamString += bbName+" ($"+QString::number(bbSet,10)+")"; logFileStreamString += bbName+" ($"+QString::number(bbSet,10)+")";
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
HandInterface *currentHand = myW->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myW->getSession()->getCurrentGame()->getCurrentHand();
for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) { for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) {
if(currentHand->getActivePlayerList()->size() > 2) { if(currentHand->getActivePlayerList()->size() > 2) {
if((*it_c)->getMyButton() == BUTTON_DEALER) { if((*it_c)->getMyButton() == BUTTON_DEALER) {
@@ -1537,7 +1537,7 @@ QString guiLog::determineHandName(int myCardsValueInt) {
list<int> sameHandCardsValueInt; list<int> sameHandCardsValueInt;
bool different = false; bool different = false;
bool equal = false; bool equal = false;
HandInterface *currentHand = myW->getSession()->getCurrentGame()->getCurrentHand(); boost::shared_ptr<HandInterface> currentHand = myW->getSession()->getCurrentGame()->getCurrentHand();
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
// collect cardsValueInt of all players who will show their cards // collect cardsValueInt of all players who will show their cards