diff --git a/src/engine/handinterface.h b/src/engine/handinterface.h index d1c850f6..f05b6f18 100644 --- a/src/engine/handinterface.h +++ b/src/engine/handinterface.h @@ -45,7 +45,7 @@ public: virtual boost::shared_ptr getRiver() const =0; virtual GuiInterface* getGuiInterface() const =0; virtual boost::shared_ptr getCurrentBeRo() const =0; - virtual Log* getLog() const =0; + virtual Log* getLog() const =0; virtual void setMyID(int theValue) =0; virtual int getMyID() const =0; diff --git a/src/engine/local_engine/localbero.cpp b/src/engine/local_engine/localbero.cpp index 46a6672f..9256dd88 100644 --- a/src/engine/local_engine/localbero.cpp +++ b/src/engine/local_engine/localbero.cpp @@ -141,7 +141,7 @@ void LocalBeRo::run() switch(myBeRoID) { case GAME_STATE_FLOP: myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2]); - myHand->getLog()->logBoardCards(myBeRoID, tempBoardCardsArray); + myHand->getLog()->logBoardCards(myBeRoID, tempBoardCardsArray); break; case GAME_STATE_TURN: myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3]); diff --git a/src/engine/local_engine/localhand.cpp b/src/engine/local_engine/localhand.cpp index 1d80f248..5dff0bab 100755 --- a/src/engine/local_engine/localhand.cpp +++ b/src/engine/local_engine/localhand.cpp @@ -362,7 +362,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: myLog->logNewHandMsg(myID, dealerPosition, smallBlind, smallBlindPosition, 2*smallBlind, bigBlindPosition, seatsList); - setBlinds(); + setBlinds(); myBeRo = myFactory->createBeRo(this, myID, dealerPosition, smallBlind); } @@ -475,41 +475,41 @@ void LocalHand::assignButtons() void LocalHand::setBlinds() { - PlayerListConstIterator it_c; + PlayerListConstIterator it_c; - //do sets --> TODO switch? - for (it_c=runningPlayerList->begin(); it_c!=runningPlayerList->end(); ++it_c) { + //do sets --> TODO switch? + for (it_c=runningPlayerList->begin(); it_c!=runningPlayerList->end(); ++it_c) { - //small blind - if((*it_c)->getMyButton() == BUTTON_SMALL_BLIND) { + //small blind + if((*it_c)->getMyButton() == BUTTON_SMALL_BLIND) { - // All in ? - if((*it_c)->getMyCash() <= smallBlind) { + // All in ? + if((*it_c)->getMyCash() <= smallBlind) { - (*it_c)->setMySet((*it_c)->getMyCash()); - // 1 to do not log this - (*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1); + (*it_c)->setMySet((*it_c)->getMyCash()); + // 1 to do not log this + (*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1); - } else { - (*it_c)->setMySet(smallBlind); - } - } + } else { + (*it_c)->setMySet(smallBlind); + } + } - //big blind - if((*it_c)->getMyButton() == BUTTON_BIG_BLIND) { + //big blind + if((*it_c)->getMyButton() == BUTTON_BIG_BLIND) { - // all in ? - if((*it_c)->getMyCash() <= 2*smallBlind) { + // all in ? + if((*it_c)->getMyCash() <= 2*smallBlind) { - (*it_c)->setMySet((*it_c)->getMyCash()); - // 1 to do not log this - (*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1); + (*it_c)->setMySet((*it_c)->getMyCash()); + // 1 to do not log this + (*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1); - } else { - (*it_c)->setMySet(2*smallBlind); - } - } - } + } else { + (*it_c)->setMySet(2*smallBlind); + } + } + } } diff --git a/src/engine/local_engine/localhand.h b/src/engine/local_engine/localhand.h index 1e3aa2d5..64a2d20e 100755 --- a/src/engine/local_engine/localhand.h +++ b/src/engine/local_engine/localhand.h @@ -71,9 +71,9 @@ public: return myBeRo[currentRound]; } - Log* getLog() const { - return myLog; - } + Log* getLog() const { + return myLog; + } void setMyID(int theValue) { myID = theValue; @@ -151,7 +151,7 @@ public: } void assignButtons(); - void setBlinds(); + void setBlinds(); void switchRounds(); diff --git a/src/engine/log.cpp b/src/engine/log.cpp index cbf5d9f0..a719dda7 100644 --- a/src/engine/log.cpp +++ b/src/engine/log.cpp @@ -215,121 +215,121 @@ void Log::logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned void Log::logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned smallBlindPosition, int bigBlind, unsigned bigBlindPosition, PlayerList seatsList) { - curHandID = handID; + curHandID = handID; - if(SQLITE_LOG) { + if(SQLITE_LOG) { - if(logOnOff) { - //if write logfiles is enabled + if(logOnOff) { + //if write logfiles is enabled - PlayerListConstIterator it_c; - string sql; - char *errmsg; + PlayerListConstIterator it_c; + string sql; + char *errmsg; - if( mySqliteLogDb != 0 ) { - // sqlite-db is open - int i; + if( mySqliteLogDb != 0 ) { + // sqlite-db is open + int i; - sql = "INSERT INTO Hand ("; - sql += "HandID"; - sql += ",GameID"; - sql += ",Dealer_Seat"; - sql += ",Sb_Amount"; - sql += ",Sb_Seat"; - sql += ",Bb_Amount"; - sql += ",Bb_Seat"; - for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) { - sql += ",Seat_" + boost::lexical_cast(i) + "_Cash"; - } - sql += ") VALUES ("; - sql += boost::lexical_cast(handID); - sql += "," + boost::lexical_cast(curGameID); - sql += "," + boost::lexical_cast(dealerPosition+1); - sql += "," + boost::lexical_cast(smallBlind); - sql += "," + boost::lexical_cast(smallBlindPosition+1); - sql += "," + boost::lexical_cast(bigBlind); - sql += "," + boost::lexical_cast(bigBlindPosition+1); - for(it_c = seatsList->begin(); it_c!=seatsList->end(); it_c++) { - if((*it_c)->getMyActiveStatus()) { - sql += "," + boost::lexical_cast((*it_c)->getMyCash()); - } else { - sql += ",NULL"; - } - } - sql += ")"; - if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { - cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; - } + sql = "INSERT INTO Hand ("; + sql += "HandID"; + sql += ",GameID"; + sql += ",Dealer_Seat"; + sql += ",Sb_Amount"; + sql += ",Sb_Seat"; + sql += ",Bb_Amount"; + sql += ",Bb_Seat"; + for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) { + sql += ",Seat_" + boost::lexical_cast(i) + "_Cash"; + } + sql += ") VALUES ("; + sql += boost::lexical_cast(handID); + sql += "," + boost::lexical_cast(curGameID); + sql += "," + boost::lexical_cast(dealerPosition+1); + sql += "," + boost::lexical_cast(smallBlind); + sql += "," + boost::lexical_cast(smallBlindPosition+1); + sql += "," + boost::lexical_cast(bigBlind); + sql += "," + boost::lexical_cast(bigBlindPosition+1); + for(it_c = seatsList->begin(); it_c!=seatsList->end(); it_c++) { + if((*it_c)->getMyActiveStatus()) { + sql += "," + boost::lexical_cast((*it_c)->getMyCash()); + } else { + sql += ",NULL"; + } + } + sql += ")"; + if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { + cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; + } - // Action 'starts as dealer' - sql = "INSERT INTO Action ("; - sql += "HandID"; - sql += ",GameID"; - sql += ",BeRo"; - sql += ",Player"; - sql += ",Action"; - sql += ",Amount"; - sql += ") VALUES ("; - sql += boost::lexical_cast(handID); - sql += "," + boost::lexical_cast(curGameID); - sql += ",0"; - sql += "," + boost::lexical_cast(dealerPosition+1); - sql += ",'starts as dealer'"; - sql += ",NULL"; - sql += ")"; - if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { - cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; - } + // Action 'starts as dealer' + sql = "INSERT INTO Action ("; + sql += "HandID"; + sql += ",GameID"; + sql += ",BeRo"; + sql += ",Player"; + sql += ",Action"; + sql += ",Amount"; + sql += ") VALUES ("; + sql += boost::lexical_cast(handID); + sql += "," + boost::lexical_cast(curGameID); + sql += ",0"; + sql += "," + boost::lexical_cast(dealerPosition+1); + sql += ",'starts as dealer'"; + sql += ",NULL"; + sql += ")"; + if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { + cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; + } - // Action 'posts small blind' - sql = "INSERT INTO Action ("; - sql += "HandID"; - sql += ",GameID"; - sql += ",BeRo"; - sql += ",Player"; - sql += ",Action"; - sql += ",Amount"; - sql += ") VALUES ("; - sql += boost::lexical_cast(handID); - sql += "," + boost::lexical_cast(curGameID); - sql += ",0"; - sql += "," + boost::lexical_cast(smallBlindPosition+1); - sql += ",'posts small blind'"; - sql += "," + boost::lexical_cast(smallBlind); - sql += ")"; - if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { - cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; - } + // Action 'posts small blind' + sql = "INSERT INTO Action ("; + sql += "HandID"; + sql += ",GameID"; + sql += ",BeRo"; + sql += ",Player"; + sql += ",Action"; + sql += ",Amount"; + sql += ") VALUES ("; + sql += boost::lexical_cast(handID); + sql += "," + boost::lexical_cast(curGameID); + sql += ",0"; + sql += "," + boost::lexical_cast(smallBlindPosition+1); + sql += ",'posts small blind'"; + sql += "," + boost::lexical_cast(smallBlind); + sql += ")"; + if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { + cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; + } - // Action 'posts big blind' - sql = "INSERT INTO Action ("; - sql += "HandID"; - sql += ",GameID"; - sql += ",BeRo"; - sql += ",Player"; - sql += ",Action"; - sql += ",Amount"; - sql += ") VALUES ("; - sql += boost::lexical_cast(handID); - sql += "," + boost::lexical_cast(curGameID); - sql += ",0"; - sql += "," + boost::lexical_cast(bigBlindPosition+1); - sql += ",\'posts big blind'"; - sql += "," + boost::lexical_cast(bigBlind); - sql += ")"; - if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { - cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; - } - } - } - } + // Action 'posts big blind' + sql = "INSERT INTO Action ("; + sql += "HandID"; + sql += ",GameID"; + sql += ",BeRo"; + sql += ",Player"; + sql += ",Action"; + sql += ",Amount"; + sql += ") VALUES ("; + sql += boost::lexical_cast(handID); + sql += "," + boost::lexical_cast(curGameID); + sql += ",0"; + sql += "," + boost::lexical_cast(bigBlindPosition+1); + sql += ",\'posts big blind'"; + sql += "," + boost::lexical_cast(bigBlind); + sql += ")"; + if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { + cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; + } + } + } + } } void Log::logBoardCards(GameState beroID, int boardCards[5]) { - if(SQLITE_LOG) { + if(SQLITE_LOG) { - } + } } //void diff --git a/src/engine/log.h b/src/engine/log.h index 0eda8f4c..33448e06 100644 --- a/src/engine/log.h +++ b/src/engine/log.h @@ -34,14 +34,14 @@ public: void logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned dealerPosition, PlayerList seatsList); void logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned smallBlindPosition, int bigBlind, unsigned bigBlindPosition, PlayerList seatsList); - void logBoardCards(GameState beroID, int boardCards[5]); + void logBoardCards(GameState beroID, int boardCards[5]); // void closeLogDbAtExit(); private: sqlite3 *mySqliteLogDb; int curGameID; - int curHandID; + int curHandID; bool logOnOff; }; diff --git a/src/engine/network_engine/clienthand.h b/src/engine/network_engine/clienthand.h index 5b4142c3..afeb0a31 100644 --- a/src/engine/network_engine/clienthand.h +++ b/src/engine/network_engine/clienthand.h @@ -50,9 +50,9 @@ public: GuiInterface* getGuiInterface() const; boost::shared_ptr getCurrentBeRo() const; - Log* getLog() const { - return myLog; - } + Log* getLog() const { + return myLog; + } void setMyID ( int theValue ); int getMyID() const; diff --git a/src/net/common/servermanager.cpp b/src/net/common/servermanager.cpp index c0134ac0..78478361 100644 --- a/src/net/common/servermanager.cpp +++ b/src/net/common/servermanager.cpp @@ -58,12 +58,12 @@ ServerManager::Init(unsigned serverPort, bool ipv6, ServerTransportProtocol prot tcpAcceptHelper->Listen(serverPort, ipv6, logDir, m_lobbyThread); m_acceptHelperPool.push_back(tcpAcceptHelper); } -/* if (proto & TRANSPORT_PROTOCOL_SCTP) - { - boost::shared_ptr sctpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService)); - sctpAcceptHelper->Listen(serverPort, ipv6, logDir, m_lobbyThread); - m_acceptHelperPool.push_back(sctpAcceptHelper); - }*/ + /* if (proto & TRANSPORT_PROTOCOL_SCTP) + { + boost::shared_ptr sctpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService)); + sctpAcceptHelper->Listen(serverPort, ipv6, logDir, m_lobbyThread); + m_acceptHelperPool.push_back(sctpAcceptHelper); + }*/ } GuiInterface & diff --git a/src/net/serveraccepthelper.h b/src/net/serveraccepthelper.h index d63c19c3..5032e117 100644 --- a/src/net/serveraccepthelper.h +++ b/src/net/serveraccepthelper.h @@ -50,19 +50,16 @@ public: typedef typename P::endpoint P_endpoint; ServerAcceptHelper(ServerCallback &serverCallback, boost::shared_ptr ioService) - : m_ioService(ioService), m_serverCallback(serverCallback) - { + : m_ioService(ioService), m_serverCallback(serverCallback) { m_acceptor.reset(new P_acceptor(*m_ioService)); } - virtual ~ServerAcceptHelper() - { + virtual ~ServerAcceptHelper() { } // Set the parameters. virtual void Listen(unsigned serverPort, bool ipv6, const std::string &/*logDir*/, - boost::shared_ptr lobbyThread) - { + boost::shared_ptr lobbyThread) { m_lobbyThread = lobbyThread; try { @@ -78,16 +75,14 @@ public: } } - virtual void Close() - { + virtual void Close() { boost::system::error_code ec; m_acceptor->close(ec); // Ignore any error, because we are terminating. } protected: - void InternalListen(unsigned serverPort, bool ipv6) - { + void InternalListen(unsigned serverPort, bool ipv6) { if (serverPort < 1024) throw ServerException(__FILE__, __LINE__, ERR_SOCK_INVALID_PORT, 0); @@ -117,8 +112,7 @@ protected: } void HandleAccept(boost::shared_ptr acceptedSocket, - const boost::system::error_code &error) - { + const boost::system::error_code &error) { if (!error) { boost::asio::socket_base::non_blocking_io command(true); acceptedSocket->io_control(command); @@ -139,13 +133,11 @@ protected: } } - ServerCallback &GetCallback() - { + ServerCallback &GetCallback() { return m_serverCallback; } - ServerLobbyThread &GetLobbyThread() - { + ServerLobbyThread &GetLobbyThread() { return *m_lobbyThread; } diff --git a/src/net/sessiondata.h b/src/net/sessiondata.h index 9799731b..43dc92eb 100644 --- a/src/net/sessiondata.h +++ b/src/net/sessiondata.h @@ -86,8 +86,12 @@ public: return *m_sendBuffer; } - void Close() {m_callback.CloseSession(shared_from_this());} - void HandlePacket(boost::shared_ptr packet) {m_callback.HandlePacket(shared_from_this(), packet);} + void Close() { + m_callback.CloseSession(shared_from_this()); + } + void HandlePacket(boost::shared_ptr packet) { + m_callback.HandlePacket(shared_from_this(), packet); + } void ResetActivityTimer(); unsigned GetActivityTimerElapsedSec() const;