some bugfixes in Log and guiLog
This commit is contained in:
@@ -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<std::string>(i);
|
||||
}
|
||||
sql += ") VALUES (";
|
||||
sql += boost::lexical_cast<string>(gameID);
|
||||
sql += "," + boost::lexical_cast<string>(currentGame->getStartCash());
|
||||
sql += "," + boost::lexical_cast<string>(currentGame->getStartSmallBlind());
|
||||
sql += "," + boost::lexical_cast<string>(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;
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
@@ -22,10 +22,16 @@
|
||||
|
||||
#include <sqlite3.h>
|
||||
#include <dirent.h>
|
||||
#include <iostream>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
void setSession(boost::shared_ptr<Session> session);
|
||||
|
||||
gameTableImpl* getMyW() const {return NULL;}
|
||||
guiLog* getMyLog() const {return NULL;}
|
||||
guiLog* getMyGuiLog() const {return NULL;}
|
||||
|
||||
void refreshSet() const;
|
||||
void refreshCash() const;
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
class guiLog;
|
||||
class Log;
|
||||
class Session;
|
||||
class gameTableImpl;
|
||||
|
||||
@@ -42,7 +41,7 @@ public:
|
||||
virtual void setSession(boost::shared_ptr<Session> session) =0;
|
||||
|
||||
virtual gameTableImpl *getMyW() const=0;
|
||||
virtual guiLog* getMyLog() const=0;
|
||||
virtual guiLog* getMyGuiLog() const=0;
|
||||
|
||||
|
||||
//refresh-Funktionen
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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> 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;
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <net/socket_msg.h>
|
||||
#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 {
|
||||
|
||||
+1
-1
@@ -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();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <string>
|
||||
|
||||
#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<AvatarManager> getAvatarManager();
|
||||
@@ -122,6 +125,7 @@ private:
|
||||
boost::shared_ptr<Game> currentGame;
|
||||
GuiInterface *myGui;
|
||||
ConfigFile *myConfig;
|
||||
Log *myLog;
|
||||
GameType myGameType;
|
||||
QtToolsInterface *myQtToolsInterface;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user