changes in logging with sqlite-db

This commit is contained in:
floty
2010-07-15 22:36:06 +00:00
parent 79e7a47343
commit e2cef18b57
+36 -20
View File
@@ -30,6 +30,7 @@ using namespace std;
Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), myHtmlLogFile(0), mySqliteLogDb(0)
{
myW->setLog(this);
myStyle = myW->getMyGameTableStyle();
@@ -54,7 +55,9 @@ Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), my
if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled
QDir logDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str()));
if(myConfig->readConfigString("LogDir") != "" && logDir.exists()) {
myLogDir = new QDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str()));
@@ -115,7 +118,7 @@ Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), my
for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) {
sql += ",Seat_" + QString("%1").arg(i);
}
sql += ")";
sql += ",Winner_Seat INTEGER)";
if(!query.exec(sql)) {
QMessageBox::critical(0, tr("ERROR"),query.lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
@@ -157,9 +160,7 @@ Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), my
}
} else {
QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
}
//Zu alte Dateien löschen!!!
@@ -190,8 +191,9 @@ Log::Log(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), my
}
} else {
cout << "Log directory doesn't exist. Cannot create log files";
}
else { cout << "Log directory doesn't exist. Cannot create log files"; }
}
}
@@ -276,7 +278,7 @@ void Log::logNewGameHandMsg(int gameID, int handID) {
if(myConfig->readConfigInt("LogOnOff")) {
//if write logfiles is enabled
int i;
// int i;
logFileStreamString += "<table><tr><td width=\"600\" align=\"center\"><hr noshade size=\"3\"><b>Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+"</b></td><td></td></tr></table>";
logFileStreamString += "BLIND LEVEL: $"+QString::number(currentHand->getSmallBlind())+" / $"+QString::number(currentHand->getSmallBlind()*2)+"</br>";
@@ -294,41 +296,55 @@ void Log::logNewGameHandMsg(int gameID, int handID) {
// bei Beginn eines Games
if(handID == 1) {
sql = "INSERT INTO Game (GameID,Startmoney,StartSb,DealerPos";
for(i=1;i<=MAX_NUMBER_OF_PLAYERS; i++) {
sql += ",Seat_" + QString::number(i,10);
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->getSeatsList()->begin();it_c!=currentHand->getSeatsList()->end();it_c++) {
if((*it_c)->getMyActiveStatus()) {
for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); it_c++) {
sql += ",'" + QString::fromUtf8((*it_c)->getMyName().c_str()) +"'";
} else {
sql += ",NULL";
}
}
// 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);
}
}
sql = "INSERT INTO Hand (HandID,GameID";
for(i=1;i<=MAX_NUMBER_OF_PLAYERS; i++) {
sql += ",Seat_" + QString("%1").arg(i) + "_Cash";
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);
for(it_c = currentHand->getSeatsList()->begin();it_c!=currentHand->getSeatsList()->end();it_c++) {
if((*it_c)->getMyActiveStatus()) {
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);
} else {
sql += ",NULL";
}
}
// 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)) {