Running astyle.

This commit is contained in:
lotodore
2011-02-26 10:09:45 +00:00
parent e17b5fa74e
commit 63b28d7167
10 changed files with 160 additions and 164 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ public:
virtual boost::shared_ptr<BeRoInterface> getRiver() const =0; virtual boost::shared_ptr<BeRoInterface> getRiver() const =0;
virtual GuiInterface* getGuiInterface() const =0; virtual GuiInterface* getGuiInterface() const =0;
virtual boost::shared_ptr<BeRoInterface> getCurrentBeRo() const =0; virtual boost::shared_ptr<BeRoInterface> getCurrentBeRo() const =0;
virtual Log* getLog() const =0; virtual Log* getLog() const =0;
virtual void setMyID(int theValue) =0; virtual void setMyID(int theValue) =0;
virtual int getMyID() const =0; virtual int getMyID() const =0;
+1 -1
View File
@@ -141,7 +141,7 @@ void LocalBeRo::run()
switch(myBeRoID) { switch(myBeRoID) {
case GAME_STATE_FLOP: case GAME_STATE_FLOP:
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2]); myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2]);
myHand->getLog()->logBoardCards(myBeRoID, tempBoardCardsArray); myHand->getLog()->logBoardCards(myBeRoID, tempBoardCardsArray);
break; break;
case GAME_STATE_TURN: case GAME_STATE_TURN:
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3]); myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3]);
+27 -27
View File
@@ -362,7 +362,7 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
myLog->logNewHandMsg(myID, dealerPosition, smallBlind, smallBlindPosition, 2*smallBlind, bigBlindPosition, seatsList); myLog->logNewHandMsg(myID, dealerPosition, smallBlind, smallBlindPosition, 2*smallBlind, bigBlindPosition, seatsList);
setBlinds(); setBlinds();
myBeRo = myFactory->createBeRo(this, myID, dealerPosition, smallBlind); myBeRo = myFactory->createBeRo(this, myID, dealerPosition, smallBlind);
} }
@@ -475,41 +475,41 @@ void LocalHand::assignButtons()
void LocalHand::setBlinds() void LocalHand::setBlinds()
{ {
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
//do sets --> TODO switch? //do sets --> TODO switch?
for (it_c=runningPlayerList->begin(); it_c!=runningPlayerList->end(); ++it_c) { for (it_c=runningPlayerList->begin(); it_c!=runningPlayerList->end(); ++it_c) {
//small blind //small blind
if((*it_c)->getMyButton() == BUTTON_SMALL_BLIND) { if((*it_c)->getMyButton() == BUTTON_SMALL_BLIND) {
// All in ? // All in ?
if((*it_c)->getMyCash() <= smallBlind) { if((*it_c)->getMyCash() <= smallBlind) {
(*it_c)->setMySet((*it_c)->getMyCash()); (*it_c)->setMySet((*it_c)->getMyCash());
// 1 to do not log this // 1 to do not log this
(*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1); (*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1);
} else { } else {
(*it_c)->setMySet(smallBlind); (*it_c)->setMySet(smallBlind);
} }
} }
//big blind //big blind
if((*it_c)->getMyButton() == BUTTON_BIG_BLIND) { if((*it_c)->getMyButton() == BUTTON_BIG_BLIND) {
// all in ? // all in ?
if((*it_c)->getMyCash() <= 2*smallBlind) { if((*it_c)->getMyCash() <= 2*smallBlind) {
(*it_c)->setMySet((*it_c)->getMyCash()); (*it_c)->setMySet((*it_c)->getMyCash());
// 1 to do not log this // 1 to do not log this
(*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1); (*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1);
} else { } else {
(*it_c)->setMySet(2*smallBlind); (*it_c)->setMySet(2*smallBlind);
} }
} }
} }
} }
+4 -4
View File
@@ -71,9 +71,9 @@ public:
return myBeRo[currentRound]; return myBeRo[currentRound];
} }
Log* getLog() const { Log* getLog() const {
return myLog; return myLog;
} }
void setMyID(int theValue) { void setMyID(int theValue) {
myID = theValue; myID = theValue;
@@ -151,7 +151,7 @@ public:
} }
void assignButtons(); void assignButtons();
void setBlinds(); void setBlinds();
void switchRounds(); void switchRounds();
+102 -102
View File
@@ -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) 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(logOnOff) {
//if write logfiles is enabled //if write logfiles is enabled
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
string sql; string sql;
char *errmsg; char *errmsg;
if( mySqliteLogDb != 0 ) { if( mySqliteLogDb != 0 ) {
// sqlite-db is open // sqlite-db is open
int i; int i;
sql = "INSERT INTO Hand ("; sql = "INSERT INTO Hand (";
sql += "HandID"; sql += "HandID";
sql += ",GameID"; sql += ",GameID";
sql += ",Dealer_Seat"; sql += ",Dealer_Seat";
sql += ",Sb_Amount"; sql += ",Sb_Amount";
sql += ",Sb_Seat"; sql += ",Sb_Seat";
sql += ",Bb_Amount"; sql += ",Bb_Amount";
sql += ",Bb_Seat"; sql += ",Bb_Seat";
for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) { for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) {
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Cash"; sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Cash";
} }
sql += ") VALUES ("; sql += ") VALUES (";
sql += boost::lexical_cast<string>(handID); sql += boost::lexical_cast<string>(handID);
sql += "," + boost::lexical_cast<string>(curGameID); sql += "," + boost::lexical_cast<string>(curGameID);
sql += "," + boost::lexical_cast<string>(dealerPosition+1); sql += "," + boost::lexical_cast<string>(dealerPosition+1);
sql += "," + boost::lexical_cast<string>(smallBlind); sql += "," + boost::lexical_cast<string>(smallBlind);
sql += "," + boost::lexical_cast<string>(smallBlindPosition+1); sql += "," + boost::lexical_cast<string>(smallBlindPosition+1);
sql += "," + boost::lexical_cast<string>(bigBlind); sql += "," + boost::lexical_cast<string>(bigBlind);
sql += "," + boost::lexical_cast<string>(bigBlindPosition+1); sql += "," + boost::lexical_cast<string>(bigBlindPosition+1);
for(it_c = seatsList->begin(); it_c!=seatsList->end(); it_c++) { for(it_c = seatsList->begin(); it_c!=seatsList->end(); it_c++) {
if((*it_c)->getMyActiveStatus()) { if((*it_c)->getMyActiveStatus()) {
sql += "," + boost::lexical_cast<string>((*it_c)->getMyCash()); sql += "," + boost::lexical_cast<string>((*it_c)->getMyCash());
} else { } else {
sql += ",NULL"; sql += ",NULL";
} }
} }
sql += ")"; sql += ")";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
} }
// Action 'starts as dealer' // Action 'starts as dealer'
sql = "INSERT INTO Action ("; sql = "INSERT INTO Action (";
sql += "HandID"; sql += "HandID";
sql += ",GameID"; sql += ",GameID";
sql += ",BeRo"; sql += ",BeRo";
sql += ",Player"; sql += ",Player";
sql += ",Action"; sql += ",Action";
sql += ",Amount"; sql += ",Amount";
sql += ") VALUES ("; sql += ") VALUES (";
sql += boost::lexical_cast<string>(handID); sql += boost::lexical_cast<string>(handID);
sql += "," + boost::lexical_cast<string>(curGameID); sql += "," + boost::lexical_cast<string>(curGameID);
sql += ",0"; sql += ",0";
sql += "," + boost::lexical_cast<string>(dealerPosition+1); sql += "," + boost::lexical_cast<string>(dealerPosition+1);
sql += ",'starts as dealer'"; sql += ",'starts as dealer'";
sql += ",NULL"; sql += ",NULL";
sql += ")"; sql += ")";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
} }
// Action 'posts small blind' // Action 'posts small blind'
sql = "INSERT INTO Action ("; sql = "INSERT INTO Action (";
sql += "HandID"; sql += "HandID";
sql += ",GameID"; sql += ",GameID";
sql += ",BeRo"; sql += ",BeRo";
sql += ",Player"; sql += ",Player";
sql += ",Action"; sql += ",Action";
sql += ",Amount"; sql += ",Amount";
sql += ") VALUES ("; sql += ") VALUES (";
sql += boost::lexical_cast<string>(handID); sql += boost::lexical_cast<string>(handID);
sql += "," + boost::lexical_cast<string>(curGameID); sql += "," + boost::lexical_cast<string>(curGameID);
sql += ",0"; sql += ",0";
sql += "," + boost::lexical_cast<string>(smallBlindPosition+1); sql += "," + boost::lexical_cast<string>(smallBlindPosition+1);
sql += ",'posts small blind'"; sql += ",'posts small blind'";
sql += "," + boost::lexical_cast<string>(smallBlind); sql += "," + boost::lexical_cast<string>(smallBlind);
sql += ")"; sql += ")";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
} }
// Action 'posts big blind' // Action 'posts big blind'
sql = "INSERT INTO Action ("; sql = "INSERT INTO Action (";
sql += "HandID"; sql += "HandID";
sql += ",GameID"; sql += ",GameID";
sql += ",BeRo"; sql += ",BeRo";
sql += ",Player"; sql += ",Player";
sql += ",Action"; sql += ",Action";
sql += ",Amount"; sql += ",Amount";
sql += ") VALUES ("; sql += ") VALUES (";
sql += boost::lexical_cast<string>(handID); sql += boost::lexical_cast<string>(handID);
sql += "," + boost::lexical_cast<string>(curGameID); sql += "," + boost::lexical_cast<string>(curGameID);
sql += ",0"; sql += ",0";
sql += "," + boost::lexical_cast<string>(bigBlindPosition+1); sql += "," + boost::lexical_cast<string>(bigBlindPosition+1);
sql += ",\'posts big blind'"; sql += ",\'posts big blind'";
sql += "," + boost::lexical_cast<string>(bigBlind); sql += "," + boost::lexical_cast<string>(bigBlind);
sql += ")"; sql += ")";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
} }
} }
} }
} }
} }
void Log::logBoardCards(GameState beroID, int boardCards[5]) void Log::logBoardCards(GameState beroID, int boardCards[5])
{ {
if(SQLITE_LOG) { if(SQLITE_LOG) {
} }
} }
//void //void
+2 -2
View File
@@ -34,14 +34,14 @@ public:
void logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned dealerPosition, PlayerList seatsList); 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 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(); // void closeLogDbAtExit();
private: private:
sqlite3 *mySqliteLogDb; sqlite3 *mySqliteLogDb;
int curGameID; int curGameID;
int curHandID; int curHandID;
bool logOnOff; bool logOnOff;
}; };
+3 -3
View File
@@ -50,9 +50,9 @@ public:
GuiInterface* getGuiInterface() const; GuiInterface* getGuiInterface() const;
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const; boost::shared_ptr<BeRoInterface> getCurrentBeRo() const;
Log* getLog() const { Log* getLog() const {
return myLog; return myLog;
} }
void setMyID ( int theValue ); void setMyID ( int theValue );
int getMyID() const; int getMyID() const;
+6 -6
View File
@@ -58,12 +58,12 @@ ServerManager::Init(unsigned serverPort, bool ipv6, ServerTransportProtocol prot
tcpAcceptHelper->Listen(serverPort, ipv6, logDir, m_lobbyThread); tcpAcceptHelper->Listen(serverPort, ipv6, logDir, m_lobbyThread);
m_acceptHelperPool.push_back(tcpAcceptHelper); m_acceptHelperPool.push_back(tcpAcceptHelper);
} }
/* if (proto & TRANSPORT_PROTOCOL_SCTP) /* if (proto & TRANSPORT_PROTOCOL_SCTP)
{ {
boost::shared_ptr<ServerAcceptInterface> sctpAcceptHelper(new ServerAcceptHelper<boost::asio::ip::sctp>(GetGui(), m_ioService)); boost::shared_ptr<ServerAcceptInterface> sctpAcceptHelper(new ServerAcceptHelper<boost::asio::ip::sctp>(GetGui(), m_ioService));
sctpAcceptHelper->Listen(serverPort, ipv6, logDir, m_lobbyThread); sctpAcceptHelper->Listen(serverPort, ipv6, logDir, m_lobbyThread);
m_acceptHelperPool.push_back(sctpAcceptHelper); m_acceptHelperPool.push_back(sctpAcceptHelper);
}*/ }*/
} }
GuiInterface & GuiInterface &
+8 -16
View File
@@ -50,19 +50,16 @@ public:
typedef typename P::endpoint P_endpoint; typedef typename P::endpoint P_endpoint;
ServerAcceptHelper(ServerCallback &serverCallback, boost::shared_ptr<boost::asio::io_service> ioService) ServerAcceptHelper(ServerCallback &serverCallback, boost::shared_ptr<boost::asio::io_service> ioService)
: m_ioService(ioService), m_serverCallback(serverCallback) : m_ioService(ioService), m_serverCallback(serverCallback) {
{
m_acceptor.reset(new P_acceptor(*m_ioService)); m_acceptor.reset(new P_acceptor(*m_ioService));
} }
virtual ~ServerAcceptHelper() virtual ~ServerAcceptHelper() {
{
} }
// Set the parameters. // Set the parameters.
virtual void Listen(unsigned serverPort, bool ipv6, const std::string &/*logDir*/, virtual void Listen(unsigned serverPort, bool ipv6, const std::string &/*logDir*/,
boost::shared_ptr<ServerLobbyThread> lobbyThread) boost::shared_ptr<ServerLobbyThread> lobbyThread) {
{
m_lobbyThread = lobbyThread; m_lobbyThread = lobbyThread;
try { try {
@@ -78,16 +75,14 @@ public:
} }
} }
virtual void Close() virtual void Close() {
{
boost::system::error_code ec; boost::system::error_code ec;
m_acceptor->close(ec); m_acceptor->close(ec);
// Ignore any error, because we are terminating. // Ignore any error, because we are terminating.
} }
protected: protected:
void InternalListen(unsigned serverPort, bool ipv6) void InternalListen(unsigned serverPort, bool ipv6) {
{
if (serverPort < 1024) if (serverPort < 1024)
throw ServerException(__FILE__, __LINE__, ERR_SOCK_INVALID_PORT, 0); throw ServerException(__FILE__, __LINE__, ERR_SOCK_INVALID_PORT, 0);
@@ -117,8 +112,7 @@ protected:
} }
void HandleAccept(boost::shared_ptr<typename P::socket> acceptedSocket, void HandleAccept(boost::shared_ptr<typename P::socket> acceptedSocket,
const boost::system::error_code &error) const boost::system::error_code &error) {
{
if (!error) { if (!error) {
boost::asio::socket_base::non_blocking_io command(true); boost::asio::socket_base::non_blocking_io command(true);
acceptedSocket->io_control(command); acceptedSocket->io_control(command);
@@ -139,13 +133,11 @@ protected:
} }
} }
ServerCallback &GetCallback() ServerCallback &GetCallback() {
{
return m_serverCallback; return m_serverCallback;
} }
ServerLobbyThread &GetLobbyThread() ServerLobbyThread &GetLobbyThread() {
{
return *m_lobbyThread; return *m_lobbyThread;
} }
+6 -2
View File
@@ -86,8 +86,12 @@ public:
return *m_sendBuffer; return *m_sendBuffer;
} }
void Close() {m_callback.CloseSession(shared_from_this());} void Close() {
void HandlePacket(boost::shared_ptr<NetPacket> packet) {m_callback.HandlePacket(shared_from_this(), packet);} m_callback.CloseSession(shared_from_this());
}
void HandlePacket(boost::shared_ptr<NetPacket> packet) {
m_callback.HandlePacket(shared_from_this(), packet);
}
void ResetActivityTimer(); void ResetActivityTimer();
unsigned GetActivityTimerElapsedSec() const; unsigned GetActivityTimerElapsedSec() const;