diff --git a/src/engine/local_engine/localenginefactory.cpp b/src/engine/local_engine/localenginefactory.cpp index 3288fc03..87690d49 100644 --- a/src/engine/local_engine/localenginefactory.cpp +++ b/src/engine/local_engine/localenginefactory.cpp @@ -46,7 +46,7 @@ HandInterface* LocalEngineFactory::createHand(boost::shared_ptr f BoardInterface* LocalEngineFactory::createBoard() { return new LocalBoard; } -boost::shared_ptr LocalEngineFactory::createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) { return new LocalPlayer(myConfig, b, id, uniqueId, type, name, avatar, sC, aS, mB); } +boost::shared_ptr 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 (new LocalPlayer(myConfig, b, id, uniqueId, type, name, avatar, sC, aS, mB)); } std::vector > LocalEngineFactory::createBeRo(HandInterface* hi, int id, int aP, int dP, int sB) { diff --git a/src/engine/network_engine/clientboard.cpp b/src/engine/network_engine/clientboard.cpp index eb5f4ac5..f33015d7 100644 --- a/src/engine/network_engine/clientboard.cpp +++ b/src/engine/network_engine/clientboard.cpp @@ -34,7 +34,7 @@ ClientBoard::~ClientBoard() } void -ClientBoard::setPlayer(PlayerInterface** p) +ClientBoard::setPlayer(std::vector > p) { boost::recursive_mutex::scoped_lock lock(m_syncMutex); playerArray = p; diff --git a/src/engine/network_engine/clientboard.h b/src/engine/network_engine/clientboard.h index 90112163..b2c99949 100644 --- a/src/engine/network_engine/clientboard.h +++ b/src/engine/network_engine/clientboard.h @@ -21,6 +21,8 @@ #include #include +#include + class PlayerInterface; class HandInterface; @@ -32,7 +34,7 @@ public: ClientBoard(); ~ClientBoard(); - void setPlayer(PlayerInterface**); + void setPlayer(std::vector >); void setHand(HandInterface*); void setMyCards(int* theValue); @@ -51,7 +53,7 @@ public: private: mutable boost::recursive_mutex m_syncMutex; - PlayerInterface **playerArray; + std::vector > playerArray; HandInterface *actualHand; int myCards[5]; diff --git a/src/engine/network_engine/clientenginefactory.cpp b/src/engine/network_engine/clientenginefactory.cpp index 126b7609..bcbc57fb 100644 --- a/src/engine/network_engine/clientenginefactory.cpp +++ b/src/engine/network_engine/clientenginefactory.cpp @@ -47,7 +47,7 @@ BoardInterface* ClientEngineFactory::createBoard() boost::shared_ptr ClientEngineFactory::createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) { - return new ClientPlayer(NULL, b, id, uniqueId, type, name, avatar, sC, aS, mB); + return boost::shared_ptr (new ClientPlayer(NULL, b, id, uniqueId, type, name, avatar, sC, aS, mB)); } std::vector > ClientEngineFactory::createBeRo(HandInterface* hi, int id, int aP, int dP, int sB) { diff --git a/src/engine/network_engine/clientenginefactory.h b/src/engine/network_engine/clientenginefactory.h index 2fb38c59..5cc2ecc6 100644 --- a/src/engine/network_engine/clientenginefactory.h +++ b/src/engine/network_engine/clientenginefactory.h @@ -37,7 +37,7 @@ public: ClientEngineFactory(); ~ClientEngineFactory(); - HandInterface* createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC); + HandInterface* createHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > p, int id, int sP, int aP, int dP, int sB,int sC); BoardInterface* createBoard(); boost::shared_ptr createPlayer(BoardInterface *b, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); std::vector > createBeRo(HandInterface* hi, int id, int aP, int dP, int sB); diff --git a/src/engine/network_engine/clienthand.cpp b/src/engine/network_engine/clienthand.cpp index 1898dc9d..15557ae5 100644 --- a/src/engine/network_engine/clienthand.cpp +++ b/src/engine/network_engine/clienthand.cpp @@ -21,7 +21,7 @@ using namespace std; -ClientHand::ClientHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, PlayerInterface **p, int id, int sP, int aP, int dP, int sB,int sC) +ClientHand::ClientHand(boost::shared_ptr f, GuiInterface *g, BoardInterface *b, std::vector > p, int id, int sP, int aP, int dP, int sB,int sC) : myFactory(f), myGui(g), myBoard(b), playerArray(p), myID(id), actualQuantityPlayers(aP), startQuantityPlayers(sP), dealerPosition(dP), actualRound(0), smallBlind(sB), startCash(sC), activePlayersCounter(aP), lastPlayersTurn(0), allInCondition(0), cardsShown(false), bettingRoundsPlayed(0) @@ -68,7 +68,7 @@ ClientHand::start() { } -PlayerInterface** +std::vector > ClientHand::getPlayerArray() const { return playerArray; diff --git a/src/engine/network_engine/clienthand.h b/src/engine/network_engine/clienthand.h index 6ce9e775..c7868a2c 100644 --- a/src/engine/network_engine/clienthand.h +++ b/src/engine/network_engine/clienthand.h @@ -32,12 +32,12 @@ class ClientHand : public HandInterface { public: - ClientHand ( boost::shared_ptr f, GuiInterface*, BoardInterface*, PlayerInterface**, int, int, int, int, int, int ); + ClientHand ( boost::shared_ptr f, GuiInterface*, BoardInterface*, std::vector > , int, int, int, int, int, int ); ~ClientHand(); void start(); - PlayerInterface** getPlayerArray() const; + std::vector > getPlayerArray() const; BoardInterface* getBoard() const; boost::shared_ptr getPreflop() const; boost::shared_ptr getFlop() const; @@ -91,7 +91,7 @@ class ClientHand : public HandInterface boost::shared_ptr myFactory; GuiInterface *myGui; BoardInterface *myBoard; - PlayerInterface **playerArray; + std::vector > playerArray; std::vector > myBeRo; int myID; diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index 1b575625..a17dc5f7 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -575,7 +575,7 @@ ClientStateWaitHand::InternalProcess(ClientThread &client, boost::shared_ptrToNetPacketEndOfGame()->GetData(endData); - PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId(endData.winnerPlayerId); + boost::shared_ptr tmpPlayer = curGame->getPlayerByUniqueId(endData.winnerPlayerId); if (!tmpPlayer) throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0); client.GetGui().logPlayerWinGame(tmpPlayer->getMyName(), curGame->getMyGameID()); @@ -618,7 +618,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptrToNetPacketPlayersActionDone()->GetData(actionDoneData); - PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId(actionDoneData.playerId); + boost::shared_ptr tmpPlayer = curGame->getPlayerByUniqueId(actionDoneData.playerId); if (!tmpPlayer) throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0); @@ -667,7 +667,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptrToNetPacketPlayersTurn()->GetData(turnData); - PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId(turnData.playerId); + boost::shared_ptr tmpPlayer = curGame->getPlayerByUniqueId(turnData.playerId); if (!tmpPlayer) throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0); @@ -759,7 +759,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptrgetPlayerByUniqueId((*i).playerId); + boost::shared_ptr tmpPlayer = curGame->getPlayerByUniqueId((*i).playerId); if (!tmpPlayer) throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0); @@ -786,7 +786,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptrToNetPacketEndOfHandHideCards()->GetData(endHandData); - PlayerInterface *tmpPlayer = curGame->getPlayerByUniqueId(endHandData.playerId); + boost::shared_ptr tmpPlayer = curGame->getPlayerByUniqueId(endHandData.playerId); if (!tmpPlayer) throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0); @@ -823,7 +823,7 @@ ClientStateRunHand::InternalProcess(ClientThread &client, boost::shared_ptrgetPlayerByUniqueId((*i).playerId); + boost::shared_ptr tmpPlayer = curGame->getPlayerByUniqueId((*i).playerId); if (!tmpPlayer) throw ClientException(ERR_NET_UNKNOWN_PLAYER_ID, 0); diff --git a/src/net/common/clientthread.cpp b/src/net/common/clientthread.cpp index 12bdce9e..2cdd2025 100644 --- a/src/net/common/clientthread.cpp +++ b/src/net/common/clientthread.cpp @@ -418,7 +418,7 @@ ClientThread::RemoveDisconnectedPlayers() { for (int i = 0; i < m_game->getStartQuantityPlayers(); i++) { - PlayerInterface *tmpPlayer = m_game->getPlayerArray()[i]; + boost::shared_ptr tmpPlayer = m_game->getPlayerArray()[i]; if (tmpPlayer->getMyActiveStatus()) { // If a player is not in the player data list, it was disconnected. diff --git a/src/net/common/serverrecvstate.cpp b/src/net/common/serverrecvstate.cpp index 00819f17..d0c17e92 100644 --- a/src/net/common/serverrecvstate.cpp +++ b/src/net/common/serverrecvstate.cpp @@ -45,7 +45,7 @@ using namespace std; // Helper functions // TODO: these are hacks. -static PlayerInterface *GetCurrentPlayer(Game &curGame) +static boost::shared_ptr GetCurrentPlayer(Game &curGame) { int curPlayerNum = curGame.getCurrentHand()->getCurrentBeRo()->getPlayersTurn(); assert(curPlayerNum < curGame.getStartQuantityPlayers()); // TODO: throw exception @@ -450,7 +450,7 @@ ServerRecvStateStartHand::Process(ServerRecvThread &server) curGame.getCurrentHand()->getTurn()->resetFirstRun(); curGame.getCurrentHand()->getRiver()->resetFirstRun(); - PlayerInterface **playerArray = curGame.getPlayerArray(); + std::vector >playerArray = curGame.getPlayerArray(); // Send cards to all players. for (int i = 0; i < curGame.getStartQuantityPlayers(); i++) @@ -595,7 +595,7 @@ ServerRecvStateStartRound::Process(ServerRecvThread &server) assert (!curGame.getCurrentHand()->getAllInCondition()); // this would be an error. // Retrieve current player. - PlayerInterface *curPlayer = GetCurrentPlayer(curGame); + boost::shared_ptr curPlayer = GetCurrentPlayer(curGame); assert(curPlayer); // TODO throw exception assert(curPlayer->getMyActiveStatus()); // TODO throw exception @@ -696,10 +696,10 @@ ServerRecvStateStartRound::Process(ServerRecvThread &server) return retVal; } -std::list +std::list > ServerRecvStateStartRound::GetActivePlayers(Game &curGame) { - std::list activePlayers; + std::list > activePlayers; for (int i = 0; i < curGame.getStartQuantityPlayers() ; i++) { if (curGame.getPlayerArray()[i]->getMyActiveStatus() @@ -733,7 +733,7 @@ ServerRecvStateWaitPlayerAction::Process(ServerRecvThread &server) { int retVal; - PlayerInterface *tmpPlayer = GetCurrentPlayer(server.GetGame()); + boost::shared_ptr tmpPlayer = GetCurrentPlayer(server.GetGame()); assert(tmpPlayer); assert(!tmpPlayer->getMyName().empty()); diff --git a/src/net/common/serverrecvthread.cpp b/src/net/common/serverrecvthread.cpp index 3b16a299..714ea4de 100644 --- a/src/net/common/serverrecvthread.cpp +++ b/src/net/common/serverrecvthread.cpp @@ -468,7 +468,7 @@ ServerRecvThread::RemoveDisconnectedPlayers() { for (int i = 0; i < m_game->getStartQuantityPlayers(); i++) { - PlayerInterface *tmpPlayer = m_game->getPlayerArray()[i]; + boost::shared_ptr tmpPlayer = m_game->getPlayerArray()[i]; if (!IsPlayerConnected(tmpPlayer->getMyUniqueID()) && tmpPlayer->getMyType() == PLAYER_TYPE_HUMAN) { tmpPlayer->setMyCash(0); diff --git a/src/net/serverrecvstate.h b/src/net/serverrecvstate.h index 32c1993e..88f5e8b5 100644 --- a/src/net/serverrecvstate.h +++ b/src/net/serverrecvstate.h @@ -184,7 +184,7 @@ protected: // Protected constructor - this is a singleton. ServerRecvStateStartRound(); - static std::list GetActivePlayers(Game &curGame); + static std::list > GetActivePlayers(Game &curGame); }; // State: Wait for a player action.