optimizing local sqlite-logging; implementing first steps network client sqlite-logging

This commit is contained in:
floty
2011-11-09 21:39:37 +00:00
parent 32d26e3644
commit 385a641ede
13 changed files with 177 additions and 392 deletions
+1 -1
View File
@@ -152,7 +152,7 @@ void LocalBeRo::run()
LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR - wrong myBeRoID");
}
}
myHand->getLog()->logBoardCards(myBeRoID+1, tempBoardCardsArray);
myHand->getLog()->logBoardCards(myBeRoID, tempBoardCardsArray);
logBoardCardsDone = true;
}
@@ -89,13 +89,13 @@ void LocalBeRoPostRiver::postRiverRun()
if ((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) nonfoldPlayersCounter++;
}
if(nonfoldPlayersCounter>1) {
getMyHand()->getLog()->logHoleCardsHandName(5,getMyHand()->getActivePlayerList());
getMyHand()->getLog()->logHoleCardsHandName(GAME_STATE_POST_RIVER,getMyHand()->getActivePlayerList());
}
// logging winner of the hand
for(it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); ++it_c) {
if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD && (*it_c)->getMyCardsValueInt() == highestCardsValue) {
getMyHand()->getLog()->logPlayerAction(5,(*it_c)->getMyID()+1,LOG_ACTION_WIN,(*it_c)->getLastMoneyWon());
getMyHand()->getLog()->logPlayerAction(GAME_STATE_POST_RIVER,(*it_c)->getMyID()+1,LOG_ACTION_WIN,(*it_c)->getLastMoneyWon());
}
}
@@ -107,7 +107,7 @@ void LocalBeRoPostRiver::postRiverRun()
for(it_int = winners.begin(); it_int != winners.end(); ++it_int) {
if((*it_int) == (*it_c)->getMyUniqueID()) {
getMyHand()->getLog()->logPlayerAction(5,(*it_c)->getMyID()+1,LOG_ACTION_WIN_SIDE_POT,(*it_c)->getLastMoneyWon());
getMyHand()->getLog()->logPlayerAction(GAME_STATE_POST_RIVER,(*it_c)->getMyID()+1,LOG_ACTION_WIN_SIDE_POT,(*it_c)->getLastMoneyWon());
}
}
}
@@ -116,7 +116,7 @@ void LocalBeRoPostRiver::postRiverRun()
// log player sits out
for(it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); ++it_c) {
if((*it_c)->getMyCash() == 0) {
getMyHand()->getLog()->logPlayerAction(5, (*it_c)->getMyID()+1, LOG_ACTION_SIT_OUT);
getMyHand()->getLog()->logPlayerAction(GAME_STATE_POST_RIVER, (*it_c)->getMyID()+1, LOG_ACTION_SIT_OUT);
}
}
@@ -131,7 +131,7 @@ void LocalBeRoPostRiver::postRiverRun()
if (playersPositiveCashCounter==1) {
for (it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); ++it_c) {
if ((*it_c)->getMyCash() > 0) {
getMyHand()->getLog()->logPlayerAction(5,(*it_c)->getMyID()+1,LOG_ACTION_WIN_GAME);
getMyHand()->getLog()->logPlayerAction(GAME_STATE_POST_RIVER,(*it_c)->getMyID()+1,LOG_ACTION_WIN_GAME);
}
}
// for log after every game
+5 -33
View File
@@ -363,10 +363,10 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
assignButtons();
myLog->logNewHandMsg(myID, dealerPosition+1, smallBlind, smallBlindPosition+1, 2*smallBlind, bigBlindPosition+1, seatsList);
setBlinds();
myLog->logNewHandMsg(myID, dealerPosition+1, smallBlind, smallBlindPosition+1, 2*smallBlind, bigBlindPosition+1, seatsList);
myBeRo = myFactory->createBeRo(this, dealerPosition, smallBlind);
}
@@ -489,13 +489,11 @@ void LocalHand::setBlinds()
// All in ?
if((*it_c)->getMyCash() <= smallBlind) {
myLog->logPlayerAction(0,smallBlindPosition+1,LOG_ACTION_SMALL_BLIND,(*it_c)->getMyCash());
(*it_c)->setMySet((*it_c)->getMyCash());
// 1 to do not log this
(*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1);
} else {
myLog->logPlayerAction(0,smallBlindPosition+1,LOG_ACTION_SMALL_BLIND,smallBlind);
(*it_c)->setMySet(smallBlind);
}
}
@@ -511,13 +509,11 @@ void LocalHand::setBlinds()
// all in ?
if((*it_c)->getMyCash() <= 2*smallBlind) {
myLog->logPlayerAction(0,bigBlindPosition+1,LOG_ACTION_BIG_BLIND,(*it_c)->getMyCash());
(*it_c)->setMySet((*it_c)->getMyCash());
// 1 to do not log this
(*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1);
} else {
myLog->logPlayerAction(0,bigBlindPosition+1,LOG_ACTION_BIG_BLIND,2*smallBlind);
(*it_c)->setMySet(2*smallBlind);
}
}
@@ -531,31 +527,7 @@ void LocalHand::switchRounds()
// logging last player action
PlayerListConstIterator previousPlayerIt = getRunningPlayerIt(previousPlayerID);
if(previousPlayerIt != runningPlayerList->end()) {
switch((*previousPlayerIt)->getMyAction()) {
case PLAYER_ACTION_FOLD: {
myLog->logPlayerAction(currentRound+1,(*previousPlayerIt)->getMyID()+1,LOG_ACTION_FOLD);
}
break;
case PLAYER_ACTION_CHECK: {
myLog->logPlayerAction(currentRound+1,(*previousPlayerIt)->getMyID()+1,LOG_ACTION_CHECK);
}
break;
case PLAYER_ACTION_CALL: {
myLog->logPlayerAction(currentRound+1,(*previousPlayerIt)->getMyID()+1,LOG_ACTION_CALL,(*previousPlayerIt)->getMySet());
}
break;
case PLAYER_ACTION_BET:
case PLAYER_ACTION_RAISE: {
myLog->logPlayerAction(currentRound+1,(*previousPlayerIt)->getMyID()+1,LOG_ACTION_BET,(*previousPlayerIt)->getMySet());
}
break;
case PLAYER_ACTION_ALLIN: {
myLog->logPlayerAction(currentRound+1,(*previousPlayerIt)->getMyID()+1,LOG_ACTION_ALL_IN,(*previousPlayerIt)->getMySet());
}
break;
default: {
}
}
myLog->logPlayerAction(currentRound,(*previousPlayerIt)->getMyID()+1,myLog->transformPlayerActionLog((*previousPlayerIt)->getMyAction()),(*previousPlayerIt)->getMySet());
}
PlayerListIterator it, it_1;
@@ -658,7 +630,7 @@ void LocalHand::switchRounds()
myGui->flipHolecardsAllIn();
// Logging HoleCards
if(currentRound<GAME_STATE_RIVER) {
myLog->logHoleCardsHandName(currentRound+1,activePlayerList);
myLog->logHoleCardsHandName(currentRound,activePlayerList);
}
if (currentRound < GAME_STATE_POST_RIVER) // do not increment past 4
@@ -670,7 +642,7 @@ void LocalHand::switchRounds()
myBoard->getMyCards(tempBoardCardsArray);
myGui->logDealBoardCardsMsg(currentRound, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3], tempBoardCardsArray[4]);
myLog->logBoardCards(currentRound+1, tempBoardCardsArray);
myLog->logBoardCards(currentRound, tempBoardCardsArray);
}
}
+11 -11
View File
@@ -3222,12 +3222,12 @@ void LocalPlayer::evaluation(int bet, int raise)
break;
// fold
case 1: {
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound()+1,myID+1,LOG_ACTION_FOLD);
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound(),myID+1,LOG_ACTION_FOLD);
}
break;
// check
case 2: {
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound()+1,myID+1,LOG_ACTION_CHECK);
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound(),myID+1,LOG_ACTION_CHECK);
}
break;
// call
@@ -3238,14 +3238,14 @@ void LocalPlayer::evaluation(int bet, int raise)
mySet += myCash;
myCash = 0;
myAction = PLAYER_ACTION_ALLIN;
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound()+1,myID+1,LOG_ACTION_ALL_IN,mySet);
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound(),myID+1,LOG_ACTION_ALL_IN,mySet);
// cout << "evaluation(call) - mySet: " << mySet << endl;
}
// sonst
else {
myCash = myCash - highestSet + mySet;
mySet = highestSet;
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound()+1,myID+1,LOG_ACTION_CALL,mySet);
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound(),myID+1,LOG_ACTION_CALL,mySet);
}
}
break;
@@ -3262,7 +3262,7 @@ void LocalPlayer::evaluation(int bet, int raise)
myCash = 0;
myAction = PLAYER_ACTION_ALLIN;
highestSet = mySet;
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound()+1,myID+1,LOG_ACTION_ALL_IN,mySet);
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound(),myID+1,LOG_ACTION_ALL_IN,mySet);
}
// sonst
else {
@@ -3270,7 +3270,7 @@ void LocalPlayer::evaluation(int bet, int raise)
myCash = myCash - bet;
mySet = bet;
highestSet = mySet;
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound()+1,myID+1,LOG_ACTION_BET,mySet);
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound(),myID+1,LOG_ACTION_BET,mySet);
}
// lastPlayerAction für Karten umblättern reihenfolge setzrn
@@ -3285,14 +3285,14 @@ void LocalPlayer::evaluation(int bet, int raise)
mySet += myCash;
myCash = 0;
myAction = PLAYER_ACTION_ALLIN;
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound()+1,myID+1,LOG_ACTION_ALL_IN,mySet);
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound(),myID+1,LOG_ACTION_ALL_IN,mySet);
}
// sonst
else {
myCash = myCash - highestSet + mySet;
mySet = highestSet;
myAction = PLAYER_ACTION_CALL;
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound()+1,myID+1,LOG_ACTION_CALL,mySet);
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound(),myID+1,LOG_ACTION_CALL,mySet);
}
} else {
if(raise < currentHand->getCurrentBeRo()->getMinimumRaise()) {
@@ -3329,7 +3329,7 @@ void LocalPlayer::evaluation(int bet, int raise)
myAction = PLAYER_ACTION_ALLIN;
highestSet = mySet;
}
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound()+1,myID+1,LOG_ACTION_ALL_IN,mySet);
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound(),myID+1,LOG_ACTION_ALL_IN,mySet);
}
// sonst
else {
@@ -3339,14 +3339,14 @@ void LocalPlayer::evaluation(int bet, int raise)
highestSet = mySet;
// lastPlayerAction für Karten umblättern reihenfolge setzrn
currentHand->setLastActionPlayerID(myUniqueID);
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound()+1,myID+1,LOG_ACTION_BET,mySet);
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound(),myID+1,LOG_ACTION_BET,mySet);
}
}
}
break;
// all in
case 6: {
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound()+1,myID+1,LOG_ACTION_ALL_IN,mySet);
// currentHand->getLog()->logPlayerAction(currentHand->getCurrentRound(),myID+1,LOG_ACTION_ALL_IN,mySet);
}
break;
default:
-1
View File
@@ -171,4 +171,3 @@ void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool
}*/
+124 -87
View File
@@ -221,7 +221,7 @@ Log::logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned
sql += "," + boost::lexical_cast<string>(bigBlindPosition);
for(it_c = seatsList->begin(); it_c!=seatsList->end(); it_c++) {
if((*it_c)->getMyActiveStatus()) {
sql += "," + boost::lexical_cast<string>((*it_c)->getMyCash());
sql += "," + boost::lexical_cast<string>((*it_c)->getMyRoundStartCash());
} else {
sql += ",NULL";
}
@@ -243,20 +243,30 @@ Log::logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned
}
}
if(countActivePlayer==2) {
logPlayerAction(0,smallBlindPosition,LOG_ACTION_DEALER);
logPlayerAction(GAME_STATE_PREFLOP,smallBlindPosition,LOG_ACTION_DEALER);
} else {
if(dealerButtonOnTable) {
logPlayerAction(0,dealerPosition,LOG_ACTION_DEALER);
logPlayerAction(GAME_STATE_PREFLOP,dealerPosition,LOG_ACTION_DEALER);
}
}
// !! TODO !! Hack
// log blinds
for(it_c = seatsList->begin(); it_c!=seatsList->end(); it_c++) {
if((*it_c)->getMyButton() == BUTTON_SMALL_BLIND) {
logPlayerAction(GAME_STATE_PREFLOP,smallBlindPosition,LOG_ACTION_SMALL_BLIND,(*it_c)->getMySet());
}
if((*it_c)->getMyButton() == BUTTON_BIG_BLIND) {
logPlayerAction(GAME_STATE_PREFLOP,bigBlindPosition,LOG_ACTION_BIG_BLIND,(*it_c)->getMySet());
}
}
}
}
}
}
void
Log::logPlayerAction(int bero, int seat, PlayerActionLog action, int amount)
Log::logPlayerAction(GameState bero, int seat, PlayerActionLog action, int amount)
{
if(SQLITE_LOG) {
@@ -267,80 +277,116 @@ Log::logPlayerAction(int bero, int seat, PlayerActionLog action, int amount)
if( mySqliteLogDb != 0 ) {
// sqlite-db is open
sql += "INSERT INTO Action (";
sql += "HandID";
sql += ",GameID";
sql += ",BeRo";
sql += ",Player";
sql += ",Action";
sql += ",Amount";
sql += ") VALUES (";
sql += boost::lexical_cast<string>(curHandID);
sql += "," + boost::lexical_cast<string>(curGameID);
sql += "," + boost::lexical_cast<string>(bero);;
sql += "," + boost::lexical_cast<string>(seat);
switch(action) {
case LOG_ACTION_DEALER:
sql += ",'starts as dealer'";
break;
case LOG_ACTION_SMALL_BLIND:
sql += ",'posts small blind'";
break;
case LOG_ACTION_BIG_BLIND:
sql += ",'posts big blind'";
break;
case LOG_ACTION_FOLD:
sql += ",'folds'";
break;
case LOG_ACTION_CHECK:
sql += ",'checks'";
break;
case LOG_ACTION_CALL:
sql += ",'calls'";
break;
case LOG_ACTION_BET:
sql += ",'bets'";
break;
case LOG_ACTION_ALL_IN:
sql += ",'is all in with'";
break;
case LOG_ACTION_SHOW:
sql += ",'shows'";
break;
case LOG_ACTION_HAS:
sql += ",'has'";
break;
case LOG_ACTION_WIN:
sql += ",'wins'";
break;
case LOG_ACTION_WIN_SIDE_POT:
sql += ",'wins (side pot)'";
break;
case LOG_ACTION_SIT_OUT:
sql += ",'sits out'";
break;
case LOG_ACTION_WIN_GAME:
sql += ",'wins game'";
break;
default:
return;
}
if(amount>0) {
sql += "," + boost::lexical_cast<string>(amount);
} else {
sql += ",NULL";
}
sql += ");";
if(myConfig->readConfigInt("LogInterval") == 0) {
exec_transaction();
if(action!=LOG_ACTION_NONE) {
sql += "INSERT INTO Action (";
sql += "HandID";
sql += ",GameID";
sql += ",BeRo";
sql += ",Player";
sql += ",Action";
sql += ",Amount";
sql += ") VALUES (";
sql += boost::lexical_cast<string>(curHandID);
sql += "," + boost::lexical_cast<string>(curGameID);
sql += "," + boost::lexical_cast<string>(bero);;
sql += "," + boost::lexical_cast<string>(seat);
switch(action) {
case LOG_ACTION_DEALER:
sql += ",'starts as dealer'";
sql += ",NULL";
break;
case LOG_ACTION_SMALL_BLIND:
sql += ",'posts small blind'";
sql += "," + boost::lexical_cast<string>(amount);
break;
case LOG_ACTION_BIG_BLIND:
sql += ",'posts big blind'";
sql += "," + boost::lexical_cast<string>(amount);
break;
case LOG_ACTION_FOLD:
sql += ",'folds'";
sql += ",NULL";
break;
case LOG_ACTION_CHECK:
sql += ",'checks'";
sql += ",NULL";
break;
case LOG_ACTION_CALL:
sql += ",'calls'";
sql += "," + boost::lexical_cast<string>(amount);
break;
case LOG_ACTION_BET:
sql += ",'bets'";
sql += "," + boost::lexical_cast<string>(amount);
break;
case LOG_ACTION_ALL_IN:
sql += ",'is all in with'";
sql += "," + boost::lexical_cast<string>(amount);
break;
case LOG_ACTION_SHOW:
sql += ",'shows'";
sql += ",NULL";
break;
case LOG_ACTION_HAS:
sql += ",'has'";
sql += ",NULL";
break;
case LOG_ACTION_WIN:
sql += ",'wins'";
sql += "," + boost::lexical_cast<string>(amount);
break;
case LOG_ACTION_WIN_SIDE_POT:
sql += ",'wins (side pot)'";
sql += "," + boost::lexical_cast<string>(amount);
break;
case LOG_ACTION_SIT_OUT:
sql += ",'sits out'";
sql += ",NULL";
break;
case LOG_ACTION_WIN_GAME:
sql += ",'wins game'";
sql += ",NULL";
break;
default:
return;
}
sql += ");";
if(myConfig->readConfigInt("LogInterval") == 0) {
exec_transaction();
}
}
}
}
}
}
PlayerActionLog
Log::transformPlayerActionLog(PlayerAction action)
{
switch(action) {
case PLAYER_ACTION_FOLD:
return LOG_ACTION_FOLD;
break;
case PLAYER_ACTION_CHECK:
return LOG_ACTION_CHECK;
break;
case PLAYER_ACTION_CALL:
return LOG_ACTION_CALL;
break;
case PLAYER_ACTION_BET:
case PLAYER_ACTION_RAISE:
return LOG_ACTION_BET;
break;
case PLAYER_ACTION_ALLIN:
return LOG_ACTION_ALL_IN;
break;
default:
return LOG_ACTION_NONE;
}
}
void
Log::logBoardCards(int bero, int boardCards[5])
Log::logBoardCards(GameState bero, int boardCards[5])
{
if(SQLITE_LOG) {
@@ -351,19 +397,19 @@ Log::logBoardCards(int bero, int boardCards[5])
// sqlite-db is open
switch(bero) {
case 2: {
case GAME_STATE_FLOP: {
sql += "UPDATE Hand SET ";
sql += "BoardCard_1=" + boost::lexical_cast<string>(boardCards[0]) + ",";
sql += "BoardCard_2=" + boost::lexical_cast<string>(boardCards[1]) + ",";
sql += "BoardCard_3=" + boost::lexical_cast<string>(boardCards[2]);
}
break;
case 3: {
case GAME_STATE_TURN: {
sql += "UPDATE Hand SET ";
sql += "BoardCard_4=" + boost::lexical_cast<string>(boardCards[3]);
}
break;
case 4: {
case GAME_STATE_RIVER: {
sql += "UPDATE Hand SET ";
sql += "BoardCard_5=" + boost::lexical_cast<string>(boardCards[4]);
}
@@ -384,14 +430,14 @@ Log::logBoardCards(int bero, int boardCards[5])
}
void
Log::logHoleCardsHandName(int bero, PlayerList activePlayerList)
Log::logHoleCardsHandName(GameState bero, PlayerList activePlayerList)
{
if(SQLITE_LOG) {
if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled
if( mySqliteLogDb != 0 && (bero==5 || !logHoleCardsDone)) {
if( mySqliteLogDb != 0 && (bero==GAME_STATE_POST_RIVER || !logHoleCardsDone)) {
// sqlite-db is open and we are in postriver or before postriver doesn't log hole cards til now
PlayerListConstIterator it_c;
@@ -401,11 +447,11 @@ Log::logHoleCardsHandName(int bero, PlayerList activePlayerList)
if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) {
(*it_c)->getMyCards(myCards);
sql += "UPDATE Hand SET ";
if(bero==5) {
if(bero==GAME_STATE_POST_RIVER) {
sql += "Seat_" + boost::lexical_cast<string>((*it_c)->getMyID()+1) + "_Hand_text=\"" + CardsValue::determineHandName((*it_c)->getMyCardsValueInt(),activePlayerList) + "\"";
sql += ",Seat_" + boost::lexical_cast<string>((*it_c)->getMyID()+1) + "_Hand_int=" + boost::lexical_cast<string>((*it_c)->getMyCardsValueInt());
}
if(bero==5 && !logHoleCardsDone) {
if(bero==GAME_STATE_POST_RIVER && !logHoleCardsDone) {
sql+= ",";
}
if(!logHoleCardsDone) {
@@ -473,13 +519,4 @@ Log::exec_transaction()
// sqlite3_close(mySqliteLogDb);
// mySqliteLogDb = NULL;
// }
//}
// Bero-Code
// 0 Pre-Preflop
// 1 Preflop
// 2 Flop
// 3 Turn
// 4 River
// 5 Post-River
+4 -3
View File
@@ -36,9 +36,10 @@ 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 logPlayerAction(int bero, int seat, PlayerActionLog action, int amount = 0);
void logBoardCards(int bero, int boardCards[5]);
void logHoleCardsHandName(int bero, PlayerList activePlayerList);
void logPlayerAction(GameState bero, int seat, PlayerActionLog action, int amount = 0);
PlayerActionLog transformPlayerActionLog(PlayerAction action);
void logBoardCards(GameState bero, int boardCards[5]);
void logHoleCardsHandName(GameState bero, PlayerList activePlayerList);
void logAfterHand();
void logAfterGame();
void exec_transaction();
+1 -249
View File
@@ -27,7 +27,7 @@
using namespace std;
guiLog::guiLog(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), myHtmlLogFile(0), mySqliteLogDb(0)
guiLog::guiLog(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), myHtmlLogFile(0)
{
myW->setGuiLog(this);
@@ -176,35 +176,6 @@ void guiLog::logPlayerActionMsg(QString msg, int action, int setValue)
}
if(SQLITE_LOG) {
// if(mySqliteLogDb->isOpen()) {
// QSqlQuery query(*mySqliteLogDb);
// QString sql;
// sql = "INSERT INTO Action (HandID,GameID,BeRo,Player,Action,Amount) VALUES (";
// sql += QString::number(myW->getSession()->getCurrentGame()->getCurrentHandID(),10);
// sql += "," + QString::number(myW->getSession()->getCurrentGame()->getMyGameID(),10);
// sql += "," + QString::number(myW->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->getMyBeRoID(),10);
// sql += "," + QString::number(playerID,10);
// sql += "," + QString::number(action,10);
// sql += "," + QString::number(setValue,10);
// sql += ")";
// if(myConfig->readConfigInt("LogInterval") == 0) {
// if(!query.exec(sql)) {
// QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
// }
// }
// } else {
// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
// }
}
}
}
@@ -235,155 +206,6 @@ void guiLog::logNewGameHandMsg(int gameID, int handID)
}
if(SQLITE_LOG) {
string sql;
char *errmsg;
if( mySqliteLogDb != 0 ) {
if(handID == 1) {
// start of a game -> insert game data
int i;
sql = "INSERT INTO Game (";
sql += "GameID";
sql += ",Startmoney";
sql += ",StartSb";
sql += ",DealerPos";
for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) {
sql += ",Seat_" + boost::lexical_cast<std::string>(i);
}
sql += ") VALUES (";
sql += boost::lexical_cast<string>(gameID);
sql += "," + boost::lexical_cast<string>(myW->getSession()->getCurrentGame()->getStartCash());
sql += "," + boost::lexical_cast<string>(myW->getSession()->getCurrentGame()->getStartSmallBlind());
sql += "," + boost::lexical_cast<string>(myW->getSession()->getCurrentGame()->getDealerPosition());
PlayerList seatList = currentHand->getSeatsList();
for(it_c = seatList->begin(); it_c!=seatList->end(); ++it_c) {
if((*it_c)->getMyActiveStatus()) {
sql += ",\"" + (*it_c)->getMyName() +"\"";
} else {
sql += ",NULL";
}
}
sql += ")";
if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) {
cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl;
}
}
// insert hand data
sql = "INSERT INTO Hand (";
sql += "HandID";
sql += ",GameID";
sql += ",Dealer_Seat";
sql += ",Sb_Amount";
sql += ",Sb_Seat";
sql += ",Bb_Amount";
sql += ",Bb_Seat";
sql += ") VALUES (";
// // hand data
// sql = "INSERT INTO Hand (HandID,GameID,Sb_Amount,Bb_Amount";
// for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); ++it_c) {
// sql += ",Seat_" + QString::number((*it_c)->getMyID()+1,10) + "_Cash";
// }
//// for(i=1;i<=MAX_NUMBER_OF_PLAYERS; i++) {
//// sql += ",Seat_" + QString("%1").arg(i) + "_Cash";
//// }
// sql += ") VALUES (";
// sql += QString::number(handID,10);
// sql += "," + QString::number(gameID,10);
// sql += "," + QString::number(currentHand->getSmallBlind(),10);
// sql += "," + QString::number(currentHand->getSmallBlind()*2,10);
// for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); ++it_c) {
// sql += "," + QString::number((*it_c)->getMyCash()+(*it_c)->getMySet(),10);
// }
//// for(it_c = currentHand->getSeatsList()->begin();it_c!=currentHand->getSeatsList()->end();++it_c) {
//// if((*it_c)->getMyActiveStatus()) {
//// sql += "," + QString::number((*it_c)->getMyCash()+(*it_c)->getMySet(),10);
//// } else {
//// sql += ",NULL";
//// }
//// }
// sql += ")";
}
// if(mySqliteLogDb->isOpen()) {
// QSqlQuery query(*mySqliteLogDb);
// QString sql;
// // beginning of a game
// if(handID == 1) {
// sql = "INSERT INTO Game (GameID,Startmoney,StartSb,DealerPos";
// for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); ++it_c) {
// sql += ",Seat_" + QString::number((*it_c)->getMyID()+1,10);
// }
//// for(i=1;i<=MAX_NUMBER_OF_PLAYERS; i++) {
//// sql += ",Seat_" + QString::number(i,10);
//// }
// sql += ") VALUES (";
// sql += QString::number(gameID,10) + ",";
// sql += QString::number(myW->getSession()->getCurrentGame()->getStartCash(),10) + ",";
// sql += QString::number(myW->getSession()->getCurrentGame()->getStartSmallBlind(),10) + ",";
// sql += QString::number(myW->getSession()->getCurrentGame()->getDealerPosition(),10);
// for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); ++it_c) {
// sql += ",'" + QString::fromUtf8((*it_c)->getMyName().c_str()) +"'";
// }
//// for(it_c = currentHand->getSeatsList()->begin();it_c!=currentHand->getSeatsList()->end();++it_c) {
//// if((*it_c)->getMyActiveStatus()) {
//// sql += ",'" + QString::fromUtf8((*it_c)->getMyName().c_str()) +"'";
//// } else {
//// sql += ",NULL";
//// }
//// }
// sql += ")";
// if(!query.exec(sql)) {
// QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
// }
// }
// // beginning of a hand
// sql = "INSERT INTO Hand (HandID,GameID,Sb_Amount,Bb_Amount";
// for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); ++it_c) {
// sql += ",Seat_" + QString::number((*it_c)->getMyID()+1,10) + "_Cash";
// }
//// for(i=1;i<=MAX_NUMBER_OF_PLAYERS; i++) {
//// sql += ",Seat_" + QString("%1").arg(i) + "_Cash";
//// }
// sql += ") VALUES (";
// sql += QString::number(handID,10);
// sql += "," + QString::number(gameID,10);
// sql += "," + QString::number(currentHand->getSmallBlind(),10);
// sql += "," + QString::number(currentHand->getSmallBlind()*2,10);
// for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); ++it_c) {
// sql += "," + QString::number((*it_c)->getMyCash()+(*it_c)->getMySet(),10);
// }
//// for(it_c = currentHand->getSeatsList()->begin();it_c!=currentHand->getSeatsList()->end();++it_c) {
//// if((*it_c)->getMyActiveStatus()) {
//// sql += "," + QString::number((*it_c)->getMyCash()+(*it_c)->getMySet(),10);
//// } else {
//// sql += ",NULL";
//// }
//// }
// sql += ")";
// if(!query.exec(sql)) {
// QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
// }
// } else {
// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
// }
}
}
}
@@ -431,12 +253,6 @@ void guiLog::logNewBlindsSetsMsg(int sbSet, int bbSet, QString sbName, QString b
}
if(SQLITE_LOG) {
}
}
}
@@ -535,48 +351,6 @@ void guiLog::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3,
}
if(SQLITE_LOG) {
// if(mySqliteLogDb->isOpen()) {
// QSqlQuery query(*mySqliteLogDb);
// QString sql;
// sql = "UPDATE Hand SET ";
// switch (roundID) {
// case 1: round = "Flop";
// sql += "BoardCard_1 = " + QString::number(card1,10) + ",";
// sql += "BoardCard_2 = " + QString::number(card2,10) + ",";
// sql += "BoardCard_3 = " + QString::number(card3,10);
// break;
// case 2: round = "Turn";
// sql += "BoardCard_4 = " + QString::number(card4,10);
// break;
// case 3: round = "River";
// sql += "BoardCard_5 = " + QString::number(card5,10);
// break;
// default: round = "ERROR";
// }
// sql += " WHERE ";
// sql += "HandID = " + QString::number(myW->getSession()->getCurrentGame()->getCurrentHandID(),10) + " AND ";
// sql += "GameID = " + QString::number(myW->getSession()->getCurrentGame()->getMyGameID(),10);
// if(myConfig->readConfigInt("LogInterval") == 0) {
// if(roundID <= 3) {
// if(!query.exec(sql)) {
// QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
// }
// }
// }
// } else {
// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
// }
}
}
}
@@ -623,28 +397,6 @@ void guiLog::logFlipHoleCardsMsg(QString playerName, int card1, int card2, int c
}
}
if(SQLITE_LOG) {
// if(mySqliteLogDb->isOpen()) {
// QString sql = "UPDATE Hand SET ";
// sql += "Seat_" + QString::number(playerID+1,10) + "_Card_1 = " + QString::number(card1,10) + ",";
// sql += "Seat_" + QString::number(playerID+1,10) + "_Card_2 = " + QString::number(card2,10);
// sql += " WHERE ";
// sql += "HandID = " + QString::number(myW->getSession()->getCurrentGame()->getCurrentHandID(),10) + " AND ";
// sql += "GameID = " + QString::number(myW->getSession()->getCurrentGame()->getMyGameID(),10);
// QSqlQuery query(*mySqliteLogDb);
// if(!query.exec(sql)) {
// QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
// }
// } else {
// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
// }
}
}
}
-1
View File
@@ -86,7 +86,6 @@ private:
QTextStream stream;
QDir *myLogDir;
QFile *myHtmlLogFile;
sqlite3 *mySqliteLogDb;
QString logFileStreamString;
QString myAppDataPath;
+1
View File
@@ -105,6 +105,7 @@ public:
ClientCallback &GetCallback();
GuiInterface &GetGui();
boost::shared_ptr<Log> GetClientLog();
AvatarManager &GetAvatarManager();
protected:
+18
View File
@@ -1753,6 +1753,12 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
tmpPlayer->getMyName(),
netActionDone->playerAction,
netActionDone->totalPlayerBet - tmpPlayer->getMySet());
client->GetClientLog()->logPlayerAction(
curGame->getCurrentHand()->getCurrentBeRo()->getMyBeRoID(),
tmpPlayer->getMyID()+1,
client->GetClientLog()->transformPlayerActionLog(PlayerAction(netActionDone->playerAction)),
netActionDone->totalPlayerBet - tmpPlayer->getMySet()
);
}
// Update last players turn only after the blinds.
curGame->getCurrentHand()->setPreviousPlayerID(tmpPlayer->getMyID());
@@ -1774,6 +1780,15 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
curGame->getPlayerByUniqueId(curGame->getCurrentHand()->getCurrentBeRo()->getSmallBlindPositionId())->getMyName(),
curGame->getPlayerByUniqueId(curGame->getCurrentHand()->getCurrentBeRo()->getBigBlindPositionId())->getMyName());
client->GetGui().flushLogAtHand();
client->GetClientLog()->logNewHandMsg(
curGame->getCurrentHandID(),
curGame->getDealerPosition(),
curGame->getCurrentHand()->getSmallBlind(),
curGame->getPlayerByUniqueId(curGame->getCurrentHand()->getCurrentBeRo()->getSmallBlindPositionId())->getMyID()+1,
curGame->getCurrentHand()->getSmallBlind()*2,
curGame->getPlayerByUniqueId(curGame->getCurrentHand()->getCurrentBeRo()->getBigBlindPositionId())->getMyID()+1,
curGame->getSeatsList()
);
}
// Stop the timeout for the player.
@@ -1837,6 +1852,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
curGame->getCurrentHand()->setPreviousPlayerID(-1);
client->GetGui().logDealBoardCardsMsg(GAME_STATE_FLOP, tmpCards[0], tmpCards[1], tmpCards[2], tmpCards[3], tmpCards[4]);
client->GetClientLog()->logBoardCards(GAME_STATE_FLOP,tmpCards);
client->GetGui().refreshGameLabels(GAME_STATE_FLOP);
client->GetGui().refreshPot();
client->GetGui().refreshSet();
@@ -1852,6 +1868,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
curGame->getCurrentHand()->setPreviousPlayerID(-1);
client->GetGui().logDealBoardCardsMsg(GAME_STATE_TURN, tmpCards[0], tmpCards[1], tmpCards[2], tmpCards[3], tmpCards[4]);
client->GetClientLog()->logBoardCards(GAME_STATE_TURN,tmpCards);
client->GetGui().refreshGameLabels(GAME_STATE_TURN);
client->GetGui().refreshPot();
client->GetGui().refreshSet();
@@ -1867,6 +1884,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
curGame->getCurrentHand()->setPreviousPlayerID(-1);
client->GetGui().logDealBoardCardsMsg(GAME_STATE_RIVER, tmpCards[0], tmpCards[1], tmpCards[2], tmpCards[3], tmpCards[4]);
client->GetClientLog()->logBoardCards(GAME_STATE_RIVER,tmpCards);
client->GetGui().refreshGameLabels(GAME_STATE_RIVER);
client->GetGui().refreshPot();
client->GetGui().refreshSet();
+6
View File
@@ -513,6 +513,12 @@ ClientThread::GetGui()
return m_gui;
}
boost::shared_ptr<Log>
ClientThread::GetClientLog()
{
return m_clientLog;
}
AvatarManager &
ClientThread::GetAvatarManager()
{
+1 -1
View File
@@ -905,7 +905,7 @@ ServerLobbyThread::HandlePacket(boost::shared_ptr<SessionData> 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)