From 3a659dd5d5d9121d51266f0114d6a8711eefed25 Mon Sep 17 00:00:00 2001 From: floty Date: Thu, 5 Jan 2012 20:54:27 +0000 Subject: [PATCH] logging missing network actions in sqlite; run astyle. --- src/engine/log.cpp | 23 +- src/engine/network_engine/clientplayer.h | 4 +- src/game_defs.h | 6 +- .../gamelobbydialog/gamelobbydialogimpl.cpp | 16 +- src/gui/qt/gametable/gametableimpl.cpp | 39 ++- src/gui/qt/gametable/gametableimpl.h | 2 +- src/gui/qt/gametable/log/guilog.cpp | 275 ++++++++++-------- src/gui/qt/gametable/log/guilog.h | 9 + src/gui/qt/gametable/myavatarlabel.cpp | 10 +- src/gui/qt/gametable/mynamelabel.cpp | 3 +- src/gui/qt/guiwrapper.cpp | 5 +- src/gui/qt/sound/soundevents.cpp | 12 +- src/net/common/clientstate.cpp | 21 +- src/net/common/clientthread.cpp | 22 +- src/net/common/servergamestate.cpp | 7 +- src/net/common/serverlobbythread.cpp | 2 +- 16 files changed, 263 insertions(+), 193 deletions(-) diff --git a/src/engine/log.cpp b/src/engine/log.cpp index a65c8dc9..c6542f07 100644 --- a/src/engine/log.cpp +++ b/src/engine/log.cpp @@ -266,15 +266,18 @@ Log::logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned // log blinds for(it_c = seatsList->begin(); it_c!=seatsList->end(); ++it_c) { - if((*it_c)->getMyButton() == BUTTON_SMALL_BLIND) { + if((*it_c)->getMyButton() == BUTTON_SMALL_BLIND && (*it_c)->getMySet()>0) { logPlayerAction(GAME_STATE_PREFLOP,smallBlindPosition,LOG_ACTION_SMALL_BLIND,(*it_c)->getMySet()); } } for(it_c = seatsList->begin(); it_c!=seatsList->end(); ++it_c) { - if((*it_c)->getMyButton() == BUTTON_BIG_BLIND) { + if((*it_c)->getMyButton() == BUTTON_BIG_BLIND && (*it_c)->getMySet()>0) { logPlayerAction(GAME_STATE_PREFLOP,bigBlindPosition,LOG_ACTION_BIG_BLIND,(*it_c)->getMySet()); } } + + // (*it_c)->getMySet() ist ein Hack, da es im Internetspiel vorkam, dass ein Spieler zweimal geloggt wurde mit Blind - einmal jedoch mit $0 + // !! TODO !! Hack } @@ -364,6 +367,22 @@ Log::logPlayerAction(GameState bero, int seat, PlayerActionLog action, int amoun sql += ",'wins game'"; sql += ",NULL"; break; + case LOG_ACTION_LEFT: + sql += ",'has left the game'"; + sql += ",NULL"; + break; + case LOG_ACTION_KICKED: + sql += ",'was kicked from the game'"; + sql += ",NULL"; + break; + case LOG_ACTION_ADMIN: + sql += ",'is game admin now'"; + sql += ",NULL"; + break; + case LOG_ACTION_JOIN: + sql += ",'has joined the game'"; + sql += ",NULL"; + break; default: return; } diff --git a/src/engine/network_engine/clientplayer.h b/src/engine/network_engine/clientplayer.h index 820204ce..b02b8e1d 100644 --- a/src/engine/network_engine/clientplayer.h +++ b/src/engine/network_engine/clientplayer.h @@ -141,7 +141,9 @@ public: bool checkIfINeedToShowCards(); void markRemoteAction() {} - unsigned getTimeSecSinceLastRemoteAction() const {return 0;} + unsigned getTimeSecSinceLastRemoteAction() const { + return 0; + } private: mutable boost::recursive_mutex m_syncMutex; diff --git a/src/game_defs.h b/src/game_defs.h index be2b7557..214d9dc0 100644 --- a/src/game_defs.h +++ b/src/game_defs.h @@ -94,7 +94,11 @@ enum PlayerActionLog { LOG_ACTION_WIN, // wins LOG_ACTION_WIN_SIDE_POT,// wins (side pot) LOG_ACTION_SIT_OUT, // sits out - LOG_ACTION_WIN_GAME // wins game + LOG_ACTION_WIN_GAME, // wins game + LOG_ACTION_LEFT, // left the game + LOG_ACTION_KICKED, // was kicked from + LOG_ACTION_ADMIN, // is game admin now + LOG_ACTION_JOIN // has joined the game }; enum DenyKickPlayerReason { diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp index 2f2193fe..0e0e5c1c 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp @@ -403,14 +403,14 @@ void gameLobbyDialogImpl::refresh(int actionID) waitStartGameMsgBoxTimer->start(2000); } else if(actionID == MSG_NET_GAME_CLIENT_SYNCREJOIN) { // if(this->isVisible()) { //TODO <-- does it work without isVisible??? - //break the autoStartTimer animation - autoStartTimer->stop(); - autoStartTimerOverlay->hide(); - //show msg dialog - waitRejoinStartGameMsgBox->show(); - waitRejoinStartGameMsgBox->raise(); - waitRejoinStartGameMsgBox->activateWindow(); - pushButton_Leave->setDisabled(true); + //break the autoStartTimer animation + autoStartTimer->stop(); + autoStartTimerOverlay->hide(); + //show msg dialog + waitRejoinStartGameMsgBox->show(); + waitRejoinStartGameMsgBox->raise(); + waitRejoinStartGameMsgBox->activateWindow(); + pushButton_Leave->setDisabled(true); // } } } diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index 7453998d..eb819c3c 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -907,19 +907,19 @@ void gameTableImpl::refreshPlayerName() case SEAT_ACTIVE: { playerNameLabelArray[(*it_c)->getMyID()]->setText(nick, FALSE, guest, computerPlayer ); } - break; + break; case SEAT_AUTOFOLD: { playerNameLabelArray[(*it_c)->getMyID()]->setText(nick, TRUE, guest, computerPlayer ); } - break; + break; case SEAT_STAYONTABLE: { playerNameLabelArray[(*it_c)->getMyID()]->setText(nick, TRUE, guest, computerPlayer ); } - break; + break; case SEAT_CLEAR: { playerNameLabelArray[(*it_c)->getMyID()]->setText(""); } - break; + break; default: { playerNameLabelArray[(*it_c)->getMyID()]->setText(""); } @@ -952,8 +952,7 @@ void gameTableImpl::refreshPlayerAvatar() QPixmap avatarPic; if((*it_c)->getMyAvatar() == "" || !myAvatarFile.exists()) { avatarPic = QPixmap::fromImage(QImage(myGameTableStyle->getDefaultAvatar())); - } - else { + } else { avatarPic = QPixmap::fromImage(QImage(QString::fromUtf8((*it_c)->getMyAvatar().c_str()))); } @@ -964,21 +963,21 @@ void gameTableImpl::refreshPlayerAvatar() // qDebug() << seatPlace << "AVATAR ACTIVE"; playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmapAndCountry(avatarPic, countryString, seatPlace); } - break; + break; case SEAT_AUTOFOLD: { // qDebug() << seatPlace << "AVATAR AUTOFOLD"; playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmapAndCountry(avatarPic, countryString, seatPlace, TRUE); } - break; + break; case SEAT_STAYONTABLE: { // qDebug() << seatPlace << "AVATAR STAYONTABLE"; playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmapAndCountry(avatarPic, countryString, seatPlace, TRUE); } - break; + break; case SEAT_CLEAR: { playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); } - break; + break; default: { playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); } @@ -1084,20 +1083,20 @@ void gameTableImpl::refreshCash() // qDebug() << (*it_c)->getMyID() << "CASH ACTIVE"; cashLabelArray[(*it_c)->getMyID()]->setText("$"+QString("%L1").arg((*it_c)->getMyCash())); } - break; + break; case SEAT_AUTOFOLD: { // qDebug() << (*it_c)->getMyID() << "CASH AUTOFOLD"; //TODO transparent cashLabelArray[(*it_c)->getMyID()]->setText("$"+QString("%L1").arg((*it_c)->getMyCash()), transparent); } - break; + break; case SEAT_STAYONTABLE: { cashLabelArray[(*it_c)->getMyID()]->setText(""); } - break; + break; case SEAT_CLEAR: { cashLabelArray[(*it_c)->getMyID()]->setText(""); } - break; + break; default: { cashLabelArray[(*it_c)->getMyID()]->setText(""); } @@ -3830,21 +3829,19 @@ void gameTableImpl::hide() QWidget::hide(); } -SeatState gameTableImpl::getCurrentSeatState(boost::shared_ptr player) { +SeatState gameTableImpl::getCurrentSeatState(boost::shared_ptr player) +{ if(player->getMyActiveStatus()) { if(player->isSessionActive()) { return SEAT_ACTIVE; - } - else { + } else { return SEAT_AUTOFOLD; } - } - else { + } else { if(player->getMyStayOnTableStatus() && (myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK)) { return SEAT_STAYONTABLE; - } - else { + } else { return SEAT_CLEAR; } } diff --git a/src/gui/qt/gametable/gametableimpl.h b/src/gui/qt/gametable/gametableimpl.h index 746dedf8..1b93abf2 100755 --- a/src/gui/qt/gametable/gametableimpl.h +++ b/src/gui/qt/gametable/gametableimpl.h @@ -68,7 +68,7 @@ public: SDLPlayer* getMySDLPlayer() const { return mySDLPlayer; } - SoundEvents* getMySoundEventHandler() const{ + SoundEvents* getMySoundEventHandler() const { return mySoundEventHandler; } ChatTools* getMyChat() const { diff --git a/src/gui/qt/gametable/log/guilog.cpp b/src/gui/qt/gametable/log/guilog.cpp index f0768f57..953ff7c8 100644 --- a/src/gui/qt/gametable/log/guilog.cpp +++ b/src/gui/qt/gametable/log/guilog.cpp @@ -684,18 +684,25 @@ int guiLog::exportLog(QString fileStringPdb,int modus) { bool neu = false; + result_struct results; + results.result_Session = 0; + results.result_Game = 0; + results.result_Hand = 0; + results.result_Hand_ID = 0; + results.result_Action = 0; + string sql = ""; string log_string = ""; string round_string = ""; string action_string = ""; bool data_found = false; - char **result_Session = 0, **result_Game = 0, **result_Hand = 0, **result_Hand_ID = 0, **result_Action = 0; int nRow_Session=0, nRow_Game=0, nRow_Hand=0, nRow_Hand_ID=0, nRow_Action=0; int nCol_Session=0, nCol_Game=0, nCol_Hand=0, nCol_Action=0; char *errmsg = 0; int game_ctr = 0, hand_ctr = 0, round_ctr = 0, action_ctr = 0; int i = 0, j = 0; - int gameID = 0; int uniqueGameID = 0; + int gameID = 0; + int uniqueGameID = 0; string cmpString = "", string_tmp = ""; string player[MAX_NUMBER_OF_PLAYERS]; for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) { @@ -709,14 +716,14 @@ int guiLog::exportLog(QString fileStringPdb,int modus) // read session sql = "SELECT * FROM Session"; - if(sqlite3_get_table(mySqliteLogDb,sql.data(),&result_Session,&nRow_Session,&nCol_Session,&errmsg) != SQLITE_OK) { + if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Session,&nRow_Session,&nCol_Session,&errmsg) != SQLITE_OK) { cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } if(nRow_Session<1 || nRow_Session>1) { cout << "Number of Sessions implausible!" << endl; - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } @@ -725,14 +732,14 @@ int guiLog::exportLog(QString fileStringPdb,int modus) // pokerth version data_found = false; for(i=0; i(result_Session[i]) == "PokerTH_Version") { - log_string += boost::lexical_cast(result_Session[i+nCol_Session]); + if(boost::lexical_cast(results.result_Session[i]) == "PokerTH_Version") { + log_string += boost::lexical_cast(results.result_Session[i+nCol_Session]); data_found = true; } } if(!data_found) { cout << "Missing PokerTH version information!" << endl; - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } @@ -741,14 +748,14 @@ int guiLog::exportLog(QString fileStringPdb,int modus) // logging date data_found = false; for(i=0; i(result_Session[i]) == "Date") { - log_string += boost::lexical_cast(result_Session[i+nCol_Session]); + if(boost::lexical_cast(results.result_Session[i]) == "Date") { + log_string += boost::lexical_cast(results.result_Session[i+nCol_Session]); data_found = true; } } if(!data_found) { cout << "Missing date information!" << endl; - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } @@ -757,18 +764,18 @@ int guiLog::exportLog(QString fileStringPdb,int modus) // logging time data_found = false; for(i=0; i(result_Session[i]) == "Time") { - log_string += boost::lexical_cast(result_Session[i+nCol_Session]); + if(boost::lexical_cast(results.result_Session[i]) == "Time") { + log_string += boost::lexical_cast(results.result_Session[i+nCol_Session]); data_found = true; } } if(!data_found) { cout << "Missing time information!" << endl; - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } - sqlite3_free_table(result_Session); +// sqlite3_free_table(results.result_Session); switch(modus) { case 1: @@ -789,9 +796,9 @@ int guiLog::exportLog(QString fileStringPdb,int modus) // read game sql = "SELECT * FROM Game"; - if(sqlite3_get_table(mySqliteLogDb,sql.data(),&result_Game,&nRow_Game,&nCol_Game,&errmsg) != SQLITE_OK) { + if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Game,&nRow_Game,&nCol_Game,&errmsg) != SQLITE_OK) { cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } @@ -801,28 +808,28 @@ int guiLog::exportLog(QString fileStringPdb,int modus) // unique game id data_found = false; for(i=0; i(result_Game[i]) == "UniqueGameID") { - uniqueGameID = boost::lexical_cast(result_Game[i+nCol_Game*game_ctr]); + if(boost::lexical_cast(results.result_Game[i]) == "UniqueGameID") { + uniqueGameID = boost::lexical_cast(results.result_Game[i+nCol_Game*game_ctr]); data_found = true; } } if(!data_found) { - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } // game id data_found = false; for(i=0; i(result_Game[i]) == "GameID") { - gameID = boost::lexical_cast(result_Game[i+nCol_Game*game_ctr]); + if(boost::lexical_cast(results.result_Game[i]) == "GameID") { + gameID = boost::lexical_cast(results.result_Game[i+nCol_Game*game_ctr]); data_found = true; } } if(!data_found) { - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } @@ -832,11 +839,11 @@ int guiLog::exportLog(QString fileStringPdb,int modus) for(j=0; j(i); - if(boost::lexical_cast(result_Game[j]) == cmpString) { + if(boost::lexical_cast(results.result_Game[j]) == cmpString) { // Seat found - if(result_Game[j+nCol_Game*game_ctr]) { + if(results.result_Game[j+nCol_Game*game_ctr]) { // the Seat is not empty - player[i-1] = boost::lexical_cast(result_Game[j+nCol_Game*game_ctr]); + player[i-1] = boost::lexical_cast(results.result_Game[j+nCol_Game*game_ctr]); } else { player[i-1] = ""; } @@ -845,7 +852,7 @@ int guiLog::exportLog(QString fileStringPdb,int modus) } if(!data_found) { cout << "Missing some seats!" << endl; - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } } @@ -853,9 +860,9 @@ int guiLog::exportLog(QString fileStringPdb,int modus) // read all hand id sql = "SELECT HandID FROM Hand WHERE UniqueGameID="; sql+= boost::lexical_cast(uniqueGameID); - if(sqlite3_get_table(mySqliteLogDb,sql.data(),&result_Hand_ID,&nRow_Hand_ID,&nCol_Hand,&errmsg) != SQLITE_OK) { + if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Hand_ID,&nRow_Hand_ID,&nCol_Hand,&errmsg) != SQLITE_OK) { cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } @@ -866,7 +873,7 @@ int guiLog::exportLog(QString fileStringPdb,int modus) log_string += "Game: "; log_string += boost::lexical_cast(gameID); log_string += " | Hand: "; - log_string += boost::lexical_cast(result_Hand_ID[hand_ctr]); + log_string += boost::lexical_cast(results.result_Hand_ID[hand_ctr]); switch(modus) { case 1: @@ -890,10 +897,10 @@ int guiLog::exportLog(QString fileStringPdb,int modus) sql = "SELECT * FROM Hand WHERE UniqueGameID="; sql+= boost::lexical_cast(uniqueGameID); sql+= " AND HandID="; - sql+= boost::lexical_cast(result_Hand_ID[hand_ctr]); - if(sqlite3_get_table(mySqliteLogDb,sql.data(),&result_Hand,&nRow_Hand,&nCol_Hand,&errmsg) != SQLITE_OK) { + sql+= boost::lexical_cast(results.result_Hand_ID[hand_ctr]); + if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Hand,&nRow_Hand,&nCol_Hand,&errmsg) != SQLITE_OK) { cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } @@ -904,14 +911,14 @@ int guiLog::exportLog(QString fileStringPdb,int modus) // read small blind amount data_found = false; for(i=0; i(result_Hand[i]) == "Sb_Amount") { - log_string += boost::lexical_cast(result_Hand[i+nCol_Hand]); + if(boost::lexical_cast(results.result_Hand[i]) == "Sb_Amount") { + log_string += boost::lexical_cast(results.result_Hand[i+nCol_Hand]); data_found = true; } } if(!data_found) { cout << "Missing small blind information!" << endl; - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } @@ -920,14 +927,14 @@ int guiLog::exportLog(QString fileStringPdb,int modus) // read big blind amount data_found = false; for(i=0; i(result_Hand[i]) == "Bb_Amount") { - log_string += boost::lexical_cast(result_Hand[i+nCol_Hand]); + if(boost::lexical_cast(results.result_Hand[i]) == "Bb_Amount") { + log_string += boost::lexical_cast(results.result_Hand[i+nCol_Hand]); data_found = true; } } if(!data_found) { cout << "Missing big blind information!" << endl; - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } @@ -954,8 +961,8 @@ int guiLog::exportLog(QString fileStringPdb,int modus) cmpString = "Seat_"; cmpString+= boost::lexical_cast(i); cmpString+= "_Cash"; - if(boost::lexical_cast(result_Hand[j]) == cmpString) { // seat found - if(result_Hand[j+nCol_Hand]) { // player has cash > 0 + if(boost::lexical_cast(results.result_Hand[j]) == cmpString) { // seat found + if(results.result_Hand[j+nCol_Hand]) { // player has cash > 0 log_string += "Seat "; log_string += boost::lexical_cast(i); log_string += ": "; @@ -967,7 +974,7 @@ int guiLog::exportLog(QString fileStringPdb,int modus) log_string += ""; } log_string += " ($"; - log_string += boost::lexical_cast(result_Hand[j+nCol_Hand]); + log_string += boost::lexical_cast(results.result_Hand[j+nCol_Hand]); log_string += ")"; switch(modus) { case 1: @@ -988,8 +995,8 @@ int guiLog::exportLog(QString fileStringPdb,int modus) } } if(!data_found) { - cout << "Missing seat information in uniqueGame " << uniqueGameID << " and hand " << result_Hand_ID[hand_ctr] << "!" << endl; - sqlite3_close(mySqliteLogDb); + cout << "Missing seat information in uniqueGame " << uniqueGameID << " and hand " << results.result_Hand_ID[hand_ctr] << "!" << endl; + cleanUp(results, mySqliteLogDb); return 1; } } @@ -1002,28 +1009,30 @@ int guiLog::exportLog(QString fileStringPdb,int modus) sql = "SELECT Player,Action,Amount FROM Action WHERE UniqueGameID="; sql += boost::lexical_cast(uniqueGameID); sql += " AND HandID="; - sql += boost::lexical_cast(result_Hand_ID[hand_ctr]); - sql += " AND BeRo=0"; + sql += boost::lexical_cast(results.result_Hand_ID[hand_ctr]); + sql += " AND BeRo="; + sql += boost::lexical_cast(GAME_STATE_PREFLOP); + sql += " AND (Action='posts small blind' OR Action='posts big blind' OR Action='starts as dealer')"; - if(sqlite3_get_table(mySqliteLogDb,sql.data(),&result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) { + if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) { cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } if(nRow_Action<1) { - cout << "Missing information about dealer and blinds in uniqueGame " << uniqueGameID << " hand " << result_Hand_ID[hand_ctr] << "!" << endl; - sqlite3_close(mySqliteLogDb); + cout << "Missing information about dealer and blinds in uniqueGame " << uniqueGameID << " hand " << results.result_Hand_ID[hand_ctr] << "!" << endl; + cleanUp(results, mySqliteLogDb); return 1; } // log dealer and blind setting for(i=1; i<=nRow_Action; i++) { - log_string += player[boost::lexical_cast(result_Action[3*i])-1]; + log_string += player[boost::lexical_cast(results.result_Action[3*i])-1]; log_string += " "; - log_string += boost::lexical_cast(result_Action[3*i+1]); - if(result_Action[3*i+2]) { + log_string += boost::lexical_cast(results.result_Action[3*i+1]); + if(results.result_Action[3*i+2]) { // with amount log_string += " $"; - log_string += boost::lexical_cast(result_Action[3*i+2]); + log_string += boost::lexical_cast(results.result_Action[3*i+2]); } log_string += "."; switch(modus) { @@ -1033,12 +1042,15 @@ int guiLog::exportLog(QString fileStringPdb,int modus) case 2: log_string += "\n"; break; + case 3: + log_string += "
"; + break; default: ; } } - sqlite3_free_table(result_Action); +// sqlite3_free_table(results.result_Action); } else { @@ -1048,69 +1060,69 @@ int guiLog::exportLog(QString fileStringPdb,int modus) sql = "SELECT Player,Amount FROM Action WHERE UniqueGameID="; sql += boost::lexical_cast(uniqueGameID); sql += " AND HandID="; - sql += boost::lexical_cast(result_Hand_ID[hand_ctr]); + sql += boost::lexical_cast(results.result_Hand_ID[hand_ctr]); sql += " AND BeRo=0 AND Action='posts small blind'"; - if(sqlite3_get_table(mySqliteLogDb,sql.data(),&result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) { + if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) { cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } if(nRow_Action<1 || nRow_Action>1) { - cout << "Missing information about small blinds in uniqueGame " << uniqueGameID << " hand " << result_Hand_ID[hand_ctr] << "!" << endl; - sqlite3_close(mySqliteLogDb); + cout << "Wrong information about small blind in uniqueGame " << uniqueGameID << " hand " << results.result_Hand_ID[hand_ctr] << "!" << endl; + cleanUp(results, mySqliteLogDb); return 1; } // log small blind - log_string += player[boost::lexical_cast(result_Action[2])-1]; + log_string += player[boost::lexical_cast(results.result_Action[2])-1]; log_string += " ($"; - log_string += boost::lexical_cast(result_Action[3]); + log_string += boost::lexical_cast(results.result_Action[3]); log_string += "), "; - sqlite3_free_table(result_Action); +// sqlite3_free_table(results.result_Action); // read big blind sql = "SELECT Player,Amount FROM Action WHERE UniqueGameID="; sql += boost::lexical_cast(uniqueGameID); sql += " AND HandID="; - sql += boost::lexical_cast(result_Hand_ID[hand_ctr]); + sql += boost::lexical_cast(results.result_Hand_ID[hand_ctr]); sql += " AND BeRo=0 AND Action='posts big blind'"; - if(sqlite3_get_table(mySqliteLogDb,sql.data(),&result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) { + if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) { cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } if(nRow_Action<1 || nRow_Action>1) { - cout << "Missing information about small blinds in uniqueGame " << uniqueGameID << " hand " << result_Hand_ID[hand_ctr] << "!" << endl; - sqlite3_close(mySqliteLogDb); + cout << "Wrong information about big blind in uniqueGame " << uniqueGameID << " hand " << results.result_Hand_ID[hand_ctr] << "!" << endl; + cleanUp(results, mySqliteLogDb); return 1; } // log big blind - log_string += player[boost::lexical_cast(result_Action[2])-1]; + log_string += player[boost::lexical_cast(results.result_Action[2])-1]; log_string += " ($"; - log_string += boost::lexical_cast(result_Action[3]); + log_string += boost::lexical_cast(results.result_Action[3]); log_string += ")"; - sqlite3_free_table(result_Action); +// sqlite3_free_table(results.result_Action); // read dealer sql = "SELECT Player,Amount FROM Action WHERE UniqueGameID="; sql += boost::lexical_cast(uniqueGameID); sql += " AND HandID="; - sql += boost::lexical_cast(result_Hand_ID[hand_ctr]); + sql += boost::lexical_cast(results.result_Hand_ID[hand_ctr]); sql += " AND BeRo=0 AND Action='starts as dealer'"; - if(sqlite3_get_table(mySqliteLogDb,sql.data(),&result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) { + if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) { cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } if(nRow_Action>1) { - cout << "Implausible information about dealer in uniqueGame " << uniqueGameID << " hand " << result_Hand_ID[hand_ctr] << "!" << endl; - sqlite3_close(mySqliteLogDb); + cout << "Implausible information about dealer in uniqueGame " << uniqueGameID << " hand " << results.result_Hand_ID[hand_ctr] << "!" << endl; + cleanUp(results, mySqliteLogDb); return 1; } @@ -1129,11 +1141,11 @@ int guiLog::exportLog(QString fileStringPdb,int modus) default: ; } - log_string += player[boost::lexical_cast(result_Action[2])-1]; + log_string += player[boost::lexical_cast(results.result_Action[2])-1]; log_string += " starts as dealer."; } - sqlite3_free_table(result_Action); +// sqlite3_free_table(results.result_Action); } @@ -1189,13 +1201,13 @@ int guiLog::exportLog(QString fileStringPdb,int modus) for(i=1; i<=round_ctr+2; i++) { data_found = false; for(j=0; j(result_Hand[j]) == "BoardCard_"+boost::lexical_cast(i)) { - if(result_Hand[j+nCol_Hand]) { + if(boost::lexical_cast(results.result_Hand[j]) == "BoardCard_"+boost::lexical_cast(i)) { + if(results.result_Hand[j+nCol_Hand]) { if(modus == 1 || modus == 3) round_string += ""; - string_tmp = convertCardIntToString(boost::lexical_cast(result_Hand[j+nCol_Hand])); + string_tmp = convertCardIntToString(boost::lexical_cast(results.result_Hand[j+nCol_Hand])); if(string_tmp == "") { - cout << "Implausible board card in uniqueGame " << uniqueGameID << " hand " << result_Hand_ID[hand_ctr] << "!" << endl; - sqlite3_close(mySqliteLogDb); + cout << "Implausible board card in uniqueGame " << uniqueGameID << " hand " << results.result_Hand_ID[hand_ctr] << "!" << endl; + cleanUp(results, mySqliteLogDb); return 1; } round_string += boost::lexical_cast(string_tmp.at(0)); @@ -1221,14 +1233,14 @@ int guiLog::exportLog(QString fileStringPdb,int modus) sql = "SELECT Player,Action,Amount FROM Action WHERE UniqueGameID="; sql += boost::lexical_cast(uniqueGameID); sql += " AND HandID="; - sql += boost::lexical_cast(result_Hand_ID[hand_ctr]); + sql += boost::lexical_cast(results.result_Hand_ID[hand_ctr]); sql += " AND BeRo="; sql += boost::lexical_cast(round_ctr); sql += " AND Action<>'starts as dealer' AND Action<>'posts big blind' AND Action<>'posts small blind'"; - if(sqlite3_get_table(mySqliteLogDb,sql.data(),&result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) { + if(sqlite3_get_table(mySqliteLogDb,sql.data(),&results.result_Action,&nRow_Action,&nCol_Action,&errmsg) != SQLITE_OK) { cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; - sqlite3_close(mySqliteLogDb); + cleanUp(results, mySqliteLogDb); return 1; } @@ -1236,7 +1248,7 @@ int guiLog::exportLog(QString fileStringPdb,int modus) switch(modus) { case 1: if(!neu) { - if(action_ctr>1 && (boost::lexical_cast(result_Action[3*(action_ctr-1)+1]) == "wins" || boost::lexical_cast(result_Action[3*(action_ctr-1)+1]) == "sits out" || boost::lexical_cast(result_Action[3*(action_ctr-1)+1]) == "wins (side pot)")) + if(action_ctr>1 && (boost::lexical_cast(results.result_Action[3*(action_ctr-1)+1]) == "wins" || boost::lexical_cast(results.result_Action[3*(action_ctr-1)+1]) == "sits out" || boost::lexical_cast(results.result_Action[3*(action_ctr-1)+1]) == "wins (side pot)")) log_string += "\n"; else log_string += "
\n"; @@ -1253,24 +1265,24 @@ int guiLog::exportLog(QString fileStringPdb,int modus) default: ; } - if(!neu && boost::lexical_cast(result_Action[3*action_ctr+1]) == "wins (side pot)") { - action_string += player[boost::lexical_cast(result_Action[3*action_ctr])-1]; + if(!neu && boost::lexical_cast(results.result_Action[3*action_ctr+1]) == "wins (side pot)") { + action_string += player[boost::lexical_cast(results.result_Action[3*action_ctr])-1]; action_string += " wins $"; - action_string += boost::lexical_cast(result_Action[3*action_ctr+2]); + action_string += boost::lexical_cast(results.result_Action[3*action_ctr+2]); action_string += " (side pot)"; } else { - action_string += player[boost::lexical_cast(result_Action[3*action_ctr])-1]; + action_string += player[boost::lexical_cast(results.result_Action[3*action_ctr])-1]; action_string += " "; - action_string += boost::lexical_cast(result_Action[3*action_ctr+1]); - if(result_Action[3*action_ctr+2]) { + action_string += boost::lexical_cast(results.result_Action[3*action_ctr+1]); + if(results.result_Action[3*action_ctr+2]) { // with amount action_string += " $"; - action_string += boost::lexical_cast(result_Action[3*action_ctr+2]); + action_string += boost::lexical_cast(results.result_Action[3*action_ctr+2]); } } // wins game - if(boost::lexical_cast(result_Action[3*action_ctr+1]) == "wins game") { + if(boost::lexical_cast(results.result_Action[3*action_ctr+1]) == "wins game") { switch(modus) { case 1: if(!neu) action_string = "

" + action_string + " " + boost::lexical_cast(gameID) + "!
"; @@ -1288,7 +1300,7 @@ int guiLog::exportLog(QString fileStringPdb,int modus) } // wins - if(boost::lexical_cast(result_Action[3*action_ctr+1]) == "wins" || boost::lexical_cast(result_Action[3*action_ctr+1]) == "wins (side pot)") { + if(boost::lexical_cast(results.result_Action[3*action_ctr+1]) == "wins" || boost::lexical_cast(results.result_Action[3*action_ctr+1]) == "wins (side pot)" || boost::lexical_cast(results.result_Action[3*action_ctr+1]) == "has left the game" || boost::lexical_cast(results.result_Action[3*action_ctr+1]) == "was kicked from the game" || boost::lexical_cast(results.result_Action[3*action_ctr+1]) == "is game admin now" || boost::lexical_cast(results.result_Action[3*action_ctr+1]) == "has joined the game") { switch(modus) { case 1: if(!neu) action_string = "
" + action_string + ""; @@ -1303,7 +1315,7 @@ int guiLog::exportLog(QString fileStringPdb,int modus) } // sits out - if(boost::lexical_cast(result_Action[3*action_ctr+1]) == "sits out") { + if(boost::lexical_cast(results.result_Action[3*action_ctr+1]) == "sits out") { switch(modus) { case 1: if(!neu) action_string = "
" + action_string + ""; @@ -1321,7 +1333,7 @@ int guiLog::exportLog(QString fileStringPdb,int modus) action_string = ""; // show cards - if(boost::lexical_cast(result_Action[3*action_ctr+1]) == "shows" || boost::lexical_cast(result_Action[3*action_ctr+1]) == "has") { + if(boost::lexical_cast(results.result_Action[3*action_ctr+1]) == "shows" || boost::lexical_cast(results.result_Action[3*action_ctr+1]) == "has") { // log cards if(!neu && round_ctr == GAME_STATE_POST_RIVER) log_string += " [ "; else log_string += " ["; @@ -1331,13 +1343,13 @@ int guiLog::exportLog(QString fileStringPdb,int modus) data_found = false; for(i=0; i(result_Action[3*action_ctr]); + cmpString += boost::lexical_cast(results.result_Action[3*action_ctr]); cmpString += "_Card_1"; - if(boost::lexical_cast(result_Hand[i]) == cmpString) { - string_tmp = convertCardIntToString(boost::lexical_cast(result_Hand[i+nCol_Hand])); + if(boost::lexical_cast(results.result_Hand[i]) == cmpString) { + string_tmp = convertCardIntToString(boost::lexical_cast(results.result_Hand[i+nCol_Hand])); if(string_tmp == "") { - cout << "Hole card information implausible in uniqueGame " << uniqueGameID << " hand " << result_Hand_ID[hand_ctr] << "!" << endl; - sqlite3_close(mySqliteLogDb); + cout << "Hole card information implausible in uniqueGame " << uniqueGameID << " hand " << results.result_Hand_ID[hand_ctr] << "!" << endl; + cleanUp(results, mySqliteLogDb); return 1; } log_string += boost::lexical_cast(string_tmp.at(0)); @@ -1349,8 +1361,8 @@ int guiLog::exportLog(QString fileStringPdb,int modus) } } if(!data_found) { - cout << "Missing hole card information in uniqueGame " << uniqueGameID << " hand " << result_Hand_ID[hand_ctr] << "!" << endl; - sqlite3_close(mySqliteLogDb); + cout << "Missing hole card information in uniqueGame " << uniqueGameID << " hand " << results.result_Hand_ID[hand_ctr] << "!" << endl; + cleanUp(results, mySqliteLogDb); return 1; } @@ -1358,13 +1370,13 @@ int guiLog::exportLog(QString fileStringPdb,int modus) data_found = false; for(i=0; i(result_Action[3*action_ctr]); + cmpString += boost::lexical_cast(results.result_Action[3*action_ctr]); cmpString += "_Card_2"; - if(boost::lexical_cast(result_Hand[i]) == cmpString) { - string_tmp = convertCardIntToString(boost::lexical_cast(result_Hand[i+nCol_Hand])); + if(boost::lexical_cast(results.result_Hand[i]) == cmpString) { + string_tmp = convertCardIntToString(boost::lexical_cast(results.result_Hand[i+nCol_Hand])); if(string_tmp == "") { - cout << "Hole card information implausible in uniqueGame " << uniqueGameID << " hand " << result_Hand_ID[hand_ctr] << "!" << endl; - sqlite3_close(mySqliteLogDb); + cout << "Hole card information implausible in uniqueGame " << uniqueGameID << " hand " << results.result_Hand_ID[hand_ctr] << "!" << endl; + cleanUp(results, mySqliteLogDb); return 1; } log_string += boost::lexical_cast(string_tmp.at(0)); @@ -1375,40 +1387,40 @@ int guiLog::exportLog(QString fileStringPdb,int modus) } } if(!data_found) { - cout << "Missing hole card information in uniqueGame " << uniqueGameID << " hand " << result_Hand_ID[hand_ctr] << "!" << endl; - sqlite3_close(mySqliteLogDb); + cout << "Missing hole card information in uniqueGame " << uniqueGameID << " hand " << results.result_Hand_ID[hand_ctr] << "!" << endl; + cleanUp(results, mySqliteLogDb); return 1; } if(round_ctr == GAME_STATE_POST_RIVER) { // find hand name - data_found = false; +// data_found = false; for(i=0; i(result_Action[3*action_ctr]); + cmpString += boost::lexical_cast(results.result_Action[3*action_ctr]); cmpString += "_Hand_text"; - if(boost::lexical_cast(result_Hand[i]) == cmpString) { - log_string += " - " + boost::lexical_cast(result_Hand[i+nCol_Hand]); - data_found = true; + if(boost::lexical_cast(results.result_Hand[i]) == cmpString && results.result_Hand[i+nCol_Hand]) { + log_string += " - " + boost::lexical_cast(results.result_Hand[i+nCol_Hand]); +// data_found = true; } } - if(!data_found) { - cout << "Missing hand name information in uniqueGame " << uniqueGameID << " hand " << result_Hand_ID[hand_ctr] << "!" << endl; - sqlite3_close(mySqliteLogDb); - return 1; - } +// if(!data_found) { +// cout << "Missing hand name information in uniqueGame " << uniqueGameID << " hand " << results.result_Hand_ID[hand_ctr] << "!" << endl; +// sqlite3_close(mySqliteLogDb); +// return 1; +// } } } - if(!neu && boost::lexical_cast(result_Action[3*action_ctr+1]) != "wins" && boost::lexical_cast(result_Action[3*action_ctr+1]) != "shows" && boost::lexical_cast(result_Action[3*action_ctr+1]) != "has" && boost::lexical_cast(result_Action[3*action_ctr+1]) != "sits out" && boost::lexical_cast(result_Action[3*action_ctr+1]) != "wins (side pot)" && boost::lexical_cast(result_Action[3*action_ctr+1]) != "wins game") { + if(!neu && boost::lexical_cast(results.result_Action[3*action_ctr+1]) != "wins" && boost::lexical_cast(results.result_Action[3*action_ctr+1]) != "shows" && boost::lexical_cast(results.result_Action[3*action_ctr+1]) != "has" && boost::lexical_cast(results.result_Action[3*action_ctr+1]) != "sits out" && boost::lexical_cast(results.result_Action[3*action_ctr+1]) != "wins (side pot)" && boost::lexical_cast(results.result_Action[3*action_ctr+1]) != "wins game") { log_string += "."; } - if(neu && boost::lexical_cast(result_Action[3*action_ctr+1]) != "wins game") log_string += "."; + if(neu && boost::lexical_cast(results.result_Action[3*action_ctr+1]) != "wins game") log_string += "."; } - sqlite3_free_table(result_Action); +// sqlite3_free_table(results.result_Action); } @@ -1424,10 +1436,23 @@ int guiLog::exportLog(QString fileStringPdb,int modus) } + cleanUp(results, mySqliteLogDb); + return 0; } +void guiLog::cleanUp(result_struct &results, sqlite3 *mySqliteLogDb) +{ + + sqlite3_free_table(results.result_Session); + sqlite3_free_table(results.result_Game); + sqlite3_free_table(results.result_Hand); + sqlite3_free_table(results.result_Hand_ID); + sqlite3_free_table(results.result_Action); + sqlite3_close(mySqliteLogDb); +} + int guiLog::convertCardStringToInt(string val, string col) { diff --git a/src/gui/qt/gametable/log/guilog.h b/src/gui/qt/gametable/log/guilog.h index 666bd7c9..e28e5b73 100644 --- a/src/gui/qt/gametable/log/guilog.h +++ b/src/gui/qt/gametable/log/guilog.h @@ -29,6 +29,14 @@ #include #include +struct result_struct { + char **result_Session; + char **result_Game; + char **result_Hand; + char **result_Hand_ID; + char **result_Action; +}; + class gameTableImpl; class GameTableStyleReader; @@ -87,6 +95,7 @@ private: void writeLogFileStream(std::string log_string, QFile *LogFile); void writeLog(std::string log_string, int modus); + void cleanUp(result_struct &results, sqlite3 *mySqliteLogDb); int convertCardStringToInt(std::string val, std::string col); std::string convertCardIntToString(int code); diff --git a/src/gui/qt/gametable/myavatarlabel.cpp b/src/gui/qt/gametable/myavatarlabel.cpp index f9aa1d31..bdbdf5c4 100644 --- a/src/gui/qt/gametable/myavatarlabel.cpp +++ b/src/gui/qt/gametable/myavatarlabel.cpp @@ -172,11 +172,11 @@ void MyAvatarLabel::refreshStars() #ifdef _WIN32 fontSize = "10"; #else - #ifdef __APPLE__ - fontSize = "7"; - #else - fontSize = "12"; - #endif +#ifdef __APPLE__ + fontSize = "7"; +#else + fontSize = "12"; +#endif #endif boost::shared_ptr curGame = myW->myStartWindow->getSession()->getCurrentGame(); diff --git a/src/gui/qt/gametable/mynamelabel.cpp b/src/gui/qt/gametable/mynamelabel.cpp index 30a6fff9..db6d6526 100644 --- a/src/gui/qt/gametable/mynamelabel.cpp +++ b/src/gui/qt/gametable/mynamelabel.cpp @@ -76,8 +76,7 @@ void MyNameLabel::setText ( const QString &t, bool trans, bool guest, bool compu } linkString = QString("http://pokerth.net/redirect_user_profile.php?tableview=1"+nickList+"&table="+QUrl::toPercentEncoding(QString::fromUtf8(info.name.c_str()))); - } - else { + } else { linkString = QString("http://pokerth.net/redirect_user_profile.php?nick="+QUrl::toPercentEncoding(t)); } diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index ec29bd7b..e4a37c6e 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -17,14 +17,16 @@ *****************************************************************************/ #include "guiwrapper.h" #include "session.h" +#include "game.h" +#include "playerinterface.h" #include "guilog.h" +#include "log.h" #include "gametableimpl.h" #include "startwindowimpl.h" #include "configfile.h" #include "soundevents.h" #include - using namespace std; @@ -364,7 +366,6 @@ void GuiWrapper::SignalNetClientNewGameAdmin(unsigned playerId, const string &pl myStartWindow->signalNetClientNewGameAdmin(playerId, QString::fromUtf8(playerName.c_str())); if (!playerName.empty() && playerName[0] != '#' && myW->isVisible()) myGuiLog->signalLogNewGameAdminMsg(QString::fromUtf8(playerName.c_str())); - } void GuiWrapper::SignalNetClientGameListNew(unsigned gameId) diff --git a/src/gui/qt/sound/soundevents.cpp b/src/gui/qt/sound/soundevents.cpp index dc825272..3bb3eab0 100644 --- a/src/gui/qt/sound/soundevents.cpp +++ b/src/gui/qt/sound/soundevents.cpp @@ -16,8 +16,7 @@ SoundEvents::~SoundEvents() void SoundEvents::blindsWereSet(int sB) { - if(newGameNow) - { + if(newGameNow) { lastSBLevel = 0; lastSBValue = sB; newGameNow = false; @@ -28,16 +27,13 @@ void SoundEvents::blindsWereSet(int sB) lastSBValue = sB; ++lastSBLevel; - if(lastSBLevel == 1 || lastSBLevel == 2) - { + if(lastSBLevel == 1 || lastSBLevel == 2) { mySDLPlayer->playSound("blinds_raises_level1", 0); } - if(lastSBLevel == 3 || lastSBLevel == 4) - { + if(lastSBLevel == 3 || lastSBLevel == 4) { mySDLPlayer->playSound("blinds_raises_level2", 0); } - if(lastSBLevel >= 5) - { + if(lastSBLevel >= 5) { mySDLPlayer->playSound("blinds_raises_level3", 0); } } diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index 1a460b1a..9ea30caa 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -1642,17 +1642,16 @@ ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr client boost::shared_ptr tmpPlayer = client->GetGame()->getPlayerByNumber((i + numberDiff) % client->GetStartData().numberOfPlayers); if (!tmpPlayer) throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0); - switch (*seatState) - { - case NetPlayerState_playerStateNormal : - tmpPlayer->setIsSessionActive(true); - break; - case NetPlayerState_playerStateSessionInactive : - tmpPlayer->setIsSessionActive(false); - break; - case NetPlayerState_playerStateNoMoney : - tmpPlayer->setMyCash(0); - break; + switch (*seatState) { + case NetPlayerState_playerStateNormal : + tmpPlayer->setIsSessionActive(true); + break; + case NetPlayerState_playerStateSessionInactive : + tmpPlayer->setIsSessionActive(false); + break; + case NetPlayerState_playerStateNoMoney : + tmpPlayer->setMyCash(0); + break; } } } diff --git a/src/net/common/clientthread.cpp b/src/net/common/clientthread.cpp index 083cc062..fc55cd51 100644 --- a/src/net/common/clientthread.cpp +++ b/src/net/common/clientthread.cpp @@ -752,6 +752,11 @@ ClientThread::SetNewGameAdmin(unsigned id) if (playerData.get()) { playerData->SetGameAdmin(true); GetCallback().SignalNetClientNewGameAdmin(id, playerData->GetName()); + m_clientLog->logPlayerAction( + m_game->getCurrentHand()->getCurrentRound(), + m_game->getPlayerByUniqueId(id)->getMyID()+1, + LOG_ACTION_ADMIN + ); } } @@ -1058,7 +1063,7 @@ ClientThread::CreatePlayerData(unsigned playerId, bool isGameAdmin) if (GetCachedPlayerInfo(playerId, info)) { playerData.reset( new PlayerData(playerId, 0, info.ptype, - info.isGuest ? PLAYER_RIGHTS_GUEST : PLAYER_RIGHTS_NORMAL, isGameAdmin)); + info.isGuest ? PLAYER_RIGHTS_GUEST : PLAYER_RIGHTS_NORMAL, isGameAdmin)); playerData->SetName(info.playerName); if (info.hasAvatar) { string avatarFile; @@ -1118,6 +1123,21 @@ ClientThread::RemovePlayerData(unsigned playerId, int removeReason) } } GetCallback().SignalNetClientPlayerLeft(tmpData->GetUniqueId(), tmpData->GetName(), removeReason); + + if(removeReason == NTF_NET_REMOVED_KICKED) { + m_clientLog->logPlayerAction( + m_game->getCurrentHand()->getCurrentRound(), + m_game->getPlayerByUniqueId(tmpData->GetUniqueId())->getMyID()+1, + LOG_ACTION_KICKED + ); + } else { + m_clientLog->logPlayerAction( + m_game->getCurrentHand()->getCurrentRound(), + m_game->getPlayerByUniqueId(tmpData->GetUniqueId())->getMyID()+1, + LOG_ACTION_LEFT + ); + } + } } diff --git a/src/net/common/servergamestate.cpp b/src/net/common/servergamestate.cpp index 168c204f..d462efdb 100644 --- a/src/net/common/servergamestate.cpp +++ b/src/net/common/servergamestate.cpp @@ -949,11 +949,10 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr server) server->GetStateTimer1().async_wait( boost::bind( &ServerGameStateHand::TimerComputerAction, this, boost::asio::placeholders::error, server)); - } - else { + } else { // If the player we are waiting for left, continue without him. if (!server->GetSessionManager().IsPlayerConnected(curPlayer->getMyUniqueID()) - || !curPlayer->isSessionActive()) { + || !curPlayer->isSessionActive()) { PerformPlayerAction(*server, curPlayer, PLAYER_ACTION_FOLD, 0); server->GetStateTimer1().expires_from_now( @@ -1290,7 +1289,7 @@ ServerGameStateHand::CheckPlayerTimeouts(boost::shared_ptr server) while (i != end) { boost::shared_ptr tmpPlayer = *i; if (tmpPlayer->getMyType() == PLAYER_TYPE_HUMAN - && (int)tmpPlayer->getTimeSecSinceLastRemoteAction() >= actionTimeout * SERVER_GAME_AUTOFOLD_TIMEOUT_FACTOR) { + && (int)tmpPlayer->getTimeSecSinceLastRemoteAction() >= actionTimeout * SERVER_GAME_AUTOFOLD_TIMEOUT_FACTOR) { if (tmpPlayer->isSessionActive()) { tmpPlayer->setIsSessionActive(false); boost::shared_ptr session = server->GetSessionManager().GetSessionByUniquePlayerId(tmpPlayer->getMyUniqueID()); diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index e76505e4..949bece7 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -881,7 +881,7 @@ ServerLobbyThread::HandlePacket(boost::shared_ptr session, boost::s else if (packet->GetMsg()->present == PokerTHMessage_PR_avatarRequestMessage) HandleNetPacketRetrieveAvatar(session, packet->GetMsg()->choice.avatarRequestMessage); else if (packet->GetMsg()->present == PokerTHMessage_PR_resetTimeoutMessage) - {} + {} else if (packet->GetMsg()->present == PokerTHMessage_PR_subscriptionRequestMessage) { SubscriptionRequestMessage_t *subscriptionRequest = &packet->GetMsg()->choice.subscriptionRequestMessage; if (subscriptionRequest->subscriptionAction == subscriptionAction_resubscribeGameList)