From 0e46188ff3ec15f6bfd66256cbff1f49418ef611 Mon Sep 17 00:00:00 2001 From: floty Date: Sat, 18 Dec 2010 23:10:10 +0000 Subject: [PATCH] some bugfixes in Log and guiLog --- src/engine/local_engine/log.cpp | 57 ++++++++++++++++++++++ src/engine/local_engine/log.h | 10 ++++ src/gui/generic/serverguiwrapper.h | 2 +- src/gui/guiinterface.h | 3 +- src/gui/qt/gametable/log/guilog.cpp | 15 ------ src/gui/qt/gametable/log/guilog.h | 3 +- src/gui/qt/guiwrapper.cpp | 4 +- src/gui/qt/guiwrapper.h | 4 +- src/gui/qt/startwindow/startwindowimpl.cpp | 3 +- src/session.cpp | 2 +- src/session.h | 4 ++ 11 files changed, 78 insertions(+), 29 deletions(-) diff --git a/src/engine/local_engine/log.cpp b/src/engine/local_engine/log.cpp index 72d66055..aa217e01 100644 --- a/src/engine/local_engine/log.cpp +++ b/src/engine/local_engine/log.cpp @@ -148,3 +148,60 @@ Log::~Log() sqlite3_close(mySqliteLogDb); } } + +void +Log::logNewGameMsg(int gameID, Game *currentGame) { + + if(SQLITE_LOG) { + + PlayerListConstIterator it_c; + + if(myConfig->readConfigInt("LogOnOff")) { + //if write logfiles is enabled + + string sql; + int i; + char *errmsg; + + if( mySqliteLogDb != 0 ) { + + 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(i); + } + sql += ") VALUES ("; + sql += boost::lexical_cast(gameID); + sql += "," + boost::lexical_cast(currentGame->getStartCash()); + sql += "," + boost::lexical_cast(currentGame->getStartSmallBlind()); + sql += "," + boost::lexical_cast(currentGame->getDealerPosition()); + + for(it_c = currentGame->getCurrentHand()->getSeatsList()->begin();it_c!=currentGame->getCurrentHand()->getSeatsList()->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; + } + } + } + } +} + +//void +//Log::closeLogDbAtExit() +//{ +// if(SQLITE_LOG) { +// // close sqlite-db +// sqlite3_close(mySqliteLogDb); +// mySqliteLogDb = NULL; +// } + +//} diff --git a/src/engine/local_engine/log.h b/src/engine/local_engine/log.h index 612463ac..7cf83fed 100644 --- a/src/engine/local_engine/log.h +++ b/src/engine/local_engine/log.h @@ -22,10 +22,16 @@ #include #include +#include +#include +#include "game.h" +#include "handinterface.h" #include "configfile.h" #include "game_defs.h" +//class Game; + class Log { @@ -34,6 +40,10 @@ public: ~Log(); + void logNewGameMsg(int, Game*); +// void closeLogDbAtExit(); + + private: ConfigFile *myConfig; sqlite3 *mySqliteLogDb; diff --git a/src/gui/generic/serverguiwrapper.h b/src/gui/generic/serverguiwrapper.h index da033598..d897b99d 100644 --- a/src/gui/generic/serverguiwrapper.h +++ b/src/gui/generic/serverguiwrapper.h @@ -37,7 +37,7 @@ public: void setSession(boost::shared_ptr session); gameTableImpl* getMyW() const {return NULL;} - guiLog* getMyLog() const {return NULL;} + guiLog* getMyGuiLog() const {return NULL;} void refreshSet() const; void refreshCash() const; diff --git a/src/gui/guiinterface.h b/src/gui/guiinterface.h index 7ec0d03f..58f731ea 100644 --- a/src/gui/guiinterface.h +++ b/src/gui/guiinterface.h @@ -28,7 +28,6 @@ #include class guiLog; -class Log; class Session; class gameTableImpl; @@ -42,7 +41,7 @@ public: virtual void setSession(boost::shared_ptr session) =0; virtual gameTableImpl *getMyW() const=0; - virtual guiLog* getMyLog() const=0; + virtual guiLog* getMyGuiLog() const=0; //refresh-Funktionen diff --git a/src/gui/qt/gametable/log/guilog.cpp b/src/gui/qt/gametable/log/guilog.cpp index 136c7c8f..94093de2 100644 --- a/src/gui/qt/gametable/log/guilog.cpp +++ b/src/gui/qt/gametable/log/guilog.cpp @@ -126,21 +126,6 @@ guiLog::~guiLog() { delete myLogDir; delete myHtmlLogFile; - if(SQLITE_LOG) { - sqlite3_close(mySqliteLogDb); -// delete mySqliteLogDb; - } - -} - -void guiLog::closeLogDbAtExit() -{ - if(SQLITE_LOG) { - // close sqlite-db - sqlite3_close(mySqliteLogDb); -// delete mySqliteLogDb; - mySqliteLogDb = NULL; - } } diff --git a/src/gui/qt/gametable/log/guilog.h b/src/gui/qt/gametable/log/guilog.h index 94f46f40..f40aaecd 100644 --- a/src/gui/qt/gametable/log/guilog.h +++ b/src/gui/qt/gametable/log/guilog.h @@ -44,8 +44,7 @@ public: public slots: - void closeLogDbAtExit(); - void logPlayerActionMsg(QString playerName, int playerID, int action, int setValue); + void logPlayerActionMsg(QString playerName, int playerID, int action, int setValue); void logNewGameHandMsg(int gameID, int handID); void logNewBlindsSetsMsg(int sbSet, int bbSet, QString sbName, QString bbName); void logPlayerWinsMsg(QString playerName, int pot, bool main); diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index d7f938e6..10b1ee1d 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -21,7 +21,6 @@ #include "guiwrapper.h" #include "session.h" #include "guilog.h" -#include "log.h" #include "gametableimpl.h" #include "startwindowimpl.h" #include "configfile.h" @@ -31,13 +30,12 @@ using namespace std; -GuiWrapper::GuiWrapper(ConfigFile *c, startWindowImpl *s) : myGuiLog(NULL), myLog(NULL), myW(NULL), myConfig(c), myStartWindow(s) +GuiWrapper::GuiWrapper(ConfigFile *c, startWindowImpl *s) : myGuiLog(NULL), myW(NULL), myConfig(c), myStartWindow(s) { myW = new gameTableImpl(myConfig); myGuiLog = new guiLog(myW, myConfig); - myLog = new Log(myConfig); myW->setStartWindow(myStartWindow); } diff --git a/src/gui/qt/guiwrapper.h b/src/gui/qt/guiwrapper.h index 9463c14f..efa642a0 100644 --- a/src/gui/qt/guiwrapper.h +++ b/src/gui/qt/guiwrapper.h @@ -28,7 +28,6 @@ class Session; class gameTableImpl; class startWindowImpl; class guiLog; -class Log; class ConfigFile; @@ -45,7 +44,7 @@ public: void setSession(boost::shared_ptr session); gameTableImpl* getMyW() const { return myW; } - guiLog* getMyLog() const { return myGuiLog; } + guiLog* getMyGuiLog() const { return myGuiLog; } void refreshSet() const; void refreshCash() const; @@ -169,7 +168,6 @@ public: private: guiLog *myGuiLog; - Log *myLog; gameTableImpl *myW; ConfigFile *myConfig; startWindowImpl *myStartWindow; diff --git a/src/gui/qt/startwindow/startwindowimpl.cpp b/src/gui/qt/startwindow/startwindowimpl.cpp index 3f095602..5a59dc37 100644 --- a/src/gui/qt/startwindow/startwindowimpl.cpp +++ b/src/gui/qt/startwindow/startwindowimpl.cpp @@ -26,7 +26,6 @@ #include #include "tools.h" -#include "guilog.h" #include "session.h" #include "game.h" #include "guiwrapper.h" @@ -988,7 +987,7 @@ bool startWindowImpl::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::Close) { event->ignore(); - myGuiInterface->getMyLog()->closeLogDbAtExit(); +// mySession->getMyLog()->closeLogDbAtExit(); return QMainWindow::eventFilter(obj, event); } else { diff --git a/src/session.cpp b/src/session.cpp index 77ffcc35..b6b563fb 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -42,7 +42,7 @@ using namespace std; Session::Session(GuiInterface *g, ConfigFile *c) - : currentGameNum(0), myGui(g), myConfig(c), myGameType(GAME_TYPE_NONE) + : currentGameNum(0), myGui(g), myConfig(c), myLog(0), myGameType(GAME_TYPE_NONE) { myQtToolsInterface = CreateQtToolsWrapper(); } diff --git a/src/session.h b/src/session.h index fbef4742..946fcd94 100755 --- a/src/session.h +++ b/src/session.h @@ -23,6 +23,7 @@ #include #include +#include "log.h" #include "serverdata.h" #include "gamedata.h" #include "playerdata.h" @@ -33,6 +34,7 @@ class GuiInterface; class Game; class ConfigFile; +class Log; class ClientThread; class ServerManager; class IrcThread; @@ -59,6 +61,7 @@ public: Game *getCurrentGame(); GuiInterface *getGui(); + Log* getMyLog() {return myLog; } GameType getGameType(); boost::shared_ptr getAvatarManager(); @@ -122,6 +125,7 @@ private: boost::shared_ptr currentGame; GuiInterface *myGui; ConfigFile *myConfig; + Log *myLog; GameType myGameType; QtToolsInterface *myQtToolsInterface; };