From 02518c67b2adb4f2cb3f1e17b47cf5986933ba02 Mon Sep 17 00:00:00 2001 From: lotodore Date: Fri, 11 Feb 2011 20:02:08 +0000 Subject: [PATCH] Reformatting code using Kernighan & Ritchie style, tabs, tab width=4. Command line: astyle --style=kr --indent=force-tab=4 --lineend=linux -n -r --- src/chatcleaner/badwordcheck.cpp | 4 +- src/chatcleaner/badwordcheck.h | 19 +- src/chatcleaner/capsfloodcheck.cpp | 7 +- src/chatcleaner/capsfloodcheck.h | 15 +- src/chatcleaner/chatcleaner.cpp | 14 +- src/chatcleaner/cleanerconfig.cpp | 306 +- src/chatcleaner/cleanerconfig.h | 20 +- src/chatcleaner/cleanerserver.cpp | 69 +- src/chatcleaner/cleanerserver.h | 51 +- src/chatcleaner/letterrepeatingcheck.cpp | 14 +- src/chatcleaner/letterrepeatingcheck.h | 15 +- src/chatcleaner/messagefilter.cpp | 314 +- src/chatcleaner/messagefilter.h | 59 +- src/chatcleaner/textfloodcheck.cpp | 49 +- src/chatcleaner/textfloodcheck.h | 18 +- src/chatcleaner/urlcheck.cpp | 14 +- src/chatcleaner/urlcheck.h | 19 +- src/config/configfile.cpp | 1021 +- src/config/configfile.h | 18 +- src/connectivity.cpp | 144 +- src/core/avatarmanager.h | 2 +- src/core/common/avatarmanager.cpp | 234 +- src/core/common/crypthelper.cpp | 60 +- src/core/common/loghelper_server.cpp | 18 +- src/core/common/pokerthexception.cpp | 2 +- src/core/common/thread.cpp | 22 +- src/core/linux/convhelper.cpp | 8 +- src/core/openssl_wrapper.h | 56 +- src/core/pokerthexception.h | 8 +- src/core/thread.h | 2 +- src/core/win32/convhelper.cpp | 12 +- src/db/common/serverdbgeneric.cpp | 4 +- src/db/common/serverdbnoaction.cpp | 58 +- src/db/dbdefs.h | 3 +- src/db/serverdbnoaction.h | 102 +- src/engine/berointerface.cpp | 2 +- src/engine/berointerface.h | 5 +- src/engine/boardinterface.h | 17 +- src/engine/enginefactory.h | 7 +- src/engine/handinterface.h | 21 +- src/engine/local_engine/arraydata.cpp | 31 +- src/engine/local_engine/arraydata.h | 7 +- src/engine/local_engine/cardsvalue.cpp | 451 +- src/engine/local_engine/cardsvalue.h | 19 +- src/engine/local_engine/localbero.cpp | 60 +- src/engine/local_engine/localbero.h | 143 +- src/engine/local_engine/localberoflop.h | 3 +- .../local_engine/localberopostriver.cpp | 12 +- src/engine/local_engine/localberopostriver.h | 11 +- src/engine/local_engine/localberopreflop.cpp | 57 +- src/engine/local_engine/localberopreflop.h | 5 +- src/engine/local_engine/localberoriver.h | 3 +- src/engine/local_engine/localberoturn.h | 3 +- src/engine/local_engine/localboard.cpp | 305 +- src/engine/local_engine/localboard.h | 65 +- .../local_engine/localenginefactory.cpp | 2 +- src/engine/local_engine/localhand.cpp | 565 +- src/engine/local_engine/localhand.h | 143 +- src/engine/local_engine/localplayer.cpp | 8911 +++++++++-------- src/engine/local_engine/localplayer.h | 237 +- src/engine/local_engine/replay.cpp | 8 +- src/engine/local_engine/replay.h | 8 +- src/engine/local_engine/tools.cpp | 24 +- src/engine/local_engine/tools.h | 3 +- src/engine/log.cpp | 348 +- src/engine/log.h | 14 +- src/engine/network_engine/clientbero.cpp | 6 +- src/engine/network_engine/clientbero.h | 9 +- src/engine/network_engine/clientboard.cpp | 12 +- src/engine/network_engine/clientboard.h | 12 +- src/engine/network_engine/clienthand.cpp | 8 +- src/engine/network_engine/clienthand.h | 126 +- src/engine/network_engine/clientplayer.cpp | 37 +- src/engine/network_engine/clientplayer.h | 9 +- src/engine/playerinterface.h | 7 +- src/game.cpp | 63 +- src/game.h | 73 +- src/game_defs.h | 139 +- src/gamedata.h | 33 +- src/gui/generic/serverguiwrapper.cpp | 239 +- src/gui/generic/serverguiwrapper.h | 220 +- src/gui/guiinterface.h | 121 +- src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp | 10 +- src/gui/qt/aboutpokerth/aboutpokerthimpl.h | 7 +- .../changecompleteblindsdialogimpl.cpp | 41 +- .../changecompleteblindsdialogimpl.h | 19 +- .../changecontentdialogimpl.cpp | 147 +- .../changecontentdialogimpl.h | 15 +- src/gui/qt/chattools/chattools.cpp | 292 +- src/gui/qt/chattools/chattools.h | 78 +- .../connecttoserverdialogimpl.cpp | 45 +- .../connecttoserverdialogimpl.h | 7 +- .../createinternetgamedialogimpl.cpp | 268 +- .../createinternetgamedialogimpl.h | 29 +- .../createnetworkgamedialogimpl.cpp | 49 +- .../createnetworkgamedialogimpl.h | 15 +- .../gamelobbydialog/gamelobbydialogimpl.cpp | 2328 ++--- .../qt/gamelobbydialog/gamelobbydialogimpl.h | 238 +- .../mygamelistsortfilterproxymodel.cpp | 15 +- .../mygamelistsortfilterproxymodel.h | 40 +- .../gamelobbydialog/mygamelisttreewidget.cpp | 22 +- .../qt/gamelobbydialog/mygamelisttreewidget.h | 12 +- .../mynicklistsortfilterproxymodel.cpp | 70 +- .../mynicklistsortfilterproxymodel.h | 14 +- src/gui/qt/gametable/gametableimpl.cpp | 5529 +++++----- src/gui/qt/gametable/gametableimpl.h | 750 +- src/gui/qt/gametable/log/guilog.cpp | 3073 +++--- src/gui/qt/gametable/log/guilog.h | 20 +- src/gui/qt/gametable/myactionbutton.cpp | 37 +- src/gui/qt/gametable/myactionbutton.h | 16 +- src/gui/qt/gametable/myavatarlabel.cpp | 614 +- src/gui/qt/gametable/myavatarlabel.h | 52 +- src/gui/qt/gametable/mycardspixmaplabel.cpp | 169 +- src/gui/qt/gametable/mycardspixmaplabel.h | 68 +- src/gui/qt/gametable/mychancelabel.cpp | 133 +- src/gui/qt/gametable/mychancelabel.h | 22 +- src/gui/qt/gametable/mylefttabwidget.cpp | 32 +- src/gui/qt/gametable/mylefttabwidget.h | 16 +- src/gui/qt/gametable/mymenubar.cpp | 11 +- src/gui/qt/gametable/mymenubar.h | 6 +- src/gui/qt/gametable/mynamelabel.cpp | 65 +- src/gui/qt/gametable/mynamelabel.h | 18 +- src/gui/qt/gametable/myrighttabwidget.cpp | 9 +- src/gui/qt/gametable/myrighttabwidget.h | 18 +- src/gui/qt/gametable/mysetlabel.cpp | 9 +- src/gui/qt/gametable/mysetlabel.h | 22 +- src/gui/qt/gametable/myslider.h | 29 +- src/gui/qt/gametable/mystatuslabel.cpp | 21 +- src/gui/qt/gametable/mystatuslabel.h | 20 +- src/gui/qt/gametable/mytimeoutlabel.cpp | 46 +- src/gui/qt/gametable/mytimeoutlabel.h | 30 +- .../qt/gametable/startsplash/startsplash.cpp | 9 +- .../qt/gametable/startsplash/startsplash.h | 8 +- src/gui/qt/guiwrapper.cpp | 508 +- src/gui/qt/guiwrapper.h | 220 +- .../internetgamelogindialogimpl.cpp | 186 +- .../internetgamelogindialogimpl.h | 15 +- .../joinnetworkgamedialogimpl.cpp | 244 +- .../joinnetworkgamedialogimpl.h | 9 +- .../mymessagedialog/mymessagedialogimpl.cpp | 128 +- .../qt/mymessagedialog/mymessagedialogimpl.h | 23 +- .../newlocalgamedialog/newgamedialogimpl.cpp | 22 +- .../qt/newlocalgamedialog/newgamedialogimpl.h | 15 +- src/gui/qt/qttools/nonqttoolswrapper.cpp | 20 +- src/gui/qt/qttools/nonqttoolswrapper.h | 6 +- src/gui/qt/qttools/qthelper/qthelper.cpp | 37 +- src/gui/qt/qttools/qthelper/qthelper.h | 2 +- src/gui/qt/qttools/qttoolswrapper.cpp | 20 +- src/gui/qt/qttools/qttoolswrapper.h | 10 +- .../serverlistdialog/serverlistdialogimpl.cpp | 16 +- .../serverlistdialog/serverlistdialogimpl.h | 11 +- .../manualblindsorderdialogimpl.cpp | 36 +- .../manualblindsorderdialogimpl.h | 19 +- src/gui/qt/settingsdialog/myavatarbutton.cpp | 4 +- src/gui/qt/settingsdialog/myavatarbutton.h | 16 +- .../qt/settingsdialog/myhpavatarbutton.cpp | 4 +- src/gui/qt/settingsdialog/myhpavatarbutton.h | 16 +- src/gui/qt/settingsdialog/mystylelistitem.cpp | 8 +- src/gui/qt/settingsdialog/mystylelistitem.h | 11 +- .../selectavatardialog/myavatarlistitem.cpp | 4 +- .../selectavatardialog/myavatarlistitem.h | 16 +- .../selectavatardialogimpl.cpp | 122 +- .../selectavatardialogimpl.h | 21 +- .../qt/settingsdialog/settingsdialogimpl.cpp | 2046 ++-- .../qt/settingsdialog/settingsdialogimpl.h | 53 +- src/gui/qt/sound/sdlplayer.cpp | 103 +- src/gui/qt/sound/sdlplayer.h | 11 +- .../startnetworkgamedialogimpl.cpp | 106 +- .../startnetworkgamedialogimpl.h | 32 +- src/gui/qt/startwindow/startwindowimpl.cpp | 1686 ++-- src/gui/qt/startwindow/startwindowimpl.h | 188 +- src/gui/qt/styles/carddeckstylereader.cpp | 177 +- src/gui/qt/styles/carddeckstylereader.h | 61 +- src/gui/qt/styles/gametablestylereader.cpp | 2148 ++-- src/gui/qt/styles/gametablestylereader.h | 601 +- .../qt/timeoutmsgbox/timeoutmsgboximpl.cpp | 31 +- src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.h | 24 +- src/gui/qttoolsinterface.h | 5 +- src/net/clientcontext.h | 135 +- src/net/clientstate.h | 4 +- src/net/clientthread.h | 51 +- src/net/common/chatcleanermanager.cpp | 113 +- src/net/common/clientcontext.cpp | 4 +- src/net/common/clientstate.cpp | 684 +- src/net/common/clientthread.cpp | 246 +- src/net/common/downloaderthread.cpp | 30 +- src/net/common/encodedpacket.cpp | 2 +- src/net/common/ircthread.cpp | 265 +- src/net/common/netpacket.cpp | 240 +- src/net/common/receiverhelper.cpp | 20 +- src/net/common/resolverthread.cpp | 16 +- src/net/common/senderhelper.cpp | 66 +- src/net/common/serveraccepthelper.cpp | 28 +- src/net/common/serveradminbot.cpp | 141 +- src/net/common/serverbanmanager.cpp | 52 +- src/net/common/servergame.cpp | 213 +- src/net/common/servergamestate.cpp | 569 +- src/net/common/serverlobbybot.cpp | 14 +- src/net/common/serverlobbythread.cpp | 712 +- src/net/common/servermanager.cpp | 17 +- src/net/common/sessiondata.cpp | 29 +- src/net/common/sessionmanager.cpp | 60 +- src/net/common/socket_startup.cpp | 24 +- src/net/common/transferhelper.cpp | 25 +- src/net/common/uploaderthread.cpp | 24 +- src/net/downloaderthread.h | 10 +- src/net/downloadhelper.h | 2 +- src/net/encodedpacket.h | 6 +- src/net/internalchatcleanerpacket.h | 9 +- src/net/netcontext.h | 2 +- src/net/netpacket.h | 8 +- src/net/receivebuffer.h | 7 +- src/net/serveraccepthelper.h | 4 +- src/net/serverbanmanager.h | 6 +- src/net/servergame.h | 19 +- src/net/servergamestate.h | 4 +- src/net/serverlobbythread.h | 4 +- src/net/servermanager.h | 2 +- src/net/sessionmanager.h | 3 +- src/net/socket_helper.h | 18 +- src/net/transferdata.h | 3 +- src/net/transferhelper.h | 4 +- src/net/uploaderthread.h | 5 +- src/net/uploadhelper.h | 2 +- src/playerdata.cpp | 10 +- src/playerdata.h | 15 +- src/pokerth.cpp | 52 +- src/pokerth_server.cpp | 57 +- src/serverdata.h | 3 +- src/session.cpp | 579 +- src/session.h | 121 +- src/zlib_compress.cpp | 9 +- 232 files changed, 22743 insertions(+), 21044 deletions(-) diff --git a/src/chatcleaner/badwordcheck.cpp b/src/chatcleaner/badwordcheck.cpp index 70475513..790abb96 100644 --- a/src/chatcleaner/badwordcheck.cpp +++ b/src/chatcleaner/badwordcheck.cpp @@ -6,10 +6,10 @@ BadWordCheck::BadWordCheck() { } -bool BadWordCheck::run(QString msg) +bool BadWordCheck::run(QString msg) { msg = msg.toLower(); - + QStringListIterator it(badWords); while (it.hasNext()) { if(msg.contains(it.next())) diff --git a/src/chatcleaner/badwordcheck.h b/src/chatcleaner/badwordcheck.h index 8685e720..e9785b81 100644 --- a/src/chatcleaner/badwordcheck.h +++ b/src/chatcleaner/badwordcheck.h @@ -3,17 +3,20 @@ #include -class BadWordCheck: public QObject { -Q_OBJECT +class BadWordCheck: public QObject +{ + Q_OBJECT public: - BadWordCheck(); - - void setBadWords(QStringList bw) { badWords = bw; } - + BadWordCheck(); + + void setBadWords(QStringList bw) { + badWords = bw; + } + bool run(QString); - + private: - + QStringList badWords; }; diff --git a/src/chatcleaner/capsfloodcheck.cpp b/src/chatcleaner/capsfloodcheck.cpp index 10f901ee..52de8974 100644 --- a/src/chatcleaner/capsfloodcheck.cpp +++ b/src/chatcleaner/capsfloodcheck.cpp @@ -3,11 +3,11 @@ #include CapsFloodCheck::CapsFloodCheck() -: capsNumberToTrigger(0) + : capsNumberToTrigger(0) { } -bool CapsFloodCheck::run(QString msg) +bool CapsFloodCheck::run(QString msg) { msg = msg.simplified().remove(" "); QRegExp e(QString("[A-Z]{%1,}").arg(capsNumberToTrigger)); @@ -16,8 +16,7 @@ bool CapsFloodCheck::run(QString msg) e.indexIn(msg); if(e.matchedLength() != -1 ) return true; else return false; - } - else { + } else { // qDebug() << "The current Caps Flood RegExp is invalid" << endl; return false; } diff --git a/src/chatcleaner/capsfloodcheck.h b/src/chatcleaner/capsfloodcheck.h index fa4f5c39..6b9816a9 100644 --- a/src/chatcleaner/capsfloodcheck.h +++ b/src/chatcleaner/capsfloodcheck.h @@ -3,14 +3,17 @@ #include -class CapsFloodCheck: public QObject { -Q_OBJECT +class CapsFloodCheck: public QObject +{ + Q_OBJECT public: - CapsFloodCheck(); - - void setCapsNumberToTrigger(int n) { capsNumberToTrigger = n; } + CapsFloodCheck(); + + void setCapsNumberToTrigger(int n) { + capsNumberToTrigger = n; + } bool run(QString); - + private: int capsNumberToTrigger; diff --git a/src/chatcleaner/chatcleaner.cpp b/src/chatcleaner/chatcleaner.cpp index ab6a1160..d2b73ae0 100644 --- a/src/chatcleaner/chatcleaner.cpp +++ b/src/chatcleaner/chatcleaner.cpp @@ -2,21 +2,21 @@ #include "cleanerserver.h" #ifdef _WIN32 - #include +#include #else - #include - #ifndef daemon - int daemon(int, int); - #endif +#include +#ifndef daemon +int daemon(int, int); +#endif #endif int main(int argc, char *argv[]) { - QCoreApplication a(argc, argv); + QCoreApplication a(argc, argv); CleanerServer server; #ifndef _WIN32 if (daemon(0, 0) != 0) return -1; #endif - return a.exec(); + return a.exec(); } diff --git a/src/chatcleaner/cleanerconfig.cpp b/src/chatcleaner/cleanerconfig.cpp index 9db977f0..997490a5 100644 --- a/src/chatcleaner/cleanerconfig.cpp +++ b/src/chatcleaner/cleanerconfig.cpp @@ -43,15 +43,14 @@ using namespace std; CleanerConfig::CleanerConfig() { // !!!! Revisionsnummer der Configdefaults !!!!! - configRev = 8; - + configRev = 8; + // Pfad und Dateinamen setzen #ifdef _WIN32 const char *appDataPath = getenv("AppData"); if (appDataPath && appDataPath[0] != 0) { - configFileName = appDataPath; - } - else { + configFileName = appDataPath; + } else { const int MaxPathSize = 1024; char curDir[MaxPathSize + 1]; curDir[0] = 0; @@ -67,8 +66,7 @@ CleanerConfig::CleanerConfig() // Datei wieder loeschen. tmpFile.close(); remove((configFileName + "\\" + tmpFileName).c_str()); - } - else { + } else { // Fehlgeschlagen, Verzeichnis nicht beschreibbar curDir[0] = 0; GetTempPathA(MaxPathSize, curDir); @@ -81,12 +79,12 @@ CleanerConfig::CleanerConfig() ////define log-dir // logDir = configFileName; // logDir += "log-files\\"; - + //create directories on first start of app mkdir(configFileName.c_str()); // mkdir(logDir.c_str()); - - + + #else //define app-dir const char *homePath = getenv("HOME"); @@ -99,9 +97,9 @@ CleanerConfig::CleanerConfig() //create directories on first start of app mkdir(configFileName.c_str(), MODUS) ; // mkdir(logDir.c_str(), MODUS); - + } - + #endif string userDir = configFileName.c_str(); @@ -116,15 +114,15 @@ CleanerConfig::CleanerConfig() configList.push_back(ConfigInfo("DefaultListenPort", CONFIG_TYPE_STRING, "4327")); configList.push_back(ConfigInfo("ClientAuthString", CONFIG_TYPE_STRING, "")); configList.push_back(ConfigInfo("ServerAuthString", CONFIG_TYPE_STRING, "")); - + configList.push_back(ConfigInfo("WarnLevelToKick", CONFIG_TYPE_INT, "2")); configList.push_back(ConfigInfo("TextFloodLevelToTrigger", CONFIG_TYPE_INT, "3")); configList.push_back(ConfigInfo("CapsFloodCapsNumberToTrigger", CONFIG_TYPE_INT, "10")); configList.push_back(ConfigInfo("LetterRepeatingNumberToTrigger", CONFIG_TYPE_INT, "10")); - configList.push_back(ConfigInfo("KickNumberToBan", CONFIG_TYPE_INT, "2")); - configList.push_back(ConfigInfo("SecondsToForgetAboutKick", CONFIG_TYPE_INT, "1800")); - + configList.push_back(ConfigInfo("KickNumberToBan", CONFIG_TYPE_INT, "2")); + configList.push_back(ConfigInfo("SecondsToForgetAboutKick", CONFIG_TYPE_INT, "1800")); + list badWordsList; badWordsList.push_back("arsch"); badWordsList.push_back("asshole"); @@ -169,38 +167,39 @@ CleanerConfig::CleanerConfig() urlStringsList.push_back(".org"); urlStringsList.push_back(".de"); configList.push_back(ConfigInfo("UrlStringsList", CONFIG_TYPE_STRING_LIST, "UrlStrings", urlStringsList)); - + list urlExceptionStringsList; urlExceptionStringsList.push_back("http://www.esl."); urlExceptionStringsList.push_back("http://www.pokerth.net"); urlExceptionStringsList.push_back("pokerth.net"); configList.push_back(ConfigInfo("UrlExceptionStringsList", CONFIG_TYPE_STRING_LIST, "UrlExceptionStrings", urlExceptionStringsList)); - + //fill tempList firstTime configBufferList = configList; configFileName += "cleanerconfig.xml"; - - //Prüfen ob Configfile existiert --> sonst anlegen - TiXmlDocument doc(configFileName); - if(!doc.LoadFile()){ - myConfigState = NONEXISTING; - updateConfig(myConfigState); - } - else { - //Check if config revision is ok. Otherwise --> update() - int tempRevision = 0; - - TiXmlHandle docHandle( &doc ); - TiXmlElement* confRevision = docHandle.FirstChild( "PokerTHCleaner" ).FirstChild( "Configuration" ).FirstChild( "ConfigRevision" ).ToElement(); - if ( confRevision ) { confRevision->QueryIntAttribute("value", &tempRevision ); } - if (tempRevision < configRev ) { /*löschen()*/ + //Prüfen ob Configfile existiert --> sonst anlegen + TiXmlDocument doc(configFileName); + if(!doc.LoadFile()) { + myConfigState = NONEXISTING; + updateConfig(myConfigState); + } else { + //Check if config revision is ok. Otherwise --> update() + int tempRevision = 0; + + TiXmlHandle docHandle( &doc ); + TiXmlElement* confRevision = docHandle.FirstChild( "PokerTHCleaner" ).FirstChild( "Configuration" ).FirstChild( "ConfigRevision" ).ToElement(); + if ( confRevision ) { + confRevision->QueryIntAttribute("value", &tempRevision ); + } + + if (tempRevision < configRev ) { /*löschen()*/ myConfigState = OLD; updateConfig(myConfigState) ; } } - + fillBuffer(); } @@ -211,20 +210,21 @@ CleanerConfig::~CleanerConfig() } -void CleanerConfig::fillBuffer() { +void CleanerConfig::fillBuffer() +{ string tempString1(""); string tempString2(""); - TiXmlDocument doc(configFileName); - + TiXmlDocument doc(configFileName); + if(doc.LoadFile()) { - TiXmlHandle docHandle( &doc ); + TiXmlHandle docHandle( &doc ); for (size_t i=0; iAttribute("value"); @@ -233,38 +233,40 @@ void CleanerConfig::fillBuffer() { const char *tmpStr2 = conf->Attribute("type"); if (tmpStr2) { - tempString2 = tmpStr2; + tempString2 = tmpStr2; if(tempString2 == "list") { - + list tempStringList2; TiXmlElement* confList = docHandle.FirstChild( "PokerTHCleaner" ).FirstChild( "Configuration" ).FirstChild( configList[i].name ).FirstChild().ToElement(); - + for( ; confList; confList=confList->NextSiblingElement()) { tempStringList2.push_back(confList->Attribute("value")); } - + configBufferList[i].defaultListValue = tempStringList2; } } - } - else { qDebug("Could not find the root element in the config file!"); } + } else { + qDebug("Could not find the root element in the config file!"); + } } } } -void CleanerConfig::writeBuffer() const { +void CleanerConfig::writeBuffer() const +{ + + TiXmlDocument doc; + TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", ""); + doc.LinkEndChild( decl ); + + TiXmlElement * root = new TiXmlElement( "PokerTHCleaner" ); + doc.LinkEndChild( root ); - TiXmlDocument doc; - TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", ""); - doc.LinkEndChild( decl ); - - TiXmlElement * root = new TiXmlElement( "PokerTHCleaner" ); - doc.LinkEndChild( root ); - TiXmlElement * config; - config = new TiXmlElement( "Configuration" ); - root->LinkEndChild( config ); + config = new TiXmlElement( "Configuration" ); + root->LinkEndChild( config ); size_t i; @@ -272,42 +274,43 @@ void CleanerConfig::writeBuffer() const { TiXmlElement *tmpElement = new TiXmlElement(configBufferList[i].name); config->LinkEndChild( tmpElement ); tmpElement->SetAttribute("value", configBufferList[i].defaultValue); - + if(configBufferList[i].type == CONFIG_TYPE_INT_LIST || configBufferList[i].type == CONFIG_TYPE_STRING_LIST) { tmpElement->SetAttribute("type", "list"); list tempList = configBufferList[i].defaultListValue; list::iterator it; for(it = tempList.begin(); it != tempList.end(); ++it) { - + TiXmlElement *tmpSubElement = new TiXmlElement(configBufferList[i].defaultValue); tmpElement->LinkEndChild( tmpSubElement ); tmpSubElement->SetAttribute("value", *it); } } - } + } doc.SaveFile( configFileName ); } -void CleanerConfig::updateConfig(ConfigState myConfigState) { +void CleanerConfig::updateConfig(ConfigState myConfigState) +{ size_t i; - + if(myConfigState == NONEXISTING) { - + //Create a new ConfigFile! - TiXmlDocument doc; - TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", ""); - doc.LinkEndChild( decl ); - - TiXmlElement * root = new TiXmlElement( "PokerTHCleaner" ); - doc.LinkEndChild( root ); - + TiXmlDocument doc; + TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", ""); + doc.LinkEndChild( decl ); + + TiXmlElement * root = new TiXmlElement( "PokerTHCleaner" ); + doc.LinkEndChild( root ); + TiXmlElement * config; - config = new TiXmlElement( "Configuration" ); - root->LinkEndChild( config ); + config = new TiXmlElement( "Configuration" ); + root->LinkEndChild( config ); for (i=0; i tempList = configList[i].defaultListValue; list::iterator it; for(it = tempList.begin(); it != tempList.end(); ++it) { - + TiXmlElement *tmpSubElement = new TiXmlElement(configList[i].defaultValue); tmpElement->LinkEndChild( tmpSubElement ); tmpSubElement->SetAttribute("value", *it); @@ -328,77 +331,77 @@ void CleanerConfig::updateConfig(ConfigState myConfigState) { } } - + doc.SaveFile( configFileName ); } if(myConfigState == OLD) { - - TiXmlDocument oldDoc(configFileName); - + + TiXmlDocument oldDoc(configFileName); + //load the old one if(oldDoc.LoadFile()) { - - string tempString1(""); - string tempString2(""); - - TiXmlDocument newDoc; - - //Create the new one - TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", ""); - newDoc.LinkEndChild( decl ); - - TiXmlElement * root = new TiXmlElement( "PokerTHCleaner" ); - newDoc.LinkEndChild( root ); - - TiXmlElement * config; - config = new TiXmlElement( "Configuration" ); - root->LinkEndChild( config ); - //change configRev and AppDataPath - TiXmlElement * confElement0 = new TiXmlElement( "ConfigRevision" ); + string tempString1(""); + string tempString2(""); + + TiXmlDocument newDoc; + + //Create the new one + TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", ""); + newDoc.LinkEndChild( decl ); + + TiXmlElement * root = new TiXmlElement( "PokerTHCleaner" ); + newDoc.LinkEndChild( root ); + + TiXmlElement * config; + config = new TiXmlElement( "Configuration" ); + root->LinkEndChild( config ); + + //change configRev and AppDataPath + TiXmlElement * confElement0 = new TiXmlElement( "ConfigRevision" ); config->LinkEndChild( confElement0 ); confElement0->SetAttribute("value", configRev); - TiXmlHandle oldDocHandle( &oldDoc ); + TiXmlHandle oldDocHandle( &oldDoc ); - for (i=0; i take over the saved values - + // if element is already there --> take over the saved values + if(configList[i].name != "ConfigRevision") { - // dont update ConfigRevision because it was already set ^ - + // dont update ConfigRevision because it was already set ^ + TiXmlElement *tmpElement = new TiXmlElement(configList[i].name); config->LinkEndChild( tmpElement ); - + const char *tmpStr1 = oldConf->Attribute("value"); if (tmpStr1) tempString1 = tmpStr1; tmpElement->SetAttribute("value", tempString1); - + //for lists copy elements const char *tmpStr2 = oldConf->Attribute("type"); if (tmpStr2) { - tempString2 = tmpStr2; + tempString2 = tmpStr2; if(tempString2 == "list") { - + list tempStringList2; - + TiXmlElement* oldConfList = oldDocHandle.FirstChild( "PokerTHCleaner" ).FirstChild( "Configuration" ).FirstChild( configList[i].name ).FirstChild().ToElement(); - + for( ; oldConfList; oldConfList=oldConfList->NextSiblingElement()) { tempStringList2.push_back(oldConfList->Attribute("value")); - } - + } + tmpElement->SetAttribute("type", "list"); list tempList = tempStringList2; list::iterator it; for(it = tempList.begin(); it != tempList.end(); ++it) { - + TiXmlElement *tmpSubElement = new TiXmlElement(tempString1); tmpElement->LinkEndChild( tmpSubElement ); tmpSubElement->SetAttribute("value", *it); @@ -406,32 +409,32 @@ void CleanerConfig::updateConfig(ConfigState myConfigState) { } } } - } - else { + } else { // if element is not there --> set it with defaultValue TiXmlElement *tmpElement = new TiXmlElement(configList[i].name); config->LinkEndChild( tmpElement ); tmpElement->SetAttribute("value", stringToUtf8(configList[i].defaultValue)); - + if(configList[i].type == CONFIG_TYPE_INT_LIST || configList[i].type == CONFIG_TYPE_STRING_LIST) { - + tmpElement->SetAttribute("type", "list"); list tempList = configList[i].defaultListValue; list::iterator it; for(it = tempList.begin(); it != tempList.end(); ++it) { - + TiXmlElement *tmpSubElement = new TiXmlElement(configList[i].defaultValue); tmpElement->LinkEndChild( tmpSubElement ); tmpSubElement->SetAttribute("value", *it); } } } - } + } newDoc.SaveFile( configFileName ); + } else { + qDebug("Cannot update config file: Unable to load configuration."); } - else { qDebug("Cannot update config file: Unable to load configuration."); } - + } } @@ -441,15 +444,15 @@ string CleanerConfig::readConfigString(string varName) const size_t i; string tempString(""); - for (i=0; i> tempInt; - + return tempInt; } list CleanerConfig::readConfigStringList(string varName) const { - size_t i; + size_t i; list tempStringList; - for (i=0; i CleanerConfig::readConfigIntList(string varName) const @@ -496,19 +499,19 @@ list CleanerConfig::readConfigIntList(string varName) const list tempStringList; list tempIntList; - for (i=0; i::iterator it; for(it = tempStringList.begin(); it != tempStringList.end(); ++it) { - + isst.str(*it); isst >> tempInt; tempIntList.push_back(tempInt); @@ -527,11 +530,11 @@ void CleanerConfig::writeConfigInt(string varName, int varCont) string tempString; ostringstream intToString; - for (i=0; i varCont) ostringstream intToString; list stringList; - for (i=0; i::iterator it; for(it = varCont.begin(); it != varCont.end(); ++it) { - - intToString << (*it); + + intToString << (*it); stringList.push_back(intToString.str()); intToString.str(""); intToString.clear(); } - - configBufferList[i].defaultListValue = stringList; + + configBufferList[i].defaultListValue = stringList; } } } @@ -568,11 +571,11 @@ void CleanerConfig::writeConfigStringList(string varName, list varCont) size_t i; list stringList; - for (i=0; i readConfigIntList(std::string varName) const; std::list readConfigStringList(std::string varName) const; - + void writeConfigInt(std::string varName, int varCont); void writeConfigString(std::string varName, std::string varCont); void writeConfigIntList(std::string varName, std::list varCont); @@ -57,16 +60,15 @@ public: private: - struct ConfigInfo - { + struct ConfigInfo { ConfigInfo(const std::string &n, ConfigType t, const std::string &d, const std::list &l =std::list()) : name(n), type(t), defaultValue(d), defaultListValue(l) {} std::string name; ConfigType type; std::string defaultValue; std::list defaultListValue; - + }; - + std::vector configList; std::vector configBufferList; diff --git a/src/chatcleaner/cleanerserver.cpp b/src/chatcleaner/cleanerserver.cpp index 76da4bb3..00b662b4 100644 --- a/src/chatcleaner/cleanerserver.cpp +++ b/src/chatcleaner/cleanerserver.cpp @@ -37,7 +37,7 @@ CleanerServer::CleanerServer(): config(0), blockConnection(false), m_recvBufUsed configRefreshTimer->start(10000); } -CleanerServer::~CleanerServer() +CleanerServer::~CleanerServer() { delete config; delete myMessageFilter; @@ -59,24 +59,19 @@ void CleanerServer::onRead() { qint64 bytesRead = tcpSocket->read((char *)m_recvBuf + m_recvBufUsed, sizeof(m_recvBuf) - m_recvBufUsed); bool error = bytesRead < 1; - if (!error) - { + if (!error) { m_recvBufUsed += bytesRead; asn_dec_rval_t retVal; - do - { + do { // Try to decode the packets. InternalChatCleanerPacket recvMsg; retVal = ber_decode(0, &asn_DEF_ChatCleanerMessage, (void **)recvMsg.GetMsgPtr(), m_recvBuf, m_recvBufUsed); - if(retVal.code == RC_OK) - { - if (retVal.consumed < m_recvBufUsed) - { + if(retVal.code == RC_OK) { + if (retVal.consumed < m_recvBufUsed) { m_recvBufUsed -= retVal.consumed; memmove(m_recvBuf, m_recvBuf + retVal.consumed, m_recvBufUsed); - } - else + } else m_recvBufUsed = 0; // Handle the packets. @@ -85,8 +80,7 @@ void CleanerServer::onRead() } while (!error && retVal.code == RC_OK); } - if (error) - { + if (error) { qDebug() << "Error handling packets from client."; tcpSocket->close(); } @@ -104,16 +98,14 @@ void CleanerServer::onRead() tcpSocket->write(checkMessage.toAscii().data(), checkMessage.length());*/ } -bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) { +bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) +{ bool error = true; - if (msg.GetMsg()->present == ChatCleanerMessage_PR_cleanerInitMessage) - { + if (msg.GetMsg()->present == ChatCleanerMessage_PR_cleanerInitMessage) { CleanerInitMessage_t *netInit = &msg.GetMsg()->choice.cleanerInitMessage; - if (netInit->requestedVersion == CLEANER_PROTOCOL_VERSION) - { + if (netInit->requestedVersion == CLEANER_PROTOCOL_VERSION) { string tmpClientSecret((const char *)netInit->clientSecret.buf, netInit->clientSecret.size); - if (clientSecret == QString::fromStdString(tmpClientSecret)) - { + if (clientSecret == QString::fromStdString(tmpClientSecret)) { error = false; InternalChatCleanerPacket tmpAck; @@ -125,28 +117,23 @@ bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) { tmpServerSecret.c_str(), tmpServerSecret.length()); sendMessageToClient(tmpAck); - } - else + } else qDebug() << "Invalid client secret."; - } - else + } else qDebug() << "Invalid client version: " << netInit->requestedVersion; - } - else if (msg.GetMsg()->present == ChatCleanerMessage_PR_cleanerChatRequestMessage) - { + } else if (msg.GetMsg()->present == ChatCleanerMessage_PR_cleanerChatRequestMessage) { error = false; CleanerChatRequestMessage_t *netRequest = &msg.GetMsg()->choice.cleanerChatRequestMessage; unsigned playerId = netRequest->playerId; QString nick(QString::fromUtf8( - string((const char *)netRequest->playerName.buf, netRequest->playerName.size).c_str())); + string((const char *)netRequest->playerName.buf, netRequest->playerName.size).c_str())); QString message(QString::fromUtf8( - string((const char *)netRequest->chatMessage.buf, netRequest->chatMessage.size).c_str())); + string((const char *)netRequest->chatMessage.buf, netRequest->chatMessage.size).c_str())); QStringList checkreturn = myMessageFilter->check(playerId, nick, message); QString checkAction = checkreturn.at(0); QString checkMessage = checkreturn.at(1); - if (!checkAction.isEmpty()) - { + if (!checkAction.isEmpty()) { InternalChatCleanerPacket tmpReply; tmpReply.GetMsg()->present = ChatCleanerMessage_PR_cleanerChatReplyMessage; CleanerChatReplyMessage_t *netReply = &tmpReply.GetMsg()->choice.cleanerChatReplyMessage; @@ -156,33 +143,33 @@ bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) { if(checkAction == "warn") { netReply->cleanerActionType = cleanerActionType_cleanerActionWarning; - } - else if(checkAction == "kick") { + } else if(checkAction == "kick") { netReply->cleanerActionType = cleanerActionType_cleanerActionKick; - } - else if(checkAction == "kickban") { + } else if(checkAction == "kickban") { netReply->cleanerActionType = cleanerActionType_cleanerActionBan; } string tmpCheck(checkMessage.toUtf8()); netReply->cleanerText = - OCTET_STRING_new_fromBuf( - &asn_DEF_OCTET_STRING, - (const char *)tmpCheck.c_str(), - tmpCheck.length()); + OCTET_STRING_new_fromBuf( + &asn_DEF_OCTET_STRING, + (const char *)tmpCheck.c_str(), + tmpCheck.length()); sendMessageToClient(tmpReply); } } return error; } -void CleanerServer::socketStateChanged(QAbstractSocket::SocketState state) { +void CleanerServer::socketStateChanged(QAbstractSocket::SocketState state) +{ qDebug() << "Socket state changed to: " << QAbstractSocket::UnconnectedState; if(state == QAbstractSocket::UnconnectedState) blockConnection = false; } -void CleanerServer::refreshConfig() { +void CleanerServer::refreshConfig() +{ QFileInfo configFileInfo(QString::fromUtf8(config->getConfigFileName().c_str())); diff --git a/src/chatcleaner/cleanerserver.h b/src/chatcleaner/cleanerserver.h index ee70dfe0..5c4b0d9e 100644 --- a/src/chatcleaner/cleanerserver.h +++ b/src/chatcleaner/cleanerserver.h @@ -8,36 +8,37 @@ class MessageFilter; class CleanerConfig; -class CleanerServer: public QObject { -Q_OBJECT - +class CleanerServer: public QObject +{ + Q_OBJECT + public: - CleanerServer(); + CleanerServer(); ~CleanerServer(); - + private slots: - void newCon(); - void onRead(); - bool handleMessage(InternalChatCleanerPacket &msg); - void socketStateChanged(QAbstractSocket::SocketState); - void refreshConfig(); - void sendMessageToClient(InternalChatCleanerPacket &msg); + void newCon(); + void onRead(); + bool handleMessage(InternalChatCleanerPacket &msg); + void socketStateChanged(QAbstractSocket::SocketState); + void refreshConfig(); + void sendMessageToClient(InternalChatCleanerPacket &msg); private: - QTcpServer *tcpServer; - QTcpSocket *tcpSocket; - QTimer *configRefreshTimer; - MessageFilter *myMessageFilter; - - CleanerConfig *config; - bool blockConnection; - QString clientSecret; - QString serverSecret; - - unsigned char m_recvBuf[2*MAX_CLEANER_PACKET_SIZE]; - unsigned m_recvBufUsed; - - int secondsSinceLastConfigChange; + QTcpServer *tcpServer; + QTcpSocket *tcpSocket; + QTimer *configRefreshTimer; + MessageFilter *myMessageFilter; + + CleanerConfig *config; + bool blockConnection; + QString clientSecret; + QString serverSecret; + + unsigned char m_recvBuf[2*MAX_CLEANER_PACKET_SIZE]; + unsigned m_recvBufUsed; + + int secondsSinceLastConfigChange; }; #endif // CLEANERSERVER_H diff --git a/src/chatcleaner/letterrepeatingcheck.cpp b/src/chatcleaner/letterrepeatingcheck.cpp index 6349ee64..b4e90952 100644 --- a/src/chatcleaner/letterrepeatingcheck.cpp +++ b/src/chatcleaner/letterrepeatingcheck.cpp @@ -3,23 +3,21 @@ #include LetterRepeatingCheck::LetterRepeatingCheck() -: letterNumberToTrigger(0) + : letterNumberToTrigger(0) { } -bool LetterRepeatingCheck::run(QString msg) +bool LetterRepeatingCheck::run(QString msg) { msg = msg.simplified().remove(" "); QRegExp e(QString(".*(.)\\1{%1,}.*").arg(letterNumberToTrigger-1)); if(e.isValid()) { - if(e.exactMatch(msg)) { - return true; - } - else { + if(e.exactMatch(msg)) { + return true; + } else { return false; } - } - else { + } else { // qDebug() << "The current Letter Repeating RegExp is invalid" << endl; return false; } diff --git a/src/chatcleaner/letterrepeatingcheck.h b/src/chatcleaner/letterrepeatingcheck.h index e23126f7..e1f9a558 100644 --- a/src/chatcleaner/letterrepeatingcheck.h +++ b/src/chatcleaner/letterrepeatingcheck.h @@ -3,14 +3,17 @@ #include -class LetterRepeatingCheck: public QObject { -Q_OBJECT +class LetterRepeatingCheck: public QObject +{ + Q_OBJECT public: - LetterRepeatingCheck(); - - void setLetterNumberToTrigger(int n) { letterNumberToTrigger = n; } + LetterRepeatingCheck(); + + void setLetterNumberToTrigger(int n) { + letterNumberToTrigger = n; + } bool run(QString); - + private: int letterNumberToTrigger; diff --git a/src/chatcleaner/messagefilter.cpp b/src/chatcleaner/messagefilter.cpp index a4bbea9c..f2a04ce8 100644 --- a/src/chatcleaner/messagefilter.cpp +++ b/src/chatcleaner/messagefilter.cpp @@ -10,203 +10,199 @@ #include "urlcheck.h" enum ActionType { - NOTHING, - WARN, - KICK, - KICKBAN + NOTHING, + WARN, + KICK, + KICKBAN }; enum OffenceType { - NONE, - BAD_WORD, - TEXT_FLOOD_LINES, - CAPS_FLOOD, - LETTER_REPEATING, - URL + NONE, + BAD_WORD, + TEXT_FLOOD_LINES, + CAPS_FLOOD, + LETTER_REPEATING, + URL }; MessageFilter::MessageFilter(CleanerConfig *c): config(c) { - myBadWordCheck = new BadWordCheck; - myTextFloodCheck = new TextFloodCheck; - myCapsFloodCheck = new CapsFloodCheck; - myLetterRepeatingCheck = new LetterRepeatingCheck; - myUrlCheck = new UrlCheck; + myBadWordCheck = new BadWordCheck; + myTextFloodCheck = new TextFloodCheck; + myCapsFloodCheck = new CapsFloodCheck; + myLetterRepeatingCheck = new LetterRepeatingCheck; + myUrlCheck = new UrlCheck; - cleanTimer = new QTimer(); - connect(cleanTimer, SIGNAL(timeout()), this, SLOT(cleanKickCounterList())); - cleanTimer->start(30000); + cleanTimer = new QTimer(); + connect(cleanTimer, SIGNAL(timeout()), this, SLOT(cleanKickCounterList())); + cleanTimer->start(30000); } -MessageFilter::~MessageFilter() { +MessageFilter::~MessageFilter() +{ - delete myBadWordCheck; - delete myTextFloodCheck; - delete myCapsFloodCheck; - delete myLetterRepeatingCheck; - delete myUrlCheck; - delete cleanTimer; + delete myBadWordCheck; + delete myTextFloodCheck; + delete myCapsFloodCheck; + delete myLetterRepeatingCheck; + delete myUrlCheck; + delete cleanTimer; } QStringList MessageFilter::check(unsigned playerId, QString nick, QString msg) { - QStringList returnList; - QString returnMessage; - QString returnAction; + QStringList returnList; + QString returnMessage; + QString returnAction; - OffenceType offence = NONE; + OffenceType offence = NONE; - if(myBadWordCheck->run(msg)) offence = BAD_WORD; - if(myCapsFloodCheck->run(msg)) offence = CAPS_FLOOD; - if(myLetterRepeatingCheck->run(msg)) offence = LETTER_REPEATING; - if(myUrlCheck->run(msg)) offence = URL; - if(myTextFloodCheck->run(playerId)) offence = TEXT_FLOOD_LINES; + if(myBadWordCheck->run(msg)) offence = BAD_WORD; + if(myCapsFloodCheck->run(msg)) offence = CAPS_FLOOD; + if(myLetterRepeatingCheck->run(msg)) offence = LETTER_REPEATING; + if(myUrlCheck->run(msg)) offence = URL; + if(myTextFloodCheck->run(playerId)) offence = TEXT_FLOOD_LINES; + + if(offence) { - if(offence){ - ActionType action = NOTHING; QMap::const_iterator i = myClientWarnLevelList.find(playerId); - if(i == myClientWarnLevelList.end()) { - ClientWarnInfos tmpInfos; - tmpInfos.warnLevel = 1; - tmpInfos.lastWarnType = offence; - tmpInfos.nick = nick; - myClientWarnLevelList.insert(playerId, tmpInfos); - action = WARN; - } - else { - if(i.value().warnLevel == warnLevelToKick || i.value().lastWarnType == offence) { - // Kick Command - action = KICK; - //remove playerId from all lists and as LAST from myClientWarnLevelList - myTextFloodCheck->removeNickFromList(i.key()); - myClientWarnLevelList.remove(i.key()); - //check if player is already on kickCounterList - QMap::const_iterator j = myClientKickCounterList.find(nick); - if(j == myClientKickCounterList.end()) { - //if player is NOT on this list put the playerId on it to ban after multiple offence - ClientKickInfos tmpInfos; - tmpInfos.kickNumber = 1; - tmpInfos.lastKickTimestamp = timer.elapsed().total_seconds(); - myClientKickCounterList.insert(nick, tmpInfos); - } - else { - //pleayer is already on the list: either raise kickNumber or kickban when kickNumerToBan is reached - if(j.value().kickNumber == kickNumberToBan) { - action = KICKBAN; - //remove player from kickCounterList - myClientKickCounterList.remove(j.key()); - } - else { - ClientKickInfos tmpInfos; - tmpInfos.kickNumber = j.value().kickNumber+1; - tmpInfos.lastKickTimestamp = timer.elapsed().total_seconds(); - myClientKickCounterList.insert(nick, tmpInfos); - } - } - } - else { - ClientWarnInfos tmpInfos; - tmpInfos.warnLevel = i.value().warnLevel+1; - tmpInfos.lastWarnType = offence; - tmpInfos.nick = nick; - myClientWarnLevelList.insert(playerId, tmpInfos); - action = WARN; - } - } + if(i == myClientWarnLevelList.end()) { + ClientWarnInfos tmpInfos; + tmpInfos.warnLevel = 1; + tmpInfos.lastWarnType = offence; + tmpInfos.nick = nick; + myClientWarnLevelList.insert(playerId, tmpInfos); + action = WARN; + } else { + if(i.value().warnLevel == warnLevelToKick || i.value().lastWarnType == offence) { + // Kick Command + action = KICK; + //remove playerId from all lists and as LAST from myClientWarnLevelList + myTextFloodCheck->removeNickFromList(i.key()); + myClientWarnLevelList.remove(i.key()); + //check if player is already on kickCounterList + QMap::const_iterator j = myClientKickCounterList.find(nick); + if(j == myClientKickCounterList.end()) { + //if player is NOT on this list put the playerId on it to ban after multiple offence + ClientKickInfos tmpInfos; + tmpInfos.kickNumber = 1; + tmpInfos.lastKickTimestamp = timer.elapsed().total_seconds(); + myClientKickCounterList.insert(nick, tmpInfos); + } else { + //pleayer is already on the list: either raise kickNumber or kickban when kickNumerToBan is reached + if(j.value().kickNumber == kickNumberToBan) { + action = KICKBAN; + //remove player from kickCounterList + myClientKickCounterList.remove(j.key()); + } else { + ClientKickInfos tmpInfos; + tmpInfos.kickNumber = j.value().kickNumber+1; + tmpInfos.lastKickTimestamp = timer.elapsed().total_seconds(); + myClientKickCounterList.insert(nick, tmpInfos); + } + } + } else { + ClientWarnInfos tmpInfos; + tmpInfos.warnLevel = i.value().warnLevel+1; + tmpInfos.lastWarnType = offence; + tmpInfos.nick = nick; + myClientWarnLevelList.insert(playerId, tmpInfos); + action = WARN; + } + } - if(action == WARN) { + if(action == WARN) { - switch(offence) { - case BAD_WORD: { - returnMessage = QString ("%1: Warning! No racial, religious, or sexually inflammatory language!\n").arg(nick); - } - break; - case TEXT_FLOOD_LINES: { - returnMessage = QString ("%1: Warning! You've triggered text flood (lines) protection, slow down your typing!\n").arg(nick); - } - break; - case CAPS_FLOOD: { - returnMessage = QString ("%1: Warning: You've triggered caps flood protection, release your caps!\n").arg(nick); - } - break; - case LETTER_REPEATING: { - returnMessage = QString ("%1: Warning: You've triggered letter repeating protection, stop repeating!\n").arg(nick); - } - break; - case URL: { - returnMessage = QString ("%1: Warning: You've triggered url spam protection, stop posting urls!\n").arg(nick); - } - break; - default:; - } - returnAction = QString("warn"); - } - else if(action == KICK) { - returnMessage = QString("%1 kicked! Please respect: http://chatrules.pokerth.net\n").arg(nick); - returnAction = QString("kick"); - } - else if(action == KICKBAN) { - returnMessage = QString("%1 kicked and banned! Please respect: http://chatrules.pokerth.net\n").arg(nick); - returnAction = QString("kickban"); - } - } - else { - returnAction = QString(""); - returnMessage = QString(""); - } + switch(offence) { + case BAD_WORD: { + returnMessage = QString ("%1: Warning! No racial, religious, or sexually inflammatory language!\n").arg(nick); + } + break; + case TEXT_FLOOD_LINES: { + returnMessage = QString ("%1: Warning! You've triggered text flood (lines) protection, slow down your typing!\n").arg(nick); + } + break; + case CAPS_FLOOD: { + returnMessage = QString ("%1: Warning: You've triggered caps flood protection, release your caps!\n").arg(nick); + } + break; + case LETTER_REPEATING: { + returnMessage = QString ("%1: Warning: You've triggered letter repeating protection, stop repeating!\n").arg(nick); + } + break; + case URL: { + returnMessage = QString ("%1: Warning: You've triggered url spam protection, stop posting urls!\n").arg(nick); + } + break; + default: + ; + } + returnAction = QString("warn"); + } else if(action == KICK) { + returnMessage = QString("%1 kicked! Please respect: http://chatrules.pokerth.net\n").arg(nick); + returnAction = QString("kick"); + } else if(action == KICKBAN) { + returnMessage = QString("%1 kicked and banned! Please respect: http://chatrules.pokerth.net\n").arg(nick); + returnAction = QString("kickban"); + } + } else { + returnAction = QString(""); + returnMessage = QString(""); + } - returnList << returnAction << returnMessage; - return returnList; + returnList << returnAction << returnMessage; + return returnList; } -void MessageFilter::refreshConfig() { +void MessageFilter::refreshConfig() +{ - // global settings - warnLevelToKick = config->readConfigInt("WarnLevelToKick"); - kickNumberToBan = config->readConfigInt("KickNumberToBan"); + // global settings + warnLevelToKick = config->readConfigInt("WarnLevelToKick"); + kickNumberToBan = config->readConfigInt("KickNumberToBan"); - // special check settings - //Bad Words - std::list badWordsList = config->readConfigStringList("BadWordsList"); - std::list::iterator it1; - QStringList bwList; + // special check settings + //Bad Words + std::list badWordsList = config->readConfigStringList("BadWordsList"); + std::list::iterator it1; + QStringList bwList; for(it1= badWordsList.begin(); it1 != badWordsList.end(); ++it1) { - bwList << QString::fromUtf8(it1->c_str()); - } - myBadWordCheck->setBadWords(bwList); + bwList << QString::fromUtf8(it1->c_str()); + } + myBadWordCheck->setBadWords(bwList); - std::list urlStringsList = config->readConfigStringList("UrlStringsList"); - std::list::iterator it2; - QStringList urlList; + std::list urlStringsList = config->readConfigStringList("UrlStringsList"); + std::list::iterator it2; + QStringList urlList; for(it2= urlStringsList.begin(); it2 != urlStringsList.end(); ++it2) { - urlList << QString::fromUtf8(it2->c_str()); - } - myUrlCheck->setUrlStrings(urlList); + urlList << QString::fromUtf8(it2->c_str()); + } + myUrlCheck->setUrlStrings(urlList); - std::list urlExceptionStringsList = config->readConfigStringList("UrlExceptionStringsList"); - std::list::iterator it3; - QStringList urlExceptionList; + std::list urlExceptionStringsList = config->readConfigStringList("UrlExceptionStringsList"); + std::list::iterator it3; + QStringList urlExceptionList; for(it3= urlExceptionStringsList.begin(); it3 != urlExceptionStringsList.end(); ++it3) { - urlExceptionList << QString::fromUtf8(it3->c_str()); - } - myUrlCheck->setUrlExceptionStrings(urlExceptionList); + urlExceptionList << QString::fromUtf8(it3->c_str()); + } + myUrlCheck->setUrlExceptionStrings(urlExceptionList); - myTextFloodCheck->setTextFloodLevelToTrigger(config->readConfigInt("TextFloodLevelToTrigger")); - myCapsFloodCheck->setCapsNumberToTrigger(config->readConfigInt("CapsFloodCapsNumberToTrigger")); - myLetterRepeatingCheck->setLetterNumberToTrigger(config->readConfigInt("LetterRepeatingNumberToTrigger")); + myTextFloodCheck->setTextFloodLevelToTrigger(config->readConfigInt("TextFloodLevelToTrigger")); + myCapsFloodCheck->setCapsNumberToTrigger(config->readConfigInt("CapsFloodCapsNumberToTrigger")); + myLetterRepeatingCheck->setLetterNumberToTrigger(config->readConfigInt("LetterRepeatingNumberToTrigger")); } void MessageFilter::cleanKickCounterList() { - QMapIterator it(myClientKickCounterList); - while (it.hasNext()) { - it.next(); - if(timer.elapsed().total_seconds()-it.value().lastKickTimestamp > static_cast(config->readConfigInt("SecondsToForgetAboutKick"))) { + QMapIterator it(myClientKickCounterList); + while (it.hasNext()) { + it.next(); + if(timer.elapsed().total_seconds()-it.value().lastKickTimestamp > static_cast(config->readConfigInt("SecondsToForgetAboutKick"))) { // qDebug() << it.key() << "removed from kick counter list" << endl; - myClientKickCounterList.remove(it.key()); - } - } + myClientKickCounterList.remove(it.key()); + } + } } diff --git a/src/chatcleaner/messagefilter.h b/src/chatcleaner/messagefilter.h index c220d6f0..7f4e3af1 100644 --- a/src/chatcleaner/messagefilter.h +++ b/src/chatcleaner/messagefilter.h @@ -12,46 +12,47 @@ class CapsFloodCheck; class LetterRepeatingCheck; class UrlCheck; -class MessageFilter: public QObject { - Q_OBJECT +class MessageFilter: public QObject +{ + Q_OBJECT public: - MessageFilter(CleanerConfig*); - ~MessageFilter(); + MessageFilter(CleanerConfig*); + ~MessageFilter(); - QStringList check(unsigned, QString, QString); - void refreshConfig(); + QStringList check(unsigned, QString, QString); + void refreshConfig(); public slots: - void cleanKickCounterList(); + void cleanKickCounterList(); -private: - BadWordCheck *myBadWordCheck; - TextFloodCheck *myTextFloodCheck; - CapsFloodCheck *myCapsFloodCheck; - LetterRepeatingCheck *myLetterRepeatingCheck; - UrlCheck *myUrlCheck; +private: + BadWordCheck *myBadWordCheck; + TextFloodCheck *myTextFloodCheck; + CapsFloodCheck *myCapsFloodCheck; + LetterRepeatingCheck *myLetterRepeatingCheck; + UrlCheck *myUrlCheck; - struct ClientWarnInfos { - QString nick; - int lastWarnType; - int warnLevel; - }; + struct ClientWarnInfos { + QString nick; + int lastWarnType; + int warnLevel; + }; - struct ClientKickInfos { - size_t lastKickTimestamp; - int kickNumber; - }; + struct ClientKickInfos { + size_t lastKickTimestamp; + int kickNumber; + }; - QMap myClientWarnLevelList; - QMap myClientKickCounterList; + QMap myClientWarnLevelList; + QMap myClientKickCounterList; - int warnLevelToKick; - int kickNumberToBan; + int warnLevelToKick; + int kickNumberToBan; - CleanerConfig *config; + CleanerConfig *config; - boost::timers::portable::second_timer timer; - QTimer *cleanTimer; + boost::timers::portable::second_timer timer; + QTimer *cleanTimer; }; #endif // MESSAGEFILTER_H diff --git a/src/chatcleaner/textfloodcheck.cpp b/src/chatcleaner/textfloodcheck.cpp index 44968f32..3094b425 100644 --- a/src/chatcleaner/textfloodcheck.cpp +++ b/src/chatcleaner/textfloodcheck.cpp @@ -5,13 +5,13 @@ TextFloodCheck::TextFloodCheck() { timer.reset(); timer.start(); - + cleanTimer = new QTimer(); - + connect(cleanTimer, SIGNAL(timeout()), this, SLOT(cleanMsgTimesList())); cleanTimer->start(4000); - + } TextFloodCheck::~TextFloodCheck() @@ -19,24 +19,24 @@ TextFloodCheck::~TextFloodCheck() delete cleanTimer; } -bool TextFloodCheck::run(unsigned playerId) { - +bool TextFloodCheck::run(unsigned playerId) +{ + QMapIterator it(msgTimesList); while (it.hasNext()) { - it.next(); + it.next(); // qDebug() << "counter: " << msgTimesList.count() << " playerid: " << it.key() << " floodlevel: " << it.value().floodLevel << " timestamp: " << it.value().timeStamp; } - + QMap::const_iterator i = msgTimesList.find(playerId); - + if(i == msgTimesList.end()) { TextFloodInfos tmpInfos1; tmpInfos1.floodLevel = 0; tmpInfos1.timeStamp = timer.elapsed().total_seconds(); msgTimesList.insert(playerId, tmpInfos1); qDebug () << "Add Player: set player floodlevel to " << tmpInfos1.floodLevel; - } - else { + } else { TextFloodInfos tmpInfos2; if(timer.elapsed().total_seconds()-i.value().timeStamp <= 1) { if(i.value().floodLevel == textFloodLevelToTrigger) { @@ -46,35 +46,33 @@ bool TextFloodCheck::run(unsigned playerId) { qDebug () << "Trigger: set player floodlevel to " << tmpInfos3.floodLevel; msgTimesList.insert(playerId, tmpInfos3); return true; - } - else { + } else { tmpInfos2.floodLevel = i.value().floodLevel+1; qDebug () << "Raise: set player floodlevel to " << tmpInfos2.floodLevel << " from " << i.value().floodLevel; - } - } - else { - tmpInfos2.floodLevel = i.value().floodLevel; + } + } else { + tmpInfos2.floodLevel = i.value().floodLevel; qDebug () << "Keep: player floodlevel is " << tmpInfos2.floodLevel << " from " << i.value().floodLevel; } - + tmpInfos2.timeStamp = timer.elapsed().total_seconds(); msgTimesList.insert(playerId, tmpInfos2); } return false; } -void TextFloodCheck::cleanMsgTimesList() { +void TextFloodCheck::cleanMsgTimesList() +{ QMapIterator it(msgTimesList); while (it.hasNext()) { - it.next(); - if(timer.elapsed().total_seconds()-it.value().timeStamp > 3) { - + it.next(); + if(timer.elapsed().total_seconds()-it.value().timeStamp > 3) { + if(it.value().floodLevel == 0) { msgTimesList.remove(it.key()); qDebug () << "Refresh: player removed from List"; - } - else { + } else { TextFloodInfos tmpInfos; tmpInfos.floodLevel = it.value().floodLevel-1; tmpInfos.timeStamp = it.value().timeStamp; @@ -86,8 +84,9 @@ void TextFloodCheck::cleanMsgTimesList() { } } -void TextFloodCheck::removeNickFromList(unsigned playerId) { - +void TextFloodCheck::removeNickFromList(unsigned playerId) +{ + // qDebug() << "id " << playerId << "removed from textfloodcheck list" << endl; msgTimesList.remove(playerId); } diff --git a/src/chatcleaner/textfloodcheck.h b/src/chatcleaner/textfloodcheck.h index 8e61cbba..38d3e7c4 100644 --- a/src/chatcleaner/textfloodcheck.h +++ b/src/chatcleaner/textfloodcheck.h @@ -10,18 +10,20 @@ class TextFloodCheck: public QObject { Q_OBJECT public: - TextFloodCheck(); + TextFloodCheck(); ~TextFloodCheck(); - - void setTextFloodLevelToTrigger(int level) { textFloodLevelToTrigger = level; } - + + void setTextFloodLevelToTrigger(int level) { + textFloodLevelToTrigger = level; + } + bool run(unsigned); - + public slots: void cleanMsgTimesList(); void removeNickFromList(unsigned); - -private: + +private: QTimer *cleanTimer; boost::timers::portable::second_timer timer; struct TextFloodInfos { @@ -29,7 +31,7 @@ private: size_t timeStamp; }; QMap msgTimesList; - + int textFloodLevelToTrigger; }; diff --git a/src/chatcleaner/urlcheck.cpp b/src/chatcleaner/urlcheck.cpp index 5021c56f..735a119d 100644 --- a/src/chatcleaner/urlcheck.cpp +++ b/src/chatcleaner/urlcheck.cpp @@ -6,23 +6,25 @@ UrlCheck::UrlCheck() { } -bool UrlCheck::run(QString msg) +bool UrlCheck::run(QString msg) { msg = msg.toLower(); - + QStringListIterator it1(urlStrings); - + while (it1.hasNext()) { if(msg.contains(it1.next())) { QStringListIterator it2(urlExceptionStrings); bool exception = false; while (it2.hasNext()) { - if(msg.contains(it2.next())) { - exception = true; + if(msg.contains(it2.next())) { + exception = true; break; } } - if(!exception) { return true; } + if(!exception) { + return true; + } } } return false; diff --git a/src/chatcleaner/urlcheck.h b/src/chatcleaner/urlcheck.h index 10ec2ccc..40060e39 100644 --- a/src/chatcleaner/urlcheck.h +++ b/src/chatcleaner/urlcheck.h @@ -3,15 +3,20 @@ #include -class UrlCheck: public QObject { -Q_OBJECT +class UrlCheck: public QObject +{ + Q_OBJECT public: - UrlCheck(); - - void setUrlStrings(QStringList us) { urlStrings = us; } - void setUrlExceptionStrings(QStringList ues) { urlExceptionStrings = ues; } + UrlCheck(); + + void setUrlStrings(QStringList us) { + urlStrings = us; + } + void setUrlExceptionStrings(QStringList ues) { + urlExceptionStrings = ues; + } bool run(QString); - + private: QStringList urlStrings; diff --git a/src/config/configfile.cpp b/src/config/configfile.cpp index 2d682d5f..3fb32316 100644 --- a/src/config/configfile.cpp +++ b/src/config/configfile.cpp @@ -43,244 +43,242 @@ using namespace std; ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly) { - myArgv0 = argv0; + myArgv0 = argv0; - myQtToolsInterface = CreateQtToolsWrapper(); + myQtToolsInterface = CreateQtToolsWrapper(); - myConfigState = OK; + myConfigState = OK; - // !!!! Revisionsnummer der Configdefaults !!!!! + // !!!! Revisionsnummer der Configdefaults !!!!! configRev = 92; - //standard defaults - logOnOffDefault = "1"; + //standard defaults + logOnOffDefault = "1"; - // Pfad und Dateinamen setzen + // Pfad und Dateinamen setzen #ifdef _WIN32 - const char *appDataPath = getenv("AppData"); - if (appDataPath && appDataPath[0] != 0) { - configFileName = appDataPath; - } - else { - const int MaxPathSize = 1024; - char curDir[MaxPathSize + 1]; - curDir[0] = 0; - _getcwd(curDir, MaxPathSize); - curDir[MaxPathSize] = 0; - configFileName = curDir; - // Testen ob das Verzeichnis beschreibbar ist - ofstream tmpFile; - const char *tmpFileName = "pokerth_test.tmp"; - tmpFile.open((configFileName + "\\" + tmpFileName).c_str()); - if (tmpFile) { - // Erfolgreich, Verzeichnis beschreibbar. - // Datei wieder loeschen. - tmpFile.close(); - remove((configFileName + "\\" + tmpFileName).c_str()); - } - else { - // Fehlgeschlagen, Verzeichnis nicht beschreibbar - curDir[0] = 0; - GetTempPathA(MaxPathSize, curDir); - curDir[MaxPathSize] = 0; - configFileName = curDir; - } - } - //define app-dir - configFileName += "\\pokerth\\"; - ////define log-dir - logDir = configFileName; - logDir += "log-files\\"; - ////define data-dir - dataDir = configFileName; - dataDir += "data\\"; - ////define cache-dir - cacheDir = configFileName; - cacheDir += "cache\\"; + const char *appDataPath = getenv("AppData"); + if (appDataPath && appDataPath[0] != 0) { + configFileName = appDataPath; + } else { + const int MaxPathSize = 1024; + char curDir[MaxPathSize + 1]; + curDir[0] = 0; + _getcwd(curDir, MaxPathSize); + curDir[MaxPathSize] = 0; + configFileName = curDir; + // Testen ob das Verzeichnis beschreibbar ist + ofstream tmpFile; + const char *tmpFileName = "pokerth_test.tmp"; + tmpFile.open((configFileName + "\\" + tmpFileName).c_str()); + if (tmpFile) { + // Erfolgreich, Verzeichnis beschreibbar. + // Datei wieder loeschen. + tmpFile.close(); + remove((configFileName + "\\" + tmpFileName).c_str()); + } else { + // Fehlgeschlagen, Verzeichnis nicht beschreibbar + curDir[0] = 0; + GetTempPathA(MaxPathSize, curDir); + curDir[MaxPathSize] = 0; + configFileName = curDir; + } + } + //define app-dir + configFileName += "\\pokerth\\"; + ////define log-dir + logDir = configFileName; + logDir += "log-files\\"; + ////define data-dir + dataDir = configFileName; + dataDir += "data\\"; + ////define cache-dir + cacheDir = configFileName; + cacheDir += "cache\\"; - //create directories on first start of app - mkdir(configFileName.c_str()); - mkdir(logDir.c_str()); - mkdir(dataDir.c_str()); - mkdir(cacheDir.c_str()); + //create directories on first start of app + mkdir(configFileName.c_str()); + mkdir(logDir.c_str()); + mkdir(dataDir.c_str()); + mkdir(cacheDir.c_str()); #else - //define app-dir - const char *homePath = getenv("HOME"); - if(homePath) { - configFileName = homePath; - configFileName += "/.pokerth/"; - ////define log-dir - logDir = configFileName; - logDir += "log-files/"; - ////define data-dir - dataDir = configFileName; - dataDir += "data/"; - ////define cache-dir - cacheDir = configFileName; - cacheDir += "cache/"; - //create directories on first start of app - mkdir(configFileName.c_str(), MODUS) ; - mkdir(logDir.c_str(), MODUS); - mkdir(dataDir.c_str(), MODUS); - mkdir(cacheDir.c_str(), MODUS); - } + //define app-dir + const char *homePath = getenv("HOME"); + if(homePath) { + configFileName = homePath; + configFileName += "/.pokerth/"; + ////define log-dir + logDir = configFileName; + logDir += "log-files/"; + ////define data-dir + dataDir = configFileName; + dataDir += "data/"; + ////define cache-dir + cacheDir = configFileName; + cacheDir += "cache/"; + //create directories on first start of app + mkdir(configFileName.c_str(), MODUS) ; + mkdir(logDir.c_str(), MODUS); + mkdir(dataDir.c_str(), MODUS); + mkdir(cacheDir.c_str(), MODUS); + } #endif - ostringstream tempIntToString; - tempIntToString << configRev; - configList.push_back(ConfigInfo("ConfigRevision", CONFIG_TYPE_INT, tempIntToString.str())); - configList.push_back(ConfigInfo("AppDataDir", CONFIG_TYPE_STRING, myQtToolsInterface->getDataPathStdString(myArgv0))); - configList.push_back(ConfigInfo("Language", CONFIG_TYPE_INT, myQtToolsInterface->getDefaultLanguage())); - /*configList.push_back(ConfigInfo("InternetServerAddressIRCChannelUpdateDone", CONFIG_TYPE_INT, "1"));*/ //HACK - configList.push_back(ConfigInfo("ShowLeftToolBox", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("ShowCountryFlagInAvatar", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("ShowRightToolBox", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("ShowFadeOutCardsAnimation", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("ShowFlipCardsAnimation", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("ShowBlindButtons", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("ShowCardsChanceMonitor", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("DontTranslateInternationalPokerStringsFromStyle", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("DisableSplashScreenOnStartup", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("AntiPeekMode", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("AlternateFKeysUserActionMode", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("EnableBetInputFocusSwitch", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("FlipsideTux", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("FlipsideOwn", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("FlipsideOwnFile", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("GameTableStylesList", CONFIG_TYPE_STRING_LIST, "GameTableStyles")); - configList.push_back(ConfigInfo("CurrentGameTableStyle", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("CardDeckStylesList", CONFIG_TYPE_STRING_LIST, "CardDeckStyles")); - configList.push_back(ConfigInfo("PlayerTooltips", CONFIG_TYPE_STRING_LIST, "PlayerTooltips")); - configList.push_back(ConfigInfo("CurrentCardDeckStyle", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("LastGameTableStyleDir", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("LastCardDeckStyleDir", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("PlaySoundEffects", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("SoundVolume", CONFIG_TYPE_INT, "8")); - configList.push_back(ConfigInfo("PlayGameActions", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("PlayLobbyChatNotification", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("PlayNetworkGameNotification", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("NumberOfPlayers", CONFIG_TYPE_INT, "10")); - configList.push_back(ConfigInfo("StartCash", CONFIG_TYPE_INT, "5000")); - configList.push_back(ConfigInfo("FirstSmallBlind", CONFIG_TYPE_INT, "10")); - configList.push_back(ConfigInfo("RaiseBlindsAtHands", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("RaiseBlindsAtMinutes", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("RaiseSmallBlindEveryHands", CONFIG_TYPE_INT, "8")); - configList.push_back(ConfigInfo("RaiseSmallBlindEveryMinutes", CONFIG_TYPE_INT, "5")); - configList.push_back(ConfigInfo("AlwaysDoubleBlinds", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("ManualBlindsOrder", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("ManualBlindsList", CONFIG_TYPE_INT_LIST, "Blind")); - configList.push_back(ConfigInfo("AfterMBAlwaysDoubleBlinds", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("AfterMBAlwaysRaiseAbout", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("AfterMBAlwaysRaiseValue", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("AfterMBStayAtLastBlind", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("GameSpeed", CONFIG_TYPE_INT, "4")); - configList.push_back(ConfigInfo("PauseBetweenHands", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("ShowGameSettingsDialogOnNewGame", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("NetNumberOfPlayers", CONFIG_TYPE_INT, "10")); - configList.push_back(ConfigInfo("NetStartCash", CONFIG_TYPE_INT, "3000")); - configList.push_back(ConfigInfo("NetFirstSmallBlind", CONFIG_TYPE_INT, "10")); - configList.push_back(ConfigInfo("NetRaiseBlindsAtHands", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("NetRaiseBlindsAtMinutes", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("NetRaiseSmallBlindEveryHands", CONFIG_TYPE_INT, "8")); - configList.push_back(ConfigInfo("NetRaiseSmallBlindEveryMinutes", CONFIG_TYPE_INT, "5")); - configList.push_back(ConfigInfo("NetAlwaysDoubleBlinds", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("NetManualBlindsOrder", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("NetManualBlindsList", CONFIG_TYPE_INT_LIST, "NetBlind")); - configList.push_back(ConfigInfo("NetAfterMBAlwaysDoubleBlinds", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("NetAfterMBAlwaysRaiseAbout", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("NetAfterMBAlwaysRaiseValue", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("NetAfterMBStayAtLastBlind", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("NetGameSpeed", CONFIG_TYPE_INT, "4")); - configList.push_back(ConfigInfo("NetDelayBetweenHands", CONFIG_TYPE_INT, "7")); - configList.push_back(ConfigInfo("NetTimeOutPlayerAction", CONFIG_TYPE_INT, "20")); + ostringstream tempIntToString; + tempIntToString << configRev; + configList.push_back(ConfigInfo("ConfigRevision", CONFIG_TYPE_INT, tempIntToString.str())); + configList.push_back(ConfigInfo("AppDataDir", CONFIG_TYPE_STRING, myQtToolsInterface->getDataPathStdString(myArgv0))); + configList.push_back(ConfigInfo("Language", CONFIG_TYPE_INT, myQtToolsInterface->getDefaultLanguage())); + /*configList.push_back(ConfigInfo("InternetServerAddressIRCChannelUpdateDone", CONFIG_TYPE_INT, "1"));*/ //HACK + configList.push_back(ConfigInfo("ShowLeftToolBox", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("ShowCountryFlagInAvatar", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("ShowRightToolBox", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("ShowFadeOutCardsAnimation", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("ShowFlipCardsAnimation", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("ShowBlindButtons", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("ShowCardsChanceMonitor", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("DontTranslateInternationalPokerStringsFromStyle", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("DisableSplashScreenOnStartup", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("AntiPeekMode", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("AlternateFKeysUserActionMode", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("EnableBetInputFocusSwitch", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("FlipsideTux", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("FlipsideOwn", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("FlipsideOwnFile", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("GameTableStylesList", CONFIG_TYPE_STRING_LIST, "GameTableStyles")); + configList.push_back(ConfigInfo("CurrentGameTableStyle", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("CardDeckStylesList", CONFIG_TYPE_STRING_LIST, "CardDeckStyles")); + configList.push_back(ConfigInfo("PlayerTooltips", CONFIG_TYPE_STRING_LIST, "PlayerTooltips")); + configList.push_back(ConfigInfo("CurrentCardDeckStyle", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("LastGameTableStyleDir", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("LastCardDeckStyleDir", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("PlaySoundEffects", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("SoundVolume", CONFIG_TYPE_INT, "8")); + configList.push_back(ConfigInfo("PlayGameActions", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("PlayLobbyChatNotification", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("PlayNetworkGameNotification", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("NumberOfPlayers", CONFIG_TYPE_INT, "10")); + configList.push_back(ConfigInfo("StartCash", CONFIG_TYPE_INT, "5000")); + configList.push_back(ConfigInfo("FirstSmallBlind", CONFIG_TYPE_INT, "10")); + configList.push_back(ConfigInfo("RaiseBlindsAtHands", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("RaiseBlindsAtMinutes", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("RaiseSmallBlindEveryHands", CONFIG_TYPE_INT, "8")); + configList.push_back(ConfigInfo("RaiseSmallBlindEveryMinutes", CONFIG_TYPE_INT, "5")); + configList.push_back(ConfigInfo("AlwaysDoubleBlinds", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("ManualBlindsOrder", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("ManualBlindsList", CONFIG_TYPE_INT_LIST, "Blind")); + configList.push_back(ConfigInfo("AfterMBAlwaysDoubleBlinds", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("AfterMBAlwaysRaiseAbout", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("AfterMBAlwaysRaiseValue", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("AfterMBStayAtLastBlind", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("GameSpeed", CONFIG_TYPE_INT, "4")); + configList.push_back(ConfigInfo("PauseBetweenHands", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("ShowGameSettingsDialogOnNewGame", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("NetNumberOfPlayers", CONFIG_TYPE_INT, "10")); + configList.push_back(ConfigInfo("NetStartCash", CONFIG_TYPE_INT, "3000")); + configList.push_back(ConfigInfo("NetFirstSmallBlind", CONFIG_TYPE_INT, "10")); + configList.push_back(ConfigInfo("NetRaiseBlindsAtHands", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("NetRaiseBlindsAtMinutes", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("NetRaiseSmallBlindEveryHands", CONFIG_TYPE_INT, "8")); + configList.push_back(ConfigInfo("NetRaiseSmallBlindEveryMinutes", CONFIG_TYPE_INT, "5")); + configList.push_back(ConfigInfo("NetAlwaysDoubleBlinds", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("NetManualBlindsOrder", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("NetManualBlindsList", CONFIG_TYPE_INT_LIST, "NetBlind")); + configList.push_back(ConfigInfo("NetAfterMBAlwaysDoubleBlinds", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("NetAfterMBAlwaysRaiseAbout", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("NetAfterMBAlwaysRaiseValue", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("NetAfterMBStayAtLastBlind", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("NetGameSpeed", CONFIG_TYPE_INT, "4")); + configList.push_back(ConfigInfo("NetDelayBetweenHands", CONFIG_TYPE_INT, "7")); + configList.push_back(ConfigInfo("NetTimeOutPlayerAction", CONFIG_TYPE_INT, "20")); configList.push_back(ConfigInfo("NetAutoLeaveGameAfterFinish", CONFIG_TYPE_INT, "0")); configList.push_back(ConfigInfo("ServerPassword", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("ServerUseIpv6", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("ServerUseSctp", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("ServerPort", CONFIG_TYPE_INT, "7234")); - configList.push_back(ConfigInfo("ServerUsePutAvatars", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("ServerPutAvatarsAddress", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("ServerPutAvatarsUser", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("ServerPutAvatarsPassword", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("ServerUseIpv6", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("ServerUseSctp", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("ServerPort", CONFIG_TYPE_INT, "7234")); + configList.push_back(ConfigInfo("ServerUsePutAvatars", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("ServerPutAvatarsAddress", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("ServerPutAvatarsUser", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("ServerPutAvatarsPassword", CONFIG_TYPE_STRING, "")); configList.push_back(ConfigInfo("ServerDoNotAutoKickSmallDelaySec", CONFIG_TYPE_STRING, "10")); configList.push_back(ConfigInfo("ServerBruteForceProtection", CONFIG_TYPE_INT, "1")); configList.push_back(ConfigInfo("InternetServerConfigMode", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("InternetServerListAddress", CONFIG_TYPE_STRING, "pokerth.net/serverlist.xml.z")); - configList.push_back(ConfigInfo("InternetServerAddress", CONFIG_TYPE_STRING, "pokerth.6dns.org")); - configList.push_back(ConfigInfo("InternetServerPort", CONFIG_TYPE_INT, "7234")); - configList.push_back(ConfigInfo("InternetServerPassword", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("InternetServerUseIpv6", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("InternetServerUseSctp", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("UseAvatarServer", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("AvatarServerAddress", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("UseInternetGamePassword", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("InternetGamePassword", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("InternetGameType", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("InternetGameName", CONFIG_TYPE_STRING, "My Online Game")); - configList.push_back(ConfigInfo("UseLobbyChat", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("UseAdminIRC", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("AdminIRCServerAddress", CONFIG_TYPE_STRING, "chat.freenode.net")); - configList.push_back(ConfigInfo("AdminIRCServerPort", CONFIG_TYPE_INT, "6667")); - configList.push_back(ConfigInfo("AdminIRCChannel", CONFIG_TYPE_STRING, "#test")); - configList.push_back(ConfigInfo("AdminIRCChannelPassword", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("AdminIRCServerUseIpv6", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("AdminIRCServerNick", CONFIG_TYPE_INT, "PokerTH_Admin")); - configList.push_back(ConfigInfo("UseLobbyIRC", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("LobbyIRCServerAddress", CONFIG_TYPE_STRING, "chat.freenode.net")); - configList.push_back(ConfigInfo("LobbyIRCServerPort", CONFIG_TYPE_INT, "6667")); - configList.push_back(ConfigInfo("LobbyIRCChannel", CONFIG_TYPE_STRING, "#pokerth-lobby")); - configList.push_back(ConfigInfo("LobbyIRCChannelPassword", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("LobbyIRCServerUseIpv6", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("LobbyIRCServerNick", CONFIG_TYPE_INT, "PokerTH_Lobby")); - configList.push_back(ConfigInfo("UseChatCleaner", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("ChatCleanerHostAddress", CONFIG_TYPE_STRING, "localhost")); - configList.push_back(ConfigInfo("ChatCleanerPort", CONFIG_TYPE_INT, "4327")); - configList.push_back(ConfigInfo("ChatCleanerClientAuth", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("ChatCleanerServerAuth", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("ChatCleanerUseIpv6", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("MyName", CONFIG_TYPE_STRING, "Human Player")); - configList.push_back(ConfigInfo("MyAvatar", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("MyRememberedNameDuringGuestLogin", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("Opponent1Name", CONFIG_TYPE_STRING, "Player 1")); - configList.push_back(ConfigInfo("Opponent1Avatar", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("Opponent2Name", CONFIG_TYPE_STRING, "Player 2")); - configList.push_back(ConfigInfo("Opponent2Avatar", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("Opponent3Name", CONFIG_TYPE_STRING, "Player 3")); - configList.push_back(ConfigInfo("Opponent3Avatar", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("Opponent4Name", CONFIG_TYPE_STRING, "Player 4")); - configList.push_back(ConfigInfo("Opponent4Avatar", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("Opponent5Name", CONFIG_TYPE_STRING, "Player 5")); - configList.push_back(ConfigInfo("Opponent5Avatar", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("Opponent6Name", CONFIG_TYPE_STRING, "Player 6")); - configList.push_back(ConfigInfo("Opponent6Avatar", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("Opponent7Name", CONFIG_TYPE_STRING, "Player 7")); - configList.push_back(ConfigInfo("Opponent7Avatar", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("Opponent8Name", CONFIG_TYPE_STRING, "Player 8")); - configList.push_back(ConfigInfo("Opponent8Avatar", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("Opponent9Name", CONFIG_TYPE_STRING, "Player 9")); - configList.push_back(ConfigInfo("Opponent9Avatar", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("LogOnOff", CONFIG_TYPE_INT, logOnOffDefault)); - configList.push_back(ConfigInfo("LogDir", CONFIG_TYPE_STRING, logDir)); - configList.push_back(ConfigInfo("LogStoreDuration", CONFIG_TYPE_INT, "2")); - configList.push_back(ConfigInfo("LogInterval", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("UserDataDir", CONFIG_TYPE_STRING, dataDir)); - configList.push_back(ConfigInfo("CacheDir", CONFIG_TYPE_STRING, cacheDir)); - configList.push_back(ConfigInfo("CLA_NoWriteAccess", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("DisableBackToLobbyWarning", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("DlgGameLobbyGameListSortingSection", CONFIG_TYPE_INT, "2")); - configList.push_back(ConfigInfo("DlgGameLobbyGameListSortingOrder", CONFIG_TYPE_INT, "1")); - configList.push_back(ConfigInfo("DlgGameLobbyGameListFilterIndex", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("DlgGameLobbyNickListSortFilterIndex", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("GameTableFullScreenSave", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("GameTableHeightSave", CONFIG_TYPE_INT, "600")); - configList.push_back(ConfigInfo("GameTableWidthSave", CONFIG_TYPE_INT, "1024")); - configList.push_back(ConfigInfo("InternetLoginMode", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("InternetLoginPassword", CONFIG_TYPE_STRING, "")); - configList.push_back(ConfigInfo("InternetSavePassword", CONFIG_TYPE_INT, "0")); - configList.push_back(ConfigInfo("IfInfoMessageShowList", CONFIG_TYPE_STRING_LIST, "Msg")); - configList.push_back(ConfigInfo("PlayerIgnoreList", CONFIG_TYPE_STRING_LIST, "Player")); + configList.push_back(ConfigInfo("InternetServerListAddress", CONFIG_TYPE_STRING, "pokerth.net/serverlist.xml.z")); + configList.push_back(ConfigInfo("InternetServerAddress", CONFIG_TYPE_STRING, "pokerth.6dns.org")); + configList.push_back(ConfigInfo("InternetServerPort", CONFIG_TYPE_INT, "7234")); + configList.push_back(ConfigInfo("InternetServerPassword", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("InternetServerUseIpv6", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("InternetServerUseSctp", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("UseAvatarServer", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("AvatarServerAddress", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("UseInternetGamePassword", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("InternetGamePassword", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("InternetGameType", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("InternetGameName", CONFIG_TYPE_STRING, "My Online Game")); + configList.push_back(ConfigInfo("UseLobbyChat", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("UseAdminIRC", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("AdminIRCServerAddress", CONFIG_TYPE_STRING, "chat.freenode.net")); + configList.push_back(ConfigInfo("AdminIRCServerPort", CONFIG_TYPE_INT, "6667")); + configList.push_back(ConfigInfo("AdminIRCChannel", CONFIG_TYPE_STRING, "#test")); + configList.push_back(ConfigInfo("AdminIRCChannelPassword", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("AdminIRCServerUseIpv6", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("AdminIRCServerNick", CONFIG_TYPE_INT, "PokerTH_Admin")); + configList.push_back(ConfigInfo("UseLobbyIRC", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("LobbyIRCServerAddress", CONFIG_TYPE_STRING, "chat.freenode.net")); + configList.push_back(ConfigInfo("LobbyIRCServerPort", CONFIG_TYPE_INT, "6667")); + configList.push_back(ConfigInfo("LobbyIRCChannel", CONFIG_TYPE_STRING, "#pokerth-lobby")); + configList.push_back(ConfigInfo("LobbyIRCChannelPassword", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("LobbyIRCServerUseIpv6", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("LobbyIRCServerNick", CONFIG_TYPE_INT, "PokerTH_Lobby")); + configList.push_back(ConfigInfo("UseChatCleaner", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("ChatCleanerHostAddress", CONFIG_TYPE_STRING, "localhost")); + configList.push_back(ConfigInfo("ChatCleanerPort", CONFIG_TYPE_INT, "4327")); + configList.push_back(ConfigInfo("ChatCleanerClientAuth", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("ChatCleanerServerAuth", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("ChatCleanerUseIpv6", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("MyName", CONFIG_TYPE_STRING, "Human Player")); + configList.push_back(ConfigInfo("MyAvatar", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("MyRememberedNameDuringGuestLogin", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("Opponent1Name", CONFIG_TYPE_STRING, "Player 1")); + configList.push_back(ConfigInfo("Opponent1Avatar", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("Opponent2Name", CONFIG_TYPE_STRING, "Player 2")); + configList.push_back(ConfigInfo("Opponent2Avatar", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("Opponent3Name", CONFIG_TYPE_STRING, "Player 3")); + configList.push_back(ConfigInfo("Opponent3Avatar", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("Opponent4Name", CONFIG_TYPE_STRING, "Player 4")); + configList.push_back(ConfigInfo("Opponent4Avatar", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("Opponent5Name", CONFIG_TYPE_STRING, "Player 5")); + configList.push_back(ConfigInfo("Opponent5Avatar", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("Opponent6Name", CONFIG_TYPE_STRING, "Player 6")); + configList.push_back(ConfigInfo("Opponent6Avatar", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("Opponent7Name", CONFIG_TYPE_STRING, "Player 7")); + configList.push_back(ConfigInfo("Opponent7Avatar", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("Opponent8Name", CONFIG_TYPE_STRING, "Player 8")); + configList.push_back(ConfigInfo("Opponent8Avatar", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("Opponent9Name", CONFIG_TYPE_STRING, "Player 9")); + configList.push_back(ConfigInfo("Opponent9Avatar", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("LogOnOff", CONFIG_TYPE_INT, logOnOffDefault)); + configList.push_back(ConfigInfo("LogDir", CONFIG_TYPE_STRING, logDir)); + configList.push_back(ConfigInfo("LogStoreDuration", CONFIG_TYPE_INT, "2")); + configList.push_back(ConfigInfo("LogInterval", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("UserDataDir", CONFIG_TYPE_STRING, dataDir)); + configList.push_back(ConfigInfo("CacheDir", CONFIG_TYPE_STRING, cacheDir)); + configList.push_back(ConfigInfo("CLA_NoWriteAccess", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("DisableBackToLobbyWarning", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("DlgGameLobbyGameListSortingSection", CONFIG_TYPE_INT, "2")); + configList.push_back(ConfigInfo("DlgGameLobbyGameListSortingOrder", CONFIG_TYPE_INT, "1")); + configList.push_back(ConfigInfo("DlgGameLobbyGameListFilterIndex", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("DlgGameLobbyNickListSortFilterIndex", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("GameTableFullScreenSave", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("GameTableHeightSave", CONFIG_TYPE_INT, "600")); + configList.push_back(ConfigInfo("GameTableWidthSave", CONFIG_TYPE_INT, "1024")); + configList.push_back(ConfigInfo("InternetLoginMode", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("InternetLoginPassword", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("InternetSavePassword", CONFIG_TYPE_INT, "0")); + configList.push_back(ConfigInfo("IfInfoMessageShowList", CONFIG_TYPE_STRING_LIST, "Msg")); + configList.push_back(ConfigInfo("PlayerIgnoreList", CONFIG_TYPE_STRING_LIST, "Player")); configList.push_back(ConfigInfo("DBServerAddress", CONFIG_TYPE_STRING, "127.0.0.1")); configList.push_back(ConfigInfo("DBServerUser", CONFIG_TYPE_STRING, "pokerth")); configList.push_back(ConfigInfo("DBServerPassword", CONFIG_TYPE_STRING, "")); @@ -288,450 +286,459 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly) configList.push_back(ConfigInfo("DBServerEncryptionKey", CONFIG_TYPE_STRING, "")); configList.push_back(ConfigInfo("GameNameBadWordList", CONFIG_TYPE_STRING_LIST, "Regex")); - //fill tempList firstTime - configBufferList = configList; + //fill tempList firstTime + configBufferList = configList; - // cout << configTempList[3].name << " " << configTempList[10].defaultValue << endl; + // cout << configTempList[3].name << " " << configTempList[10].defaultValue << endl; - if(!noWriteAccess) { - configFileName += "config.xml"; + if(!noWriteAccess) { + configFileName += "config.xml"; - //Prüfen ob Configfile existiert --> sonst anlegen - TiXmlDocument doc(configFileName); - if(!doc.LoadFile()){ - myConfigState = NONEXISTING; - updateConfig(myConfigState); - } - else { - //Check if config revision and AppDataDir is ok. Otherwise --> update() - int tempRevision = 0; - string tempAppDataPath (""); + //Prüfen ob Configfile existiert --> sonst anlegen + TiXmlDocument doc(configFileName); + if(!doc.LoadFile()) { + myConfigState = NONEXISTING; + updateConfig(myConfigState); + } else { + //Check if config revision and AppDataDir is ok. Otherwise --> update() + int tempRevision = 0; + string tempAppDataPath (""); - TiXmlHandle docHandle( &doc ); - TiXmlElement* confRevision = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( "ConfigRevision" ).ToElement(); - if ( confRevision ) { confRevision->QueryIntAttribute("value", &tempRevision ); } - TiXmlElement* confAppDataPath = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( "AppDataDir" ).ToElement(); - if ( confAppDataPath ) { - const char *tmpStr = confAppDataPath->Attribute("value"); - if (tmpStr) tempAppDataPath = tmpStr; - //if appdatapath changes directly update it here not in UpdateConfig() - if(tempAppDataPath != myQtToolsInterface->getDataPathStdString(myArgv0)) { - confAppDataPath->SetAttribute("value", myQtToolsInterface->stringToUtf8(myQtToolsInterface->getDataPathStdString(myArgv0))); - doc.SaveFile( configFileName ); - } - } - if (tempRevision < configRev) { - myConfigState = OLD; - updateConfig(myConfigState) ; - } - } + TiXmlHandle docHandle( &doc ); + TiXmlElement* confRevision = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( "ConfigRevision" ).ToElement(); + if ( confRevision ) { + confRevision->QueryIntAttribute("value", &tempRevision ); + } + TiXmlElement* confAppDataPath = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( "AppDataDir" ).ToElement(); + if ( confAppDataPath ) { + const char *tmpStr = confAppDataPath->Attribute("value"); + if (tmpStr) tempAppDataPath = tmpStr; + //if appdatapath changes directly update it here not in UpdateConfig() + if(tempAppDataPath != myQtToolsInterface->getDataPathStdString(myArgv0)) { + confAppDataPath->SetAttribute("value", myQtToolsInterface->stringToUtf8(myQtToolsInterface->getDataPathStdString(myArgv0))); + doc.SaveFile( configFileName ); + } + } + if (tempRevision < configRev) { + myConfigState = OLD; + updateConfig(myConfigState) ; + } + } - fillBuffer(); - } + fillBuffer(); + } } ConfigFile::~ConfigFile() { - delete myQtToolsInterface; - myQtToolsInterface = 0; + delete myQtToolsInterface; + myQtToolsInterface = 0; } -void ConfigFile::fillBuffer() { +void ConfigFile::fillBuffer() +{ - boost::recursive_mutex::scoped_lock lock(m_configMutex); + boost::recursive_mutex::scoped_lock lock(m_configMutex); string tempString1(""); - string tempString2(""); + string tempString2(""); - TiXmlDocument doc(configFileName); + TiXmlDocument doc(configFileName); - if(doc.LoadFile()) { - TiXmlHandle docHandle( &doc ); + if(doc.LoadFile()) { + TiXmlHandle docHandle( &doc ); for (size_t i=0; iAttribute("value"); - if (tmpStr1) tempString1 = tmpStr1; - configBufferList[i].defaultValue = tempString1; + const char *tmpStr1 = conf->Attribute("value"); + if (tmpStr1) tempString1 = tmpStr1; + configBufferList[i].defaultValue = tempString1; - const char *tmpStr2 = conf->Attribute("type"); - if (tmpStr2) { - tempString2 = tmpStr2; - if(tempString2 == "list") { + const char *tmpStr2 = conf->Attribute("type"); + if (tmpStr2) { + tempString2 = tmpStr2; + if(tempString2 == "list") { - list tempStringList2; + list tempStringList2; - TiXmlElement* confList = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( configList[i].name ).FirstChild().ToElement(); + TiXmlElement* confList = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( configList[i].name ).FirstChild().ToElement(); - for( ; confList; confList=confList->NextSiblingElement()) { - tempStringList2.push_back(confList->Attribute("value")); - } + for( ; confList; confList=confList->NextSiblingElement()) { + tempStringList2.push_back(confList->Attribute("value")); + } - configBufferList[i].defaultListValue = tempStringList2; - } - } + configBufferList[i].defaultListValue = tempStringList2; + } + } - } - else { LOG_ERROR("Could not find the root element in the config file!"); } + } else { + LOG_ERROR("Could not find the root element in the config file!"); + } - // cout << configBufferList[i].name << " " << configBufferList[i].defaultValue << endl; - } - } + // cout << configBufferList[i].name << " " << configBufferList[i].defaultValue << endl; + } + } } -void ConfigFile::writeBuffer() const { +void ConfigFile::writeBuffer() const +{ - boost::recursive_mutex::scoped_lock lock(m_configMutex); + boost::recursive_mutex::scoped_lock lock(m_configMutex); - //write buffer to disc if enabled - if(!noWriteAccess) { - TiXmlDocument doc; - TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", ""); - doc.LinkEndChild( decl ); + //write buffer to disc if enabled + if(!noWriteAccess) { + TiXmlDocument doc; + TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", ""); + doc.LinkEndChild( decl ); - TiXmlElement * root = new TiXmlElement( "PokerTH" ); - doc.LinkEndChild( root ); + TiXmlElement * root = new TiXmlElement( "PokerTH" ); + doc.LinkEndChild( root ); - TiXmlElement * config; - config = new TiXmlElement( "Configuration" ); - root->LinkEndChild( config ); + TiXmlElement * config; + config = new TiXmlElement( "Configuration" ); + root->LinkEndChild( config ); - size_t i; + size_t i; - for (i=0; iLinkEndChild( tmpElement ); - tmpElement->SetAttribute("value", configBufferList[i].defaultValue); + for (i=0; iLinkEndChild( tmpElement ); + tmpElement->SetAttribute("value", configBufferList[i].defaultValue); - if(configBufferList[i].type == CONFIG_TYPE_INT_LIST || configBufferList[i].type == CONFIG_TYPE_STRING_LIST) { + if(configBufferList[i].type == CONFIG_TYPE_INT_LIST || configBufferList[i].type == CONFIG_TYPE_STRING_LIST) { - tmpElement->SetAttribute("type", "list"); - list tempList = configBufferList[i].defaultListValue; - list::iterator it; + tmpElement->SetAttribute("type", "list"); + list tempList = configBufferList[i].defaultListValue; + list::iterator it; for(it = tempList.begin(); it != tempList.end(); ++it) { - TiXmlElement *tmpSubElement = new TiXmlElement(configBufferList[i].defaultValue); - tmpElement->LinkEndChild( tmpSubElement ); - tmpSubElement->SetAttribute("value", *it); - } + TiXmlElement *tmpSubElement = new TiXmlElement(configBufferList[i].defaultValue); + tmpElement->LinkEndChild( tmpSubElement ); + tmpSubElement->SetAttribute("value", *it); + } - } - } + } + } - doc.SaveFile( configFileName ); - } + doc.SaveFile( configFileName ); + } } -void ConfigFile::updateConfig(ConfigState myConfigState) { +void ConfigFile::updateConfig(ConfigState myConfigState) +{ - boost::recursive_mutex::scoped_lock lock(m_configMutex); + boost::recursive_mutex::scoped_lock lock(m_configMutex); - size_t i; + size_t i; - if(myConfigState == NONEXISTING) { + if(myConfigState == NONEXISTING) { - //Create a new ConfigFile! - TiXmlDocument doc; - TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", ""); - doc.LinkEndChild( decl ); + //Create a new ConfigFile! + TiXmlDocument doc; + TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", ""); + doc.LinkEndChild( decl ); - TiXmlElement * root = new TiXmlElement( "PokerTH" ); - doc.LinkEndChild( root ); + TiXmlElement * root = new TiXmlElement( "PokerTH" ); + doc.LinkEndChild( root ); - TiXmlElement * config; - config = new TiXmlElement( "Configuration" ); - root->LinkEndChild( config ); + TiXmlElement * config; + config = new TiXmlElement( "Configuration" ); + root->LinkEndChild( config ); - for (i=0; iLinkEndChild( tmpElement ); - tmpElement->SetAttribute("value", myQtToolsInterface->stringToUtf8(configList[i].defaultValue)); + for (i=0; iLinkEndChild( tmpElement ); + tmpElement->SetAttribute("value", myQtToolsInterface->stringToUtf8(configList[i].defaultValue)); - if(configList[i].type == CONFIG_TYPE_INT_LIST || configBufferList[i].type == CONFIG_TYPE_STRING_LIST) { + if(configList[i].type == CONFIG_TYPE_INT_LIST || configBufferList[i].type == CONFIG_TYPE_STRING_LIST) { - tmpElement->SetAttribute("type", "list"); - list tempList = configList[i].defaultListValue; - list::iterator it; + tmpElement->SetAttribute("type", "list"); + list tempList = configList[i].defaultListValue; + list::iterator it; for(it = tempList.begin(); it != tempList.end(); ++it) { - TiXmlElement *tmpSubElement = new TiXmlElement(configList[i].defaultValue); - tmpElement->LinkEndChild( tmpSubElement ); - tmpSubElement->SetAttribute("value", *it); - } + TiXmlElement *tmpSubElement = new TiXmlElement(configList[i].defaultValue); + tmpElement->LinkEndChild( tmpSubElement ); + tmpSubElement->SetAttribute("value", *it); + } - } - } + } + } - doc.SaveFile( configFileName ); - } + doc.SaveFile( configFileName ); + } - if(myConfigState == OLD) { + if(myConfigState == OLD) { - TiXmlDocument oldDoc(configFileName); + TiXmlDocument oldDoc(configFileName); - //load the old one - if(oldDoc.LoadFile()) { + //load the old one + if(oldDoc.LoadFile()) { - string tempString1(""); - string tempString2(""); + string tempString1(""); + string tempString2(""); - TiXmlDocument newDoc; + TiXmlDocument newDoc; - //Create the new one - TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", ""); - newDoc.LinkEndChild( decl ); + //Create the new one + TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", ""); + newDoc.LinkEndChild( decl ); - TiXmlElement * root = new TiXmlElement( "PokerTH" ); - newDoc.LinkEndChild( root ); + TiXmlElement * root = new TiXmlElement( "PokerTH" ); + newDoc.LinkEndChild( root ); - TiXmlElement * config; - config = new TiXmlElement( "Configuration" ); - root->LinkEndChild( config ); + TiXmlElement * config; + config = new TiXmlElement( "Configuration" ); + root->LinkEndChild( config ); - //change configRev and AppDataPath - TiXmlElement * confElement0 = new TiXmlElement( "ConfigRevision" ); - config->LinkEndChild( confElement0 ); - confElement0->SetAttribute("value", configRev); + //change configRev and AppDataPath + TiXmlElement * confElement0 = new TiXmlElement( "ConfigRevision" ); + config->LinkEndChild( confElement0 ); + confElement0->SetAttribute("value", configRev); - TiXmlElement * confElement1 = new TiXmlElement( "AppDataDir" ); - config->LinkEndChild( confElement1 ); - confElement1->SetAttribute("value", myQtToolsInterface->stringToUtf8(myQtToolsInterface->getDataPathStdString(myArgv0))); + TiXmlElement * confElement1 = new TiXmlElement( "AppDataDir" ); + config->LinkEndChild( confElement1 ); + confElement1->SetAttribute("value", myQtToolsInterface->stringToUtf8(myQtToolsInterface->getDataPathStdString(myArgv0))); - TiXmlHandle oldDocHandle( &oldDoc ); + TiXmlHandle oldDocHandle( &oldDoc ); - for (i=0; i take over the saved values + if ( oldConf /*&& (ISAIRCChannelUpdateDone || !(configList[i].name == "IRCChannel" || (configList[i].name == "InternetServerAddress" )))*/ /*HACK remove after 0.6*/ ) { + // if element is already there --> take over the saved values - if(configList[i].name != "ConfigRevision" && configList[i].name != "AppDataDir") { - // dont update ConfigRevision and AppDataDir becaus it was already set ^ + if(configList[i].name != "ConfigRevision" && configList[i].name != "AppDataDir") { + // dont update ConfigRevision and AppDataDir becaus it was already set ^ - TiXmlElement *tmpElement = new TiXmlElement(configList[i].name); - config->LinkEndChild( tmpElement ); + TiXmlElement *tmpElement = new TiXmlElement(configList[i].name); + config->LinkEndChild( tmpElement ); - const char *tmpStr1 = oldConf->Attribute("value"); - if (tmpStr1) tempString1 = tmpStr1; - tmpElement->SetAttribute("value", tempString1); + const char *tmpStr1 = oldConf->Attribute("value"); + if (tmpStr1) tempString1 = tmpStr1; + tmpElement->SetAttribute("value", tempString1); - //for lists copy elements - const char *tmpStr2 = oldConf->Attribute("type"); - if (tmpStr2) { - tempString2 = tmpStr2; - if(tempString2 == "list") { + //for lists copy elements + const char *tmpStr2 = oldConf->Attribute("type"); + if (tmpStr2) { + tempString2 = tmpStr2; + if(tempString2 == "list") { - list tempStringList2; + list tempStringList2; - TiXmlElement* oldConfList = oldDocHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( configList[i].name ).FirstChild().ToElement(); + TiXmlElement* oldConfList = oldDocHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( configList[i].name ).FirstChild().ToElement(); - for( ; oldConfList; oldConfList=oldConfList->NextSiblingElement()) { - tempStringList2.push_back(oldConfList->Attribute("value")); - } + for( ; oldConfList; oldConfList=oldConfList->NextSiblingElement()) { + tempStringList2.push_back(oldConfList->Attribute("value")); + } - tmpElement->SetAttribute("type", "list"); - list tempList = tempStringList2; - list::iterator it; + tmpElement->SetAttribute("type", "list"); + list tempList = tempStringList2; + list::iterator it; for(it = tempList.begin(); it != tempList.end(); ++it) { - TiXmlElement *tmpSubElement = new TiXmlElement(tempString1); - tmpElement->LinkEndChild( tmpSubElement ); - tmpSubElement->SetAttribute("value", *it); - } - } - } - } - } - else { - // if element is not there --> set it with defaultValue - TiXmlElement *tmpElement = new TiXmlElement(configList[i].name); - config->LinkEndChild( tmpElement ); - tmpElement->SetAttribute("value", myQtToolsInterface->stringToUtf8(configList[i].defaultValue)); + TiXmlElement *tmpSubElement = new TiXmlElement(tempString1); + tmpElement->LinkEndChild( tmpSubElement ); + tmpSubElement->SetAttribute("value", *it); + } + } + } + } + } else { + // if element is not there --> set it with defaultValue + TiXmlElement *tmpElement = new TiXmlElement(configList[i].name); + config->LinkEndChild( tmpElement ); + tmpElement->SetAttribute("value", myQtToolsInterface->stringToUtf8(configList[i].defaultValue)); - if(configList[i].type == CONFIG_TYPE_INT_LIST || configBufferList[i].type == CONFIG_TYPE_STRING_LIST) { + if(configList[i].type == CONFIG_TYPE_INT_LIST || configBufferList[i].type == CONFIG_TYPE_STRING_LIST) { - tmpElement->SetAttribute("type", "list"); - list tempList = configList[i].defaultListValue; - list::iterator it; + tmpElement->SetAttribute("type", "list"); + list tempList = configList[i].defaultListValue; + list::iterator it; for(it = tempList.begin(); it != tempList.end(); ++it) { - TiXmlElement *tmpSubElement = new TiXmlElement(configList[i].defaultValue); - tmpElement->LinkEndChild( tmpSubElement ); - tmpSubElement->SetAttribute("value", *it); - } - } - } - } - newDoc.SaveFile( configFileName ); - } - else { LOG_ERROR("Cannot update config file: Unable to load configuration."); } + TiXmlElement *tmpSubElement = new TiXmlElement(configList[i].defaultValue); + tmpElement->LinkEndChild( tmpSubElement ); + tmpSubElement->SetAttribute("value", *it); + } + } + } + } + newDoc.SaveFile( configFileName ); + } else { + LOG_ERROR("Cannot update config file: Unable to load configuration."); + } - } + } } string ConfigFile::readConfigString(string varName) const { - boost::recursive_mutex::scoped_lock lock(m_configMutex); + boost::recursive_mutex::scoped_lock lock(m_configMutex); - size_t i; - string tempString(""); + size_t i; + string tempString(""); - for (i=0; i> tempInt; + istringstream isst; + isst.str (tempString); + isst >> tempInt; - return tempInt; + return tempInt; } list ConfigFile::readConfigIntList(string varName) const { - boost::recursive_mutex::scoped_lock lock(m_configMutex); + boost::recursive_mutex::scoped_lock lock(m_configMutex); - size_t i; - list tempStringList; - list tempIntList; + size_t i; + list tempStringList; + list tempIntList; - for (i=0; i::iterator it; + istringstream isst; + string tempString; + int tempInt; + list::iterator it; for(it = tempStringList.begin(); it != tempStringList.end(); ++it) { - isst.str(*it); - isst >> tempInt; - tempIntList.push_back(tempInt); - isst.str(""); - isst.clear(); - } + isst.str(*it); + isst >> tempInt; + tempIntList.push_back(tempInt); + isst.str(""); + isst.clear(); + } - return tempIntList; + return tempIntList; } list ConfigFile::readConfigStringList(string varName) const { - boost::recursive_mutex::scoped_lock lock(m_configMutex); + boost::recursive_mutex::scoped_lock lock(m_configMutex); - size_t i; - list tempStringList; + size_t i; + list tempStringList; - for (i=0; i varCont) { - boost::recursive_mutex::scoped_lock lock(m_configMutex); + boost::recursive_mutex::scoped_lock lock(m_configMutex); - size_t i; - ostringstream intToString; - list stringList; + size_t i; + ostringstream intToString; + list stringList; - for (i=0; i::iterator it; + if (configBufferList[i].name == varName) { + string tempString; + list::iterator it; for(it = varCont.begin(); it != varCont.end(); ++it) { - intToString << (*it); - stringList.push_back(intToString.str()); - intToString.str(""); - intToString.clear(); - } + intToString << (*it); + stringList.push_back(intToString.str()); + intToString.str(""); + intToString.clear(); + } - configBufferList[i].defaultListValue = stringList; - } - } + configBufferList[i].defaultListValue = stringList; + } + } } void ConfigFile::writeConfigString(string varName, string varCont) { - boost::recursive_mutex::scoped_lock lock(m_configMutex); + boost::recursive_mutex::scoped_lock lock(m_configMutex); - size_t i; - for (i=0; i varCont) { - boost::recursive_mutex::scoped_lock lock(m_configMutex); + boost::recursive_mutex::scoped_lock lock(m_configMutex); - size_t i; - for (i=0; i readConfigStringList(std::string varName) const; @@ -50,22 +53,21 @@ public: std::list readConfigIntList(std::string varName) const; void writeConfigInt(std::string varName, int varCont); void writeConfigIntList(std::string varName, std::list varCont); - + private: mutable boost::recursive_mutex m_configMutex; - struct ConfigInfo - { + struct ConfigInfo { ConfigInfo(const std::string &n, ConfigType t, const std::string &d, const std::list &l =std::list()) : name(n), type(t), defaultValue(d), defaultListValue(l) {} std::string name; ConfigType type; std::string defaultValue; std::list defaultListValue; - + }; - + std::vector configList; std::vector configBufferList; diff --git a/src/connectivity.cpp b/src/connectivity.cpp index 8139ae73..af95774d 100644 --- a/src/connectivity.cpp +++ b/src/connectivity.cpp @@ -56,23 +56,16 @@ PokerTHMessage_t * receiveMessage(tcp::socket &socket) { PokerTHMessage_t *msg = NULL; - do - { + do { asn_dec_rval_t retVal = ber_decode(0, &asn_DEF_PokerTHMessage, (void **)&msg, recBuf.data(), recBufPos); - if(retVal.code == RC_OK && msg != NULL) - { - if (retVal.consumed < recBufPos) - { + if(retVal.code == RC_OK && msg != NULL) { + if (retVal.consumed < recBufPos) { recBufPos -= retVal.consumed; memmove(recBuf.c_array(), recBuf.c_array() + retVal.consumed, recBufPos); - } - else - { + } else { recBufPos = 0; } - } - else - { + } else { // Free the partially decoded message (if applicable). ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg); msg = NULL; @@ -86,11 +79,9 @@ bool sendMessage(tcp::socket &socket, PokerTHMessage_t *msg) { bool retVal = false; - if (msg) - { + if (msg) { asn_enc_rval_t e = der_encode_to_buffer(&asn_DEF_PokerTHMessage, msg, sendBuf.data(), BUF_SIZE); - if (e.encoded != -1) - { + if (e.encoded != -1) { socket.send(boost::asio::buffer(sendBuf.data(), e.encoded)); retVal = true; } @@ -102,30 +93,27 @@ sendMessage(tcp::socket &socket, PokerTHMessage_t *msg) int main(int argc, char *argv[]) { - try - { + try { // Check command line options. po::options_description desc("Allowed options"); desc.add_options() - ("help,h", "produce help message") - ("server,s", po::value(), "PokerTH server name") - ("port,P", po::value(), "PokerTH server port") - ("mode,m", po::value(), "set mode (0=connection test, 1=lag test)") - ("username,u", po::value(), "user name used for test") - ("password,p", po::value(), "password used for test") - ; + ("help,h", "produce help message") + ("server,s", po::value(), "PokerTH server name") + ("port,P", po::value(), "PokerTH server port") + ("mode,m", po::value(), "set mode (0=connection test, 1=lag test)") + ("username,u", po::value(), "user name used for test") + ("password,p", po::value(), "password used for test") + ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); - if (vm.count("help")) - { + if (vm.count("help")) { cout << desc << endl; return 1; } - if (!vm.count("server") || !vm.count("port") || !vm.count("mode") || !vm.count("username")) - { + if (!vm.count("server") || !vm.count("port") || !vm.count("mode") || !vm.count("username")) { cout << "Missing option!" << endl << desc << endl; return 1; } @@ -135,22 +123,19 @@ main(int argc, char *argv[]) int mode = vm["mode"].as(); string username(vm["username"].as()); string password; - if (vm.count("password")) - { + if (vm.count("password")) { password = vm["password"].as(); } // Initialise gsasl. Gsasl *authContext; Gsasl_session *authSession; int res = gsasl_init(&authContext); - if (res != GSASL_OK) - { + if (res != GSASL_OK) { cout << "gsasl init failed" << endl; return 1; } - if (!gsasl_client_support_p(authContext, "SCRAM-SHA-1")) - { + if (!gsasl_client_support_p(authContext, "SCRAM-SHA-1")) { gsasl_done(authContext); cout << "This version of gsasl does not support SCRAM-SHA-1" << endl; return 1; @@ -165,26 +150,22 @@ main(int argc, char *argv[]) tcp::resolver::iterator end; tcp::socket socket(io_service); boost::system::error_code error = boost::asio::error::host_not_found; - while (error && endpoint_iterator != end) - { + while (error && endpoint_iterator != end) { socket.close(); socket.connect(*endpoint_iterator++, error); } - if (error) - { + if (error) { cout << "Connect failed" << endl; return 1; } - if (mode == 1) - { + if (mode == 1) { cout << "Connect.value " << perfTimer.elapsed().total_milliseconds() << endl; } perfTimer.restart(); // Receive server information PokerTHMessage_t *msg = receiveMessage(socket); - if (!msg || msg->present != PokerTHMessage_PR_announceMessage) - { + if (!msg || msg->present != PokerTHMessage_PR_announceMessage) { cout << "Announce failed" << endl; return 1; } @@ -196,24 +177,19 @@ main(int argc, char *argv[]) InitMessage_t *netInit = &msg->choice.initMessage; netInit->requestedVersion.major = 1; netInit->requestedVersion.minor = 0; - if (password.empty()) - { + if (password.empty()) { netInit->login.present = login_PR_guestLogin; GuestLogin_t *guestLogin = &netInit->login.choice.guestLogin; OCTET_STRING_fromBuf(&guestLogin->nickName, username.c_str(), username.length()); - if (!sendMessage(socket, msg)) - { + if (!sendMessage(socket, msg)) { cout << "Init guest failed" << endl; return 1; } - } - else - { + } else { int errorCode = gsasl_client_start(authContext, "SCRAM-SHA-1", &authSession); - if (errorCode == GSASL_OK) - { + if (errorCode == GSASL_OK) { gsasl_property_set(authSession, GSASL_AUTHID, username.c_str()); gsasl_property_set(authSession, GSASL_PASSWORD, password.c_str()); @@ -224,12 +200,9 @@ main(int argc, char *argv[]) size_t tmpOutSize; string nextGsaslMsg; errorCode = gsasl_step(authSession, NULL, 0, &tmpOut, &tmpOutSize); - if (errorCode == GSASL_NEEDS_MORE) - { + if (errorCode == GSASL_NEEDS_MORE) { nextGsaslMsg = string(tmpOut, tmpOutSize); - } - else - { + } else { cout << "gsasl step 1 failed" << endl; return 1; } @@ -238,15 +211,13 @@ main(int argc, char *argv[]) OCTET_STRING_fromBuf(&authLogin->clientUserData, nextGsaslMsg.c_str(), nextGsaslMsg.length()); - if (!sendMessage(socket, msg)) - { + if (!sendMessage(socket, msg)) { cout << "Init auth request failed" << endl; return 1; } msg = receiveMessage(socket); - if (!msg || msg->present != PokerTHMessage_PR_authMessage) - { + if (!msg || msg->present != PokerTHMessage_PR_authMessage) { cout << "Auth request failed" << endl; return 1; } @@ -255,12 +226,9 @@ main(int argc, char *argv[]) AuthServerChallenge_t *netChallenge = &netAuth->choice.authServerChallenge; string challengeStr = STL_STRING_FROM_OCTET_STRING(netChallenge->serverChallenge); errorCode = gsasl_step(authSession, challengeStr.c_str(), challengeStr.size(), &tmpOut, &tmpOutSize); - if (errorCode == GSASL_NEEDS_MORE) - { + if (errorCode == GSASL_NEEDS_MORE) { nextGsaslMsg = string(tmpOut, tmpOutSize); - } - else - { + } else { cout << "gsasl step 2 failed" << endl; return 1; } @@ -275,14 +243,12 @@ main(int argc, char *argv[]) OCTET_STRING_fromBuf(&outResponse->clientResponse, nextGsaslMsg.c_str(), nextGsaslMsg.length()); - if (!sendMessage(socket, msg)) - { + if (!sendMessage(socket, msg)) { cout << "Init auth response failed" << endl; return 1; } msg = receiveMessage(socket); - if (!msg || msg->present != PokerTHMessage_PR_authMessage) - { + if (!msg || msg->present != PokerTHMessage_PR_authMessage) { cout << "Auth response failed" << endl; return 1; } @@ -291,15 +257,13 @@ main(int argc, char *argv[]) // Receive init ack msg = receiveMessage(socket); - if (!msg || msg->present != PokerTHMessage_PR_initAckMessage) - { + if (!msg || msg->present != PokerTHMessage_PR_initAckMessage) { cout << "Init ack failed" << endl; return 1; } ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg); - if (mode == 1) - { + if (mode == 1) { cout << "Init.value " << perfTimer.elapsed().total_milliseconds() << endl; } perfTimer.restart(); @@ -310,9 +274,9 @@ main(int argc, char *argv[]) JoinGameRequestMessage_t *netJoinGame = &msg->choice.joinGameRequestMessage; string tmpGamePassword("blah123"); netJoinGame->password = OCTET_STRING_new_fromBuf( - &asn_DEF_UTF8String, - tmpGamePassword.c_str(), - tmpGamePassword.length()); + &asn_DEF_UTF8String, + tmpGamePassword.c_str(), + tmpGamePassword.length()); netJoinGame->joinGameAction.present = joinGameAction_PR_joinNewGame; JoinNewGame_t *joinNew = &netJoinGame->joinGameAction.choice.joinNewGame; string tmpGameName("_perftest_do_not_join_" + username); @@ -330,48 +294,38 @@ main(int argc, char *argv[]) OCTET_STRING_fromBuf(&joinNew->gameInfo.gameName, tmpGameName.c_str(), tmpGameName.length()); - if (!sendMessage(socket, msg)) - { + if (!sendMessage(socket, msg)) { cout << "Create game failed" << endl; return 1; } msg = NULL; // Receive join game ack - do - { + do { ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg); msg = receiveMessage(socket); - if (!msg) - { + if (!msg) { cout << "Receive in lobby failed" << endl; return 1; } - if (msg->present == PokerTHMessage_PR_errorMessage) - { + if (msg->present == PokerTHMessage_PR_errorMessage) { cout << "Received error" << endl; return 1; } } while (msg->present != PokerTHMessage_PR_joinGameReplyMessage); - if (msg->choice.joinGameReplyMessage.joinGameResult.present != joinGameResult_PR_joinGameAck) - { + if (msg->choice.joinGameReplyMessage.joinGameResult.present != joinGameResult_PR_joinGameAck) { cout << "Join game ack failed" << endl; return 1; } ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg); - if (mode == 1) - { + if (mode == 1) { cout << "CreateGame.value " << perfTimer.elapsed().total_milliseconds() << endl; - } - else - { + } else { cout << "Success" << endl; } perfTimer.restart(); gsasl_done(authContext); - } - catch (...) - { + } catch (...) { cout << "Exception caught" << endl; return 1; } diff --git a/src/core/avatarmanager.h b/src/core/avatarmanager.h index 72527fcb..2e351515 100644 --- a/src/core/avatarmanager.h +++ b/src/core/avatarmanager.h @@ -42,7 +42,7 @@ class AvatarManager public: AvatarManager(bool useExternalServer = false, const std::string &externalServerAddress = "", - const std::string &externalServerUser = "", const std::string &externalServerPassword = ""); + const std::string &externalServerUser = "", const std::string &externalServerPassword = ""); ~AvatarManager(); bool Init(const std::string &dataDir, const std::string &cacheDir); diff --git a/src/core/common/avatarmanager.cpp b/src/core/common/avatarmanager.cpp index 75dda9a2..0b54cb54 100644 --- a/src/core/common/avatarmanager.cpp +++ b/src/core/common/avatarmanager.cpp @@ -48,15 +48,14 @@ using namespace std; using namespace boost::filesystem; -struct AvatarFileState -{ +struct AvatarFileState { ifstream inputStream; }; AvatarManager::AvatarManager(bool useExternalServer, const std::string &externalServerAddress, - const string &externalServerUser, const string &externalServerPassword) -: m_useExternalServer(useExternalServer), m_externalServerAddress(externalServerAddress), - m_externalServerUser(externalServerUser), m_externalServerPassword(externalServerPassword) + const string &externalServerUser, const string &externalServerPassword) + : m_useExternalServer(useExternalServer), m_externalServerAddress(externalServerAddress), + m_externalServerUser(externalServerUser), m_externalServerPassword(externalServerPassword) { m_uploader.reset(new UploaderThread()); } @@ -87,8 +86,7 @@ AvatarManager::Init(const string &dataDir, const string &cacheDir) } if (cacheDir.empty() || tmpCachePath.empty()) LOG_ERROR("Cache directory was not set!"); - else - { + else { boost::mutex::scoped_lock lock(m_cachedAvatarsMutex); tmpRet = InternalReadDirectory(tmpCachePath.directory_string(), m_cachedAvatars); retVal = retVal && tmpRet; @@ -105,20 +103,17 @@ AvatarManager::AddSingleAvatar(const std::string &fileName) path filePath(fileName); string tmpFileName(filePath.file_string()); - if (!fileName.empty() && !tmpFileName.empty()) - { + if (!fileName.empty() && !tmpFileName.empty()) { unsigned outFileSize = 0; AvatarFileType outFileType; boost::shared_ptr tmpFileState = OpenAvatarFileForChunkRead(tmpFileName, outFileSize, outFileType); // Check whether the avatar file is valid. - if (tmpFileState.get()) - { + if (tmpFileState.get()) { tmpFileState.reset(); MD5Buf md5buf; - if (CryptHelper::MD5Sum(tmpFileName, md5buf)) - { + if (CryptHelper::MD5Sum(tmpFileName, md5buf)) { boost::mutex::scoped_lock lock(m_avatarsMutex); m_avatars.insert(AvatarMap::value_type(md5buf, tmpFileName)); retVal = true; @@ -133,13 +128,11 @@ AvatarManager::OpenAvatarFileForChunkRead(const std::string &fileName, unsigned { outFileSize = 0; boost::shared_ptr retVal; - try - { + try { outFileType = GetAvatarFileType(fileName); boost::shared_ptr fileState(new AvatarFileState); fileState->inputStream.open(fileName.c_str(), ios_base::in | ios_base::binary); - if (!fileState->inputStream.fail()) - { + if (!fileState->inputStream.fail()) { // Find out file size. // Not fully portable, but works on win/linux/mac. fileState->inputStream.seekg(0, ios_base::beg); @@ -149,8 +142,7 @@ AvatarManager::OpenAvatarFileForChunkRead(const std::string &fileName, unsigned fileState->inputStream.seekg(0, ios_base::beg); std::streamoff posDiff(endPos - startPos); outFileSize = (unsigned)posDiff; - if (outFileSize >= MIN_AVATAR_FILE_SIZE && outFileSize <= MAX_AVATAR_FILE_SIZE) - { + if (outFileSize >= MIN_AVATAR_FILE_SIZE && outFileSize <= MAX_AVATAR_FILE_SIZE) { // Validate type of file by verifying image header. unsigned char fileHeader[MAX_HEADER_SIZE]; fileState->inputStream.read((char *)fileHeader, sizeof(fileHeader)); @@ -160,8 +152,7 @@ AvatarManager::OpenAvatarFileForChunkRead(const std::string &fileName, unsigned retVal = fileState; } } - } catch (...) - { + } catch (...) { LOG_ERROR("Exception caught when trying to open avatar."); } return retVal; @@ -171,17 +162,13 @@ unsigned AvatarManager::ChunkReadAvatarFile(boost::shared_ptr fileState, unsigned char *data, unsigned chunkSize) { unsigned retVal = 0; - if (fileState.get()) - { - try - { - if (!fileState->inputStream.fail() && !fileState->inputStream.eof()) - { + if (fileState.get()) { + try { + if (!fileState->inputStream.fail() && !fileState->inputStream.eof()) { fileState->inputStream.read((char *)data, chunkSize); retVal = fileState->inputStream.gcount(); } - } catch (...) - { + } catch (...) { LOG_ERROR("Exception caught when trying to read avatar."); } } @@ -195,8 +182,7 @@ AvatarManager::AvatarFileToNetPackets(const string &fileName, unsigned requestId unsigned fileSize = 0; AvatarFileType fileType; boost::shared_ptr tmpState = OpenAvatarFileForChunkRead(fileName, fileSize, fileType); - if (tmpState.get() && fileSize && fileType != AVATAR_FILE_TYPE_UNKNOWN) - { + if (tmpState.get() && fileSize && fileType != AVATAR_FILE_TYPE_UNKNOWN) { boost::shared_ptr avatarHeader(new NetPacket(NetPacket::Alloc)); avatarHeader->GetMsg()->present = PokerTHMessage_PR_avatarReplyMessage; AvatarReplyMessage_t *netHeader = &avatarHeader->GetMsg()->choice.avatarReplyMessage; @@ -209,11 +195,9 @@ AvatarManager::AvatarFileToNetPackets(const string &fileName, unsigned requestId unsigned numBytes = 0; unsigned totalBytesRead = 0; vector tmpData(MAX_FILE_DATA_SIZE); - do - { + do { numBytes = ChunkReadAvatarFile(tmpState, &tmpData[0], MAX_FILE_DATA_SIZE); - if (numBytes) - { + if (numBytes) { totalBytesRead += numBytes; boost::shared_ptr avatarFile(new NetPacket(NetPacket::Alloc)); @@ -231,8 +215,7 @@ AvatarManager::AvatarFileToNetPackets(const string &fileName, unsigned requestId if (fileSize != totalBytesRead) retVal = ERR_NET_WRONG_AVATAR_SIZE; - else - { + else { boost::shared_ptr avatarEnd(new NetPacket(NetPacket::Alloc)); avatarEnd->GetMsg()->present = PokerTHMessage_PR_avatarReplyMessage; AvatarReplyMessage_t *netEnd = &avatarEnd->GetMsg()->choice.avatarReplyMessage; @@ -268,19 +251,18 @@ string AvatarManager::GetAvatarFileExtension(AvatarFileType fileType) { string ext; - switch (fileType) - { - case AVATAR_FILE_TYPE_PNG: - ext = ".png"; - break; - case AVATAR_FILE_TYPE_JPG: - ext = ".jpg"; - break; - case AVATAR_FILE_TYPE_GIF: - ext = ".gif"; - break; - case AVATAR_FILE_TYPE_UNKNOWN: - break; + switch (fileType) { + case AVATAR_FILE_TYPE_PNG: + ext = ".png"; + break; + case AVATAR_FILE_TYPE_JPG: + ext = ".jpg"; + break; + case AVATAR_FILE_TYPE_GIF: + ext = ".gif"; + break; + case AVATAR_FILE_TYPE_UNKNOWN: + break; } return ext; } @@ -289,17 +271,14 @@ bool AvatarManager::GetHashForAvatar(const std::string &fileName, MD5Buf &md5buf) const { bool found = false; - if (exists(fileName)) - { + if (exists(fileName)) { // Scan default avatars first. { boost::mutex::scoped_lock lock(m_avatarsMutex); AvatarMap::const_iterator i = m_avatars.begin(); AvatarMap::const_iterator end = m_avatars.end(); - while (i != end) - { - if (i->second == fileName) - { + while (i != end) { + if (i->second == fileName) { md5buf = i->first; found = true; break; @@ -308,15 +287,12 @@ AvatarManager::GetHashForAvatar(const std::string &fileName, MD5Buf &md5buf) con } } // Check cached avatars next. - if (!found) - { + if (!found) { boost::mutex::scoped_lock lock(m_cachedAvatarsMutex); AvatarMap::const_iterator i = m_cachedAvatars.begin(); AvatarMap::const_iterator end = m_cachedAvatars.end(); - while (i != end) - { - if (i->second == fileName) - { + while (i != end) { + if (i->second == fileName) { md5buf = i->first; found = true; break; @@ -326,8 +302,7 @@ AvatarManager::GetHashForAvatar(const std::string &fileName, MD5Buf &md5buf) con } // Calculate md5 sum if not found. - if (!found) - { + if (!found) { if (CryptHelper::MD5Sum(fileName, md5buf)) found = true; } @@ -342,18 +317,15 @@ AvatarManager::GetAvatarFileName(const MD5Buf &md5buf, std::string &fileName) co { boost::mutex::scoped_lock lock(m_avatarsMutex); AvatarMap::const_iterator pos = m_avatars.find(md5buf); - if (pos != m_avatars.end()) - { + if (pos != m_avatars.end()) { fileName = pos->second; retVal = true; } } - if (!retVal) - { + if (!retVal) { boost::mutex::scoped_lock lock(m_cachedAvatarsMutex); AvatarMap::const_iterator pos = m_cachedAvatars.find(md5buf); - if (pos != m_cachedAvatars.end()) - { + if (pos != m_cachedAvatars.end()) { fileName = pos->second; retVal = true; } @@ -377,24 +349,19 @@ AvatarManager::StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFil boost::mutex::scoped_lock lock(m_cacheDirMutex); cacheDir = m_cacheDir; } - try - { + try { string ext(GetAvatarFileExtension(avatarFileType)); - if (!ext.empty() && !cacheDir.empty()) - { + if (!ext.empty() && !cacheDir.empty()) { // Check header before storing file. - if (IsValidAvatarFileType(avatarFileType, data, size)) - { + if (IsValidAvatarFileType(avatarFileType, data, size)) { path tmpPath(cacheDir); tmpPath /= (md5buf.ToString() + ext); string fileName(tmpPath.file_string()); ofstream o(fileName.c_str(), ios_base::out | ios_base::binary | ios_base::trunc); - if (!o.fail()) - { + if (!o.fail()) { o.write((const char *)data, size); o.close(); - if (upload && m_useExternalServer) - { + if (upload && m_useExternalServer) { m_uploader->QueueUpload(m_externalServerAddress, m_externalServerUser, m_externalServerPassword, fileName, size); } @@ -406,8 +373,7 @@ AvatarManager::StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFil } } } - } catch (...) - { + } catch (...) { LOG_ERROR("Exception caught when trying to store avatar."); } return retVal; @@ -418,32 +384,28 @@ AvatarManager::IsValidAvatarFileType(AvatarFileType avatarFileType, const unsign { bool validType = false; - switch (avatarFileType) - { - case AVATAR_FILE_TYPE_PNG: - if (fileHeaderSize >= PNG_HEADER_SIZE - && memcmp(fileHeader, PNG_HEADER, PNG_HEADER_SIZE) == 0) - { - validType = true; - } - break; - case AVATAR_FILE_TYPE_JPG: - if (fileHeaderSize >= JPG_HEADER_SIZE - && memcmp(fileHeader, JPG_HEADER, JPG_HEADER_SIZE) == 0) - { - validType = true; - } - break; - case AVATAR_FILE_TYPE_GIF: - if (fileHeaderSize >= GIF_HEADER_SIZE + switch (avatarFileType) { + case AVATAR_FILE_TYPE_PNG: + if (fileHeaderSize >= PNG_HEADER_SIZE + && memcmp(fileHeader, PNG_HEADER, PNG_HEADER_SIZE) == 0) { + validType = true; + } + break; + case AVATAR_FILE_TYPE_JPG: + if (fileHeaderSize >= JPG_HEADER_SIZE + && memcmp(fileHeader, JPG_HEADER, JPG_HEADER_SIZE) == 0) { + validType = true; + } + break; + case AVATAR_FILE_TYPE_GIF: + if (fileHeaderSize >= GIF_HEADER_SIZE && (memcmp(fileHeader, GIF_HEADER_1, GIF_HEADER_SIZE) == 0 - || memcmp(fileHeader, GIF_HEADER_2, GIF_HEADER_SIZE) == 0)) - { - validType = true; - } - break; - case AVATAR_FILE_TYPE_UNKNOWN: - break; + || memcmp(fileHeader, GIF_HEADER_2, GIF_HEADER_SIZE) == 0)) { + validType = true; + } + break; + case AVATAR_FILE_TYPE_UNKNOWN: + break; } return validType; } @@ -456,13 +418,11 @@ AvatarManager::RemoveOldAvatarCacheEntries() boost::mutex::scoped_lock lock(m_cacheDirMutex); cacheDir = m_cacheDir; } - try - { + try { path cachePath(cacheDir); cacheDir = cachePath.directory_string(); // Never delete anything if we do not have a special cache dir set. - if (!cacheDir.empty()) - { + if (!cacheDir.empty()) { boost::mutex::scoped_lock lock(m_cachedAvatarsMutex); // First pass: Remove files which no longer exist. @@ -473,18 +433,15 @@ AvatarManager::RemoveOldAvatarCacheEntries() { AvatarMap::const_iterator i = m_cachedAvatars.begin(); AvatarMap::const_iterator end = m_cachedAvatars.end(); - while (i != end) - { + while (i != end) { bool keepFile = false; path filePath(i->second); string fileString(filePath.file_string()); // Only consider files which are definitely in the cache dir. - if (fileString.size() > cacheDir.size() && fileString.substr(0, cacheDir.size()) == cacheDir) - { + if (fileString.size() > cacheDir.size() && fileString.substr(0, cacheDir.size()) == cacheDir) { // Only consider files with MD5 as file name. MD5Buf tmpBuf; - if (exists(filePath) && tmpBuf.FromString(basename(filePath))) - { + if (exists(filePath) && tmpBuf.FromString(basename(filePath))) { ++fileCount; timeMap.insert(TimeAvatarMap::value_type(last_write_time(filePath), i->first)); keepFile = true; @@ -500,8 +457,7 @@ AvatarManager::RemoveOldAvatarCacheEntries() { AvatarList::const_iterator i = removeList.begin(); AvatarList::const_iterator end = removeList.end(); - while (i != end) - { + while (i != end) { m_cachedAvatars.erase(*i); ++i; } @@ -514,14 +470,11 @@ AvatarManager::RemoveOldAvatarCacheEntries() // - delete until only MAX_NUMBER_OF_FILES/2 are left. // 2. Files are older than 30 days. - if (m_cachedAvatars.size() > MAX_NUMBER_OF_FILES) - { - while (!timeMap.empty() && m_cachedAvatars.size() > MAX_NUMBER_OF_FILES / 2) - { + if (m_cachedAvatars.size() > MAX_NUMBER_OF_FILES) { + while (!timeMap.empty() && m_cachedAvatars.size() > MAX_NUMBER_OF_FILES / 2) { TimeAvatarMap::iterator i = timeMap.begin(); AvatarMap::iterator pos = m_cachedAvatars.find(i->second); - if (pos != m_cachedAvatars.end()) - { + if (pos != m_cachedAvatars.end()) { path tmpPath(pos->second); remove(tmpPath); m_cachedAvatars.erase(pos); @@ -532,14 +485,12 @@ AvatarManager::RemoveOldAvatarCacheEntries() // Get reference time. time_t curTime = time(NULL); - while (!timeMap.empty() && !m_cachedAvatars.empty()) - { + while (!timeMap.empty() && !m_cachedAvatars.empty()) { TimeAvatarMap::iterator i = timeMap.begin(); if (curTime - i->first < (int)MAX_AVATAR_CACHE_AGE) break; AvatarMap::iterator pos = m_cachedAvatars.find(i->second); - if (pos != m_cachedAvatars.end()) - { + if (pos != m_cachedAvatars.end()) { path tmpPath(pos->second); remove(tmpPath); m_cachedAvatars.erase(pos); @@ -547,8 +498,7 @@ AvatarManager::RemoveOldAvatarCacheEntries() timeMap.erase(i); } } - } catch (...) - { + } catch (...) { LOG_ERROR("Exception caught while cleaning up cache."); } } @@ -559,37 +509,29 @@ AvatarManager::InternalReadDirectory(const std::string &dir, AvatarMap &avatars) bool retVal = true; path tmpPath(dir); - if (exists(tmpPath) && is_directory(tmpPath)) - { - try - { + if (exists(tmpPath) && is_directory(tmpPath)) { + try { // This method is not thread safe. Only call after locking the map. directory_iterator i(tmpPath); directory_iterator end; - while (i != end) - { - if (is_regular(i->status())) - { + while (i != end) { + if (is_regular(i->status())) { string md5sum(basename(i->path())); MD5Buf md5buf; string fileName(i->path().file_string()); - if (md5buf.FromString(md5sum)) - { + if (md5buf.FromString(md5sum)) { // Only consider files with md5sum as name. avatars.insert(AvatarMap::value_type(md5buf, fileName)); } } ++i; } - } catch (...) - { + } catch (...) { LOG_ERROR("Exception caught when trying to scan avatar directory."); retVal = false; } - } - else - { + } else { LOG_ERROR("Avatar directory does not exist."); retVal = false; } diff --git a/src/core/common/crypthelper.cpp b/src/core/common/crypthelper.cpp index 5751653d..4dfe06df 100644 --- a/src/core/common/crypthelper.cpp +++ b/src/core/common/crypthelper.cpp @@ -53,8 +53,7 @@ HashBuf::ToString() const char tmpBuf[2 + 1]; tmpBuf[sizeof(tmpBuf) - 1] = 0; const unsigned char *tmpData = GetData(); - for (int i = 0; i < GetDataSize(); i++) - { + for (int i = 0; i < GetDataSize(); i++) { sprintf(tmpBuf, "%02x", tmpData[i]); retValue += tmpBuf; } @@ -67,8 +66,7 @@ HashBuf::FromString(const std::string &text) // Convert hex-based string to MD5 data. bool retVal = false; int tmpSize = GetDataSize(); - if (text.size() == 2 * (unsigned)tmpSize) - { + if (text.size() == 2 * (unsigned)tmpSize) { unsigned char *tmpData = GetData(); const char *t = text.c_str(); int i = 0; @@ -92,8 +90,7 @@ HashBuf::IsZero() const int dataSize = GetDataSize(); const unsigned char *tmpData = GetData(); int i; - for (i = 0; i < dataSize; i++) - { + for (i = 0; i < dataSize; i++) { if (tmpData[i] != 0) break; } @@ -166,8 +163,7 @@ CryptHelper::MD5Sum(const std::string &fileName, MD5Buf &buf) bool retVal = false; FILE *file = fopen(fileName.c_str(), "rb"); - if (file) - { + if (file) { // Calculate MD5 sum of file. unsigned char readBuf[8192]; MD5_CTX context; @@ -211,15 +207,12 @@ CryptHelper::HMACSha1(const unsigned char *keyData, unsigned keySize, const unsi retVal = false; gcry_md_hd_t hd; gcry_error_t err = gcry_md_open(&hd, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC); - if (!err) - { + if (!err) { err = gcry_md_setkey(hd, keyData, keySize); - if (!err) - { + if (!err) { gcry_md_write(hd, plainData, plainSize); unsigned char *hash = gcry_md_read(hd, 0); - if (hash) - { + if (hash) { memcpy(buf.GetData(), hash, buf.GetDataSize()); retVal = true; } @@ -260,8 +253,7 @@ CryptHelper::AES128Encrypt(const unsigned char *keyData, unsigned keySize, const { bool retVal = false; unsigned plainSize = static_cast(plainStr.size()); - if (keySize && plainSize) - { + if (keySize && plainSize) { unsigned char key[AES_BLOCK_SIZE]; unsigned char iv[AES_BLOCK_SIZE]; BytesToKey(keyData, keySize, key, iv); @@ -281,24 +273,20 @@ CryptHelper::AES128Encrypt(const unsigned char *keyData, unsigned keySize, const int success = EVP_EncryptInit(&encryptCtx, EVP_aes_128_cbc(), key, iv); EVP_CIPHER_CTX_set_padding(&encryptCtx, 0); - if (success) - { + if (success) { success = EVP_EncryptUpdate(&encryptCtx, &outCipher[0], &outCipherSize, paddedPlainStr, paddedPlainSize); - if (success && outCipherSize) - { + if (success && outCipherSize) { // Since padding is off, this will not modify the cipher. However, parameters need to be set. EVP_EncryptFinal(&encryptCtx, &outCipher[0], &outCipherSize); retVal = true; } - } - else + } else outCipher.clear(); #else gcry_cipher_hd_t hd; gcry_error_t err = gcry_cipher_open(&hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC, 0); - if (!err) - { + if (!err) { gcry_cipher_setkey(hd, key, sizeof(key)); gcry_cipher_setiv(hd, iv, sizeof(iv)); err = gcry_cipher_encrypt(hd, &outCipher[0], cipherSize, paddedPlainStr, paddedPlainSize); @@ -306,8 +294,7 @@ CryptHelper::AES128Encrypt(const unsigned char *keyData, unsigned keySize, const retVal = true; else outCipher.clear(); - } - else + } else outCipher.clear(); gcry_cipher_close(hd); @@ -320,8 +307,7 @@ bool CryptHelper::AES128Decrypt(const unsigned char *keyData, unsigned keySize, const unsigned char *cipher, unsigned cipherSize, string &outPlain) { bool retVal = false; - if (keySize && cipherSize) - { + if (keySize && cipherSize) { unsigned char key[AES_BLOCK_SIZE]; unsigned char iv[AES_BLOCK_SIZE]; BytesToKey(keyData, keySize, key, iv); @@ -333,24 +319,20 @@ CryptHelper::AES128Decrypt(const unsigned char *keyData, unsigned keySize, const int success = EVP_DecryptInit(&decryptCtx, EVP_aes_128_cbc(), key, iv); EVP_CIPHER_CTX_set_padding(&decryptCtx, 0); - if (success) - { + if (success) { success = EVP_DecryptUpdate(&decryptCtx, (unsigned char *)&outPlain[0], &outPlainSize, cipher, cipherSize); - if (success && outPlainSize) - { + if (success && outPlainSize) { // Since padding is off, this will not modify the plain text. However, parameters need to be set. EVP_DecryptFinal(&decryptCtx, (unsigned char *)outPlain.c_str(), &outPlainSize); retVal = true; } - } - else + } else outPlain.clear(); #else gcry_cipher_hd_t hd; gcry_error_t err = gcry_cipher_open(&hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC, 0); - if (!err) - { + if (!err) { gcry_cipher_setkey(hd, key, sizeof(key)); gcry_cipher_setiv(hd, iv, sizeof(iv)); err = gcry_cipher_decrypt(hd, &outPlain[0], outPlain.size(), cipher, cipherSize); @@ -358,15 +340,13 @@ CryptHelper::AES128Decrypt(const unsigned char *keyData, unsigned keySize, const retVal = true; else outPlain.clear(); - } - else + } else outPlain.clear(); gcry_cipher_close(hd); #endif // Remove trailing zeroes (padding). - if (!outPlain.empty()) - { + if (!outPlain.empty()) { size_t pos = outPlain.find_first_of('\0'); if (pos != string::npos) outPlain = outPlain.substr(0, pos); diff --git a/src/core/common/loghelper_server.cpp b/src/core/common/loghelper_server.cpp index ac8f2973..88098f6f 100644 --- a/src/core/common/loghelper_server.cpp +++ b/src/core/common/loghelper_server.cpp @@ -54,11 +54,9 @@ loghelper_init(const string &logDir, int logLevel) void internal_log_err(const string &msg) { - if (!g_logFile.empty()) - { + if (!g_logFile.empty()) { ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app); - if (!o.fail()) - { + if (!o.fail()) { o << second_clock::local_time() << " ERR: " << msg; o.flush(); } @@ -68,10 +66,8 @@ internal_log_err(const string &msg) void internal_log_msg(const std::string &msg) { - if (g_logLevel) - { - if (!g_logFile.empty()) - { + if (g_logLevel) { + if (!g_logFile.empty()) { ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app); if (!o.fail()) o << second_clock::local_time() << " MSG: " << msg; @@ -82,10 +78,8 @@ internal_log_msg(const std::string &msg) void internal_log_level(const std::string &msg, int logLevel) { - if (g_logLevel >= logLevel) - { - if (!g_logFile.empty()) - { + if (g_logLevel >= logLevel) { + if (!g_logFile.empty()) { ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app); if (!o.fail()) o << second_clock::local_time() << " OUT: " << msg; diff --git a/src/core/common/pokerthexception.cpp b/src/core/common/pokerthexception.cpp index 872f1048..1ce32b9a 100644 --- a/src/core/common/pokerthexception.cpp +++ b/src/core/common/pokerthexception.cpp @@ -23,7 +23,7 @@ using namespace std; PokerTHException::PokerTHException(const char *sourcefile, int sourceline, int errorId, int osErrorCode) -: m_errorId(errorId), m_osErrorCode(osErrorCode) + : m_errorId(errorId), m_osErrorCode(osErrorCode) { ostringstream msgStream; msgStream << sourcefile << " (" << sourceline << "): Error " << errorId; diff --git a/src/core/common/thread.cpp b/src/core/common/thread.cpp index c553318d..c1a263bc 100644 --- a/src/core/common/thread.cpp +++ b/src/core/common/thread.cpp @@ -26,8 +26,7 @@ inline void ADD_MSEC_TO_XTIME(boost::xtime &xt, unsigned msec) { xt.sec += msec / 1000; xt.nsec += (msec % 1000) * 1000000; - if (xt.nsec > NANOSECONDS_PER_SECOND) - { + if (xt.nsec > NANOSECONDS_PER_SECOND) { xt.sec++; xt.nsec -= NANOSECONDS_PER_SECOND; } @@ -39,8 +38,7 @@ class ThreadStarter { public: ThreadStarter(Thread &thread) : m_thread(thread) {} - void operator()() - { + void operator()() { m_thread.MainWrapper(); } @@ -62,8 +60,7 @@ Thread::Run() boost::mutex::scoped_lock threadLock(m_threadObjMutex); // Create the boost thread object. - if (!m_threadObj.get()) - { + if (!m_threadObj.get()) { // Initialise data structures within the context of the thread // who runs/terminates this thread. m_userReqTerminateLock.reset(new boost::timed_mutex::scoped_try_lock(m_shouldTerminateMutex)); @@ -89,14 +86,11 @@ Thread::Join(unsigned msecTimeout) return true; bool tmpIsTerminated; - if (msecTimeout == THREAD_WAIT_INFINITE) - { + if (msecTimeout == THREAD_WAIT_INFINITE) { // Wait infinitely. boost::timed_mutex::scoped_lock lock(m_isTerminatedMutex); tmpIsTerminated = true; - } - else - { + } else { // Wait for the termination of the application code. #if (BOOST_VERSION) >= 103500 boost::defer_lock_t defer; @@ -113,12 +107,10 @@ Thread::Join(unsigned msecTimeout) #endif } - if (tmpIsTerminated) - { + if (tmpIsTerminated) { boost::mutex::scoped_lock lock(m_threadObjMutex); // Wait for "real" termination of the thread. - if (m_threadObj.get()) - { + if (m_threadObj.get()) { m_threadObj->join(); m_threadObj.reset(); } diff --git a/src/core/linux/convhelper.cpp b/src/core/linux/convhelper.cpp index 934dbdcf..a9da2661 100644 --- a/src/core/linux/convhelper.cpp +++ b/src/core/linux/convhelper.cpp @@ -25,7 +25,7 @@ #endif #if defined(__FreeBSD__) || defined(__NetBSD__) - #define HAVE_ICONV_CONST +#define HAVE_ICONV_CONST #endif #include @@ -57,8 +57,7 @@ ConvHelper::NativeToUtf8(const std::string &inStr) if (conversion == (iconv_t)(-1)) LOG_ERROR("iconv_open() failed: " << strerror(errno)); - else - { + else { size_t retval = iconv(conversion, &inbuf, &insize, &outbuf, &outsize); if (retval == (size_t)-1) @@ -91,8 +90,7 @@ ConvHelper::Utf8ToNative(const std::string &inStr) if (conversion == (iconv_t)(-1)) LOG_ERROR("iconv_open() failed: " << strerror(errno)); - else - { + else { size_t retval = iconv(conversion, &inbuf, &insize, &outbuf, &outsize); if (retval == (size_t)-1) diff --git a/src/core/openssl_wrapper.h b/src/core/openssl_wrapper.h index b1e4587e..293d679a 100644 --- a/src/core/openssl_wrapper.h +++ b/src/core/openssl_wrapper.h @@ -25,28 +25,28 @@ #define HAVE_SSIZE_T #include #ifdef _WIN64 // This is only for Windows. - #ifndef _SSIZE_T_ - typedef long long ssize_t; - #define _SSIZE_T_ - #endif - #ifndef _PID_T_ - typedef __int64 pid_t; - #define _PID_T_ - #endif +#ifndef _SSIZE_T_ +typedef long long ssize_t; +#define _SSIZE_T_ +#endif +#ifndef _PID_T_ +typedef __int64 pid_t; +#define _PID_T_ +#endif #elif _WIN32 - #ifndef _SSIZE_T_ - typedef int ssize_t; - #define _SSIZE_T_ - #endif - #ifndef _PID_T_ - typedef int pid_t; - #define _PID_T_ - #endif +#ifndef _SSIZE_T_ +typedef int ssize_t; +#define _SSIZE_T_ +#endif +#ifndef _PID_T_ +typedef int pid_t; +#define _PID_T_ +#endif #endif #endif #ifdef X509_NAME - #undef X509_NAME // Again for Windows - conflict with WinCrypt.h. +#undef X509_NAME // Again for Windows - conflict with WinCrypt.h. #endif // For BSD-Systems, we assume that OpenSSL is part of the operating system. @@ -56,21 +56,21 @@ // http://www.openssl.org/support/faq.html#LEGAL2 // #if defined(_WIN64) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) - #define HAVE_OPENSSL +#define HAVE_OPENSSL #endif #ifdef HAVE_OPENSSL - #include - #include - #include - #include - #include - #include +#include +#include +#include +#include +#include +#include #else - // For all other systems, we use GnuTLS. - #include - #include - #define PKTH_USE_GNUTLS +// For all other systems, we use GnuTLS. +#include +#include +#define PKTH_USE_GNUTLS #endif #endif diff --git a/src/core/pokerthexception.h b/src/core/pokerthexception.h index 803788f7..a4b1700a 100644 --- a/src/core/pokerthexception.h +++ b/src/core/pokerthexception.h @@ -31,8 +31,12 @@ public: PokerTHException(const char *sourcefile, int sourceline, int errorId, int osErrorCode); virtual ~PokerTHException() throw(); - int GetErrorId() const {return m_errorId;} - int GetOsErrorCode() const {return m_osErrorCode;} + int GetErrorId() const { + return m_errorId; + } + int GetOsErrorCode() const { + return m_osErrorCode; + } virtual const char *what() const throw(); diff --git a/src/core/thread.h b/src/core/thread.h index 6bc90e4d..3053b465 100644 --- a/src/core/thread.h +++ b/src/core/thread.h @@ -82,7 +82,7 @@ private: mutable boost::shared_ptr m_threadStartBarrier; -friend class ThreadStarter; + friend class ThreadStarter; }; #endif diff --git a/src/core/win32/convhelper.cpp b/src/core/win32/convhelper.cpp index 9ac70d1f..ef2e9f88 100644 --- a/src/core/win32/convhelper.cpp +++ b/src/core/win32/convhelper.cpp @@ -33,22 +33,18 @@ Convert(const std::string &inStr, int fromCP, int toCP) // convert str from current Windows source to target charset string retStr(inStr); - if (!inStr.empty()) - { + if (!inStr.empty()) { int len = (int)inStr.length() + 1; int reqLen = ::MultiByteToWideChar(fromCP, 0, inStr.c_str(), len, NULL, 0); - if (reqLen) - { + if (reqLen) { wchar_t *wstr = new wchar_t[reqLen]; wstr[0] = L'\0'; - if (::MultiByteToWideChar(fromCP, 0, inStr.c_str(), len, wstr, reqLen) == (int)reqLen) - { + if (::MultiByteToWideChar(fromCP, 0, inStr.c_str(), len, wstr, reqLen) == (int)reqLen) { len = reqLen; reqLen = ::WideCharToMultiByte(toCP, 0, wstr, len, NULL, 0, NULL, NULL); - if (reqLen) - { + if (reqLen) { char *str = new char[reqLen]; if (::WideCharToMultiByte(toCP, 0, wstr, len, str, reqLen, NULL, NULL) == (int)reqLen) retStr = str; diff --git a/src/db/common/serverdbgeneric.cpp b/src/db/common/serverdbgeneric.cpp index c31503a0..ce957ce6 100644 --- a/src/db/common/serverdbgeneric.cpp +++ b/src/db/common/serverdbgeneric.cpp @@ -24,7 +24,7 @@ using namespace std; ServerDBGeneric::ServerDBGeneric(ServerDBCallback &cb, boost::shared_ptr ioService) -: m_ioService(ioService), m_callback(cb) + : m_ioService(ioService), m_callback(cb) { } @@ -87,7 +87,7 @@ ServerDBGeneric::EndGame(DB_id /*gameId*/) } void - ServerDBGeneric::AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id /*reportedPlayerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/, DB_id */*byPlayerId*/) +ServerDBGeneric::AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id /*reportedPlayerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/, DB_id */*byPlayerId*/) { m_ioService->post(boost::bind(&ServerDBCallback::ReportAvatarFailed, &m_callback, requestId, replyId)); } diff --git a/src/db/common/serverdbnoaction.cpp b/src/db/common/serverdbnoaction.cpp index 8a85ce0e..20fce8a2 100644 --- a/src/db/common/serverdbnoaction.cpp +++ b/src/db/common/serverdbnoaction.cpp @@ -1,29 +1,29 @@ -/*************************************************************************** - * Copyright (C) 2010 by Lothar May * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include - - -ServerDBNoAction::ServerDBNoAction() -{ -} - -ServerDBNoAction::~ServerDBNoAction() -{ -} +/*************************************************************************** + * Copyright (C) 2010 by Lothar May * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include + + +ServerDBNoAction::ServerDBNoAction() +{ +} + +ServerDBNoAction::~ServerDBNoAction() +{ +} diff --git a/src/db/dbdefs.h b/src/db/dbdefs.h index 40f826cf..3e3855fa 100644 --- a/src/db/dbdefs.h +++ b/src/db/dbdefs.h @@ -27,8 +27,7 @@ typedef unsigned DB_id; #define DB_ID_INVALID 0 -struct DBPlayerData -{ +struct DBPlayerData { DBPlayerData() : id(DB_ID_INVALID) {} DB_id id; std::string secret; diff --git a/src/db/serverdbnoaction.h b/src/db/serverdbnoaction.h index 3b0aadee..370d4496 100644 --- a/src/db/serverdbnoaction.h +++ b/src/db/serverdbnoaction.h @@ -1,51 +1,51 @@ -/*************************************************************************** - * Copyright (C) 2010 by Lothar May * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -/* Generic server database implementation. Basically does nothing. */ - -#ifndef _SERVERDBNOACTION_H_ -#define _SERVERDBNOACTION_H_ - -#include - - -class ServerDBNoAction : public ServerDBInterface -{ -public: - ServerDBNoAction(); - virtual ~ServerDBNoAction(); - - virtual void Init(const std::string &/*host*/, const std::string &/*user*/, const std::string &/*pwd*/, - const std::string &/*database*/, const std::string &/*encryptionKey*/) {} - - virtual void Start() {} - virtual void Stop() {} - - virtual void AsyncPlayerLogin(unsigned /*requestId*/, const std::string &/*playerName*/) {} - virtual void AsyncCheckAvatarBlacklist(unsigned /*requestId*/, const std::string &/*avatarHash*/) {} - virtual void PlayerPostLogin(DB_id /*playerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/) {} - virtual void PlayerLogout(DB_id /*playerId*/) {} - - virtual void AsyncCreateGame(unsigned /*requestId*/, const std::string &/*gameName*/) {} - virtual void SetGamePlayerPlace(DB_id /*gameId*/, DB_id /*playerId*/, unsigned /*place*/) {} - virtual void EndGame(DB_id /*gameId*/) {} - - virtual void AsyncReportAvatar(unsigned /*requestId*/, unsigned /*replyId*/, DB_id /*reportedPlayerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/, DB_id */*byPlayerId*/) {} -}; - -#endif // _SERVERDBNOACTION_H_ +/*************************************************************************** + * Copyright (C) 2010 by Lothar May * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +/* Generic server database implementation. Basically does nothing. */ + +#ifndef _SERVERDBNOACTION_H_ +#define _SERVERDBNOACTION_H_ + +#include + + +class ServerDBNoAction : public ServerDBInterface +{ +public: + ServerDBNoAction(); + virtual ~ServerDBNoAction(); + + virtual void Init(const std::string &/*host*/, const std::string &/*user*/, const std::string &/*pwd*/, + const std::string &/*database*/, const std::string &/*encryptionKey*/) {} + + virtual void Start() {} + virtual void Stop() {} + + virtual void AsyncPlayerLogin(unsigned /*requestId*/, const std::string &/*playerName*/) {} + virtual void AsyncCheckAvatarBlacklist(unsigned /*requestId*/, const std::string &/*avatarHash*/) {} + virtual void PlayerPostLogin(DB_id /*playerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/) {} + virtual void PlayerLogout(DB_id /*playerId*/) {} + + virtual void AsyncCreateGame(unsigned /*requestId*/, const std::string &/*gameName*/) {} + virtual void SetGamePlayerPlace(DB_id /*gameId*/, DB_id /*playerId*/, unsigned /*place*/) {} + virtual void EndGame(DB_id /*gameId*/) {} + + virtual void AsyncReportAvatar(unsigned /*requestId*/, unsigned /*replyId*/, DB_id /*reportedPlayerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/, DB_id */*byPlayerId*/) {} +}; + +#endif // _SERVERDBNOACTION_H_ diff --git a/src/engine/berointerface.cpp b/src/engine/berointerface.cpp index 30976630..e4fb2d8e 100644 --- a/src/engine/berointerface.cpp +++ b/src/engine/berointerface.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: berointerface // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 diff --git a/src/engine/berointerface.h b/src/engine/berointerface.h index 42f07f0b..128a6309 100644 --- a/src/engine/berointerface.h +++ b/src/engine/berointerface.h @@ -23,11 +23,12 @@ #include #include -class BeRoInterface{ +class BeRoInterface +{ public: virtual ~BeRoInterface(); - + virtual GameState getMyBeRoID() const =0; virtual void setCurrentPlayersTurnId(unsigned) =0; diff --git a/src/engine/boardinterface.h b/src/engine/boardinterface.h index e4acb12d..08061279 100644 --- a/src/engine/boardinterface.h +++ b/src/engine/boardinterface.h @@ -24,25 +24,26 @@ class HandInterface; -class BoardInterface { +class BoardInterface +{ public: - + virtual ~BoardInterface(); -// +// virtual void setPlayerLists(PlayerList, PlayerList, PlayerList) =0; -// +// virtual void setMyCards(int* theValue) =0; virtual void getMyCards(int* theValue) =0; -// +// virtual int getPot() const=0; virtual void setPot(int theValue) =0; virtual int getSets() const=0; virtual void setSets(int theValue) =0; - virtual void setAllInCondition(bool theValue) =0; - virtual void setLastActionPlayer(unsigned theValue) =0; -// + virtual void setAllInCondition(bool theValue) =0; + virtual void setLastActionPlayer(unsigned theValue) =0; +// virtual void collectSets() =0; virtual void collectPot() =0; diff --git a/src/engine/enginefactory.h b/src/engine/enginefactory.h index ecf3f452..adbc9af5 100644 --- a/src/engine/enginefactory.h +++ b/src/engine/enginefactory.h @@ -26,11 +26,12 @@ #include "berointerface.h" #include "log.h" -class EngineFactory{ +class EngineFactory +{ public: - + virtual ~EngineFactory(); - + virtual boost::shared_ptr createHand(boost::shared_ptr f, GuiInterface *g, boost::shared_ptr b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) =0; virtual boost::shared_ptr createBoard(unsigned dp) =0; virtual boost::shared_ptr createPlayer(int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) =0; diff --git a/src/engine/handinterface.h b/src/engine/handinterface.h index b83110a0..71dabcb7 100644 --- a/src/engine/handinterface.h +++ b/src/engine/handinterface.h @@ -25,9 +25,10 @@ #include "playerinterface.h" #include "berointerface.h" -class HandInterface{ +class HandInterface +{ public: - + virtual ~HandInterface(); virtual void start() = 0; @@ -46,7 +47,7 @@ public: virtual void setMyID(int theValue) =0; virtual int getMyID() const =0; - + virtual void setStartQuantityPlayers(int theValue) =0; virtual int getStartQuantityPlayers() const =0; @@ -84,13 +85,13 @@ protected: virtual PlayerListIterator getActivePlayerIt(unsigned) const =0; virtual PlayerListIterator getRunningPlayerIt(unsigned) const =0; -friend class Game; -friend class LocalBeRo; -friend class LocalBeRoPreflop; -friend class LocalBeRoFlop; -friend class LocalBeRoTurn; -friend class LocalBeRoRiver; -friend class LocalBeRoPostRiver; + friend class Game; + friend class LocalBeRo; + friend class LocalBeRoPreflop; + friend class LocalBeRoFlop; + friend class LocalBeRoTurn; + friend class LocalBeRoRiver; + friend class LocalBeRoPostRiver; }; #endif diff --git a/src/engine/local_engine/arraydata.cpp b/src/engine/local_engine/arraydata.cpp index e1fcf24f..e3d2f4e8 100644 --- a/src/engine/local_engine/arraydata.cpp +++ b/src/engine/local_engine/arraydata.cpp @@ -22,14 +22,12 @@ using namespace std; -struct RoundData -{ +struct RoundData { int hand; double data[4]; }; -static const RoundData PreflopValues[] = -{ +static const RoundData PreflopValues[] = { { 0, { 0.392398, 0.276545, 0.212940, 0.178564 } }, { 10, { 0.341141, 0.213735, 0.153802, 0.121123 } }, { 11, { 0.374930, 0.252093, 0.194671, 0.161691 } }, @@ -201,8 +199,7 @@ static const RoundData PreflopValues[] = { 12120, { 0.855608, 0.736617, 0.642366, 0.562044 } } }; -static const RoundData FlopValues[] = -{ +static const RoundData FlopValues[] = { { 106, { 0.160312, 0.078750, 0.048325, 0.033350 } }, { 206, { 0.185012, 0.099666, 0.071425, 0.053450 } }, { 306, { 0.199662, 0.115567, 0.081625, 0.067500 } }, @@ -839,14 +836,12 @@ static const RoundData FlopValues[] = { 71212, { 0.751687, 0.628100, 0.560100, 0.516900 } } }; -struct calcHandsData -{ +struct calcHandsData { int hand; int data[10][2]; }; -static const calcHandsData handChancePreflop[] = -{ +static const calcHandsData handChancePreflop[] = { { 0, { { 0,0}, { 36,1}, { 40,1}, { 12,1}, { 1,1}, { 2,1}, { 9,1}, { 1,1}, { 0,1}, { 0,1} } }, { 10, { { 19,1}, { 45,1}, { 23,1}, { 4,1}, { 5,1}, { 2,1}, { 2,1}, { 0,1}, { 0,1}, { 0,1} } }, { 11, { { 18,1}, { 42,1}, { 22,1}, { 4,1}, { 5,1}, { 6,1}, { 2,1}, { 0,1}, { 0,1}, { 0,1} } }, @@ -1030,15 +1025,16 @@ ArrayData::~ArrayData() { } -void ArrayData::getHandChancePreflop(int handCode, int** values) { +void ArrayData::getHandChancePreflop(int handCode, int** values) +{ int check = -1; for (unsigned val = 0; val < NUM_HAND_CHANCE_PREFLOP; val++) { if(handCode == handChancePreflop[val].hand) { check = 1; - for(int i=0;i<10;i++) { - for(int j=0;j<2;j++) { + for(int i=0; i<10; i++) { + for(int j=0; j<2; j++) { values[i][j] = handChancePreflop[val].data[i][j]; } } @@ -1049,7 +1045,8 @@ void ArrayData::getHandChancePreflop(int handCode, int** values) { } -vector< vector > ArrayData::getHandChancePreflop(int handCode) { +vector< vector > ArrayData::getHandChancePreflop(int handCode) +{ int check = -1; @@ -1060,7 +1057,7 @@ vector< vector > ArrayData::getHandChancePreflop(int handCode) { chance[0].resize(10); chance[1].resize(10); - for(i=0;i<10;i++) { + for(i=0; i<10; i++) { chance[0][i] = 0; chance[1][i] = 0; } @@ -1068,8 +1065,8 @@ vector< vector > ArrayData::getHandChancePreflop(int handCode) { for (unsigned val = 0; val < NUM_HAND_CHANCE_PREFLOP; val++) { if(handCode == handChancePreflop[val].hand) { check = 1; - for(int i=0;i<10;i++) { - for(int j=0;j<2;j++) { + for(int i=0; i<10; i++) { + for(int j=0; j<2; j++) { chance[j][i] = handChancePreflop[val].data[i][j]; } } diff --git a/src/engine/local_engine/arraydata.h b/src/engine/local_engine/arraydata.h index 51af34f2..ef53df74 100644 --- a/src/engine/local_engine/arraydata.h +++ b/src/engine/local_engine/arraydata.h @@ -24,11 +24,12 @@ #include -class ArrayData{ +class ArrayData +{ public: - ArrayData(); + ArrayData(); - ~ArrayData(); + ~ArrayData(); void getHandChancePreflop(int, int**); std::vector< std::vector > getHandChancePreflop(int); diff --git a/src/engine/local_engine/cardsvalue.cpp b/src/engine/local_engine/cardsvalue.cpp index bc9670fb..acff6a7c 100755 --- a/src/engine/local_engine/cardsvalue.cpp +++ b/src/engine/local_engine/cardsvalue.cpp @@ -30,143 +30,192 @@ CardsValue::~CardsValue() { } -int CardsValue::holeCardsClass(int one, int two) const { +int CardsValue::holeCardsClass(int one, int two) const +{ - if((one-1)%13<(two-1)%13) { - int temp = one; - one = two; - two = temp; - } + if((one-1)%13<(two-1)%13) { + int temp = one; + one = two; + two = temp; + } - if((one-1)%13 == (two-1)%13) { - if((one-1)%13+2 > 10) return 10; - else { - switch((one-1)%13+2) { - case 10: return 9; - case 9: return 8; - case 8: return 7; - case 7: return 6; - default: return 5; - } - } - } - switch((one-1)%13+2) { - //Ass - case 14: { - if((one-1)/13 == (two-1)/13) { - switch((one-1)%13-(two-1)%13) { - case 1: return 10; - case 2: return 9; - case 3: return 9; - case 4: return 8; - default: return 7; - } - } - else { - switch((one-1)%13-(two-1)%13) { - case 1: return 9; - case 2: return 8; - case 3: return 7; - case 4: return 7; - default: return 4; - } - } - } break; - //K�ig - case 13: { - if((one-1)/13 == (two-1)/13) { - switch((one-1)%13-(two-1)%13) { - case 1: return 9; - case 2: return 8; - case 3: return 8; - case 4: return 6; - default: return 5; - } - } - else { - switch((one-1)%13-(two-1)%13) { - case 1: return 7; - case 2: return 6; - case 3: return 6; - default: return 4; - } - } - } break; - //Dame - case 12: { - if((one-1)/13 == (two-1)/13) { - switch((one-1)%13-(two-1)%13) { - case 1: return 8; - case 2: return 7; - case 3: return 6; - case 4: return 5; - default: return 4; - } - } - else { - switch((one-1)%13-(two-1)%13) { - case 1: return 6; - case 2: return 6; - case 3: return 4; - default: return 3; - } - } - } break; - //Bube - case 11: { - if((one-1)/13 == (two-1)/13) { - switch((one-1)%13-(two-1)%13) { - case 1: return 7; - case 2: return 6; - case 3: return 5; - case 4: return 4; - default: return 3; - } - } - else { - switch((one-1)%13-(two-1)%13) { - case 1: return 6; - case 2: return 5; - case 3: return 4; - default: return 2; - } - } - } break; - //10 - case 10: { - if((one-1)/13 == (two-1)/13) { - switch((one-1)%13-(two-1)%13) { - case 1: return 6; - case 2: return 5; - default: return 2; - } - } - else { - switch((one-1)%13-(two-1)%13) { - case 1: return 5; - case 2: return 4; - default: return 1; - } - } - } break; - //Rest - default: { - if((one-1)%13 - (two-1)%13 <= 2) { - if((one-1)/13 == (two-1)/13) return 5; - else return 3; - } - else { - if((one-1)%13 - (two-1)%13 == 3) return 2; - else return 1; - } - } - } + if((one-1)%13 == (two-1)%13) { + if((one-1)%13+2 > 10) return 10; + else { + switch((one-1)%13+2) { + case 10: + return 9; + case 9: + return 8; + case 8: + return 7; + case 7: + return 6; + default: + return 5; + } + } + } + switch((one-1)%13+2) { + //Ass + case 14: { + if((one-1)/13 == (two-1)/13) { + switch((one-1)%13-(two-1)%13) { + case 1: + return 10; + case 2: + return 9; + case 3: + return 9; + case 4: + return 8; + default: + return 7; + } + } else { + switch((one-1)%13-(two-1)%13) { + case 1: + return 9; + case 2: + return 8; + case 3: + return 7; + case 4: + return 7; + default: + return 4; + } + } + } + break; + //K�ig + case 13: { + if((one-1)/13 == (two-1)/13) { + switch((one-1)%13-(two-1)%13) { + case 1: + return 9; + case 2: + return 8; + case 3: + return 8; + case 4: + return 6; + default: + return 5; + } + } else { + switch((one-1)%13-(two-1)%13) { + case 1: + return 7; + case 2: + return 6; + case 3: + return 6; + default: + return 4; + } + } + } + break; + //Dame + case 12: { + if((one-1)/13 == (two-1)/13) { + switch((one-1)%13-(two-1)%13) { + case 1: + return 8; + case 2: + return 7; + case 3: + return 6; + case 4: + return 5; + default: + return 4; + } + } else { + switch((one-1)%13-(two-1)%13) { + case 1: + return 6; + case 2: + return 6; + case 3: + return 4; + default: + return 3; + } + } + } + break; + //Bube + case 11: { + if((one-1)/13 == (two-1)/13) { + switch((one-1)%13-(two-1)%13) { + case 1: + return 7; + case 2: + return 6; + case 3: + return 5; + case 4: + return 4; + default: + return 3; + } + } else { + switch((one-1)%13-(two-1)%13) { + case 1: + return 6; + case 2: + return 5; + case 3: + return 4; + default: + return 2; + } + } + } + break; + //10 + case 10: { + if((one-1)/13 == (two-1)/13) { + switch((one-1)%13-(two-1)%13) { + case 1: + return 6; + case 2: + return 5; + default: + return 2; + } + } else { + switch((one-1)%13-(two-1)%13) { + case 1: + return 5; + case 2: + return 4; + default: + return 1; + } + } + } + break; + //Rest + default: { + if((one-1)%13 - (two-1)%13 <= 2) { + if((one-1)/13 == (two-1)/13) return 5; + else return 3; + } else { + if((one-1)%13 - (two-1)%13 == 3) return 2; + else return 1; + } + } + } } -int CardsValue::holeCardsToIntCode(int* cards) const { +int CardsValue::holeCardsToIntCode(int* cards) const +{ // Code der HoleCards ermitteln if(cards[0]%13 == cards[1]%13) { @@ -189,7 +238,8 @@ int CardsValue::holeCardsToIntCode(int* cards) const { } -int* CardsValue::intCodeToHoleCards(int code) const { +int* CardsValue::intCodeToHoleCards(int code) const +{ // one possibility !!! @@ -198,8 +248,9 @@ int* CardsValue::intCodeToHoleCards(int code) const { cards[0] = code/1000; cards[1] = (code-cards[0]*1000)/10; - if(cards[0]==cards[1]) { cards[1] +=13; } - else { + if(cards[0]==cards[1]) { + cards[1] +=13; + } else { if(code%10 == 0) cards[1] +=13; } @@ -207,9 +258,10 @@ int* CardsValue::intCodeToHoleCards(int code) const { } -int CardsValue::cardsValue(int* cards, int* position) const { +int CardsValue::cardsValue(int* cards, int* position) const +{ -int array[7][3]; + int array[7][3]; int j1, j2, j3, j4, j5, k1, k2, ktemp[3]; // Kartenwerte umwandeln (z.B. [ 11 (Karo K�ig) -> 0 11 ] oder [ 31 (Pik 7) -> 2 5 ] ) @@ -360,7 +412,7 @@ int array[7][3]; for(j1=0; j1<4; j1++) { if(array[j1][1] == array[j1+1][1] && array[j1][1] == array[j1+2][1] && array[j1][1] == array[j1+3][1]) { // Position des Kickers ermitteln und der Blattwertung als dritte Gewichtung hinzuaddieren - if(j1==0) { + if(j1==0) { if(position) { // Position-Array fuellen for(j2=0; j2<5; j2++) { @@ -368,8 +420,7 @@ int array[7][3]; } } return 700000000+array[j1][1]*1000000+array[j1+4][1]*10000; - } - else { + } else { if(position) { // Position-Array fuellen for(j2=0; j2<4; j2++) { @@ -414,8 +465,13 @@ int array[7][3]; position[4] = array[j5][2]; } // Paar und Drilling des Full House ermitteln ermitteln - if(array[j3][1]==array[j1][1]) { drei = array[j1][1]; zwei = array[j4][1]; } - else { drei = array[j4][1]; zwei = array[j1][1]; } + if(array[j3][1]==array[j1][1]) { + drei = array[j1][1]; + zwei = array[j4][1]; + } else { + drei = array[j4][1]; + zwei = array[j1][1]; + } return 600000000+drei*1000000+zwei*10000; } } @@ -454,26 +510,24 @@ int array[7][3]; if(j1==0) { if(position) { // Position-Array fuellen - for(j2=0; j2<5;j2++) { + for(j2=0; j2<5; j2++) { position[j2] = array[j2][2]; } } return 300000000+array[j1][1]*1000000+array[j1+3][1]*10000+array[j1+4][1]*100; - } - else { + } else { if(j1==1) { if(position) { // Position-Array fuellen - for(j2=0; j2<5;j2++) { + for(j2=0; j2<5; j2++) { position[j2] = array[j2][2]; } } return 300000000+array[j1][1]*1000000+array[j1-1][1]*10000+array[j1+3][1]*100; - } - else { + } else { if(position) { // Position-Array fuellen - for(j2=0; j2<3;j2++) { + for(j2=0; j2<3; j2++) { position[j2] = array[j1+j2][2]; } position[3] = array[0][2]; @@ -498,30 +552,28 @@ int array[7][3]; position[1] = array[j1+1][2]; position[2] = array[j2][2]; position[3] = array[j2+1][2]; - position[4] = array[j2+2][2]; + position[4] = array[j2+2][2]; } return 200000000+array[j1][1]*1000000+array[j2][1]*10000+array[j2+2][1]*100; - } - else { + } else { if(position) { // Position-Array fuellen position[0] = array[j1][2]; position[1] = array[j1+1][2]; position[2] = array[j2][2]; position[3] = array[j2+1][2]; - position[4] = array[j1+2][2]; + position[4] = array[j1+2][2]; } return 200000000+array[j1][1]*1000000+array[j2][1]*10000+array[j1+2][1]*100; } - } - else { + } else { if(position) { // Position-Array fuellen position[0] = array[j1][2]; position[1] = array[j1+1][2]; position[2] = array[j2][2]; position[3] = array[j2+1][2]; - position[4] = array[0][2]; + position[4] = array[0][2]; } return 200000000+array[j1][1]*1000000+array[j2][1]*10000+array[0][1]*100; } @@ -559,8 +611,7 @@ int array[7][3]; } } return 100000000+array[j1][1]*1000000+array[j1-2][1]*10000+array[j1-1][1]*100+array[j1+2][1]; - } - else { + } else { if(position) { // Position-Array fuellen for(j2=0; j2<2; j2++) { @@ -595,7 +646,7 @@ vector< vector > CardsValue::calcCardsChance(GameState beRoID, int* playerC chance[0].resize(10); chance[1].resize(10); - for(i=0;i<10;i++) { + for(i=0; i<10; i++) { chance[0][i] = 0; chance[1][i] = 0; } @@ -605,22 +656,23 @@ vector< vector > CardsValue::calcCardsChance(GameState beRoID, int* playerC cards[0] = playerCards[0]; cards[1] = playerCards[1]; - for(i=0;i<5;i++) cards[i+2] = boardCards[i]; + for(i=0; i<5; i++) cards[i+2] = boardCards[i]; switch(beRoID) { - case GAME_STATE_PREFLOP: { - ArrayData* myArrayData = new ArrayData; + case GAME_STATE_PREFLOP: { + ArrayData* myArrayData = new ArrayData; - chance = myArrayData->getHandChancePreflop(holeCardsToIntCode(playerCards)); + chance = myArrayData->getHandChancePreflop(holeCardsToIntCode(playerCards)); - delete myArrayData; + delete myArrayData; - } break; - case GAME_STATE_FLOP: { + } + break; + case GAME_STATE_FLOP: { - for(i=0;i<51;i++) { - if(i!=cards[0] && i!=cards[1] && i!=cards[2] && i!=cards[3] && i!=cards[4]) { - for(j=i+1;j<52;j++) { + for(i=0; i<51; i++) { + if(i!=cards[0] && i!=cards[1] && i!=cards[2] && i!=cards[3] && i!=cards[4]) { + for(j=i+1; j<52; j++) { if(j!=cards[0] && j!=cards[1] && j!=cards[2] && j!=cards[3] && j!=cards[4]) { cards[5] = i; cards[6] = j; @@ -628,35 +680,38 @@ vector< vector > CardsValue::calcCardsChance(GameState beRoID, int* playerC sum++; } } - } } - for(i=0;i<10;i++) { - if(chance[0][i] > 0) chance[1][i] = 1; - chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5); - } - - } break; - case GAME_STATE_TURN: { - - for(i=0;i<52;i++) { - if(i!=cards[0] && i!=cards[1] && i!=cards[2] && i!=cards[3] && i!=cards[4] && i!=cards[5]) { - cards[6] = i; - (chance[0][cardsValue(cards,0)/100000000])++; - sum++; - } - } - for(i=0;i<10;i++) { - if(chance[0][i] > 0) chance[1][i] = 1; - chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5); - } - - } break; - case GAME_STATE_RIVER: { - chance[0][cardsValue(cards,0)/100000000] = 100; - chance[1][cardsValue(cards,0)/100000000] = 1; - } break; - default: { } + for(i=0; i<10; i++) { + if(chance[0][i] > 0) chance[1][i] = 1; + chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5); + } + + } + break; + case GAME_STATE_TURN: { + + for(i=0; i<52; i++) { + if(i!=cards[0] && i!=cards[1] && i!=cards[2] && i!=cards[3] && i!=cards[4] && i!=cards[5]) { + cards[6] = i; + (chance[0][cardsValue(cards,0)/100000000])++; + sum++; + } + } + for(i=0; i<10; i++) { + if(chance[0][i] > 0) chance[1][i] = 1; + chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5); + } + + } + break; + case GAME_STATE_RIVER: { + chance[0][cardsValue(cards,0)/100000000] = 100; + chance[1][cardsValue(cards,0)/100000000] = 1; + } + break; + default: { + } } return chance; @@ -665,18 +720,18 @@ vector< vector > CardsValue::calcCardsChance(GameState beRoID, int* playerC //int** CardsValue::showdown(GameState beRoID, int** playerCards, int playerCount) { // // int i,j; -// +// // int** chance = new int*[2]; -// +// // for(i=0;i<10;i++) { // chance[i] = new int[2]; // for(j=0;j<2;j++) { // chance[i][j] = 0; // } // } -// +// // int rand[5]; -// +// // return chance; // //} diff --git a/src/engine/local_engine/cardsvalue.h b/src/engine/local_engine/cardsvalue.h index 646090d5..5c6f5b83 100755 --- a/src/engine/local_engine/cardsvalue.h +++ b/src/engine/local_engine/cardsvalue.h @@ -28,20 +28,21 @@ -class CardsValue{ +class CardsValue +{ public: - CardsValue(); + CardsValue(); - ~CardsValue(); + ~CardsValue(); - int holeCardsClass(int, int) const; - int cardsValue(int*, int*) const; + int holeCardsClass(int, int) const; + int cardsValue(int*, int*) const; - int holeCardsToIntCode(int*) const; - int* intCodeToHoleCards(int) const; + int holeCardsToIntCode(int*) const; + int* intCodeToHoleCards(int) const; - std::vector< std::vector > calcCardsChance(GameState, int*, int*) const; - //int** showdown(GameState, int**, int); + std::vector< std::vector > calcCardsChance(GameState, int*, int*) const; + //int** showdown(GameState, int**, int); }; diff --git a/src/engine/local_engine/localbero.cpp b/src/engine/local_engine/localbero.cpp index 0b325b3e..a5f21edf 100644 --- a/src/engine/local_engine/localbero.cpp +++ b/src/engine/local_engine/localbero.cpp @@ -26,7 +26,7 @@ using namespace std; LocalBeRo::LocalBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS) -: BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), dealerPositionId(dP), smallBlindPositionId(0), bigBlindPositionId(0), smallBlind(sB), highestSet(0), minimumRaise(2*sB), fullBetRule(false), firstRun(true), firstRunGui(true), firstRound(true), firstHeadsUpRound(true), currentPlayersTurnId(0), firstRoundLastPlayersTurnId(0), logBoardCardsDone(false) + : BeRoInterface(), myHand(hi), myBeRoID(gS), myID(id), dealerPosition(dP), smallBlindPosition(0), dealerPositionId(dP), smallBlindPositionId(0), bigBlindPositionId(0), smallBlind(sB), highestSet(0), minimumRaise(2*sB), fullBetRule(false), firstRun(true), firstRunGui(true), firstRound(true), firstHeadsUpRound(true), currentPlayersTurnId(0), firstRoundLastPlayersTurnId(0), logBoardCardsDone(false) { currentPlayersTurnIt = myHand->getRunningPlayerList()->begin(); lastPlayersTurnIt = myHand->getRunningPlayerList()->begin(); @@ -68,7 +68,8 @@ int LocalBeRo::getHighestCardsValue() const return 0; } -void LocalBeRo::nextPlayer() { +void LocalBeRo::nextPlayer() +{ PlayerListConstIterator currentPlayersTurnConstIt = myHand->getRunningPlayerIt(currentPlayersTurnId); if(currentPlayersTurnConstIt == myHand->getRunningPlayerList()->end()) { @@ -79,37 +80,37 @@ void LocalBeRo::nextPlayer() { } -void LocalBeRo::run() { +void LocalBeRo::run() +{ if(firstRunGui) { firstRunGui = false; myHand->setLastPlayersTurn(-1); myHand->getGuiInterface()->dealBeRoCards(myBeRoID); - } - else { + } else { if(firstRun) { firstRun = false; - + if(!(myHand->getAllInCondition())) { PlayerListIterator it_1, it_2; - + // running player before smallBlind bool formerRunningPlayerFound = false; if(myHand->getActivePlayerList()->size() > 2) { - + it_1 = myHand->getActivePlayerIt(smallBlindPositionId); if(it_1 == myHand->getActivePlayerList()->end()) { throw LocalException(__FILE__, __LINE__, ERR_ACTIVE_PLAYER_NOT_FOUND); } - + for(size_t i=0; igetActivePlayerList()->size(); i++) { - + if(it_1 == myHand->getActivePlayerList()->begin()) it_1 = myHand->getActivePlayerList()->end(); --it_1; - + it_2 = myHand->getRunningPlayerIt((*it_1)->getMyUniqueID()); // running player found if(it_2 != myHand->getRunningPlayerList()->end()) { @@ -125,7 +126,7 @@ void LocalBeRo::run() { // heads up: bigBlind begins -> dealer/smallBlind is running player before bigBlind else { firstRoundLastPlayersTurnId = smallBlindPositionId; - } + } currentPlayersTurnId = firstRoundLastPlayersTurnId; } } @@ -138,13 +139,18 @@ void LocalBeRo::run() { myHand->getBoard()->getMyCards(tempBoardCardsArray); switch(myBeRoID) { - case GAME_STATE_FLOP: myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2]); + case GAME_STATE_FLOP: + myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2]); break; - case GAME_STATE_TURN: myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3]); + case GAME_STATE_TURN: + myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3]); break; - case GAME_STATE_RIVER: myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3], tempBoardCardsArray[4]); + case GAME_STATE_RIVER: + myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3], tempBoardCardsArray[4]); break; - default: { LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR - wrong myBeRoID"); } + default: { + LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR - wrong myBeRoID"); + } } logBoardCardsDone = true; @@ -165,8 +171,8 @@ void LocalBeRo::run() { } // prfen, ob aktuelle bero wirklich dran ist - if(!firstRound && allHighestSet) { - + if(!firstRound && allHighestSet) { + // aktuelle bero nicht dran, weil alle Sets gleich sind //also gehe in naechste bero myHand->setCurrentRound(myBeRoID+1); @@ -180,14 +186,15 @@ void LocalBeRo::run() { myHand->getBoard()->collectSets(); myHand->getBoard()->collectPot(); myHand->getGuiInterface()->refreshPot(); - + myHand->getGuiInterface()->refreshSet(); myHand->getGuiInterface()->refreshCash(); - for(int i=0; igetGuiInterface()->refreshAction(i,PLAYER_ACTION_NONE); } - + for(int i=0; igetGuiInterface()->refreshAction(i,PLAYER_ACTION_NONE); + } + myHand->switchRounds(); - } - else { + } else { // aktuelle bero ist wirklich dran // Anzahl der effektiv gespielten Runden (des human player) erhöhen @@ -204,10 +211,10 @@ void LocalBeRo::run() { if(currentPlayersTurnIt == myHand->getRunningPlayerList()->end()) { throw LocalException(__FILE__, __LINE__, ERR_RUNNING_PLAYER_NOT_FOUND); } - + ++currentPlayersTurnIt; if(currentPlayersTurnIt == myHand->getRunningPlayerList()->end()) currentPlayersTurnIt = myHand->getRunningPlayerList()->begin(); - + currentPlayersTurnId = (*currentPlayersTurnIt)->getMyUniqueID(); //highlight active players groupbox and clear action @@ -229,8 +236,7 @@ void LocalBeRo::run() { if( currentPlayersTurnId == 0) { // Wir sind dran myHand->getGuiInterface()->meInAction(); - } - else { + } else { //Gegner sind dran myHand->getGuiInterface()->beRoAnimation2(myBeRoID); diff --git a/src/engine/local_engine/localbero.h b/src/engine/local_engine/localbero.h index a610bdfa..354e4f11 100644 --- a/src/engine/local_engine/localbero.h +++ b/src/engine/local_engine/localbero.h @@ -26,75 +26,142 @@ #include "berointerface.h" #include "handinterface.h" -class LocalBeRo : public BeRoInterface{ +class LocalBeRo : public BeRoInterface +{ public: LocalBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS); ~LocalBeRo(); - GameState getMyBeRoID() const { return myBeRoID; } + GameState getMyBeRoID() const { + return myBeRoID; + } int getHighestCardsValue() const; void setHighestCardsValue(int /*theValue*/) { } - void setMinimumRaise ( int theValue ) { minimumRaise = theValue; } - int getMinimumRaise() const { return minimumRaise; } + void setMinimumRaise ( int theValue ) { + minimumRaise = theValue; + } + int getMinimumRaise() const { + return minimumRaise; + } - void setFullBetRule ( bool theValue ) { fullBetRule = theValue; } - bool getFullBetRule() const { return fullBetRule; } + void setFullBetRule ( bool theValue ) { + fullBetRule = theValue; + } + bool getFullBetRule() const { + return fullBetRule; + } - void skipFirstRunGui() { firstRunGui = false; } + void skipFirstRunGui() { + firstRunGui = false; + } void nextPlayer(); void run(); void postRiverRun() {}; - + protected: - HandInterface* getMyHand() const { return myHand; } + HandInterface* getMyHand() const { + return myHand; + } - int getDealerPosition() const {return dealerPosition; } - void setDealerPosition(int theValue) { dealerPosition = theValue; } + int getDealerPosition() const { + return dealerPosition; + } + void setDealerPosition(int theValue) { + dealerPosition = theValue; + } - void setCurrentPlayersTurnId(unsigned theValue) { currentPlayersTurnId = theValue; } - unsigned getCurrentPlayersTurnId() const { return currentPlayersTurnId;} + void setCurrentPlayersTurnId(unsigned theValue) { + currentPlayersTurnId = theValue; + } + unsigned getCurrentPlayersTurnId() const { + return currentPlayersTurnId; + } - void setFirstRoundLastPlayersTurnId(unsigned theValue) { firstRoundLastPlayersTurnId = theValue; } - unsigned getFirstRoundLastPlayersTurnId() const { return firstRoundLastPlayersTurnId;} + void setFirstRoundLastPlayersTurnId(unsigned theValue) { + firstRoundLastPlayersTurnId = theValue; + } + unsigned getFirstRoundLastPlayersTurnId() const { + return firstRoundLastPlayersTurnId; + } - void setCurrentPlayersTurnIt(PlayerListIterator theValue) { currentPlayersTurnIt = theValue; } - PlayerListIterator getCurrentPlayersTurnIt() const { return currentPlayersTurnIt; } + void setCurrentPlayersTurnIt(PlayerListIterator theValue) { + currentPlayersTurnIt = theValue; + } + PlayerListIterator getCurrentPlayersTurnIt() const { + return currentPlayersTurnIt; + } - void setLastPlayersTurnIt(PlayerListIterator theValue) { lastPlayersTurnIt = theValue; } - PlayerListIterator getLastPlayersTurnIt() const { return lastPlayersTurnIt; } - - void setHighestSet(int theValue) { highestSet = theValue; } - int getHighestSet() const { return highestSet;} + void setLastPlayersTurnIt(PlayerListIterator theValue) { + lastPlayersTurnIt = theValue; + } + PlayerListIterator getLastPlayersTurnIt() const { + return lastPlayersTurnIt; + } - void setFirstRun(bool theValue) { firstRun = theValue;} - bool getFirstRun() const { return firstRun;} + void setHighestSet(int theValue) { + highestSet = theValue; + } + int getHighestSet() const { + return highestSet; + } - void setFirstRound(bool theValue) { firstRound = theValue;} - bool getFirstRound() const { return firstRound;} + void setFirstRun(bool theValue) { + firstRun = theValue; + } + bool getFirstRun() const { + return firstRun; + } + + void setFirstRound(bool theValue) { + firstRound = theValue; + } + bool getFirstRound() const { + return firstRound; + } - void setDealerPositionId(unsigned theValue) { dealerPositionId = theValue;} - unsigned getDealerPositionId() const { return dealerPositionId; } + void setDealerPositionId(unsigned theValue) { + dealerPositionId = theValue; + } + unsigned getDealerPositionId() const { + return dealerPositionId; + } - void setSmallBlindPositionId(unsigned theValue) { smallBlindPositionId = theValue;} - unsigned getSmallBlindPositionId() const { return smallBlindPositionId; } + void setSmallBlindPositionId(unsigned theValue) { + smallBlindPositionId = theValue; + } + unsigned getSmallBlindPositionId() const { + return smallBlindPositionId; + } - void setBigBlindPositionId(unsigned theValue) { bigBlindPositionId = theValue;} - unsigned getBigBlindPositionId() const { return bigBlindPositionId; } + void setBigBlindPositionId(unsigned theValue) { + bigBlindPositionId = theValue; + } + unsigned getBigBlindPositionId() const { + return bigBlindPositionId; + } - void setSmallBlindPosition(int theValue) { smallBlindPosition = theValue;} - int getSmallBlindPosition() const { return smallBlindPosition; } + void setSmallBlindPosition(int theValue) { + smallBlindPosition = theValue; + } + int getSmallBlindPosition() const { + return smallBlindPosition; + } + + void setSmallBlind(int theValue) { + smallBlind = theValue; + } + int getSmallBlind() const { + return smallBlind; + } - void setSmallBlind(int theValue) { smallBlind = theValue; } - int getSmallBlind() const { return smallBlind; } - @@ -115,7 +182,7 @@ private: int smallBlind; int highestSet; int minimumRaise; - bool fullBetRule; + bool fullBetRule; bool firstRun; bool firstRunGui; // HACK diff --git a/src/engine/local_engine/localberoflop.h b/src/engine/local_engine/localberoflop.h index 9a1cc5af..3325523c 100644 --- a/src/engine/local_engine/localberoflop.h +++ b/src/engine/local_engine/localberoflop.h @@ -25,7 +25,8 @@ class HandInterface; -class LocalBeRoFlop : public LocalBeRo{ +class LocalBeRoFlop : public LocalBeRo +{ public: LocalBeRoFlop(HandInterface*, int, unsigned, int); diff --git a/src/engine/local_engine/localberopostriver.cpp b/src/engine/local_engine/localberopostriver.cpp index 2796f559..4abb4d01 100644 --- a/src/engine/local_engine/localberopostriver.cpp +++ b/src/engine/local_engine/localberopostriver.cpp @@ -33,10 +33,12 @@ LocalBeRoPostRiver::~LocalBeRoPostRiver() { } -void LocalBeRoPostRiver::run() { +void LocalBeRoPostRiver::run() +{ } -void LocalBeRoPostRiver::postRiverRun() { +void LocalBeRoPostRiver::postRiverRun() +{ PlayerListConstIterator it_c; PlayerListIterator it; @@ -44,8 +46,8 @@ void LocalBeRoPostRiver::postRiverRun() { // who is the winner for(it_c=getMyHand()->getActivePlayerList()->begin(); it_c!=getMyHand()->getActivePlayerList()->end(); ++it_c) { - if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && (*it_c)->getMyCardsValueInt() > highestCardsValue ) { - highestCardsValue = (*it_c)->getMyCardsValueInt(); + if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && (*it_c)->getMyCardsValueInt() > highestCardsValue ) { + highestCardsValue = (*it_c)->getMyCardsValueInt(); } } @@ -83,5 +85,5 @@ void LocalBeRoPostRiver::postRiverRun() { getMyHand()->getBoard()->setPot(0); //starte die Animaionsreihe - getMyHand()->getGuiInterface()->postRiverRunAnimation1(); + getMyHand()->getGuiInterface()->postRiverRunAnimation1(); } diff --git a/src/engine/local_engine/localberopostriver.h b/src/engine/local_engine/localberopostriver.h index 523f2edf..3188fad7 100644 --- a/src/engine/local_engine/localberopostriver.h +++ b/src/engine/local_engine/localberopostriver.h @@ -26,13 +26,18 @@ class HandInterface; -class LocalBeRoPostRiver : public LocalBeRo{ +class LocalBeRoPostRiver : public LocalBeRo +{ public: LocalBeRoPostRiver(HandInterface*, int, int, int); ~LocalBeRoPostRiver(); - void setHighestCardsValue(int theValue) { highestCardsValue = theValue;} - int getHighestCardsValue() const { return highestCardsValue;} + void setHighestCardsValue(int theValue) { + highestCardsValue = theValue; + } + int getHighestCardsValue() const { + return highestCardsValue; + } void run(); diff --git a/src/engine/local_engine/localberopreflop.cpp b/src/engine/local_engine/localberopreflop.cpp index 0db1562b..19058115 100644 --- a/src/engine/local_engine/localberopreflop.cpp +++ b/src/engine/local_engine/localberopreflop.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * Copyright (C) 2006 by FThauer FHammer * - * f.thauer@web.de *Irische Segenswnsche, + * f.thauer@web.de *Irische Segenswnsche, * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -38,37 +38,38 @@ LocalBeRoPreflop::~LocalBeRoPreflop() { } -void LocalBeRoPreflop::run() { +void LocalBeRoPreflop::run() +{ if(getFirstRun()) { - + PlayerListIterator it; - + // search bigBlindPosition in runningPlayerList PlayerListIterator bigBlindPositionIt = getMyHand()->getRunningPlayerIt(getBigBlindPositionId()); - + // more than 2 players are still active -> runningPlayerList is not empty if(getMyHand()->getActivePlayerList()->size() > 2) { - + // bigBlindPlayer not found in runningPlayerList (he is all in) -> bigBlindPlayer is not the running player before first action player if(bigBlindPositionIt == getMyHand()->getRunningPlayerList()->end()) { - + // search smallBlindPosition in runningPlayerList PlayerListIterator smallBlindPositionIt = getMyHand()->getRunningPlayerIt(getSmallBlindPositionId()); - + // smallBlindPlayer not found in runningPlayerList (he is all in) -> next active player before smallBlindPlayer is running player before first action player if(smallBlindPositionIt == getMyHand()->getRunningPlayerList()->end()) { - + it = getMyHand()->getActivePlayerIt(getSmallBlindPositionId()); if(it == getMyHand()->getActivePlayerList()->end()) { throw LocalException(__FILE__, __LINE__, ERR_ACTIVE_PLAYER_NOT_FOUND); } - + if(it == getMyHand()->getActivePlayerList()->begin()) it = getMyHand()->getActivePlayerList()->end(); --it; - + setFirstRoundLastPlayersTurnId( (*it)->getMyUniqueID() ); - + } // smallBlindPlayer found in runningPlayerList -> running player before first action player else { @@ -82,30 +83,30 @@ void LocalBeRoPreflop::run() { } // heads up -> dealer/smallBlindPlayer is first action player and bigBlindPlayer is player before else { - + // bigBlindPlayer not found in runningPlayerList (he is all in) -> only smallBlind has to choose fold or call the bigBlindAmount if(bigBlindPositionIt == getMyHand()->getRunningPlayerList()->end()) { - + // search smallBlindPosition in runningPlayerList PlayerListIterator smallBlindPositionIt = getMyHand()->getRunningPlayerIt(getSmallBlindPositionId()); - + // smallBlindPlayer not found in runningPlayerList (he is all in) -> no running player -> showdown and no firstRoundLastPlayersTurnId is used if(smallBlindPositionIt == getMyHand()->getRunningPlayerList()->end()) { - + } // smallBlindPlayer found in runningPlayerList -> running player before first action player (himself) else { setFirstRoundLastPlayersTurnId( getSmallBlindPositionId() ); } - - + + } else { setFirstRoundLastPlayersTurnId( getBigBlindPositionId() ); } } - + setCurrentPlayersTurnId( getFirstRoundLastPlayersTurnId() ); - + setFirstRun(false); } @@ -131,9 +132,9 @@ void LocalBeRoPreflop::run() { if(currentPlayersTurnIt == getMyHand()->getRunningPlayerList()->end()) currentPlayersTurnIt = getMyHand()->getRunningPlayerList()->begin(); setCurrentPlayersTurnId( (*currentPlayersTurnIt)->getMyUniqueID() ); - + // prfen, ob Preflop wirklich dran ist - if(!getFirstRound() && allHighestSet) { + if(!getFirstRound() && allHighestSet) { // Preflop nicht dran, weil wir nicht mehr in erster PreflopRunde und alle Sets gleich sind //also gehe in Flop @@ -148,14 +149,15 @@ void LocalBeRoPreflop::run() { getMyHand()->getBoard()->collectSets(); getMyHand()->getBoard()->collectPot(); getMyHand()->getGuiInterface()->refreshPot(); - + getMyHand()->getGuiInterface()->refreshSet(); getMyHand()->getGuiInterface()->refreshCash(); - for(int i=0; igetGuiInterface()->refreshAction(i,PLAYER_ACTION_NONE); } + for(int i=0; igetGuiInterface()->refreshAction(i,PLAYER_ACTION_NONE); + } getMyHand()->switchRounds(); - } - else { + } else { // lastPlayersTurn -> PreflopFirstRound is over if( getCurrentPlayersTurnId() == getFirstRoundLastPlayersTurnId() ) { setFirstRound(false); @@ -175,8 +177,7 @@ void LocalBeRoPreflop::run() { if( getCurrentPlayersTurnId() == 0) { // Wir sind dran getMyHand()->getGuiInterface()->meInAction(); - } - else { + } else { //Gegner sind dran getMyHand()->getGuiInterface()->beRoAnimation2(getMyBeRoID()); } diff --git a/src/engine/local_engine/localberopreflop.h b/src/engine/local_engine/localberopreflop.h index 79d17baa..a2409e8e 100644 --- a/src/engine/local_engine/localberopreflop.h +++ b/src/engine/local_engine/localberopreflop.h @@ -25,8 +25,9 @@ class HandInterface; -class LocalBeRoPreflop : public LocalBeRo{ - +class LocalBeRoPreflop : public LocalBeRo +{ + public: LocalBeRoPreflop(HandInterface*, int, unsigned, int); ~LocalBeRoPreflop(); diff --git a/src/engine/local_engine/localberoriver.h b/src/engine/local_engine/localberoriver.h index 2638b37a..e118ddaa 100644 --- a/src/engine/local_engine/localberoriver.h +++ b/src/engine/local_engine/localberoriver.h @@ -26,7 +26,8 @@ class HandInterface; -class LocalBeRoRiver : public LocalBeRo{ +class LocalBeRoRiver : public LocalBeRo +{ public: LocalBeRoRiver(HandInterface*, int, unsigned, int); ~LocalBeRoRiver(); diff --git a/src/engine/local_engine/localberoturn.h b/src/engine/local_engine/localberoturn.h index e39aae92..5165de48 100644 --- a/src/engine/local_engine/localberoturn.h +++ b/src/engine/local_engine/localberoturn.h @@ -25,7 +25,8 @@ class HandInterface; -class LocalBeRoTurn : public LocalBeRo{ +class LocalBeRoTurn : public LocalBeRo +{ public: LocalBeRoTurn(HandInterface*, int, unsigned, int); ~LocalBeRoTurn(); diff --git a/src/engine/local_engine/localboard.cpp b/src/engine/local_engine/localboard.cpp index 835a34b5..65811e0e 100755 --- a/src/engine/local_engine/localboard.cpp +++ b/src/engine/local_engine/localboard.cpp @@ -36,13 +36,15 @@ LocalBoard::~LocalBoard() { } -void LocalBoard::setPlayerLists(PlayerList sl, PlayerList apl, PlayerList rpl) { +void LocalBoard::setPlayerLists(PlayerList sl, PlayerList apl, PlayerList rpl) +{ seatsList = sl; activePlayerList = apl; runningPlayerList = rpl; } -void LocalBoard::collectSets() { +void LocalBoard::collectSets() +{ sets = 0; @@ -53,9 +55,10 @@ void LocalBoard::collectSets() { } -void LocalBoard::collectPot() { +void LocalBoard::collectPot() +{ - pot += sets; + pot += sets; sets = 0; PlayerListIterator it; @@ -65,7 +68,8 @@ void LocalBoard::collectPot() { } -void LocalBoard::distributePot() { +void LocalBoard::distributePot() +{ winners.clear(); @@ -115,8 +119,8 @@ void LocalBoard::distributePot() { // determine level highestCardsValue for(it_c=seatsList->begin(), j=0; it_c!=seatsList->end(); ++it_c,j++) { - if((*it_c)->getMyActiveStatus() && (*it_c)->getMyCardsValueInt() > highestCardsValue && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) { - highestCardsValue = (*it_c)->getMyCardsValueInt(); + if((*it_c)->getMyActiveStatus() && (*it_c)->getMyCardsValueInt() > highestCardsValue && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && playerSets[j] >= potLevel[0]) { + highestCardsValue = (*it_c)->getMyCardsValueInt(); } } @@ -139,12 +143,12 @@ void LocalBoard::distributePot() { if(mod == 0) { for(j=2; jbegin(); it!=seatsList->end(); ++it) { - if((*it)->getMyUniqueID() == potLevel[j]) { - break; - } - } + if((*it)->getMyUniqueID() == potLevel[j]) { + break; + } + } if(it == seatsList->end()) { throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND); } @@ -162,13 +166,13 @@ void LocalBoard::distributePot() { // winnerPointer = currentHand->getDealerPosition(); - // find Seat with dealerPosition + // find Seat with dealerPosition for(it=seatsList->begin(); it!=seatsList->end(); ++it) { - if((*it)->getMyUniqueID() == dealerPosition) { - break; - } - } - if(it == seatsList->end()) { + if((*it)->getMyUniqueID() == dealerPosition) { + break; + } + } + if(it == seatsList->end()) { throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND); } @@ -176,7 +180,7 @@ void LocalBoard::distributePot() { winnerHit = false; - for(k=0; kbegin(); it_c != activePlayerList->end(); ++it_c) { - if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { - playerNeedToShowCards.push_back((*it_c)->getMyUniqueID()); - } - } + if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { + playerNeedToShowCards.push_back((*it_c)->getMyUniqueID()); + } + } - } + } - else { + else { - // all winners have to show their cards - // playerNeedToShowCards = winners; + // all winners have to show their cards + // playerNeedToShowCards = winners; - // std::_List_const_iterator it_c; + // std::_List_const_iterator it_c; - std::list level; + std::list level; - // for(it_c=winners.begin(); it_c != winners.end(); it_c++) { - // cout << (*it_c) << endl; - // } - // - // cout << "lastActionPlayer" << currentHand->getCurrentBeRo()->getLastActionPlayer() << endl; - // - // int lastActionPlayer = ; - // - // if(lastActionPlayer == -1) { - // lastActionPlayer = 0; - // } - // - // - // + // for(it_c=winners.begin(); it_c != winners.end(); it_c++) { + // cout << (*it_c) << endl; + // } + // + // cout << "lastActionPlayer" << currentHand->getCurrentBeRo()->getLastActionPlayer() << endl; + // + // int lastActionPlayer = ; + // + // if(lastActionPlayer == -1) { + // lastActionPlayer = 0; + // } + // + // + // - PlayerListConstIterator lastActionPlayerIt; - PlayerListConstIterator it_c; + PlayerListConstIterator lastActionPlayerIt; + PlayerListConstIterator it_c; - // cout << "lAP-Ende: " << currentHand->getLastActionPlayer() << endl; - // search lastActionPlayer - for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); ++it_c) { - if((*it_c)->getMyUniqueID() == lastActionPlayer && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { - lastActionPlayerIt = it_c; + // cout << "lAP-Ende: " << currentHand->getLastActionPlayer() << endl; + // search lastActionPlayer + for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); ++it_c) { + if((*it_c)->getMyUniqueID() == lastActionPlayer && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { + lastActionPlayerIt = it_c; // cout << (*it_c)->getMyUniqueID() << endl; - break; - } - } + break; + } + } - if(it_c == activePlayerList->end()) { - for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); ++it_c) { - if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { - lastActionPlayerIt = it_c; - break; - } - } - } + if(it_c == activePlayerList->end()) { + for(it_c = activePlayerList->begin(); it_c != activePlayerList->end(); ++it_c) { + if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { + lastActionPlayerIt = it_c; + break; + } + } + } - // the player who has done the last action has to show his cards first - playerNeedToShowCards.push_back((*lastActionPlayerIt)->getMyUniqueID()); + // the player who has done the last action has to show his cards first + playerNeedToShowCards.push_back((*lastActionPlayerIt)->getMyUniqueID()); // cout << (*lastActionPlayerIt)->getMyUniqueID() << " - " << (*lastActionPlayerIt)->getMyName() << endl; - int *level_tmp = new int[2]; - // get position und cardsValue of the player who show his cards first - level_tmp[0] = (*lastActionPlayerIt)->getMyCardsValueInt(); - level_tmp[1] = (*lastActionPlayerIt)->getMyRoundStartCash()-(*lastActionPlayerIt)->getMyCash(); + int *level_tmp = new int[2]; + // get position und cardsValue of the player who show his cards first + level_tmp[0] = (*lastActionPlayerIt)->getMyCardsValueInt(); + level_tmp[1] = (*lastActionPlayerIt)->getMyRoundStartCash()-(*lastActionPlayerIt)->getMyCash(); - // level_tmp = {(*lastActionPlayerIt)->getMyCardsValueInt(),(*lastActionPlayerIt)->getMyRoundStartCash()-(*lastActionPlayerIt)->getMyCash()}; + // level_tmp = {(*lastActionPlayerIt)->getMyCardsValueInt(),(*lastActionPlayerIt)->getMyRoundStartCash()-(*lastActionPlayerIt)->getMyCash()}; // cout << level_tmp[0] << "," << level_tmp[1] << endl; - level.push_back(level_tmp); + level.push_back(level_tmp); - std::_List_iterator level_it; - std::_List_iterator level_it_tmp; - std::_List_iterator next_level_it; + std::_List_iterator level_it; + std::_List_iterator level_it_tmp; + std::_List_iterator next_level_it; - // PlayerListConstIterator firstAfterLastActionPlayerIt = lastActionPlayerIt; - // firstAfterLastActionPlayerIt++; + // PlayerListConstIterator firstAfterLastActionPlayerIt = lastActionPlayerIt; + // firstAfterLastActionPlayerIt++; - it_c = lastActionPlayerIt; - ++it_c; + it_c = lastActionPlayerIt; + ++it_c; - for(unsigned i = 0; i < activePlayerList->size(); i++) { + for(unsigned i = 0; i < activePlayerList->size(); i++) { - if(it_c == activePlayerList->end()) it_c = activePlayerList->begin(); + if(it_c == activePlayerList->end()) it_c = activePlayerList->begin(); - if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { - // for(it_c = firstAfterLastActionPlayerIt; it_c != lastActionPlayerIt; it_c++) { + if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { + // for(it_c = firstAfterLastActionPlayerIt; it_c != lastActionPlayerIt; it_c++) { - // if(it_c == lastActionPlayerIt) { - // break; - // } - // } - for(level_it = level.begin(); level_it != level.end(); level_it++) { - if((*it_c)->getMyCardsValueInt() > (*level_it)[0]) { - next_level_it = level_it; - next_level_it++; - if(next_level_it == level.end()) { - playerNeedToShowCards.push_back((*it_c)->getMyUniqueID()); - level_tmp = new int[2]; - level_tmp[0] = (*it_c)->getMyCardsValueInt(); - level_tmp[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash(); - level.push_back(level_tmp); - break; - } - } else { - if((*it_c)->getMyCardsValueInt() == (*level_it)[0]) { - next_level_it = level_it; - next_level_it++; + // if(it_c == lastActionPlayerIt) { + // break; + // } + // } + for(level_it = level.begin(); level_it != level.end(); level_it++) { + if((*it_c)->getMyCardsValueInt() > (*level_it)[0]) { + next_level_it = level_it; + next_level_it++; + if(next_level_it == level.end()) { + playerNeedToShowCards.push_back((*it_c)->getMyUniqueID()); + level_tmp = new int[2]; + level_tmp[0] = (*it_c)->getMyCardsValueInt(); + level_tmp[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash(); + level.push_back(level_tmp); + break; + } + } else { + if((*it_c)->getMyCardsValueInt() == (*level_it)[0]) { + next_level_it = level_it; + next_level_it++; // // for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) { // cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl; // } - if(next_level_it == level.end() || (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*next_level_it)[1]) { - playerNeedToShowCards.push_back((*it_c)->getMyUniqueID()); - if((*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*level_it)[1]) { - (*level_it)[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash(); - } - } - break; - } else { - if((*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*level_it)[1]) { - playerNeedToShowCards.push_back((*it_c)->getMyUniqueID()); - level_tmp = new int(2); - level_tmp[0] = (*it_c)->getMyCardsValueInt(); - level_tmp[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash(); + if(next_level_it == level.end() || (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*next_level_it)[1]) { + playerNeedToShowCards.push_back((*it_c)->getMyUniqueID()); + if((*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*level_it)[1]) { + (*level_it)[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash(); + } + } + break; + } else { + if((*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash() > (*level_it)[1]) { + playerNeedToShowCards.push_back((*it_c)->getMyUniqueID()); + level_tmp = new int(2); + level_tmp[0] = (*it_c)->getMyCardsValueInt(); + level_tmp[1] = (*it_c)->getMyRoundStartCash()-(*it_c)->getMyCash(); // // for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) { // cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl; // } - level.insert(level_it,level_tmp); + level.insert(level_it,level_tmp); // for(level_it_tmp = level.begin(); level_it_tmp != level.end(); level_it_tmp++) { // cout << (*level_it_tmp)[0] << "," << (*level_it_tmp)[1] << endl; // } - break; - } - } - } - } + break; + } + } + } + } - } + } - ++it_c; + ++it_c; - } + } - // bool showCards; + // bool showCards; - // search for more player who have to show their cards (perhaps not all situation are considered yet) - // for(it_c = ++lastActionPlayerIt; it_c!=activePlayerList->end(); it_c++) { - // - // showCards = false; - // - //// if((*it_c)->getMyCardsValueInt() >= highestCardsValueInt) { - //// playerNeedToShowCards.push_back((*it_c)->getMyUniqueID()); - //// highestCardsValueInt = (*it_c)->getMyCardsValueInt(); - //// } - // } - // - // for(it_c = activePlayerList->begin(); it_c!=lastActionPlayerIt; it_c++) { - //// if((*it_c)->getMyCardsValueInt() >= highestCardsValueInt) { - //// playerNeedToShowCards.push_back((*it_c)->getMyUniqueID()); - //// highestCardsValueInt = (*it_c)->getMyCardsValueInt(); - //// } - // } + // search for more player who have to show their cards (perhaps not all situation are considered yet) + // for(it_c = ++lastActionPlayerIt; it_c!=activePlayerList->end(); it_c++) { + // + // showCards = false; + // + //// if((*it_c)->getMyCardsValueInt() >= highestCardsValueInt) { + //// playerNeedToShowCards.push_back((*it_c)->getMyUniqueID()); + //// highestCardsValueInt = (*it_c)->getMyCardsValueInt(); + //// } + // } + // + // for(it_c = activePlayerList->begin(); it_c!=lastActionPlayerIt; it_c++) { + //// if((*it_c)->getMyCardsValueInt() >= highestCardsValueInt) { + //// playerNeedToShowCards.push_back((*it_c)->getMyUniqueID()); + //// highestCardsValueInt = (*it_c)->getMyCardsValueInt(); + //// } + // } - } + } - // sort and unique the list - playerNeedToShowCards.sort(); - playerNeedToShowCards.unique(); + // sort and unique the list + playerNeedToShowCards.sort(); + playerNeedToShowCards.unique(); // std::_List_iterator playerNeedToShowCardsIt; // diff --git a/src/engine/local_engine/localboard.h b/src/engine/local_engine/localboard.h index 1367d35c..79e5443d 100755 --- a/src/engine/local_engine/localboard.h +++ b/src/engine/local_engine/localboard.h @@ -30,35 +30,62 @@ class PlayerInterface; class HandInterface; -class LocalBoard : public BoardInterface{ +class LocalBoard : public BoardInterface +{ public: - LocalBoard(unsigned dealerPosition); + LocalBoard(unsigned dealerPosition); ~LocalBoard(); void setPlayerLists(PlayerList, PlayerList, PlayerList); - void setMyCards(int* theValue) { int i; for(i=0; i<5; i++) myCards[i] = theValue[i]; } - void getMyCards(int* theValue) { int i; for(i=0; i<5; i++) theValue[i] = myCards[i]; } + void setMyCards(int* theValue) { + int i; + for(i=0; i<5; i++) myCards[i] = theValue[i]; + } + void getMyCards(int* theValue) { + int i; + for(i=0; i<5; i++) theValue[i] = myCards[i]; + } - void setAllInCondition(bool theValue) { allInCondition = theValue; } - void setLastActionPlayer(unsigned theValue) { lastActionPlayer = theValue; } + void setAllInCondition(bool theValue) { + allInCondition = theValue; + } + void setLastActionPlayer(unsigned theValue) { + lastActionPlayer = theValue; + } - int getPot() const { return pot;} - void setPot(int theValue) { pot = theValue;} - int getSets() const { return sets; } - void setSets(int theValue) { sets = theValue; } + int getPot() const { + return pot; + } + void setPot(int theValue) { + pot = theValue; + } + int getSets() const { + return sets; + } + void setSets(int theValue) { + sets = theValue; + } void collectSets() ; void collectPot() ; void distributePot(); - void determinePlayerNeedToShowCards(); + void determinePlayerNeedToShowCards(); - std::list getWinners() const { return winners; } - void setWinners(const std::list &w) { winners = w; } + std::list getWinners() const { + return winners; + } + void setWinners(const std::list &w) { + winners = w; + } - std::list getPlayerNeedToShowCards() const { return playerNeedToShowCards; } - void setPlayerNeedToShowCards(const std::list &p) { playerNeedToShowCards = p; } + std::list getPlayerNeedToShowCards() const { + return playerNeedToShowCards; + } + void setPlayerNeedToShowCards(const std::list &p) { + playerNeedToShowCards = p; + } private: @@ -67,14 +94,14 @@ private: PlayerList runningPlayerList; std::list winners; - std::list playerNeedToShowCards; + std::list playerNeedToShowCards; int myCards[5]; int pot; int sets; - unsigned dealerPosition; - bool allInCondition; - unsigned lastActionPlayer; + unsigned dealerPosition; + bool allInCondition; + unsigned lastActionPlayer; }; diff --git a/src/engine/local_engine/localenginefactory.cpp b/src/engine/local_engine/localenginefactory.cpp index 68a8d22c..f1378d81 100644 --- a/src/engine/local_engine/localenginefactory.cpp +++ b/src/engine/local_engine/localenginefactory.cpp @@ -32,7 +32,7 @@ LocalEngineFactory::LocalEngineFactory(ConfigFile *c) -: myConfig(c) + : myConfig(c) { } diff --git a/src/engine/local_engine/localhand.cpp b/src/engine/local_engine/localhand.cpp index 6dbf3e49..9f8830fe 100755 --- a/src/engine/local_engine/localhand.cpp +++ b/src/engine/local_engine/localhand.cpp @@ -31,8 +31,8 @@ using namespace std; LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost::shared_ptr b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, unsigned dP, int sB,int sC) -: myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), smallBlindPosition(dP), bigBlindPosition(dP), currentRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(-1), lastActionPlayer(0), allInCondition(false), - cardsShown(false), bettingRoundsPlayed(0) + : myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myBeRo(0), myID(id), startQuantityPlayers(sP), dealerPosition(dP), smallBlindPosition(dP), bigBlindPosition(dP), currentRound(0), smallBlind(sB), startCash(sC), lastPlayersTurn(-1), lastActionPlayer(0), allInCondition(false), + cardsShown(false), bettingRoundsPlayed(0) { int i, j, k; @@ -94,19 +94,19 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: // !!!!!!!!!!!!!!!!!!!!!!!!!!!!! DEBUGGER !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // - if(DEBUG_MODE) { + if(DEBUG_MODE) { - //QSqlDatabase *mySqliteLogDb; + //QSqlDatabase *mySqliteLogDb; - // myGui->getMyW()->getSession(); + // myGui->getMyW()->getSession(); - //QSqlDatabase * test = myGui->getMyLog()->getMySqliteLogDb(); + //QSqlDatabase * test = myGui->getMyLog()->getMySqliteLogDb(); - // if(!mySqliteLogDb->open()) { - // QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel); - // } +// if(!mySqliteLogDb->open()) { +// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel); +// } @@ -114,237 +114,240 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: switch(myID) { - case 1: { + case 1: { - tempBoardArray[0] = 4; - tempBoardArray[1] = 19; - tempBoardArray[2] = 20; - tempBoardArray[3] = 43; - tempBoardArray[4] = 49; - - myBoard->setMyCards(tempBoardArray); - - tempPlayerAndBoardArray[2] = tempBoardArray[0]; - tempPlayerAndBoardArray[3] = tempBoardArray[1]; - tempPlayerAndBoardArray[4] = tempBoardArray[2]; - tempPlayerAndBoardArray[5] = tempBoardArray[3]; - tempPlayerAndBoardArray[6] = tempBoardArray[4]; - - // player0 - it = seatsList->begin(); - - tempPlayerArray[0] = 18; - tempPlayerArray[1] = 17; - tempPlayerAndBoardArray[0] = tempPlayerArray[0]; - tempPlayerAndBoardArray[1] = tempPlayerArray[1]; - - (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); - - (*it)->setMyBestHandPosition(temp5Array); + tempBoardArray[0] = 4; + tempBoardArray[1] = 19; + tempBoardArray[2] = 20; + tempBoardArray[3] = 43; + tempBoardArray[4] = 49; - // player1 - ++it; - - tempPlayerArray[0] = 31; - tempPlayerArray[1] = 8; - tempPlayerAndBoardArray[0] = tempPlayerArray[0]; - tempPlayerAndBoardArray[1] = tempPlayerArray[1]; - - (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); - - (*it)->setMyBestHandPosition(temp5Array); - - // player2 - ++it; - - tempPlayerArray[0] = 26; - tempPlayerArray[1] = 27; - tempPlayerAndBoardArray[0] = tempPlayerArray[0]; - tempPlayerAndBoardArray[1] = tempPlayerArray[1]; - - (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); - - (*it)->setMyBestHandPosition(temp5Array); - - // player3 - ++it; - - tempPlayerArray[0] = 31; - tempPlayerArray[1] = 30; - tempPlayerAndBoardArray[0] = tempPlayerArray[0]; - tempPlayerAndBoardArray[1] = tempPlayerArray[1]; + myBoard->setMyCards(tempBoardArray); - (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + tempPlayerAndBoardArray[2] = tempBoardArray[0]; + tempPlayerAndBoardArray[3] = tempBoardArray[1]; + tempPlayerAndBoardArray[4] = tempBoardArray[2]; + tempPlayerAndBoardArray[5] = tempBoardArray[3]; + tempPlayerAndBoardArray[6] = tempBoardArray[4]; - (*it)->setMyBestHandPosition(temp5Array); + // player0 + it = seatsList->begin(); - // player4 - ++it; - - tempPlayerArray[0] = 50; - tempPlayerArray[1] = 51; - tempPlayerAndBoardArray[0] = tempPlayerArray[0]; - tempPlayerAndBoardArray[1] = tempPlayerArray[1]; - - (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); - - (*it)->setMyBestHandPosition(temp5Array); + tempPlayerArray[0] = 18; + tempPlayerArray[1] = 17; + tempPlayerAndBoardArray[0] = tempPlayerArray[0]; + tempPlayerAndBoardArray[1] = tempPlayerArray[1]; - // player5 - ++it; - - tempPlayerArray[0] = 25; - tempPlayerArray[1] = 24; - tempPlayerAndBoardArray[0] = tempPlayerArray[0]; - tempPlayerAndBoardArray[1] = tempPlayerArray[1]; + (*it)->setMyCards(tempPlayerArray); + (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); - (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + (*it)->setMyBestHandPosition(temp5Array); - (*it)->setMyBestHandPosition(temp5Array); + // player1 + ++it; - // player6 - ++it; - - tempPlayerArray[0] = 38; - tempPlayerArray[1] = 37; - tempPlayerAndBoardArray[0] = tempPlayerArray[0]; - tempPlayerAndBoardArray[1] = tempPlayerArray[1]; - - (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); - - (*it)->setMyBestHandPosition(temp5Array); + tempPlayerArray[0] = 31; + tempPlayerArray[1] = 8; + tempPlayerAndBoardArray[0] = tempPlayerArray[0]; + tempPlayerAndBoardArray[1] = tempPlayerArray[1]; - // player7 - ++it; + (*it)->setMyCards(tempPlayerArray); + (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); - tempPlayerArray[0] = 32; - tempPlayerArray[1] = 33; - tempPlayerAndBoardArray[0] = tempPlayerArray[0]; - tempPlayerAndBoardArray[1] = tempPlayerArray[1]; + (*it)->setMyBestHandPosition(temp5Array); - (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + // player2 + ++it; - (*it)->setMyBestHandPosition(temp5Array); + tempPlayerArray[0] = 26; + tempPlayerArray[1] = 27; + tempPlayerAndBoardArray[0] = tempPlayerArray[0]; + tempPlayerAndBoardArray[1] = tempPlayerArray[1]; - // player8 - ++it; + (*it)->setMyCards(tempPlayerArray); + (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); - tempPlayerArray[0] = 19; - tempPlayerArray[1] = 20; - tempPlayerAndBoardArray[0] = tempPlayerArray[0]; - tempPlayerAndBoardArray[1] = tempPlayerArray[1]; + (*it)->setMyBestHandPosition(temp5Array); - (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + // player3 + ++it; - (*it)->setMyBestHandPosition(temp5Array); + tempPlayerArray[0] = 31; + tempPlayerArray[1] = 30; + tempPlayerAndBoardArray[0] = tempPlayerArray[0]; + tempPlayerAndBoardArray[1] = tempPlayerArray[1]; + + (*it)->setMyCards(tempPlayerArray); + (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + + (*it)->setMyBestHandPosition(temp5Array); + + // player4 + ++it; + + tempPlayerArray[0] = 50; + tempPlayerArray[1] = 51; + tempPlayerAndBoardArray[0] = tempPlayerArray[0]; + tempPlayerAndBoardArray[1] = tempPlayerArray[1]; + + (*it)->setMyCards(tempPlayerArray); + (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + + (*it)->setMyBestHandPosition(temp5Array); + + // player5 + ++it; + + tempPlayerArray[0] = 25; + tempPlayerArray[1] = 24; + tempPlayerAndBoardArray[0] = tempPlayerArray[0]; + tempPlayerAndBoardArray[1] = tempPlayerArray[1]; + + (*it)->setMyCards(tempPlayerArray); + (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + + (*it)->setMyBestHandPosition(temp5Array); + + // player6 + ++it; + + tempPlayerArray[0] = 38; + tempPlayerArray[1] = 37; + tempPlayerAndBoardArray[0] = tempPlayerArray[0]; + tempPlayerAndBoardArray[1] = tempPlayerArray[1]; + + (*it)->setMyCards(tempPlayerArray); + (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + + (*it)->setMyBestHandPosition(temp5Array); + + // player7 + ++it; + + tempPlayerArray[0] = 32; + tempPlayerArray[1] = 33; + tempPlayerAndBoardArray[0] = tempPlayerArray[0]; + tempPlayerAndBoardArray[1] = tempPlayerArray[1]; + + (*it)->setMyCards(tempPlayerArray); + (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + + (*it)->setMyBestHandPosition(temp5Array); + + // player8 + ++it; + + tempPlayerArray[0] = 19; + tempPlayerArray[1] = 20; + tempPlayerAndBoardArray[0] = tempPlayerArray[0]; + tempPlayerAndBoardArray[1] = tempPlayerArray[1]; + + (*it)->setMyCards(tempPlayerArray); + (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); + + (*it)->setMyBestHandPosition(temp5Array); - } break; - case 2: { - -/* tempBoardArray[0] = 48; - tempBoardArray[1] = 21; - tempBoardArray[2] = 4; - tempBoardArray[3] = 9; - tempBoardArray[4] = 0; - - myBoard->setMyCards(tempBoardArray); - - tempPlayerAndBoardArray[2] = tempBoardArray[0]; - tempPlayerAndBoardArray[3] = tempBoardArray[1]; - tempPlayerAndBoardArray[4] = tempBoardArray[2]; - tempPlayerAndBoardArray[5] = tempBoardArray[3]; - tempPlayerAndBoardArray[6] = tempBoardArray[4];*/ - - // player0 - it = seatsList->begin(); - + } + break; + case 2: { + + /* tempBoardArray[0] = 48; + tempBoardArray[1] = 21; + tempBoardArray[2] = 4; + tempBoardArray[3] = 9; + tempBoardArray[4] = 0; + + myBoard->setMyCards(tempBoardArray); + + tempPlayerAndBoardArray[2] = tempBoardArray[0]; + tempPlayerAndBoardArray[3] = tempBoardArray[1]; + tempPlayerAndBoardArray[4] = tempBoardArray[2]; + tempPlayerAndBoardArray[5] = tempBoardArray[3]; + tempPlayerAndBoardArray[6] = tempBoardArray[4];*/ + + // player0 + it = seatsList->begin(); + // tempPlayerArray[0] = 9; // tempPlayerArray[1] = 5; // tempPlayerAndBoardArray[0] = tempPlayerArray[0]; // tempPlayerAndBoardArray[1] = tempPlayerArray[1]; -// +// // (*it)->setMyCards(tempPlayerArray); // (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); -// +// // (*it)->setMyBestHandPosition(temp5Array); - // player1 - ++it; - + // player1 + ++it; + // tempPlayerArray[0] = 47; // tempPlayerArray[1] = 22; // tempPlayerAndBoardArray[0] = tempPlayerArray[0]; // tempPlayerAndBoardArray[1] = tempPlayerArray[1]; -// +// // (*it)->setMyCards(tempPlayerArray); // (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); -// +// // (*it)->setMyBestHandPosition(temp5Array); - - // player2 - ++it; - + + // player2 + ++it; + // tempPlayerArray[0] = 33; // tempPlayerArray[1] = 27; // tempPlayerAndBoardArray[0] = tempPlayerArray[0]; // tempPlayerAndBoardArray[1] = tempPlayerArray[1]; -// +// // (*it)->setMyCards(tempPlayerArray); // (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); -// +// // (*it)->setMyBestHandPosition(temp5Array); - - // player3 - ++it; - + + // player3 + ++it; + // tempPlayerArray[0] = 38; // tempPlayerArray[1] = 22; // tempPlayerAndBoardArray[0] = tempPlayerArray[0]; // tempPlayerAndBoardArray[1] = tempPlayerArray[1]; -// +// // (*it)->setMyCards(tempPlayerArray); // (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); -// +// // (*it)->setMyBestHandPosition(temp5Array); - // player4 - ++it; - + // player4 + ++it; + // tempPlayerArray[0] = 25; // tempPlayerArray[1] = 16; // tempPlayerAndBoardArray[0] = tempPlayerArray[0]; // tempPlayerAndBoardArray[1] = tempPlayerArray[1]; -// +// // (*it)->setMyCards(tempPlayerArray); // (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); -// +// // (*it)->setMyBestHandPosition(temp5Array); - // player5 - ++it; - + // player5 + ++it; + // tempPlayerArray[0] = 27; // tempPlayerArray[1] = 10; // tempPlayerAndBoardArray[0] = tempPlayerArray[0]; // tempPlayerAndBoardArray[1] = tempPlayerArray[1]; -// +// // (*it)->setMyCards(tempPlayerArray); // (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); -// +// // (*it)->setMyBestHandPosition(temp5Array); - } break; - default: {} + } + break; + default: + {} } @@ -356,7 +359,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, boost: // determine dealer, SB, BB assignButtons(); - myLog->logNewHandMsg(myID, dealerPosition, smallBlind, smallBlindPosition, 2*smallBlind, bigBlindPosition, seatsList); + myLog->logNewHandMsg(myID, dealerPosition, smallBlind, smallBlindPosition, 2*smallBlind, bigBlindPosition, seatsList); myBeRo = myFactory->createBeRo(this, myID, dealerPosition, smallBlind); } @@ -367,29 +370,32 @@ LocalHand::~LocalHand() { } -void LocalHand::start() { +void LocalHand::start() +{ //Log blinds sets for new Hand PlayerListConstIterator it_sB, it_bB; it_sB = getActivePlayerIt(getCurrentBeRo()->getSmallBlindPositionId()); it_bB = getActivePlayerIt(getCurrentBeRo()->getBigBlindPositionId()); if(it_sB != getActivePlayerList()->end() && it_bB != getActivePlayerList()->end()) { - myGui->logNewBlindsSetsMsg((*it_sB)->getMySet(), (*it_bB)->getMySet(), (*it_sB)->getMyName().c_str(), (*it_bB)->getMyName().c_str()); - } - else { LOG_ERROR(__FILE__ << " (" << __LINE__ << "): Log Error: cannot find sBID or bBID"); } - myGui->flushLogAtHand(); + myGui->logNewBlindsSetsMsg((*it_sB)->getMySet(), (*it_bB)->getMySet(), (*it_sB)->getMyName().c_str(), (*it_bB)->getMyName().c_str()); + } else { + LOG_ERROR(__FILE__ << " (" << __LINE__ << "): Log Error: cannot find sBID or bBID"); + } + myGui->flushLogAtHand(); // deal cards myGui->dealHoleCards(); getBoard()->collectSets(); getGuiInterface()->refreshPot(); - + // change rounds | first start preflop myGui->nextPlayerAnimation(); } -void LocalHand::assignButtons() { +void LocalHand::assignButtons() +{ size_t i; PlayerListIterator it; @@ -424,33 +430,33 @@ void LocalHand::assignButtons() { it = getActivePlayerIt( (*dealerPositionIt)->getMyUniqueID() ); if(it != activePlayerList->end() ) { nextActivePlayerFound = true; - if(activePlayerList->size() > 2) { - //small blind normal - (*it)->setMyButton(2); - smallBlindPosition = (*it)->getMyUniqueID(); - } else { - //big blind in heads up - (*it)->setMyButton(3); - bigBlindPosition = (*it)->getMyUniqueID(); - // lastPlayerAction for showing cards - } + if(activePlayerList->size() > 2) { + //small blind normal + (*it)->setMyButton(2); + smallBlindPosition = (*it)->getMyUniqueID(); + } else { + //big blind in heads up + (*it)->setMyButton(3); + bigBlindPosition = (*it)->getMyUniqueID(); + // lastPlayerAction for showing cards + } - // first player after dealer have to show his cards first (in showdown) - lastActionPlayer = (*it)->getMyUniqueID(); - myBoard->setLastActionPlayer(lastActionPlayer); + // first player after dealer have to show his cards first (in showdown) + lastActionPlayer = (*it)->getMyUniqueID(); + myBoard->setLastActionPlayer(lastActionPlayer); ++it; if(it == activePlayerList->end()) it = activePlayerList->begin(); - if(activePlayerList->size() > 2) { - //big blind normal - (*it)->setMyButton(3); - bigBlindPosition = (*it)->getMyUniqueID(); - } else { - //small blind in heads up - (*it)->setMyButton(2); - smallBlindPosition = (*it)->getMyUniqueID(); - } + if(activePlayerList->size() > 2) { + //big blind normal + (*it)->setMyButton(3); + bigBlindPosition = (*it)->getMyUniqueID(); + } else { + //small blind in heads up + (*it)->setMyButton(2); + smallBlindPosition = (*it)->getMyUniqueID(); + } break; } @@ -466,7 +472,7 @@ void LocalHand::assignButtons() { for (it_c=runningPlayerList->begin(); it_c!=runningPlayerList->end(); ++it_c) { //small blind - if((*it_c)->getMyButton() == BUTTON_SMALL_BLIND) { + if((*it_c)->getMyButton() == BUTTON_SMALL_BLIND) { // All in ? if((*it_c)->getMyCash() <= smallBlind) { @@ -475,24 +481,22 @@ void LocalHand::assignButtons() { // 1 to do not log this (*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1); - } - else { + } else { (*it_c)->setMySet(smallBlind); } } //big blind - if((*it_c)->getMyButton() == BUTTON_BIG_BLIND) { - + if((*it_c)->getMyButton() == BUTTON_BIG_BLIND) { + // all in ? if((*it_c)->getMyCash() <= 2*smallBlind) { (*it_c)->setMySet((*it_c)->getMyCash()); // 1 to do not log this (*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1); - - } - else { + + } else { (*it_c)->setMySet(2*smallBlind); } } @@ -500,7 +504,8 @@ void LocalHand::assignButtons() { } -void LocalHand::switchRounds() { +void LocalHand::switchRounds() +{ PlayerListIterator it, it_1; PlayerListConstIterator it_c; @@ -537,10 +542,10 @@ void LocalHand::switchRounds() { // if only one player non-fold -> distribute pot if(nonFoldPlayerCounter==1) { - myBoard->collectPot(); + myBoard->collectPot(); myGui->refreshPot(); myGui->refreshSet(); - currentRound = 4; + currentRound = 4; } // check for all in condition @@ -550,7 +555,7 @@ void LocalHand::switchRounds() { // 1) all players all in if(allInPlayersCounter == nonFoldPlayerCounter) { allInCondition = true; - myBoard->setAllInCondition(true); + myBoard->setAllInCondition(true); } // 2) all players but one all in and he has highest set @@ -559,64 +564,64 @@ void LocalHand::switchRounds() { for(it_c=runningPlayerList->begin(); it_c!=runningPlayerList->end(); ++it_c) { if((*it_c)->getMySet() >= myBeRo[currentRound]->getHighestSet()) { - allInCondition = true; - myBoard->setAllInCondition(true); + allInCondition = true; + myBoard->setAllInCondition(true); } } // exception - // no.1: if in first Preflop Round next player is small blind and only all-in-big-blind with less than smallblind amount and other all-in players with less than small blind are nonfold too -> preflop is over - PlayerListConstIterator smallBlindIt_c = getRunningPlayerIt(myBeRo[currentRound]->getSmallBlindPositionId()); - PlayerListConstIterator bigBlindIt_c = getActivePlayerIt(myBeRo[currentRound]->getBigBlindPositionId()); - if(smallBlindIt_c!=runningPlayerList->end() && bigBlindIt_c!=activePlayerList->end() && currentRound == GAME_STATE_PREFLOP && myBeRo[currentRound]->getFirstRound()) { - // determine player who are all in with less than small blind amount - int tempCounter = 0; - for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - if((*it_c)->getMyAction() == PLAYER_ACTION_ALLIN && (*it_c)->getMySet() <= smallBlind) { - tempCounter++; - } - } - if( (*bigBlindIt_c)->getMySet() <= smallBlind && tempCounter == allInPlayersCounter) { - allInCondition = true; - myBoard->setAllInCondition(true); - } - } - - // no.2: heads up -> detect player who is all in and bb but could set less than sb + // no.1: if in first Preflop Round next player is small blind and only all-in-big-blind with less than smallblind amount and other all-in players with less than small blind are nonfold too -> preflop is over + PlayerListConstIterator smallBlindIt_c = getRunningPlayerIt(myBeRo[currentRound]->getSmallBlindPositionId()); + PlayerListConstIterator bigBlindIt_c = getActivePlayerIt(myBeRo[currentRound]->getBigBlindPositionId()); + if(smallBlindIt_c!=runningPlayerList->end() && bigBlindIt_c!=activePlayerList->end() && currentRound == GAME_STATE_PREFLOP && myBeRo[currentRound]->getFirstRound()) { + // determine player who are all in with less than small blind amount + int tempCounter = 0; for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - - if(activePlayerList->size()==2 && (*it_c)->getMyAction() == PLAYER_ACTION_ALLIN && (*it_c)->getMyButton()==BUTTON_BIG_BLIND && (*it_c)->getMySet()<=smallBlind && currentRound == GAME_STATE_PREFLOP) { - allInCondition = true; - myBoard->setAllInCondition(true); + if((*it_c)->getMyAction() == PLAYER_ACTION_ALLIN && (*it_c)->getMySet() <= smallBlind) { + tempCounter++; } } + if( (*bigBlindIt_c)->getMySet() <= smallBlind && tempCounter == allInPlayersCounter) { + allInCondition = true; + myBoard->setAllInCondition(true); + } + } + + // no.2: heads up -> detect player who is all in and bb but could set less than sb + for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { + + if(activePlayerList->size()==2 && (*it_c)->getMyAction() == PLAYER_ACTION_ALLIN && (*it_c)->getMyButton()==BUTTON_BIG_BLIND && (*it_c)->getMySet()<=smallBlind && currentRound == GAME_STATE_PREFLOP) { + allInCondition = true; + myBoard->setAllInCondition(true); + } + } } } // special routine if(allInCondition) { - myBoard->collectPot(); + myBoard->collectPot(); myGui->refreshPot(); myGui->refreshSet(); myGui->flipHolecardsAllIn(); - + if (currentRound < 4) // do not increment past 4 currentRound++; - + //log board cards for allin if(currentRound >= 1) { int tempBoardCardsArray[5]; - + myBoard->getMyCards(tempBoardCardsArray); myGui->logDealBoardCardsMsg(currentRound, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3], tempBoardCardsArray[4]); } - + } //unhighlight current players groupbox it_c = getActivePlayerIt(lastPlayersTurn); - if( it_c != activePlayerList->end() ) { + if( it_c != activePlayerList->end() ) { // lastPlayersTurn is active myGui->refreshGroupbox(lastPlayersTurn,1); } @@ -624,38 +629,45 @@ void LocalHand::switchRounds() { myGui->refreshGameLabels((GameState)getCurrentRound()); switch(currentRound) { - case 0: { - // start preflop - myGui->preflopAnimation1(); - } break; - case 1: { - // start flop - myGui->flopAnimation1(); - } break; - case 2: { - // start turn - myGui->turnAnimation1(); + case 0: { + // start preflop + myGui->preflopAnimation1(); + } + break; + case 1: { + // start flop + myGui->flopAnimation1(); + } + break; + case 2: { + // start turn + myGui->turnAnimation1(); - } break; - case 3: { - // start river - myGui->riverAnimation1(); + } + break; + case 3: { + // start river + myGui->riverAnimation1(); - } break; - case 4: { - // start post river - myGui->postRiverAnimation1(); + } + break; + case 4: { + // start post river + myGui->postRiverAnimation1(); + + } + break; + default: + {} - } break; - default: {} - } } -PlayerListIterator LocalHand::getSeatIt(unsigned uniqueId) const { +PlayerListIterator LocalHand::getSeatIt(unsigned uniqueId) const +{ PlayerListIterator it; @@ -669,7 +681,8 @@ PlayerListIterator LocalHand::getSeatIt(unsigned uniqueId) const { } -PlayerListIterator LocalHand::getActivePlayerIt(unsigned uniqueId) const { +PlayerListIterator LocalHand::getActivePlayerIt(unsigned uniqueId) const +{ PlayerListIterator it; @@ -683,7 +696,8 @@ PlayerListIterator LocalHand::getActivePlayerIt(unsigned uniqueId) const { } -PlayerListIterator LocalHand::getRunningPlayerIt(unsigned uniqueId) const { +PlayerListIterator LocalHand::getRunningPlayerIt(unsigned uniqueId) const +{ PlayerListIterator it; @@ -698,7 +712,8 @@ PlayerListIterator LocalHand::getRunningPlayerIt(unsigned uniqueId) const { } -void LocalHand::setLastActionPlayer(unsigned theValue) { - lastActionPlayer = theValue; - myBoard->setLastActionPlayer(theValue); +void LocalHand::setLastActionPlayer(unsigned theValue) +{ + lastActionPlayer = theValue; + myBoard->setLastActionPlayer(theValue); } diff --git a/src/engine/local_engine/localhand.h b/src/engine/local_engine/localhand.h index 4734ca44..197cdaad 100755 --- a/src/engine/local_engine/localhand.h +++ b/src/engine/local_engine/localhand.h @@ -31,57 +31,120 @@ class Log; -class LocalHand : public HandInterface{ +class LocalHand : public HandInterface +{ public: LocalHand(boost::shared_ptr f, GuiInterface*, boost::shared_ptr, Log*, PlayerList, PlayerList, PlayerList, int, int, unsigned, int, int); ~LocalHand(); void start(); - PlayerList getSeatsList() const {return seatsList;} - PlayerList getActivePlayerList() const {return activePlayerList;} - PlayerList getRunningPlayerList() const {return runningPlayerList;} + PlayerList getSeatsList() const { + return seatsList; + } + PlayerList getActivePlayerList() const { + return activePlayerList; + } + PlayerList getRunningPlayerList() const { + return runningPlayerList; + } - boost::shared_ptr getBoard() const { return myBoard; } - boost::shared_ptr getPreflop() const { return myBeRo[GAME_STATE_PREFLOP]; } - boost::shared_ptr getFlop() const { return myBeRo[GAME_STATE_FLOP]; } - boost::shared_ptr getTurn() const { return myBeRo[GAME_STATE_TURN]; } - boost::shared_ptr getRiver() const { return myBeRo[GAME_STATE_RIVER]; } - GuiInterface* getGuiInterface() const { return myGui; } - boost::shared_ptr getCurrentBeRo() const { return myBeRo[currentRound]; } + boost::shared_ptr getBoard() const { + return myBoard; + } + boost::shared_ptr getPreflop() const { + return myBeRo[GAME_STATE_PREFLOP]; + } + boost::shared_ptr getFlop() const { + return myBeRo[GAME_STATE_FLOP]; + } + boost::shared_ptr getTurn() const { + return myBeRo[GAME_STATE_TURN]; + } + boost::shared_ptr getRiver() const { + return myBeRo[GAME_STATE_RIVER]; + } + GuiInterface* getGuiInterface() const { + return myGui; + } + boost::shared_ptr getCurrentBeRo() const { + return myBeRo[currentRound]; + } - void setMyID(int theValue) { myID = theValue; } - int getMyID() const { return myID; } + void setMyID(int theValue) { + myID = theValue; + } + int getMyID() const { + return myID; + } - void setStartQuantityPlayers(int theValue) { startQuantityPlayers = theValue; } - int getStartQuantityPlayers() const { return startQuantityPlayers; } + void setStartQuantityPlayers(int theValue) { + startQuantityPlayers = theValue; + } + int getStartQuantityPlayers() const { + return startQuantityPlayers; + } - void setCurrentRound(int theValue) { currentRound = theValue; } - int getCurrentRound() const { return currentRound; } + void setCurrentRound(int theValue) { + currentRound = theValue; + } + int getCurrentRound() const { + return currentRound; + } - void setDealerPosition(int theValue) { dealerPosition = theValue; } - int getDealerPosition() const { return dealerPosition; } + void setDealerPosition(int theValue) { + dealerPosition = theValue; + } + int getDealerPosition() const { + return dealerPosition; + } - void setSmallBlind(int theValue) { smallBlind = theValue; } - int getSmallBlind() const { return smallBlind; } + void setSmallBlind(int theValue) { + smallBlind = theValue; + } + int getSmallBlind() const { + return smallBlind; + } - void setAllInCondition(bool theValue) { allInCondition = theValue; } - bool getAllInCondition() const { return allInCondition; } + void setAllInCondition(bool theValue) { + allInCondition = theValue; + } + bool getAllInCondition() const { + return allInCondition; + } - void setStartCash(int theValue) { startCash = theValue; } - int getStartCash() const { return startCash; } - - void setBettingRoundsPlayed(int theValue) { bettingRoundsPlayed = theValue; } - int getBettingRoundsPlayed() const { return bettingRoundsPlayed; } + void setStartCash(int theValue) { + startCash = theValue; + } + int getStartCash() const { + return startCash; + } - void setLastPlayersTurn(int theValue) { lastPlayersTurn = theValue; } - int getLastPlayersTurn() const { return lastPlayersTurn; } + void setBettingRoundsPlayed(int theValue) { + bettingRoundsPlayed = theValue; + } + int getBettingRoundsPlayed() const { + return bettingRoundsPlayed; + } + + void setLastPlayersTurn(int theValue) { + lastPlayersTurn = theValue; + } + int getLastPlayersTurn() const { + return lastPlayersTurn; + } void setLastActionPlayer ( unsigned theValue ); - unsigned getLastActionPlayer() const { return lastActionPlayer; } + unsigned getLastActionPlayer() const { + return lastActionPlayer; + } - void setCardsShown(bool theValue) { cardsShown = theValue; } - bool getCardsShown() const { return cardsShown; } + void setCardsShown(bool theValue) { + cardsShown = theValue; + } + bool getCardsShown() const { + return cardsShown; + } void assignButtons(); @@ -97,25 +160,25 @@ private: boost::shared_ptr myFactory; GuiInterface *myGui; boost::shared_ptr myBoard; - Log *myLog; + Log *myLog; - PlayerList seatsList; // all player - PlayerList activePlayerList; // all player who are not out - PlayerList runningPlayerList; // all player who are not folded, not all in and not out + PlayerList seatsList; // all player + PlayerList activePlayerList; // all player who are not out + PlayerList runningPlayerList; // all player who are not folded, not all in and not out std::vector > myBeRo; int myID; int startQuantityPlayers; unsigned dealerPosition; - unsigned smallBlindPosition; - unsigned bigBlindPosition; + unsigned smallBlindPosition; + unsigned bigBlindPosition; int currentRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river int smallBlind; int startCash; int lastPlayersTurn; - unsigned lastActionPlayer; + unsigned lastActionPlayer; bool allInCondition; bool cardsShown; diff --git a/src/engine/local_engine/localplayer.cpp b/src/engine/local_engine/localplayer.cpp index 80fbec9e..e5445ecc 100755 --- a/src/engine/local_engine/localplayer.cpp +++ b/src/engine/local_engine/localplayer.cpp @@ -29,821 +29,818 @@ using namespace std; -struct RoundData -{ - int hand; - double data[4]; +struct RoundData { + int hand; + double data[4]; }; -static const RoundData PreflopValues[] = -{ - { 0, { 0.392398, 0.276545, 0.212940, 0.178564 } }, - { 10, { 0.341141, 0.213735, 0.153802, 0.121123 } }, - { 11, { 0.374930, 0.252093, 0.194671, 0.161691 } }, - { 20, { 0.351826, 0.220031, 0.160432, 0.127509 } }, - { 21, { 0.385048, 0.260354, 0.200738, 0.167674 } }, - { 30, { 0.362845, 0.227411, 0.167515, 0.132691 } }, - { 31, { 0.393682, 0.265876, 0.207630, 0.172295 } }, - { 40, { 0.364174, 0.220155, 0.158920, 0.124233 } }, - { 41, { 0.395005, 0.261673, 0.199692, 0.165581 } }, - { 50, { 0.368042, 0.220327, 0.157511, 0.119645 } }, - { 51, { 0.403993, 0.258386, 0.197324, 0.159935 } }, - { 60, { 0.389178, 0.234286, 0.164548, 0.126870 } }, - { 61, { 0.418772, 0.270658, 0.204814, 0.167860 } }, - { 70, { 0.411282, 0.248507, 0.175819, 0.133796 } }, - { 71, { 0.441392, 0.285024, 0.216091, 0.174384 } }, - { 80, { 0.440480, 0.268060, 0.190030, 0.147938 } }, - { 81, { 0.467023, 0.302555, 0.231871, 0.188436 } }, - { 90, { 0.467598, 0.292983, 0.206409, 0.159414 } }, - { 91, { 0.492893, 0.327706, 0.247315, 0.200483 } }, - { 100, { 0.500946, 0.321231, 0.229723, 0.176626 } }, - { 101, { 0.523507, 0.354234, 0.266130, 0.216512 } }, - { 110, { 0.546298, 0.361122, 0.262676, 0.202235 } }, - { 111, { 0.564731, 0.391539, 0.300782, 0.241582 } }, - { 120, { 0.612210, 0.437722, 0.333962, 0.266613 } }, - { 121, { 0.631711, 0.466625, 0.370526, 0.302552 } }, - { 1010, { 0.425249, 0.294167, 0.227440, 0.189070 } }, - { 1020, { 0.368338, 0.236502, 0.175148, 0.141144 } }, - { 1021, { 0.398522, 0.274875, 0.213918, 0.181193 } }, - { 1030, { 0.380584, 0.244160, 0.183336, 0.148602 } }, - { 1031, { 0.411600, 0.280911, 0.221748, 0.185122 } }, - { 1040, { 0.379182, 0.238104, 0.174768, 0.138399 } }, - { 1041, { 0.410886, 0.274157, 0.214447, 0.178769 } }, - { 1050, { 0.388704, 0.236244, 0.169994, 0.133749 } }, - { 1051, { 0.416815, 0.269452, 0.210729, 0.172591 } }, - { 1060, { 0.396943, 0.237112, 0.169488, 0.130860 } }, - { 1061, { 0.425483, 0.274880, 0.208163, 0.171587 } }, - { 1070, { 0.421637, 0.255125, 0.181848, 0.138975 } }, - { 1071, { 0.447019, 0.291320, 0.219969, 0.180664 } }, - { 1080, { 0.448126, 0.274144, 0.196289, 0.151646 } }, - { 1081, { 0.473606, 0.310826, 0.235919, 0.190739 } }, - { 1090, { 0.478501, 0.298148, 0.212041, 0.163683 } }, -{ 1091, { 0.504431, 0.333231, 0.251471, 0.204792 } }, -{ 1100, { 0.510525, 0.327482, 0.234555, 0.180396 } }, -{ 1101, { 0.532065, 0.360810, 0.270922, 0.220332 } }, -{ 1110, { 0.553686, 0.367362, 0.268589, 0.207489 } }, -{ 1111, { 0.576153, 0.400387, 0.303690, 0.247722 } }, -{ 1120, { 0.621342, 0.446336, 0.343233, 0.273911 } }, -{ 1121, { 0.637968, 0.474715, 0.373390, 0.310121 } }, -{ 2020, { 0.458947, 0.313939, 0.242610, 0.200423 } }, -{ 2030, { 0.398033, 0.259838, 0.198458, 0.161070 } }, -{ 2031, { 0.425525, 0.293960, 0.235756, 0.199501 } }, -{ 2040, { 0.397817, 0.255376, 0.190636, 0.154640 } }, -{ 2041, { 0.425873, 0.292207, 0.228006, 0.194654 } }, -{ 2050, { 0.405126, 0.253793, 0.186274, 0.148799 } }, -{ 2051, { 0.434334, 0.290140, 0.224181, 0.187256 } }, -{ 2060, { 0.415893, 0.254033, 0.183065, 0.144964 } }, -{ 2061, { 0.442020, 0.289907, 0.223390, 0.183388 } }, -{ 2070, { 0.431662, 0.261557, 0.186207, 0.143897 } }, -{ 2071, { 0.458148, 0.295690, 0.221357, 0.182633 } }, -{ 2080, { 0.458244, 0.283182, 0.202632, 0.158355 } }, -{ 2081, { 0.485387, 0.317359, 0.244065, 0.197194 } }, -{ 2090, { 0.486843, 0.305900, 0.219227, 0.169682 } }, -{ 2091, { 0.509158, 0.336822, 0.255117, 0.209493 } }, -{ 2100, { 0.520532, 0.334651, 0.241959, 0.186116 } }, -{ 2101, { 0.544106, 0.367181, 0.277500, 0.224167 } }, -{ 2110, { 0.562867, 0.376359, 0.275377, 0.213308 } }, -{ 2111, { 0.583419, 0.408087, 0.311465, 0.251205 } }, -{ 2120, { 0.631754, 0.455162, 0.349977, 0.281266 } }, -{ 2121, { 0.647554, 0.478675, 0.382699, 0.318028 } }, -{ 3030, { 0.491574, 0.334918, 0.260822, 0.215129 } }, -{ 3040, { 0.415659, 0.266638, 0.203475, 0.168118 } }, -{ 3041, { 0.440987, 0.306280, 0.241409, 0.206000 } }, -{ 3050, { 0.420281, 0.269759, 0.202282, 0.163709 } }, -{ 3051, { 0.446296, 0.302118, 0.239135, 0.202622 } }, -{ 3060, { 0.434861, 0.270280, 0.199293, 0.158721 } }, -{ 3061, { 0.457776, 0.306309, 0.238337, 0.200351 } }, -{ 3070, { 0.445102, 0.275557, 0.201226, 0.157838 } }, -{ 3071, { 0.471762, 0.310139, 0.239625, 0.197345 } }, -{ 3080, { 0.468139, 0.289426, 0.208934, 0.162483 } }, -{ 3081, { 0.491828, 0.325417, 0.244964, 0.199125 } }, -{ 3090, { 0.499743, 0.313642, 0.227720, 0.176322 } }, -{ 3091, { 0.521336, 0.347760, 0.262093, 0.214462 } }, -{ 3100, { 0.534472, 0.344431, 0.248543, 0.193602 } }, -{ 3101, { 0.553252, 0.374123, 0.284209, 0.232423 } }, -{ 3110, { 0.573378, 0.384744, 0.283403, 0.220253 } }, -{ 3111, { 0.588956, 0.415055, 0.318031, 0.259790 } }, -{ 3120, { 0.641023, 0.464428, 0.359995, 0.290579 } }, -{ 3121, { 0.657020, 0.489627, 0.389187, 0.322193 } }, -{ 4040, { 0.516006, 0.359183, 0.277032, 0.228881 } }, -{ 4050, { 0.435729, 0.282211, 0.212923, 0.174751 } }, -{ 4051, { 0.462412, 0.313824, 0.249562, 0.212472 } }, -{ 4060, { 0.447638, 0.285155, 0.212276, 0.172773 } }, -{ 4061, { 0.470266, 0.319709, 0.250671, 0.208987 } }, -{ 4070, { 0.460265, 0.288142, 0.213646, 0.171749 } }, -{ 4071, { 0.487225, 0.324893, 0.250578, 0.208518 } }, -{ 4080, { 0.482136, 0.303300, 0.219496, 0.173420 } }, -{ 4081, { 0.502701, 0.334032, 0.255191, 0.211497 } }, -{ 4090, { 0.504535, 0.319118, 0.230051, 0.180925 } }, -{ 4091, { 0.530570, 0.355567, 0.265668, 0.219096 } }, -{ 4100, { 0.539041, 0.348698, 0.254279, 0.198336 } }, -{ 4101, { 0.560032, 0.381288, 0.289776, 0.233638 } }, -{ 4110, { 0.582704, 0.393881, 0.290373, 0.226942 } }, -{ 4111, { 0.598407, 0.422241, 0.321170, 0.263919 } }, -{ 4120, { 0.642734, 0.464127, 0.357691, 0.287758 } }, -{ 4121, { 0.659588, 0.488409, 0.390229, 0.321964 } }, -{ 5050, { 0.549268, 0.382451, 0.297085, 0.244325 } }, -{ 5060, { 0.461289, 0.298799, 0.224119, 0.184892 } }, -{ 5061, { 0.485634, 0.330149, 0.263757, 0.223014 } }, -{ 5070, { 0.473494, 0.303907, 0.228508, 0.183815 } }, -{ 5071, { 0.499667, 0.340404, 0.266624, 0.219160 } }, -{ 5080, { 0.497160, 0.318137, 0.235993, 0.189195 } }, -{ 5081, { 0.519271, 0.346657, 0.273157, 0.225601 } }, -{ 5090, { 0.519085, 0.333791, 0.244852, 0.193839 } }, -{ 5091, { 0.545203, 0.363052, 0.280410, 0.228881 } }, -{ 5100, { 0.548230, 0.359064, 0.263356, 0.204509 } }, -{ 5101, { 0.565488, 0.387187, 0.295925, 0.242237 } }, -{ 5110, { 0.591864, 0.402174, 0.298403, 0.235400 } }, -{ 5111, { 0.608657, 0.431376, 0.331219, 0.269897 } }, -{ 5120, { 0.652519, 0.476460, 0.368421, 0.296733 } }, -{ 5121, { 0.666606, 0.497720, 0.396138, 0.331399 } }, -{ 6060, { 0.572002, 0.405822, 0.316323, 0.263300 } }, -{ 6070, { 0.490941, 0.317838, 0.241244, 0.198071 } }, -{ 6071, { 0.511400, 0.351731, 0.277871, 0.233745 } }, -{ 6080, { 0.513155, 0.333109, 0.251517, 0.203524 } }, -{ 6081, { 0.534313, 0.364968, 0.284903, 0.239425 } }, -{ 6090, { 0.535497, 0.351791, 0.262208, 0.209001 } }, -{ 6091, { 0.555172, 0.379223, 0.294741, 0.242575 } }, -{ 6100, { 0.564425, 0.375204, 0.277724, 0.220820 } }, -{ 6101, { 0.585780, 0.404858, 0.309063, 0.255885 } }, -{ 6110, { 0.601187, 0.412856, 0.307546, 0.243076 } }, -{ 6111, { 0.619748, 0.439626, 0.340543, 0.278683 } }, -{ 6120, { 0.663506, 0.484994, 0.379012, 0.308522 } }, -{ 6121, { 0.672680, 0.508199, 0.406539, 0.338819 } }, -{ 7070, { 0.602459, 0.432679, 0.339776, 0.280706 } }, -{ 7080, { 0.525674, 0.349554, 0.266348, 0.218304 } }, -{ 7081, { 0.546982, 0.380494, 0.299939, 0.252933 } }, -{ 7090, { 0.550741, 0.367646, 0.277965, 0.224762 } }, -{ 7091, { 0.570817, 0.396292, 0.308852, 0.257872 } }, -{ 7100, { 0.578107, 0.392576, 0.296196, 0.237797 } }, -{ 7101, { 0.597385, 0.417610, 0.325814, 0.269943 } }, -{ 7110, { 0.616725, 0.429318, 0.326413, 0.260805 } }, -{ 7111, { 0.633622, 0.455894, 0.358718, 0.295226 } }, -{ 7120, { 0.673638, 0.496498, 0.389773, 0.317947 } }, -{ 7121, { 0.685843, 0.518038, 0.416296, 0.347696 } }, -{ 8080, { 0.633155, 0.462777, 0.368277, 0.305162 } }, -{ 8090, { 0.569903, 0.386443, 0.299307, 0.246643 } }, -{ 8091, { 0.582209, 0.415800, 0.328378, 0.277974 } }, -{ 8100, { 0.597204, 0.413220, 0.317080, 0.258892 } }, -{ 8101, { 0.612997, 0.437354, 0.344853, 0.288854 } }, -{ 8110, { 0.632288, 0.447764, 0.345514, 0.281554 } }, -{ 8111, { 0.651514, 0.473083, 0.372330, 0.311285 } }, -{ 8120, { 0.689345, 0.516179, 0.410605, 0.339648 } }, -{ 8121, { 0.700118, 0.537866, 0.439058, 0.369618 } }, -{ 9090, { 0.660660, 0.495556, 0.396267, 0.332142 } }, -{ 9100, { 0.606741, 0.425296, 0.327092, 0.266201 } }, -{ 9101, { 0.626335, 0.449237, 0.357001, 0.298544 } }, -{ 9110, { 0.645998, 0.460582, 0.357830, 0.289691 } }, -{ 9111, { 0.657509, 0.486536, 0.383815, 0.322174 } }, -{ 9120, { 0.699304, 0.529890, 0.420874, 0.350739 } }, -{ 9121, { 0.711152, 0.550163, 0.444167, 0.379029 } }, -{ 10100, { 0.698831, 0.534374, 0.436462, 0.369034 } }, -{ 10110, { 0.660376, 0.479650, 0.373328, 0.304814 } }, -{ 10111, { 0.677518, 0.502799, 0.401653, 0.334030 } }, -{ 10120, { 0.718249, 0.550870, 0.440722, 0.365350 } }, -{ 10121, { 0.732486, 0.566302, 0.463868, 0.391412 } }, -{ 11110, { 0.757306, 0.604317, 0.501322, 0.428978 } }, -{ 11120, { 0.745230, 0.580949, 0.472283, 0.393985 } }, -{ 11121, { 0.754219, 0.599772, 0.495033, 0.416241 } }, -{ 12120, { 0.855608, 0.736617, 0.642366, 0.562044 } } +static const RoundData PreflopValues[] = { + { 0, { 0.392398, 0.276545, 0.212940, 0.178564 } }, + { 10, { 0.341141, 0.213735, 0.153802, 0.121123 } }, + { 11, { 0.374930, 0.252093, 0.194671, 0.161691 } }, + { 20, { 0.351826, 0.220031, 0.160432, 0.127509 } }, + { 21, { 0.385048, 0.260354, 0.200738, 0.167674 } }, + { 30, { 0.362845, 0.227411, 0.167515, 0.132691 } }, + { 31, { 0.393682, 0.265876, 0.207630, 0.172295 } }, + { 40, { 0.364174, 0.220155, 0.158920, 0.124233 } }, + { 41, { 0.395005, 0.261673, 0.199692, 0.165581 } }, + { 50, { 0.368042, 0.220327, 0.157511, 0.119645 } }, + { 51, { 0.403993, 0.258386, 0.197324, 0.159935 } }, + { 60, { 0.389178, 0.234286, 0.164548, 0.126870 } }, + { 61, { 0.418772, 0.270658, 0.204814, 0.167860 } }, + { 70, { 0.411282, 0.248507, 0.175819, 0.133796 } }, + { 71, { 0.441392, 0.285024, 0.216091, 0.174384 } }, + { 80, { 0.440480, 0.268060, 0.190030, 0.147938 } }, + { 81, { 0.467023, 0.302555, 0.231871, 0.188436 } }, + { 90, { 0.467598, 0.292983, 0.206409, 0.159414 } }, + { 91, { 0.492893, 0.327706, 0.247315, 0.200483 } }, + { 100, { 0.500946, 0.321231, 0.229723, 0.176626 } }, + { 101, { 0.523507, 0.354234, 0.266130, 0.216512 } }, + { 110, { 0.546298, 0.361122, 0.262676, 0.202235 } }, + { 111, { 0.564731, 0.391539, 0.300782, 0.241582 } }, + { 120, { 0.612210, 0.437722, 0.333962, 0.266613 } }, + { 121, { 0.631711, 0.466625, 0.370526, 0.302552 } }, + { 1010, { 0.425249, 0.294167, 0.227440, 0.189070 } }, + { 1020, { 0.368338, 0.236502, 0.175148, 0.141144 } }, + { 1021, { 0.398522, 0.274875, 0.213918, 0.181193 } }, + { 1030, { 0.380584, 0.244160, 0.183336, 0.148602 } }, + { 1031, { 0.411600, 0.280911, 0.221748, 0.185122 } }, + { 1040, { 0.379182, 0.238104, 0.174768, 0.138399 } }, + { 1041, { 0.410886, 0.274157, 0.214447, 0.178769 } }, + { 1050, { 0.388704, 0.236244, 0.169994, 0.133749 } }, + { 1051, { 0.416815, 0.269452, 0.210729, 0.172591 } }, + { 1060, { 0.396943, 0.237112, 0.169488, 0.130860 } }, + { 1061, { 0.425483, 0.274880, 0.208163, 0.171587 } }, + { 1070, { 0.421637, 0.255125, 0.181848, 0.138975 } }, + { 1071, { 0.447019, 0.291320, 0.219969, 0.180664 } }, + { 1080, { 0.448126, 0.274144, 0.196289, 0.151646 } }, + { 1081, { 0.473606, 0.310826, 0.235919, 0.190739 } }, + { 1090, { 0.478501, 0.298148, 0.212041, 0.163683 } }, + { 1091, { 0.504431, 0.333231, 0.251471, 0.204792 } }, + { 1100, { 0.510525, 0.327482, 0.234555, 0.180396 } }, + { 1101, { 0.532065, 0.360810, 0.270922, 0.220332 } }, + { 1110, { 0.553686, 0.367362, 0.268589, 0.207489 } }, + { 1111, { 0.576153, 0.400387, 0.303690, 0.247722 } }, + { 1120, { 0.621342, 0.446336, 0.343233, 0.273911 } }, + { 1121, { 0.637968, 0.474715, 0.373390, 0.310121 } }, + { 2020, { 0.458947, 0.313939, 0.242610, 0.200423 } }, + { 2030, { 0.398033, 0.259838, 0.198458, 0.161070 } }, + { 2031, { 0.425525, 0.293960, 0.235756, 0.199501 } }, + { 2040, { 0.397817, 0.255376, 0.190636, 0.154640 } }, + { 2041, { 0.425873, 0.292207, 0.228006, 0.194654 } }, + { 2050, { 0.405126, 0.253793, 0.186274, 0.148799 } }, + { 2051, { 0.434334, 0.290140, 0.224181, 0.187256 } }, + { 2060, { 0.415893, 0.254033, 0.183065, 0.144964 } }, + { 2061, { 0.442020, 0.289907, 0.223390, 0.183388 } }, + { 2070, { 0.431662, 0.261557, 0.186207, 0.143897 } }, + { 2071, { 0.458148, 0.295690, 0.221357, 0.182633 } }, + { 2080, { 0.458244, 0.283182, 0.202632, 0.158355 } }, + { 2081, { 0.485387, 0.317359, 0.244065, 0.197194 } }, + { 2090, { 0.486843, 0.305900, 0.219227, 0.169682 } }, + { 2091, { 0.509158, 0.336822, 0.255117, 0.209493 } }, + { 2100, { 0.520532, 0.334651, 0.241959, 0.186116 } }, + { 2101, { 0.544106, 0.367181, 0.277500, 0.224167 } }, + { 2110, { 0.562867, 0.376359, 0.275377, 0.213308 } }, + { 2111, { 0.583419, 0.408087, 0.311465, 0.251205 } }, + { 2120, { 0.631754, 0.455162, 0.349977, 0.281266 } }, + { 2121, { 0.647554, 0.478675, 0.382699, 0.318028 } }, + { 3030, { 0.491574, 0.334918, 0.260822, 0.215129 } }, + { 3040, { 0.415659, 0.266638, 0.203475, 0.168118 } }, + { 3041, { 0.440987, 0.306280, 0.241409, 0.206000 } }, + { 3050, { 0.420281, 0.269759, 0.202282, 0.163709 } }, + { 3051, { 0.446296, 0.302118, 0.239135, 0.202622 } }, + { 3060, { 0.434861, 0.270280, 0.199293, 0.158721 } }, + { 3061, { 0.457776, 0.306309, 0.238337, 0.200351 } }, + { 3070, { 0.445102, 0.275557, 0.201226, 0.157838 } }, + { 3071, { 0.471762, 0.310139, 0.239625, 0.197345 } }, + { 3080, { 0.468139, 0.289426, 0.208934, 0.162483 } }, + { 3081, { 0.491828, 0.325417, 0.244964, 0.199125 } }, + { 3090, { 0.499743, 0.313642, 0.227720, 0.176322 } }, + { 3091, { 0.521336, 0.347760, 0.262093, 0.214462 } }, + { 3100, { 0.534472, 0.344431, 0.248543, 0.193602 } }, + { 3101, { 0.553252, 0.374123, 0.284209, 0.232423 } }, + { 3110, { 0.573378, 0.384744, 0.283403, 0.220253 } }, + { 3111, { 0.588956, 0.415055, 0.318031, 0.259790 } }, + { 3120, { 0.641023, 0.464428, 0.359995, 0.290579 } }, + { 3121, { 0.657020, 0.489627, 0.389187, 0.322193 } }, + { 4040, { 0.516006, 0.359183, 0.277032, 0.228881 } }, + { 4050, { 0.435729, 0.282211, 0.212923, 0.174751 } }, + { 4051, { 0.462412, 0.313824, 0.249562, 0.212472 } }, + { 4060, { 0.447638, 0.285155, 0.212276, 0.172773 } }, + { 4061, { 0.470266, 0.319709, 0.250671, 0.208987 } }, + { 4070, { 0.460265, 0.288142, 0.213646, 0.171749 } }, + { 4071, { 0.487225, 0.324893, 0.250578, 0.208518 } }, + { 4080, { 0.482136, 0.303300, 0.219496, 0.173420 } }, + { 4081, { 0.502701, 0.334032, 0.255191, 0.211497 } }, + { 4090, { 0.504535, 0.319118, 0.230051, 0.180925 } }, + { 4091, { 0.530570, 0.355567, 0.265668, 0.219096 } }, + { 4100, { 0.539041, 0.348698, 0.254279, 0.198336 } }, + { 4101, { 0.560032, 0.381288, 0.289776, 0.233638 } }, + { 4110, { 0.582704, 0.393881, 0.290373, 0.226942 } }, + { 4111, { 0.598407, 0.422241, 0.321170, 0.263919 } }, + { 4120, { 0.642734, 0.464127, 0.357691, 0.287758 } }, + { 4121, { 0.659588, 0.488409, 0.390229, 0.321964 } }, + { 5050, { 0.549268, 0.382451, 0.297085, 0.244325 } }, + { 5060, { 0.461289, 0.298799, 0.224119, 0.184892 } }, + { 5061, { 0.485634, 0.330149, 0.263757, 0.223014 } }, + { 5070, { 0.473494, 0.303907, 0.228508, 0.183815 } }, + { 5071, { 0.499667, 0.340404, 0.266624, 0.219160 } }, + { 5080, { 0.497160, 0.318137, 0.235993, 0.189195 } }, + { 5081, { 0.519271, 0.346657, 0.273157, 0.225601 } }, + { 5090, { 0.519085, 0.333791, 0.244852, 0.193839 } }, + { 5091, { 0.545203, 0.363052, 0.280410, 0.228881 } }, + { 5100, { 0.548230, 0.359064, 0.263356, 0.204509 } }, + { 5101, { 0.565488, 0.387187, 0.295925, 0.242237 } }, + { 5110, { 0.591864, 0.402174, 0.298403, 0.235400 } }, + { 5111, { 0.608657, 0.431376, 0.331219, 0.269897 } }, + { 5120, { 0.652519, 0.476460, 0.368421, 0.296733 } }, + { 5121, { 0.666606, 0.497720, 0.396138, 0.331399 } }, + { 6060, { 0.572002, 0.405822, 0.316323, 0.263300 } }, + { 6070, { 0.490941, 0.317838, 0.241244, 0.198071 } }, + { 6071, { 0.511400, 0.351731, 0.277871, 0.233745 } }, + { 6080, { 0.513155, 0.333109, 0.251517, 0.203524 } }, + { 6081, { 0.534313, 0.364968, 0.284903, 0.239425 } }, + { 6090, { 0.535497, 0.351791, 0.262208, 0.209001 } }, + { 6091, { 0.555172, 0.379223, 0.294741, 0.242575 } }, + { 6100, { 0.564425, 0.375204, 0.277724, 0.220820 } }, + { 6101, { 0.585780, 0.404858, 0.309063, 0.255885 } }, + { 6110, { 0.601187, 0.412856, 0.307546, 0.243076 } }, + { 6111, { 0.619748, 0.439626, 0.340543, 0.278683 } }, + { 6120, { 0.663506, 0.484994, 0.379012, 0.308522 } }, + { 6121, { 0.672680, 0.508199, 0.406539, 0.338819 } }, + { 7070, { 0.602459, 0.432679, 0.339776, 0.280706 } }, + { 7080, { 0.525674, 0.349554, 0.266348, 0.218304 } }, + { 7081, { 0.546982, 0.380494, 0.299939, 0.252933 } }, + { 7090, { 0.550741, 0.367646, 0.277965, 0.224762 } }, + { 7091, { 0.570817, 0.396292, 0.308852, 0.257872 } }, + { 7100, { 0.578107, 0.392576, 0.296196, 0.237797 } }, + { 7101, { 0.597385, 0.417610, 0.325814, 0.269943 } }, + { 7110, { 0.616725, 0.429318, 0.326413, 0.260805 } }, + { 7111, { 0.633622, 0.455894, 0.358718, 0.295226 } }, + { 7120, { 0.673638, 0.496498, 0.389773, 0.317947 } }, + { 7121, { 0.685843, 0.518038, 0.416296, 0.347696 } }, + { 8080, { 0.633155, 0.462777, 0.368277, 0.305162 } }, + { 8090, { 0.569903, 0.386443, 0.299307, 0.246643 } }, + { 8091, { 0.582209, 0.415800, 0.328378, 0.277974 } }, + { 8100, { 0.597204, 0.413220, 0.317080, 0.258892 } }, + { 8101, { 0.612997, 0.437354, 0.344853, 0.288854 } }, + { 8110, { 0.632288, 0.447764, 0.345514, 0.281554 } }, + { 8111, { 0.651514, 0.473083, 0.372330, 0.311285 } }, + { 8120, { 0.689345, 0.516179, 0.410605, 0.339648 } }, + { 8121, { 0.700118, 0.537866, 0.439058, 0.369618 } }, + { 9090, { 0.660660, 0.495556, 0.396267, 0.332142 } }, + { 9100, { 0.606741, 0.425296, 0.327092, 0.266201 } }, + { 9101, { 0.626335, 0.449237, 0.357001, 0.298544 } }, + { 9110, { 0.645998, 0.460582, 0.357830, 0.289691 } }, + { 9111, { 0.657509, 0.486536, 0.383815, 0.322174 } }, + { 9120, { 0.699304, 0.529890, 0.420874, 0.350739 } }, + { 9121, { 0.711152, 0.550163, 0.444167, 0.379029 } }, + { 10100, { 0.698831, 0.534374, 0.436462, 0.369034 } }, + { 10110, { 0.660376, 0.479650, 0.373328, 0.304814 } }, + { 10111, { 0.677518, 0.502799, 0.401653, 0.334030 } }, + { 10120, { 0.718249, 0.550870, 0.440722, 0.365350 } }, + { 10121, { 0.732486, 0.566302, 0.463868, 0.391412 } }, + { 11110, { 0.757306, 0.604317, 0.501322, 0.428978 } }, + { 11120, { 0.745230, 0.580949, 0.472283, 0.393985 } }, + { 11121, { 0.754219, 0.599772, 0.495033, 0.416241 } }, + { 12120, { 0.855608, 0.736617, 0.642366, 0.562044 } } }; -static const RoundData FlopValues[] = -{ - { 106, { 0.160312, 0.078750, 0.048325, 0.033350 } }, - { 206, { 0.185012, 0.099666, 0.071425, 0.053450 } }, - { 306, { 0.199662, 0.115567, 0.081625, 0.067500 } }, - { 406, { 0.199712, 0.121383, 0.088775, 0.070750 } }, - { 1206, { 0.191537, 0.110250, 0.078400, 0.057350 } }, - { 1306, { 0.212125, 0.119433, 0.089325, 0.071200 } }, - { 1406, { 0.219762, 0.133983, 0.101875, 0.080000 } }, - { 2306, { 0.228400, 0.142983, 0.103950, 0.087900 } }, - { 2406, { 0.242275, 0.155600, 0.124050, 0.100400 } }, - { 3406, { 0.237262, 0.164333, 0.125725, 0.099750 } }, - { 107, { 0.165612, 0.083566, 0.054850, 0.043750 } }, - { 207, { 0.183363, 0.101283, 0.068825, 0.054500 } }, - { 307, { 0.203250, 0.114933, 0.081875, 0.068600 } }, - { 407, { 0.221225, 0.119917, 0.085025, 0.065600 } }, - { 1207, { 0.199200, 0.113817, 0.078950, 0.061400 } }, - { 1307, { 0.214062, 0.126883, 0.092250, 0.075100 } }, - { 1407, { 0.245438, 0.141217, 0.102000, 0.081350 } }, - { 2307, { 0.231950, 0.141733, 0.105300, 0.084550 } }, - { 2407, { 0.267275, 0.166483, 0.126300, 0.101750 } }, - { 3407, { 0.257300, 0.168650, 0.129225, 0.100700 } }, - { 108, { 0.169475, 0.082066, 0.052325, 0.037950 } }, - { 208, { 0.186787, 0.100850, 0.070175, 0.052000 } }, - { 308, { 0.215725, 0.112733, 0.073875, 0.054150 } }, - { 408, { 0.253450, 0.134367, 0.092525, 0.072050 } }, - { 1208, { 0.195000, 0.111100, 0.077225, 0.056750 } }, - { 1308, { 0.235763, 0.123700, 0.084700, 0.065500 } }, - { 1408, { 0.262225, 0.140717, 0.099175, 0.074350 } }, - { 2308, { 0.242300, 0.135200, 0.096750, 0.074400 } }, - { 2408, { 0.287313, 0.160033, 0.116075, 0.094650 } }, - { 3408, { 0.277012, 0.163533, 0.116650, 0.095300 } }, - { 109, { 0.186037, 0.085966, 0.051825, 0.038350 } }, - { 209, { 0.200400, 0.098150, 0.066675, 0.050650 } }, - { 309, { 0.220688, 0.108317, 0.073075, 0.052350 } }, - { 409, { 0.275813, 0.135517, 0.086325, 0.063050 } }, - { 1209, { 0.219025, 0.115400, 0.080150, 0.061800 } }, - { 1309, { 0.246425, 0.130383, 0.092425, 0.068150 } }, - { 1409, { 0.304438, 0.158233, 0.108500, 0.081800 } }, - { 2309, { 0.254300, 0.143233, 0.104850, 0.079500 } }, - { 2409, { 0.326638, 0.178833, 0.127100, 0.099550 } }, - { 3409, { 0.323150, 0.178717, 0.129425, 0.097950 } }, - { 110, { 0.190100, 0.071466, 0.035575, 0.021400 } }, -{ 210, { 0.213588, 0.085183, 0.046225, 0.028200 } }, -{ 310, { 0.275788, 0.119583, 0.068500, 0.044200 } }, -{ 410, { 0.320487, 0.149867, 0.090450, 0.068700 } }, -{ 1210, { 0.225675, 0.098333, 0.056975, 0.036900 } }, -{ 1310, { 0.302862, 0.133517, 0.078175, 0.052900 } }, -{ 1410, { 0.344763, 0.168200, 0.106625, 0.075650 } }, -{ 2310, { 0.310525, 0.151150, 0.092025, 0.066950 } }, -{ 2410, { 0.365463, 0.188500, 0.121275, 0.093100 } }, -{ 3410, { 0.386962, 0.214933, 0.151325, 0.119000 } }, -{ 111, { 0.191887, 0.074800, 0.036500, 0.023150 } }, -{ 211, { 0.197437, 0.074633, 0.038425, 0.021600 } }, -{ 311, { 0.279463, 0.118717, 0.068550, 0.045300 } }, -{ 411, { 0.375588, 0.179217, 0.106850, 0.074700 } }, -{ 1211, { 0.226475, 0.101767, 0.058650, 0.037050 } }, -{ 1311, { 0.302500, 0.135333, 0.078800, 0.054450 } }, -{ 1411, { 0.402687, 0.198867, 0.126825, 0.083850 } }, -{ 2311, { 0.311925, 0.150033, 0.097125, 0.066200 } }, -{ 2411, { 0.420350, 0.219233, 0.141225, 0.100850 } }, -{ 3411, { 0.476650, 0.281733, 0.202000, 0.160500 } }, -{ 112, { 0.271713, 0.106417, 0.054675, 0.029350 } }, -{ 212, { 0.305475, 0.124833, 0.068875, 0.039100 } }, -{ 312, { 0.393087, 0.183367, 0.100875, 0.064600 } }, -{ 412, { 0.453037, 0.240100, 0.146400, 0.101700 } }, -{ 1212, { 0.310725, 0.143767, 0.078825, 0.049750 } }, -{ 1312, { 0.420900, 0.205133, 0.117425, 0.078750 } }, -{ 1412, { 0.481088, 0.263833, 0.160975, 0.114650 } }, -{ 2312, { 0.422438, 0.215050, 0.133150, 0.089900 } }, -{ 2412, { 0.498025, 0.283417, 0.184950, 0.133700 } }, -{ 3412, { 0.509725, 0.303550, 0.211825, 0.153700 } }, -{ 10201, { 0.277375, 0.133517, 0.076325, 0.042900 } }, -{ 10102, { 0.317775, 0.177483, 0.112400, 0.077850 } }, -{ 10202, { 0.291087, 0.147300, 0.085675, 0.051200 } }, -{ 10103, { 0.328775, 0.179900, 0.113375, 0.079500 } }, -{ 10203, { 0.295988, 0.150617, 0.089500, 0.056800 } }, -{ 10104, { 0.315550, 0.168617, 0.103550, 0.068600 } }, -{ 10204, { 0.308200, 0.155367, 0.093075, 0.056450 } }, -{ 10005, { 0.270150, 0.170433, 0.124725, 0.096250 } }, -{ 10105, { 0.296262, 0.172950, 0.126950, 0.095050 } }, -{ 10205, { 0.336438, 0.172217, 0.103250, 0.068550 } }, -{ 10006, { 0.289838, 0.171233, 0.128600, 0.096950 } }, -{ 10106, { 0.324525, 0.182750, 0.130125, 0.101000 } }, -{ 10206, { 0.381512, 0.197733, 0.124625, 0.086700 } }, -{ 10007, { 0.310425, 0.175450, 0.128100, 0.096550 } }, -{ 10107, { 0.367663, 0.207800, 0.144725, 0.110750 } }, -{ 10207, { 0.425438, 0.224617, 0.138200, 0.092250 } }, -{ 10008, { 0.352000, 0.194683, 0.136925, 0.103950 } }, -{ 10108, { 0.422225, 0.237950, 0.164950, 0.121300 } }, -{ 10208, { 0.485413, 0.273783, 0.171725, 0.114450 } }, -{ 10009, { 0.397750, 0.222400, 0.151450, 0.116250 } }, -{ 10109, { 0.470425, 0.261367, 0.170925, 0.121600 } }, -{ 10209, { 0.532787, 0.305733, 0.190700, 0.118150 } }, -{ 10010, { 0.454037, 0.251483, 0.168825, 0.126050 } }, -{ 10110, { 0.550462, 0.334933, 0.229600, 0.167950 } }, -{ 10210, { 0.613350, 0.392250, 0.259175, 0.174450 } }, -{ 10011, { 0.526900, 0.317983, 0.217350, 0.153850 } }, -{ 10111, { 0.642038, 0.431733, 0.313825, 0.236850 } }, -{ 10012, { 0.611275, 0.396950, 0.277325, 0.206950 } }, -{ 11200, { 0.573987, 0.362933, 0.252050, 0.192800 } }, -{ 11101, { 0.635763, 0.427050, 0.305575, 0.227200 } }, -{ 11201, { 0.579963, 0.368700, 0.259525, 0.193700 } }, -{ 11002, { 0.641050, 0.437717, 0.313950, 0.235550 } }, -{ 11102, { 0.654863, 0.449200, 0.321575, 0.247450 } }, -{ 11202, { 0.597325, 0.389683, 0.268975, 0.203750 } }, -{ 11003, { 0.647775, 0.442267, 0.316825, 0.243500 } }, -{ 11103, { 0.654050, 0.446483, 0.320175, 0.245900 } }, -{ 11203, { 0.627513, 0.412067, 0.290050, 0.212450 } }, -{ 11004, { 0.689688, 0.487583, 0.362425, 0.266950 } }, -{ 11104, { 0.673050, 0.468117, 0.336500, 0.260750 } }, -{ 11204, { 0.651563, 0.437467, 0.313000, 0.230700 } }, -{ 11005, { 0.731213, 0.553867, 0.428225, 0.340550 } }, -{ 11105, { 0.697263, 0.497867, 0.368350, 0.288650 } }, -{ 11205, { 0.661388, 0.454883, 0.325175, 0.247450 } }, -{ 11006, { 0.753262, 0.580283, 0.452975, 0.366400 } }, -{ 11106, { 0.716875, 0.529517, 0.399350, 0.310700 } }, -{ 11206, { 0.679713, 0.473533, 0.346825, 0.255500 } }, -{ 11007, { 0.780038, 0.616067, 0.488425, 0.400650 } }, -{ 11107, { 0.743613, 0.565267, 0.439275, 0.344200 } }, -{ 11207, { 0.665825, 0.462400, 0.333175, 0.252750 } }, -{ 11008, { 0.801338, 0.649083, 0.529225, 0.437450 } }, -{ 11108, { 0.747300, 0.571033, 0.439275, 0.343300 } }, -{ 11208, { 0.665063, 0.462650, 0.334500, 0.250000 } }, -{ 11009, { 0.795763, 0.640850, 0.516675, 0.427450 } }, -{ 11109, { 0.765500, 0.594217, 0.458475, 0.370950 } }, -{ 11209, { 0.694300, 0.492983, 0.361300, 0.269800 } }, -{ 11010, { 0.818762, 0.677283, 0.564350, 0.469850 } }, -{ 11110, { 0.755775, 0.577433, 0.448450, 0.347350 } }, -{ 11210, { 0.709525, 0.511550, 0.379400, 0.291150 } }, -{ 11011, { 0.843975, 0.713083, 0.610900, 0.520750 } }, -{ 11111, { 0.807163, 0.651467, 0.525225, 0.432100 } }, -{ 11012, { 0.866263, 0.749767, 0.655075, 0.569900 } }, -{ 12300, { 0.446325, 0.224100, 0.133125, 0.097100 } }, -{ 12201, { 0.541987, 0.314517, 0.195500, 0.133600 } }, -{ 12301, { 0.460913, 0.241117, 0.145000, 0.097950 } }, -{ 12102, { 0.641775, 0.424583, 0.289350, 0.206500 } }, -{ 12202, { 0.565462, 0.330867, 0.212075, 0.148150 } }, -{ 12302, { 0.481162, 0.253533, 0.154325, 0.106450 } }, -{ 12103, { 0.655763, 0.442417, 0.305875, 0.222850 } }, -{ 12203, { 0.576050, 0.347733, 0.221600, 0.146250 } }, -{ 12303, { 0.499538, 0.274933, 0.163900, 0.111500 } }, -{ 12104, { 0.667987, 0.449733, 0.310625, 0.223550 } }, -{ 12204, { 0.595762, 0.367533, 0.240700, 0.169500 } }, -{ 12304, { 0.529400, 0.299100, 0.185825, 0.123600 } }, -{ 12005, { 0.709287, 0.502400, 0.365725, 0.270400 } }, -{ 12105, { 0.673400, 0.460317, 0.323550, 0.229950 } }, -{ 12205, { 0.613313, 0.387950, 0.257175, 0.181950 } }, -{ 12305, { 0.544462, 0.309800, 0.191700, 0.129750 } }, -{ 12006, { 0.719650, 0.522967, 0.382550, 0.291200 } }, -{ 12106, { 0.692875, 0.482733, 0.345825, 0.253050 } }, -{ 12206, { 0.633238, 0.413717, 0.276850, 0.195200 } }, -{ 12306, { 0.562913, 0.339250, 0.215550, 0.147250 } }, -{ 12007, { 0.759613, 0.584300, 0.446275, 0.344550 } }, -{ 12107, { 0.709600, 0.507483, 0.371300, 0.274150 } }, -{ 12207, { 0.666238, 0.449700, 0.310075, 0.219450 } }, -{ 12307, { 0.583650, 0.356250, 0.224450, 0.155600 } }, -{ 12008, { 0.767475, 0.593817, 0.463025, 0.370750 } }, -{ 12108, { 0.718925, 0.524250, 0.385325, 0.294600 } }, -{ 12208, { 0.695125, 0.486433, 0.349075, 0.250250 } }, -{ 12009, { 0.787362, 0.623250, 0.502500, 0.397000 } }, -{ 12109, { 0.740750, 0.552867, 0.412425, 0.317100 } }, -{ 12209, { 0.712725, 0.509083, 0.365475, 0.262950 } }, -{ 12010, { 0.826462, 0.686000, 0.570850, 0.483000 } }, -{ 12110, { 0.766262, 0.589100, 0.456425, 0.356700 } }, -{ 12210, { 0.729612, 0.533183, 0.393700, 0.292100 } }, -{ 12011, { 0.833638, 0.701600, 0.588350, 0.496800 } }, -{ 12111, { 0.778250, 0.605767, 0.477175, 0.380450 } }, -{ 12012, { 0.863613, 0.751683, 0.652550, 0.561100 } }, -{ 21000, { 0.625838, 0.410617, 0.270925, 0.190000 } }, -{ 21001, { 0.648913, 0.439150, 0.299050, 0.207200 } }, -{ 21101, { 0.660925, 0.451067, 0.324350, 0.240950 } }, -{ 21002, { 0.679150, 0.472167, 0.334075, 0.247900 } }, -{ 21102, { 0.666275, 0.464717, 0.331075, 0.240200 } }, -{ 21003, { 0.701150, 0.500167, 0.364575, 0.266300 } }, -{ 21103, { 0.686625, 0.481400, 0.351650, 0.262200 } }, -{ 21004, { 0.731800, 0.541583, 0.407800, 0.303500 } }, -{ 21104, { 0.709675, 0.513417, 0.380125, 0.291950 } }, -{ 21005, { 0.755663, 0.579500, 0.440825, 0.339550 } }, -{ 21105, { 0.736100, 0.553650, 0.421150, 0.324500 } }, -{ 21006, { 0.782800, 0.608600, 0.476850, 0.380650 } }, -{ 21106, { 0.760350, 0.581683, 0.457225, 0.358500 } }, -{ 21007, { 0.810125, 0.657750, 0.532425, 0.434600 } }, -{ 21107, { 0.781587, 0.614050, 0.484450, 0.396600 } }, -{ 21008, { 0.795125, 0.637433, 0.513125, 0.413050 } }, -{ 21108, { 0.782750, 0.621833, 0.493250, 0.402300 } }, -{ 21009, { 0.821125, 0.682633, 0.566600, 0.465600 } }, -{ 21109, { 0.811562, 0.663167, 0.536500, 0.449750 } }, -{ 21010, { 0.850012, 0.720967, 0.610900, 0.517400 } }, -{ 21110, { 0.833425, 0.695433, 0.580225, 0.491300 } }, -{ 21011, { 0.881563, 0.773350, 0.678975, 0.596350 } }, -{ 21111, { 0.861350, 0.739867, 0.640600, 0.552200 } }, -{ 21112, { 0.883838, 0.784233, 0.693675, 0.608300 } }, -{ 22000, { 0.494837, 0.276100, 0.173950, 0.121300 } }, -{ 22001, { 0.512687, 0.300783, 0.191075, 0.134950 } }, -{ 22101, { 0.579575, 0.352150, 0.223700, 0.160050 } }, -{ 22002, { 0.539288, 0.318483, 0.207925, 0.148700 } }, -{ 22102, { 0.601537, 0.374417, 0.246825, 0.171800 } }, -{ 22003, { 0.559063, 0.343450, 0.230575, 0.162500 } }, -{ 22103, { 0.624287, 0.398150, 0.266900, 0.191750 } }, -{ 22004, { 0.586975, 0.373667, 0.250275, 0.186900 } }, -{ 22104, { 0.643887, 0.424983, 0.292000, 0.206800 } }, -{ 22005, { 0.619375, 0.412650, 0.288550, 0.209100 } }, -{ 22105, { 0.663300, 0.453867, 0.309300, 0.223150 } }, -{ 22006, { 0.650125, 0.443033, 0.311900, 0.229550 } }, -{ 22106, { 0.684963, 0.475650, 0.336650, 0.248150 } }, -{ 22007, { 0.696263, 0.490017, 0.355825, 0.267800 } }, -{ 22107, { 0.708137, 0.501767, 0.365350, 0.273450 } }, -{ 22008, { 0.738287, 0.549433, 0.413700, 0.314500 } }, -{ 22108, { 0.727075, 0.535983, 0.393100, 0.300650 } }, -{ 22009, { 0.847912, 0.722017, 0.616725, 0.523850 } }, -{ 22109, { 0.812725, 0.658717, 0.543300, 0.446600 } }, -{ 22010, { 0.868900, 0.752417, 0.656675, 0.561700 } }, -{ 22110, { 0.821000, 0.680383, 0.562475, 0.470100 } }, -{ 22011, { 0.888225, 0.785000, 0.693000, 0.612450 } }, -{ 22111, { 0.833363, 0.700750, 0.589450, 0.503050 } }, -{ 22112, { 0.858475, 0.738600, 0.636825, 0.553700 } }, -{ 22201, { 0.856137, 0.742967, 0.651625, 0.574600 } }, -{ 22202, { 0.859688, 0.746217, 0.656150, 0.580900 } }, -{ 22203, { 0.862888, 0.752333, 0.664400, 0.586800 } }, -{ 22204, { 0.858088, 0.742617, 0.649500, 0.571800 } }, -{ 22205, { 0.853263, 0.734683, 0.641875, 0.559850 } }, -{ 22206, { 0.867075, 0.756617, 0.664375, 0.591450 } }, -{ 22207, { 0.872938, 0.766767, 0.678900, 0.605650 } }, -{ 22208, { 0.874800, 0.771667, 0.688800, 0.616650 } }, -{ 22209, { 0.887825, 0.792483, 0.719900, 0.650000 } }, -{ 22210, { 0.895650, 0.808067, 0.735575, 0.671050 } }, -{ 22211, { 0.919162, 0.850183, 0.785825, 0.729700 } }, -{ 22212, { 0.935600, 0.877833, 0.825725, 0.781800 } }, -{ 30001, { 0.344288, 0.222633, 0.164400, 0.127100 } }, -{ 30002, { 0.347087, 0.227383, 0.170950, 0.136900 } }, -{ 30102, { 0.363162, 0.236250, 0.169975, 0.122950 } }, -{ 30003, { 0.353500, 0.234733, 0.177000, 0.140700 } }, -{ 30103, { 0.364412, 0.236583, 0.172325, 0.132450 } }, -{ 30004, { 0.367337, 0.240800, 0.187725, 0.156750 } }, -{ 30104, { 0.371575, 0.243267, 0.184725, 0.138900 } }, -{ 30005, { 0.389600, 0.248250, 0.196350, 0.153950 } }, -{ 30105, { 0.376387, 0.247067, 0.186375, 0.145050 } }, -{ 30006, { 0.422950, 0.269267, 0.211625, 0.179050 } }, -{ 30106, { 0.388362, 0.249483, 0.191125, 0.157850 } }, -{ 30007, { 0.463462, 0.294067, 0.218500, 0.186350 } }, -{ 30107, { 0.416438, 0.258417, 0.200850, 0.163700 } }, -{ 30008, { 0.512837, 0.321717, 0.238700, 0.197850 } }, -{ 30108, { 0.466575, 0.291450, 0.223225, 0.184350 } }, -{ 30009, { 0.577688, 0.379667, 0.282675, 0.217700 } }, -{ 30109, { 0.518075, 0.330517, 0.245975, 0.199450 } }, -{ 30010, { 0.645362, 0.447467, 0.331675, 0.263600 } }, -{ 30110, { 0.577037, 0.370500, 0.274075, 0.212850 } }, -{ 30011, { 0.718850, 0.532200, 0.412975, 0.335200 } }, -{ 30111, { 0.642912, 0.441300, 0.324475, 0.253150 } }, -{ 30112, { 0.715350, 0.528400, 0.403125, 0.326600 } }, -{ 41104, { 0.311063, 0.191417, 0.143925, 0.111150 } }, -{ 41204, { 0.622650, 0.408700, 0.282950, 0.208600 } }, -{ 41005, { 0.241925, 0.148983, 0.109150, 0.078200 } }, -{ 41105, { 0.353787, 0.204000, 0.147650, 0.110350 } }, -{ 41205, { 0.637350, 0.427133, 0.301150, 0.219250 } }, -{ 41006, { 0.262412, 0.162067, 0.120525, 0.091800 } }, -{ 41106, { 0.374837, 0.216017, 0.156400, 0.121500 } }, -{ 41206, { 0.654100, 0.446733, 0.315550, 0.227350 } }, -{ 41007, { 0.281788, 0.166167, 0.119675, 0.090250 } }, -{ 41107, { 0.417137, 0.238983, 0.166225, 0.126500 } }, -{ 41207, { 0.673787, 0.468433, 0.336425, 0.245300 } }, -{ 41008, { 0.294438, 0.160567, 0.108150, 0.080150 } }, -{ 41108, { 0.469050, 0.273150, 0.181300, 0.140800 } }, -{ 41208, { 0.694975, 0.492300, 0.357850, 0.263450 } }, -{ 41009, { 0.327000, 0.172217, 0.113000, 0.081250 } }, -{ 41109, { 0.525288, 0.312350, 0.207875, 0.149050 } }, -{ 41209, { 0.711425, 0.518733, 0.378975, 0.290700 } }, -{ 41010, { 0.382525, 0.202600, 0.131125, 0.096650 } }, -{ 41110, { 0.529775, 0.321067, 0.214900, 0.154300 } }, -{ 41210, { 0.743725, 0.556700, 0.417775, 0.317000 } }, -{ 41011, { 0.413625, 0.212317, 0.136275, 0.095900 } }, -{ 41211, { 0.762962, 0.588517, 0.456225, 0.355800 } }, -{ 41012, { 0.492750, 0.298683, 0.221950, 0.185600 } }, -{ 41212, { 0.834475, 0.703650, 0.590950, 0.507050 } }, -{ 42004, { 0.272075, 0.189533, 0.154000, 0.130900 } }, -{ 42204, { 0.558087, 0.350000, 0.238125, 0.171450 } }, -{ 42005, { 0.293525, 0.196417, 0.156200, 0.138000 } }, -{ 42205, { 0.574750, 0.361550, 0.250350, 0.179300 } }, -{ 42006, { 0.322700, 0.204917, 0.159825, 0.138950 } }, -{ 42206, { 0.592150, 0.382783, 0.260500, 0.193550 } }, -{ 42007, { 0.354563, 0.217383, 0.170950, 0.147300 } }, -{ 42207, { 0.614363, 0.399333, 0.278975, 0.199000 } }, -{ 42008, { 0.383175, 0.232967, 0.176525, 0.149850 } }, -{ 42208, { 0.632000, 0.419717, 0.295275, 0.212400 } }, -{ 42009, { 0.380225, 0.237933, 0.187000, 0.151900 } }, -{ 42209, { 0.651100, 0.440883, 0.307875, 0.223250 } }, -{ 42010, { 0.432150, 0.273117, 0.208100, 0.175100 } }, -{ 42210, { 0.680638, 0.472867, 0.336475, 0.245050 } }, -{ 42011, { 0.486375, 0.309800, 0.239700, 0.202900 } }, -{ 42211, { 0.703037, 0.499717, 0.368450, 0.272750 } }, -{ 42012, { 0.539112, 0.356167, 0.271325, 0.235650 } }, -{ 42212, { 0.774487, 0.610033, 0.485250, 0.399300 } }, -{ 43104, { 0.409863, 0.271383, 0.221500, 0.193500 } }, -{ 43204, { 0.674612, 0.484033, 0.367575, 0.292950 } }, -{ 43005, { 0.273612, 0.200917, 0.165400, 0.149900 } }, -{ 43105, { 0.417563, 0.270517, 0.221725, 0.195200 } }, -{ 43205, { 0.684512, 0.498017, 0.378375, 0.305750 } }, -{ 43006, { 0.309837, 0.220700, 0.186450, 0.170800 } }, -{ 43106, { 0.430175, 0.290183, 0.239550, 0.212950 } }, -{ 43206, { 0.693287, 0.504233, 0.389650, 0.311650 } }, -{ 43007, { 0.333612, 0.221617, 0.184400, 0.161500 } }, -{ 43107, { 0.474075, 0.315533, 0.250375, 0.221250 } }, -{ 43207, { 0.714700, 0.529633, 0.403875, 0.332650 } }, -{ 43008, { 0.366375, 0.235083, 0.191950, 0.171900 } }, -{ 43108, { 0.478425, 0.318050, 0.256450, 0.218950 } }, -{ 43208, { 0.730437, 0.556533, 0.435500, 0.349800 } }, -{ 43009, { 0.394825, 0.241567, 0.189150, 0.165250 } }, -{ 43109, { 0.582588, 0.391300, 0.306525, 0.258850 } }, -{ 43209, { 0.754012, 0.580250, 0.462725, 0.377800 } }, -{ 43010, { 0.445638, 0.270467, 0.203300, 0.174450 } }, -{ 43110, { 0.581725, 0.391300, 0.296350, 0.244000 } }, -{ 43210, { 0.774787, 0.608450, 0.486750, 0.405050 } }, -{ 43011, { 0.493063, 0.298867, 0.218075, 0.174500 } }, -{ 43211, { 0.795150, 0.640217, 0.524175, 0.430450 } }, -{ 43012, { 0.554212, 0.354300, 0.263500, 0.210650 } }, -{ 43212, { 0.817175, 0.673367, 0.567850, 0.482750 } }, -{ 44004, { 0.307038, 0.228567, 0.195650, 0.175900 } }, -{ 44204, { 0.658875, 0.465283, 0.344600, 0.268000 } }, -{ 44005, { 0.329525, 0.231150, 0.197550, 0.172200 } }, -{ 44205, { 0.675550, 0.480683, 0.358925, 0.279700 } }, -{ 44006, { 0.362038, 0.249583, 0.202575, 0.178200 } }, -{ 44206, { 0.695137, 0.501583, 0.380750, 0.303800 } }, -{ 44007, { 0.396062, 0.259800, 0.212000, 0.185900 } }, -{ 44207, { 0.710562, 0.522133, 0.402875, 0.313250 } }, -{ 44008, { 0.409938, 0.284817, 0.239925, 0.214050 } }, -{ 44208, { 0.729025, 0.545667, 0.423575, 0.327600 } }, -{ 44009, { 0.441763, 0.299717, 0.246700, 0.216600 } }, -{ 44209, { 0.749025, 0.575000, 0.452725, 0.361400 } }, -{ 44010, { 0.486963, 0.324150, 0.258175, 0.216700 } }, -{ 44210, { 0.779200, 0.613317, 0.491025, 0.396800 } }, -{ 44011, { 0.544312, 0.368567, 0.289350, 0.244350 } }, -{ 44211, { 0.807025, 0.663100, 0.550800, 0.457450 } }, -{ 44012, { 0.602287, 0.418417, 0.322750, 0.264100 } }, -{ 44212, { 0.833538, 0.697883, 0.591800, 0.495950 } }, -{ 45103, { 0.446537, 0.320717, 0.258300, 0.229650 } }, -{ 45203, { 0.660650, 0.475000, 0.364250, 0.291550 } }, -{ 45104, { 0.449338, 0.315950, 0.256475, 0.216550 } }, -{ 45204, { 0.669375, 0.477967, 0.357125, 0.286200 } }, -{ 45005, { 0.354975, 0.267583, 0.218450, 0.186250 } }, -{ 45105, { 0.451525, 0.319533, 0.254850, 0.220550 } }, -{ 45205, { 0.685837, 0.490700, 0.370900, 0.298350 } }, -{ 45006, { 0.374312, 0.270217, 0.223775, 0.187900 } }, -{ 45106, { 0.492350, 0.333350, 0.260700, 0.220150 } }, -{ 45206, { 0.700025, 0.512533, 0.395450, 0.314200 } }, -{ 45007, { 0.396838, 0.276150, 0.226725, 0.195000 } }, -{ 45107, { 0.502000, 0.341300, 0.272350, 0.227850 } }, -{ 45207, { 0.715512, 0.528850, 0.408850, 0.323650 } }, -{ 45008, { 0.421350, 0.283000, 0.225525, 0.187700 } }, -{ 45108, { 0.543037, 0.368167, 0.283500, 0.237700 } }, -{ 45208, { 0.729588, 0.551767, 0.429675, 0.340050 } }, -{ 45009, { 0.458587, 0.295383, 0.230075, 0.189400 } }, -{ 45109, { 0.587450, 0.403633, 0.311325, 0.250400 } }, -{ 45209, { 0.747225, 0.571583, 0.449975, 0.360700 } }, -{ 45010, { 0.494925, 0.321633, 0.246600, 0.199150 } }, -{ 45110, { 0.626425, 0.454617, 0.366225, 0.319700 } }, -{ 45210, { 0.768275, 0.598867, 0.476275, 0.387300 } }, -{ 45011, { 0.564175, 0.402817, 0.341375, 0.308450 } }, -{ 45211, { 0.835438, 0.712033, 0.618225, 0.548900 } }, -{ 46003, { 0.393412, 0.325133, 0.290800, 0.262650 } }, -{ 46203, { 0.616788, 0.428533, 0.332000, 0.270250 } }, -{ 46004, { 0.408050, 0.324033, 0.290675, 0.273100 } }, -{ 46204, { 0.621762, 0.428233, 0.330775, 0.263500 } }, -{ 46005, { 0.426350, 0.331800, 0.294425, 0.275050 } }, -{ 46205, { 0.637687, 0.442550, 0.339525, 0.274300 } }, -{ 46006, { 0.424287, 0.298133, 0.242425, 0.208950 } }, -{ 46206, { 0.650700, 0.460850, 0.345900, 0.274650 } }, -{ 46007, { 0.456813, 0.311117, 0.242075, 0.205300 } }, -{ 46207, { 0.670850, 0.475450, 0.359300, 0.281500 } }, -{ 46008, { 0.489600, 0.325300, 0.256975, 0.215200 } }, -{ 46208, { 0.684512, 0.491350, 0.376250, 0.298350 } }, -{ 46009, { 0.523763, 0.378883, 0.326650, 0.289750 } }, -{ 46209, { 0.702950, 0.515500, 0.390650, 0.306250 } }, -{ 46010, { 0.566300, 0.411217, 0.355550, 0.324150 } }, -{ 46210, { 0.720163, 0.538167, 0.419300, 0.329400 } }, -{ 46011, { 0.612413, 0.458083, 0.383525, 0.338000 } }, -{ 46211, { 0.788062, 0.642550, 0.538650, 0.467050 } }, -{ 47103, { 0.471550, 0.373750, 0.339475, 0.320850 } }, -{ 47203, { 0.712512, 0.547183, 0.449275, 0.393250 } }, -{ 47104, { 0.475825, 0.373333, 0.330600, 0.303850 } }, -{ 47204, { 0.715800, 0.549467, 0.452925, 0.389600 } }, -{ 47005, { 0.393350, 0.323100, 0.291775, 0.273500 } }, -{ 47105, { 0.505525, 0.382067, 0.335800, 0.312800 } }, -{ 47205, { 0.726325, 0.563583, 0.462500, 0.398700 } }, -{ 47006, { 0.409537, 0.327417, 0.298125, 0.279350 } }, -{ 47106, { 0.513325, 0.379950, 0.337075, 0.312600 } }, -{ 47206, { 0.743337, 0.574517, 0.476475, 0.403150 } }, -{ 47007, { 0.431150, 0.331817, 0.294775, 0.280500 } }, -{ 47107, { 0.549813, 0.403817, 0.348025, 0.318450 } }, -{ 47207, { 0.758500, 0.603533, 0.494375, 0.422850 } }, -{ 47008, { 0.465612, 0.343300, 0.298125, 0.279450 } }, -{ 47108, { 0.589638, 0.435017, 0.364825, 0.326650 } }, -{ 47208, { 0.773550, 0.620767, 0.512475, 0.446550 } }, -{ 47009, { 0.498600, 0.360433, 0.306375, 0.280400 } }, -{ 47109, { 0.638363, 0.480517, 0.390100, 0.343050 } }, -{ 47209, { 0.793125, 0.644517, 0.538925, 0.467600 } }, -{ 47010, { 0.537250, 0.381883, 0.320025, 0.287450 } }, -{ 47110, { 0.650475, 0.488167, 0.406400, 0.362350 } }, -{ 47210, { 0.808975, 0.667967, 0.566075, 0.487500 } }, -{ 47011, { 0.574788, 0.410933, 0.343250, 0.307450 } }, -{ 47211, { 0.829862, 0.702650, 0.604125, 0.536500 } }, -{ 48003, { 0.437437, 0.372950, 0.345550, 0.321600 } }, -{ 48203, { 0.758550, 0.601850, 0.499875, 0.436700 } }, -{ 48004, { 0.447738, 0.377883, 0.345675, 0.325550 } }, -{ 48204, { 0.738812, 0.578317, 0.474075, 0.406200 } }, -{ 48005, { 0.465250, 0.385383, 0.347550, 0.322950 } }, -{ 48205, { 0.754475, 0.590500, 0.489050, 0.417700 } }, -{ 48006, { 0.485762, 0.392267, 0.355850, 0.335850 } }, -{ 48206, { 0.770100, 0.612867, 0.509100, 0.440600 } }, -{ 48007, { 0.513262, 0.407900, 0.362625, 0.332900 } }, -{ 48207, { 0.784737, 0.636200, 0.527375, 0.458650 } }, -{ 48008, { 0.549225, 0.424117, 0.375525, 0.349150 } }, -{ 48208, { 0.801113, 0.660333, 0.550825, 0.474000 } }, -{ 48009, { 0.562100, 0.447650, 0.398400, 0.369750 } }, -{ 48209, { 0.820037, 0.682783, 0.580650, 0.504050 } }, -{ 48010, { 0.597800, 0.470500, 0.408600, 0.383350 } }, -{ 48210, { 0.834775, 0.709433, 0.607925, 0.533750 } }, -{ 48011, { 0.638713, 0.500050, 0.437450, 0.395450 } }, -{ 48211, { 0.854437, 0.742983, 0.650175, 0.577100 } }, -{ 50005, { 0.510262, 0.313833, 0.218400, 0.154900 } }, -{ 50006, { 0.525575, 0.335667, 0.233525, 0.178550 } }, -{ 50007, { 0.562262, 0.376000, 0.277625, 0.215050 } }, -{ 50008, { 0.579575, 0.398367, 0.308200, 0.237200 } }, -{ 50009, { 0.633363, 0.452767, 0.361100, 0.293650 } }, -{ 50010, { 0.647537, 0.484900, 0.385475, 0.331150 } }, -{ 50011, { 0.677488, 0.526450, 0.447275, 0.392600 } }, -{ 50103, { 0.599825, 0.397350, 0.275725, 0.204050 } }, -{ 50104, { 0.567913, 0.353483, 0.233500, 0.158700 } }, -{ 50105, { 0.544125, 0.342167, 0.237425, 0.171400 } }, -{ 50106, { 0.556462, 0.367967, 0.265450, 0.197150 } }, -{ 50107, { 0.580688, 0.399833, 0.297825, 0.234800 } }, -{ 50108, { 0.608387, 0.433967, 0.340575, 0.277950 } }, -{ 50109, { 0.658687, 0.485533, 0.390100, 0.332800 } }, -{ 50110, { 0.679175, 0.521367, 0.437575, 0.385000 } }, -{ 50201, { 0.499700, 0.279550, 0.172150, 0.106200 } }, -{ 50202, { 0.510413, 0.295367, 0.188475, 0.129700 } }, -{ 50203, { 0.526737, 0.318817, 0.216700, 0.148500 } }, -{ 50204, { 0.544312, 0.342083, 0.234125, 0.168750 } }, -{ 50205, { 0.562500, 0.367067, 0.264075, 0.197300 } }, -{ 50206, { 0.578600, 0.391483, 0.287625, 0.222050 } }, -{ 50207, { 0.633262, 0.447267, 0.341525, 0.269100 } }, -{ 50207, { 0.634100, 0.445667, 0.338500, 0.268000 } }, -{ 50207, { 0.632000, 0.444467, 0.341475, 0.268700 } }, -{ 50300, { 0.522600, 0.300500, 0.184175, 0.114950 } }, -{ 50301, { 0.534013, 0.316800, 0.203550, 0.133100 } }, -{ 50302, { 0.542975, 0.334133, 0.216025, 0.145900 } }, -{ 50303, { 0.573950, 0.358667, 0.244925, 0.177350 } }, -{ 50304, { 0.582725, 0.384033, 0.267600, 0.197450 } }, -{ 50305, { 0.592800, 0.400850, 0.294125, 0.230250 } }, -{ 50306, { 0.607100, 0.429083, 0.330500, 0.264200 } }, -{ 51005, { 0.517325, 0.400183, 0.320550, 0.259850 } }, -{ 51006, { 0.476925, 0.357450, 0.279500, 0.220200 } }, -{ 51007, { 0.453912, 0.328583, 0.258825, 0.198350 } }, -{ 51008, { 0.488387, 0.358700, 0.286150, 0.228150 } }, -{ 51009, { 0.519250, 0.375967, 0.308500, 0.255700 } }, -{ 51010, { 0.557338, 0.410900, 0.342025, 0.296150 } }, -{ 51011, { 0.621525, 0.474133, 0.406375, 0.365400 } }, -{ 51012, { 0.679325, 0.538100, 0.468975, 0.427500 } }, -{ 51104, { 0.455338, 0.338717, 0.256075, 0.199200 } }, -{ 51105, { 0.411425, 0.287100, 0.210625, 0.155700 } }, -{ 51106, { 0.447437, 0.314667, 0.240000, 0.182600 } }, -{ 51107, { 0.468250, 0.332183, 0.257425, 0.208100 } }, -{ 51108, { 0.507437, 0.364967, 0.291425, 0.240100 } }, -{ 51109, { 0.551700, 0.404933, 0.333700, 0.280950 } }, -{ 51110, { 0.615150, 0.467283, 0.391525, 0.347700 } }, -{ 51111, { 0.666162, 0.519900, 0.449650, 0.407100 } }, -{ 51201, { 0.366287, 0.215917, 0.134950, 0.088450 } }, -{ 51202, { 0.389300, 0.230183, 0.152650, 0.098800 } }, -{ 51203, { 0.429663, 0.258150, 0.174750, 0.119100 } }, -{ 51204, { 0.450813, 0.288167, 0.201275, 0.151050 } }, -{ 51205, { 0.491737, 0.320900, 0.230975, 0.173250 } }, -{ 51206, { 0.539750, 0.360683, 0.267825, 0.211450 } }, -{ 51207, { 0.554500, 0.388600, 0.299900, 0.248550 } }, -{ 51208, { 0.653900, 0.502500, 0.419550, 0.360150 } }, -{ 51209, { 0.651688, 0.606217, 0.429275, 0.486300 } }, -{ 51210, { 0.663737, 0.510117, 0.430075, 0.395050 } }, -{ 51300, { 0.374575, 0.212500, 0.133100, 0.085400 } }, -{ 51301, { 0.393663, 0.236817, 0.155525, 0.107650 } }, -{ 51302, { 0.433300, 0.261867, 0.177925, 0.122250 } }, -{ 51303, { 0.473288, 0.295433, 0.205450, 0.148950 } }, -{ 51304, { 0.528250, 0.338267, 0.241275, 0.176950 } }, -{ 51305, { 0.541500, 0.364833, 0.274075, 0.213300 } }, -{ 51306, { 0.585225, 0.404750, 0.304400, 0.245100 } }, -{ 51307, { 0.680837, 0.511117, 0.418425, 0.357800 } }, -{ 52005, { 0.433787, 0.325783, 0.254575, 0.208050 } }, -{ 52006, { 0.434525, 0.313600, 0.231975, 0.173100 } }, -{ 52007, { 0.411488, 0.289517, 0.217100, 0.168100 } }, -{ 52008, { 0.440550, 0.317383, 0.242675, 0.190650 } }, -{ 52009, { 0.497812, 0.357500, 0.286875, 0.236250 } }, -{ 52010, { 0.530238, 0.388467, 0.316000, 0.269350 } }, -{ 52011, { 0.587000, 0.442150, 0.374575, 0.328550 } }, -{ 52012, { 0.644625, 0.497233, 0.438425, 0.401100 } }, -{ 52104, { 0.439450, 0.322667, 0.243000, 0.183300 } }, -{ 52105, { 0.396050, 0.270767, 0.197225, 0.145500 } }, -{ 52106, { 0.426988, 0.296667, 0.222800, 0.167400 } }, -{ 52107, { 0.455850, 0.313850, 0.243925, 0.197550 } }, -{ 52108, { 0.509225, 0.357333, 0.291600, 0.242000 } }, -{ 52109, { 0.545037, 0.393867, 0.321400, 0.278350 } }, -{ 52110, { 0.592600, 0.440233, 0.366100, 0.325250 } }, -{ 52111, { 0.648587, 0.500317, 0.427300, 0.392050 } }, -{ 52202, { 0.359825, 0.235550, 0.152900, 0.109500 } }, -{ 52203, { 0.382650, 0.251150, 0.173950, 0.120400 } }, -{ 52204, { 0.399975, 0.260900, 0.191075, 0.134100 } }, -{ 52205, { 0.426200, 0.280567, 0.208000, 0.154250 } }, -{ 52206, { 0.459788, 0.311433, 0.238600, 0.191850 } }, -{ 52207, { 0.496225, 0.342267, 0.275250, 0.218400 } }, -{ 52208, { 0.553863, 0.398000, 0.323150, 0.282750 } }, -{ 52209, { 0.605888, 0.444450, 0.369800, 0.321600 } }, -{ 52210, { 0.652725, 0.499567, 0.424825, 0.383000 } }, -{ 52301, { 0.364625, 0.219883, 0.144425, 0.094500 } }, -{ 52302, { 0.378400, 0.238967, 0.161425, 0.109800 } }, -{ 52303, { 0.408938, 0.263950, 0.185900, 0.133650 } }, -{ 52304, { 0.432013, 0.283050, 0.207225, 0.155200 } }, -{ 52305, { 0.476237, 0.316733, 0.239075, 0.192950 } }, -{ 52306, { 0.510787, 0.351550, 0.277225, 0.229000 } }, -{ 52307, { 0.553238, 0.390633, 0.313825, 0.265550 } }, -{ 53005, { 0.671550, 0.462267, 0.326050, 0.239800 } }, -{ 53006, { 0.714975, 0.521183, 0.379050, 0.285700 } }, -{ 53007, { 0.725888, 0.539000, 0.401425, 0.312350 } }, -{ 53008, { 0.765875, 0.595433, 0.471975, 0.376500 } }, -{ 53009, { 0.792950, 0.635133, 0.520575, 0.424200 } }, -{ 53010, { 0.816987, 0.677700, 0.570375, 0.484100 } }, -{ 53011, { 0.832275, 0.707483, 0.608725, 0.527600 } }, -{ 53012, { 0.879188, 0.781317, 0.704100, 0.645950 } }, -{ 53102, { 0.646188, 0.431000, 0.297600, 0.212250 } }, -{ 53103, { 0.662075, 0.451183, 0.316450, 0.226250 } }, -{ 53104, { 0.679488, 0.476467, 0.338175, 0.247350 } }, -{ 53105, { 0.685588, 0.486467, 0.355675, 0.262250 } }, -{ 53106, { 0.710063, 0.516383, 0.389000, 0.299000 } }, -{ 53107, { 0.737263, 0.554483, 0.426550, 0.339200 } }, -{ 53108, { 0.769500, 0.602567, 0.484000, 0.391150 } }, -{ 53109, { 0.788512, 0.633800, 0.524600, 0.437200 } }, -{ 53110, { 0.817612, 0.680600, 0.582975, 0.502600 } }, -{ 53111, { 0.832588, 0.712100, 0.629325, 0.562650 } }, -{ 53201, { 0.677300, 0.463333, 0.333250, 0.238700 } }, -{ 53201, { 0.677675, 0.467983, 0.330350, 0.234150 } }, -{ 53203, { 0.708037, 0.505850, 0.371000, 0.274750 } }, -{ 53204, { 0.731738, 0.540933, 0.404050, 0.309350 } }, -{ 53205, { 0.744363, 0.563950, 0.432425, 0.338750 } }, -{ 53206, { 0.769687, 0.599167, 0.473925, 0.375550 } }, -{ 53207, { 0.802450, 0.647200, 0.533025, 0.430750 } }, -{ 53208, { 0.832425, 0.695833, 0.585975, 0.497900 } }, -{ 53209, { 0.855850, 0.736900, 0.642750, 0.561800 } }, -{ 53210, { 0.872650, 0.772550, 0.692250, 0.619650 } }, -{ 53300, { 0.671262, 0.462133, 0.321625, 0.231600 } }, -{ 53301, { 0.686913, 0.481600, 0.342825, 0.249700 } }, -{ 53302, { 0.712013, 0.513850, 0.376300, 0.279150 } }, -{ 53303, { 0.731025, 0.542133, 0.406350, 0.313500 } }, -{ 53304, { 0.761413, 0.587967, 0.449450, 0.348700 } }, -{ 53305, { 0.781200, 0.615433, 0.485325, 0.380500 } }, -{ 53306, { 0.788900, 0.630667, 0.507500, 0.415200 } }, -{ 53307, { 0.803338, 0.658517, 0.548025, 0.464250 } }, -{ 60105, { 0.449263, 0.372250, 0.329725, 0.301050 } }, -{ 60106, { 0.457888, 0.371467, 0.331025, 0.305750 } }, -{ 60107, { 0.465225, 0.372783, 0.327575, 0.301500 } }, -{ 60108, { 0.465237, 0.376017, 0.326300, 0.306300 } }, -{ 60109, { 0.463462, 0.373900, 0.327375, 0.300650 } }, -{ 60110, { 0.484550, 0.380033, 0.334850, 0.306000 } }, -{ 60111, { 0.498262, 0.383467, 0.334500, 0.309250 } }, -{ 60112, { 0.507550, 0.391383, 0.345825, 0.308150 } }, -{ 60205, { 0.464050, 0.387800, 0.341925, 0.314150 } }, -{ 60206, { 0.477787, 0.386600, 0.345400, 0.316300 } }, -{ 60207, { 0.486150, 0.383117, 0.331725, 0.311850 } }, -{ 60208, { 0.495975, 0.393867, 0.344275, 0.314400 } }, -{ 60209, { 0.525800, 0.410417, 0.351100, 0.324100 } }, -{ 60210, { 0.529763, 0.409683, 0.357775, 0.330750 } }, -{ 60211, { 0.552412, 0.415517, 0.360550, 0.330600 } }, -{ 60212, { 0.553475, 0.419217, 0.363925, 0.330700 } }, -{ 60305, { 0.470900, 0.389867, 0.352600, 0.324350 } }, -{ 60306, { 0.493825, 0.394883, 0.351575, 0.320400 } }, -{ 60307, { 0.507075, 0.403533, 0.351175, 0.322750 } }, -{ 60308, { 0.534925, 0.416150, 0.359450, 0.329150 } }, -{ 60309, { 0.577087, 0.437533, 0.385150, 0.346100 } }, -{ 60310, { 0.582462, 0.460883, 0.399325, 0.374550 } }, -{ 60311, { 0.621838, 0.482767, 0.421350, 0.388650 } }, -{ 60312, { 0.665325, 0.521000, 0.451400, 0.426500 } }, -{ 61205, { 0.471450, 0.393600, 0.345100, 0.318200 } }, -{ 61206, { 0.489613, 0.396983, 0.351175, 0.322750 } }, -{ 61207, { 0.488000, 0.393300, 0.347050, 0.319450 } }, -{ 61208, { 0.507012, 0.401367, 0.352875, 0.322700 } }, -{ 61209, { 0.529975, 0.407283, 0.359375, 0.326050 } }, -{ 61210, { 0.538613, 0.420967, 0.373875, 0.339550 } }, -{ 61211, { 0.598113, 0.457800, 0.395250, 0.364400 } }, -{ 61212, { 0.630637, 0.486500, 0.414750, 0.374450 } }, -{ 61305, { 0.484588, 0.402333, 0.358050, 0.326600 } }, -{ 61306, { 0.509900, 0.411400, 0.368800, 0.334250 } }, -{ 61307, { 0.522637, 0.413067, 0.365875, 0.335750 } }, -{ 61308, { 0.555638, 0.431650, 0.380650, 0.349350 } }, -{ 61309, { 0.591175, 0.452767, 0.393800, 0.356700 } }, -{ 61310, { 0.602012, 0.469183, 0.412875, 0.382650 } }, -{ 61311, { 0.631050, 0.492500, 0.434525, 0.397000 } }, -{ 61312, { 0.676462, 0.531650, 0.461650, 0.426000 } }, -{ 62305, { 0.495500, 0.412033, 0.366375, 0.333950 } }, -{ 62306, { 0.519388, 0.424033, 0.372825, 0.344200 } }, -{ 62307, { 0.534613, 0.426467, 0.375600, 0.346250 } }, -{ 62308, { 0.557137, 0.438667, 0.378650, 0.346100 } }, -{ 62309, { 0.594437, 0.458850, 0.397700, 0.360150 } }, -{ 62310, { 0.607625, 0.487617, 0.434500, 0.398800 } }, -{ 62311, { 0.641975, 0.499533, 0.435450, 0.407300 } }, -{ 62312, { 0.703137, 0.561583, 0.487200, 0.444400 } }, -{ 70103, { 0.549350, 0.415500, 0.344525, 0.303000 } }, -{ 70104, { 0.560662, 0.424933, 0.357650, 0.308500 } }, -{ 70105, { 0.566275, 0.438433, 0.364575, 0.313700 } }, -{ 70106, { 0.599775, 0.460033, 0.383200, 0.337550 } }, -{ 70107, { 0.635238, 0.489750, 0.408925, 0.358750 } }, -{ 70108, { 0.593487, 0.470683, 0.405500, 0.365900 } }, -{ 70109, { 0.622250, 0.494050, 0.430375, 0.383850 } }, -{ 70110, { 0.657725, 0.524967, 0.460425, 0.416400 } }, -{ 70111, { 0.696450, 0.567133, 0.501450, 0.460800 } }, -{ 70203, { 0.611600, 0.549250, 0.514275, 0.484950 } }, -{ 70204, { 0.621100, 0.545367, 0.505775, 0.481450 } }, -{ 70205, { 0.634200, 0.551617, 0.515000, 0.486250 } }, -{ 70206, { 0.645563, 0.555433, 0.508525, 0.477150 } }, -{ 70207, { 0.665488, 0.566550, 0.520925, 0.489550 } }, -{ 70208, { 0.681575, 0.593467, 0.550600, 0.524750 } }, -{ 70209, { 0.701113, 0.608083, 0.560450, 0.536300 } }, -{ 70210, { 0.726838, 0.624467, 0.572425, 0.548250 } }, -{ 70211, { 0.754563, 0.656283, 0.594225, 0.558150 } }, -{ 71104, { 0.512750, 0.350417, 0.264550, 0.216200 } }, -{ 71105, { 0.528850, 0.369000, 0.286975, 0.230200 } }, -{ 71106, { 0.547200, 0.393933, 0.309375, 0.251600 } }, -{ 71107, { 0.585550, 0.427233, 0.339825, 0.279150 } }, -{ 71108, { 0.599650, 0.445783, 0.363475, 0.309750 } }, -{ 71109, { 0.572087, 0.433050, 0.361125, 0.316300 } }, -{ 71110, { 0.610487, 0.465467, 0.390825, 0.342150 } }, -{ 71111, { 0.647575, 0.503700, 0.432725, 0.390050 } }, -{ 71112, { 0.703662, 0.562233, 0.494850, 0.460550 } }, -{ 71204, { 0.543100, 0.468933, 0.427475, 0.393500 } }, -{ 71205, { 0.560638, 0.476717, 0.437200, 0.408000 } }, -{ 71206, { 0.578850, 0.483267, 0.440675, 0.408050 } }, -{ 71207, { 0.594387, 0.489250, 0.443050, 0.411900 } }, -{ 71208, { 0.611750, 0.514117, 0.470200, 0.442250 } }, -{ 71209, { 0.636775, 0.532250, 0.486750, 0.450400 } }, -{ 71210, { 0.672350, 0.555367, 0.499375, 0.463250 } }, -{ 71211, { 0.709275, 0.580383, 0.527200, 0.483850 } }, -{ 71212, { 0.751687, 0.628100, 0.560100, 0.516900 } } +static const RoundData FlopValues[] = { + { 106, { 0.160312, 0.078750, 0.048325, 0.033350 } }, + { 206, { 0.185012, 0.099666, 0.071425, 0.053450 } }, + { 306, { 0.199662, 0.115567, 0.081625, 0.067500 } }, + { 406, { 0.199712, 0.121383, 0.088775, 0.070750 } }, + { 1206, { 0.191537, 0.110250, 0.078400, 0.057350 } }, + { 1306, { 0.212125, 0.119433, 0.089325, 0.071200 } }, + { 1406, { 0.219762, 0.133983, 0.101875, 0.080000 } }, + { 2306, { 0.228400, 0.142983, 0.103950, 0.087900 } }, + { 2406, { 0.242275, 0.155600, 0.124050, 0.100400 } }, + { 3406, { 0.237262, 0.164333, 0.125725, 0.099750 } }, + { 107, { 0.165612, 0.083566, 0.054850, 0.043750 } }, + { 207, { 0.183363, 0.101283, 0.068825, 0.054500 } }, + { 307, { 0.203250, 0.114933, 0.081875, 0.068600 } }, + { 407, { 0.221225, 0.119917, 0.085025, 0.065600 } }, + { 1207, { 0.199200, 0.113817, 0.078950, 0.061400 } }, + { 1307, { 0.214062, 0.126883, 0.092250, 0.075100 } }, + { 1407, { 0.245438, 0.141217, 0.102000, 0.081350 } }, + { 2307, { 0.231950, 0.141733, 0.105300, 0.084550 } }, + { 2407, { 0.267275, 0.166483, 0.126300, 0.101750 } }, + { 3407, { 0.257300, 0.168650, 0.129225, 0.100700 } }, + { 108, { 0.169475, 0.082066, 0.052325, 0.037950 } }, + { 208, { 0.186787, 0.100850, 0.070175, 0.052000 } }, + { 308, { 0.215725, 0.112733, 0.073875, 0.054150 } }, + { 408, { 0.253450, 0.134367, 0.092525, 0.072050 } }, + { 1208, { 0.195000, 0.111100, 0.077225, 0.056750 } }, + { 1308, { 0.235763, 0.123700, 0.084700, 0.065500 } }, + { 1408, { 0.262225, 0.140717, 0.099175, 0.074350 } }, + { 2308, { 0.242300, 0.135200, 0.096750, 0.074400 } }, + { 2408, { 0.287313, 0.160033, 0.116075, 0.094650 } }, + { 3408, { 0.277012, 0.163533, 0.116650, 0.095300 } }, + { 109, { 0.186037, 0.085966, 0.051825, 0.038350 } }, + { 209, { 0.200400, 0.098150, 0.066675, 0.050650 } }, + { 309, { 0.220688, 0.108317, 0.073075, 0.052350 } }, + { 409, { 0.275813, 0.135517, 0.086325, 0.063050 } }, + { 1209, { 0.219025, 0.115400, 0.080150, 0.061800 } }, + { 1309, { 0.246425, 0.130383, 0.092425, 0.068150 } }, + { 1409, { 0.304438, 0.158233, 0.108500, 0.081800 } }, + { 2309, { 0.254300, 0.143233, 0.104850, 0.079500 } }, + { 2409, { 0.326638, 0.178833, 0.127100, 0.099550 } }, + { 3409, { 0.323150, 0.178717, 0.129425, 0.097950 } }, + { 110, { 0.190100, 0.071466, 0.035575, 0.021400 } }, + { 210, { 0.213588, 0.085183, 0.046225, 0.028200 } }, + { 310, { 0.275788, 0.119583, 0.068500, 0.044200 } }, + { 410, { 0.320487, 0.149867, 0.090450, 0.068700 } }, + { 1210, { 0.225675, 0.098333, 0.056975, 0.036900 } }, + { 1310, { 0.302862, 0.133517, 0.078175, 0.052900 } }, + { 1410, { 0.344763, 0.168200, 0.106625, 0.075650 } }, + { 2310, { 0.310525, 0.151150, 0.092025, 0.066950 } }, + { 2410, { 0.365463, 0.188500, 0.121275, 0.093100 } }, + { 3410, { 0.386962, 0.214933, 0.151325, 0.119000 } }, + { 111, { 0.191887, 0.074800, 0.036500, 0.023150 } }, + { 211, { 0.197437, 0.074633, 0.038425, 0.021600 } }, + { 311, { 0.279463, 0.118717, 0.068550, 0.045300 } }, + { 411, { 0.375588, 0.179217, 0.106850, 0.074700 } }, + { 1211, { 0.226475, 0.101767, 0.058650, 0.037050 } }, + { 1311, { 0.302500, 0.135333, 0.078800, 0.054450 } }, + { 1411, { 0.402687, 0.198867, 0.126825, 0.083850 } }, + { 2311, { 0.311925, 0.150033, 0.097125, 0.066200 } }, + { 2411, { 0.420350, 0.219233, 0.141225, 0.100850 } }, + { 3411, { 0.476650, 0.281733, 0.202000, 0.160500 } }, + { 112, { 0.271713, 0.106417, 0.054675, 0.029350 } }, + { 212, { 0.305475, 0.124833, 0.068875, 0.039100 } }, + { 312, { 0.393087, 0.183367, 0.100875, 0.064600 } }, + { 412, { 0.453037, 0.240100, 0.146400, 0.101700 } }, + { 1212, { 0.310725, 0.143767, 0.078825, 0.049750 } }, + { 1312, { 0.420900, 0.205133, 0.117425, 0.078750 } }, + { 1412, { 0.481088, 0.263833, 0.160975, 0.114650 } }, + { 2312, { 0.422438, 0.215050, 0.133150, 0.089900 } }, + { 2412, { 0.498025, 0.283417, 0.184950, 0.133700 } }, + { 3412, { 0.509725, 0.303550, 0.211825, 0.153700 } }, + { 10201, { 0.277375, 0.133517, 0.076325, 0.042900 } }, + { 10102, { 0.317775, 0.177483, 0.112400, 0.077850 } }, + { 10202, { 0.291087, 0.147300, 0.085675, 0.051200 } }, + { 10103, { 0.328775, 0.179900, 0.113375, 0.079500 } }, + { 10203, { 0.295988, 0.150617, 0.089500, 0.056800 } }, + { 10104, { 0.315550, 0.168617, 0.103550, 0.068600 } }, + { 10204, { 0.308200, 0.155367, 0.093075, 0.056450 } }, + { 10005, { 0.270150, 0.170433, 0.124725, 0.096250 } }, + { 10105, { 0.296262, 0.172950, 0.126950, 0.095050 } }, + { 10205, { 0.336438, 0.172217, 0.103250, 0.068550 } }, + { 10006, { 0.289838, 0.171233, 0.128600, 0.096950 } }, + { 10106, { 0.324525, 0.182750, 0.130125, 0.101000 } }, + { 10206, { 0.381512, 0.197733, 0.124625, 0.086700 } }, + { 10007, { 0.310425, 0.175450, 0.128100, 0.096550 } }, + { 10107, { 0.367663, 0.207800, 0.144725, 0.110750 } }, + { 10207, { 0.425438, 0.224617, 0.138200, 0.092250 } }, + { 10008, { 0.352000, 0.194683, 0.136925, 0.103950 } }, + { 10108, { 0.422225, 0.237950, 0.164950, 0.121300 } }, + { 10208, { 0.485413, 0.273783, 0.171725, 0.114450 } }, + { 10009, { 0.397750, 0.222400, 0.151450, 0.116250 } }, + { 10109, { 0.470425, 0.261367, 0.170925, 0.121600 } }, + { 10209, { 0.532787, 0.305733, 0.190700, 0.118150 } }, + { 10010, { 0.454037, 0.251483, 0.168825, 0.126050 } }, + { 10110, { 0.550462, 0.334933, 0.229600, 0.167950 } }, + { 10210, { 0.613350, 0.392250, 0.259175, 0.174450 } }, + { 10011, { 0.526900, 0.317983, 0.217350, 0.153850 } }, + { 10111, { 0.642038, 0.431733, 0.313825, 0.236850 } }, + { 10012, { 0.611275, 0.396950, 0.277325, 0.206950 } }, + { 11200, { 0.573987, 0.362933, 0.252050, 0.192800 } }, + { 11101, { 0.635763, 0.427050, 0.305575, 0.227200 } }, + { 11201, { 0.579963, 0.368700, 0.259525, 0.193700 } }, + { 11002, { 0.641050, 0.437717, 0.313950, 0.235550 } }, + { 11102, { 0.654863, 0.449200, 0.321575, 0.247450 } }, + { 11202, { 0.597325, 0.389683, 0.268975, 0.203750 } }, + { 11003, { 0.647775, 0.442267, 0.316825, 0.243500 } }, + { 11103, { 0.654050, 0.446483, 0.320175, 0.245900 } }, + { 11203, { 0.627513, 0.412067, 0.290050, 0.212450 } }, + { 11004, { 0.689688, 0.487583, 0.362425, 0.266950 } }, + { 11104, { 0.673050, 0.468117, 0.336500, 0.260750 } }, + { 11204, { 0.651563, 0.437467, 0.313000, 0.230700 } }, + { 11005, { 0.731213, 0.553867, 0.428225, 0.340550 } }, + { 11105, { 0.697263, 0.497867, 0.368350, 0.288650 } }, + { 11205, { 0.661388, 0.454883, 0.325175, 0.247450 } }, + { 11006, { 0.753262, 0.580283, 0.452975, 0.366400 } }, + { 11106, { 0.716875, 0.529517, 0.399350, 0.310700 } }, + { 11206, { 0.679713, 0.473533, 0.346825, 0.255500 } }, + { 11007, { 0.780038, 0.616067, 0.488425, 0.400650 } }, + { 11107, { 0.743613, 0.565267, 0.439275, 0.344200 } }, + { 11207, { 0.665825, 0.462400, 0.333175, 0.252750 } }, + { 11008, { 0.801338, 0.649083, 0.529225, 0.437450 } }, + { 11108, { 0.747300, 0.571033, 0.439275, 0.343300 } }, + { 11208, { 0.665063, 0.462650, 0.334500, 0.250000 } }, + { 11009, { 0.795763, 0.640850, 0.516675, 0.427450 } }, + { 11109, { 0.765500, 0.594217, 0.458475, 0.370950 } }, + { 11209, { 0.694300, 0.492983, 0.361300, 0.269800 } }, + { 11010, { 0.818762, 0.677283, 0.564350, 0.469850 } }, + { 11110, { 0.755775, 0.577433, 0.448450, 0.347350 } }, + { 11210, { 0.709525, 0.511550, 0.379400, 0.291150 } }, + { 11011, { 0.843975, 0.713083, 0.610900, 0.520750 } }, + { 11111, { 0.807163, 0.651467, 0.525225, 0.432100 } }, + { 11012, { 0.866263, 0.749767, 0.655075, 0.569900 } }, + { 12300, { 0.446325, 0.224100, 0.133125, 0.097100 } }, + { 12201, { 0.541987, 0.314517, 0.195500, 0.133600 } }, + { 12301, { 0.460913, 0.241117, 0.145000, 0.097950 } }, + { 12102, { 0.641775, 0.424583, 0.289350, 0.206500 } }, + { 12202, { 0.565462, 0.330867, 0.212075, 0.148150 } }, + { 12302, { 0.481162, 0.253533, 0.154325, 0.106450 } }, + { 12103, { 0.655763, 0.442417, 0.305875, 0.222850 } }, + { 12203, { 0.576050, 0.347733, 0.221600, 0.146250 } }, + { 12303, { 0.499538, 0.274933, 0.163900, 0.111500 } }, + { 12104, { 0.667987, 0.449733, 0.310625, 0.223550 } }, + { 12204, { 0.595762, 0.367533, 0.240700, 0.169500 } }, + { 12304, { 0.529400, 0.299100, 0.185825, 0.123600 } }, + { 12005, { 0.709287, 0.502400, 0.365725, 0.270400 } }, + { 12105, { 0.673400, 0.460317, 0.323550, 0.229950 } }, + { 12205, { 0.613313, 0.387950, 0.257175, 0.181950 } }, + { 12305, { 0.544462, 0.309800, 0.191700, 0.129750 } }, + { 12006, { 0.719650, 0.522967, 0.382550, 0.291200 } }, + { 12106, { 0.692875, 0.482733, 0.345825, 0.253050 } }, + { 12206, { 0.633238, 0.413717, 0.276850, 0.195200 } }, + { 12306, { 0.562913, 0.339250, 0.215550, 0.147250 } }, + { 12007, { 0.759613, 0.584300, 0.446275, 0.344550 } }, + { 12107, { 0.709600, 0.507483, 0.371300, 0.274150 } }, + { 12207, { 0.666238, 0.449700, 0.310075, 0.219450 } }, + { 12307, { 0.583650, 0.356250, 0.224450, 0.155600 } }, + { 12008, { 0.767475, 0.593817, 0.463025, 0.370750 } }, + { 12108, { 0.718925, 0.524250, 0.385325, 0.294600 } }, + { 12208, { 0.695125, 0.486433, 0.349075, 0.250250 } }, + { 12009, { 0.787362, 0.623250, 0.502500, 0.397000 } }, + { 12109, { 0.740750, 0.552867, 0.412425, 0.317100 } }, + { 12209, { 0.712725, 0.509083, 0.365475, 0.262950 } }, + { 12010, { 0.826462, 0.686000, 0.570850, 0.483000 } }, + { 12110, { 0.766262, 0.589100, 0.456425, 0.356700 } }, + { 12210, { 0.729612, 0.533183, 0.393700, 0.292100 } }, + { 12011, { 0.833638, 0.701600, 0.588350, 0.496800 } }, + { 12111, { 0.778250, 0.605767, 0.477175, 0.380450 } }, + { 12012, { 0.863613, 0.751683, 0.652550, 0.561100 } }, + { 21000, { 0.625838, 0.410617, 0.270925, 0.190000 } }, + { 21001, { 0.648913, 0.439150, 0.299050, 0.207200 } }, + { 21101, { 0.660925, 0.451067, 0.324350, 0.240950 } }, + { 21002, { 0.679150, 0.472167, 0.334075, 0.247900 } }, + { 21102, { 0.666275, 0.464717, 0.331075, 0.240200 } }, + { 21003, { 0.701150, 0.500167, 0.364575, 0.266300 } }, + { 21103, { 0.686625, 0.481400, 0.351650, 0.262200 } }, + { 21004, { 0.731800, 0.541583, 0.407800, 0.303500 } }, + { 21104, { 0.709675, 0.513417, 0.380125, 0.291950 } }, + { 21005, { 0.755663, 0.579500, 0.440825, 0.339550 } }, + { 21105, { 0.736100, 0.553650, 0.421150, 0.324500 } }, + { 21006, { 0.782800, 0.608600, 0.476850, 0.380650 } }, + { 21106, { 0.760350, 0.581683, 0.457225, 0.358500 } }, + { 21007, { 0.810125, 0.657750, 0.532425, 0.434600 } }, + { 21107, { 0.781587, 0.614050, 0.484450, 0.396600 } }, + { 21008, { 0.795125, 0.637433, 0.513125, 0.413050 } }, + { 21108, { 0.782750, 0.621833, 0.493250, 0.402300 } }, + { 21009, { 0.821125, 0.682633, 0.566600, 0.465600 } }, + { 21109, { 0.811562, 0.663167, 0.536500, 0.449750 } }, + { 21010, { 0.850012, 0.720967, 0.610900, 0.517400 } }, + { 21110, { 0.833425, 0.695433, 0.580225, 0.491300 } }, + { 21011, { 0.881563, 0.773350, 0.678975, 0.596350 } }, + { 21111, { 0.861350, 0.739867, 0.640600, 0.552200 } }, + { 21112, { 0.883838, 0.784233, 0.693675, 0.608300 } }, + { 22000, { 0.494837, 0.276100, 0.173950, 0.121300 } }, + { 22001, { 0.512687, 0.300783, 0.191075, 0.134950 } }, + { 22101, { 0.579575, 0.352150, 0.223700, 0.160050 } }, + { 22002, { 0.539288, 0.318483, 0.207925, 0.148700 } }, + { 22102, { 0.601537, 0.374417, 0.246825, 0.171800 } }, + { 22003, { 0.559063, 0.343450, 0.230575, 0.162500 } }, + { 22103, { 0.624287, 0.398150, 0.266900, 0.191750 } }, + { 22004, { 0.586975, 0.373667, 0.250275, 0.186900 } }, + { 22104, { 0.643887, 0.424983, 0.292000, 0.206800 } }, + { 22005, { 0.619375, 0.412650, 0.288550, 0.209100 } }, + { 22105, { 0.663300, 0.453867, 0.309300, 0.223150 } }, + { 22006, { 0.650125, 0.443033, 0.311900, 0.229550 } }, + { 22106, { 0.684963, 0.475650, 0.336650, 0.248150 } }, + { 22007, { 0.696263, 0.490017, 0.355825, 0.267800 } }, + { 22107, { 0.708137, 0.501767, 0.365350, 0.273450 } }, + { 22008, { 0.738287, 0.549433, 0.413700, 0.314500 } }, + { 22108, { 0.727075, 0.535983, 0.393100, 0.300650 } }, + { 22009, { 0.847912, 0.722017, 0.616725, 0.523850 } }, + { 22109, { 0.812725, 0.658717, 0.543300, 0.446600 } }, + { 22010, { 0.868900, 0.752417, 0.656675, 0.561700 } }, + { 22110, { 0.821000, 0.680383, 0.562475, 0.470100 } }, + { 22011, { 0.888225, 0.785000, 0.693000, 0.612450 } }, + { 22111, { 0.833363, 0.700750, 0.589450, 0.503050 } }, + { 22112, { 0.858475, 0.738600, 0.636825, 0.553700 } }, + { 22201, { 0.856137, 0.742967, 0.651625, 0.574600 } }, + { 22202, { 0.859688, 0.746217, 0.656150, 0.580900 } }, + { 22203, { 0.862888, 0.752333, 0.664400, 0.586800 } }, + { 22204, { 0.858088, 0.742617, 0.649500, 0.571800 } }, + { 22205, { 0.853263, 0.734683, 0.641875, 0.559850 } }, + { 22206, { 0.867075, 0.756617, 0.664375, 0.591450 } }, + { 22207, { 0.872938, 0.766767, 0.678900, 0.605650 } }, + { 22208, { 0.874800, 0.771667, 0.688800, 0.616650 } }, + { 22209, { 0.887825, 0.792483, 0.719900, 0.650000 } }, + { 22210, { 0.895650, 0.808067, 0.735575, 0.671050 } }, + { 22211, { 0.919162, 0.850183, 0.785825, 0.729700 } }, + { 22212, { 0.935600, 0.877833, 0.825725, 0.781800 } }, + { 30001, { 0.344288, 0.222633, 0.164400, 0.127100 } }, + { 30002, { 0.347087, 0.227383, 0.170950, 0.136900 } }, + { 30102, { 0.363162, 0.236250, 0.169975, 0.122950 } }, + { 30003, { 0.353500, 0.234733, 0.177000, 0.140700 } }, + { 30103, { 0.364412, 0.236583, 0.172325, 0.132450 } }, + { 30004, { 0.367337, 0.240800, 0.187725, 0.156750 } }, + { 30104, { 0.371575, 0.243267, 0.184725, 0.138900 } }, + { 30005, { 0.389600, 0.248250, 0.196350, 0.153950 } }, + { 30105, { 0.376387, 0.247067, 0.186375, 0.145050 } }, + { 30006, { 0.422950, 0.269267, 0.211625, 0.179050 } }, + { 30106, { 0.388362, 0.249483, 0.191125, 0.157850 } }, + { 30007, { 0.463462, 0.294067, 0.218500, 0.186350 } }, + { 30107, { 0.416438, 0.258417, 0.200850, 0.163700 } }, + { 30008, { 0.512837, 0.321717, 0.238700, 0.197850 } }, + { 30108, { 0.466575, 0.291450, 0.223225, 0.184350 } }, + { 30009, { 0.577688, 0.379667, 0.282675, 0.217700 } }, + { 30109, { 0.518075, 0.330517, 0.245975, 0.199450 } }, + { 30010, { 0.645362, 0.447467, 0.331675, 0.263600 } }, + { 30110, { 0.577037, 0.370500, 0.274075, 0.212850 } }, + { 30011, { 0.718850, 0.532200, 0.412975, 0.335200 } }, + { 30111, { 0.642912, 0.441300, 0.324475, 0.253150 } }, + { 30112, { 0.715350, 0.528400, 0.403125, 0.326600 } }, + { 41104, { 0.311063, 0.191417, 0.143925, 0.111150 } }, + { 41204, { 0.622650, 0.408700, 0.282950, 0.208600 } }, + { 41005, { 0.241925, 0.148983, 0.109150, 0.078200 } }, + { 41105, { 0.353787, 0.204000, 0.147650, 0.110350 } }, + { 41205, { 0.637350, 0.427133, 0.301150, 0.219250 } }, + { 41006, { 0.262412, 0.162067, 0.120525, 0.091800 } }, + { 41106, { 0.374837, 0.216017, 0.156400, 0.121500 } }, + { 41206, { 0.654100, 0.446733, 0.315550, 0.227350 } }, + { 41007, { 0.281788, 0.166167, 0.119675, 0.090250 } }, + { 41107, { 0.417137, 0.238983, 0.166225, 0.126500 } }, + { 41207, { 0.673787, 0.468433, 0.336425, 0.245300 } }, + { 41008, { 0.294438, 0.160567, 0.108150, 0.080150 } }, + { 41108, { 0.469050, 0.273150, 0.181300, 0.140800 } }, + { 41208, { 0.694975, 0.492300, 0.357850, 0.263450 } }, + { 41009, { 0.327000, 0.172217, 0.113000, 0.081250 } }, + { 41109, { 0.525288, 0.312350, 0.207875, 0.149050 } }, + { 41209, { 0.711425, 0.518733, 0.378975, 0.290700 } }, + { 41010, { 0.382525, 0.202600, 0.131125, 0.096650 } }, + { 41110, { 0.529775, 0.321067, 0.214900, 0.154300 } }, + { 41210, { 0.743725, 0.556700, 0.417775, 0.317000 } }, + { 41011, { 0.413625, 0.212317, 0.136275, 0.095900 } }, + { 41211, { 0.762962, 0.588517, 0.456225, 0.355800 } }, + { 41012, { 0.492750, 0.298683, 0.221950, 0.185600 } }, + { 41212, { 0.834475, 0.703650, 0.590950, 0.507050 } }, + { 42004, { 0.272075, 0.189533, 0.154000, 0.130900 } }, + { 42204, { 0.558087, 0.350000, 0.238125, 0.171450 } }, + { 42005, { 0.293525, 0.196417, 0.156200, 0.138000 } }, + { 42205, { 0.574750, 0.361550, 0.250350, 0.179300 } }, + { 42006, { 0.322700, 0.204917, 0.159825, 0.138950 } }, + { 42206, { 0.592150, 0.382783, 0.260500, 0.193550 } }, + { 42007, { 0.354563, 0.217383, 0.170950, 0.147300 } }, + { 42207, { 0.614363, 0.399333, 0.278975, 0.199000 } }, + { 42008, { 0.383175, 0.232967, 0.176525, 0.149850 } }, + { 42208, { 0.632000, 0.419717, 0.295275, 0.212400 } }, + { 42009, { 0.380225, 0.237933, 0.187000, 0.151900 } }, + { 42209, { 0.651100, 0.440883, 0.307875, 0.223250 } }, + { 42010, { 0.432150, 0.273117, 0.208100, 0.175100 } }, + { 42210, { 0.680638, 0.472867, 0.336475, 0.245050 } }, + { 42011, { 0.486375, 0.309800, 0.239700, 0.202900 } }, + { 42211, { 0.703037, 0.499717, 0.368450, 0.272750 } }, + { 42012, { 0.539112, 0.356167, 0.271325, 0.235650 } }, + { 42212, { 0.774487, 0.610033, 0.485250, 0.399300 } }, + { 43104, { 0.409863, 0.271383, 0.221500, 0.193500 } }, + { 43204, { 0.674612, 0.484033, 0.367575, 0.292950 } }, + { 43005, { 0.273612, 0.200917, 0.165400, 0.149900 } }, + { 43105, { 0.417563, 0.270517, 0.221725, 0.195200 } }, + { 43205, { 0.684512, 0.498017, 0.378375, 0.305750 } }, + { 43006, { 0.309837, 0.220700, 0.186450, 0.170800 } }, + { 43106, { 0.430175, 0.290183, 0.239550, 0.212950 } }, + { 43206, { 0.693287, 0.504233, 0.389650, 0.311650 } }, + { 43007, { 0.333612, 0.221617, 0.184400, 0.161500 } }, + { 43107, { 0.474075, 0.315533, 0.250375, 0.221250 } }, + { 43207, { 0.714700, 0.529633, 0.403875, 0.332650 } }, + { 43008, { 0.366375, 0.235083, 0.191950, 0.171900 } }, + { 43108, { 0.478425, 0.318050, 0.256450, 0.218950 } }, + { 43208, { 0.730437, 0.556533, 0.435500, 0.349800 } }, + { 43009, { 0.394825, 0.241567, 0.189150, 0.165250 } }, + { 43109, { 0.582588, 0.391300, 0.306525, 0.258850 } }, + { 43209, { 0.754012, 0.580250, 0.462725, 0.377800 } }, + { 43010, { 0.445638, 0.270467, 0.203300, 0.174450 } }, + { 43110, { 0.581725, 0.391300, 0.296350, 0.244000 } }, + { 43210, { 0.774787, 0.608450, 0.486750, 0.405050 } }, + { 43011, { 0.493063, 0.298867, 0.218075, 0.174500 } }, + { 43211, { 0.795150, 0.640217, 0.524175, 0.430450 } }, + { 43012, { 0.554212, 0.354300, 0.263500, 0.210650 } }, + { 43212, { 0.817175, 0.673367, 0.567850, 0.482750 } }, + { 44004, { 0.307038, 0.228567, 0.195650, 0.175900 } }, + { 44204, { 0.658875, 0.465283, 0.344600, 0.268000 } }, + { 44005, { 0.329525, 0.231150, 0.197550, 0.172200 } }, + { 44205, { 0.675550, 0.480683, 0.358925, 0.279700 } }, + { 44006, { 0.362038, 0.249583, 0.202575, 0.178200 } }, + { 44206, { 0.695137, 0.501583, 0.380750, 0.303800 } }, + { 44007, { 0.396062, 0.259800, 0.212000, 0.185900 } }, + { 44207, { 0.710562, 0.522133, 0.402875, 0.313250 } }, + { 44008, { 0.409938, 0.284817, 0.239925, 0.214050 } }, + { 44208, { 0.729025, 0.545667, 0.423575, 0.327600 } }, + { 44009, { 0.441763, 0.299717, 0.246700, 0.216600 } }, + { 44209, { 0.749025, 0.575000, 0.452725, 0.361400 } }, + { 44010, { 0.486963, 0.324150, 0.258175, 0.216700 } }, + { 44210, { 0.779200, 0.613317, 0.491025, 0.396800 } }, + { 44011, { 0.544312, 0.368567, 0.289350, 0.244350 } }, + { 44211, { 0.807025, 0.663100, 0.550800, 0.457450 } }, + { 44012, { 0.602287, 0.418417, 0.322750, 0.264100 } }, + { 44212, { 0.833538, 0.697883, 0.591800, 0.495950 } }, + { 45103, { 0.446537, 0.320717, 0.258300, 0.229650 } }, + { 45203, { 0.660650, 0.475000, 0.364250, 0.291550 } }, + { 45104, { 0.449338, 0.315950, 0.256475, 0.216550 } }, + { 45204, { 0.669375, 0.477967, 0.357125, 0.286200 } }, + { 45005, { 0.354975, 0.267583, 0.218450, 0.186250 } }, + { 45105, { 0.451525, 0.319533, 0.254850, 0.220550 } }, + { 45205, { 0.685837, 0.490700, 0.370900, 0.298350 } }, + { 45006, { 0.374312, 0.270217, 0.223775, 0.187900 } }, + { 45106, { 0.492350, 0.333350, 0.260700, 0.220150 } }, + { 45206, { 0.700025, 0.512533, 0.395450, 0.314200 } }, + { 45007, { 0.396838, 0.276150, 0.226725, 0.195000 } }, + { 45107, { 0.502000, 0.341300, 0.272350, 0.227850 } }, + { 45207, { 0.715512, 0.528850, 0.408850, 0.323650 } }, + { 45008, { 0.421350, 0.283000, 0.225525, 0.187700 } }, + { 45108, { 0.543037, 0.368167, 0.283500, 0.237700 } }, + { 45208, { 0.729588, 0.551767, 0.429675, 0.340050 } }, + { 45009, { 0.458587, 0.295383, 0.230075, 0.189400 } }, + { 45109, { 0.587450, 0.403633, 0.311325, 0.250400 } }, + { 45209, { 0.747225, 0.571583, 0.449975, 0.360700 } }, + { 45010, { 0.494925, 0.321633, 0.246600, 0.199150 } }, + { 45110, { 0.626425, 0.454617, 0.366225, 0.319700 } }, + { 45210, { 0.768275, 0.598867, 0.476275, 0.387300 } }, + { 45011, { 0.564175, 0.402817, 0.341375, 0.308450 } }, + { 45211, { 0.835438, 0.712033, 0.618225, 0.548900 } }, + { 46003, { 0.393412, 0.325133, 0.290800, 0.262650 } }, + { 46203, { 0.616788, 0.428533, 0.332000, 0.270250 } }, + { 46004, { 0.408050, 0.324033, 0.290675, 0.273100 } }, + { 46204, { 0.621762, 0.428233, 0.330775, 0.263500 } }, + { 46005, { 0.426350, 0.331800, 0.294425, 0.275050 } }, + { 46205, { 0.637687, 0.442550, 0.339525, 0.274300 } }, + { 46006, { 0.424287, 0.298133, 0.242425, 0.208950 } }, + { 46206, { 0.650700, 0.460850, 0.345900, 0.274650 } }, + { 46007, { 0.456813, 0.311117, 0.242075, 0.205300 } }, + { 46207, { 0.670850, 0.475450, 0.359300, 0.281500 } }, + { 46008, { 0.489600, 0.325300, 0.256975, 0.215200 } }, + { 46208, { 0.684512, 0.491350, 0.376250, 0.298350 } }, + { 46009, { 0.523763, 0.378883, 0.326650, 0.289750 } }, + { 46209, { 0.702950, 0.515500, 0.390650, 0.306250 } }, + { 46010, { 0.566300, 0.411217, 0.355550, 0.324150 } }, + { 46210, { 0.720163, 0.538167, 0.419300, 0.329400 } }, + { 46011, { 0.612413, 0.458083, 0.383525, 0.338000 } }, + { 46211, { 0.788062, 0.642550, 0.538650, 0.467050 } }, + { 47103, { 0.471550, 0.373750, 0.339475, 0.320850 } }, + { 47203, { 0.712512, 0.547183, 0.449275, 0.393250 } }, + { 47104, { 0.475825, 0.373333, 0.330600, 0.303850 } }, + { 47204, { 0.715800, 0.549467, 0.452925, 0.389600 } }, + { 47005, { 0.393350, 0.323100, 0.291775, 0.273500 } }, + { 47105, { 0.505525, 0.382067, 0.335800, 0.312800 } }, + { 47205, { 0.726325, 0.563583, 0.462500, 0.398700 } }, + { 47006, { 0.409537, 0.327417, 0.298125, 0.279350 } }, + { 47106, { 0.513325, 0.379950, 0.337075, 0.312600 } }, + { 47206, { 0.743337, 0.574517, 0.476475, 0.403150 } }, + { 47007, { 0.431150, 0.331817, 0.294775, 0.280500 } }, + { 47107, { 0.549813, 0.403817, 0.348025, 0.318450 } }, + { 47207, { 0.758500, 0.603533, 0.494375, 0.422850 } }, + { 47008, { 0.465612, 0.343300, 0.298125, 0.279450 } }, + { 47108, { 0.589638, 0.435017, 0.364825, 0.326650 } }, + { 47208, { 0.773550, 0.620767, 0.512475, 0.446550 } }, + { 47009, { 0.498600, 0.360433, 0.306375, 0.280400 } }, + { 47109, { 0.638363, 0.480517, 0.390100, 0.343050 } }, + { 47209, { 0.793125, 0.644517, 0.538925, 0.467600 } }, + { 47010, { 0.537250, 0.381883, 0.320025, 0.287450 } }, + { 47110, { 0.650475, 0.488167, 0.406400, 0.362350 } }, + { 47210, { 0.808975, 0.667967, 0.566075, 0.487500 } }, + { 47011, { 0.574788, 0.410933, 0.343250, 0.307450 } }, + { 47211, { 0.829862, 0.702650, 0.604125, 0.536500 } }, + { 48003, { 0.437437, 0.372950, 0.345550, 0.321600 } }, + { 48203, { 0.758550, 0.601850, 0.499875, 0.436700 } }, + { 48004, { 0.447738, 0.377883, 0.345675, 0.325550 } }, + { 48204, { 0.738812, 0.578317, 0.474075, 0.406200 } }, + { 48005, { 0.465250, 0.385383, 0.347550, 0.322950 } }, + { 48205, { 0.754475, 0.590500, 0.489050, 0.417700 } }, + { 48006, { 0.485762, 0.392267, 0.355850, 0.335850 } }, + { 48206, { 0.770100, 0.612867, 0.509100, 0.440600 } }, + { 48007, { 0.513262, 0.407900, 0.362625, 0.332900 } }, + { 48207, { 0.784737, 0.636200, 0.527375, 0.458650 } }, + { 48008, { 0.549225, 0.424117, 0.375525, 0.349150 } }, + { 48208, { 0.801113, 0.660333, 0.550825, 0.474000 } }, + { 48009, { 0.562100, 0.447650, 0.398400, 0.369750 } }, + { 48209, { 0.820037, 0.682783, 0.580650, 0.504050 } }, + { 48010, { 0.597800, 0.470500, 0.408600, 0.383350 } }, + { 48210, { 0.834775, 0.709433, 0.607925, 0.533750 } }, + { 48011, { 0.638713, 0.500050, 0.437450, 0.395450 } }, + { 48211, { 0.854437, 0.742983, 0.650175, 0.577100 } }, + { 50005, { 0.510262, 0.313833, 0.218400, 0.154900 } }, + { 50006, { 0.525575, 0.335667, 0.233525, 0.178550 } }, + { 50007, { 0.562262, 0.376000, 0.277625, 0.215050 } }, + { 50008, { 0.579575, 0.398367, 0.308200, 0.237200 } }, + { 50009, { 0.633363, 0.452767, 0.361100, 0.293650 } }, + { 50010, { 0.647537, 0.484900, 0.385475, 0.331150 } }, + { 50011, { 0.677488, 0.526450, 0.447275, 0.392600 } }, + { 50103, { 0.599825, 0.397350, 0.275725, 0.204050 } }, + { 50104, { 0.567913, 0.353483, 0.233500, 0.158700 } }, + { 50105, { 0.544125, 0.342167, 0.237425, 0.171400 } }, + { 50106, { 0.556462, 0.367967, 0.265450, 0.197150 } }, + { 50107, { 0.580688, 0.399833, 0.297825, 0.234800 } }, + { 50108, { 0.608387, 0.433967, 0.340575, 0.277950 } }, + { 50109, { 0.658687, 0.485533, 0.390100, 0.332800 } }, + { 50110, { 0.679175, 0.521367, 0.437575, 0.385000 } }, + { 50201, { 0.499700, 0.279550, 0.172150, 0.106200 } }, + { 50202, { 0.510413, 0.295367, 0.188475, 0.129700 } }, + { 50203, { 0.526737, 0.318817, 0.216700, 0.148500 } }, + { 50204, { 0.544312, 0.342083, 0.234125, 0.168750 } }, + { 50205, { 0.562500, 0.367067, 0.264075, 0.197300 } }, + { 50206, { 0.578600, 0.391483, 0.287625, 0.222050 } }, + { 50207, { 0.633262, 0.447267, 0.341525, 0.269100 } }, + { 50207, { 0.634100, 0.445667, 0.338500, 0.268000 } }, + { 50207, { 0.632000, 0.444467, 0.341475, 0.268700 } }, + { 50300, { 0.522600, 0.300500, 0.184175, 0.114950 } }, + { 50301, { 0.534013, 0.316800, 0.203550, 0.133100 } }, + { 50302, { 0.542975, 0.334133, 0.216025, 0.145900 } }, + { 50303, { 0.573950, 0.358667, 0.244925, 0.177350 } }, + { 50304, { 0.582725, 0.384033, 0.267600, 0.197450 } }, + { 50305, { 0.592800, 0.400850, 0.294125, 0.230250 } }, + { 50306, { 0.607100, 0.429083, 0.330500, 0.264200 } }, + { 51005, { 0.517325, 0.400183, 0.320550, 0.259850 } }, + { 51006, { 0.476925, 0.357450, 0.279500, 0.220200 } }, + { 51007, { 0.453912, 0.328583, 0.258825, 0.198350 } }, + { 51008, { 0.488387, 0.358700, 0.286150, 0.228150 } }, + { 51009, { 0.519250, 0.375967, 0.308500, 0.255700 } }, + { 51010, { 0.557338, 0.410900, 0.342025, 0.296150 } }, + { 51011, { 0.621525, 0.474133, 0.406375, 0.365400 } }, + { 51012, { 0.679325, 0.538100, 0.468975, 0.427500 } }, + { 51104, { 0.455338, 0.338717, 0.256075, 0.199200 } }, + { 51105, { 0.411425, 0.287100, 0.210625, 0.155700 } }, + { 51106, { 0.447437, 0.314667, 0.240000, 0.182600 } }, + { 51107, { 0.468250, 0.332183, 0.257425, 0.208100 } }, + { 51108, { 0.507437, 0.364967, 0.291425, 0.240100 } }, + { 51109, { 0.551700, 0.404933, 0.333700, 0.280950 } }, + { 51110, { 0.615150, 0.467283, 0.391525, 0.347700 } }, + { 51111, { 0.666162, 0.519900, 0.449650, 0.407100 } }, + { 51201, { 0.366287, 0.215917, 0.134950, 0.088450 } }, + { 51202, { 0.389300, 0.230183, 0.152650, 0.098800 } }, + { 51203, { 0.429663, 0.258150, 0.174750, 0.119100 } }, + { 51204, { 0.450813, 0.288167, 0.201275, 0.151050 } }, + { 51205, { 0.491737, 0.320900, 0.230975, 0.173250 } }, + { 51206, { 0.539750, 0.360683, 0.267825, 0.211450 } }, + { 51207, { 0.554500, 0.388600, 0.299900, 0.248550 } }, + { 51208, { 0.653900, 0.502500, 0.419550, 0.360150 } }, + { 51209, { 0.651688, 0.606217, 0.429275, 0.486300 } }, + { 51210, { 0.663737, 0.510117, 0.430075, 0.395050 } }, + { 51300, { 0.374575, 0.212500, 0.133100, 0.085400 } }, + { 51301, { 0.393663, 0.236817, 0.155525, 0.107650 } }, + { 51302, { 0.433300, 0.261867, 0.177925, 0.122250 } }, + { 51303, { 0.473288, 0.295433, 0.205450, 0.148950 } }, + { 51304, { 0.528250, 0.338267, 0.241275, 0.176950 } }, + { 51305, { 0.541500, 0.364833, 0.274075, 0.213300 } }, + { 51306, { 0.585225, 0.404750, 0.304400, 0.245100 } }, + { 51307, { 0.680837, 0.511117, 0.418425, 0.357800 } }, + { 52005, { 0.433787, 0.325783, 0.254575, 0.208050 } }, + { 52006, { 0.434525, 0.313600, 0.231975, 0.173100 } }, + { 52007, { 0.411488, 0.289517, 0.217100, 0.168100 } }, + { 52008, { 0.440550, 0.317383, 0.242675, 0.190650 } }, + { 52009, { 0.497812, 0.357500, 0.286875, 0.236250 } }, + { 52010, { 0.530238, 0.388467, 0.316000, 0.269350 } }, + { 52011, { 0.587000, 0.442150, 0.374575, 0.328550 } }, + { 52012, { 0.644625, 0.497233, 0.438425, 0.401100 } }, + { 52104, { 0.439450, 0.322667, 0.243000, 0.183300 } }, + { 52105, { 0.396050, 0.270767, 0.197225, 0.145500 } }, + { 52106, { 0.426988, 0.296667, 0.222800, 0.167400 } }, + { 52107, { 0.455850, 0.313850, 0.243925, 0.197550 } }, + { 52108, { 0.509225, 0.357333, 0.291600, 0.242000 } }, + { 52109, { 0.545037, 0.393867, 0.321400, 0.278350 } }, + { 52110, { 0.592600, 0.440233, 0.366100, 0.325250 } }, + { 52111, { 0.648587, 0.500317, 0.427300, 0.392050 } }, + { 52202, { 0.359825, 0.235550, 0.152900, 0.109500 } }, + { 52203, { 0.382650, 0.251150, 0.173950, 0.120400 } }, + { 52204, { 0.399975, 0.260900, 0.191075, 0.134100 } }, + { 52205, { 0.426200, 0.280567, 0.208000, 0.154250 } }, + { 52206, { 0.459788, 0.311433, 0.238600, 0.191850 } }, + { 52207, { 0.496225, 0.342267, 0.275250, 0.218400 } }, + { 52208, { 0.553863, 0.398000, 0.323150, 0.282750 } }, + { 52209, { 0.605888, 0.444450, 0.369800, 0.321600 } }, + { 52210, { 0.652725, 0.499567, 0.424825, 0.383000 } }, + { 52301, { 0.364625, 0.219883, 0.144425, 0.094500 } }, + { 52302, { 0.378400, 0.238967, 0.161425, 0.109800 } }, + { 52303, { 0.408938, 0.263950, 0.185900, 0.133650 } }, + { 52304, { 0.432013, 0.283050, 0.207225, 0.155200 } }, + { 52305, { 0.476237, 0.316733, 0.239075, 0.192950 } }, + { 52306, { 0.510787, 0.351550, 0.277225, 0.229000 } }, + { 52307, { 0.553238, 0.390633, 0.313825, 0.265550 } }, + { 53005, { 0.671550, 0.462267, 0.326050, 0.239800 } }, + { 53006, { 0.714975, 0.521183, 0.379050, 0.285700 } }, + { 53007, { 0.725888, 0.539000, 0.401425, 0.312350 } }, + { 53008, { 0.765875, 0.595433, 0.471975, 0.376500 } }, + { 53009, { 0.792950, 0.635133, 0.520575, 0.424200 } }, + { 53010, { 0.816987, 0.677700, 0.570375, 0.484100 } }, + { 53011, { 0.832275, 0.707483, 0.608725, 0.527600 } }, + { 53012, { 0.879188, 0.781317, 0.704100, 0.645950 } }, + { 53102, { 0.646188, 0.431000, 0.297600, 0.212250 } }, + { 53103, { 0.662075, 0.451183, 0.316450, 0.226250 } }, + { 53104, { 0.679488, 0.476467, 0.338175, 0.247350 } }, + { 53105, { 0.685588, 0.486467, 0.355675, 0.262250 } }, + { 53106, { 0.710063, 0.516383, 0.389000, 0.299000 } }, + { 53107, { 0.737263, 0.554483, 0.426550, 0.339200 } }, + { 53108, { 0.769500, 0.602567, 0.484000, 0.391150 } }, + { 53109, { 0.788512, 0.633800, 0.524600, 0.437200 } }, + { 53110, { 0.817612, 0.680600, 0.582975, 0.502600 } }, + { 53111, { 0.832588, 0.712100, 0.629325, 0.562650 } }, + { 53201, { 0.677300, 0.463333, 0.333250, 0.238700 } }, + { 53201, { 0.677675, 0.467983, 0.330350, 0.234150 } }, + { 53203, { 0.708037, 0.505850, 0.371000, 0.274750 } }, + { 53204, { 0.731738, 0.540933, 0.404050, 0.309350 } }, + { 53205, { 0.744363, 0.563950, 0.432425, 0.338750 } }, + { 53206, { 0.769687, 0.599167, 0.473925, 0.375550 } }, + { 53207, { 0.802450, 0.647200, 0.533025, 0.430750 } }, + { 53208, { 0.832425, 0.695833, 0.585975, 0.497900 } }, + { 53209, { 0.855850, 0.736900, 0.642750, 0.561800 } }, + { 53210, { 0.872650, 0.772550, 0.692250, 0.619650 } }, + { 53300, { 0.671262, 0.462133, 0.321625, 0.231600 } }, + { 53301, { 0.686913, 0.481600, 0.342825, 0.249700 } }, + { 53302, { 0.712013, 0.513850, 0.376300, 0.279150 } }, + { 53303, { 0.731025, 0.542133, 0.406350, 0.313500 } }, + { 53304, { 0.761413, 0.587967, 0.449450, 0.348700 } }, + { 53305, { 0.781200, 0.615433, 0.485325, 0.380500 } }, + { 53306, { 0.788900, 0.630667, 0.507500, 0.415200 } }, + { 53307, { 0.803338, 0.658517, 0.548025, 0.464250 } }, + { 60105, { 0.449263, 0.372250, 0.329725, 0.301050 } }, + { 60106, { 0.457888, 0.371467, 0.331025, 0.305750 } }, + { 60107, { 0.465225, 0.372783, 0.327575, 0.301500 } }, + { 60108, { 0.465237, 0.376017, 0.326300, 0.306300 } }, + { 60109, { 0.463462, 0.373900, 0.327375, 0.300650 } }, + { 60110, { 0.484550, 0.380033, 0.334850, 0.306000 } }, + { 60111, { 0.498262, 0.383467, 0.334500, 0.309250 } }, + { 60112, { 0.507550, 0.391383, 0.345825, 0.308150 } }, + { 60205, { 0.464050, 0.387800, 0.341925, 0.314150 } }, + { 60206, { 0.477787, 0.386600, 0.345400, 0.316300 } }, + { 60207, { 0.486150, 0.383117, 0.331725, 0.311850 } }, + { 60208, { 0.495975, 0.393867, 0.344275, 0.314400 } }, + { 60209, { 0.525800, 0.410417, 0.351100, 0.324100 } }, + { 60210, { 0.529763, 0.409683, 0.357775, 0.330750 } }, + { 60211, { 0.552412, 0.415517, 0.360550, 0.330600 } }, + { 60212, { 0.553475, 0.419217, 0.363925, 0.330700 } }, + { 60305, { 0.470900, 0.389867, 0.352600, 0.324350 } }, + { 60306, { 0.493825, 0.394883, 0.351575, 0.320400 } }, + { 60307, { 0.507075, 0.403533, 0.351175, 0.322750 } }, + { 60308, { 0.534925, 0.416150, 0.359450, 0.329150 } }, + { 60309, { 0.577087, 0.437533, 0.385150, 0.346100 } }, + { 60310, { 0.582462, 0.460883, 0.399325, 0.374550 } }, + { 60311, { 0.621838, 0.482767, 0.421350, 0.388650 } }, + { 60312, { 0.665325, 0.521000, 0.451400, 0.426500 } }, + { 61205, { 0.471450, 0.393600, 0.345100, 0.318200 } }, + { 61206, { 0.489613, 0.396983, 0.351175, 0.322750 } }, + { 61207, { 0.488000, 0.393300, 0.347050, 0.319450 } }, + { 61208, { 0.507012, 0.401367, 0.352875, 0.322700 } }, + { 61209, { 0.529975, 0.407283, 0.359375, 0.326050 } }, + { 61210, { 0.538613, 0.420967, 0.373875, 0.339550 } }, + { 61211, { 0.598113, 0.457800, 0.395250, 0.364400 } }, + { 61212, { 0.630637, 0.486500, 0.414750, 0.374450 } }, + { 61305, { 0.484588, 0.402333, 0.358050, 0.326600 } }, + { 61306, { 0.509900, 0.411400, 0.368800, 0.334250 } }, + { 61307, { 0.522637, 0.413067, 0.365875, 0.335750 } }, + { 61308, { 0.555638, 0.431650, 0.380650, 0.349350 } }, + { 61309, { 0.591175, 0.452767, 0.393800, 0.356700 } }, + { 61310, { 0.602012, 0.469183, 0.412875, 0.382650 } }, + { 61311, { 0.631050, 0.492500, 0.434525, 0.397000 } }, + { 61312, { 0.676462, 0.531650, 0.461650, 0.426000 } }, + { 62305, { 0.495500, 0.412033, 0.366375, 0.333950 } }, + { 62306, { 0.519388, 0.424033, 0.372825, 0.344200 } }, + { 62307, { 0.534613, 0.426467, 0.375600, 0.346250 } }, + { 62308, { 0.557137, 0.438667, 0.378650, 0.346100 } }, + { 62309, { 0.594437, 0.458850, 0.397700, 0.360150 } }, + { 62310, { 0.607625, 0.487617, 0.434500, 0.398800 } }, + { 62311, { 0.641975, 0.499533, 0.435450, 0.407300 } }, + { 62312, { 0.703137, 0.561583, 0.487200, 0.444400 } }, + { 70103, { 0.549350, 0.415500, 0.344525, 0.303000 } }, + { 70104, { 0.560662, 0.424933, 0.357650, 0.308500 } }, + { 70105, { 0.566275, 0.438433, 0.364575, 0.313700 } }, + { 70106, { 0.599775, 0.460033, 0.383200, 0.337550 } }, + { 70107, { 0.635238, 0.489750, 0.408925, 0.358750 } }, + { 70108, { 0.593487, 0.470683, 0.405500, 0.365900 } }, + { 70109, { 0.622250, 0.494050, 0.430375, 0.383850 } }, + { 70110, { 0.657725, 0.524967, 0.460425, 0.416400 } }, + { 70111, { 0.696450, 0.567133, 0.501450, 0.460800 } }, + { 70203, { 0.611600, 0.549250, 0.514275, 0.484950 } }, + { 70204, { 0.621100, 0.545367, 0.505775, 0.481450 } }, + { 70205, { 0.634200, 0.551617, 0.515000, 0.486250 } }, + { 70206, { 0.645563, 0.555433, 0.508525, 0.477150 } }, + { 70207, { 0.665488, 0.566550, 0.520925, 0.489550 } }, + { 70208, { 0.681575, 0.593467, 0.550600, 0.524750 } }, + { 70209, { 0.701113, 0.608083, 0.560450, 0.536300 } }, + { 70210, { 0.726838, 0.624467, 0.572425, 0.548250 } }, + { 70211, { 0.754563, 0.656283, 0.594225, 0.558150 } }, + { 71104, { 0.512750, 0.350417, 0.264550, 0.216200 } }, + { 71105, { 0.528850, 0.369000, 0.286975, 0.230200 } }, + { 71106, { 0.547200, 0.393933, 0.309375, 0.251600 } }, + { 71107, { 0.585550, 0.427233, 0.339825, 0.279150 } }, + { 71108, { 0.599650, 0.445783, 0.363475, 0.309750 } }, + { 71109, { 0.572087, 0.433050, 0.361125, 0.316300 } }, + { 71110, { 0.610487, 0.465467, 0.390825, 0.342150 } }, + { 71111, { 0.647575, 0.503700, 0.432725, 0.390050 } }, + { 71112, { 0.703662, 0.562233, 0.494850, 0.460550 } }, + { 71204, { 0.543100, 0.468933, 0.427475, 0.393500 } }, + { 71205, { 0.560638, 0.476717, 0.437200, 0.408000 } }, + { 71206, { 0.578850, 0.483267, 0.440675, 0.408050 } }, + { 71207, { 0.594387, 0.489250, 0.443050, 0.411900 } }, + { 71208, { 0.611750, 0.514117, 0.470200, 0.442250 } }, + { 71209, { 0.636775, 0.532250, 0.486750, 0.450400 } }, + { 71210, { 0.672350, 0.555367, 0.499375, 0.463250 } }, + { 71211, { 0.709275, 0.580383, 0.527200, 0.483850 } }, + { 71212, { 0.751687, 0.628100, 0.560100, 0.516900 } } }; #define NUM_PREFLOP_VALUES (sizeof(PreflopValues)/sizeof(RoundData)) @@ -853,138 +850,148 @@ LocalPlayer::LocalPlayer(ConfigFile *c, int id, unsigned uniqueId, PlayerType ty : PlayerInterface(), myConfig(c), currentHand(0), myCardsValue(0), myID(id), myUniqueID(uniqueId), myType(type), myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myLastRelativeSet(0), myAction(0), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(1), myTurn(0), myCardsFlip(0), myRoundStartCash(0), lastMoneyWon(0), sBluff(0), sBluffStatus(0), myWinnerState(false), m_actionTimeoutCounter(0) { - // !!!!!!!!!!!!!!!!!!!!!!!! testing !!!!!!!!!!!!!!!!!!!!!!!! - if(DEBUG_MODE) { + // !!!!!!!!!!!!!!!!!!!!!!!! testing !!!!!!!!!!!!!!!!!!!!!!!! + if(DEBUG_MODE) { - //cout << myConfig->readConfigString("LogDir").c_str() << endl; + //cout << myConfig->readConfigString("LogDir").c_str() << endl; - switch(myUniqueID) { + switch(myUniqueID) { - case 0: { - myCash=4140; - } break; - case 1: { - myCash=4940; - } break; - case 2: { - myCash=4660; - } break; - case 3: { - myCash=4960; - } break; - case 4: { - myCash=5680; - } break; - case 5: { - myCash=4960; - } break; - case 6: { - myCash=4960; - } break; - case 7: { - myCash=5780; - } break; - case 8: { - myCash=4960; - } break; - case 9: { - myCash=4960; - } break; + case 0: { + myCash=4140; + } + break; + case 1: { + myCash=4940; + } + break; + case 2: { + myCash=4660; + } + break; + case 3: { + myCash=4960; + } + break; + case 4: { + myCash=5680; + } + break; + case 5: { + myCash=4960; + } + break; + case 6: { + myCash=4960; + } + break; + case 7: { + myCash=5780; + } + break; + case 8: { + myCash=4960; + } + break; + case 9: { + myCash=4960; + } + break; - default: { - } + default: { + } - } + } - } - //////////////////////////// + } + //////////////////////////// - int i; - for(i=0; i<3; i++) { - myNiveau[i] = 0; - } - for(i=0; i<2; i++) { - myCards[i] = -1; - } + int i; + for(i=0; i<3; i++) { + myNiveau[i] = 0; + } + for(i=0; i<2; i++) { + myCards[i] = -1; + } - // myBestHandPosition mit -1 initialisieren - for(i=0; i<5; i++) { - myBestHandPosition[i] = -1; - } + // myBestHandPosition mit -1 initialisieren + for(i=0; i<5; i++) { + myBestHandPosition[i] = -1; + } - // myAverageSets initialisieren - for(i=0; i<4; i++) { - myAverageSets[i] = 0; - } + // myAverageSets initialisieren + for(i=0; i<4; i++) { + myAverageSets[i] = 0; + } - // myAggressive initialisieren - for(i=0; i<7; i++) { - myAggressive[i] = 0; - } + // myAggressive initialisieren + for(i=0; i<7; i++) { + myAggressive[i] = 0; + } - // Dude zuweisen - Tools::getRandNumber(3 , 5, 1, &myDude, 0); - // cout << "Spieler: " << myID << " Dude: " << myDude << " Cash: " << myCash << " ActiveStatus: " << myActiveStatus << " Button: " << myButton << endl; + // Dude zuweisen + Tools::getRandNumber(3 , 5, 1, &myDude, 0); + // cout << "Spieler: " << myID << " Dude: " << myDude << " Cash: " << myCash << " ActiveStatus: " << myActiveStatus << " Button: " << myButton << endl; - // Dude4 zuweisen - int interval = 7; - int count = 4; + // Dude4 zuweisen + int interval = 7; + int count = 4; - int *tempArray = new int[count]; - Tools::getRandNumber(0, 2*interval, count, tempArray, 0); - for(i=0; igetCurrentBeRo()->getHighestSet(); - // int oldMinimumRaise = currentHand->getCurrentBeRo()->getMinimumRaise(); - // int myOldSet = mySet; - - switch(currentHand->getCurrentRound()) { - case 0: { - - if(myConfig->readConfigInt("EngineVersion")) preflopEngine3(); - else preflopEngine(); - - currentHand->getBoard()->collectSets(); - currentHand->getGuiInterface()->refreshPot(); - - } break; - case 1: { - - if(myConfig->readConfigInt("EngineVersion")) flopEngine3(); - else flopEngine(); - - currentHand->getBoard()->collectSets(); - currentHand->getGuiInterface()->refreshPot(); - - } break; - case 2: { - - if(myConfig->readConfigInt("EngineVersion")) turnEngine3(); - else turnEngine(); - - currentHand->getBoard()->collectSets(); - currentHand->getGuiInterface()->refreshPot(); - - } break; - case 3: { - - if(myConfig->readConfigInt("EngineVersion")) riverEngine3(); - else riverEngine(); - - currentHand->getBoard()->collectSets(); - currentHand->getGuiInterface()->refreshPot(); - - } break; - default: {} - } - - // cout << currentHand->getCurrentBeRo()->getMinimumRaise() << endl; - - // cout << checkMyAction(myAction, mySet - myOldSet, myOldSet, myOldCash, oldHighestSet, oldMinimumRaise, currentHand->getSmallBlind()) << endl; - - - myTurn = 0; - // cout << "jetzt" << endl; - - //set that i was the last active player. need this for unhighlighting groupbox - currentHand->setLastPlayersTurn(myID); - - currentHand->getGuiInterface()->logPlayerActionMsg(myName, myID, myAction, mySet); - currentHand->getGuiInterface()->nextPlayerAnimation(); - - // cout << "playerID in action(): " << (*(currentHand->getCurrentBeRo()->getCurrentPlayersTurnIt()))->getMyID() << endl; +void LocalPlayer::setHand(HandInterface* br) +{ + currentHand = br; } -int LocalPlayer::checkMyAction(int targetAction, int targetBet, int highestSet, int minimumRaise, int smallBlind) { - switch(targetAction) { - case PLAYER_ACTION_FOLD: { - return 0; - } break; - case PLAYER_ACTION_CHECK: { - if(getMySet() == highestSet) { - return 0; - } - } break; - case PLAYER_ACTION_CALL: { - if(getMySet() < highestSet && targetBet <= getMyCash()) { - // not all in - if(getMyCash() + getMySet() >= highestSet && targetBet == highestSet - getMySet()) { - return 0; - } - // all in - if(getMyCash() + getMySet() <= highestSet) { - return 0; - } - } - } break; - case PLAYER_ACTION_BET: { - if(highestSet == 0 && targetBet <= getMyCash() && targetBet >= 2*smallBlind) { - return 0; - } - } break; - case PLAYER_ACTION_RAISE: { - if(highestSet > 0 && targetBet >= minimumRaise && targetBet <= getMyCash()) { - return 0; - } - } break; - case PLAYER_ACTION_ALLIN: { - if(targetBet == getMyCash()) { - return 0; - } - } break; - default: { +void LocalPlayer::action() +{ - } - } + // int myOldCash = myCash; + // int oldHighestSet = currentHand->getCurrentBeRo()->getHighestSet(); + // int oldMinimumRaise = currentHand->getCurrentBeRo()->getMinimumRaise(); + // int myOldSet = mySet; - return 1; + switch(currentHand->getCurrentRound()) { + case 0: { + + if(myConfig->readConfigInt("EngineVersion")) preflopEngine3(); + else preflopEngine(); + + currentHand->getBoard()->collectSets(); + currentHand->getGuiInterface()->refreshPot(); + + } + break; + case 1: { + + if(myConfig->readConfigInt("EngineVersion")) flopEngine3(); + else flopEngine(); + + currentHand->getBoard()->collectSets(); + currentHand->getGuiInterface()->refreshPot(); + + } + break; + case 2: { + + if(myConfig->readConfigInt("EngineVersion")) turnEngine3(); + else turnEngine(); + + currentHand->getBoard()->collectSets(); + currentHand->getGuiInterface()->refreshPot(); + + } + break; + case 3: { + + if(myConfig->readConfigInt("EngineVersion")) riverEngine3(); + else riverEngine(); + + currentHand->getBoard()->collectSets(); + currentHand->getGuiInterface()->refreshPot(); + + } + break; + default: + {} + } + + // cout << currentHand->getCurrentBeRo()->getMinimumRaise() << endl; + + // cout << checkMyAction(myAction, mySet - myOldSet, myOldSet, myOldCash, oldHighestSet, oldMinimumRaise, currentHand->getSmallBlind()) << endl; + + + myTurn = 0; + // cout << "jetzt" << endl; + + //set that i was the last active player. need this for unhighlighting groupbox + currentHand->setLastPlayersTurn(myID); + + currentHand->getGuiInterface()->logPlayerActionMsg(myName, myID, myAction, mySet); + currentHand->getGuiInterface()->nextPlayerAnimation(); + + // cout << "playerID in action(): " << (*(currentHand->getCurrentBeRo()->getCurrentPlayersTurnIt()))->getMyID() << endl; +} + +int LocalPlayer::checkMyAction(int targetAction, int targetBet, int highestSet, int minimumRaise, int smallBlind) +{ + + switch(targetAction) { + case PLAYER_ACTION_FOLD: { + return 0; + } + break; + case PLAYER_ACTION_CHECK: { + if(getMySet() == highestSet) { + return 0; + } + } + break; + case PLAYER_ACTION_CALL: { + if(getMySet() < highestSet && targetBet <= getMyCash()) { + // not all in + if(getMyCash() + getMySet() >= highestSet && targetBet == highestSet - getMySet()) { + return 0; + } + // all in + if(getMyCash() + getMySet() <= highestSet) { + return 0; + } + } + } + break; + case PLAYER_ACTION_BET: { + if(highestSet == 0 && targetBet <= getMyCash() && targetBet >= 2*smallBlind) { + return 0; + } + } + break; + case PLAYER_ACTION_RAISE: { + if(highestSet > 0 && targetBet >= minimumRaise && targetBet <= getMyCash()) { + return 0; + } + } + break; + case PLAYER_ACTION_ALLIN: { + if(targetBet == getMyCash()) { + return 0; + } + } + break; + default: { + + } + } + + return 1; } -void LocalPlayer::preflopEngine() { +void LocalPlayer::preflopEngine() +{ - int bet = 0; - int raise = 0; - int cBluff; - PlayerListConstIterator it_c; + int bet = 0; + int raise = 0; + int cBluff; + PlayerListConstIterator it_c; - // temporär solange preflopValue und flopValue noch nicht bereinigt für sechs und sieben spieler - int players = currentHand->getActivePlayerList()->size(); - if(players > 5) players = 5; + // temporär solange preflopValue und flopValue noch nicht bereinigt für sechs und sieben spieler + int players = currentHand->getActivePlayerList()->size(); + if(players > 5) players = 5; - // myOdds auslesen - calcMyOdds(); + // myOdds auslesen + calcMyOdds(); - // Niveaus setzen + Dude + Anzahl Gegenspieler - // 1. Fold -- Call - myNiveau[0] = 43 + myDude4 - 6*(players - 2); - // 3. Call -- Raise - myNiveau[2] = 54 + myDude4 - 7*(players - 2); + // Niveaus setzen + Dude + Anzahl Gegenspieler + // 1. Fold -- Call + myNiveau[0] = 43 + myDude4 - 6*(players - 2); + // 3. Call -- Raise + myNiveau[2] = 54 + myDude4 - 7*(players - 2); - // eigenes mögliches highestSet - int individualHighestSet = currentHand->getCurrentBeRo()->getHighestSet(); - if(individualHighestSet > myCash) individualHighestSet = myCash; + // eigenes mögliches highestSet + int individualHighestSet = currentHand->getCurrentBeRo()->getHighestSet(); + if(individualHighestSet > myCash) individualHighestSet = myCash; - // Verhaeltnis Set / Cash für call - if(myCash/individualHighestSet >= 25) { - myNiveau[0] += (25-myCash/individualHighestSet)/10; - } else { - myNiveau[0] += (25-myCash/individualHighestSet)/3; - } + // Verhaeltnis Set / Cash für call + if(myCash/individualHighestSet >= 25) { + myNiveau[0] += (25-myCash/individualHighestSet)/10; + } else { + myNiveau[0] += (25-myCash/individualHighestSet)/3; + } - // Verhaeltnis Set / Cash für raise - if(myCash/individualHighestSet < 11) { - myNiveau[2] += (21-myCash/individualHighestSet)/2; - } + // Verhaeltnis Set / Cash für raise + if(myCash/individualHighestSet < 11) { + myNiveau[2] += (21-myCash/individualHighestSet)/2; + } - // cout << myID << ": " << myHoleCardsValue << " - " << myNiveau[0] << " " << myNiveau[2] << " - " << myCards[0] << " " << myCards[1] << endl; + // cout << myID << ": " << myHoleCardsValue << " - " << myNiveau[0] << " " << myNiveau[2] << " - " << myCards[0] << " " << myCards[1] << endl; - // count number of active human players - size_t countHumanPlayers = 0; + // count number of active human players + size_t countHumanPlayers = 0; for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); ++it_c) { - if((*it_c)->getMyType() == PLAYER_TYPE_HUMAN) { - countHumanPlayers++; - } - } - if(countHumanPlayers) { - // local or network game and only one human player is active --> set aggValue - if(countHumanPlayers == 1) { + if((*it_c)->getMyType() == PLAYER_TYPE_HUMAN) { + countHumanPlayers++; + } + } + if(countHumanPlayers) { + // local or network game and only one human player is active --> set aggValue + if(countHumanPlayers == 1) { for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); ++it_c) { - if((*it_c)->getMyType() == PLAYER_TYPE_HUMAN && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { - int aggValue = (int)((( (*it_c)->getMyAggressive()*1.0)/7.0 - 1.0/currentHand->getActivePlayerList()->size())*21.0); - myNiveau[0] -= aggValue; - myNiveau[2] -= aggValue; - } - } - // network game - } else { - myNiveau[0] -= 3; - myNiveau[2] -= 3; - } - } + if((*it_c)->getMyType() == PLAYER_TYPE_HUMAN && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { + int aggValue = (int)((( (*it_c)->getMyAggressive()*1.0)/7.0 - 1.0/currentHand->getActivePlayerList()->size())*21.0); + myNiveau[0] -= aggValue; + myNiveau[2] -= aggValue; + } + } + // network game + } else { + myNiveau[0] -= 3; + myNiveau[2] -= 3; + } + } - // Aggresivität des humanPlayers auslesen -> nur wenn er aktiv ist ! - // it_c = currentHand->getActivePlayerIt(0); - // if( it_c != currentHand->getActivePlayerList()->end() ) { - // if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD ) { - // int aggValue = (int)((( (*it_c)->getMyAggressive()*1.0)/7.0 - 1.0/currentHand->getActivePlayerList()->size())*21.0); - // myNiveau[0] -= aggValue; - // myNiveau[2] -= aggValue; - // } - // - // } + // Aggresivität des humanPlayers auslesen -> nur wenn er aktiv ist ! + // it_c = currentHand->getActivePlayerIt(0); + // if( it_c != currentHand->getActivePlayerList()->end() ) { + // if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD ) { + // int aggValue = (int)((( (*it_c)->getMyAggressive()*1.0)/7.0 - 1.0/currentHand->getActivePlayerList()->size())*21.0); + // myNiveau[0] -= aggValue; + // myNiveau[2] -= aggValue; + // } + // + // } - // cout << "Spieler " << myID << ": Dude " << myDude4 << "\t Wert " << myHoleCardsValue << "\t Niveau " << myNiveau[0] << " " << myNiveau[1] << " " << myNiveau[2] << "\t Agg " << aggValue << " " << endl; + // cout << "Spieler " << myID << ": Dude " << myDude4 << "\t Wert " << myHoleCardsValue << "\t Niveau " << myNiveau[0] << " " << myNiveau[1] << " " << myNiveau[2] << "\t Agg " << aggValue << " " << endl; - // Check-Bluff generieren - Tools::getRandNumber(1,100,1,&cBluff,0); + // Check-Bluff generieren + Tools::getRandNumber(1,100,1,&cBluff,0); - // aktive oder passivie Situation ? -> im preflop nur passiv + // aktive oder passivie Situation ? -> im preflop nur passiv - // raise (bei hohem Niveau) - if(myOdds >= myNiveau[2]) { + // raise (bei hohem Niveau) + if(myOdds >= myNiveau[2]) { - // raise-loop unterbinden -> d.h. entweder call oder bei superblatt all in - if(currentHand->getCurrentBeRo()->getHighestSet() >= 12*currentHand->getSmallBlind()) { - // all in - if(myOdds >= myNiveau[2] + 8) { - raise = myCash; - myAction = 5; - } - // nur call - else { - // all in bei knappem call - if(myCash-currentHand->getCurrentBeRo()->getHighestSet() <= (myCash*1)/5) { - raise = myCash; - myAction = 5; - } else { - myAction = 3; - } - } + // raise-loop unterbinden -> d.h. entweder call oder bei superblatt all in + if(currentHand->getCurrentBeRo()->getHighestSet() >= 12*currentHand->getSmallBlind()) { + // all in + if(myOdds >= myNiveau[2] + 8) { + raise = myCash; + myAction = 5; + } + // nur call + else { + // all in bei knappem call + if(myCash-currentHand->getCurrentBeRo()->getHighestSet() <= (myCash*1)/5) { + raise = myCash; + myAction = 5; + } else { + myAction = 3; + } + } - // Standard-Raise-Routine - } else { - // raise-Betrag ermitteln - raise = (((int)myOdds-myNiveau[2])/2)*2*currentHand->getSmallBlind(); - // raise-Betrag zu klein -> mindestens Standard-raise - // if(raise < currentHand->getCurrentBeRo()->getHighestSet()) { - // raise = currentHand->getCurrentBeRo()->getHighestSet(); - // } - // all in bei nur wenigen Chips oder knappem raise - if(myCash/(2*currentHand->getSmallBlind()) <= 6 || raise >= (myCash*4)/5) { - raise = myCash; - } - myAction = 5; - } + // Standard-Raise-Routine + } else { + // raise-Betrag ermitteln + raise = (((int)myOdds-myNiveau[2])/2)*2*currentHand->getSmallBlind(); + // raise-Betrag zu klein -> mindestens Standard-raise + // if(raise < currentHand->getCurrentBeRo()->getHighestSet()) { + // raise = currentHand->getCurrentBeRo()->getHighestSet(); + // } + // all in bei nur wenigen Chips oder knappem raise + if(myCash/(2*currentHand->getSmallBlind()) <= 6 || raise >= (myCash*4)/5) { + raise = myCash; + } + myAction = 5; + } - // auf cBluff testen --> call (bzw check) statt raise - if(cBluff > 90) { - myAction = 3; - // bigBlind --> check - if(myButton == 3 && mySet == currentHand->getCurrentBeRo()->getHighestSet()) myAction = 2; - } - if(cBluff > 80 && myOdds >= myNiveau[2] + 4) { - myAction = 3; - // bigBlind --> check - if(myButton == 3 && mySet == currentHand->getCurrentBeRo()->getHighestSet()) myAction = 2; - } - if(cBluff > 70 && myOdds >= myNiveau[2] + 8) { - myAction = 3; - // bigBlind --> check - if(myButton == 3 && mySet == currentHand->getCurrentBeRo()->getHighestSet()) myAction = 2; - } - if(cBluff > 60 && myOdds >= myNiveau[2] + 12) { - myAction = 3; - // bigBlind --> check - if(myButton == 3 && mySet == currentHand->getCurrentBeRo()->getHighestSet()) myAction = 2; - } + // auf cBluff testen --> call (bzw check) statt raise + if(cBluff > 90) { + myAction = 3; + // bigBlind --> check + if(myButton == 3 && mySet == currentHand->getCurrentBeRo()->getHighestSet()) myAction = 2; + } + if(cBluff > 80 && myOdds >= myNiveau[2] + 4) { + myAction = 3; + // bigBlind --> check + if(myButton == 3 && mySet == currentHand->getCurrentBeRo()->getHighestSet()) myAction = 2; + } + if(cBluff > 70 && myOdds >= myNiveau[2] + 8) { + myAction = 3; + // bigBlind --> check + if(myButton == 3 && mySet == currentHand->getCurrentBeRo()->getHighestSet()) myAction = 2; + } + if(cBluff > 60 && myOdds >= myNiveau[2] + 12) { + myAction = 3; + // bigBlind --> check + if(myButton == 3 && mySet == currentHand->getCurrentBeRo()->getHighestSet()) myAction = 2; + } - } - else { - // call - if(myOdds >= myNiveau[0] || (mySet >= currentHand->getCurrentBeRo()->getHighestSet()/2 && myOdds >= myNiveau[0]-8)) { - // bigBlind --> check - if(myButton == 3 && mySet == currentHand->getCurrentBeRo()->getHighestSet()) myAction = 2; - else { - // all in bei knappem call - if(myCash-currentHand->getCurrentBeRo()->getHighestSet() <= (myCash*1)/5) { - raise = myCash; - myAction = 5; - } - else { - myAction = 3; - } - } - } - // fold - else { - // bigBlind -> check - if(myButton == 3 && mySet == currentHand->getCurrentBeRo()->getHighestSet()) myAction = 2; - else myAction = 1; - } - } + } else { + // call + if(myOdds >= myNiveau[0] || (mySet >= currentHand->getCurrentBeRo()->getHighestSet()/2 && myOdds >= myNiveau[0]-8)) { + // bigBlind --> check + if(myButton == 3 && mySet == currentHand->getCurrentBeRo()->getHighestSet()) myAction = 2; + else { + // all in bei knappem call + if(myCash-currentHand->getCurrentBeRo()->getHighestSet() <= (myCash*1)/5) { + raise = myCash; + myAction = 5; + } else { + myAction = 3; + } + } + } + // fold + else { + // bigBlind -> check + if(myButton == 3 && mySet == currentHand->getCurrentBeRo()->getHighestSet()) myAction = 2; + else myAction = 1; + } + } - // cout << sBluff << endl; + // cout << sBluff << endl; - // auf sBluff testen --> raise statt call oder fold - if((sBluff < 100/((((int)currentHand->getActivePlayerList()->size()-2)*6)+3) && myOdds < myNiveau[2] && currentHand->getCurrentBeRo()->getHighestSet() == 2*currentHand->getSmallBlind() && sBluffStatus == 0) || sBluffStatus == 1) { + // auf sBluff testen --> raise statt call oder fold + if((sBluff < 100/((((int)currentHand->getActivePlayerList()->size()-2)*6)+3) && myOdds < myNiveau[2] && currentHand->getCurrentBeRo()->getHighestSet() == 2*currentHand->getSmallBlind() && sBluffStatus == 0) || sBluffStatus == 1) { - // cout << "sBLUFF!" << endl; - sBluffStatus = 1; + // cout << "sBLUFF!" << endl; + sBluffStatus = 1; - // Gegner raisen ebenfalls -> call - if(currentHand->getCurrentBeRo()->getHighestSet() >= 4*currentHand->getSmallBlind()) { - // all in bei knappem call - if(myCash-currentHand->getCurrentBeRo()->getHighestSet() <= (myCash*1)/6) { - raise = myCash; - myAction = 5; - } - else { - myAction = 3; - // bigBlind --> check - if(myButton == 3 && mySet == currentHand->getCurrentBeRo()->getHighestSet()) myAction = 2; - } - } - // Standard-Raise-Routine - else { - // raise-Betrag ermitteln - raise = (sBluff/(8-min(7,(int)(currentHand->getActivePlayerList()->size()))))*currentHand->getSmallBlind(); - // raise-Betrag zu klein -> mindestens Standard-raise - // if(raise < currentHand->getCurrentBeRo()->getHighestSet()) { - // raise = currentHand->getCurrentBeRo()->getHighestSet(); - // } - // all in bei nur wenigen Chips oder knappem raise - if(myCash/(2*currentHand->getSmallBlind()) <= 6 || raise >= (myCash*4)/5) { - raise = myCash; - } - myAction = 5; - } + // Gegner raisen ebenfalls -> call + if(currentHand->getCurrentBeRo()->getHighestSet() >= 4*currentHand->getSmallBlind()) { + // all in bei knappem call + if(myCash-currentHand->getCurrentBeRo()->getHighestSet() <= (myCash*1)/6) { + raise = myCash; + myAction = 5; + } else { + myAction = 3; + // bigBlind --> check + if(myButton == 3 && mySet == currentHand->getCurrentBeRo()->getHighestSet()) myAction = 2; + } + } + // Standard-Raise-Routine + else { + // raise-Betrag ermitteln + raise = (sBluff/(8-min(7,(int)(currentHand->getActivePlayerList()->size()))))*currentHand->getSmallBlind(); + // raise-Betrag zu klein -> mindestens Standard-raise + // if(raise < currentHand->getCurrentBeRo()->getHighestSet()) { + // raise = currentHand->getCurrentBeRo()->getHighestSet(); + // } + // all in bei nur wenigen Chips oder knappem raise + if(myCash/(2*currentHand->getSmallBlind()) <= 6 || raise >= (myCash*4)/5) { + raise = myCash; + } + myAction = 5; + } - // extrem hoher set der gegner -> bluff beenden - if((currentHand->getCurrentBeRo()->getHighestSet() >= 12*currentHand->getSmallBlind() && myOdds < myNiveau[0]) || (currentHand->getCurrentBeRo()->getHighestSet() >= 20*currentHand->getSmallBlind() && myOdds < myNiveau[2])) { - myAction = 1; - } + // extrem hoher set der gegner -> bluff beenden + if((currentHand->getCurrentBeRo()->getHighestSet() >= 12*currentHand->getSmallBlind() && myOdds < myNiveau[0]) || (currentHand->getCurrentBeRo()->getHighestSet() >= 20*currentHand->getSmallBlind() && myOdds < myNiveau[2])) { + myAction = 1; + } - } + } - // minimum raise setting and resetting - // if(myAction == 5) { - // - // if(raise < currentHand->getCurrentBeRo()->getMinimumRaise()) { - // raise = currentHand->getCurrentBeRo()->getMinimumRaise(); - // } - // currentHand->getCurrentBeRo()->setMinimumRaise(raise); - // } - // + // minimum raise setting and resetting + // if(myAction == 5) { + // + // if(raise < currentHand->getCurrentBeRo()->getMinimumRaise()) { + // raise = currentHand->getCurrentBeRo()->getMinimumRaise(); + // } + // currentHand->getCurrentBeRo()->setMinimumRaise(raise); + // } + // - // cout << myID << ": " << myOdds << " - " << myNiveau[0] << " " << myNiveau[2] << " - " << "Bluff: " << sBluffStatus << endl; + // cout << myID << ": " << myOdds << " - " << myNiveau[0] << " " << myNiveau[2] << " - " << "Bluff: " << sBluffStatus << endl; - if(DEBUG_MODE) { - switch(myUniqueID) { - case 0: {} - break; - case 1: { - // player 1 + if(DEBUG_MODE) { + switch(myUniqueID) { + case 0: + {} + break; + case 1: { + // player 1 - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_CALL; - // raise = 20; - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 25; - } - break; - default: { - } - } + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CALL; + // raise = 20; + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 25; + } + break; + default: { + } + } - } - break; - case 2: { - // player 2 + } + break; + case 2: { + // player 2 - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_CALL; + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CALL; // raise = 20000; - // if(mySet >= 40) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - case 2: { - // myAction = PLAYER_ACTION_FOLD; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + // if(mySet >= 40) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + case 2: { + // myAction = PLAYER_ACTION_FOLD; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 3: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_CALL; + } + break; + case 3: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CALL; // raise = 2000; - // if(mySet >= 40) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - case 2: { - // myAction = PLAYER_ACTION_FOLD; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } - } - break; - case 4: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_CALL; + // if(mySet >= 40) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + case 2: { + // myAction = PLAYER_ACTION_FOLD; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } + } + break; + case 4: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CALL; // raise = 2000; - // if(mySet > 0) { - // myAction = PLAYER_ACTION_FOLD; - // } - } - break; - case 2: { - // myAction = PLAYER_ACTION_FOLD; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } - } - break; - case 5: { - // if(mySet == 0) { - myAction = PLAYER_ACTION_CALL; + // if(mySet > 0) { + // myAction = PLAYER_ACTION_FOLD; + // } + } + break; + case 2: { + // myAction = PLAYER_ACTION_FOLD; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } + } + break; + case 5: { + // if(mySet == 0) { + myAction = PLAYER_ACTION_CALL; // raise = 20; - // } - } - break; - case 6: { - // if(mySet == 160) { - myAction = PLAYER_ACTION_CHECK; - // } - } - break; - case 7: { - // if(mySet == 160) { - myAction = PLAYER_ACTION_CALL; + // } + } + break; + case 6: { + // if(mySet == 160) { + myAction = PLAYER_ACTION_CHECK; + // } + } + break; + case 7: { + // if(mySet == 160) { + myAction = PLAYER_ACTION_CALL; - // } - } - break; - case 8: { - // if(mySet == 160) { - myAction = PLAYER_ACTION_CALL; + // } + } + break; + case 8: { + // if(mySet == 160) { + myAction = PLAYER_ACTION_CALL; - // } - } - break; - case 9: { - // if(mySet == 160) { - myAction = PLAYER_ACTION_CALL; + // } + } + break; + case 9: { + // if(mySet == 160) { + myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: {} - } + // } + } + break; + default: + {} + } - } + } - evaluation(bet, raise); + evaluation(bet, raise); } -void LocalPlayer::flopEngine() { +void LocalPlayer::flopEngine() +{ - int raise = 0; - int bet = 0; - // int i; - int cBluff; - int pBluff; - int rand; - PlayerListConstIterator it_c; + int raise = 0; + int bet = 0; + // int i; + int cBluff; + int pBluff; + int rand; + PlayerListConstIterator it_c; - // übergang solange preflopValue und flopValue noch nicht bereinigt - int players = currentHand->getActivePlayerList()->size(); - if(players > 5) players = 5; + // übergang solange preflopValue und flopValue noch nicht bereinigt + int players = currentHand->getActivePlayerList()->size(); + if(players > 5) players = 5; - calcMyOdds(); + calcMyOdds(); - // Niveaus setzen + Dude + Anzahl Gegenspieler - // 1. Fold -- Call - myNiveau[0] = 53 + myDude4 - 6*(players - 2); - // 2. Check -- Bet - myNiveau[1] = 56 + myDude4 - 6*(players - 2); - // 3. Call -- Raise - myNiveau[2] = 69 + myDude4 - 7*(players - 2); + // Niveaus setzen + Dude + Anzahl Gegenspieler + // 1. Fold -- Call + myNiveau[0] = 53 + myDude4 - 6*(players - 2); + // 2. Check -- Bet + myNiveau[1] = 56 + myDude4 - 6*(players - 2); + // 3. Call -- Raise + myNiveau[2] = 69 + myDude4 - 7*(players - 2); - // eigenes mögliches highestSet - int individualHighestSet = currentHand->getCurrentBeRo()->getHighestSet(); - if(individualHighestSet > myCash) individualHighestSet = myCash; + // eigenes mögliches highestSet + int individualHighestSet = currentHand->getCurrentBeRo()->getHighestSet(); + if(individualHighestSet > myCash) individualHighestSet = myCash; - // count number of active human players - size_t countHumanPlayers = 0; + // count number of active human players + size_t countHumanPlayers = 0; for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); ++it_c) { - if((*it_c)->getMyType() == PLAYER_TYPE_HUMAN) { - countHumanPlayers++; - } - } - if(countHumanPlayers) { - // local or network game and only one human player is active --> set aggValue - if(countHumanPlayers == 1) { + if((*it_c)->getMyType() == PLAYER_TYPE_HUMAN) { + countHumanPlayers++; + } + } + if(countHumanPlayers) { + // local or network game and only one human player is active --> set aggValue + if(countHumanPlayers == 1) { for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); ++it_c) { - if((*it_c)->getMyType() == PLAYER_TYPE_HUMAN && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { - int aggValue = (int)((( (*it_c)->getMyAggressive()*1.0)/7.0 - 1.0/currentHand->getActivePlayerList()->size())*21.0); - myNiveau[0] -= aggValue; - myNiveau[1] -= aggValue; - myNiveau[2] -= aggValue; - } - } - // network game - } else { - myNiveau[0] -= 3; - myNiveau[1] -= 3; - myNiveau[2] -= 3; - } - } + if((*it_c)->getMyType() == PLAYER_TYPE_HUMAN && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { + int aggValue = (int)((( (*it_c)->getMyAggressive()*1.0)/7.0 - 1.0/currentHand->getActivePlayerList()->size())*21.0); + myNiveau[0] -= aggValue; + myNiveau[1] -= aggValue; + myNiveau[2] -= aggValue; + } + } + // network game + } else { + myNiveau[0] -= 3; + myNiveau[1] -= 3; + myNiveau[2] -= 3; + } + } - // Aggresivität des humanPlayers auslesen -> nur wenn er aktiv ist ! - // it_c = currentHand->getActivePlayerIt(0); - // if( it_c != currentHand->getActivePlayerList()->end() ) { - // if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD ) { - // int aggValue = (int)((( (*it_c)->getMyAggressive()*1.0)/7.0 - 1.0/currentHand->getActivePlayerList()->size())*21.0); - // for(i=0; i<3; i++) { - // myNiveau[i] -= aggValue; - // } - // } - // - // } + // Aggresivität des humanPlayers auslesen -> nur wenn er aktiv ist ! + // it_c = currentHand->getActivePlayerIt(0); + // if( it_c != currentHand->getActivePlayerList()->end() ) { + // if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD ) { + // int aggValue = (int)((( (*it_c)->getMyAggressive()*1.0)/7.0 - 1.0/currentHand->getActivePlayerList()->size())*21.0); + // for(i=0; i<3; i++) { + // myNiveau[i] -= aggValue; + // } + // } + // + // } - // Check-Bluff generieren - Tools::getRandNumber(1,100,1,&cBluff,0); + // Check-Bluff generieren + Tools::getRandNumber(1,100,1,&cBluff,0); - // aktiv oder passiv? - if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + // aktiv oder passiv? + if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - // Verhaeltnis Set / Cash für call - if(myCash/individualHighestSet >= 25) { - myNiveau[0] += (25-myCash/individualHighestSet)/20; - } else { - myNiveau[0] += (25-myCash/individualHighestSet)/2; - } + // Verhaeltnis Set / Cash für call + if(myCash/individualHighestSet >= 25) { + myNiveau[0] += (25-myCash/individualHighestSet)/20; + } else { + myNiveau[0] += (25-myCash/individualHighestSet)/2; + } - // Verhaeltnis Set / Cash für raise - if(myCash/individualHighestSet < 11) { - myNiveau[2] += (21-myCash/individualHighestSet)/2; - } + // Verhaeltnis Set / Cash für raise + if(myCash/individualHighestSet < 11) { + myNiveau[2] += (21-myCash/individualHighestSet)/2; + } - // raise (bei hohem Niveau) - if(myOdds >= myNiveau[2]) { + // raise (bei hohem Niveau) + if(myOdds >= myNiveau[2]) { - // raise-loop unterbinden -> d.h. entweder call oder bei superblatt all in - if(currentHand->getCurrentBeRo()->getHighestSet() >= 12*currentHand->getSmallBlind()) { - // all in - if(myOdds >= myNiveau[2] + 15) { - raise = myCash; - myAction = 5; - } - // nur call - else { - // all in bei knappem call - if(myCash-currentHand->getCurrentBeRo()->getHighestSet() <= (myCash*1)/5) { - raise = myCash; - myAction = 5; - } else { - myAction = 3; - } - } + // raise-loop unterbinden -> d.h. entweder call oder bei superblatt all in + if(currentHand->getCurrentBeRo()->getHighestSet() >= 12*currentHand->getSmallBlind()) { + // all in + if(myOdds >= myNiveau[2] + 15) { + raise = myCash; + myAction = 5; + } + // nur call + else { + // all in bei knappem call + if(myCash-currentHand->getCurrentBeRo()->getHighestSet() <= (myCash*1)/5) { + raise = myCash; + myAction = 5; + } else { + myAction = 3; + } + } - // Standard-Raise-Routine - } else { - // raise-Betrag ermitteln - raise = (((int)myOdds-myNiveau[2])/5)*2*currentHand->getSmallBlind(); - // raise-Betrag zu klein -> mindestens Standard-raise - // if(raise < currentHand->getCurrentBeRo()->getHighestSet()) { - // raise = currentHand->getCurrentBeRo()->getHighestSet(); - // } - // all in bei nur wenigen Chips oder knappem raise - if(myCash/(2*currentHand->getSmallBlind()) <= 6 || raise >= (myCash*4.0)/5.0) { - raise = myCash; - } - myAction = 5; - } + // Standard-Raise-Routine + } else { + // raise-Betrag ermitteln + raise = (((int)myOdds-myNiveau[2])/5)*2*currentHand->getSmallBlind(); + // raise-Betrag zu klein -> mindestens Standard-raise + // if(raise < currentHand->getCurrentBeRo()->getHighestSet()) { + // raise = currentHand->getCurrentBeRo()->getHighestSet(); + // } + // all in bei nur wenigen Chips oder knappem raise + if(myCash/(2*currentHand->getSmallBlind()) <= 6 || raise >= (myCash*4.0)/5.0) { + raise = myCash; + } + myAction = 5; + } - // auf cBluff testen --> call statt raise - if(cBluff > 90) myAction = 3; - if(cBluff > 80 && myOdds >= myNiveau[2] + 4) myAction = 3; - if(cBluff > 70 && myOdds >= myNiveau[2] + 8) myAction = 3; - if(cBluff > 60 && myOdds >= myNiveau[2] + 12) myAction = 3; + // auf cBluff testen --> call statt raise + if(cBluff > 90) myAction = 3; + if(cBluff > 80 && myOdds >= myNiveau[2] + 4) myAction = 3; + if(cBluff > 70 && myOdds >= myNiveau[2] + 8) myAction = 3; + if(cBluff > 60 && myOdds >= myNiveau[2] + 12) myAction = 3; - } - else { - // call -> über niveau0, schon einiges gesetzt im flop, schon einiges insgesamt gesetzt - if(myOdds >= myNiveau[0] || (mySet >= currentHand->getCurrentBeRo()->getHighestSet()/2 && myOdds >= myNiveau[0]-5) || (myRoundStartCash-myCash > individualHighestSet && myNiveau[0]-3)) { - // all in bei knappem call - if(currentHand->getCurrentBeRo()->getHighestSet() > (myCash*3.0)/4.0) { - raise = myCash; - myAction = 5; - } - else myAction = 3; - } - // fold - else { - myAction = 1; - } - } - } - else { - // bet - if(myOdds >= myNiveau[1]) { - bet = (((int)myOdds-myNiveau[1])/8)*2*currentHand->getSmallBlind(); - // bet zu klein - if(bet == 0) { - bet = 2*currentHand->getSmallBlind(); - } - // all in bei nur wenigen Chips - if(myCash/(2*currentHand->getSmallBlind()) <= 6) { - bet = myCash; - } - // all in bei knappem bet - if(bet > (myCash*4.0)/5.0) { - bet = myCash; - } - myAction = 4; + } else { + // call -> über niveau0, schon einiges gesetzt im flop, schon einiges insgesamt gesetzt + if(myOdds >= myNiveau[0] || (mySet >= currentHand->getCurrentBeRo()->getHighestSet()/2 && myOdds >= myNiveau[0]-5) || (myRoundStartCash-myCash > individualHighestSet && myNiveau[0]-3)) { + // all in bei knappem call + if(currentHand->getCurrentBeRo()->getHighestSet() > (myCash*3.0)/4.0) { + raise = myCash; + myAction = 5; + } else myAction = 3; + } + // fold + else { + myAction = 1; + } + } + } else { + // bet + if(myOdds >= myNiveau[1]) { + bet = (((int)myOdds-myNiveau[1])/8)*2*currentHand->getSmallBlind(); + // bet zu klein + if(bet == 0) { + bet = 2*currentHand->getSmallBlind(); + } + // all in bei nur wenigen Chips + if(myCash/(2*currentHand->getSmallBlind()) <= 6) { + bet = myCash; + } + // all in bei knappem bet + if(bet > (myCash*4.0)/5.0) { + bet = myCash; + } + myAction = 4; - // auf cBluff testen --> check statt bet - if(cBluff > 80) myAction = 2; - if(cBluff > 70 && myOdds >= myNiveau[1] + 4) myAction = 2; - if(cBluff > 60 && myOdds >= myNiveau[1] + 8) myAction = 2; - if(cBluff > 50 && myOdds >= myNiveau[1] + 12) myAction = 2; - } - // check - else { - myAction = 2; - // Position - if(myButton == 1) { - // Position-Bluff generieren - Tools::getRandNumber(1,100,1,&pBluff,0); - if(pBluff <= 16) { - bet = (pBluff/4)*2*currentHand->getSmallBlind(); - // bet zu klein - if(bet == 0) { - bet = 2*currentHand->getSmallBlind(); - } - // all in bei nur wenigen Chips - if(myCash/(2*currentHand->getSmallBlind()) <= 6) { - bet = myCash; - } - // all in bei knappem bet - if(bet > (myCash*4.0)/5.0) { - bet = myCash; - } - myAction = 4; - } - } - } + // auf cBluff testen --> check statt bet + if(cBluff > 80) myAction = 2; + if(cBluff > 70 && myOdds >= myNiveau[1] + 4) myAction = 2; + if(cBluff > 60 && myOdds >= myNiveau[1] + 8) myAction = 2; + if(cBluff > 50 && myOdds >= myNiveau[1] + 12) myAction = 2; + } + // check + else { + myAction = 2; + // Position + if(myButton == 1) { + // Position-Bluff generieren + Tools::getRandNumber(1,100,1,&pBluff,0); + if(pBluff <= 16) { + bet = (pBluff/4)*2*currentHand->getSmallBlind(); + // bet zu klein + if(bet == 0) { + bet = 2*currentHand->getSmallBlind(); + } + // all in bei nur wenigen Chips + if(myCash/(2*currentHand->getSmallBlind()) <= 6) { + bet = myCash; + } + // all in bei knappem bet + if(bet > (myCash*4.0)/5.0) { + bet = myCash; + } + myAction = 4; + } + } + } - } + } - // auf sBluffStatus testen --> raise statt call und bet statt check + // auf sBluffStatus testen --> raise statt call und bet statt check - // aktiv oder passiv? - if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + // aktiv oder passiv? + if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - if(sBluffStatus && myOdds < myNiveau[2]) { + if(sBluffStatus && myOdds < myNiveau[2]) { - // cout << "sBLUFF!" << endl; + // cout << "sBLUFF!" << endl; - // Gegner setzen -> call - if(currentHand->getCurrentBeRo()->getHighestSet() >= 4*currentHand->getSmallBlind()) { - myAction = 3; - } - // Standard-Raise-Routine - else { - // raise-Betrag ermitteln - Tools::getRandNumber(1,8,1,&rand,0); - raise = rand*currentHand->getSmallBlind(); - // raise-Betrag zu klein -> mindestens Standard-raise - // if(raise < currentHand->getCurrentBeRo()->getHighestSet()) { - // raise = currentHand->getCurrentBeRo()->getHighestSet(); - // } - // all in bei nur wenigen Chips oder knappem raise - if(myCash/(2*currentHand->getSmallBlind()) <= 6 || raise >= (myCash*4)/5) { - raise = myCash; - } - myAction = 5; - } + // Gegner setzen -> call + if(currentHand->getCurrentBeRo()->getHighestSet() >= 4*currentHand->getSmallBlind()) { + myAction = 3; + } + // Standard-Raise-Routine + else { + // raise-Betrag ermitteln + Tools::getRandNumber(1,8,1,&rand,0); + raise = rand*currentHand->getSmallBlind(); + // raise-Betrag zu klein -> mindestens Standard-raise + // if(raise < currentHand->getCurrentBeRo()->getHighestSet()) { + // raise = currentHand->getCurrentBeRo()->getHighestSet(); + // } + // all in bei nur wenigen Chips oder knappem raise + if(myCash/(2*currentHand->getSmallBlind()) <= 6 || raise >= (myCash*4)/5) { + raise = myCash; + } + myAction = 5; + } - // extrem hoher set der gegner -> bluff beenden - if(currentHand->getCurrentBeRo()->getHighestSet() >= 10*currentHand->getSmallBlind()) { - myAction = 1; - } - } - } - else { - if(sBluffStatus && myOdds < myNiveau[1]) { + // extrem hoher set der gegner -> bluff beenden + if(currentHand->getCurrentBeRo()->getHighestSet() >= 10*currentHand->getSmallBlind()) { + myAction = 1; + } + } + } else { + if(sBluffStatus && myOdds < myNiveau[1]) { - // cout << "sBLUFF!" << endl; + // cout << "sBLUFF!" << endl; - Tools::getRandNumber(1,8,1,&rand,0); - bet = rand*currentHand->getSmallBlind(); - // bet zu klein - if(bet < 2*currentHand->getSmallBlind()) { - bet = 2*currentHand->getSmallBlind(); - } - // all in bei nur wenigen Chips - if(myCash/(2*currentHand->getSmallBlind()) <= 6) { - bet = myCash; - } - // all in bei knappem bet - if(bet > (myCash*4.0)/5.0) { - bet = myCash; - } - myAction = 4; - } + Tools::getRandNumber(1,8,1,&rand,0); + bet = rand*currentHand->getSmallBlind(); + // bet zu klein + if(bet < 2*currentHand->getSmallBlind()) { + bet = 2*currentHand->getSmallBlind(); + } + // all in bei nur wenigen Chips + if(myCash/(2*currentHand->getSmallBlind()) <= 6) { + bet = myCash; + } + // all in bei knappem bet + if(bet > (myCash*4.0)/5.0) { + bet = myCash; + } + myAction = 4; + } - } + } - if(DEBUG_MODE) { - switch(myUniqueID) { - case 0: { - } break; - case 1: { + if(DEBUG_MODE) { + switch(myUniqueID) { + case 0: { + } break; + case 1: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_CHECK; - // bet = 20; - // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - // myAction = PLAYER_ACTION_CALL; - // } - } break; - case 2: { - // myAction = PLAYER_ACTION_BET; - // raise = 25; - } break; - default: { - } - } - } break; - case 2: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CHECK; + // bet = 20; + // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + case 2: { + // myAction = PLAYER_ACTION_BET; + // raise = 25; + } break; + default: { + } + } + } break; + case 2: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_CHECK; - // bet = 20; - // raise = 20; - // if(mySet > 20) { - // myAction = PLAYER_ACTION_CALL; - // } - // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CHECK; + // bet = 20; + // raise = 20; + // if(mySet > 20) { + // myAction = PLAYER_ACTION_CALL; + // } + // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 3: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_CHECK; - // raise = 400; - // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + } + break; + case 3: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CHECK; + // raise = 400; + // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 4: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_CHECK; - // raise = 140; + } + break; + case 4: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CHECK; + // raise = 140; // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { // myAction = PLAYER_ACTION_CALL; // } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 5: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_CHECK; + } + break; + case 5: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CHECK; // bet = 20; - // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - // myAction = PLAYER_ACTION_FOLD; - // } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + // myAction = PLAYER_ACTION_FOLD; + // } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 6: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_CHECK; + } + break; + case 6: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CHECK; // raise = 40; // if(currentHand->getCurrentBeRo()->getHighestSet() > 60) { // myAction = PLAYER_ACTION_CALL; // } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 7: { - myAction = PLAYER_ACTION_CHECK; - } - break; - case 8: { - myAction = PLAYER_ACTION_CHECK; - } - break; - case 9: { - myAction = PLAYER_ACTION_CHECK; - } - break; - default: {} - } + } + break; + case 7: { + myAction = PLAYER_ACTION_CHECK; + } + break; + case 8: { + myAction = PLAYER_ACTION_CHECK; + } + break; + case 9: { + myAction = PLAYER_ACTION_CHECK; + } + break; + default: + {} + } - } + } - // minimum raise setting and resetting - // if(myAction == 5) { - // - // if(raise < currentHand->getCurrentBeRo()->getMinimumRaise()) { - // raise = currentHand->getCurrentBeRo()->getMinimumRaise(); - // } - // currentHand->getCurrentBeRo()->setMinimumRaise(raise); - // - // } - // - // if(myAction == 4) { currentHand->getCurrentBeRo()->setMinimumRaise(bet); } + // minimum raise setting and resetting + // if(myAction == 5) { + // + // if(raise < currentHand->getCurrentBeRo()->getMinimumRaise()) { + // raise = currentHand->getCurrentBeRo()->getMinimumRaise(); + // } + // currentHand->getCurrentBeRo()->setMinimumRaise(raise); + // + // } + // + // if(myAction == 4) { currentHand->getCurrentBeRo()->setMinimumRaise(bet); } - evaluation(bet, raise); + evaluation(bet, raise); - // cout << "Engine 0.4" << endl; - // int tempArray[5]; - // int boardCards[5]; - // int info[4]; - // int cBluff; - // int sBluff; - // int bet = 0; - // int raise = 0; - // - // int i; - // - // - // for(i=0; i<2; i++) tempArray[i] = myCards[i]; - // currentBoard->getMyCards(boardCards); - // for(i=0; i<3; i++) tempArray[2+i] = boardCards[i]; - // - // for(i=0; i<4; i++) info[i] = -1; - // - // // for(i=0; i<5; i++) cout << tempArray[i] << " "; - // // cout << endl; - // - // cout << myID << ": "; - // - // flopCardsValue(tempArray); - // - // // aktive Situation --> check / bet - // if(currentHand->getCurrentBeRo()->getHighestSet() == 0) { - // - // switch(info[0]) { - // case 9: {} - // case 8: {} - // case 7: {} - // case 6: {} - // case 5: {} - // case 4: { - // Tools::getRandNumber(0,100,1,&cBluff,0); - // if(cBluff < 35) { - // myAction = 2; - // } - // else { - // if(myCash/(2*currentHand->getSmallBlind()) <= 8) { - // myAction = 6; - // } else { - // if(cBluff < 60) { - // bet = (7-myDude4)*2*currentHand->getSmallBlind(); - // } else { - // bet = (((100-cBluff)/20)+2)*currentHand->getSmallBlind(); - // } - // if(bet < 2*currentHand->getSmallBlind()) bet = 2*currentHand->getSmallBlind(); - // myAction = 4; - // } - // } - // } - // break; - // case 3: { - // switch(info[3]) { - // case 2: { - // Tools::getRandNumber(0,100,1,&cBluff,0); - // if(cBluff < 35) { - // myAction = 2; - // } - // else { - // if(myCash/(2*currentHand->getSmallBlind()) <= 8) { - // myAction = 6; - // } else { - // if(cBluff < 60) { - // bet = (5-myDude4)*2*currentHand->getSmallBlind(); - // } else { - // bet = (((100-cBluff)/20)+2)*currentHand->getSmallBlind(); - // } - // if(bet < 2*currentHand->getSmallBlind()) bet = 2*currentHand->getSmallBlind(); - // myAction = 4; - // } - // } - // } - // break; - // case 1: { - // Tools::getRandNumber(0,100,1,&cBluff,0); - // if(cBluff < 40) { - // myAction = 2; - // } - // else { - // if(myCash/(2*currentHand->getSmallBlind()) <= 6) { - // myAction = 6; - // } else { - // if(cBluff < 60) { - // bet = (3-myDude4)*2*currentHand->getSmallBlind(); - // } else { - // bet = (((100-cBluff)/20)+2)*currentHand->getSmallBlind(); - // } - // if(bet < 2*currentHand->getSmallBlind()) bet = 2*currentHand->getSmallBlind(); - // myAction = 4; - // } - // } - // } - // break; - // default: { - // Tools::getRandNumber(0,100,1,&sBluff,0); - // if(info[1] >= 10 && sBluff <= 40) { - // bet = (sBluff/10)*2*currentHand->getSmallBlind(); - // if(bet < 2*currentHand->getSmallBlind()) bet = 2*currentHand->getSmallBlind(); - // myAction = 4; - // } - // else { - // myAction = 2; - // } - // } - // } - // } - // break; - // case 2: { - // switch(info[3]) { - // case 2: { - // Tools::getRandNumber(0,100,1,&cBluff,0); - // if(cBluff > 80) { - // myAction = 2; - // } - // else { - // if(myCash/(2*currentHand->getSmallBlind()) <= 6) { - // myAction = 6; - // } else { - // bet = (cBluff/20)*2*currentHand->getSmallBlind(); - // if(bet < 2*currentHand->getSmallBlind()) bet = 2*currentHand->getSmallBlind(); - // myAction = 4; - // } - // } - // } - // break; - // default: { - // Tools::getRandNumber(0,100,1,&cBluff,0); - // if(cBluff > 90) { - // myAction = 2; - // } - // else { - // if(myCash/(2*currentHand->getSmallBlind()) <= 5) { - // myAction = 6; - // } else { - // bet = (cBluff/30)*2*currentHand->getSmallBlind(); - // if(bet < 2*currentHand->getSmallBlind()) bet = 2*currentHand->getSmallBlind(); - // myAction = 4; - // } - // } - // } - // } - // } - // break; - // case 1: { - // if(!info[2]) { - // Tools::getRandNumber(0,100,1,&sBluff,0); - // switch(info[3]) { - // case 2: {} - // case 1: { - // if(currentHand->getActivePlayerList().size() == 2) { - // bet = (1-myDude4)*2*currentHand->getSmallBlind(); - // if(bet < 2*currentHand->getSmallBlind()) bet = 2*currentHand->getSmallBlind(); - // myAction = 4; - // - // } - // else { - // switch(info[1]) { - // case 3: { - // if(sBluff <= 10) { - // bet = (sBluff/5 + 2)*currentHand->getSmallBlind(); - // myAction = 4; - // } - // else { - // myAction = 2; - // } - // } - // break; - // case 2: { - // if(sBluff <= 15) { - // bet = (sBluff/5 + 2)*currentHand->getSmallBlind(); - // myAction = 4; - // } - // else { - // myAction = 2; - // } - // } - // break; - // case 1: { - // if(sBluff <= 50) { - // bet = (sBluff/15 + 2)*currentHand->getSmallBlind(); - // myAction = 4; - // } - // else { - // myAction = 2; - // } - // } - // break; - // default: { - // if(myCash/(2*currentHand->getSmallBlind()) <= 5) { - // myAction = 6; - // } else { - // bet = (sBluff/15)*2*currentHand->getSmallBlind(); - // if(bet < 2*currentHand->getSmallBlind()) bet = 2*currentHand->getSmallBlind(); - // myAction = 4; - // } - // } - // break; - // } - // } - // } - // break; - // default: { - // } - // } - // } - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // - // } - // break; - // default: {} - // } - // - // - // - // } - // // passive Situation --> fold / call / raise - // else { - // - // - // - // } + // cout << "Engine 0.4" << endl; + // int tempArray[5]; + // int boardCards[5]; + // int info[4]; + // int cBluff; + // int sBluff; + // int bet = 0; + // int raise = 0; + // + // int i; + // + // + // for(i=0; i<2; i++) tempArray[i] = myCards[i]; + // currentBoard->getMyCards(boardCards); + // for(i=0; i<3; i++) tempArray[2+i] = boardCards[i]; + // + // for(i=0; i<4; i++) info[i] = -1; + // + // // for(i=0; i<5; i++) cout << tempArray[i] << " "; + // // cout << endl; + // + // cout << myID << ": "; + // + // flopCardsValue(tempArray); + // + // // aktive Situation --> check / bet + // if(currentHand->getCurrentBeRo()->getHighestSet() == 0) { + // + // switch(info[0]) { + // case 9: {} + // case 8: {} + // case 7: {} + // case 6: {} + // case 5: {} + // case 4: { + // Tools::getRandNumber(0,100,1,&cBluff,0); + // if(cBluff < 35) { + // myAction = 2; + // } + // else { + // if(myCash/(2*currentHand->getSmallBlind()) <= 8) { + // myAction = 6; + // } else { + // if(cBluff < 60) { + // bet = (7-myDude4)*2*currentHand->getSmallBlind(); + // } else { + // bet = (((100-cBluff)/20)+2)*currentHand->getSmallBlind(); + // } + // if(bet < 2*currentHand->getSmallBlind()) bet = 2*currentHand->getSmallBlind(); + // myAction = 4; + // } + // } + // } + // break; + // case 3: { + // switch(info[3]) { + // case 2: { + // Tools::getRandNumber(0,100,1,&cBluff,0); + // if(cBluff < 35) { + // myAction = 2; + // } + // else { + // if(myCash/(2*currentHand->getSmallBlind()) <= 8) { + // myAction = 6; + // } else { + // if(cBluff < 60) { + // bet = (5-myDude4)*2*currentHand->getSmallBlind(); + // } else { + // bet = (((100-cBluff)/20)+2)*currentHand->getSmallBlind(); + // } + // if(bet < 2*currentHand->getSmallBlind()) bet = 2*currentHand->getSmallBlind(); + // myAction = 4; + // } + // } + // } + // break; + // case 1: { + // Tools::getRandNumber(0,100,1,&cBluff,0); + // if(cBluff < 40) { + // myAction = 2; + // } + // else { + // if(myCash/(2*currentHand->getSmallBlind()) <= 6) { + // myAction = 6; + // } else { + // if(cBluff < 60) { + // bet = (3-myDude4)*2*currentHand->getSmallBlind(); + // } else { + // bet = (((100-cBluff)/20)+2)*currentHand->getSmallBlind(); + // } + // if(bet < 2*currentHand->getSmallBlind()) bet = 2*currentHand->getSmallBlind(); + // myAction = 4; + // } + // } + // } + // break; + // default: { + // Tools::getRandNumber(0,100,1,&sBluff,0); + // if(info[1] >= 10 && sBluff <= 40) { + // bet = (sBluff/10)*2*currentHand->getSmallBlind(); + // if(bet < 2*currentHand->getSmallBlind()) bet = 2*currentHand->getSmallBlind(); + // myAction = 4; + // } + // else { + // myAction = 2; + // } + // } + // } + // } + // break; + // case 2: { + // switch(info[3]) { + // case 2: { + // Tools::getRandNumber(0,100,1,&cBluff,0); + // if(cBluff > 80) { + // myAction = 2; + // } + // else { + // if(myCash/(2*currentHand->getSmallBlind()) <= 6) { + // myAction = 6; + // } else { + // bet = (cBluff/20)*2*currentHand->getSmallBlind(); + // if(bet < 2*currentHand->getSmallBlind()) bet = 2*currentHand->getSmallBlind(); + // myAction = 4; + // } + // } + // } + // break; + // default: { + // Tools::getRandNumber(0,100,1,&cBluff,0); + // if(cBluff > 90) { + // myAction = 2; + // } + // else { + // if(myCash/(2*currentHand->getSmallBlind()) <= 5) { + // myAction = 6; + // } else { + // bet = (cBluff/30)*2*currentHand->getSmallBlind(); + // if(bet < 2*currentHand->getSmallBlind()) bet = 2*currentHand->getSmallBlind(); + // myAction = 4; + // } + // } + // } + // } + // } + // break; + // case 1: { + // if(!info[2]) { + // Tools::getRandNumber(0,100,1,&sBluff,0); + // switch(info[3]) { + // case 2: {} + // case 1: { + // if(currentHand->getActivePlayerList().size() == 2) { + // bet = (1-myDude4)*2*currentHand->getSmallBlind(); + // if(bet < 2*currentHand->getSmallBlind()) bet = 2*currentHand->getSmallBlind(); + // myAction = 4; + // + // } + // else { + // switch(info[1]) { + // case 3: { + // if(sBluff <= 10) { + // bet = (sBluff/5 + 2)*currentHand->getSmallBlind(); + // myAction = 4; + // } + // else { + // myAction = 2; + // } + // } + // break; + // case 2: { + // if(sBluff <= 15) { + // bet = (sBluff/5 + 2)*currentHand->getSmallBlind(); + // myAction = 4; + // } + // else { + // myAction = 2; + // } + // } + // break; + // case 1: { + // if(sBluff <= 50) { + // bet = (sBluff/15 + 2)*currentHand->getSmallBlind(); + // myAction = 4; + // } + // else { + // myAction = 2; + // } + // } + // break; + // default: { + // if(myCash/(2*currentHand->getSmallBlind()) <= 5) { + // myAction = 6; + // } else { + // bet = (sBluff/15)*2*currentHand->getSmallBlind(); + // if(bet < 2*currentHand->getSmallBlind()) bet = 2*currentHand->getSmallBlind(); + // myAction = 4; + // } + // } + // break; + // } + // } + // } + // break; + // default: { + // } + // } + // } + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // + // } + // break; + // default: {} + // } + // + // + // + // } + // // passive Situation --> fold / call / raise + // else { + // + // + // + // } } -void LocalPlayer::turnEngine() { +void LocalPlayer::turnEngine() +{ - // int tempArray[6]; - // int boardCards[5]; - // int i; + // int tempArray[6]; + // int boardCards[5]; + // int i; - // for(i=0; i<2; i++) tempArray[i] = myCards[i]; - // currentBoard->getMyCards(boardCards); - // for(i=0; i<4; i++) tempArray[2+i] = boardCards[i]; + // for(i=0; i<2; i++) tempArray[i] = myCards[i]; + // currentBoard->getMyCards(boardCards); + // for(i=0; i<4; i++) tempArray[2+i] = boardCards[i]; - // for(i=0; i<5; i++) cout << tempArray[i] << " "; - // cout << endl; + // for(i=0; i<5; i++) cout << tempArray[i] << " "; + // cout << endl; - // cout << myID << ": "; + // cout << myID << ": "; - // turnCardsValue(tempArray); + // turnCardsValue(tempArray); - int raise = 0; - int bet = 0; - // int i; - int cBluff; - int pBluff; - int rand; - PlayerListConstIterator it_c; + int raise = 0; + int bet = 0; + // int i; + int cBluff; + int pBluff; + int rand; + PlayerListConstIterator it_c; - calcMyOdds(); + calcMyOdds(); - // Niveaus setzen + Dude + Anzahl Gegenspieler - // 1. Fold -- Call - myNiveau[0] = 53 + myDude4/* - 6*(currentHand->getActivePlayerList().size() - 2)*/; - // 2. Check -- Bet - myNiveau[1] = 56 + myDude4/* - 6*(currentHand->getActivePlayerList().size() - 2)*/; - // 3. Call -- Raise - myNiveau[2] = 69 + myDude4/* - 6*(currentHand->getActivePlayerList().size() - 2)*/; + // Niveaus setzen + Dude + Anzahl Gegenspieler + // 1. Fold -- Call + myNiveau[0] = 53 + myDude4/* - 6*(currentHand->getActivePlayerList().size() - 2)*/; + // 2. Check -- Bet + myNiveau[1] = 56 + myDude4/* - 6*(currentHand->getActivePlayerList().size() - 2)*/; + // 3. Call -- Raise + myNiveau[2] = 69 + myDude4/* - 6*(currentHand->getActivePlayerList().size() - 2)*/; - // count number of active human players - size_t countHumanPlayers = 0; + // count number of active human players + size_t countHumanPlayers = 0; for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); ++it_c) { - if((*it_c)->getMyType() == PLAYER_TYPE_HUMAN) { - countHumanPlayers++; - } - } - if(countHumanPlayers) { - // local or network game and only one human player is active --> set aggValue - if(countHumanPlayers == 1) { + if((*it_c)->getMyType() == PLAYER_TYPE_HUMAN) { + countHumanPlayers++; + } + } + if(countHumanPlayers) { + // local or network game and only one human player is active --> set aggValue + if(countHumanPlayers == 1) { for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); ++it_c) { - if((*it_c)->getMyType() == PLAYER_TYPE_HUMAN && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { - int aggValue = (int)((( (*it_c)->getMyAggressive()*1.0)/7.0 - 1.0/currentHand->getActivePlayerList()->size())*21.0); - myNiveau[0] -= aggValue; - myNiveau[1] -= aggValue; - myNiveau[2] -= aggValue; - } - } - // network game - } else { - myNiveau[0] -= 3; - myNiveau[1] -= 3; - myNiveau[2] -= 3; - } - } + if((*it_c)->getMyType() == PLAYER_TYPE_HUMAN && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { + int aggValue = (int)((( (*it_c)->getMyAggressive()*1.0)/7.0 - 1.0/currentHand->getActivePlayerList()->size())*21.0); + myNiveau[0] -= aggValue; + myNiveau[1] -= aggValue; + myNiveau[2] -= aggValue; + } + } + // network game + } else { + myNiveau[0] -= 3; + myNiveau[1] -= 3; + myNiveau[2] -= 3; + } + } - // Aggresivität des humanPlayers auslesen -> nur wenn er aktiv ist ! - // it_c = currentHand->getActivePlayerIt(0); - // if( it_c != currentHand->getActivePlayerList()->end() ) { - // if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD ) { - // int aggValue = (int)((( (*it_c)->getMyAggressive()*1.0)/7.0 - 1.0/currentHand->getActivePlayerList()->size())*21.0); - // for(i=0; i<3; i++) { - // myNiveau[i] -= aggValue; - // } - // } - // - // } + // Aggresivität des humanPlayers auslesen -> nur wenn er aktiv ist ! + // it_c = currentHand->getActivePlayerIt(0); + // if( it_c != currentHand->getActivePlayerList()->end() ) { + // if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD ) { + // int aggValue = (int)((( (*it_c)->getMyAggressive()*1.0)/7.0 - 1.0/currentHand->getActivePlayerList()->size())*21.0); + // for(i=0; i<3; i++) { + // myNiveau[i] -= aggValue; + // } + // } + // + // } - // cout << "Spieler " << myID << ": Dude " << myDude4 << "\t Wert " << myHoleCardsValue << "\t Niveau " << myNiveau[0] << " " << myNiveau[1] << " " << myNiveau[2] << "\t Agg " << aggValue << " " << endl; + // cout << "Spieler " << myID << ": Dude " << myDude4 << "\t Wert " << myHoleCardsValue << "\t Niveau " << myNiveau[0] << " " << myNiveau[1] << " " << myNiveau[2] << "\t Agg " << aggValue << " " << endl; - // eigenes mögliches highestSet - int individualHighestSet = currentHand->getCurrentBeRo()->getHighestSet(); - if(individualHighestSet > myCash) individualHighestSet = myCash; + // eigenes mögliches highestSet + int individualHighestSet = currentHand->getCurrentBeRo()->getHighestSet(); + if(individualHighestSet > myCash) individualHighestSet = myCash; - // Check-Bluff generieren - Tools::getRandNumber(1,100,1,&cBluff,0); + // Check-Bluff generieren + Tools::getRandNumber(1,100,1,&cBluff,0); - // aktiv oder passiv? - if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + // aktiv oder passiv? + if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - // Verhaeltnis Set / Cash - if(myCash/individualHighestSet >= 25) { - myNiveau[0] += (25-myCash/individualHighestSet)/10; - } else { - myNiveau[0] += (25-myCash/individualHighestSet)/2; - } + // Verhaeltnis Set / Cash + if(myCash/individualHighestSet >= 25) { + myNiveau[0] += (25-myCash/individualHighestSet)/10; + } else { + myNiveau[0] += (25-myCash/individualHighestSet)/2; + } - // Verhaeltnis Set / Cash für raise - if(myCash/individualHighestSet < 11) { - myNiveau[2] += (21-myCash/individualHighestSet)/2; - } + // Verhaeltnis Set / Cash für raise + if(myCash/individualHighestSet < 11) { + myNiveau[2] += (21-myCash/individualHighestSet)/2; + } - // raise (bei hohem Niveau) - if(myOdds >= myNiveau[2]) { + // raise (bei hohem Niveau) + if(myOdds >= myNiveau[2]) { - // raise-loop unterbinden -> d.h. entweder call oder bei superblatt all in - if(currentHand->getCurrentBeRo()->getHighestSet() >= 12*currentHand->getSmallBlind()) { - // all in - if(myOdds >= myNiveau[2] + 15) { - raise = myCash; - myAction = 5; - } - // nur call - else { - // all in bei knappem call - if(myCash-currentHand->getCurrentBeRo()->getHighestSet() <= (myCash*1)/5) { - raise = myCash; - myAction = 5; - } else { - myAction = 3; - } - } + // raise-loop unterbinden -> d.h. entweder call oder bei superblatt all in + if(currentHand->getCurrentBeRo()->getHighestSet() >= 12*currentHand->getSmallBlind()) { + // all in + if(myOdds >= myNiveau[2] + 15) { + raise = myCash; + myAction = 5; + } + // nur call + else { + // all in bei knappem call + if(myCash-currentHand->getCurrentBeRo()->getHighestSet() <= (myCash*1)/5) { + raise = myCash; + myAction = 5; + } else { + myAction = 3; + } + } - // Standard-Raise-Routine - } else { - // raise-Betrag ermitteln - raise = (((int)myOdds-myNiveau[2])/4)*2*currentHand->getSmallBlind(); - // raise-Betrag zu klein -> mindestens Standard-raise - // if(raise < currentHand->getCurrentBeRo()->getHighestSet()) { - // raise = currentHand->getCurrentBeRo()->getHighestSet(); - // } - // all in bei nur wenigen Chips oder knappem raise - if(myCash/(2*currentHand->getSmallBlind()) <= 6 || raise >= (myCash*4.0)/5.0) { - raise = myCash; - } - myAction = 5; - } - // auf cBluff testen --> call statt raise - if(cBluff > 90) myAction = 3; - if(cBluff > 80 && myOdds >= myNiveau[2] + 5) myAction = 3; - if(cBluff > 70 && myOdds >= myNiveau[2] + 10) myAction = 3; - if(cBluff > 60 && myOdds >= myNiveau[2] + 15) myAction = 3; - } - else { - // call -> über niveau0, schon einiges gesetzt im flop, schon einiges insgesamt gesetzt - if(myOdds >= myNiveau[0] || (mySet >= currentHand->getCurrentBeRo()->getHighestSet()/2 && myOdds >= myNiveau[0]-5) || (myRoundStartCash-myCash > individualHighestSet && myNiveau[0]-3)) { - // all in bei knappem call - if(currentHand->getCurrentBeRo()->getHighestSet() > (myCash*3.0)/4.0) { - raise = myCash; - myAction = 5; - } - else myAction = 3; - } - // fold - else { - myAction = 1; - } - } - } - // aktiv - else { - // bet - if(myOdds >= myNiveau[1]) { - bet = (((int)myOdds-myNiveau[1])/6)*2*currentHand->getSmallBlind(); - if(bet == 0) { - bet = 2*currentHand->getSmallBlind(); - } - // all in bei nur wenigen Chips - if(myCash/(2*currentHand->getSmallBlind()) <= 6) { - bet = myCash; - } - // all in bei knappem bet - if(bet > (myCash*4.0)/5.0) { - bet = myCash; - } - myAction = 4; + // Standard-Raise-Routine + } else { + // raise-Betrag ermitteln + raise = (((int)myOdds-myNiveau[2])/4)*2*currentHand->getSmallBlind(); + // raise-Betrag zu klein -> mindestens Standard-raise + // if(raise < currentHand->getCurrentBeRo()->getHighestSet()) { + // raise = currentHand->getCurrentBeRo()->getHighestSet(); + // } + // all in bei nur wenigen Chips oder knappem raise + if(myCash/(2*currentHand->getSmallBlind()) <= 6 || raise >= (myCash*4.0)/5.0) { + raise = myCash; + } + myAction = 5; + } + // auf cBluff testen --> call statt raise + if(cBluff > 90) myAction = 3; + if(cBluff > 80 && myOdds >= myNiveau[2] + 5) myAction = 3; + if(cBluff > 70 && myOdds >= myNiveau[2] + 10) myAction = 3; + if(cBluff > 60 && myOdds >= myNiveau[2] + 15) myAction = 3; + } else { + // call -> über niveau0, schon einiges gesetzt im flop, schon einiges insgesamt gesetzt + if(myOdds >= myNiveau[0] || (mySet >= currentHand->getCurrentBeRo()->getHighestSet()/2 && myOdds >= myNiveau[0]-5) || (myRoundStartCash-myCash > individualHighestSet && myNiveau[0]-3)) { + // all in bei knappem call + if(currentHand->getCurrentBeRo()->getHighestSet() > (myCash*3.0)/4.0) { + raise = myCash; + myAction = 5; + } else myAction = 3; + } + // fold + else { + myAction = 1; + } + } + } + // aktiv + else { + // bet + if(myOdds >= myNiveau[1]) { + bet = (((int)myOdds-myNiveau[1])/6)*2*currentHand->getSmallBlind(); + if(bet == 0) { + bet = 2*currentHand->getSmallBlind(); + } + // all in bei nur wenigen Chips + if(myCash/(2*currentHand->getSmallBlind()) <= 6) { + bet = myCash; + } + // all in bei knappem bet + if(bet > (myCash*4.0)/5.0) { + bet = myCash; + } + myAction = 4; - // auf cBluff testen --> call statt raise - if(cBluff > 90) myAction = 2; - if(cBluff > 80 && myOdds >= myNiveau[2] + 5) myAction = 2; - if(cBluff > 70 && myOdds >= myNiveau[2] + 10) myAction = 2; - if(cBluff > 60 && myOdds >= myNiveau[2] + 15) myAction = 2; - } - // check - else { - myAction = 2; - // Position - if(myButton == 1) { - // Position-Bluff generieren - Tools::getRandNumber(1,100,1,&pBluff,0); - if(pBluff <= 16) { - bet = (pBluff/4)*2*currentHand->getSmallBlind(); - // bet zu klein - if(bet == 0) { - bet = 2*currentHand->getSmallBlind(); - } - // all in bei nur wenigen Chips - if(myCash/(2*currentHand->getSmallBlind()) <= 6) { - bet = myCash; - } - // all in bei knappem bet - if(bet > (myCash*4.0)/5.0) { - bet = myCash; - } - myAction = 4; - } - } - } - } + // auf cBluff testen --> call statt raise + if(cBluff > 90) myAction = 2; + if(cBluff > 80 && myOdds >= myNiveau[2] + 5) myAction = 2; + if(cBluff > 70 && myOdds >= myNiveau[2] + 10) myAction = 2; + if(cBluff > 60 && myOdds >= myNiveau[2] + 15) myAction = 2; + } + // check + else { + myAction = 2; + // Position + if(myButton == 1) { + // Position-Bluff generieren + Tools::getRandNumber(1,100,1,&pBluff,0); + if(pBluff <= 16) { + bet = (pBluff/4)*2*currentHand->getSmallBlind(); + // bet zu klein + if(bet == 0) { + bet = 2*currentHand->getSmallBlind(); + } + // all in bei nur wenigen Chips + if(myCash/(2*currentHand->getSmallBlind()) <= 6) { + bet = myCash; + } + // all in bei knappem bet + if(bet > (myCash*4.0)/5.0) { + bet = myCash; + } + myAction = 4; + } + } + } + } - // auf sBluffStatus testen --> raise statt call und bet statt check + // auf sBluffStatus testen --> raise statt call und bet statt check - // aktiv oder passiv? - if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + // aktiv oder passiv? + if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - if(sBluffStatus && myOdds < myNiveau[2]) { + if(sBluffStatus && myOdds < myNiveau[2]) { - // cout << "sBLUFF!" << endl; + // cout << "sBLUFF!" << endl; - // Gegner setzen -> call - if(currentHand->getCurrentBeRo()->getHighestSet() >= 4*currentHand->getSmallBlind()) { - myAction = 3; - } - // Standard-Raise-Routine - else { - // raise-Betrag ermitteln - Tools::getRandNumber(1,8,1,&rand,0); - raise = rand*currentHand->getSmallBlind(); - // raise-Betrag zu klein -> mindestens Standard-raise - // if(raise < currentHand->getCurrentBeRo()->getHighestSet()) { - // raise = currentHand->getCurrentBeRo()->getHighestSet(); - // } - // all in bei nur wenigen Chips oder knappem raise - if(myCash/(2*currentHand->getSmallBlind()) <= 6 || raise >= (myCash*4)/5) { - raise = myCash; - } - myAction = 5; - } + // Gegner setzen -> call + if(currentHand->getCurrentBeRo()->getHighestSet() >= 4*currentHand->getSmallBlind()) { + myAction = 3; + } + // Standard-Raise-Routine + else { + // raise-Betrag ermitteln + Tools::getRandNumber(1,8,1,&rand,0); + raise = rand*currentHand->getSmallBlind(); + // raise-Betrag zu klein -> mindestens Standard-raise + // if(raise < currentHand->getCurrentBeRo()->getHighestSet()) { + // raise = currentHand->getCurrentBeRo()->getHighestSet(); + // } + // all in bei nur wenigen Chips oder knappem raise + if(myCash/(2*currentHand->getSmallBlind()) <= 6 || raise >= (myCash*4)/5) { + raise = myCash; + } + myAction = 5; + } - // extrem hoher set der gegner -> bluff beenden - if(currentHand->getCurrentBeRo()->getHighestSet() >= 10*currentHand->getSmallBlind()) { - myAction = 1; - } - } - } - else { - if(sBluffStatus && myOdds < myNiveau[1]) { + // extrem hoher set der gegner -> bluff beenden + if(currentHand->getCurrentBeRo()->getHighestSet() >= 10*currentHand->getSmallBlind()) { + myAction = 1; + } + } + } else { + if(sBluffStatus && myOdds < myNiveau[1]) { - // cout << "sBLUFF!" << endl; + // cout << "sBLUFF!" << endl; - Tools::getRandNumber(1,8,1,&rand,0); - bet = rand*currentHand->getSmallBlind(); - // bet zu klein - if(bet < 2*currentHand->getSmallBlind()) { - bet = 2*currentHand->getSmallBlind(); - } - // all in bei nur wenigen Chips - if(myCash/(2*currentHand->getSmallBlind()) <= 6) { - bet = myCash; - } - // all in bei knappem bet - if(bet > (myCash*4.0)/5.0) { - bet = myCash; - } - myAction = 4; - } + Tools::getRandNumber(1,8,1,&rand,0); + bet = rand*currentHand->getSmallBlind(); + // bet zu klein + if(bet < 2*currentHand->getSmallBlind()) { + bet = 2*currentHand->getSmallBlind(); + } + // all in bei nur wenigen Chips + if(myCash/(2*currentHand->getSmallBlind()) <= 6) { + bet = myCash; + } + // all in bei knappem bet + if(bet > (myCash*4.0)/5.0) { + bet = myCash; + } + myAction = 4; + } - } + } - if(DEBUG_MODE) { + if(DEBUG_MODE) { - switch(myUniqueID) { + switch(myUniqueID) { - case 0: { - } - break; - case 1: { + case 0: { + } + break; + case 1: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_FOLD; - // bet = 20; - // if(currentHand->getCurrentBeRo()->getHighestSet() > 20) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - case 2: { - // myAction = PLAYER_ACTION_BET; - // raise = 25; - } - break; - default: { - } - } - } - break; - case 2: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_FOLD; + // bet = 20; + // if(currentHand->getCurrentBeRo()->getHighestSet() > 20) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + case 2: { + // myAction = PLAYER_ACTION_BET; + // raise = 25; + } + break; + default: { + } + } + } + break; + case 2: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_FOLD; - // raise = 40; - // bet = 40; - // if(currentHand->getCurrentBeRo()->getHighestSet() > 100) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_FOLD; + // raise = 40; + // bet = 40; + // if(currentHand->getCurrentBeRo()->getHighestSet() > 100) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 3: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_FOLD; - // bet = 10; - // if(currentHand->getCurrentBeRo()->getHighestSet() > 500) { - // myAction = PLAYER_ACTION_RAISE; - // raise = 10000; - // } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + } + break; + case 3: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_FOLD; + // bet = 10; + // if(currentHand->getCurrentBeRo()->getHighestSet() > 500) { + // myAction = PLAYER_ACTION_RAISE; + // raise = 10000; + // } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 4: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_FOLD; + } + break; + case 4: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_FOLD; // bet = 120; // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { // myAction = PLAYER_ACTION_CALL; // } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 5: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_BET; - bet = 20; - if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - myAction = PLAYER_ACTION_CALL; - } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + } + break; + case 5: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_BET; + bet = 20; + if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + myAction = PLAYER_ACTION_CALL; + } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 6: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_RAISE; - bet = 20; - if(currentHand->getCurrentBeRo()->getHighestSet() > 20) { - myAction = PLAYER_ACTION_CALL; + } + break; + case 6: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_RAISE; + bet = 20; + if(currentHand->getCurrentBeRo()->getHighestSet() > 20) { + myAction = PLAYER_ACTION_CALL; // raise = 10000; - } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 7: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_CALL; + } + break; + case 7: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CALL; // bet = 20; // if(currentHand->getCurrentBeRo()->getHighestSet() > 20) { // myAction = PLAYER_ACTION_CALL; // raise = 10000; // } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 8: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_FOLD; + } + break; + case 8: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_FOLD; // bet = 20; // if(currentHand->getCurrentBeRo()->getHighestSet() > 20) { // myAction = PLAYER_ACTION_CALL; // raise = 10000; // } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 9: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_RAISE; - bet = 60; - if(currentHand->getCurrentBeRo()->getHighestSet() > 40) { - myAction = PLAYER_ACTION_CALL; + } + break; + case 9: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_RAISE; + bet = 60; + if(currentHand->getCurrentBeRo()->getHighestSet() > 40) { + myAction = PLAYER_ACTION_CALL; // raise = 10000; - } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - default: {} - } + } + break; + default: + {} + } - } + } - // minimum raise setting and resetting - // if(myAction == 5) { - // - // if(raise < currentHand->getCurrentBeRo()->getMinimumRaise()) { - // raise = currentHand->getCurrentBeRo()->getMinimumRaise(); - // } - // currentHand->getCurrentBeRo()->setMinimumRaise(raise); - // - // } - // - // if(myAction == 4) { currentHand->getCurrentBeRo()->setMinimumRaise(bet); } + // minimum raise setting and resetting + // if(myAction == 5) { + // + // if(raise < currentHand->getCurrentBeRo()->getMinimumRaise()) { + // raise = currentHand->getCurrentBeRo()->getMinimumRaise(); + // } + // currentHand->getCurrentBeRo()->setMinimumRaise(raise); + // + // } + // + // if(myAction == 4) { currentHand->getCurrentBeRo()->setMinimumRaise(bet); } - evaluation(bet, raise); + evaluation(bet, raise); } -void LocalPlayer::riverEngine() { +void LocalPlayer::riverEngine() +{ - // int tempArray[6]; - // int boardCards[5]; - // int i; + // int tempArray[6]; + // int boardCards[5]; + // int i; - // for(i=0; i<2; i++) tempArray[i] = myCards[i]; - // currentBoard->getMyCards(boardCards); - // for(i=0; i<4; i++) tempArray[2+i] = boardCards[i]; + // for(i=0; i<2; i++) tempArray[i] = myCards[i]; + // currentBoard->getMyCards(boardCards); + // for(i=0; i<4; i++) tempArray[2+i] = boardCards[i]; - // for(i=0; i<5; i++) cout << tempArray[i] << " "; - // cout << endl; + // for(i=0; i<5; i++) cout << tempArray[i] << " "; + // cout << endl; - // cout << myID << ": "; + // cout << myID << ": "; - // turnCardsValue(tempArray); + // turnCardsValue(tempArray); - int raise = 0; - int bet = 0; - // int i; - int rand; - int pBluff; - PlayerListConstIterator it_c; + int raise = 0; + int bet = 0; + // int i; + int rand; + int pBluff; + PlayerListConstIterator it_c; - calcMyOdds(); + calcMyOdds(); - // Niveaus setzen + Dude + Anzahl Gegenspieler - // 1. Fold -- Call - myNiveau[0] = 53 + myDude4/* - 6*(currentHand->getActivePlayerList().size() - 2)*/; - // 2. Check -- Bet - myNiveau[1] = 56 + myDude4/* - 6*(currentHand->getActivePlayerList().size() - 2)*/; - // 3. Call -- Raise - myNiveau[2] = 69 + myDude4/* - 6*(currentHand->getActivePlayerList().size() - 2)*/; + // Niveaus setzen + Dude + Anzahl Gegenspieler + // 1. Fold -- Call + myNiveau[0] = 53 + myDude4/* - 6*(currentHand->getActivePlayerList().size() - 2)*/; + // 2. Check -- Bet + myNiveau[1] = 56 + myDude4/* - 6*(currentHand->getActivePlayerList().size() - 2)*/; + // 3. Call -- Raise + myNiveau[2] = 69 + myDude4/* - 6*(currentHand->getActivePlayerList().size() - 2)*/; - // count number of active human players - size_t countHumanPlayers = 0; + // count number of active human players + size_t countHumanPlayers = 0; for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); ++it_c) { - if((*it_c)->getMyType() == PLAYER_TYPE_HUMAN) { - countHumanPlayers++; - } - } - if(countHumanPlayers) { - // local or network game and only one human player is active --> set aggValue - if(countHumanPlayers == 1) { + if((*it_c)->getMyType() == PLAYER_TYPE_HUMAN) { + countHumanPlayers++; + } + } + if(countHumanPlayers) { + // local or network game and only one human player is active --> set aggValue + if(countHumanPlayers == 1) { for(it_c=currentHand->getActivePlayerList()->begin(); it_c!=currentHand->getActivePlayerList()->end(); ++it_c) { - if((*it_c)->getMyType() == PLAYER_TYPE_HUMAN && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { - int aggValue = (int)((( (*it_c)->getMyAggressive()*1.0)/7.0 - 1.0/currentHand->getActivePlayerList()->size())*21.0); - myNiveau[0] -= aggValue; - myNiveau[1] -= aggValue; - myNiveau[2] -= aggValue; - } - } - // network game - } else { - myNiveau[0] -= 3; - myNiveau[1] -= 3; - myNiveau[2] -= 3; - } - } + if((*it_c)->getMyType() == PLAYER_TYPE_HUMAN && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { + int aggValue = (int)((( (*it_c)->getMyAggressive()*1.0)/7.0 - 1.0/currentHand->getActivePlayerList()->size())*21.0); + myNiveau[0] -= aggValue; + myNiveau[1] -= aggValue; + myNiveau[2] -= aggValue; + } + } + // network game + } else { + myNiveau[0] -= 3; + myNiveau[1] -= 3; + myNiveau[2] -= 3; + } + } - // Aggresivität des humanPlayers auslesen -> nur wenn er aktiv ist ! - // it_c = currentHand->getActivePlayerIt(0); - // if( it_c != currentHand->getActivePlayerList()->end() ) { - // if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD ) { - // int aggValue = (int)((( (*it_c)->getMyAggressive()*1.0)/7.0 - 1.0/currentHand->getActivePlayerList()->size())*21.0); - // for(i=0; i<3; i++) { - // myNiveau[i] -= aggValue; - // } - // } - // - // } + // Aggresivität des humanPlayers auslesen -> nur wenn er aktiv ist ! + // it_c = currentHand->getActivePlayerIt(0); + // if( it_c != currentHand->getActivePlayerList()->end() ) { + // if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD ) { + // int aggValue = (int)((( (*it_c)->getMyAggressive()*1.0)/7.0 - 1.0/currentHand->getActivePlayerList()->size())*21.0); + // for(i=0; i<3; i++) { + // myNiveau[i] -= aggValue; + // } + // } + // + // } - // cout << "Spieler " << myID << ": Dude " << myDude4 << "\t Wert " << myHoleCardsValue << "\t Niveau " << myNiveau[0] << " " << myNiveau[1] << " " << myNiveau[2] << "\t Agg " << aggValue << " " << endl; + // cout << "Spieler " << myID << ": Dude " << myDude4 << "\t Wert " << myHoleCardsValue << "\t Niveau " << myNiveau[0] << " " << myNiveau[1] << " " << myNiveau[2] << "\t Agg " << aggValue << " " << endl; - // eigenes mögliches highestSet - int individualHighestSet = currentHand->getCurrentBeRo()->getHighestSet(); - if(individualHighestSet > myCash) individualHighestSet = myCash; + // eigenes mögliches highestSet + int individualHighestSet = currentHand->getCurrentBeRo()->getHighestSet(); + if(individualHighestSet > myCash) individualHighestSet = myCash; - // aktiv oder passiv? - if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + // aktiv oder passiv? + if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - // Verhaeltnis Set / Cash - if(myCash/individualHighestSet >= 25) { - myNiveau[0] += (25-myCash/individualHighestSet)/10; - } else { - myNiveau[0] += (25-myCash/individualHighestSet)/2; - } + // Verhaeltnis Set / Cash + if(myCash/individualHighestSet >= 25) { + myNiveau[0] += (25-myCash/individualHighestSet)/10; + } else { + myNiveau[0] += (25-myCash/individualHighestSet)/2; + } - // Verhaeltnis Set / Cash für raise - if(myCash/individualHighestSet < 11) { - myNiveau[2] += (21-myCash/individualHighestSet)/2; - } + // Verhaeltnis Set / Cash für raise + if(myCash/individualHighestSet < 11) { + myNiveau[2] += (21-myCash/individualHighestSet)/2; + } - // raise (bei hohem Niveau) - if(myOdds >= myNiveau[2]) { - // raise-loop unterbinden -> d.h. entweder call oder bei superblatt all in - if(currentHand->getCurrentBeRo()->getHighestSet() >= 12*currentHand->getSmallBlind()) { - // all in - if(myOdds >= myNiveau[2] + 15) { - raise = myCash; - myAction = 5; - } - // nur call - else { - // all in bei knappem call - if(myCash-currentHand->getCurrentBeRo()->getHighestSet() <= (myCash*1)/5) { - raise = myCash; - myAction = 5; - } else { - myAction = 3; - } - } - } - // Standard-Raise-Routine - else { - // raise-Betrag ermitteln - raise = (((int)myOdds-myNiveau[2])/2)*2*currentHand->getSmallBlind(); - // raise-Betrag zu klein -> mindestens Standard-raise - // if(raise < currentHand->getCurrentBeRo()->getHighestSet()) { - // raise = currentHand->getCurrentBeRo()->getHighestSet(); - // } - // all in bei nur wenigen Chips - if(myCash/(2*currentHand->getSmallBlind()) <= 8) { - raise = myCash; - } - myAction = 5; - } - } - else { - // call -> über niveau0, schon einiges gesetzt im flop, schon einiges insgesamt gesetzt - if(myOdds >= myNiveau[0] || (mySet >= currentHand->getCurrentBeRo()->getHighestSet()/2 && myOdds >= myNiveau[0]-5) || (myRoundStartCash-myCash > individualHighestSet && myNiveau[0]-3)) { - // all in bei knappem call - if(myCash-currentHand->getCurrentBeRo()->getHighestSet() <= (myCash*1)/4) { - raise = myCash; - myAction = 5; - } - else myAction = 3; - } - // fold - else { - myAction = 1; - } - } - } - else { - // bet - if(myOdds >= myNiveau[1]) { - bet = (((int)myOdds-myNiveau[1])/3)*2*currentHand->getSmallBlind(); - if(bet == 0) { - bet = 2*currentHand->getSmallBlind(); - } - // all in bei nur wenigen Chips - if(myCash/(2*currentHand->getSmallBlind()) <= 6) { - raise = myCash; - } - // all in bei knappem bet - if(bet > (myCash*4.0)/5.0) { - bet = myCash; - } - myAction = 4; - } - // check - else { - myAction = 2; - // Position - if(myButton == 1) { - // Position-Bluff generieren - Tools::getRandNumber(1,100,1,&pBluff,0); - if(pBluff <= 20) { - bet = (pBluff/4)*2*currentHand->getSmallBlind(); - // bet zu klein - if(bet == 0) { - bet = 2*currentHand->getSmallBlind(); - } - // all in bei nur wenigen Chips - if(myCash/(2*currentHand->getSmallBlind()) <= 6) { - bet = myCash; - } - // all in bei knappem bet - if(bet > (myCash*4.0)/5.0) { - bet = myCash; - } - myAction = 4; - } - } - } + // raise (bei hohem Niveau) + if(myOdds >= myNiveau[2]) { + // raise-loop unterbinden -> d.h. entweder call oder bei superblatt all in + if(currentHand->getCurrentBeRo()->getHighestSet() >= 12*currentHand->getSmallBlind()) { + // all in + if(myOdds >= myNiveau[2] + 15) { + raise = myCash; + myAction = 5; + } + // nur call + else { + // all in bei knappem call + if(myCash-currentHand->getCurrentBeRo()->getHighestSet() <= (myCash*1)/5) { + raise = myCash; + myAction = 5; + } else { + myAction = 3; + } + } + } + // Standard-Raise-Routine + else { + // raise-Betrag ermitteln + raise = (((int)myOdds-myNiveau[2])/2)*2*currentHand->getSmallBlind(); + // raise-Betrag zu klein -> mindestens Standard-raise + // if(raise < currentHand->getCurrentBeRo()->getHighestSet()) { + // raise = currentHand->getCurrentBeRo()->getHighestSet(); + // } + // all in bei nur wenigen Chips + if(myCash/(2*currentHand->getSmallBlind()) <= 8) { + raise = myCash; + } + myAction = 5; + } + } else { + // call -> über niveau0, schon einiges gesetzt im flop, schon einiges insgesamt gesetzt + if(myOdds >= myNiveau[0] || (mySet >= currentHand->getCurrentBeRo()->getHighestSet()/2 && myOdds >= myNiveau[0]-5) || (myRoundStartCash-myCash > individualHighestSet && myNiveau[0]-3)) { + // all in bei knappem call + if(myCash-currentHand->getCurrentBeRo()->getHighestSet() <= (myCash*1)/4) { + raise = myCash; + myAction = 5; + } else myAction = 3; + } + // fold + else { + myAction = 1; + } + } + } else { + // bet + if(myOdds >= myNiveau[1]) { + bet = (((int)myOdds-myNiveau[1])/3)*2*currentHand->getSmallBlind(); + if(bet == 0) { + bet = 2*currentHand->getSmallBlind(); + } + // all in bei nur wenigen Chips + if(myCash/(2*currentHand->getSmallBlind()) <= 6) { + raise = myCash; + } + // all in bei knappem bet + if(bet > (myCash*4.0)/5.0) { + bet = myCash; + } + myAction = 4; + } + // check + else { + myAction = 2; + // Position + if(myButton == 1) { + // Position-Bluff generieren + Tools::getRandNumber(1,100,1,&pBluff,0); + if(pBluff <= 20) { + bet = (pBluff/4)*2*currentHand->getSmallBlind(); + // bet zu klein + if(bet == 0) { + bet = 2*currentHand->getSmallBlind(); + } + // all in bei nur wenigen Chips + if(myCash/(2*currentHand->getSmallBlind()) <= 6) { + bet = myCash; + } + // all in bei knappem bet + if(bet > (myCash*4.0)/5.0) { + bet = myCash; + } + myAction = 4; + } + } + } // // lastPlayerAction für Karten umblättern reihenfolge setzrn // currentHand->getCurrentBeRo()->setLastActionPlayer(myUniqueID); - } + } - // auf sBluffStatus testen --> raise statt call und bet statt check + // auf sBluffStatus testen --> raise statt call und bet statt check - // aktiv oder passiv? - if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + // aktiv oder passiv? + if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - if(sBluffStatus && myOdds < myNiveau[2]) { + if(sBluffStatus && myOdds < myNiveau[2]) { - // cout << "sBLUFF!" << endl; + // cout << "sBLUFF!" << endl; - // Gegner setzen -> call - if(currentHand->getCurrentBeRo()->getHighestSet() >= 4*currentHand->getSmallBlind()) { - myAction = 3; - } - // Standard-Raise-Routine - else { - // raise-Betrag ermitteln - Tools::getRandNumber(1,8,1,&rand,0); - raise = rand*currentHand->getSmallBlind(); - // raise-Betrag zu klein -> mindestens Standard-raise - // if(raise < currentHand->getCurrentBeRo()->getHighestSet()) { - // raise = currentHand->getCurrentBeRo()->getHighestSet(); - // } - // all in bei nur wenigen Chips oder knappem raise - if(myCash/(2*currentHand->getSmallBlind()) <= 6 || raise >= (myCash*4)/5) { - raise = myCash; - } - myAction = 5; - } + // Gegner setzen -> call + if(currentHand->getCurrentBeRo()->getHighestSet() >= 4*currentHand->getSmallBlind()) { + myAction = 3; + } + // Standard-Raise-Routine + else { + // raise-Betrag ermitteln + Tools::getRandNumber(1,8,1,&rand,0); + raise = rand*currentHand->getSmallBlind(); + // raise-Betrag zu klein -> mindestens Standard-raise + // if(raise < currentHand->getCurrentBeRo()->getHighestSet()) { + // raise = currentHand->getCurrentBeRo()->getHighestSet(); + // } + // all in bei nur wenigen Chips oder knappem raise + if(myCash/(2*currentHand->getSmallBlind()) <= 6 || raise >= (myCash*4)/5) { + raise = myCash; + } + myAction = 5; + } - // extrem hoher set der gegner -> bluff beenden - if(currentHand->getCurrentBeRo()->getHighestSet() >= 10*currentHand->getSmallBlind()) { - myAction = 1; - } - } - } - else { - if(sBluffStatus && myOdds < myNiveau[1]) { + // extrem hoher set der gegner -> bluff beenden + if(currentHand->getCurrentBeRo()->getHighestSet() >= 10*currentHand->getSmallBlind()) { + myAction = 1; + } + } + } else { + if(sBluffStatus && myOdds < myNiveau[1]) { - // cout << "sBLUFF!" << endl; + // cout << "sBLUFF!" << endl; - Tools::getRandNumber(1,8,1,&rand,0); - bet = rand*currentHand->getSmallBlind(); - // bet zu klein - if(bet < 2*currentHand->getSmallBlind()) { - bet = 2*currentHand->getSmallBlind(); - } - // all in bei nur wenigen Chips - if(myCash/(2*currentHand->getSmallBlind()) <= 6) { - bet = myCash; - } - // all in bei knappem bet - if(bet > (myCash*4.0)/5.0) { - bet = myCash; - } - myAction = 4; - } + Tools::getRandNumber(1,8,1,&rand,0); + bet = rand*currentHand->getSmallBlind(); + // bet zu klein + if(bet < 2*currentHand->getSmallBlind()) { + bet = 2*currentHand->getSmallBlind(); + } + // all in bei nur wenigen Chips + if(myCash/(2*currentHand->getSmallBlind()) <= 6) { + bet = myCash; + } + // all in bei knappem bet + if(bet > (myCash*4.0)/5.0) { + bet = myCash; + } + myAction = 4; + } - } + } - if(DEBUG_MODE) { - switch(myUniqueID) { - case 0: { - } break; - case 1: { + if(DEBUG_MODE) { + switch(myUniqueID) { + case 0: { + } break; + case 1: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_CALL; - // raise = 40; - // if(currentHand->getCurrentBeRo()->getHighestSet() > 60) { - // myAction = PLAYER_ACTION_CALL; - // } - } break; - case 2: { - // myAction = PLAYER_ACTION_BET; - // raise = 25; - } break; - default: { - } - } - } break; - case 2: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CALL; + // raise = 40; + // if(currentHand->getCurrentBeRo()->getHighestSet() > 60) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + case 2: { + // myAction = PLAYER_ACTION_BET; + // raise = 25; + } break; + default: { + } + } + } break; + case 2: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_BET; - bet = 100; - // raise = 40; - if(currentHand->getCurrentBeRo()->getHighestSet() > 100) { - myAction = PLAYER_ACTION_CALL; - } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_BET; + bet = 100; + // raise = 40; + if(currentHand->getCurrentBeRo()->getHighestSet() > 100) { + myAction = PLAYER_ACTION_CALL; + } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 3: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_CALL; - // bet = 120; - // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - // myAction = PLAYER_ACTION_RAISE; - // raise = 10000; - // } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + } + break; + case 3: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CALL; + // bet = 120; + // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + // myAction = PLAYER_ACTION_RAISE; + // raise = 10000; + // } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 4: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_BET; - // raise = 300; - bet = 220; - if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - myAction = PLAYER_ACTION_CALL; - // raise = 10000; - } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + } + break; + case 4: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_BET; + // raise = 300; + bet = 220; + if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + myAction = PLAYER_ACTION_CALL; + // raise = 10000; + } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 5: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_CHECK; - // bet = 120; - if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - myAction = PLAYER_ACTION_FOLD; + } + break; + case 5: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CHECK; + // bet = 120; + if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + myAction = PLAYER_ACTION_FOLD; // raise = 10000; - } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 6: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_BET; - bet = 40; - if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - myAction = PLAYER_ACTION_CALL; + } + break; + case 6: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_BET; + bet = 40; + if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + myAction = PLAYER_ACTION_CALL; // raise = 10000; - } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 7: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_CALL; + } + break; + case 7: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_CALL; // bet = 40; // if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { // myAction = PLAYER_ACTION_CALL; // raise = 10000; // } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 8: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_BET; - bet = 40; - if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { - myAction = PLAYER_ACTION_CALL; + } + break; + case 8: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_BET; + bet = 40; + if(currentHand->getCurrentBeRo()->getHighestSet() > 0) { + myAction = PLAYER_ACTION_CALL; // raise = 10000; - } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - case 9: { - switch(currentHand->getMyID()) { - case 1: { - myAction = PLAYER_ACTION_RAISE; - bet = 180; - if(currentHand->getCurrentBeRo()->getHighestSet() > 40) { - myAction = PLAYER_ACTION_RAISE; - raise = 10000; - } - } - break; - case 2: { - // myAction = PLAYER_ACTION_RAISE; - // raise = 50; - // if(mySet >= 70) { - // myAction = PLAYER_ACTION_CALL; - // } - } - break; - default: { - } - } + } + break; + case 9: { + switch(currentHand->getMyID()) { + case 1: { + myAction = PLAYER_ACTION_RAISE; + bet = 180; + if(currentHand->getCurrentBeRo()->getHighestSet() > 40) { + myAction = PLAYER_ACTION_RAISE; + raise = 10000; + } + } + break; + case 2: { + // myAction = PLAYER_ACTION_RAISE; + // raise = 50; + // if(mySet >= 70) { + // myAction = PLAYER_ACTION_CALL; + // } + } + break; + default: { + } + } - } - break; - default: {} - } + } + break; + default: + {} + } - } + } - evaluation(bet, raise); + evaluation(bet, raise); @@ -3193,972 +3213,971 @@ void LocalPlayer::riverEngine() { } -void LocalPlayer::evaluation(int bet, int raise) { +void LocalPlayer::evaluation(int bet, int raise) +{ - int highestSet = 0; + int highestSet = 0; - highestSet = currentHand->getCurrentBeRo()->getHighestSet(); + highestSet = currentHand->getCurrentBeRo()->getHighestSet(); - // cout << "myAction(evaluation): " << myAction << endl; - switch(myAction) { - // none - case 0: {} - break; - // fold - case 1: {} - break; - // check - case 2: {} - break; - // call - case 3: { - // cout << "evaluation(call) - highestSet = " << highestSet << endl; - // all in - if(highestSet >= myCash + mySet) { - mySet += myCash; - myCash = 0; - myAction = 6; - // cout << "evaluation(call) - mySet: " << mySet << endl; - } - // sonst - else { - myCash = myCash - highestSet + mySet; - mySet = highestSet; - } - } - break; - // bet - case 4: { - // all in - if(bet >= myCash) { - // -> full bet rule - if(myCash < 2*currentHand->getSmallBlind()) { - currentHand->getCurrentBeRo()->setFullBetRule(true); - } - currentHand->getCurrentBeRo()->setMinimumRaise(myCash); - mySet = myCash; - myCash = 0; - myAction = 6; - highestSet = mySet; - } - // sonst - else { - currentHand->getCurrentBeRo()->setMinimumRaise(bet); - myCash = myCash - bet; - mySet = bet; - highestSet = mySet; + // cout << "myAction(evaluation): " << myAction << endl; + switch(myAction) { + // none + case 0: + {} + break; + // fold + case 1: + {} + break; + // check + case 2: + {} + break; + // call + case 3: { + // cout << "evaluation(call) - highestSet = " << highestSet << endl; + // all in + if(highestSet >= myCash + mySet) { + mySet += myCash; + myCash = 0; + myAction = 6; + // cout << "evaluation(call) - mySet: " << mySet << endl; + } + // sonst + else { + myCash = myCash - highestSet + mySet; + mySet = highestSet; + } + } + break; + // bet + case 4: { + // all in + if(bet >= myCash) { + // -> full bet rule + if(myCash < 2*currentHand->getSmallBlind()) { + currentHand->getCurrentBeRo()->setFullBetRule(true); + } + currentHand->getCurrentBeRo()->setMinimumRaise(myCash); + mySet = myCash; + myCash = 0; + myAction = 6; + highestSet = mySet; + } + // sonst + else { + currentHand->getCurrentBeRo()->setMinimumRaise(bet); + myCash = myCash - bet; + mySet = bet; + highestSet = mySet; - } - // lastPlayerAction für Karten umblättern reihenfolge setzrn - currentHand->setLastActionPlayer(myUniqueID); - } - break; - // raise - case 5: { - if(currentHand->getCurrentBeRo()->getFullBetRule()) { // full bet rule -> only call possible - // all in - if(highestSet >= myCash + mySet) { - mySet += myCash; - myCash = 0; - myAction = 6; - } - // sonst - else { - myCash = myCash - highestSet + mySet; - mySet = highestSet; - myAction = 3; - } - } - else { - if(raise < currentHand->getCurrentBeRo()->getMinimumRaise()) { - raise = currentHand->getCurrentBeRo()->getMinimumRaise(); - } - // all in - if(highestSet + raise >= myCash + mySet) { - if(highestSet + currentHand->getCurrentBeRo()->getMinimumRaise() > myCash + mySet) { - // perhaps full bet rule - if(highestSet >= myCash + mySet) { - // only call all-in - mySet += myCash; - myCash = 0; - myAction = 6; - } else { - // raise, but not enough --> full bet rule - currentHand->getCurrentBeRo()->setFullBetRule(true); - // lastPlayerAction für Karten umblättern reihenfolge setzrn - currentHand->setLastActionPlayer(myUniqueID); + } + // lastPlayerAction für Karten umblättern reihenfolge setzrn + currentHand->setLastActionPlayer(myUniqueID); + } + break; + // raise + case 5: { + if(currentHand->getCurrentBeRo()->getFullBetRule()) { // full bet rule -> only call possible + // all in + if(highestSet >= myCash + mySet) { + mySet += myCash; + myCash = 0; + myAction = 6; + } + // sonst + else { + myCash = myCash - highestSet + mySet; + mySet = highestSet; + myAction = 3; + } + } else { + if(raise < currentHand->getCurrentBeRo()->getMinimumRaise()) { + raise = currentHand->getCurrentBeRo()->getMinimumRaise(); + } + // all in + if(highestSet + raise >= myCash + mySet) { + if(highestSet + currentHand->getCurrentBeRo()->getMinimumRaise() > myCash + mySet) { + // perhaps full bet rule + if(highestSet >= myCash + mySet) { + // only call all-in + mySet += myCash; + myCash = 0; + myAction = 6; + } else { + // raise, but not enough --> full bet rule + currentHand->getCurrentBeRo()->setFullBetRule(true); + // lastPlayerAction für Karten umblättern reihenfolge setzrn + currentHand->setLastActionPlayer(myUniqueID); - mySet += myCash; - currentHand->getCurrentBeRo()->setMinimumRaise(mySet-highestSet); - myCash = 0; - myAction = 6; - highestSet = mySet; - } - } else { - // lastPlayerAction für Karten umblättern reihenfolge setzrn - currentHand->setLastActionPlayer(myUniqueID); + mySet += myCash; + currentHand->getCurrentBeRo()->setMinimumRaise(mySet-highestSet); + myCash = 0; + myAction = 6; + highestSet = mySet; + } + } else { + // lastPlayerAction für Karten umblättern reihenfolge setzrn + currentHand->setLastActionPlayer(myUniqueID); - mySet += myCash; - currentHand->getCurrentBeRo()->setMinimumRaise(mySet-highestSet); - myCash = 0; - myAction = 6; - highestSet = mySet; - } - } - // sonst - else { - currentHand->getCurrentBeRo()->setMinimumRaise(raise); - myCash = myCash + mySet - highestSet - raise; - mySet = highestSet + raise; - highestSet = mySet; - // lastPlayerAction für Karten umblättern reihenfolge setzrn - currentHand->setLastActionPlayer(myUniqueID); - } - } - } - break; - // all in - case 6: {} - break; - default: {} - } + mySet += myCash; + currentHand->getCurrentBeRo()->setMinimumRaise(mySet-highestSet); + myCash = 0; + myAction = 6; + highestSet = mySet; + } + } + // sonst + else { + currentHand->getCurrentBeRo()->setMinimumRaise(raise); + myCash = myCash + mySet - highestSet - raise; + mySet = highestSet + raise; + highestSet = mySet; + // lastPlayerAction für Karten umblättern reihenfolge setzrn + currentHand->setLastActionPlayer(myUniqueID); + } + } + } + break; + // all in + case 6: + {} + break; + default: + {} + } - // cout << "highestSet(ende evaluation): " << highestSet << endl; + // cout << "highestSet(ende evaluation): " << highestSet << endl; - currentHand->getCurrentBeRo()->setHighestSet(highestSet); + currentHand->getCurrentBeRo()->setHighestSet(highestSet); // cout << "lAP: " << currentHand->getLastActionPlayer() << endl; } -int LocalPlayer::flopCardsValue(int* cards) { +int LocalPlayer::flopCardsValue(int* cards) +{ - int array[5][3]; - int j1, j2, j3, j4, j5, k1, k2, ktemp[3]; - int temp = 0; - int temp1 = 0; - int temp2 = 0; - int temp2Array[2]; - int tempValue = -1; - bool breakLoop = 0; + int array[5][3]; + int j1, j2, j3, j4, j5, k1, k2, ktemp[3]; + int temp = 0; + int temp1 = 0; + int temp2 = 0; + int temp2Array[2]; + int tempValue = -1; + bool breakLoop = 0; - // Kartenwerte umwandeln (z.B. [ 11 (Karo K�ig) -> 0 11 ] oder [ 31 (Pik 7) -> 2 5 ] ) - for(j1=0; j1<5; j1++) { - array[j1][0] = cards[j1]/13; - array[j1][1] = cards[j1]%13; - array[j1][2] = j1; - } + // Kartenwerte umwandeln (z.B. [ 11 (Karo K�ig) -> 0 11 ] oder [ 31 (Pik 7) -> 2 5 ] ) + for(j1=0; j1<5; j1++) { + array[j1][0] = cards[j1]/13; + array[j1][1] = cards[j1]%13; + array[j1][2] = j1; + } - // Karten nach Farben sortieren: Kreuz - Pik - Herz - Karo - for(k1=0; k1<5; k1++) { - for(k2=k1+1; k2<5; k2++) { - if(array[k1][0] array[j1+j2][1]) temp1++; - if(temp2Array[0] > array[j1+j2][1]) temp2++; - } - return (60000 + temp1*1000 + temp2*100 + array[j1][1]); - } - // Anteil 1 - else { + // Anteil 2 + if(temp==2) { + for(j2=0; j2<4; j2++) { + if(temp2Array[1] > array[j1+j2][1]) temp1++; + if(temp2Array[0] > array[j1+j2][1]) temp2++; + } + return (60000 + temp1*1000 + temp2*100 + array[j1][1]); + } + // Anteil 1 + else { - // 2.Stelle - for(j2=0; j2<4; j2++) { - if(j1==0) { - if(array[4][1] < array[j1+j2][1]) temp1++; - } else { - if(array[0][1] < array[j1+j2][1]) temp1++; - } - } - if(temp1 >= 2) temp1 = 1; - if(temp1 == 4) temp1 = 2; + // 2.Stelle + for(j2=0; j2<4; j2++) { + if(j1==0) { + if(array[4][1] < array[j1+j2][1]) temp1++; + } else { + if(array[0][1] < array[j1+j2][1]) temp1++; + } + } + if(temp1 >= 2) temp1 = 1; + if(temp1 == 4) temp1 = 2; - // 3.Stelle - for(j2=0; j2<4; j2++) { - if(temp2Array[0] < array[j1+j2][1]) temp2++; - } - tempValue = (50000 + temp1*1000 + temp2*100 + temp2Array[0]); - breakLoop = 1; - } - } - } - } - } - } + // 3.Stelle + for(j2=0; j2<4; j2++) { + if(temp2Array[0] < array[j1+j2][1]) temp2++; + } + tempValue = (50000 + temp1*1000 + temp2*100 + temp2Array[0]); + breakLoop = 1; + } + } + } + } + } + } - // Karten fr den Vierling-, Full-House-, Drilling- und Paartest umsortieren - for(k1=0; k1<5; k1++) { - for(k2=k1+1; k2<5; k2++) { - if(array[k1][1] array[j1][1]) { - temp1++; - } - if(temp2Array[0] > array[j2][1]) { - temp1++; - } - if(temp2Array[0] > array[j3][1]) { - temp1++; - } - if(temp2Array[0] > array[j4][1]) { - temp1++; - } + // Anteil 2 + if(temp==2) { + if(temp2Array[0] > array[j1][1]) { + temp1++; + } + if(temp2Array[0] > array[j2][1]) { + temp1++; + } + if(temp2Array[0] > array[j3][1]) { + temp1++; + } + if(temp2Array[0] > array[j4][1]) { + temp1++; + } - if(temp1 >= 3) temp1 = 2; + if(temp1 >= 3) temp1 = 2; - tempValue = (40012 + temp1*2000); - } - // Anteil 1 - else { + tempValue = (40012 + temp1*2000); + } + // Anteil 1 + else { - // 2.Stelle - if(temp2Array[0] > array[j1][1]) { - temp1++; - } - if(temp2Array[0] > array[j2][1]) { - temp1++; - } - if(temp2Array[0] > array[j3][1]) { - temp1++; - } - if(temp2Array[0] > array[j4][1]) { - temp1++; - } + // 2.Stelle + if(temp2Array[0] > array[j1][1]) { + temp1++; + } + if(temp2Array[0] > array[j2][1]) { + temp1++; + } + if(temp2Array[0] > array[j3][1]) { + temp1++; + } + if(temp2Array[0] > array[j4][1]) { + temp1++; + } - if(temp1 >= 1) temp1 = 2; + if(temp1 >= 1) temp1 = 2; - tempValue = (40012 + (temp1+1)*1000); - } - breakLoop = 1; - } - // Strassenansatz in der Mitte - else { - // cout << "zusammenhaengender Straight-Draw in der Mitte"; + tempValue = (40012 + (temp1+1)*1000); + } + breakLoop = 1; + } + // Strassenansatz in der Mitte + else { + // cout << "zusammenhaengender Straight-Draw in der Mitte"; - // Anteil ermitteln - if(array[j1][2] <= 1) { - temp2Array[temp] = array[j1][1]; - temp++; - } - if(array[j2][2] <= 1) { - temp2Array[temp] = array[j2][1]; - temp++; - } - if(array[j3][2] <= 1) { - temp2Array[temp] = array[j3][1]; - temp++; - } - if(array[j4][2] <= 1) { - temp2Array[temp] = array[j4][1]; - temp++; - } + // Anteil ermitteln + if(array[j1][2] <= 1) { + temp2Array[temp] = array[j1][1]; + temp++; + } + if(array[j2][2] <= 1) { + temp2Array[temp] = array[j2][1]; + temp++; + } + if(array[j3][2] <= 1) { + temp2Array[temp] = array[j3][1]; + temp++; + } + if(array[j4][2] <= 1) { + temp2Array[temp] = array[j4][1]; + temp++; + } - // Anteil 2 - if(temp==2) { - if(temp2Array[0] > array[j1][1]) { - temp1++; - } - if(temp2Array[0] > array[j2][1]) { - temp1++; - } - if(temp2Array[0] > array[j3][1]) { - temp1++; - } - if(temp2Array[0] > array[j4][1]) { - temp1++; - } + // Anteil 2 + if(temp==2) { + if(temp2Array[0] > array[j1][1]) { + temp1++; + } + if(temp2Array[0] > array[j2][1]) { + temp1++; + } + if(temp2Array[0] > array[j3][1]) { + temp1++; + } + if(temp2Array[0] > array[j4][1]) { + temp1++; + } - if(temp1 >= 3) temp1 = 2; + if(temp1 >= 3) temp1 = 2; - tempValue = (40000 + (temp1+2)*2000 + array[j1][1]); - } - // Anteil 1 - else { + tempValue = (40000 + (temp1+2)*2000 + array[j1][1]); + } + // Anteil 1 + else { - // 2.Stelle - if(temp2Array[0] > array[j1][1]) { - temp1++; - } - if(temp2Array[0] > array[j2][1]) { - temp1++; - } - if(temp2Array[0] > array[j3][1]) { - temp1++; - } - if(temp2Array[0] > array[j4][1]) { - temp1++; - } + // 2.Stelle + if(temp2Array[0] > array[j1][1]) { + temp1++; + } + if(temp2Array[0] > array[j2][1]) { + temp1++; + } + if(temp2Array[0] > array[j3][1]) { + temp1++; + } + if(temp2Array[0] > array[j4][1]) { + temp1++; + } - if(temp1 >= 1) temp1 = 2; + if(temp1 >= 1) temp1 = 2; - // 3.Stelle - for(j5=0; j5<5; j5++) { - if(j5 != j1 && j5 != j2 && j5 != j3 && j5 != j4) { - if(array[j5][1] < array[j4][1]) { - temp2 = 0; - } - else { - temp2 = 1; - } - } - } + // 3.Stelle + for(j5=0; j5<5; j5++) { + if(j5 != j1 && j5 != j2 && j5 != j3 && j5 != j4) { + if(array[j5][1] < array[j4][1]) { + temp2 = 0; + } else { + temp2 = 1; + } + } + } - tempValue = (40000 + (temp1+5)*1000 + temp2*100 + array[j1][1]); - } - breakLoop = 1; - } - } - else { - // Bauchschuss ? - if((array[j1][1]-2 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-1 == array[j2][1] && array[j2][1]-2 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-1 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-2 == array[j4][1])) { - // cout << "Straight-Draw Bauchschuss"; + tempValue = (40000 + (temp1+5)*1000 + temp2*100 + array[j1][1]); + } + breakLoop = 1; + } + } else { + // Bauchschuss ? + if((array[j1][1]-2 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-1 == array[j2][1] && array[j2][1]-2 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-1 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-2 == array[j4][1])) { + // cout << "Straight-Draw Bauchschuss"; - // Anteil ermitteln - if(array[j1][2] <= 1) { - temp2Array[temp] = array[j1][1]; - temp++; - } - if(array[j2][2] <= 1) { - temp2Array[temp] = array[j2][1]; - temp++; - } - if(array[j3][2] <= 1) { - temp2Array[temp] = array[j3][1]; - temp++; - } - if(array[j4][2] <= 1) { - temp2Array[temp] = array[j4][1]; - temp++; - } + // Anteil ermitteln + if(array[j1][2] <= 1) { + temp2Array[temp] = array[j1][1]; + temp++; + } + if(array[j2][2] <= 1) { + temp2Array[temp] = array[j2][1]; + temp++; + } + if(array[j3][2] <= 1) { + temp2Array[temp] = array[j3][1]; + temp++; + } + if(array[j4][2] <= 1) { + temp2Array[temp] = array[j4][1]; + temp++; + } - // Anteil 2 - if(temp==2) { - if(temp2Array[0] > array[j1][1]) { - temp1++; - } - if(temp2Array[0] > array[j2][1]) { - temp1++; - } - if(temp2Array[0] > array[j3][1]) { - temp1++; - } - if(temp2Array[0] > array[j4][1]) { - temp1++; - } + // Anteil 2 + if(temp==2) { + if(temp2Array[0] > array[j1][1]) { + temp1++; + } + if(temp2Array[0] > array[j2][1]) { + temp1++; + } + if(temp2Array[0] > array[j3][1]) { + temp1++; + } + if(temp2Array[0] > array[j4][1]) { + temp1++; + } - if(temp1 >= 3) temp1 = 2; + if(temp1 >= 3) temp1 = 2; - tempValue = (40000 + temp1*2000 + array[j1][1]); - } - // Anteil 1 - else { + tempValue = (40000 + temp1*2000 + array[j1][1]); + } + // Anteil 1 + else { - // 2.Stelle - if(temp2Array[0] > array[j1][1]) { - temp1++; - } - if(temp2Array[0] > array[j2][1]) { - temp1++; - } - if(temp2Array[0] > array[j3][1]) { - temp1++; - } - if(temp2Array[0] > array[j4][1]) { - temp1++; - } + // 2.Stelle + if(temp2Array[0] > array[j1][1]) { + temp1++; + } + if(temp2Array[0] > array[j2][1]) { + temp1++; + } + if(temp2Array[0] > array[j3][1]) { + temp1++; + } + if(temp2Array[0] > array[j4][1]) { + temp1++; + } - if(temp1 >= 1) temp1 = 2; + if(temp1 >= 1) temp1 = 2; - // 3.Stelle - for(j5=0; j5<5; j5++) { - if(j5 != j1 && j5 != j2 && j5 != j3 && j5 != j4) { - if(array[j5][1] < array[j4][1]) { - temp2 = 0; - } - else { - temp2 = 1; - } - } - } + // 3.Stelle + for(j5=0; j5<5; j5++) { + if(j5 != j1 && j5 != j2 && j5 != j3 && j5 != j4) { + if(array[j5][1] < array[j4][1]) { + temp2 = 0; + } else { + temp2 = 1; + } + } + } - tempValue = (40000 + (temp1+1)*1000 + temp2*100 + array[j1][1]); - } - breakLoop = 1; - } - else { - // Test auf Straßenansatz-Ausnahme 5-4-3-2-A - if(array[j1][1] == 12 && ((array[j1][1]-9 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-9 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-2 == array[j4][1]) || (array[j1][1]-9 == array[j2][1] && array[j2][1]-2 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-10 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]))) { - // cout << "Straight-Draw Ass unten"; + tempValue = (40000 + (temp1+1)*1000 + temp2*100 + array[j1][1]); + } + breakLoop = 1; + } else { + // Test auf Straßenansatz-Ausnahme 5-4-3-2-A + if(array[j1][1] == 12 && ((array[j1][1]-9 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-9 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-2 == array[j4][1]) || (array[j1][1]-9 == array[j2][1] && array[j2][1]-2 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-10 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]))) { + // cout << "Straight-Draw Ass unten"; - // Anteil ermitteln - if(array[j1][2] <= 1) { - temp2Array[temp] = array[j1][1]; - temp++; - } - if(array[j2][2] <= 1) { - temp2Array[temp] = array[j2][1]; - temp++; - } - if(array[j3][2] <= 1) { - temp2Array[temp] = array[j3][1]; - temp++; - } - if(array[j4][2] <= 1) { - temp2Array[temp] = array[j4][1]; - temp++; - } + // Anteil ermitteln + if(array[j1][2] <= 1) { + temp2Array[temp] = array[j1][1]; + temp++; + } + if(array[j2][2] <= 1) { + temp2Array[temp] = array[j2][1]; + temp++; + } + if(array[j3][2] <= 1) { + temp2Array[temp] = array[j3][1]; + temp++; + } + if(array[j4][2] <= 1) { + temp2Array[temp] = array[j4][1]; + temp++; + } - // Anteil 2 - if(temp==2) { - if(temp2Array[0] > array[j1][1]) { - temp1++; - } - if(temp2Array[0] > array[j2][1]) { - temp1++; - } - if(temp2Array[0] > array[j3][1]) { - temp1++; - } - if(temp2Array[0] > array[j4][1]) { - temp1++; - } + // Anteil 2 + if(temp==2) { + if(temp2Array[0] > array[j1][1]) { + temp1++; + } + if(temp2Array[0] > array[j2][1]) { + temp1++; + } + if(temp2Array[0] > array[j3][1]) { + temp1++; + } + if(temp2Array[0] > array[j4][1]) { + temp1++; + } - if(temp1 >= 3) temp1 = 2; + if(temp1 >= 3) temp1 = 2; - tempValue = (40012 + temp1*2000); - } - // Anteil 1 - else { + tempValue = (40012 + temp1*2000); + } + // Anteil 1 + else { - // 2.Stelle - if(temp2Array[0] > array[j1][1]) { - temp1++; - } - if(temp2Array[0] > array[j2][1]) { - temp1++; - } - if(temp2Array[0] > array[j3][1]) { - temp1++; - } - if(temp2Array[0] > array[j4][1]) { - temp1++; - } + // 2.Stelle + if(temp2Array[0] > array[j1][1]) { + temp1++; + } + if(temp2Array[0] > array[j2][1]) { + temp1++; + } + if(temp2Array[0] > array[j3][1]) { + temp1++; + } + if(temp2Array[0] > array[j4][1]) { + temp1++; + } - if(temp1 >= 1) temp1 = 2; + if(temp1 >= 1) temp1 = 2; - tempValue = (40004 + (temp1+1)*1000 + 100); - } + tempValue = (40004 + (temp1+1)*1000 + 100); + } - breakLoop = 1; - } - } - } - } - } - } - } + breakLoop = 1; + } + } + } + } + } + } + } - // auf Drilling testen - for(j1=0; j1<3; j1++) { - if(array[j1][1] == array[j1+1][1] && array[j1][1] == array[j1+2][1]) { - // cout << "Drilling"; - for(j2=0; j2<3; j2++) { - if(array[j1+j2][2] <= 1) temp++; - } - if(temp >=1) { - return 80000; - } else { - if(j1==0) { - return (30000 + array[j1+3][1]); - } else { - return (30100 + array[0][1]); - } - } - } - } + // auf Drilling testen + for(j1=0; j1<3; j1++) { + if(array[j1][1] == array[j1+1][1] && array[j1][1] == array[j1+2][1]) { + // cout << "Drilling"; + for(j2=0; j2<3; j2++) { + if(array[j1+j2][2] <= 1) temp++; + } + if(temp >=1) { + return 80000; + } else { + if(j1==0) { + return (30000 + array[j1+3][1]); + } else { + return (30100 + array[0][1]); + } + } + } + } - // auf Zwei Paare testen - for(j1=0; j1<2; j1++) { - for(j2=j1+2; j2<4; j2++) { - if(array[j1][1] == array[j1+1][1] && array[j2][1] == array[j2+1][1]) { - // cout << "Zwei Paare"; - // Anteil ermitteln - for(j3=0; j3<2; j3++) { - if(array[j1+j3][2] <= 1) { - temp2Array[temp] = array[j1+j3][1]; - temp++; - } - } - for(j3=0; j3<2; j3++) { - if(array[j2+j3][2] <= 1) { - temp2Array[temp] = array[j2+j3][1]; - temp++; - } - } + // auf Zwei Paare testen + for(j1=0; j1<2; j1++) { + for(j2=j1+2; j2<4; j2++) { + if(array[j1][1] == array[j1+1][1] && array[j2][1] == array[j2+1][1]) { + // cout << "Zwei Paare"; + // Anteil ermitteln + for(j3=0; j3<2; j3++) { + if(array[j1+j3][2] <= 1) { + temp2Array[temp] = array[j1+j3][1]; + temp++; + } + } + for(j3=0; j3<2; j3++) { + if(array[j2+j3][2] <= 1) { + temp2Array[temp] = array[j2+j3][1]; + temp++; + } + } - // Anteil 2 - if(temp == 2) { - if(temp2Array[0] != temp2Array[1]) { - return (22200 + temp2Array[0]); - } - else { - if(temp2Array[0] == array[j1][1]) { - return (22100 + temp2Array[0]); - } else { - return (22000 + temp2Array[0]); - } - } + // Anteil 2 + if(temp == 2) { + if(temp2Array[0] != temp2Array[1]) { + return (22200 + temp2Array[0]); + } else { + if(temp2Array[0] == array[j1][1]) { + return (22100 + temp2Array[0]); + } else { + return (22000 + temp2Array[0]); + } + } - } - // Anteil 1 - else { - if(temp2Array[0] == array[j1][1]) { - return 21100 + array[j1][1]; - } else { - return 21000 + array[j2][1]; - } - } - } - } - } + } + // Anteil 1 + else { + if(temp2Array[0] == array[j1][1]) { + return 21100 + array[j1][1]; + } else { + return 21000 + array[j2][1]; + } + } + } + } + } - temp = 0; - temp1 = 0; - temp2 = 0; + temp = 0; + temp1 = 0; + temp2 = 0; - // auf Paar testen - for(j1=0; j1<4; j1++) { - if(array[j1][1] == array[j1+1][1]) { - // cout << "Paar"; - // ohne Straight- und Flush-Draw - if(!breakLoop) { - // Anteil ermitteln - for(j2=0; j2<2; j2++) { - if(array[j1+j2][2] <= 1) temp++; - } - // Anteil 2 - if(temp == 2) { - return (12000 + j1*100 + array[j1][1]); - } else { - // Anteil 1 - if(temp == 1) { - for(j2=0; j2<5; j2++) { - if(array[j2][2] >= 2 && array[j2][1] > array[j1][1]) temp1++; - } - return (11000 + temp1*100 + array[j1][1]); - } - // Anteil 0 - else { - for(j2=0; j2<5; j2++) { - if(array[j2][2] <= 1 && array[j2][1] > temp1) temp1 = array[j2][1]; - } - for(j2=0; j2<5; j2++) { - if(array[j2][2] >= 2 && array[j2][1] > temp1) temp2++; - } - if(temp2 == 2) temp2 = 1; - if(temp2 == 3) temp2 = 2; - return (10000 + temp2*100 + temp1); - } - } - } - else { - // STraight (==4) - if(((int)(tempValue/10000)) == 4) { - return (((int)(tempValue/1000))*1000 + 200+ (tempValue - ((int)(tempValue/100))*100)); - } - // Flush Anteil 1 (==5) - else { - return (((int)(tempValue/10000))*10000 + 3000 + (tempValue - ((int)(tempValue/1000))*1000)); - } - } - } - } + // auf Paar testen + for(j1=0; j1<4; j1++) { + if(array[j1][1] == array[j1+1][1]) { + // cout << "Paar"; + // ohne Straight- und Flush-Draw + if(!breakLoop) { + // Anteil ermitteln + for(j2=0; j2<2; j2++) { + if(array[j1+j2][2] <= 1) temp++; + } + // Anteil 2 + if(temp == 2) { + return (12000 + j1*100 + array[j1][1]); + } else { + // Anteil 1 + if(temp == 1) { + for(j2=0; j2<5; j2++) { + if(array[j2][2] >= 2 && array[j2][1] > array[j1][1]) temp1++; + } + return (11000 + temp1*100 + array[j1][1]); + } + // Anteil 0 + else { + for(j2=0; j2<5; j2++) { + if(array[j2][2] <= 1 && array[j2][1] > temp1) temp1 = array[j2][1]; + } + for(j2=0; j2<5; j2++) { + if(array[j2][2] >= 2 && array[j2][1] > temp1) temp2++; + } + if(temp2 == 2) temp2 = 1; + if(temp2 == 3) temp2 = 2; + return (10000 + temp2*100 + temp1); + } + } + } else { + // STraight (==4) + if(((int)(tempValue/10000)) == 4) { + return (((int)(tempValue/1000))*1000 + 200+ (tempValue - ((int)(tempValue/100))*100)); + } + // Flush Anteil 1 (==5) + else { + return (((int)(tempValue/10000))*10000 + 3000 + (tempValue - ((int)(tempValue/1000))*1000)); + } + } + } + } - // Highest Card (Klasse 0) + Kicker + // Highest Card (Klasse 0) + Kicker - // ohne Straight- und Flush-Draw - if(!breakLoop) { - // cout << "Highest Card"; - // Anteil ermitteln - for(j1=0; j1<5; j1++) { - if(array[j1][2] <= 1) { - temp2Array[temp] = array[j1][1]; - temp++; - } - } - for(j1=0; j1<5; j1++) { - if(temp2Array[1] > array[j1][1]) temp1++; - if(temp2Array[0] > array[j1][1]) temp2++; - } - return (temp1*1000 + temp2*100 + array[0][1]); + // ohne Straight- und Flush-Draw + if(!breakLoop) { + // cout << "Highest Card"; + // Anteil ermitteln + for(j1=0; j1<5; j1++) { + if(array[j1][2] <= 1) { + temp2Array[temp] = array[j1][1]; + temp++; + } + } + for(j1=0; j1<5; j1++) { + if(temp2Array[1] > array[j1][1]) temp1++; + if(temp2Array[0] > array[j1][1]) temp2++; + } + return (temp1*1000 + temp2*100 + array[0][1]); - } else { - return tempValue; - } + } else { + return tempValue; + } } -void LocalPlayer::calcMyOdds() { +void LocalPlayer::calcMyOdds() +{ - int handCode; + int handCode; - switch(currentHand->getCurrentRound()) { + switch(currentHand->getCurrentRound()) { - case 0: { + case 0: { - handCode = myCardsValue->holeCardsToIntCode(myCards); + handCode = myCardsValue->holeCardsToIntCode(myCards); - // übergang solange preflopValue und flopValue noch nicht bereinigt - int players = currentHand->getActivePlayerList()->size(); - if(players > 5) players = 5; - // paranoia - if(players < 2) players = 2; + // übergang solange preflopValue und flopValue noch nicht bereinigt + int players = currentHand->getActivePlayerList()->size(); + if(players > 5) players = 5; + // paranoia + if(players < 2) players = 2; - for (unsigned val = 0; val < NUM_PREFLOP_VALUES; val++) { - if(handCode == PreflopValues[val].hand) { - myOdds = 100.0*PreflopValues[val].data[players - 2]; - break; - } - } - if (myOdds == -1) LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR myOdds - " << handCode); + for (unsigned val = 0; val < NUM_PREFLOP_VALUES; val++) { + if(handCode == PreflopValues[val].hand) { + myOdds = 100.0*PreflopValues[val].data[players - 2]; + break; + } + } + if (myOdds == -1) LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR myOdds - " << handCode); - } - break; - case 1: { + } + break; + case 1: { - int tempArray[5]; - int boardCards[5]; + int tempArray[5]; + int boardCards[5]; - int i; + int i; - for(i=0; i<2; i++) tempArray[i] = myCards[i]; - currentHand->getBoard()->getMyCards(boardCards); - for(i=0; i<3; i++) tempArray[2+i] = boardCards[i]; + for(i=0; i<2; i++) tempArray[i] = myCards[i]; + currentHand->getBoard()->getMyCards(boardCards); + for(i=0; i<3; i++) tempArray[2+i] = boardCards[i]; - // cout << myID << ": "; + // cout << myID << ": "; - handCode = flopCardsValue(tempArray); + handCode = flopCardsValue(tempArray); - // cout << "\t" << handCode << endl; + // cout << "\t" << handCode << endl; - // übergang solange preflopValue und flopValue noch nicht bereinigt - int players = currentHand->getActivePlayerList()->size(); - if(players > 5) players = 5; - // paranoia - if(players < 2) players = 2; + // übergang solange preflopValue und flopValue noch nicht bereinigt + int players = currentHand->getActivePlayerList()->size(); + if(players > 5) players = 5; + // paranoia + if(players < 2) players = 2; - if(handCode != 80000) { - for (unsigned val = 0; val < NUM_FLOP_VALUES; val++) { - if(handCode == FlopValues[val].hand) { - myOdds = 100.0*FlopValues[val].data[players - 2]; - break; - } - } - if(myOdds == -1) { - ostringstream logger; - logger << "ERROR myOdds is -1: "; - for(i=0; i<5; i++) logger << tempArray[i] << " "; - LOG_ERROR(__FILE__ << " (" << __LINE__ << "): " << logger.str()); - // cout << "\t" << handCode << "\t" << myID << endl; - } else { - // cout << myHoleCardsValue << endl; - } - } else { - myOdds = 100; - } + if(handCode != 80000) { + for (unsigned val = 0; val < NUM_FLOP_VALUES; val++) { + if(handCode == FlopValues[val].hand) { + myOdds = 100.0*FlopValues[val].data[players - 2]; + break; + } + } + if(myOdds == -1) { + ostringstream logger; + logger << "ERROR myOdds is -1: "; + for(i=0; i<5; i++) logger << tempArray[i] << " "; + LOG_ERROR(__FILE__ << " (" << __LINE__ << "): " << logger.str()); + // cout << "\t" << handCode << "\t" << myID << endl; + } else { + // cout << myHoleCardsValue << endl; + } + } else { + myOdds = 100; + } - } - break; - case 2: { + } + break; + case 2: { - // Prozent ausrechnen + // Prozent ausrechnen - int i, j, k; - int tempBoardCardsArray[5]; - int tempMyCardsArray[7]; - int tempOpponentCardsArray[7]; - currentHand->getBoard()->getMyCards(tempBoardCardsArray); + int i, j, k; + int tempBoardCardsArray[5]; + int tempMyCardsArray[7]; + int tempOpponentCardsArray[7]; + currentHand->getBoard()->getMyCards(tempBoardCardsArray); - tempMyCardsArray[0] = myCards[0]; - tempMyCardsArray[1] = myCards[1]; - tempMyCardsArray[2] = tempBoardCardsArray[0]; - tempMyCardsArray[3] = tempBoardCardsArray[1]; - tempMyCardsArray[4] = tempBoardCardsArray[2]; - tempMyCardsArray[5] = tempBoardCardsArray[3]; + tempMyCardsArray[0] = myCards[0]; + tempMyCardsArray[1] = myCards[1]; + tempMyCardsArray[2] = tempBoardCardsArray[0]; + tempMyCardsArray[3] = tempBoardCardsArray[1]; + tempMyCardsArray[4] = tempBoardCardsArray[2]; + tempMyCardsArray[5] = tempBoardCardsArray[3]; - tempOpponentCardsArray[2] = tempBoardCardsArray[0]; - tempOpponentCardsArray[3] = tempBoardCardsArray[1]; - tempOpponentCardsArray[4] = tempBoardCardsArray[2]; - tempOpponentCardsArray[5] = tempBoardCardsArray[3]; + tempOpponentCardsArray[2] = tempBoardCardsArray[0]; + tempOpponentCardsArray[3] = tempBoardCardsArray[1]; + tempOpponentCardsArray[4] = tempBoardCardsArray[2]; + tempOpponentCardsArray[5] = tempBoardCardsArray[3]; - int tempMyCardsValue; - int tempOpponentCardsValue; + int tempMyCardsValue; + int tempOpponentCardsValue; - int countAll = 0; - int countMy = 0; + int countAll = 0; + int countMy = 0; - for(i=0; i<49; i++) { - if(i != myCards[0] && i != myCards[1] && i != tempBoardCardsArray[0] && i != tempBoardCardsArray[1] && i != tempBoardCardsArray[2]) { - for(j=i+1; j<50; j++) { - if(j != myCards[0] && j != myCards[1] && j != tempBoardCardsArray[0] && j != tempBoardCardsArray[1] && j != tempBoardCardsArray[2]) { - for(k=j+1; k<51; k++) { - if(k != myCards[0] && k != myCards[1] && k != tempBoardCardsArray[0] && k != tempBoardCardsArray[1] && k != tempBoardCardsArray[2]) { + for(i=0; i<49; i++) { + if(i != myCards[0] && i != myCards[1] && i != tempBoardCardsArray[0] && i != tempBoardCardsArray[1] && i != tempBoardCardsArray[2]) { + for(j=i+1; j<50; j++) { + if(j != myCards[0] && j != myCards[1] && j != tempBoardCardsArray[0] && j != tempBoardCardsArray[1] && j != tempBoardCardsArray[2]) { + for(k=j+1; k<51; k++) { + if(k != myCards[0] && k != myCards[1] && k != tempBoardCardsArray[0] && k != tempBoardCardsArray[1] && k != tempBoardCardsArray[2]) { - countAll++; + countAll++; - tempOpponentCardsArray[0] = i; - tempOpponentCardsArray[1] = j; - tempOpponentCardsArray[6] = k; - tempMyCardsArray[6] = k; - tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); - tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); + tempOpponentCardsArray[0] = i; + tempOpponentCardsArray[1] = j; + tempOpponentCardsArray[6] = k; + tempMyCardsArray[6] = k; + tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); + tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); - if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; - } - } - } - } - } - } + if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; + } + } + } + } + } + } - myOdds = 100.0*(countMy*1.0)/(countAll*1.0); + myOdds = 100.0*(countMy*1.0)/(countAll*1.0); - } - break; - case 3: { + } + break; + case 3: { - // Prozent ausrechnen + // Prozent ausrechnen - int i, j; - int tempBoardCardsArray[5]; - int tempMyCardsArray[7]; - int tempOpponentCardsArray[7]; - currentHand->getBoard()->getMyCards(tempBoardCardsArray); + int i, j; + int tempBoardCardsArray[5]; + int tempMyCardsArray[7]; + int tempOpponentCardsArray[7]; + currentHand->getBoard()->getMyCards(tempBoardCardsArray); - tempMyCardsArray[0] = myCards[0]; - tempMyCardsArray[1] = myCards[1]; - tempMyCardsArray[2] = tempBoardCardsArray[0]; - tempMyCardsArray[3] = tempBoardCardsArray[1]; - tempMyCardsArray[4] = tempBoardCardsArray[2]; - tempMyCardsArray[5] = tempBoardCardsArray[3]; - tempMyCardsArray[6] = tempBoardCardsArray[4]; + tempMyCardsArray[0] = myCards[0]; + tempMyCardsArray[1] = myCards[1]; + tempMyCardsArray[2] = tempBoardCardsArray[0]; + tempMyCardsArray[3] = tempBoardCardsArray[1]; + tempMyCardsArray[4] = tempBoardCardsArray[2]; + tempMyCardsArray[5] = tempBoardCardsArray[3]; + tempMyCardsArray[6] = tempBoardCardsArray[4]; - tempOpponentCardsArray[2] = tempBoardCardsArray[0]; - tempOpponentCardsArray[3] = tempBoardCardsArray[1]; - tempOpponentCardsArray[4] = tempBoardCardsArray[2]; - tempOpponentCardsArray[5] = tempBoardCardsArray[3]; - tempOpponentCardsArray[6] = tempBoardCardsArray[4]; + tempOpponentCardsArray[2] = tempBoardCardsArray[0]; + tempOpponentCardsArray[3] = tempBoardCardsArray[1]; + tempOpponentCardsArray[4] = tempBoardCardsArray[2]; + tempOpponentCardsArray[5] = tempBoardCardsArray[3]; + tempOpponentCardsArray[6] = tempBoardCardsArray[4]; - int tempMyCardsValue; - int tempOpponentCardsValue; + int tempMyCardsValue; + int tempOpponentCardsValue; - int countAll = 0; - int countMy = 0; + int countAll = 0; + int countMy = 0; - for(i=0; i<49; i++) { - if(i != myCards[0] && i != myCards[1] && i != tempBoardCardsArray[0] && i != tempBoardCardsArray[1] && i != tempBoardCardsArray[2]) { - for(j=i+1; j<50; j++) { - if(j != myCards[0] && j != myCards[1] && j != tempBoardCardsArray[0] && j != tempBoardCardsArray[1] && j != tempBoardCardsArray[2]) { + for(i=0; i<49; i++) { + if(i != myCards[0] && i != myCards[1] && i != tempBoardCardsArray[0] && i != tempBoardCardsArray[1] && i != tempBoardCardsArray[2]) { + for(j=i+1; j<50; j++) { + if(j != myCards[0] && j != myCards[1] && j != tempBoardCardsArray[0] && j != tempBoardCardsArray[1] && j != tempBoardCardsArray[2]) { - countAll++; + countAll++; - tempOpponentCardsArray[0] = i; - tempOpponentCardsArray[1] = j; - tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); - tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); + tempOpponentCardsArray[0] = i; + tempOpponentCardsArray[1] = j; + tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); + tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); - if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; - } - } - } - } + if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; + } + } + } + } - myOdds = 100.0*(countMy*1.0)/(countAll*1.0); + myOdds = 100.0*(countMy*1.0)/(countAll*1.0); - } - break; - default: LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR - wrong init of currentRound"); + } + break; + default: + LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR - wrong init of currentRound"); - } + } } @@ -4174,249 +4193,245 @@ void LocalPlayer::calcMyOdds() { -int LocalPlayer::turnCardsValue(int* cards) { +int LocalPlayer::turnCardsValue(int* cards) +{ - int array[6][3]; - int j1, j2, j3, j4, j5, k1, k2, ktemp[3]; + int array[6][3]; + int j1, j2, j3, j4, j5, k1, k2, ktemp[3]; - // Kartenwerte umwandeln (z.B. [ 11 (Karo K�ig) -> 0 11 ] oder [ 31 (Pik 7) -> 2 5 ] ) - for(j1=0; j1<6; j1++) { - array[j1][0] = cards[j1]/13; - array[j1][1] = cards[j1]%13; - array[j1][2] = j1; - } + // Kartenwerte umwandeln (z.B. [ 11 (Karo K�ig) -> 0 11 ] oder [ 31 (Pik 7) -> 2 5 ] ) + for(j1=0; j1<6; j1++) { + array[j1][0] = cards[j1]/13; + array[j1][1] = cards[j1]%13; + array[j1][2] = j1; + } - // Karten nach Farben sortieren: Kreuz - Pik - Herz - Karo - for(k1=0; k1<6; k1++) { - for(k2=k1+1; k2<6; k2++) { - if(array[k1][0] Sieg -> alles mitgehen - return 100; - } - else { - // Straight Flush Ausnahme: 5-4-3-2-A - for(j2=j1+1; j2<3; j2++) { - if(array[j1][1]-9==array[j2][1] && array[j2][1]-1==array[j2+1][1] && array[j2+1][1]-1==array[j2+2][1] && array[j2+2][1]-1==array[j2+3][1] && array[j1][0]==array[j2+2][0] && array[j1][0]==array[j2+3][0]) { - // cout << "Straight Flush Ass unten" << endl; - // -> fast sicherer Sieg -> alles mitgehen - return 99; - } - } - } - } - } + // auf Straight Flush und Flush testen + // 5 Karten gleiche Farbe ? + for(j1=0; j1<2; j1++) { + // 5 Karten gleiche Farbe ? + if(array[j1][0] == array[j1+1][0] && array[j1][0] == array[j1+2][0] && array[j1][0] == array[j1+3][0] && array[j1][0] == array[j1+4][0]) { + // Straight Flush? + if(array[j1][1]-4 == array[j1+4][1]) { + // cout << "Straight Flush" << endl; + // -> Sieg -> alles mitgehen + return 100; + } else { + // Straight Flush Ausnahme: 5-4-3-2-A + for(j2=j1+1; j2<3; j2++) { + if(array[j1][1]-9==array[j2][1] && array[j2][1]-1==array[j2+1][1] && array[j2+1][1]-1==array[j2+2][1] && array[j2+2][1]-1==array[j2+3][1] && array[j1][0]==array[j2+2][0] && array[j1][0]==array[j2+3][0]) { + // cout << "Straight Flush Ass unten" << endl; + // -> fast sicherer Sieg -> alles mitgehen + return 99; + } + } + } + } + } - // auf Flush testen - for(j1=0; j1<2; j1++) { - if(array[j1][0] == array[j1+1][0] && array[j1][0] == array[j1+2][0] && array[j1][0] == array[j1+3][0] && array[j1][0] == array[j1+4][0]) { - // cout << "Flush" << endl; - // -> sehr gutes Blatt -> eigenen Anteil ermitteln und auf andere achten - return 70; - } - } + // auf Flush testen + for(j1=0; j1<2; j1++) { + if(array[j1][0] == array[j1+1][0] && array[j1][0] == array[j1+2][0] && array[j1][0] == array[j1+3][0] && array[j1][0] == array[j1+4][0]) { + // cout << "Flush" << endl; + // -> sehr gutes Blatt -> eigenen Anteil ermitteln und auf andere achten + return 70; + } + } - // auf Straight Flush Draw und Flush Draw testen - for(j1=0; j1<3; j1++) { - // 4 Karten gleiche Farbe ? - if(array[j1][0] == array[j1+1][0] && array[j1][0] == array[j1+2][0] && array[j1][0] == array[j1+3][0]) { - // zusammenhaengender Strassenansatz ? - if(array[j1][1]-3 == array[j1+3][1]) { - // Strassenansatz am Rand? - if(array[j1][1] == 12) { - // cout << "zusammenhaengender Straight-Flush-Draw mit Ass high "; - break; - } - // Strassenansatz in der Mitte - else { - // cout << "zusammenhaengender Straight-Flush-Draw in der Mitte "; - break; - } - } - else { - // Bauchschuss ? - if(array[j1][1]-4 == array[j1+3][1]) { - // cout << "Straight-Flush-Bauchschuss "; - break; - } - else { - // Test auf Straight-Flush-Ausnahme 5-4-3-2-A - if(array[j1][1] == 12 && (array[j1+1][1]<=3 || (array[j1+2][1]<=3 && array[j1][0]==array[j1+4][0]) || (array[j1+3][1]<=3 && array[j1][0]==array[j1+4][0] && array[j1][0]==array[j1+4][0]))) { - // cout << "Straight-Flush-Draw Ass unten "; - break; - } - // Flush Draw - else { - // cout << "Flush Draw "; - break; - } - } + // auf Straight Flush Draw und Flush Draw testen + for(j1=0; j1<3; j1++) { + // 4 Karten gleiche Farbe ? + if(array[j1][0] == array[j1+1][0] && array[j1][0] == array[j1+2][0] && array[j1][0] == array[j1+3][0]) { + // zusammenhaengender Strassenansatz ? + if(array[j1][1]-3 == array[j1+3][1]) { + // Strassenansatz am Rand? + if(array[j1][1] == 12) { + // cout << "zusammenhaengender Straight-Flush-Draw mit Ass high "; + break; + } + // Strassenansatz in der Mitte + else { + // cout << "zusammenhaengender Straight-Flush-Draw in der Mitte "; + break; + } + } else { + // Bauchschuss ? + if(array[j1][1]-4 == array[j1+3][1]) { + // cout << "Straight-Flush-Bauchschuss "; + break; + } else { + // Test auf Straight-Flush-Ausnahme 5-4-3-2-A + if(array[j1][1] == 12 && (array[j1+1][1]<=3 || (array[j1+2][1]<=3 && array[j1][0]==array[j1+4][0]) || (array[j1+3][1]<=3 && array[j1][0]==array[j1+4][0] && array[j1][0]==array[j1+4][0]))) { + // cout << "Straight-Flush-Draw Ass unten "; + break; + } + // Flush Draw + else { + // cout << "Flush Draw "; + break; + } + } - } - } - } + } + } + } - // Karten fr den Vierling-, Full-House-, Drilling- und Paartest umsortieren - for(k1=0; k1<6; k1++) { - for(k2=k1+1; k2<6; k2++) { - if(array[k1][1] Sieg (nur von Sraight Flush schlagbar) -> alles mitgehn - return 100; - } - } + // auf Vierling testen + for(j1=0; j1<3; j1++) { + if(array[j1][1] == array[j1+1][1] && array[j1][1] == array[j1+2][1] && array[j1][1] == array[j1+3][1]) { + // cout << "Vierling" << endl; + // -> Sieg (nur von Sraight Flush schlagbar) -> alles mitgehn + return 100; + } + } - // auf Straight und Full House testen - for(j1=0; j1<6; j1++) { - for(j2=j1+1; j2<6; j2++) { - for(j3=j2+1; j3<6; j3++) { - for(j4=j3+1; j4<6; j4++) { - for(j5=j4+1; j5<6; j5++) { - // Straight - if((array[j1][1]-1 == array[j2][1] || array[j1][1]-9 == array[j2][1] ) && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1] && array[j4][1]-1 == array[j5][1]) { - // cout << "Straight" << endl; - // -> super Blatt -> auf andere achten - return 70; - } - // Full House - if((array[j1][1] == array[j2][1] && array[j1][1] == array[j3][1] && array[j4][1] == array[j5][1]) || (array[j3][1] == array[j4][1] && array[j3][1] == array[j5][1] && array[j1][1] == array[j2][1])) { - // cout << "Full House" << endl; - // -> super Blatt -> auf andere achten - return 70; - } - } - } - } - } - } + // auf Straight und Full House testen + for(j1=0; j1<6; j1++) { + for(j2=j1+1; j2<6; j2++) { + for(j3=j2+1; j3<6; j3++) { + for(j4=j3+1; j4<6; j4++) { + for(j5=j4+1; j5<6; j5++) { + // Straight + if((array[j1][1]-1 == array[j2][1] || array[j1][1]-9 == array[j2][1] ) && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1] && array[j4][1]-1 == array[j5][1]) { + // cout << "Straight" << endl; + // -> super Blatt -> auf andere achten + return 70; + } + // Full House + if((array[j1][1] == array[j2][1] && array[j1][1] == array[j3][1] && array[j4][1] == array[j5][1]) || (array[j3][1] == array[j4][1] && array[j3][1] == array[j5][1] && array[j1][1] == array[j2][1])) { + // cout << "Full House" << endl; + // -> super Blatt -> auf andere achten + return 70; + } + } + } + } + } + } - // auf Straßenansatz testen - for(j1=0; j1<6; j1++) { - for(j2=j1+1; j2<6; j2++) { - for(j3=j2+1; j3<6; j3++) { - for(j4=j3+1; j4<6; j4++) { - // zusammenhaengender Strassenansatz ? - if(array[j1][1]-1 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) { - // Strassenansatz am Rand? - if(array[j1][1] == 12) { - // cout << "zusammenhaengender Straight-Draw mit Ass high "; - break; - } - // Strassenansatz in der Mitte - else { - // cout << "zusammenhaengender Straight-Draw in der Mitte "; - break; - } - } - else { - // Bauchschuss ? - if((array[j1][1]-2 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-1 == array[j2][1] && array[j2][1]-2 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-1 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-2 == array[j4][1])) { - // cout << "Straight-Bauchschuss "; - break; - } - else { - // Test auf Straßenansatz-Ausnahme 5-4-3-2-A - if((array[j1][1]-9 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-9 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-2 == array[j4][1]) || (array[j1][1]-9 == array[j2][1] && array[j2][1]-2 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-10 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1])) { - // cout << "Straight-Draw Ass unten "; - break; - } - } - } - } - } - } - } + // auf Straßenansatz testen + for(j1=0; j1<6; j1++) { + for(j2=j1+1; j2<6; j2++) { + for(j3=j2+1; j3<6; j3++) { + for(j4=j3+1; j4<6; j4++) { + // zusammenhaengender Strassenansatz ? + if(array[j1][1]-1 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) { + // Strassenansatz am Rand? + if(array[j1][1] == 12) { + // cout << "zusammenhaengender Straight-Draw mit Ass high "; + break; + } + // Strassenansatz in der Mitte + else { + // cout << "zusammenhaengender Straight-Draw in der Mitte "; + break; + } + } else { + // Bauchschuss ? + if((array[j1][1]-2 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-1 == array[j2][1] && array[j2][1]-2 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-1 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-2 == array[j4][1])) { + // cout << "Straight-Bauchschuss "; + break; + } else { + // Test auf Straßenansatz-Ausnahme 5-4-3-2-A + if((array[j1][1]-9 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-9 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-2 == array[j4][1]) || (array[j1][1]-9 == array[j2][1] && array[j2][1]-2 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-10 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1])) { + // cout << "Straight-Draw Ass unten "; + break; + } + } + } + } + } + } + } - // auf Drilling testen - for(j1=0; j1<4; j1++) { - if(array[j1][1] == array[j1+1][1] && array[j1][1] == array[j1+2][1]) { - // cout << "Drilling" << endl; - // -> gutes Blatt -> eigenen Anteil ermitteln und auf andere achten - return 50; - } - } + // auf Drilling testen + for(j1=0; j1<4; j1++) { + if(array[j1][1] == array[j1+1][1] && array[j1][1] == array[j1+2][1]) { + // cout << "Drilling" << endl; + // -> gutes Blatt -> eigenen Anteil ermitteln und auf andere achten + return 50; + } + } - // auf Zwei Paare testen - for(j1=0; j1<3; j1++) { - for(j2=j1+2; j2<5; j2++) { - if(array[j1][1] == array[j1+1][1] && array[j2][1] == array[j2+1][1]) { - // cout << "Zwei Paare" << endl; - // -> gutes Blatt -> eigenen Anteil ermitteln und auf andere achten - return 40; - } - } - } + // auf Zwei Paare testen + for(j1=0; j1<3; j1++) { + for(j2=j1+2; j2<5; j2++) { + if(array[j1][1] == array[j1+1][1] && array[j2][1] == array[j2+1][1]) { + // cout << "Zwei Paare" << endl; + // -> gutes Blatt -> eigenen Anteil ermitteln und auf andere achten + return 40; + } + } + } - // auf Paar testen - for(j1=0; j1<5; j1++) { - if(array[j1][1] == array[j1+1][1]) { - // cout << "Paar" << endl; - // -> gutes Blatt -> eigenen Anteil ermitteln und auf andere achten - return 30; - } - } + // auf Paar testen + for(j1=0; j1<5; j1++) { + if(array[j1][1] == array[j1+1][1]) { + // cout << "Paar" << endl; + // -> gutes Blatt -> eigenen Anteil ermitteln und auf andere achten + return 30; + } + } - // Highest Card (Klasse 0) + Kicker - // cout << endl; - return 10; + // Highest Card (Klasse 0) + Kicker + // cout << endl; + return 10; -} +} @@ -4424,690 +4439,685 @@ int LocalPlayer::turnCardsValue(int* cards) { -void LocalPlayer::preflopEngine3() { +void LocalPlayer::preflopEngine3() +{ - // cout << "nextID " << currentHand->getPlayerArray()[(myID+1)%5]->getMyID() << endl; + // cout << "nextID " << currentHand->getPlayerArray()[(myID+1)%5]->getMyID() << endl; - // Bauchgefhl (zufᅵlig) - int tempRand; - Tools::getRandNumber(1,10,1,&tempRand,0); + // Bauchgefhl (zufᅵlig) + int tempRand; + Tools::getRandNumber(1,10,1,&tempRand,0); - // bluff, checkbluff - int bluff; - Tools::getRandNumber(1,100,1,&bluff,0); + // bluff, checkbluff + int bluff; + Tools::getRandNumber(1,100,1,&bluff,0); - // cout << "preflop-bluff " << bluff << endl; + // cout << "preflop-bluff " << bluff << endl; - // Potential - int potential = 10*(4*(myCardsValue->holeCardsClass(myCards[0], myCards[1]))+1*tempRand)/50-myDude; + // Potential + int potential = 10*(4*(myCardsValue->holeCardsClass(myCards[0], myCards[1]))+1*tempRand)/50-myDude; - int setToHighest = currentHand->getCurrentBeRo()->getHighestSet() - mySet; + int setToHighest = currentHand->getCurrentBeRo()->getHighestSet() - mySet; - // temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist - int tempFold; - // tempFold = (currentHand->getPlayerArray()[0]->getMyAverageSets())/(8*currentHand->getSmallBlind()); - Tools::getRandNumber(2,3,1,&tempFold,0); + // temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist + int tempFold; + // tempFold = (currentHand->getPlayerArray()[0]->getMyAverageSets())/(8*currentHand->getSmallBlind()); + Tools::getRandNumber(2,3,1,&tempFold,0); - // FOLD --> wenn Potential negativ oder HighestSet zu hoch - if( (potential*setToHighest<0 || (setToHighest > tempFold * currentHand->getSmallBlind() && potential<1) || (setToHighest > 2 * tempFold * currentHand->getSmallBlind() && potential<2) || (setToHighest > 4 * tempFold * currentHand->getSmallBlind() && potential<3) || (setToHighest > 10 * tempFold * currentHand->getSmallBlind() && potential<4)) && myCardsValue->holeCardsClass(myCards[0], myCards[1]) < 9 && bluff > 15) { - myAction=1; - } - else { - // RAISE --> wenn hohes Potential - if((potential >= 4 && 6 * currentHand->getSmallBlind() >= currentHand->getCurrentBeRo()->getHighestSet()) || bluff <= 6) { + // FOLD --> wenn Potential negativ oder HighestSet zu hoch + if( (potential*setToHighest<0 || (setToHighest > tempFold * currentHand->getSmallBlind() && potential<1) || (setToHighest > 2 * tempFold * currentHand->getSmallBlind() && potential<2) || (setToHighest > 4 * tempFold * currentHand->getSmallBlind() && potential<3) || (setToHighest > 10 * tempFold * currentHand->getSmallBlind() && potential<4)) && myCardsValue->holeCardsClass(myCards[0], myCards[1]) < 9 && bluff > 15) { + myAction=1; + } else { + // RAISE --> wenn hohes Potential + if((potential >= 4 && 6 * currentHand->getSmallBlind() >= currentHand->getCurrentBeRo()->getHighestSet()) || bluff <= 6) { int raise = 0; // extrem hohes Potential --> groᅵr Raise - if(potential>=6 || bluff <= 2) { + if(potential>=6 || bluff <= 2) { - // bluff - raise - if(bluff <=2 && 4 * currentHand->getSmallBlind() > currentHand->getCurrentBeRo()->getHighestSet()) { - raise = 3 * currentHand->getCurrentBeRo()->getHighestSet(); - } - else { - // bluff - call - if(bluff >= 98) { - // All In - if(currentHand->getCurrentBeRo()->getHighestSet() >= myCash) { + // bluff - raise + if(bluff <=2 && 4 * currentHand->getSmallBlind() > currentHand->getCurrentBeRo()->getHighestSet()) { + raise = 3 * currentHand->getCurrentBeRo()->getHighestSet(); + } else { + // bluff - call + if(bluff >= 98) { + // All In + if(currentHand->getCurrentBeRo()->getHighestSet() >= myCash) { - mySet += myCash; - myCash = 0; - myAction = 6; + mySet += myCash; + myCash = 0; + myAction = 6; - } - // sonst - else { - myCash = myCash - currentHand->getCurrentBeRo()->getHighestSet() + mySet; - mySet = currentHand->getCurrentBeRo()->getHighestSet(); - myAction = 3; - } - } else { - // doch nich raisen, sondern nur checken, weil highestSets bereits sehr hoch !!! - if(! (4 * currentHand->getSmallBlind() > currentHand->getCurrentBeRo()->getHighestSet())) { + } + // sonst + else { + myCash = myCash - currentHand->getCurrentBeRo()->getHighestSet() + mySet; + mySet = currentHand->getCurrentBeRo()->getHighestSet(); + myAction = 3; + } + } else { + // doch nich raisen, sondern nur checken, weil highestSets bereits sehr hoch !!! + if(! (4 * currentHand->getSmallBlind() > currentHand->getCurrentBeRo()->getHighestSet())) { - // All In - if(currentHand->getCurrentBeRo()->getHighestSet() >= myCash) { - - mySet += myCash; - myCash = 0; - myAction = 6; - - } - // sonst - else { - myCash = myCash - currentHand->getCurrentBeRo()->getHighestSet() + mySet; - mySet = currentHand->getCurrentBeRo()->getHighestSet(); - myAction = 3; - } + // All In + if(currentHand->getCurrentBeRo()->getHighestSet() >= myCash) { - } - else raise = (potential - 4 ) * 2 * currentHand->getCurrentBeRo()->getHighestSet(); - } - } - } - // hohes Potential --> gemäßigter Raise - else { - // bluff - raise - if(bluff <= 6 && 4 * currentHand->getSmallBlind() > currentHand->getCurrentBeRo()->getHighestSet()) { - raise = 2*currentHand->getCurrentBeRo()->getHighestSet(); - } - else { - // bluff - call - if(bluff >= 93) { + mySet += myCash; + myCash = 0; + myAction = 6; - // All In - if(currentHand->getCurrentBeRo()->getHighestSet() >= myCash) { + } + // sonst + else { + myCash = myCash - currentHand->getCurrentBeRo()->getHighestSet() + mySet; + mySet = currentHand->getCurrentBeRo()->getHighestSet(); + myAction = 3; + } - mySet += myCash; - myCash = 0; - myAction = 6; + } else raise = (potential - 4 ) * 2 * currentHand->getCurrentBeRo()->getHighestSet(); + } + } + } + // hohes Potential --> gemäßigter Raise + else { + // bluff - raise + if(bluff <= 6 && 4 * currentHand->getSmallBlind() > currentHand->getCurrentBeRo()->getHighestSet()) { + raise = 2*currentHand->getCurrentBeRo()->getHighestSet(); + } else { + // bluff - call + if(bluff >= 93) { - } - // sonst - else { - myCash = myCash - currentHand->getCurrentBeRo()->getHighestSet() + mySet; - mySet = currentHand->getCurrentBeRo()->getHighestSet(); - myAction = 3; - } - } - else { - // doch nich raisen, sondern nur checken, weil highestSets bereits sehr hoch !!! - if(! (4 * currentHand->getSmallBlind() > currentHand->getCurrentBeRo()->getHighestSet())) { + // All In + if(currentHand->getCurrentBeRo()->getHighestSet() >= myCash) { - // All In - if(currentHand->getCurrentBeRo()->getHighestSet() >= myCash) { - - mySet += myCash; - myCash = 0; - myAction = 6; - - } - // sonst - else { - myCash = myCash - currentHand->getCurrentBeRo()->getHighestSet() + mySet; - mySet = currentHand->getCurrentBeRo()->getHighestSet(); - myAction = 3; - } - } - else raise = (potential - 3 ) * currentHand->getCurrentBeRo()->getHighestSet(); - } - } - } + mySet += myCash; + myCash = 0; + myAction = 6; - if (raise > 0) { - // All In - if(currentHand->getCurrentBeRo()->getHighestSet() + raise >= myCash) { + } + // sonst + else { + myCash = myCash - currentHand->getCurrentBeRo()->getHighestSet() + mySet; + mySet = currentHand->getCurrentBeRo()->getHighestSet(); + myAction = 3; + } + } else { + // doch nich raisen, sondern nur checken, weil highestSets bereits sehr hoch !!! + if(! (4 * currentHand->getSmallBlind() > currentHand->getCurrentBeRo()->getHighestSet())) { - mySet += myCash; - myCash = 0; - myAction = 6; - if(mySet > currentHand->getCurrentBeRo()->getHighestSet()) currentHand->getCurrentBeRo()->setHighestSet(mySet); + // All In + if(currentHand->getCurrentBeRo()->getHighestSet() >= myCash) { - } - // sonst - else { + mySet += myCash; + myCash = 0; + myAction = 6; - myCash = myCash + mySet - currentHand->getCurrentBeRo()->getHighestSet() - raise; - mySet = currentHand->getCurrentBeRo()->getHighestSet() + raise; - currentHand->getCurrentBeRo()->setHighestSet(mySet); - myAction = 5; - } - } - } - //CHECK und CALL - else { - // CHECK --> wenn alle Sets glieich bei BigBlind und nich zu hohem Potential - if(mySet == currentHand->getCurrentBeRo()->getHighestSet()) { - myAction = 2; - } - // CALL --> bei normalen Potential - else { - // All In - if(currentHand->getCurrentBeRo()->getHighestSet() >= myCash) { + } + // sonst + else { + myCash = myCash - currentHand->getCurrentBeRo()->getHighestSet() + mySet; + mySet = currentHand->getCurrentBeRo()->getHighestSet(); + myAction = 3; + } + } else raise = (potential - 3 ) * currentHand->getCurrentBeRo()->getHighestSet(); + } + } + } - mySet += myCash; - myCash = 0; - myAction = 6; + if (raise > 0) { + // All In + if(currentHand->getCurrentBeRo()->getHighestSet() + raise >= myCash) { - } - // sonst - else { - myCash = myCash - currentHand->getCurrentBeRo()->getHighestSet() + mySet; - mySet = currentHand->getCurrentBeRo()->getHighestSet(); - myAction = 3; - } - } - } - } + mySet += myCash; + myCash = 0; + myAction = 6; + if(mySet > currentHand->getCurrentBeRo()->getHighestSet()) currentHand->getCurrentBeRo()->setHighestSet(mySet); + + } + // sonst + else { + + myCash = myCash + mySet - currentHand->getCurrentBeRo()->getHighestSet() - raise; + mySet = currentHand->getCurrentBeRo()->getHighestSet() + raise; + currentHand->getCurrentBeRo()->setHighestSet(mySet); + myAction = 5; + } + } + } + //CHECK und CALL + else { + // CHECK --> wenn alle Sets glieich bei BigBlind und nich zu hohem Potential + if(mySet == currentHand->getCurrentBeRo()->getHighestSet()) { + myAction = 2; + } + // CALL --> bei normalen Potential + else { + // All In + if(currentHand->getCurrentBeRo()->getHighestSet() >= myCash) { + + mySet += myCash; + myCash = 0; + myAction = 6; + + } + // sonst + else { + myCash = myCash - currentHand->getCurrentBeRo()->getHighestSet() + mySet; + mySet = currentHand->getCurrentBeRo()->getHighestSet(); + myAction = 3; + } + } + } + } } -void LocalPlayer::flopEngine3() { +void LocalPlayer::flopEngine3() +{ - // Prozent ausrechnen + // Prozent ausrechnen - int i, j, k ,l; - int tempBoardCardsArray[5]; - int tempMyCardsArray[7]; - int tempOpponentCardsArray[7]; + int i, j, k ,l; + int tempBoardCardsArray[5]; + int tempMyCardsArray[7]; + int tempOpponentCardsArray[7]; currentHand->getBoard()->getMyCards(tempBoardCardsArray); - tempMyCardsArray[0] = myCards[0]; - tempMyCardsArray[1] = myCards[1]; - tempMyCardsArray[2] = tempBoardCardsArray[0]; - tempMyCardsArray[3] = tempBoardCardsArray[1]; - tempMyCardsArray[4] = tempBoardCardsArray[2]; + tempMyCardsArray[0] = myCards[0]; + tempMyCardsArray[1] = myCards[1]; + tempMyCardsArray[2] = tempBoardCardsArray[0]; + tempMyCardsArray[3] = tempBoardCardsArray[1]; + tempMyCardsArray[4] = tempBoardCardsArray[2]; - tempOpponentCardsArray[2] = tempBoardCardsArray[0]; - tempOpponentCardsArray[3] = tempBoardCardsArray[1]; - tempOpponentCardsArray[4] = tempBoardCardsArray[2]; + tempOpponentCardsArray[2] = tempBoardCardsArray[0]; + tempOpponentCardsArray[3] = tempBoardCardsArray[1]; + tempOpponentCardsArray[4] = tempBoardCardsArray[2]; - int tempMyCardsValue; - int tempOpponentCardsValue; + int tempMyCardsValue; + int tempOpponentCardsValue; - int countAll = 0; - int countMy = 0; + int countAll = 0; + int countMy = 0; - for(i=0; i<49; i++) { - if(i != myCards[0] && i != myCards[1] && i != tempBoardCardsArray[0] && i != tempBoardCardsArray[1] && i != tempBoardCardsArray[2]) { - for(j=i+1; j<50; j++) { - if(j != myCards[0] && j != myCards[1] && j != tempBoardCardsArray[0] && j != tempBoardCardsArray[1] && j != tempBoardCardsArray[2]) { - for(k=j+1; k<51; k++) { - if(k != myCards[0] && k != myCards[1] && k != tempBoardCardsArray[0] && k != tempBoardCardsArray[1] && k != tempBoardCardsArray[2]) { - for(l=k+1; l<52; l++) { - if(l != myCards[0] && l != myCards[1] && l != tempBoardCardsArray[0] && l != tempBoardCardsArray[1] && l != tempBoardCardsArray[2]) { + for(i=0; i<49; i++) { + if(i != myCards[0] && i != myCards[1] && i != tempBoardCardsArray[0] && i != tempBoardCardsArray[1] && i != tempBoardCardsArray[2]) { + for(j=i+1; j<50; j++) { + if(j != myCards[0] && j != myCards[1] && j != tempBoardCardsArray[0] && j != tempBoardCardsArray[1] && j != tempBoardCardsArray[2]) { + for(k=j+1; k<51; k++) { + if(k != myCards[0] && k != myCards[1] && k != tempBoardCardsArray[0] && k != tempBoardCardsArray[1] && k != tempBoardCardsArray[2]) { + for(l=k+1; l<52; l++) { + if(l != myCards[0] && l != myCards[1] && l != tempBoardCardsArray[0] && l != tempBoardCardsArray[1] && l != tempBoardCardsArray[2]) { - countAll++; + countAll++; - tempOpponentCardsArray[0] = i; - tempOpponentCardsArray[1] = j; - tempOpponentCardsArray[5] = k; - tempOpponentCardsArray[6] = l; - tempMyCardsArray[5] = k; - tempMyCardsArray[6] = l; - tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); - tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); + tempOpponentCardsArray[0] = i; + tempOpponentCardsArray[1] = j; + tempOpponentCardsArray[5] = k; + tempOpponentCardsArray[6] = l; + tempMyCardsArray[5] = k; + tempMyCardsArray[6] = l; + tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); + tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); - if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; + if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; - } - } - } - } - } - } - } - } + } + } + } + } + } + } + } + } - double percent = (countMy*1.0)/(countAll*1.0); - // cout << "Prozent: " << percent << endl; + double percent = (countMy*1.0)/(countAll*1.0); + // cout << "Prozent: " << percent << endl; - // Bauchgefhl (zufᅵlig) - int tempRand; - Tools::getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0); + // Bauchgefhl (zufᅵlig) + int tempRand; + Tools::getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0); - // bluff, checkbluff - int bluff; - Tools::getRandNumber(1,100,1,&bluff,0); + // bluff, checkbluff + int bluff; + Tools::getRandNumber(1,100,1,&bluff,0); - // cout << "flop-bluff " << bluff << endl; + // cout << "flop-bluff " << bluff << endl; - // Potential - int potential = (10*(5*(int)(percent*100.)+10*tempRand*2))/700-myDude; + // Potential + int potential = (10*(5*(int)(percent*100.)+10*tempRand*2))/700-myDude; - int setToHighest = currentHand->getCurrentBeRo()->getHighestSet() - mySet; + int setToHighest = currentHand->getCurrentBeRo()->getHighestSet() - mySet; - // temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist - int tempFold; - // tempFold = (currentHand->getPlayerArray()[0]->getMyAverageSets())/(8*currentHand->getSmallBlind()); - Tools::getRandNumber(2,3,1,&tempFold,0); + // temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist + int tempFold; + // tempFold = (currentHand->getPlayerArray()[0]->getMyAverageSets())/(8*currentHand->getSmallBlind()); + Tools::getRandNumber(2,3,1,&tempFold,0); - // FOLD --> wenn potential negativ oder HighestSet zu hoch - if(( potential*setToHighest<0 || (setToHighest > tempFold * currentHand->getSmallBlind() && potential<1) || (setToHighest > 3 * tempFold * currentHand->getSmallBlind() && potential<2) || (setToHighest > 9 * tempFold * currentHand->getSmallBlind() && potential<3) || (setToHighest > 20*tempFold * currentHand->getSmallBlind() && potential<4) || (setToHighest > 40 *tempFold * currentHand->getSmallBlind() && potential<5)) && percent < 0.90 && bluff > 18) { - myAction=1; - } - else { - // CHECK und BET --> wenn noch keiner was gesetzt hat - if(currentHand->getCurrentBeRo()->getHighestSet() == 0) { - // CHECK --> wenn Potential klein oder check-bluff sonst bet oder bet-bluff - if((potential<3 || bluff >= 80) && bluff > 15) { - // check - myAction = 2; - } - // BET --> wenn Potential hoch - else { - if(bluff <= 5) mySet = (bluff+1) * currentHand->getSmallBlind(); - else { - if(bluff <=15 ) mySet = 4 * currentHand->getSmallBlind(); - // je höher das Potential, desto höher der Einsatz (zur Basis SmallBlind) - else mySet = (potential-1) * 2 * currentHand->getSmallBlind(); - } + // FOLD --> wenn potential negativ oder HighestSet zu hoch + if(( potential*setToHighest<0 || (setToHighest > tempFold * currentHand->getSmallBlind() && potential<1) || (setToHighest > 3 * tempFold * currentHand->getSmallBlind() && potential<2) || (setToHighest > 9 * tempFold * currentHand->getSmallBlind() && potential<3) || (setToHighest > 20*tempFold * currentHand->getSmallBlind() && potential<4) || (setToHighest > 40 *tempFold * currentHand->getSmallBlind() && potential<5)) && percent < 0.90 && bluff > 18) { + myAction=1; + } else { + // CHECK und BET --> wenn noch keiner was gesetzt hat + if(currentHand->getCurrentBeRo()->getHighestSet() == 0) { + // CHECK --> wenn Potential klein oder check-bluff sonst bet oder bet-bluff + if((potential<3 || bluff >= 80) && bluff > 15) { + // check + myAction = 2; + } + // BET --> wenn Potential hoch + else { + if(bluff <= 5) mySet = (bluff+1) * currentHand->getSmallBlind(); + else { + if(bluff <=15 ) mySet = 4 * currentHand->getSmallBlind(); + // je höher das Potential, desto höher der Einsatz (zur Basis SmallBlind) + else mySet = (potential-1) * 2 * currentHand->getSmallBlind(); + } - // All In - if(mySet >= myCash) { - mySet = myCash; - myCash = 0; - myAction = 6; + // All In + if(mySet >= myCash) { + mySet = myCash; + myCash = 0; + myAction = 6; - } - // sonst - else { - myCash -= mySet; - myAction = 4; - } - currentHand->getCurrentBeRo()->setHighestSet(mySet); - } + } + // sonst + else { + myCash -= mySet; + myAction = 4; + } + currentHand->getCurrentBeRo()->setHighestSet(mySet); + } - } - // CALL und RAISE --> wenn bereits gesetzt wurde - else { - // RAISE --> wenn Potential besonders gut - if((potential >=4 && 2 * tempFold * currentHand->getSmallBlind() >= currentHand->getCurrentBeRo()->getHighestSet()) || (bluff <= 5 && 4 * tempFold * currentHand->getSmallBlind() >= currentHand->getCurrentBeRo()->getHighestSet())) { + } + // CALL und RAISE --> wenn bereits gesetzt wurde + else { + // RAISE --> wenn Potential besonders gut + if((potential >=4 && 2 * tempFold * currentHand->getSmallBlind() >= currentHand->getCurrentBeRo()->getHighestSet()) || (bluff <= 5 && 4 * tempFold * currentHand->getSmallBlind() >= currentHand->getCurrentBeRo()->getHighestSet())) { int raise = 0; // bluff - raise - if(bluff <=5) raise = ((bluff+1)/2) * currentHand->getCurrentBeRo()->getHighestSet(); - // Betrag, der ber dem aktuell HighestSet gesetzt werden soll - else raise = ((potential - 2 ) / 2) * currentHand->getCurrentBeRo()->getHighestSet(); + if(bluff <=5) raise = ((bluff+1)/2) * currentHand->getCurrentBeRo()->getHighestSet(); + // Betrag, der ber dem aktuell HighestSet gesetzt werden soll + else raise = ((potential - 2 ) / 2) * currentHand->getCurrentBeRo()->getHighestSet(); - // All In - if(currentHand->getCurrentBeRo()->getHighestSet() + raise >= myCash) { + // All In + if(currentHand->getCurrentBeRo()->getHighestSet() + raise >= myCash) { - mySet += myCash; - myCash = 0; - myAction = 6; - if(mySet > currentHand->getCurrentBeRo()->getHighestSet()) currentHand->getCurrentBeRo()->setHighestSet(mySet); + mySet += myCash; + myCash = 0; + myAction = 6; + if(mySet > currentHand->getCurrentBeRo()->getHighestSet()) currentHand->getCurrentBeRo()->setHighestSet(mySet); - } - // sonst - else { + } + // sonst + else { - myCash = myCash + mySet - currentHand->getCurrentBeRo()->getHighestSet() - raise; - mySet = currentHand->getCurrentBeRo()->getHighestSet() + raise; - currentHand->getCurrentBeRo()->setHighestSet(mySet); - myAction = 5; - } - } - // CALL --> bei normalen Potential - else { + myCash = myCash + mySet - currentHand->getCurrentBeRo()->getHighestSet() - raise; + mySet = currentHand->getCurrentBeRo()->getHighestSet() + raise; + currentHand->getCurrentBeRo()->setHighestSet(mySet); + myAction = 5; + } + } + // CALL --> bei normalen Potential + else { - // All In - if(currentHand->getCurrentBeRo()->getHighestSet() >= myCash) { + // All In + if(currentHand->getCurrentBeRo()->getHighestSet() >= myCash) { - mySet += myCash; - myCash = 0; - myAction = 6; + mySet += myCash; + myCash = 0; + myAction = 6; - } - // sonst - else { - myCash = myCash - currentHand->getCurrentBeRo()->getHighestSet() + mySet; - mySet = currentHand->getCurrentBeRo()->getHighestSet(); - myAction = 3; - } - } - } - } + } + // sonst + else { + myCash = myCash - currentHand->getCurrentBeRo()->getHighestSet() + mySet; + mySet = currentHand->getCurrentBeRo()->getHighestSet(); + myAction = 3; + } + } + } + } } -void LocalPlayer::turnEngine3() { +void LocalPlayer::turnEngine3() +{ - // Prozent ausrechnen + // Prozent ausrechnen - int i, j, k; - int tempBoardCardsArray[5]; - int tempMyCardsArray[7]; - int tempOpponentCardsArray[7]; + int i, j, k; + int tempBoardCardsArray[5]; + int tempMyCardsArray[7]; + int tempOpponentCardsArray[7]; currentHand->getBoard()->getMyCards(tempBoardCardsArray); - tempMyCardsArray[0] = myCards[0]; - tempMyCardsArray[1] = myCards[1]; - tempMyCardsArray[2] = tempBoardCardsArray[0]; - tempMyCardsArray[3] = tempBoardCardsArray[1]; - tempMyCardsArray[4] = tempBoardCardsArray[2]; - tempMyCardsArray[5] = tempBoardCardsArray[3]; + tempMyCardsArray[0] = myCards[0]; + tempMyCardsArray[1] = myCards[1]; + tempMyCardsArray[2] = tempBoardCardsArray[0]; + tempMyCardsArray[3] = tempBoardCardsArray[1]; + tempMyCardsArray[4] = tempBoardCardsArray[2]; + tempMyCardsArray[5] = tempBoardCardsArray[3]; - tempOpponentCardsArray[2] = tempBoardCardsArray[0]; - tempOpponentCardsArray[3] = tempBoardCardsArray[1]; - tempOpponentCardsArray[4] = tempBoardCardsArray[2]; - tempOpponentCardsArray[5] = tempBoardCardsArray[3]; + tempOpponentCardsArray[2] = tempBoardCardsArray[0]; + tempOpponentCardsArray[3] = tempBoardCardsArray[1]; + tempOpponentCardsArray[4] = tempBoardCardsArray[2]; + tempOpponentCardsArray[5] = tempBoardCardsArray[3]; - int tempMyCardsValue; - int tempOpponentCardsValue; + int tempMyCardsValue; + int tempOpponentCardsValue; - int countAll = 0; - int countMy = 0; + int countAll = 0; + int countMy = 0; - for(i=0; i<49; i++) { - if(i != myCards[0] && i != myCards[1] && i != tempBoardCardsArray[0] && i != tempBoardCardsArray[1] && i != tempBoardCardsArray[2]) { - for(j=i+1; j<50; j++) { - if(j != myCards[0] && j != myCards[1] && j != tempBoardCardsArray[0] && j != tempBoardCardsArray[1] && j != tempBoardCardsArray[2]) { - for(k=j+1; k<51; k++) { - if(k != myCards[0] && k != myCards[1] && k != tempBoardCardsArray[0] && k != tempBoardCardsArray[1] && k != tempBoardCardsArray[2]) { + for(i=0; i<49; i++) { + if(i != myCards[0] && i != myCards[1] && i != tempBoardCardsArray[0] && i != tempBoardCardsArray[1] && i != tempBoardCardsArray[2]) { + for(j=i+1; j<50; j++) { + if(j != myCards[0] && j != myCards[1] && j != tempBoardCardsArray[0] && j != tempBoardCardsArray[1] && j != tempBoardCardsArray[2]) { + for(k=j+1; k<51; k++) { + if(k != myCards[0] && k != myCards[1] && k != tempBoardCardsArray[0] && k != tempBoardCardsArray[1] && k != tempBoardCardsArray[2]) { - countAll++; + countAll++; - tempOpponentCardsArray[0] = i; - tempOpponentCardsArray[1] = j; - tempOpponentCardsArray[6] = k; - tempMyCardsArray[6] = k; - tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); - tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); + tempOpponentCardsArray[0] = i; + tempOpponentCardsArray[1] = j; + tempOpponentCardsArray[6] = k; + tempMyCardsArray[6] = k; + tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); + tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); - if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; - } - } - } - } - } - } + if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; + } + } + } + } + } + } - double percent = (countMy*1.0)/(countAll*1.0); - // cout << "Prozent: " << percent << endl; + double percent = (countMy*1.0)/(countAll*1.0); + // cout << "Prozent: " << percent << endl; - // Bauchgefhl (zufᅵlig) - int tempRand; - Tools::getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0); + // Bauchgefhl (zufᅵlig) + int tempRand; + Tools::getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0); - // bluff, checkbluff - int bluff; - Tools::getRandNumber(1,100,1,&bluff,0); + // bluff, checkbluff + int bluff; + Tools::getRandNumber(1,100,1,&bluff,0); - // cout << "turn-bluff " << bluff << endl; + // cout << "turn-bluff " << bluff << endl; - // Potential - int potential = (10*(5*(int)(percent*100.)+10*tempRand*2))/700-myDude; + // Potential + int potential = (10*(5*(int)(percent*100.)+10*tempRand*2))/700-myDude; - int setToHighest = currentHand->getCurrentBeRo()->getHighestSet() - mySet; + int setToHighest = currentHand->getCurrentBeRo()->getHighestSet() - mySet; - // temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist - int tempFold; - // tempFold = (currentHand->getPlayerArray()[0]->getMyAverageSets())/(7*currentHand->getSmallBlind()); - Tools::getRandNumber(3,4,1,&tempFold,0); + // temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist + int tempFold; + // tempFold = (currentHand->getPlayerArray()[0]->getMyAverageSets())/(7*currentHand->getSmallBlind()); + Tools::getRandNumber(3,4,1,&tempFold,0); - // FOLD - // --> wenn potential negativ oder HighestSet zu hoch - if( (potential*setToHighest<0 || (setToHighest > tempFold * currentHand->getSmallBlind() && potential<1) || (setToHighest > 3 * tempFold * currentHand->getSmallBlind() && potential<2) || (setToHighest > 9 * tempFold * currentHand->getSmallBlind() && potential<3) || (setToHighest > 20*tempFold * currentHand->getSmallBlind() && potential<4) || (setToHighest > 40 *tempFold * currentHand->getSmallBlind() && potential<5)) && percent < 0.90 && bluff > 15) { - myAction=1; - } - else { - // CHECK und BET --> wenn noch keiner was gesetzt hat - if(currentHand->getCurrentBeRo()->getHighestSet() == 0) { - // CHECK --> wenn Potential klein - if((potential<2 || bluff >= 80) && bluff > 10) { - // check - myAction = 2; - } - // BET --> wenn Potential hoch - else { + // FOLD + // --> wenn potential negativ oder HighestSet zu hoch + if( (potential*setToHighest<0 || (setToHighest > tempFold * currentHand->getSmallBlind() && potential<1) || (setToHighest > 3 * tempFold * currentHand->getSmallBlind() && potential<2) || (setToHighest > 9 * tempFold * currentHand->getSmallBlind() && potential<3) || (setToHighest > 20*tempFold * currentHand->getSmallBlind() && potential<4) || (setToHighest > 40 *tempFold * currentHand->getSmallBlind() && potential<5)) && percent < 0.90 && bluff > 15) { + myAction=1; + } else { + // CHECK und BET --> wenn noch keiner was gesetzt hat + if(currentHand->getCurrentBeRo()->getHighestSet() == 0) { + // CHECK --> wenn Potential klein + if((potential<2 || bluff >= 80) && bluff > 10) { + // check + myAction = 2; + } + // BET --> wenn Potential hoch + else { - if(bluff <= 3) mySet = bluff * 2 * currentHand->getSmallBlind(); - else { - if(bluff <=10 ) mySet = ((bluff+2)/3) * currentHand->getSmallBlind(); - // je hᅵer das Potential, desto hᅵher der Einsatz (zur Basis SmallBlind) - else mySet = (potential-1) * 3 * currentHand->getSmallBlind(); - } + if(bluff <= 3) mySet = bluff * 2 * currentHand->getSmallBlind(); + else { + if(bluff <=10 ) mySet = ((bluff+2)/3) * currentHand->getSmallBlind(); + // je hᅵer das Potential, desto hᅵher der Einsatz (zur Basis SmallBlind) + else mySet = (potential-1) * 3 * currentHand->getSmallBlind(); + } - // All In - if(mySet >= myCash) { - mySet = myCash; - myCash = 0; - myAction = 6; + // All In + if(mySet >= myCash) { + mySet = myCash; + myCash = 0; + myAction = 6; - } - // sonst - else { - myCash -= mySet; - myAction = 4; - } - currentHand->getCurrentBeRo()->setHighestSet(mySet); - } + } + // sonst + else { + myCash -= mySet; + myAction = 4; + } + currentHand->getCurrentBeRo()->setHighestSet(mySet); + } - } - // CALL und RAISE --> wenn bereits gesetzt wurde - else { - // RAISE --> wenn Potential besonders gut - if((potential >=4 && 2 * tempFold * currentHand->getSmallBlind() >= currentHand->getCurrentBeRo()->getHighestSet()) || (bluff <= 4 && 3 * tempFold * currentHand->getSmallBlind() >= currentHand->getCurrentBeRo()->getHighestSet())) { + } + // CALL und RAISE --> wenn bereits gesetzt wurde + else { + // RAISE --> wenn Potential besonders gut + if((potential >=4 && 2 * tempFold * currentHand->getSmallBlind() >= currentHand->getCurrentBeRo()->getHighestSet()) || (bluff <= 4 && 3 * tempFold * currentHand->getSmallBlind() >= currentHand->getCurrentBeRo()->getHighestSet())) { int raise = 0; // bluff - raise - if(bluff <= 4) raise = ((bluff+1)/2) * currentHand->getCurrentBeRo()->getHighestSet(); - // Betrag, der ber dem aktuell HighestSet gesetzt werden soll - else raise = ( potential - 3 ) * currentHand->getCurrentBeRo()->getHighestSet(); + if(bluff <= 4) raise = ((bluff+1)/2) * currentHand->getCurrentBeRo()->getHighestSet(); + // Betrag, der ber dem aktuell HighestSet gesetzt werden soll + else raise = ( potential - 3 ) * currentHand->getCurrentBeRo()->getHighestSet(); - // All In - if(currentHand->getCurrentBeRo()->getHighestSet() + raise >= myCash) { + // All In + if(currentHand->getCurrentBeRo()->getHighestSet() + raise >= myCash) { - mySet += myCash; - myCash = 0; - myAction = 6; - if(mySet > currentHand->getCurrentBeRo()->getHighestSet()) currentHand->getCurrentBeRo()->setHighestSet(mySet); + mySet += myCash; + myCash = 0; + myAction = 6; + if(mySet > currentHand->getCurrentBeRo()->getHighestSet()) currentHand->getCurrentBeRo()->setHighestSet(mySet); - } - // sonst - else { + } + // sonst + else { - myCash = myCash + mySet - currentHand->getCurrentBeRo()->getHighestSet() - raise; - mySet = currentHand->getCurrentBeRo()->getHighestSet() + raise; - currentHand->getCurrentBeRo()->setHighestSet(mySet); - myAction = 5; - } - } - // CALL --> bei normalen Potential - else { - // All In - if(currentHand->getCurrentBeRo()->getHighestSet() >= myCash) { + myCash = myCash + mySet - currentHand->getCurrentBeRo()->getHighestSet() - raise; + mySet = currentHand->getCurrentBeRo()->getHighestSet() + raise; + currentHand->getCurrentBeRo()->setHighestSet(mySet); + myAction = 5; + } + } + // CALL --> bei normalen Potential + else { + // All In + if(currentHand->getCurrentBeRo()->getHighestSet() >= myCash) { - mySet += myCash; - myCash = 0; - myAction = 6; + mySet += myCash; + myCash = 0; + myAction = 6; - } - // sonst - else { - myCash = myCash - currentHand->getCurrentBeRo()->getHighestSet() + mySet; - mySet = currentHand->getCurrentBeRo()->getHighestSet(); - myAction = 3; - } - } - } - } + } + // sonst + else { + myCash = myCash - currentHand->getCurrentBeRo()->getHighestSet() + mySet; + mySet = currentHand->getCurrentBeRo()->getHighestSet(); + myAction = 3; + } + } + } + } } -void LocalPlayer::riverEngine3() { +void LocalPlayer::riverEngine3() +{ - // Prozent ausrechnen + // Prozent ausrechnen - int i, j; - int tempBoardCardsArray[5]; - int tempMyCardsArray[7]; - int tempOpponentCardsArray[7]; + int i, j; + int tempBoardCardsArray[5]; + int tempMyCardsArray[7]; + int tempOpponentCardsArray[7]; currentHand->getBoard()->getMyCards(tempBoardCardsArray); - tempMyCardsArray[0] = myCards[0]; - tempMyCardsArray[1] = myCards[1]; - tempMyCardsArray[2] = tempBoardCardsArray[0]; - tempMyCardsArray[3] = tempBoardCardsArray[1]; - tempMyCardsArray[4] = tempBoardCardsArray[2]; - tempMyCardsArray[5] = tempBoardCardsArray[3]; - tempMyCardsArray[6] = tempBoardCardsArray[4]; + tempMyCardsArray[0] = myCards[0]; + tempMyCardsArray[1] = myCards[1]; + tempMyCardsArray[2] = tempBoardCardsArray[0]; + tempMyCardsArray[3] = tempBoardCardsArray[1]; + tempMyCardsArray[4] = tempBoardCardsArray[2]; + tempMyCardsArray[5] = tempBoardCardsArray[3]; + tempMyCardsArray[6] = tempBoardCardsArray[4]; - tempOpponentCardsArray[2] = tempBoardCardsArray[0]; - tempOpponentCardsArray[3] = tempBoardCardsArray[1]; - tempOpponentCardsArray[4] = tempBoardCardsArray[2]; - tempOpponentCardsArray[5] = tempBoardCardsArray[3]; - tempOpponentCardsArray[6] = tempBoardCardsArray[4]; + tempOpponentCardsArray[2] = tempBoardCardsArray[0]; + tempOpponentCardsArray[3] = tempBoardCardsArray[1]; + tempOpponentCardsArray[4] = tempBoardCardsArray[2]; + tempOpponentCardsArray[5] = tempBoardCardsArray[3]; + tempOpponentCardsArray[6] = tempBoardCardsArray[4]; - int tempMyCardsValue; - int tempOpponentCardsValue; + int tempMyCardsValue; + int tempOpponentCardsValue; - int countAll = 0; - int countMy = 0; + int countAll = 0; + int countMy = 0; - for(i=0; i<49; i++) { - if(i != myCards[0] && i != myCards[1] && i != tempBoardCardsArray[0] && i != tempBoardCardsArray[1] && i != tempBoardCardsArray[2]) { - for(j=i+1; j<50; j++) { - if(j != myCards[0] && j != myCards[1] && j != tempBoardCardsArray[0] && j != tempBoardCardsArray[1] && j != tempBoardCardsArray[2]) { + for(i=0; i<49; i++) { + if(i != myCards[0] && i != myCards[1] && i != tempBoardCardsArray[0] && i != tempBoardCardsArray[1] && i != tempBoardCardsArray[2]) { + for(j=i+1; j<50; j++) { + if(j != myCards[0] && j != myCards[1] && j != tempBoardCardsArray[0] && j != tempBoardCardsArray[1] && j != tempBoardCardsArray[2]) { - countAll++; + countAll++; - tempOpponentCardsArray[0] = i; - tempOpponentCardsArray[1] = j; - tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); - tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); + tempOpponentCardsArray[0] = i; + tempOpponentCardsArray[1] = j; + tempMyCardsValue = myCardsValue->cardsValue(tempMyCardsArray,0); + tempOpponentCardsValue = myCardsValue->cardsValue(tempOpponentCardsArray,0); - if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; - } - } - } - } + if(tempMyCardsValue>=tempOpponentCardsValue) countMy++; + } + } + } + } - double percent = (countMy*1.0)/(countAll*1.0); - // cout << "Prozent: " << percent << endl; + double percent = (countMy*1.0)/(countAll*1.0); + // cout << "Prozent: " << percent << endl; - // Bauchgefhl (zufᅵlig) - int tempRand; - Tools::getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0); + // Bauchgefhl (zufᅵlig) + int tempRand; + Tools::getRandNumber((int)(percent*10.)-2,(int)(percent*10.)+2,1,&tempRand,0); - // bluff, checkbluff - int bluff; - Tools::getRandNumber(1,100,1,&bluff,0); + // bluff, checkbluff + int bluff; + Tools::getRandNumber(1,100,1,&bluff,0); - // cout << "river-bluff " << bluff << endl; + // cout << "river-bluff " << bluff << endl; - // Potential - int potential = (10*(5*(int)(percent*100.)+10*tempRand*1))/600-myDude; + // Potential + int potential = (10*(5*(int)(percent*100.)+10*tempRand*1))/600-myDude; - int setToHighest = currentHand->getCurrentBeRo()->getHighestSet() - mySet; + int setToHighest = currentHand->getCurrentBeRo()->getHighestSet() - mySet; - // temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist - int tempFold; - // tempFold = (currentHand->getPlayerArray()[0]->getMyAverageSets())/(6*currentHand->getSmallBlind()); - Tools::getRandNumber(4,6,1,&tempFold,0); + // temp fr das Vielfache des Small Blind, sodass HighestSet zu hoch ist + int tempFold; + // tempFold = (currentHand->getPlayerArray()[0]->getMyAverageSets())/(6*currentHand->getSmallBlind()); + Tools::getRandNumber(4,6,1,&tempFold,0); - // FOLD - // --> wenn potential negativ oder HighestSet zu hoch - if( (potential*setToHighest<0 || (setToHighest > tempFold * currentHand->getSmallBlind() && potential<1) || (setToHighest > 3 * tempFold * currentHand->getSmallBlind() && potential<2) || (setToHighest > 9 * tempFold * currentHand->getSmallBlind() && potential<3) || (setToHighest > 20*tempFold * currentHand->getSmallBlind() && potential<4) || (setToHighest > 40 *tempFold * currentHand->getSmallBlind() && potential<5)) && percent < 0.90 && bluff > 15) { - myAction=1; - } - else { - // CHECK und BET --> wenn noch keiner was gesetzt hat - if(currentHand->getCurrentBeRo()->getHighestSet() == 0) { - // CHECK --> wenn Potential klein - if((potential<2 || bluff >= 92) && bluff > 15) { - // check - myAction = 2; - } - // BET --> wenn Potential hoch - else { + // FOLD + // --> wenn potential negativ oder HighestSet zu hoch + if( (potential*setToHighest<0 || (setToHighest > tempFold * currentHand->getSmallBlind() && potential<1) || (setToHighest > 3 * tempFold * currentHand->getSmallBlind() && potential<2) || (setToHighest > 9 * tempFold * currentHand->getSmallBlind() && potential<3) || (setToHighest > 20*tempFold * currentHand->getSmallBlind() && potential<4) || (setToHighest > 40 *tempFold * currentHand->getSmallBlind() && potential<5)) && percent < 0.90 && bluff > 15) { + myAction=1; + } else { + // CHECK und BET --> wenn noch keiner was gesetzt hat + if(currentHand->getCurrentBeRo()->getHighestSet() == 0) { + // CHECK --> wenn Potential klein + if((potential<2 || bluff >= 92) && bluff > 15) { + // check + myAction = 2; + } + // BET --> wenn Potential hoch + else { - if(bluff <= 5) mySet = (bluff+3) * currentHand->getSmallBlind(); - else { - if(bluff <= 15 ) mySet = ((bluff-1)/5) * 2 * currentHand->getSmallBlind(); - // je hᅵer das Potential, desto hᅵher der Einsatz (zur Basis SmallBlind) - else mySet = (potential-1) * 4 * currentHand->getSmallBlind(); - } + if(bluff <= 5) mySet = (bluff+3) * currentHand->getSmallBlind(); + else { + if(bluff <= 15 ) mySet = ((bluff-1)/5) * 2 * currentHand->getSmallBlind(); + // je hᅵer das Potential, desto hᅵher der Einsatz (zur Basis SmallBlind) + else mySet = (potential-1) * 4 * currentHand->getSmallBlind(); + } - // All In - if(mySet >= myCash) { - mySet = myCash; - myCash = 0; - myAction = 6; + // All In + if(mySet >= myCash) { + mySet = myCash; + myCash = 0; + myAction = 6; - } - // sonst - else { - myCash -= mySet; - myAction = 4; - } - currentHand->getCurrentBeRo()->setHighestSet(mySet); - } + } + // sonst + else { + myCash -= mySet; + myAction = 4; + } + currentHand->getCurrentBeRo()->setHighestSet(mySet); + } - } - // CALL und RAISE --> wenn bereits gesetzt wurde - else { - // RAISE --> wenn Potential besonders gut - if((potential >=4 && 2 * tempFold * currentHand->getSmallBlind() >= currentHand->getCurrentBeRo()->getHighestSet()) || (bluff <= 2 && 4 * tempFold * currentHand->getSmallBlind() >= currentHand->getCurrentBeRo()->getHighestSet())) { + } + // CALL und RAISE --> wenn bereits gesetzt wurde + else { + // RAISE --> wenn Potential besonders gut + if((potential >=4 && 2 * tempFold * currentHand->getSmallBlind() >= currentHand->getCurrentBeRo()->getHighestSet()) || (bluff <= 2 && 4 * tempFold * currentHand->getSmallBlind() >= currentHand->getCurrentBeRo()->getHighestSet())) { int raise = 0; // bluff - raise - if(bluff <= 2 ) raise = bluff * currentHand->getCurrentBeRo()->getHighestSet(); - // Betrag, der ber dem aktuell HighestSet gesetzt werden soll - else raise = ( potential - 3 ) * currentHand->getCurrentBeRo()->getHighestSet(); + if(bluff <= 2 ) raise = bluff * currentHand->getCurrentBeRo()->getHighestSet(); + // Betrag, der ber dem aktuell HighestSet gesetzt werden soll + else raise = ( potential - 3 ) * currentHand->getCurrentBeRo()->getHighestSet(); - // All In - if(currentHand->getCurrentBeRo()->getHighestSet() + raise >= myCash) { + // All In + if(currentHand->getCurrentBeRo()->getHighestSet() + raise >= myCash) { - mySet += myCash; - myCash = 0; - myAction = 6; - if(mySet > currentHand->getCurrentBeRo()->getHighestSet()) currentHand->getCurrentBeRo()->setHighestSet(mySet); + mySet += myCash; + myCash = 0; + myAction = 6; + if(mySet > currentHand->getCurrentBeRo()->getHighestSet()) currentHand->getCurrentBeRo()->setHighestSet(mySet); - } - // sonst - else { + } + // sonst + else { - myCash = myCash + mySet - currentHand->getCurrentBeRo()->getHighestSet() - raise; - mySet = currentHand->getCurrentBeRo()->getHighestSet() + raise; - currentHand->getCurrentBeRo()->setHighestSet(mySet); - myAction = 5; - } - } - // CALL --> bei normalen Potential - else { - // All In - if(currentHand->getCurrentBeRo()->getHighestSet() >= myCash) { + myCash = myCash + mySet - currentHand->getCurrentBeRo()->getHighestSet() - raise; + mySet = currentHand->getCurrentBeRo()->getHighestSet() + raise; + currentHand->getCurrentBeRo()->setHighestSet(mySet); + myAction = 5; + } + } + // CALL --> bei normalen Potential + else { + // All In + if(currentHand->getCurrentBeRo()->getHighestSet() >= myCash) { - mySet += myCash; - myCash = 0; - myAction = 6; + mySet += myCash; + myCash = 0; + myAction = 6; - } - // sonst - else { - myCash = myCash - currentHand->getCurrentBeRo()->getHighestSet() + mySet; - mySet = currentHand->getCurrentBeRo()->getHighestSet(); - myAction = 3; - } - } - } - } + } + // sonst + else { + myCash = myCash - currentHand->getCurrentBeRo()->getHighestSet() + mySet; + mySet = currentHand->getCurrentBeRo()->getHighestSet(); + myAction = 3; + } + } + } + } } void LocalPlayer::setNetSessionData(boost::shared_ptr session) { - myNetSessionData = session; + myNetSessionData = session; } boost::shared_ptr LocalPlayer::getNetSessionData() { - return myNetSessionData; + return myNetSessionData; } unsigned @@ -5131,10 +5141,9 @@ LocalPlayer::resetActionTimeoutCounter() bool LocalPlayer::checkIfINeedToShowCards() { std::list playerNeedToShowCardsList = currentHand->getBoard()->getPlayerNeedToShowCards(); - for(std::list::iterator it = playerNeedToShowCardsList.begin(); it != playerNeedToShowCardsList.end(); ++it) - { - if(*it == myUniqueID) return true; - } + for(std::list::iterator it = playerNeedToShowCardsList.begin(); it != playerNeedToShowCardsList.end(); ++it) { + if(*it == myUniqueID) return true; + } - return false; + return false; } diff --git a/src/engine/local_engine/localplayer.h b/src/engine/local_engine/localplayer.h index 82a2616f..e79d3151 100755 --- a/src/engine/local_engine/localplayer.h +++ b/src/engine/local_engine/localplayer.h @@ -30,7 +30,8 @@ class CardsValue; class ConfigFile; class HandInterface; -class LocalPlayer : public PlayerInterface{ +class LocalPlayer : public PlayerInterface +{ public: LocalPlayer(ConfigFile*, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); @@ -38,93 +39,179 @@ public: void setHand(HandInterface *); - int getMyID() const { return myID; } - unsigned getMyUniqueID() const { return myUniqueID; } - PlayerType getMyType() const { return myType; } - - void setMyDude(int theValue) { myDude = theValue; } - int getMyDude() const { return myDude; } - - void setMyDude4(int theValue) { myDude4 = theValue; } - int getMyDude4() const { return myDude4; } - - void setMyName(const std::string& theValue) { myName = theValue; } - std::string getMyName() const { return myName; } - - void setMyAvatar(const std::string& theValue) { myAvatar = theValue; } - std::string getMyAvatar() const { return myAvatar; } - - void setMyCash(int theValue) { myCash = theValue; } - int getMyCash() const { return myCash; } - - void setMySet(int theValue) { myLastRelativeSet = theValue; mySet += theValue; myCash -= theValue; } - void setMySetAbsolute(int theValue) { mySet = theValue; } - void setMySetNull() { mySet = 0; myLastRelativeSet = 0; } - int getMySet() const { return mySet;} - int getMyLastRelativeSet() const { return myLastRelativeSet; } - - void setMyAction(int theValue, bool blind = 0) { - myAction = theValue; - // logging for human player - if(myAction && !blind) currentHand->getGuiInterface()->logPlayerActionMsg(myName, myID, myAction, mySet); + int getMyID() const { + return myID; + } + unsigned getMyUniqueID() const { + return myUniqueID; + } + PlayerType getMyType() const { + return myType; } - int getMyAction() const { return myAction; } - void setMyButton(int theValue) { myButton = theValue; } - int getMyButton() const { return myButton; } + void setMyDude(int theValue) { + myDude = theValue; + } + int getMyDude() const { + return myDude; + } - void setMyActiveStatus(bool theValue) { myActiveStatus = theValue; } - bool getMyActiveStatus() const { return myActiveStatus; } + void setMyDude4(int theValue) { + myDude4 = theValue; + } + int getMyDude4() const { + return myDude4; + } - void setMyStayOnTableStatus(bool theValue) { myStayOnTableStatus = theValue; } - bool getMyStayOnTableStatus() const { return myStayOnTableStatus; } + void setMyName(const std::string& theValue) { + myName = theValue; + } + std::string getMyName() const { + return myName; + } - void setMyCards(int* theValue) { int i; for(i=0; i<2; i++) myCards[i] = theValue[i]; } - void getMyCards(int* theValue) const { int i; for(i=0; i<2; i++) theValue[i] = myCards[i]; } + void setMyAvatar(const std::string& theValue) { + myAvatar = theValue; + } + std::string getMyAvatar() const { + return myAvatar; + } - void setMyTurn(bool theValue){ myTurn = theValue;} - bool getMyTurn() const{ return myTurn;} + void setMyCash(int theValue) { + myCash = theValue; + } + int getMyCash() const { + return myCash; + } - void setMyCardsFlip(bool theValue, int state){ + void setMySet(int theValue) { + myLastRelativeSet = theValue; + mySet += theValue; + myCash -= theValue; + } + void setMySetAbsolute(int theValue) { + mySet = theValue; + } + void setMySetNull() { + mySet = 0; + myLastRelativeSet = 0; + } + int getMySet() const { + return mySet; + } + int getMyLastRelativeSet() const { + return myLastRelativeSet; + } + + void setMyAction(int theValue, bool blind = 0) { + myAction = theValue; + // logging for human player + if(myAction && !blind) currentHand->getGuiInterface()->logPlayerActionMsg(myName, myID, myAction, mySet); + } + int getMyAction() const { + return myAction; + } + + void setMyButton(int theValue) { + myButton = theValue; + } + int getMyButton() const { + return myButton; + } + + void setMyActiveStatus(bool theValue) { + myActiveStatus = theValue; + } + bool getMyActiveStatus() const { + return myActiveStatus; + } + + void setMyStayOnTableStatus(bool theValue) { + myStayOnTableStatus = theValue; + } + bool getMyStayOnTableStatus() const { + return myStayOnTableStatus; + } + + void setMyCards(int* theValue) { + int i; + for(i=0; i<2; i++) myCards[i] = theValue[i]; + } + void getMyCards(int* theValue) const { + int i; + for(i=0; i<2; i++) theValue[i] = myCards[i]; + } + + void setMyTurn(bool theValue) { + myTurn = theValue; + } + bool getMyTurn() const { + return myTurn; + } + + void setMyCardsFlip(bool theValue, int state) { myCardsFlip = theValue; // log flipping cards if(myCardsFlip) { switch(state) { - case 1: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt); + case 1: + currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt); break; - case 2: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]); + case 2: + currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]); break; - case 3: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt, "has"); + case 3: + currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt, "has"); break; - default: ; + default: + ; } } } - bool getMyCardsFlip() const{ return myCardsFlip;} + bool getMyCardsFlip() const { + return myCardsFlip; + } - void setMyCardsValueInt(int theValue) { myCardsValueInt = theValue;} - int getMyCardsValueInt() const { return myCardsValueInt; } + void setMyCardsValueInt(int theValue) { + myCardsValueInt = theValue; + } + int getMyCardsValueInt() const { + return myCardsValueInt; + } - void setMyBestHandPosition(int* theValue) - { + void setMyBestHandPosition(int* theValue) { for (int i = 0; i < 5; i++) myBestHandPosition[i] = theValue[i]; } - void getMyBestHandPosition(int* theValue) const - { + void getMyBestHandPosition(int* theValue) const { for (int i = 0; i < 5; i++) theValue[i] = myBestHandPosition[i]; } - void setMyRoundStartCash(int theValue) { myRoundStartCash = theValue;} - int getMyRoundStartCash() const { return myRoundStartCash; } + void setMyRoundStartCash(int theValue) { + myRoundStartCash = theValue; + } + int getMyRoundStartCash() const { + return myRoundStartCash; + } - void setLastMoneyWon ( int theValue ) { lastMoneyWon = theValue; } - int getLastMoneyWon() const { return lastMoneyWon; } + void setLastMoneyWon ( int theValue ) { + lastMoneyWon = theValue; + } + int getLastMoneyWon() const { + return lastMoneyWon; + } + + void setMyAverageSets(int theValue) { + myAverageSets[0] = myAverageSets[1]; + myAverageSets[1] = myAverageSets[2]; + myAverageSets[2] = myAverageSets[3]; + myAverageSets[3] = theValue; + } + int getMyAverageSets() const { + return (myAverageSets[0]+myAverageSets[1]+myAverageSets[2]+myAverageSets[3])/4; + } - void setMyAverageSets(int theValue) { myAverageSets[0] = myAverageSets[1]; myAverageSets[1] = myAverageSets[2]; myAverageSets[2] = myAverageSets[3]; myAverageSets[3] = theValue; } - int getMyAverageSets() const { return (myAverageSets[0]+myAverageSets[1]+myAverageSets[2]+myAverageSets[3])/4; } - void setMyAggressive(bool theValue) { int i; for(i=0; i<6; i++) { @@ -140,24 +227,34 @@ public: return sum; } - void setSBluff ( int theValue ) { sBluff = theValue; } - int getSBluff() const { return sBluff; } + void setSBluff ( int theValue ) { + sBluff = theValue; + } + int getSBluff() const { + return sBluff; + } - void setSBluffStatus ( bool theValue ) { sBluffStatus = theValue; } - bool getSBluffStatus() const { return sBluffStatus; } + void setSBluffStatus ( bool theValue ) { + sBluffStatus = theValue; + } + bool getSBluffStatus() const { + return sBluffStatus; + } void setMyWinnerState ( bool theValue, int pot ) { if(theValue) myWinnerState = theValue; - currentHand->getGuiInterface()->logPlayerWinsMsg(myName, pot, theValue); + currentHand->getGuiInterface()->logPlayerWinsMsg(myName, pot, theValue); } - bool getMyWinnerState() const { return myWinnerState;} - + bool getMyWinnerState() const { + return myWinnerState; + } + void action(); int checkMyAction(int targetAction, int targetBet, int highestSet, int minimumRaise, int smallBlind); - + void preflopEngine(); void flopEngine(); void turnEngine(); @@ -214,7 +311,7 @@ private: int myAction; // 0 = none, 1 = fold, 2 = check, 3 = call, 4 = bet, 5 = raise, 6 = allin int myButton; // 0 = none, 1 = dealer, 2 =small, 3 = big bool myActiveStatus; // 0 = inactive, 1 = active - bool myStayOnTableStatus; // 0 = left, 1 = stay + bool myStayOnTableStatus; // 0 = left, 1 = stay bool myTurn; // 0 = no, 1 = yes bool myCardsFlip; // 0 = cards are not fliped, 1 = cards are already flipped, int myRoundStartCash; @@ -225,7 +322,7 @@ private: int sBluff; bool sBluffStatus; - + bool myWinnerState; unsigned m_actionTimeoutCounter; diff --git a/src/engine/local_engine/replay.cpp b/src/engine/local_engine/replay.cpp index c7b25563..d02685a4 100644 --- a/src/engine/local_engine/replay.cpp +++ b/src/engine/local_engine/replay.cpp @@ -25,10 +25,10 @@ Replay::Replay() : replaySqliteLogDb(0) // replaySqliteLogDb = new QSqlDatabase(); // // *replaySqliteLogDb = QSqlDatabase::addDatabase("QSQLITE"); - //replaySqliteLogDb->setDatabaseName(myLogDir->absolutePath()+"/pokerth-log-"+currentTime.toString("yyyy-MM-dd_hh.mm.ss")+".pdb"); - //if(!mySqliteLogDb->open()) { - // QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel); - //} + //replaySqliteLogDb->setDatabaseName(myLogDir->absolutePath()+"/pokerth-log-"+currentTime.toString("yyyy-MM-dd_hh.mm.ss")+".pdb"); + //if(!mySqliteLogDb->open()) { + // QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel); + //} } diff --git a/src/engine/local_engine/replay.h b/src/engine/local_engine/replay.h index 6189b00f..10e74046 100644 --- a/src/engine/local_engine/replay.h +++ b/src/engine/local_engine/replay.h @@ -24,12 +24,12 @@ class Replay { - public: - Replay(); - ~Replay(); +public: + Replay(); + ~Replay(); private: - QSqlDatabase *replaySqliteLogDb; + QSqlDatabase *replaySqliteLogDb; }; diff --git a/src/engine/local_engine/tools.cpp b/src/engine/local_engine/tools.cpp index 5be0a825..f12c0aa9 100755 --- a/src/engine/local_engine/tools.cpp +++ b/src/engine/local_engine/tools.cpp @@ -27,7 +27,8 @@ using namespace std; -void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool different, int* bad, int countBad) { +void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool different, int* bad, int countBad) +{ int r = end-start+1; unsigned char rand_buf[4]; @@ -39,8 +40,7 @@ void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool for (i=0; i::max()) / r ) ) * r) { randNumber = randNumber % r; - if (tempArray[randNumber] == 1) { - - randArray[counter] = start + randNumber; + if (tempArray[randNumber] == 1) { + + randArray[counter] = start + randNumber; tempArray[randNumber] = 0; counter++; } } - + } delete[] tempArray; diff --git a/src/engine/local_engine/tools.h b/src/engine/local_engine/tools.h index 1357ce08..29515a29 100755 --- a/src/engine/local_engine/tools.h +++ b/src/engine/local_engine/tools.h @@ -20,7 +20,8 @@ #ifndef TOOLS_H #define TOOLS_H -class Tools{ +class Tools +{ public: static void getRandNumber(int, int, int, int*, bool, int* = 0, int = 0); diff --git a/src/engine/log.cpp b/src/engine/log.cpp index 82e9e9aa..33543810 100644 --- a/src/engine/log.cpp +++ b/src/engine/log.cpp @@ -32,238 +32,240 @@ using namespace std; Log::Log(string logDirString, int logOnOffInt) : curGameID(0), logOnOff(false) { - if(SQLITE_LOG) { + if(SQLITE_LOG) { - // logging activated - if(logOnOffInt) { + // logging activated + if(logOnOffInt) { - logOnOff = true; + logOnOff = true; - DIR *logDir; - logDir = opendir(logDirString.c_str()); + DIR *logDir; + logDir = opendir(logDirString.c_str()); bool dirExists = logDir != NULL; closedir(logDir); - // check if logging path exist + // check if logging path exist if(logDirString != "" && dirExists) { - string sql; - char *errmsg; + string sql; + char *errmsg; - // detect current time - char curDateTime[20]; - char curDate[11]; - char curTime[9]; - time_t now = time(NULL); - tm *z = localtime(&now); - strftime(curDateTime,20,"%Y-%m-%d_%H.%M.%S",z); - strftime(curDate,11,"%Y-%m-%d",z); - strftime(curTime,9,"%H:%M:%S",z); + // detect current time + char curDateTime[20]; + char curDate[11]; + char curTime[9]; + time_t now = time(NULL); + tm *z = localtime(&now); + strftime(curDateTime,20,"%Y-%m-%d_%H.%M.%S",z); + strftime(curDate,11,"%Y-%m-%d",z); + strftime(curTime,9,"%H:%M:%S",z); - string mySqliteLogFileName = boost::lexical_cast(logDirString.c_str()); - mySqliteLogFileName += "pokerth-log-" + boost::lexical_cast(curDateTime) + ".pdb"; + string mySqliteLogFileName = boost::lexical_cast(logDirString.c_str()); + mySqliteLogFileName += "pokerth-log-" + boost::lexical_cast(curDateTime) + ".pdb"; - // open sqlite-db - sqlite3_open(mySqliteLogFileName.data(), &mySqliteLogDb); - if( mySqliteLogDb != 0 ) { + // open sqlite-db + sqlite3_open(mySqliteLogFileName.data(), &mySqliteLogDb); + if( mySqliteLogDb != 0 ) { int i; // create session table - sql = "CREATE TABLE Session ("; - sql += "PokerTH_Version TEXT NOT NULL"; - sql += ",Date TEXT NOT NULL"; - sql += ",Time TEXT NOT NULL"; - sql += ", PRIMARY KEY(Date,Time))"; - if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { - cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; + sql = "CREATE TABLE Session ("; + sql += "PokerTH_Version TEXT NOT NULL"; + sql += ",Date TEXT NOT NULL"; + sql += ",Time TEXT NOT NULL"; + sql += ", PRIMARY KEY(Date,Time))"; + if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { + cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; sqlite3_free(errmsg); } - sql = "INSERT INTO Session ("; - sql += "PokerTH_Version"; - sql += ",Date"; - sql += ",Time"; - sql += ") VALUES ("; - sql += "\"" + boost::lexical_cast(POKERTH_BETA_RELEASE_STRING) + "\","; - sql += "\"" + boost::lexical_cast(curDate) + "\","; - sql += "\"" + boost::lexical_cast(curTime) + "\")"; - if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { - cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; + sql = "INSERT INTO Session ("; + sql += "PokerTH_Version"; + sql += ",Date"; + sql += ",Time"; + sql += ") VALUES ("; + sql += "\"" + boost::lexical_cast(POKERTH_BETA_RELEASE_STRING) + "\","; + sql += "\"" + boost::lexical_cast(curDate) + "\","; + sql += "\"" + boost::lexical_cast(curTime) + "\")"; + if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { + cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; sqlite3_free(errmsg); } - // create game table - sql = "CREATE TABLE Game ("; - sql += "GameID INTEGER NOT NULL PRIMARY KEY"; - sql += ",Startmoney INTEGER NOT NULL"; - sql += ",StartSb INTEGER NOT NULL"; - sql += ",DealerPos INTEGER NOT NULL"; - for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) { - sql += ",Seat_" + boost::lexical_cast(i) + " TEXT"; - } - sql += ",Winner_Seat INTEGER"; - sql += ")"; - if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { - cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; + // create game table + sql = "CREATE TABLE Game ("; + sql += "GameID INTEGER NOT NULL PRIMARY KEY"; + sql += ",Startmoney INTEGER NOT NULL"; + sql += ",StartSb INTEGER NOT NULL"; + sql += ",DealerPos INTEGER NOT NULL"; + for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) { + sql += ",Seat_" + boost::lexical_cast(i) + " TEXT"; + } + sql += ",Winner_Seat INTEGER"; + sql += ")"; + if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { + cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; sqlite3_free(errmsg); } - // create hand table - sql = "CREATE TABLE Hand ("; - sql += "HandID INTEGER NOT NULL"; - sql += ",GameID INTEGER NOT NULL"; - sql += ",Dealer_Seat INTEGER"; - sql += ",Sb_Amount INTEGER NOT NULL"; - sql += ",Sb_Seat INTEGER NOT NULL"; - sql += ",Bb_Amount INTEGER NOT NULL"; - sql += ",Bb_Seat INTEGER NOT NULL"; - for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) { - sql += ",Seat_" + boost::lexical_cast(i) + "_Cash INTEGER"; - sql += ",Seat_" + boost::lexical_cast(i) + "_Card_1 INTEGER"; - sql += ",Seat_" + boost::lexical_cast(i) + "_Card_2 INTEGER"; - sql += ",Seat_" + boost::lexical_cast(i) + "_Hand_text TEXT"; - sql += ",Seat_" + boost::lexical_cast(i) + "_Hand_int INTEGER"; - } - for(i=1; i<=5; i++) { - sql += ",BoardCard_" + boost::lexical_cast(i) + " INTEGER"; - } - sql += ",PRIMARY KEY(HandID,GameID))"; - if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { - cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; + // create hand table + sql = "CREATE TABLE Hand ("; + sql += "HandID INTEGER NOT NULL"; + sql += ",GameID INTEGER NOT NULL"; + sql += ",Dealer_Seat INTEGER"; + sql += ",Sb_Amount INTEGER NOT NULL"; + sql += ",Sb_Seat INTEGER NOT NULL"; + sql += ",Bb_Amount INTEGER NOT NULL"; + sql += ",Bb_Seat INTEGER NOT NULL"; + for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) { + sql += ",Seat_" + boost::lexical_cast(i) + "_Cash INTEGER"; + sql += ",Seat_" + boost::lexical_cast(i) + "_Card_1 INTEGER"; + sql += ",Seat_" + boost::lexical_cast(i) + "_Card_2 INTEGER"; + sql += ",Seat_" + boost::lexical_cast(i) + "_Hand_text TEXT"; + sql += ",Seat_" + boost::lexical_cast(i) + "_Hand_int INTEGER"; + } + for(i=1; i<=5; i++) { + sql += ",BoardCard_" + boost::lexical_cast(i) + " INTEGER"; + } + sql += ",PRIMARY KEY(HandID,GameID))"; + if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { + cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; sqlite3_free(errmsg); } - // create action table - sql = "CREATE TABLE Action ("; - sql += "ActionID INTEGER PRIMARY KEY AUTOINCREMENT"; - sql += ",HandID INTEGER NOT NULL"; - sql += ",GameID INTEGER NOT NULL"; - sql += ",BeRo INTEGER NOT NULL"; - sql += ",Player INTEGER NOT NULL"; - sql += ",Action TEXT NOT NULL"; - sql += ",Amount INTEGER"; - sql += ")"; - if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { - cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; + // create action table + sql = "CREATE TABLE Action ("; + sql += "ActionID INTEGER PRIMARY KEY AUTOINCREMENT"; + sql += ",HandID INTEGER NOT NULL"; + sql += ",GameID INTEGER NOT NULL"; + sql += ",BeRo INTEGER NOT NULL"; + sql += ",Player INTEGER NOT NULL"; + sql += ",Action TEXT NOT NULL"; + sql += ",Amount INTEGER"; + sql += ")"; + if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { + cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; sqlite3_free(errmsg); } - } + } - } + } - } + } - } + } } Log::~Log() { - if(SQLITE_LOG) { - sqlite3_close(mySqliteLogDb); - } + if(SQLITE_LOG) { + sqlite3_close(mySqliteLogDb); + } } void -Log::logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned dealerPosition, PlayerList seatsList) { +Log::logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned dealerPosition, PlayerList seatsList) +{ - curGameID = gameID; + curGameID = gameID; - if(SQLITE_LOG) { + if(SQLITE_LOG) { - if(logOnOff) { - //if write logfiles is enabled + if(logOnOff) { + //if write logfiles is enabled - PlayerListConstIterator it_c; - string sql; - char *errmsg; + PlayerListConstIterator it_c; + string sql; + char *errmsg; - if( mySqliteLogDb != 0 ) { - // sqlite-db is open + if( mySqliteLogDb != 0 ) { + // sqlite-db is open 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(i); - } - sql += ") VALUES ("; - sql += boost::lexical_cast(curGameID); - sql += "," + boost::lexical_cast(startCash); - sql += "," + boost::lexical_cast(startSmallBlind); - sql += "," + boost::lexical_cast(dealerPosition); - for(it_c = seatsList->begin();it_c!=seatsList->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; - } - } - } - } + 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(curGameID); + sql += "," + boost::lexical_cast(startCash); + sql += "," + boost::lexical_cast(startSmallBlind); + sql += "," + boost::lexical_cast(dealerPosition); + for(it_c = seatsList->begin(); it_c!=seatsList->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::logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned smallBlindPosition, int bigBlind, unsigned bigBlindPosition, PlayerList seatsList) { +Log::logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned smallBlindPosition, int bigBlind, unsigned bigBlindPosition, PlayerList seatsList) +{ - if(SQLITE_LOG) { + if(SQLITE_LOG) { - if(logOnOff) { - //if write logfiles is enabled + if(logOnOff) { + //if write logfiles is enabled - PlayerListConstIterator it_c; - string sql; - char *errmsg; + PlayerListConstIterator it_c; + string sql; + char *errmsg; - if( mySqliteLogDb != 0 ) { - // sqlite-db is open + if( mySqliteLogDb != 0 ) { + // sqlite-db is open int i; - sql = "INSERT INTO Hand ("; - sql += "HandID"; - sql += ",GameID"; - sql += ",Dealer_Seat"; - sql += ",Sb_Amount"; - sql += ",Sb_Seat"; - sql += ",Bb_Amount"; - sql += ",Bb_Seat"; - for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) { - sql += ",Seat_" + boost::lexical_cast(i) + "_Cash"; - } - sql += ") VALUES ("; - sql += boost::lexical_cast(handID); - sql += "," + boost::lexical_cast(curGameID); - sql += "," + boost::lexical_cast(dealerPosition+1); - sql += "," + boost::lexical_cast(smallBlind); - sql += "," + boost::lexical_cast(smallBlindPosition+1); - sql += "," + boost::lexical_cast(bigBlind); - sql += "," + boost::lexical_cast(bigBlindPosition+1); - for(it_c = seatsList->begin();it_c!=seatsList->end();it_c++) { - if((*it_c)->getMyActiveStatus()) { - sql += "," + boost::lexical_cast((*it_c)->getMyCash()); - } else { - sql += ",NULL"; - } - } - sql += ")"; - if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { - cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; - } + sql = "INSERT INTO Hand ("; + sql += "HandID"; + sql += ",GameID"; + sql += ",Dealer_Seat"; + sql += ",Sb_Amount"; + sql += ",Sb_Seat"; + sql += ",Bb_Amount"; + sql += ",Bb_Seat"; + for(i=1; i<=MAX_NUMBER_OF_PLAYERS; i++) { + sql += ",Seat_" + boost::lexical_cast(i) + "_Cash"; + } + sql += ") VALUES ("; + sql += boost::lexical_cast(handID); + sql += "," + boost::lexical_cast(curGameID); + sql += "," + boost::lexical_cast(dealerPosition+1); + sql += "," + boost::lexical_cast(smallBlind); + sql += "," + boost::lexical_cast(smallBlindPosition+1); + sql += "," + boost::lexical_cast(bigBlind); + sql += "," + boost::lexical_cast(bigBlindPosition+1); + for(it_c = seatsList->begin(); it_c!=seatsList->end(); it_c++) { + if((*it_c)->getMyActiveStatus()) { + sql += "," + boost::lexical_cast((*it_c)->getMyCash()); + } else { + sql += ",NULL"; + } + } + sql += ")"; + if(sqlite3_exec(mySqliteLogDb, sql.data(), 0, 0, &errmsg) != SQLITE_OK) { + cout << "Error in statement: " << sql.data() << "[" << errmsg << "]." << endl; + } - } + } - } + } - } + } } //void diff --git a/src/engine/log.h b/src/engine/log.h index 69c79747..552099b2 100644 --- a/src/engine/log.h +++ b/src/engine/log.h @@ -28,19 +28,19 @@ class Log { public: - Log(std::string logDirString, int logOnOffInt); + Log(std::string logDirString, int logOnOffInt); - ~Log(); + ~Log(); - 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 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 closeLogDbAtExit(); private: - sqlite3 *mySqliteLogDb; - int curGameID; - bool logOnOff; + sqlite3 *mySqliteLogDb; + int curGameID; + bool logOnOff; }; diff --git a/src/engine/network_engine/clientbero.cpp b/src/engine/network_engine/clientbero.cpp index 78ed3988..e2fad063 100644 --- a/src/engine/network_engine/clientbero.cpp +++ b/src/engine/network_engine/clientbero.cpp @@ -20,9 +20,9 @@ #include "clientbero.h" ClientBeRo::ClientBeRo(HandInterface* hi, int /*id*/, unsigned /*dP*/, int sB, GameState gS) -: BeRoInterface(), myBeRoID(gS), myHand(hi), highestCardsValue(0), smallBlindPositionId(0), bigBlindPositionId(0), currentPlayersTurnId(0), - firstRoundLastPlayersTurnId(0), highestSet(0), firstRound(true), smallBlindPosition(0), smallBlind(sB), minimumRaise(2*sB), fullBetRule(false), - lastActionPlayer(0) + : BeRoInterface(), myBeRoID(gS), myHand(hi), highestCardsValue(0), smallBlindPositionId(0), bigBlindPositionId(0), currentPlayersTurnId(0), + firstRoundLastPlayersTurnId(0), highestSet(0), firstRound(true), smallBlindPosition(0), smallBlind(sB), minimumRaise(2*sB), fullBetRule(false), + lastActionPlayer(0) { } diff --git a/src/engine/network_engine/clientbero.h b/src/engine/network_engine/clientbero.h index 799e872f..c97d29e4 100644 --- a/src/engine/network_engine/clientbero.h +++ b/src/engine/network_engine/clientbero.h @@ -28,7 +28,8 @@ class HandInterface; /** @author FThauer FHammer */ -class ClientBeRo : public BeRoInterface{ +class ClientBeRo : public BeRoInterface +{ public: ClientBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS); ~ClientBeRo(); @@ -38,8 +39,8 @@ public: int getHighestCardsValue() const; void setHighestCardsValue(int theValue); - void setLastActionPlayer ( unsigned theValue ); - unsigned getLastActionPlayer() const; + void setLastActionPlayer ( unsigned theValue ); + unsigned getLastActionPlayer() const; void setSmallBlindPositionId(unsigned theValue); unsigned getSmallBlindPositionId() const; @@ -58,7 +59,7 @@ public: void setLastPlayersTurnIt(PlayerListIterator theValue); PlayerListIterator getLastPlayersTurnIt() const; - + void setHighestSet(int theValue); int getHighestSet() const; diff --git a/src/engine/network_engine/clientboard.cpp b/src/engine/network_engine/clientboard.cpp index 3c26ef54..74631431 100644 --- a/src/engine/network_engine/clientboard.cpp +++ b/src/engine/network_engine/clientboard.cpp @@ -24,7 +24,7 @@ using namespace std; ClientBoard::ClientBoard(unsigned dp) -: pot(0), sets(0), dealerPosition(dp), allInCondition(false), lastActionPlayer(0) + : pot(0), sets(0), dealerPosition(dp), allInCondition(false), lastActionPlayer(0) { myCards[0] = myCards[1] = myCards[2] = myCards[3] = myCards[4] = 0; } @@ -90,15 +90,15 @@ ClientBoard::setSets(int theValue) void ClientBoard::setAllInCondition(bool theValue) { - boost::recursive_mutex::scoped_lock lock(m_syncMutex); - allInCondition = theValue; + boost::recursive_mutex::scoped_lock lock(m_syncMutex); + allInCondition = theValue; } void ClientBoard::setLastActionPlayer(unsigned theValue) { - boost::recursive_mutex::scoped_lock lock(m_syncMutex); - lastActionPlayer = theValue; + boost::recursive_mutex::scoped_lock lock(m_syncMutex); + lastActionPlayer = theValue; } void @@ -116,7 +116,7 @@ void ClientBoard::collectPot() { boost::recursive_mutex::scoped_lock lock(m_syncMutex); - pot += sets; + pot += sets; sets = 0; } diff --git a/src/engine/network_engine/clientboard.h b/src/engine/network_engine/clientboard.h index fbb19c6d..c7361c49 100644 --- a/src/engine/network_engine/clientboard.h +++ b/src/engine/network_engine/clientboard.h @@ -31,7 +31,7 @@ class HandInterface; class ClientBoard : public BoardInterface { public: - ClientBoard(unsigned dealerPosition); + ClientBoard(unsigned dealerPosition); ~ClientBoard(); void setPlayerLists(PlayerList, PlayerList, PlayerList); @@ -44,8 +44,8 @@ public: int getSets() const; void setSets(int theValue); - void setAllInCondition(bool theValue); - void setLastActionPlayer(unsigned theValue); + void setAllInCondition(bool theValue); + void setLastActionPlayer(unsigned theValue); void collectSets(); void collectPot(); @@ -72,9 +72,9 @@ private: int myCards[5]; int pot; int sets; - unsigned dealerPosition; - bool allInCondition; - unsigned lastActionPlayer; + unsigned dealerPosition; + bool allInCondition; + unsigned lastActionPlayer; }; #endif diff --git a/src/engine/network_engine/clienthand.cpp b/src/engine/network_engine/clienthand.cpp index a38caf42..1d8f248a 100644 --- a/src/engine/network_engine/clienthand.cpp +++ b/src/engine/network_engine/clienthand.cpp @@ -22,15 +22,15 @@ using namespace std; ClientHand::ClientHand(boost::shared_ptr f, GuiInterface *g, boost::shared_ptr b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) -: myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myID(id), startQuantityPlayers(sP), dealerPosition(dP), currentRound(0), - smallBlind(sB), startCash(sC), lastPlayersTurn(-1), allInCondition(0), - cardsShown(false), bettingRoundsPlayed(0) + : myFactory(f), myGui(g), myBoard(b), myLog(l), seatsList(sl), activePlayerList(apl), runningPlayerList(rpl), myID(id), startQuantityPlayers(sP), dealerPosition(dP), currentRound(0), + smallBlind(sB), startCash(sC), lastPlayersTurn(-1), allInCondition(0), + cardsShown(false), bettingRoundsPlayed(0) { PlayerListIterator it; for(it=seatsList->begin(); it!=seatsList->end(); ++it) { (*it)->setHand(this); - // myFlipCards auf 0 setzen + // myFlipCards auf 0 setzen (*it)->setMyCardsFlip(0, 0); } diff --git a/src/engine/network_engine/clienthand.h b/src/engine/network_engine/clienthand.h index d94f73c6..61484017 100644 --- a/src/engine/network_engine/clienthand.h +++ b/src/engine/network_engine/clienthand.h @@ -32,97 +32,97 @@ class ClientHand : public HandInterface { - public: - ClientHand ( boost::shared_ptr f, GuiInterface*, boost::shared_ptr, Log*, PlayerList, PlayerList, PlayerList , int, int, int, int, int ); - ~ClientHand(); +public: + ClientHand ( boost::shared_ptr f, GuiInterface*, boost::shared_ptr, Log*, PlayerList, PlayerList, PlayerList , int, int, int, int, int ); + ~ClientHand(); - void start(); + void start(); - PlayerList getSeatsList() const; - PlayerList getActivePlayerList() const; - PlayerList getRunningPlayerList() const; + PlayerList getSeatsList() const; + PlayerList getActivePlayerList() const; + PlayerList getRunningPlayerList() const; - boost::shared_ptr getBoard() const; - boost::shared_ptr getPreflop() const; - boost::shared_ptr getFlop() const; - boost::shared_ptr getTurn() const; - boost::shared_ptr getRiver() const; - GuiInterface* getGuiInterface() const; - boost::shared_ptr getCurrentBeRo() const; + boost::shared_ptr getBoard() const; + boost::shared_ptr getPreflop() const; + boost::shared_ptr getFlop() const; + boost::shared_ptr getTurn() const; + boost::shared_ptr getRiver() const; + GuiInterface* getGuiInterface() const; + boost::shared_ptr getCurrentBeRo() const; - void setMyID ( int theValue ); - int getMyID() const; + void setMyID ( int theValue ); + int getMyID() const; - void setCurrentQuantityPlayers ( int theValue ); - int getCurrentQuantityPlayers() const; + void setCurrentQuantityPlayers ( int theValue ); + int getCurrentQuantityPlayers() const; - void setStartQuantityPlayers ( int theValue ); - int getStartQuantityPlayers() const; + void setStartQuantityPlayers ( int theValue ); + int getStartQuantityPlayers() const; - void setCurrentRound ( int theValue ); - int getCurrentRound() const; + void setCurrentRound ( int theValue ); + int getCurrentRound() const; - void setDealerPosition ( int theValue ); - int getDealerPosition() const; + void setDealerPosition ( int theValue ); + int getDealerPosition() const; - void setSmallBlind ( int theValue ); - int getSmallBlind() const; + void setSmallBlind ( int theValue ); + int getSmallBlind() const; - void setAllInCondition ( bool theValue ); - bool getAllInCondition() const; + void setAllInCondition ( bool theValue ); + bool getAllInCondition() const; - void setStartCash ( int theValue ); - int getStartCash() const; + void setStartCash ( int theValue ); + int getStartCash() const; - void setBettingRoundsPlayed ( int theValue ); - int getBettingRoundsPlayed() const; + void setBettingRoundsPlayed ( int theValue ); + int getBettingRoundsPlayed() const; - void setLastPlayersTurn ( int theValue ); - int getLastPlayersTurn() const; + void setLastPlayersTurn ( int theValue ); + int getLastPlayersTurn() const; - void setLastActionPlayer ( unsigned theValue ); - unsigned getLastActionPlayer() const; + void setLastActionPlayer ( unsigned theValue ); + unsigned getLastActionPlayer() const; - void setCardsShown ( bool theValue ); - bool getCardsShown() const; + void setCardsShown ( bool theValue ); + bool getCardsShown() const; - void switchRounds(); + void switchRounds(); protected: - PlayerListIterator getSeatIt(unsigned) const; - PlayerListIterator getActivePlayerIt(unsigned) const; - PlayerListIterator getRunningPlayerIt(unsigned) const; + PlayerListIterator getSeatIt(unsigned) const; + PlayerListIterator getActivePlayerIt(unsigned) const; + PlayerListIterator getRunningPlayerIt(unsigned) const; private: - mutable boost::recursive_mutex m_syncMutex; + mutable boost::recursive_mutex m_syncMutex; - boost::shared_ptr myFactory; - GuiInterface *myGui; - boost::shared_ptr myBoard; - Log *myLog; + boost::shared_ptr myFactory; + GuiInterface *myGui; + boost::shared_ptr myBoard; + Log *myLog; - PlayerList seatsList; - PlayerList activePlayerList; - PlayerList runningPlayerList; + PlayerList seatsList; + PlayerList activePlayerList; + PlayerList runningPlayerList; - std::vector > myBeRo; + std::vector > myBeRo; - int myID; - int startQuantityPlayers; - unsigned dealerPosition; - int currentRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river - int smallBlind; - int startCash; + int myID; + int startQuantityPlayers; + unsigned dealerPosition; + int currentRound; //0 = preflop, 1 = flop, 2 = turn, 3 = river + int smallBlind; + int startCash; - int lastPlayersTurn; - unsigned lastActionPlayer; + int lastPlayersTurn; + unsigned lastActionPlayer; - bool allInCondition; - bool cardsShown; + bool allInCondition; + bool cardsShown; - // hier steht bis zu welcher bettingRound der human player gespielt hat: 0 - nur Preflop, 1 - bis Flop, ... - int bettingRoundsPlayed; + // hier steht bis zu welcher bettingRound der human player gespielt hat: 0 - nur Preflop, 1 - bis Flop, ... + int bettingRoundsPlayed; }; #endif diff --git a/src/engine/network_engine/clientplayer.cpp b/src/engine/network_engine/clientplayer.cpp index 1329e4e7..13fc42e3 100644 --- a/src/engine/network_engine/clientplayer.cpp +++ b/src/engine/network_engine/clientplayer.cpp @@ -23,10 +23,10 @@ using namespace std; ClientPlayer::ClientPlayer(ConfigFile *c, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) -: PlayerInterface(), myConfig(c), currentHand(0), myCardsValue(0), myID(id), myUniqueID(uniqueId), myType(type), - myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myLastRelativeSet(0), - myAction(0), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(true), myTurn(false), myCardsFlip(false), myRoundStartCash(0), - lastMoneyWon(0), sBluff(0), sBluffStatus(false), myWinnerState(false) + : PlayerInterface(), myConfig(c), currentHand(0), myCardsValue(0), myID(id), myUniqueID(uniqueId), myType(type), + myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), myCash(sC), mySet(0), myLastRelativeSet(0), + myAction(0), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(true), myTurn(false), myCardsFlip(false), myRoundStartCash(0), + lastMoneyWon(0), sBluff(0), sBluffStatus(false), myWinnerState(false) { myBestHandPosition[0] = myBestHandPosition[1] = myBestHandPosition[2] = myBestHandPosition[3] = myBestHandPosition[4] = 0; myNiveau[0] = myNiveau[1] = myNiveau[2] = 0; @@ -266,13 +266,17 @@ ClientPlayer::setMyCardsFlip(bool theValue, int state) // log flipping cards if (myCardsFlip) { switch(state) { - case 1: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt); + case 1: + currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt); break; - case 2: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]); + case 2: + currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]); break; - case 3: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt, "has"); + case 3: + currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt, "has"); break; - default: ; + default: + ; } } } @@ -363,8 +367,7 @@ void ClientPlayer::setMyAggressive(bool theValue) { boost::recursive_mutex::scoped_lock lock(m_syncMutex); - for (int i=0; i<6; i++) - { + for (int i=0; i<6; i++) { myAggressive[i] = myAggressive[i+1]; } myAggressive[6] = theValue; @@ -375,14 +378,13 @@ ClientPlayer::getMyAggressive() const { boost::recursive_mutex::scoped_lock lock(m_syncMutex); int sum = 0; - for (int i=0; i<7; i++) - { + for (int i=0; i<7; i++) { sum += myAggressive[i]; } return sum; } -void +void ClientPlayer::setSBluff(int theValue) { boost::recursive_mutex::scoped_lock lock(m_syncMutex); @@ -527,10 +529,9 @@ bool ClientPlayer::checkIfINeedToShowCards() { boost::recursive_mutex::scoped_lock lock(m_syncMutex); std::list playerNeedToShowCardsList = currentHand->getBoard()->getPlayerNeedToShowCards(); - for(std::list::iterator it = playerNeedToShowCardsList.begin(); it != playerNeedToShowCardsList.end(); ++it) - { - if(*it == myUniqueID) return true; - } + for(std::list::iterator it = playerNeedToShowCardsList.begin(); it != playerNeedToShowCardsList.end(); ++it) { + if(*it == myUniqueID) return true; + } - return false; + return false; } diff --git a/src/engine/network_engine/clientplayer.h b/src/engine/network_engine/clientplayer.h index 02331756..9dd48fe5 100644 --- a/src/engine/network_engine/clientplayer.h +++ b/src/engine/network_engine/clientplayer.h @@ -29,7 +29,8 @@ class CardsValue; class ConfigFile; class HandInterface; -class ClientPlayer : public PlayerInterface{ +class ClientPlayer : public PlayerInterface +{ public: ClientPlayer(ConfigFile*, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); ~ClientPlayer(); @@ -134,7 +135,9 @@ public: boost::shared_ptr getNetSessionData(); // unused as client - unsigned getActionTimeoutCounter() const {return 0;} + unsigned getActionTimeoutCounter() const { + return 0; + } void incrementActionTimeoutCounter() {} void resetActionTimeoutCounter() {} @@ -171,7 +174,7 @@ private: int myAction; // 0 = none, 1 = fold, 2 = check, 3 = call, 4 = bet, 5 = raise, 6 = allin int myButton; // 0 = none, 1 = dealer, 2 =small, 3 = big bool myActiveStatus; // 0 = inactive, 1 = active - bool myStayOnTableStatus; // 0 = left, 1 = stay + bool myStayOnTableStatus; // 0 = left, 1 = stay bool myTurn; // 0 = no, 1 = yes bool myCardsFlip; // 0 = cards are not fliped, 1 = cards are already flipped, int myRoundStartCash; diff --git a/src/engine/playerinterface.h b/src/engine/playerinterface.h index 84802353..139f7ef6 100644 --- a/src/engine/playerinterface.h +++ b/src/engine/playerinterface.h @@ -25,7 +25,8 @@ class SessionData; -class PlayerInterface{ +class PlayerInterface +{ public: virtual ~PlayerInterface() =0; @@ -66,8 +67,8 @@ public: virtual void setMyActiveStatus(bool theValue) =0; virtual bool getMyActiveStatus() const =0; - virtual void setMyStayOnTableStatus(bool theValue) =0; - virtual bool getMyStayOnTableStatus() const =0; + virtual void setMyStayOnTableStatus(bool theValue) =0; + virtual bool getMyStayOnTableStatus() const =0; virtual void setMyCards(int* theValue) =0; virtual void getMyCards(int* theValue) const =0; diff --git a/src/game.cpp b/src/game.cpp index b0e3f299..da217d5f 100755 --- a/src/game.cpp +++ b/src/game.cpp @@ -32,12 +32,12 @@ using namespace std; Game::Game(GuiInterface* gui, boost::shared_ptr factory, const PlayerDataList &playerDataList, const GameData &gameData, - const StartData &startData, int gameId, Log* log) -: myFactory(factory), myGui(gui), myLog(log), startQuantityPlayers(startData.numberOfPlayers), - startCash(gameData.startMoney), startSmallBlind(gameData.firstSmallBlind), - myGameID(gameId), currentSmallBlind(gameData.firstSmallBlind), currentHandID(0), dealerPosition(0), - lastHandBlindsRaised(1), lastTimeBlindsRaised(0), myGameData(gameData), - blindsTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::second_timer::manual_start) + const StartData &startData, int gameId, Log* log) + : myFactory(factory), myGui(gui), myLog(log), startQuantityPlayers(startData.numberOfPlayers), + startCash(gameData.startMoney), startSmallBlind(gameData.firstSmallBlind), + myGameID(gameId), currentSmallBlind(gameData.firstSmallBlind), currentHandID(0), dealerPosition(0), + lastHandBlindsRaised(1), lastTimeBlindsRaised(0), myGameData(gameData), + blindsTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::second_timer::manual_start) { blindsList = myGameData.manualBlindsList; @@ -56,8 +56,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr factory, PlayerDataList::const_iterator player_i = playerDataList.begin(); PlayerDataList::const_iterator player_end = playerDataList.end(); - while (player_i != player_end) - { + while (player_i != player_end) { if ((*player_i)->GetUniqueId() == dealerPosition) break; ++player_i; @@ -66,7 +65,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr factory, throw LocalException(__FILE__, __LINE__, ERR_DEALER_NOT_FOUND); // create board - currentBoard = myFactory->createBoard(dealerPosition); + currentBoard = myFactory->createBoard(dealerPosition); // create player lists seatsList = PlayerList(new std::list >); @@ -84,8 +83,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr factory, PlayerType type = PLAYER_TYPE_COMPUTER; boost::shared_ptr myNetSession; - if (player_i != player_end) - { + if (player_i != player_end) { uniqueId = (*player_i)->GetUniqueId(); type = (*player_i)->GetType(); myName = (*player_i)->GetName(); @@ -110,8 +108,8 @@ Game::Game(GuiInterface* gui, boost::shared_ptr factory, currentBoard->setPlayerLists(seatsList, activePlayerList, runningPlayerList); - // log game data - myLog->logNewGameMsg(myGameID, startCash, startSmallBlind, dealerPosition, seatsList); + // log game data + myLog->logNewGameMsg(myGameID, startCash, startSmallBlind, dealerPosition, seatsList); //start timer blindsTimer.reset(); @@ -154,7 +152,7 @@ void Game::initHand() while( it!=activePlayerList->end() ) { if((*it)->getMyCash() == 0) { - (*it)->setMyActiveStatus(false); + (*it)->setMyActiveStatus(false); it = activePlayerList->erase(it); } else { ++it; @@ -165,7 +163,7 @@ void Game::initHand() (*runningPlayerList) = (*activePlayerList); // create Hand - currentHand = myFactory->createHand(myFactory, myGui, currentBoard, myLog, seatsList, activePlayerList, runningPlayerList, currentHandID, startQuantityPlayers, dealerPosition, currentSmallBlind, startCash); + currentHand = myFactory->createHand(myFactory, myGui, currentBoard, myLog, seatsList, activePlayerList, runningPlayerList, currentHandID, startQuantityPlayers, dealerPosition, currentSmallBlind, startCash); // shifting dealer button -> TODO exception-rule !!! bool nextDealerFound = false; @@ -197,7 +195,7 @@ void Game::startHand() // log new hand myGui->logNewGameHandMsg(myGameID, currentHandID); - myGui->flushLogAtGame(myGameID); + myGui->flushLogAtGame(myGameID); currentHand->start(); } @@ -207,10 +205,8 @@ boost::shared_ptr Game::getPlayerByUniqueId(unsigned id) boost::shared_ptr tmpPlayer; PlayerListIterator i = getSeatsList()->begin(); PlayerListIterator end = getSeatsList()->end(); - while (i != end) - { - if ((*i)->getMyUniqueID() == id) - { + while (i != end) { + if ((*i)->getMyUniqueID() == id) { tmpPlayer = *i; break; } @@ -227,7 +223,8 @@ boost::shared_ptr Game::getCurrentPlayer() return tmpPlayer; } -void Game::raiseBlinds() { +void Game::raiseBlinds() +{ bool raiseBlinds = false; @@ -236,8 +233,7 @@ void Game::raiseBlinds() { raiseBlinds = true; lastHandBlindsRaised = currentHandID; } - } - else { + } else { if (lastTimeBlindsRaised + myGameData.raiseSmallBlindEveryMinutesValue <= blindsTimer.elapsed().total_seconds()/60) { raiseBlinds = true; lastTimeBlindsRaised = blindsTimer.elapsed().total_seconds()/60; @@ -245,22 +241,19 @@ void Game::raiseBlinds() { } if (raiseBlinds) { // At this point, the blinds must be raised - // Now we check how the blinds should be raised - if (myGameData.raiseMode == DOUBLE_BLINDS) { - currentSmallBlind *= 2; - } - else { + // Now we check how the blinds should be raised + if (myGameData.raiseMode == DOUBLE_BLINDS) { + currentSmallBlind *= 2; + } else { if(!blindsList.empty()) { currentSmallBlind = blindsList.front(); blindsList.pop_front(); - } - else { + } else { // The position exceeds the list - if (myGameData.afterManualBlindsMode == AFTERMB_DOUBLE_BLINDS) { - currentSmallBlind *= 2; - } - else { - if(myGameData.afterManualBlindsMode == AFTERMB_RAISE_ABOUT) { + if (myGameData.afterManualBlindsMode == AFTERMB_DOUBLE_BLINDS) { + currentSmallBlind *= 2; + } else { + if(myGameData.afterManualBlindsMode == AFTERMB_RAISE_ABOUT) { currentSmallBlind += myGameData.afterMBAlwaysRaiseValue; } } diff --git a/src/game.h b/src/game.h index 5d1f5dbe..c7eab7dc 100755 --- a/src/game.h +++ b/src/game.h @@ -35,12 +35,13 @@ struct GameData; struct StartData; -class Game { +class Game +{ public: - Game(GuiInterface *gui, boost::shared_ptr factory, - const PlayerDataList &playerDataList, const GameData &gameData, - const StartData &startData, int gameId, Log *myLog); + Game(GuiInterface *gui, boost::shared_ptr factory, + const PlayerDataList &playerDataList, const GameData &gameData, + const StartData &startData, int gameId, Log *myLog); ~Game(); @@ -50,28 +51,58 @@ public: boost::shared_ptr getCurrentHand(); const boost::shared_ptr getCurrentHand() const; - PlayerList getSeatsList() const {return seatsList;} - PlayerList getActivePlayerList() const {return activePlayerList;} - PlayerList getRunningPlayerList() const {return runningPlayerList;} + PlayerList getSeatsList() const { + return seatsList; + } + PlayerList getActivePlayerList() const { + return activePlayerList; + } + PlayerList getRunningPlayerList() const { + return runningPlayerList; + } - void setStartQuantityPlayers(int theValue) { startQuantityPlayers = theValue; } - int getStartQuantityPlayers() const { return startQuantityPlayers; } - - void setStartSmallBlind(int theValue) { startSmallBlind = theValue; } - int getStartSmallBlind() const { return startSmallBlind; } + void setStartQuantityPlayers(int theValue) { + startQuantityPlayers = theValue; + } + int getStartQuantityPlayers() const { + return startQuantityPlayers; + } - void setStartCash(int theValue) { startCash = theValue; } - int getStartCash() const { return startCash; } + void setStartSmallBlind(int theValue) { + startSmallBlind = theValue; + } + int getStartSmallBlind() const { + return startSmallBlind; + } - int getMyGameID() const { return myGameID; } + void setStartCash(int theValue) { + startCash = theValue; + } + int getStartCash() const { + return startCash; + } - void setCurrentSmallBlind(int theValue) { currentSmallBlind = theValue; } - int getCurrentSmallBlind() const { return currentSmallBlind; } + int getMyGameID() const { + return myGameID; + } - void setCurrentHandID(int theValue) { currentHandID = theValue; } - int getCurrentHandID() const { return currentHandID; } + void setCurrentSmallBlind(int theValue) { + currentSmallBlind = theValue; + } + int getCurrentSmallBlind() const { + return currentSmallBlind; + } - unsigned getDealerPosition() const { return dealerPosition; } + void setCurrentHandID(int theValue) { + currentHandID = theValue; + } + int getCurrentHandID() const { + return currentHandID; + } + + unsigned getDealerPosition() const { + return dealerPosition; + } boost::shared_ptr getPlayerByUniqueId(unsigned id); boost::shared_ptr getCurrentPlayer(); @@ -82,7 +113,7 @@ private: boost::shared_ptr myFactory; GuiInterface *myGui; - Log *myLog; + Log *myLog; boost::shared_ptr currentHand; boost::shared_ptr currentBoard; diff --git a/src/game_defs.h b/src/game_defs.h index 73d295d4..3cc9a424 100644 --- a/src/game_defs.h +++ b/src/game_defs.h @@ -43,99 +43,96 @@ #define RANKING_GAME_RAISE_EVERY_HAND 11 enum ServerMode { - SERVER_MODE_LAN, - SERVER_MODE_INTERNET_NOAUTH, - SERVER_MODE_INTERNET_AUTH + SERVER_MODE_LAN, + SERVER_MODE_INTERNET_NOAUTH, + SERVER_MODE_INTERNET_AUTH }; enum ServerTransportProtocol { - TRANSPORT_PROTOCOL_TCP = 1, - TRANSPORT_PROTOCOL_SCTP = 2, - TRANSPORT_PROTOCOL_TCP_SCTP = 3}; + TRANSPORT_PROTOCOL_TCP = 1, + TRANSPORT_PROTOCOL_SCTP = 2, + TRANSPORT_PROTOCOL_TCP_SCTP = 3 +}; enum GameState { - GAME_STATE_PREFLOP = 0, - GAME_STATE_FLOP, - GAME_STATE_TURN, - GAME_STATE_RIVER, - GAME_STATE_POST_RIVER, - GAME_STATE_PREFLOP_SMALL_BLIND = 0xF0, - GAME_STATE_PREFLOP_BIG_BLIND = 0xF1 }; + GAME_STATE_PREFLOP = 0, + GAME_STATE_FLOP, + GAME_STATE_TURN, + GAME_STATE_RIVER, + GAME_STATE_POST_RIVER, + GAME_STATE_PREFLOP_SMALL_BLIND = 0xF0, + GAME_STATE_PREFLOP_BIG_BLIND = 0xF1 +}; enum PlayerAction { - PLAYER_ACTION_NONE = 0, - PLAYER_ACTION_FOLD, - PLAYER_ACTION_CHECK, - PLAYER_ACTION_CALL, - PLAYER_ACTION_BET, - PLAYER_ACTION_RAISE, - PLAYER_ACTION_ALLIN }; - -enum PlayerActionCode -{ - ACTION_CODE_VALID = 0, - ACTION_CODE_INVALID_STATE, - ACTION_CODE_NOT_YOUR_TURN, - ACTION_CODE_NOT_ALLOWED + PLAYER_ACTION_NONE = 0, + PLAYER_ACTION_FOLD, + PLAYER_ACTION_CHECK, + PLAYER_ACTION_CALL, + PLAYER_ACTION_BET, + PLAYER_ACTION_RAISE, + PLAYER_ACTION_ALLIN }; -enum DenyKickPlayerReason -{ - KICK_DENIED_INVALID_STATE = 0, - KICK_DENIED_TOO_FEW_PLAYERS, - KICK_DENIED_TEMPORARY, - KICK_DENIED_OTHER_IN_PROGRESS, - KICK_DENIED_INVALID_PLAYER_ID +enum PlayerActionCode { + ACTION_CODE_VALID = 0, + ACTION_CODE_INVALID_STATE, + ACTION_CODE_NOT_YOUR_TURN, + ACTION_CODE_NOT_ALLOWED }; -enum KickVote -{ - KICK_VOTE_AGAINST = 0, - KICK_VOTE_IN_FAVOUR +enum DenyKickPlayerReason { + KICK_DENIED_INVALID_STATE = 0, + KICK_DENIED_TOO_FEW_PLAYERS, + KICK_DENIED_TEMPORARY, + KICK_DENIED_OTHER_IN_PROGRESS, + KICK_DENIED_INVALID_PLAYER_ID }; -enum DenyVoteReason -{ - VOTE_DENIED_INVALID_PETITION = 0, - VOTE_DENIED_ALREADY_VOTED +enum KickVote { + KICK_VOTE_AGAINST = 0, + KICK_VOTE_IN_FAVOUR }; -enum EndPetitionReason -{ - PETITION_END_ENOUGH_VOTES = 0, - PETITION_END_NOT_ENOUGH_PLAYERS, - PETITION_END_PLAYER_LEFT, - PETITION_END_TIMEOUT +enum DenyVoteReason { + VOTE_DENIED_INVALID_PETITION = 0, + VOTE_DENIED_ALREADY_VOTED }; -enum DenyGameInvitationReason -{ - DENY_GAME_INVITATION_NO = 0, - DENY_GAME_INVITATION_BUSY +enum EndPetitionReason { + PETITION_END_ENOUGH_VOTES = 0, + PETITION_END_NOT_ENOUGH_PLAYERS, + PETITION_END_PLAYER_LEFT, + PETITION_END_TIMEOUT +}; + +enum DenyGameInvitationReason { + DENY_GAME_INVITATION_NO = 0, + DENY_GAME_INVITATION_BUSY }; enum Button { - BUTTON_NONE = 0, - BUTTON_DEALER, - BUTTON_SMALL_BLIND, - BUTTON_BIG_BLIND }; - -enum NetTimeoutReason { - NETWORK_TIMEOUT_GENERIC = 0, - NETWORK_TIMEOUT_GAME_ADMIN_IDLE + BUTTON_NONE = 0, + BUTTON_DEALER, + BUTTON_SMALL_BLIND, + BUTTON_BIG_BLIND }; -struct ServerStats -{ - ServerStats() - : numberOfPlayersOnServer(0), numberOfGamesOpen(0), totalPlayersEverLoggedIn(0), - totalGamesEverCreated(0), maxGamesOpen(0), maxPlayersLoggedIn(0) {} - unsigned numberOfPlayersOnServer; - unsigned numberOfGamesOpen; - unsigned totalPlayersEverLoggedIn; - unsigned totalGamesEverCreated; - unsigned maxGamesOpen; - unsigned maxPlayersLoggedIn; +enum NetTimeoutReason { + NETWORK_TIMEOUT_GENERIC = 0, + NETWORK_TIMEOUT_GAME_ADMIN_IDLE +}; + +struct ServerStats { + ServerStats() + : numberOfPlayersOnServer(0), numberOfGamesOpen(0), totalPlayersEverLoggedIn(0), + totalGamesEverCreated(0), maxGamesOpen(0), maxPlayersLoggedIn(0) {} + unsigned numberOfPlayersOnServer; + unsigned numberOfGamesOpen; + unsigned totalPlayersEverLoggedIn; + unsigned totalGamesEverCreated; + unsigned maxGamesOpen; + unsigned maxPlayersLoggedIn; }; #endif diff --git a/src/gamedata.h b/src/gamedata.h index 0fb04dc5..23dbda33 100644 --- a/src/gamedata.h +++ b/src/gamedata.h @@ -28,43 +28,37 @@ typedef std::list PlayerIdList; -enum GameMode -{ +enum GameMode { GAME_MODE_CREATED = 1, GAME_MODE_STARTED, GAME_MODE_CLOSED }; -enum GameType -{ +enum GameType { GAME_TYPE_NORMAL = 1, GAME_TYPE_REGISTERED_ONLY, GAME_TYPE_INVITE_ONLY, GAME_TYPE_RANKING }; -enum RaiseIntervalMode -{ +enum RaiseIntervalMode { RAISE_ON_HANDNUMBER = 1, RAISE_ON_MINUTES }; -enum RaiseMode -{ +enum RaiseMode { DOUBLE_BLINDS = 1, MANUAL_BLINDS_ORDER }; -enum AfterManualBlindsMode -{ +enum AfterManualBlindsMode { AFTERMB_DOUBLE_BLINDS = 1, AFTERMB_RAISE_ABOUT, AFTERMB_STAY_AT_LAST_BLIND }; // For the sake of simplicity, this is a struct. -struct GameData -{ +struct GameData { GameData() : gameType(GAME_TYPE_NORMAL), maxNumberOfPlayers(0), startMoney(0), firstSmallBlind(0), raiseIntervalMode(RAISE_ON_HANDNUMBER), raiseSmallBlindEveryHandsValue(8), raiseSmallBlindEveryMinutesValue(1), @@ -87,8 +81,7 @@ struct GameData int playerActionTimeoutSec; }; -struct GameInfo -{ +struct GameInfo { GameInfo() : mode(GAME_MODE_CREATED), adminPlayerId(0), isPasswordProtected(false) {} std::string name; GameData data; @@ -98,19 +91,17 @@ struct GameInfo bool isPasswordProtected; }; -struct StartData -{ +struct StartData { StartData() : startDealerPlayerId(0), numberOfPlayers(0) {} unsigned startDealerPlayerId; int numberOfPlayers; }; -struct VoteKickData -{ +struct VoteKickData { VoteKickData() - : petitionId(0), kickPlayerId(0), numVotesToKick(0), - numVotesInFavourOfKicking(0), numVotesAgainstKicking(0), timeLimitSec(0), - voteTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::microsec_timer::auto_start) {} + : petitionId(0), kickPlayerId(0), numVotesToKick(0), + numVotesInFavourOfKicking(0), numVotesAgainstKicking(0), timeLimitSec(0), + voteTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::microsec_timer::auto_start) {} unsigned petitionId; unsigned kickPlayerId; int numVotesToKick; diff --git a/src/gui/generic/serverguiwrapper.cpp b/src/gui/generic/serverguiwrapper.cpp index e2748e72..4d9ec777 100644 --- a/src/gui/generic/serverguiwrapper.cpp +++ b/src/gui/generic/serverguiwrapper.cpp @@ -25,7 +25,7 @@ using namespace std; ServerGuiWrapper::ServerGuiWrapper(ConfigFile *config, ClientCallback *clientcb, ServerCallback *servercb, IrcCallback *irccb) -: myConfig(config), myClientcb(clientcb), myServercb(servercb), myIrccb(irccb) + : myConfig(config), myClientcb(clientcb), myServercb(servercb), myIrccb(irccb) { } @@ -110,64 +110,205 @@ void ServerGuiWrapper::logNewGameHandMsg(int /*gameID*/, int /*handID*/) {} void ServerGuiWrapper::logPlayerWinsMsg(std::string /*playerName*/, int /*pot*/, bool /*main*/) {} void ServerGuiWrapper::logPlayerSitsOut(std::string /*playerName*/) {} void ServerGuiWrapper::logNewBlindsSetsMsg(int /*sbSet*/, int /*bbSet*/, std::string /*sbName*/, std::string /*bbName*/) {} - + void ServerGuiWrapper::logDealBoardCardsMsg(int /*roundID*/, int /*card1*/, int /*card2*/, int /*card3*/, int /*card4*/, int /*card5*/) {} void ServerGuiWrapper::logFlipHoleCardsMsg(std::string /*playerName*/, int /*playerID*/, int /*card1*/, int /*card2*/, int /*cardsValueInt*/, std::string /*showHas*/) {} void ServerGuiWrapper::logPlayerWinGame(std::string /*playerName*/, int /*gameID*/) {} void ServerGuiWrapper::flushLogAtGame(int /*gameID*/) {} void ServerGuiWrapper::flushLogAtHand() {} -void ServerGuiWrapper::SignalNetClientServerListAdd(unsigned serverId) { if (myClientcb) myClientcb->SignalNetClientServerListAdd(serverId); } -void ServerGuiWrapper::SignalNetClientServerListClear() { if (myClientcb) myClientcb->SignalNetClientServerListClear(); } -void ServerGuiWrapper::SignalNetClientServerListShow() { if (myClientcb) myClientcb->SignalNetClientServerListShow(); } +void ServerGuiWrapper::SignalNetClientServerListAdd(unsigned serverId) +{ + if (myClientcb) myClientcb->SignalNetClientServerListAdd(serverId); +} +void ServerGuiWrapper::SignalNetClientServerListClear() +{ + if (myClientcb) myClientcb->SignalNetClientServerListClear(); +} +void ServerGuiWrapper::SignalNetClientServerListShow() +{ + if (myClientcb) myClientcb->SignalNetClientServerListShow(); +} -void ServerGuiWrapper::SignalNetClientLoginShow() { if (myClientcb) myClientcb->SignalNetClientLoginShow(); } -void ServerGuiWrapper::SignalNetClientPostRiverShowCards(unsigned playerId) { if (myClientcb) myClientcb->SignalNetClientPostRiverShowCards(playerId); } +void ServerGuiWrapper::SignalNetClientLoginShow() +{ + if (myClientcb) myClientcb->SignalNetClientLoginShow(); +} +void ServerGuiWrapper::SignalNetClientPostRiverShowCards(unsigned playerId) +{ + if (myClientcb) myClientcb->SignalNetClientPostRiverShowCards(playerId); +} -void ServerGuiWrapper::SignalNetClientConnect(int actionID) { if (myClientcb) myClientcb->SignalNetClientConnect(actionID); } -void ServerGuiWrapper::SignalNetClientGameInfo(int actionID) { if (myClientcb) myClientcb->SignalNetClientGameInfo(actionID); } -void ServerGuiWrapper::SignalNetClientError(int errorID, int osErrorID) { if (myClientcb) myClientcb->SignalNetClientError(errorID, osErrorID); } -void ServerGuiWrapper::SignalNetClientNotification(int notificationId) { if (myClientcb) myClientcb->SignalNetClientNotification(notificationId); } -void ServerGuiWrapper::SignalNetClientStatsUpdate(const ServerStats &stats) { if (myClientcb) myClientcb->SignalNetClientStatsUpdate(stats); } -void ServerGuiWrapper::SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec) { if (myClientcb) myClientcb->SignalNetClientShowTimeoutDialog(reason, remainingSec); } -void ServerGuiWrapper::SignalNetClientRemovedFromGame(int notificationId) { if (myClientcb) myClientcb->SignalNetClientRemovedFromGame(notificationId); } -void ServerGuiWrapper::SignalNetClientSelfJoined(unsigned playerId, const string &playerName, bool isGameAdmin) { if (myClientcb) myClientcb->SignalNetClientSelfJoined(playerId, playerName, isGameAdmin); } -void ServerGuiWrapper::SignalNetClientPlayerJoined(unsigned playerId, const string &playerName, bool isGameAdmin) { if (myClientcb) myClientcb->SignalNetClientPlayerJoined(playerId, playerName, isGameAdmin); } -void ServerGuiWrapper::SignalNetClientPlayerChanged(unsigned playerId, const string &newPlayerName) { if (myClientcb) myClientcb->SignalNetClientPlayerChanged(playerId, newPlayerName); } -void ServerGuiWrapper::SignalNetClientPlayerLeft(unsigned playerId, const string &playerName, int removeReason) { if (myClientcb) myClientcb->SignalNetClientPlayerLeft(playerId, playerName, removeReason); } -void ServerGuiWrapper::SignalNetClientNewGameAdmin(unsigned playerId, const string &playerName) { if (myClientcb) myClientcb->SignalNetClientNewGameAdmin(playerId, playerName); } -void ServerGuiWrapper::SignalNetClientGameListNew(unsigned gameId) { if (myClientcb) myClientcb->SignalNetClientGameListNew(gameId); } -void ServerGuiWrapper::SignalNetClientGameListRemove(unsigned gameId) { if (myClientcb) myClientcb->SignalNetClientGameListRemove(gameId); } -void ServerGuiWrapper::SignalNetClientGameListUpdateMode(unsigned gameId, GameMode mode) { if (myClientcb) myClientcb->SignalNetClientGameListUpdateMode(gameId, mode); } -void ServerGuiWrapper::SignalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId) { if (myClientcb) myClientcb->SignalNetClientGameListUpdateAdmin(gameId, adminPlayerId); } -void ServerGuiWrapper::SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId) { if (myClientcb) myClientcb->SignalNetClientGameListPlayerJoined(gameId, playerId); } -void ServerGuiWrapper::SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId) { if (myClientcb) myClientcb->SignalNetClientGameListPlayerLeft(gameId, playerId); } -void ServerGuiWrapper::SignalNetClientGameStart(boost::shared_ptr game) { if (myClientcb) myClientcb->SignalNetClientGameStart(game); } -void ServerGuiWrapper::SignalNetClientGameChatMsg(const string &playerName, const string &msg) { if (myClientcb) myClientcb->SignalNetClientGameChatMsg(playerName, msg); } -void ServerGuiWrapper::SignalNetClientLobbyChatMsg(const string &playerName, const string &msg) { if (myClientcb) myClientcb->SignalNetClientLobbyChatMsg(playerName, msg); } -void ServerGuiWrapper::SignalNetClientMsgBox(const string &msg) { if (myClientcb) myClientcb->SignalNetClientMsgBox(msg); } -void ServerGuiWrapper::SignalNetClientMsgBox(unsigned msgId) { if (myClientcb) myClientcb->SignalNetClientMsgBox(msgId); } -void ServerGuiWrapper::SignalNetClientWaitDialog() { if (myClientcb) myClientcb->SignalNetClientWaitDialog(); } -void ServerGuiWrapper::SignalNetClientWarningAutoFoldInRankingGame(unsigned remainingAutoFolds) { if (myClientcb) myClientcb->SignalNetClientWarningAutoFoldInRankingGame(remainingAutoFolds); } +void ServerGuiWrapper::SignalNetClientConnect(int actionID) +{ + if (myClientcb) myClientcb->SignalNetClientConnect(actionID); +} +void ServerGuiWrapper::SignalNetClientGameInfo(int actionID) +{ + if (myClientcb) myClientcb->SignalNetClientGameInfo(actionID); +} +void ServerGuiWrapper::SignalNetClientError(int errorID, int osErrorID) +{ + if (myClientcb) myClientcb->SignalNetClientError(errorID, osErrorID); +} +void ServerGuiWrapper::SignalNetClientNotification(int notificationId) +{ + if (myClientcb) myClientcb->SignalNetClientNotification(notificationId); +} +void ServerGuiWrapper::SignalNetClientStatsUpdate(const ServerStats &stats) +{ + if (myClientcb) myClientcb->SignalNetClientStatsUpdate(stats); +} +void ServerGuiWrapper::SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec) +{ + if (myClientcb) myClientcb->SignalNetClientShowTimeoutDialog(reason, remainingSec); +} +void ServerGuiWrapper::SignalNetClientRemovedFromGame(int notificationId) +{ + if (myClientcb) myClientcb->SignalNetClientRemovedFromGame(notificationId); +} +void ServerGuiWrapper::SignalNetClientSelfJoined(unsigned playerId, const string &playerName, bool isGameAdmin) +{ + if (myClientcb) myClientcb->SignalNetClientSelfJoined(playerId, playerName, isGameAdmin); +} +void ServerGuiWrapper::SignalNetClientPlayerJoined(unsigned playerId, const string &playerName, bool isGameAdmin) +{ + if (myClientcb) myClientcb->SignalNetClientPlayerJoined(playerId, playerName, isGameAdmin); +} +void ServerGuiWrapper::SignalNetClientPlayerChanged(unsigned playerId, const string &newPlayerName) +{ + if (myClientcb) myClientcb->SignalNetClientPlayerChanged(playerId, newPlayerName); +} +void ServerGuiWrapper::SignalNetClientPlayerLeft(unsigned playerId, const string &playerName, int removeReason) +{ + if (myClientcb) myClientcb->SignalNetClientPlayerLeft(playerId, playerName, removeReason); +} +void ServerGuiWrapper::SignalNetClientNewGameAdmin(unsigned playerId, const string &playerName) +{ + if (myClientcb) myClientcb->SignalNetClientNewGameAdmin(playerId, playerName); +} +void ServerGuiWrapper::SignalNetClientGameListNew(unsigned gameId) +{ + if (myClientcb) myClientcb->SignalNetClientGameListNew(gameId); +} +void ServerGuiWrapper::SignalNetClientGameListRemove(unsigned gameId) +{ + if (myClientcb) myClientcb->SignalNetClientGameListRemove(gameId); +} +void ServerGuiWrapper::SignalNetClientGameListUpdateMode(unsigned gameId, GameMode mode) +{ + if (myClientcb) myClientcb->SignalNetClientGameListUpdateMode(gameId, mode); +} +void ServerGuiWrapper::SignalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId) +{ + if (myClientcb) myClientcb->SignalNetClientGameListUpdateAdmin(gameId, adminPlayerId); +} +void ServerGuiWrapper::SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId) +{ + if (myClientcb) myClientcb->SignalNetClientGameListPlayerJoined(gameId, playerId); +} +void ServerGuiWrapper::SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId) +{ + if (myClientcb) myClientcb->SignalNetClientGameListPlayerLeft(gameId, playerId); +} +void ServerGuiWrapper::SignalNetClientGameStart(boost::shared_ptr game) +{ + if (myClientcb) myClientcb->SignalNetClientGameStart(game); +} +void ServerGuiWrapper::SignalNetClientGameChatMsg(const string &playerName, const string &msg) +{ + if (myClientcb) myClientcb->SignalNetClientGameChatMsg(playerName, msg); +} +void ServerGuiWrapper::SignalNetClientLobbyChatMsg(const string &playerName, const string &msg) +{ + if (myClientcb) myClientcb->SignalNetClientLobbyChatMsg(playerName, msg); +} +void ServerGuiWrapper::SignalNetClientMsgBox(const string &msg) +{ + if (myClientcb) myClientcb->SignalNetClientMsgBox(msg); +} +void ServerGuiWrapper::SignalNetClientMsgBox(unsigned msgId) +{ + if (myClientcb) myClientcb->SignalNetClientMsgBox(msgId); +} +void ServerGuiWrapper::SignalNetClientWaitDialog() +{ + if (myClientcb) myClientcb->SignalNetClientWaitDialog(); +} +void ServerGuiWrapper::SignalNetClientWarningAutoFoldInRankingGame(unsigned remainingAutoFolds) +{ + if (myClientcb) myClientcb->SignalNetClientWarningAutoFoldInRankingGame(remainingAutoFolds); +} -void ServerGuiWrapper::SignalNetServerSuccess(int actionID) { if (myServercb) myServercb->SignalNetServerSuccess(actionID); } -void ServerGuiWrapper::SignalNetServerError(int errorID, int osErrorID) { if (myServercb) myServercb->SignalNetServerError(errorID, osErrorID); } +void ServerGuiWrapper::SignalNetServerSuccess(int actionID) +{ + if (myServercb) myServercb->SignalNetServerSuccess(actionID); +} +void ServerGuiWrapper::SignalNetServerError(int errorID, int osErrorID) +{ + if (myServercb) myServercb->SignalNetServerError(errorID, osErrorID); +} -void ServerGuiWrapper::SignalIrcConnect(const string &server) { if (myIrccb) myIrccb->SignalIrcConnect(server); } -void ServerGuiWrapper::SignalIrcSelfJoined(const string &nickName, const std::string &channel) { if (myIrccb) myIrccb->SignalIrcSelfJoined(nickName, channel); } -void ServerGuiWrapper::SignalIrcPlayerJoined(const string &nickName) { if (myIrccb) myIrccb->SignalIrcPlayerJoined(nickName); } -void ServerGuiWrapper::SignalIrcPlayerChanged(const string &oldNick, const string &newNick) { if (myIrccb) myIrccb->SignalIrcPlayerChanged(oldNick, newNick); } -void ServerGuiWrapper::SignalIrcPlayerKicked(const string &nickName, const string &byWhom, const string &reason) { if (myIrccb) myIrccb->SignalIrcPlayerKicked(nickName, byWhom, reason); } -void ServerGuiWrapper::SignalIrcPlayerLeft(const string &nickName) { if (myIrccb) myIrccb->SignalIrcPlayerLeft(nickName); } -void ServerGuiWrapper::SignalIrcChatMsg(const string &nickName, const string &msg) { if (myIrccb) myIrccb->SignalIrcChatMsg(nickName, msg); } -void ServerGuiWrapper::SignalIrcError(int errorCode) { if (myIrccb) myIrccb->SignalIrcError(errorCode); } -void ServerGuiWrapper::SignalIrcServerError(int errorCode) {if (myIrccb) myIrccb->SignalIrcServerError(errorCode); } +void ServerGuiWrapper::SignalIrcConnect(const string &server) +{ + if (myIrccb) myIrccb->SignalIrcConnect(server); +} +void ServerGuiWrapper::SignalIrcSelfJoined(const string &nickName, const std::string &channel) +{ + if (myIrccb) myIrccb->SignalIrcSelfJoined(nickName, channel); +} +void ServerGuiWrapper::SignalIrcPlayerJoined(const string &nickName) +{ + if (myIrccb) myIrccb->SignalIrcPlayerJoined(nickName); +} +void ServerGuiWrapper::SignalIrcPlayerChanged(const string &oldNick, const string &newNick) +{ + if (myIrccb) myIrccb->SignalIrcPlayerChanged(oldNick, newNick); +} +void ServerGuiWrapper::SignalIrcPlayerKicked(const string &nickName, const string &byWhom, const string &reason) +{ + if (myIrccb) myIrccb->SignalIrcPlayerKicked(nickName, byWhom, reason); +} +void ServerGuiWrapper::SignalIrcPlayerLeft(const string &nickName) +{ + if (myIrccb) myIrccb->SignalIrcPlayerLeft(nickName); +} +void ServerGuiWrapper::SignalIrcChatMsg(const string &nickName, const string &msg) +{ + if (myIrccb) myIrccb->SignalIrcChatMsg(nickName, msg); +} +void ServerGuiWrapper::SignalIrcError(int errorCode) +{ + if (myIrccb) myIrccb->SignalIrcError(errorCode); +} +void ServerGuiWrapper::SignalIrcServerError(int errorCode) +{ + if (myIrccb) myIrccb->SignalIrcServerError(errorCode); +} -void ServerGuiWrapper::SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName) { if (myClientcb) myClientcb->SignalLobbyPlayerJoined(playerId, nickName); } -void ServerGuiWrapper::SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason) { if (myClientcb) myClientcb->SignalLobbyPlayerKicked(nickName, byWhom, reason); } -void ServerGuiWrapper::SignalLobbyPlayerLeft(unsigned playerId) { if (myClientcb) myClientcb->SignalLobbyPlayerLeft(playerId); } +void ServerGuiWrapper::SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName) +{ + if (myClientcb) myClientcb->SignalLobbyPlayerJoined(playerId, nickName); +} +void ServerGuiWrapper::SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason) +{ + if (myClientcb) myClientcb->SignalLobbyPlayerKicked(nickName, byWhom, reason); +} +void ServerGuiWrapper::SignalLobbyPlayerLeft(unsigned playerId) +{ + if (myClientcb) myClientcb->SignalLobbyPlayerLeft(playerId); +} -void ServerGuiWrapper::SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom) { if (myClientcb) myClientcb->SignalSelfGameInvitation(gameId, playerIdFrom); } -void ServerGuiWrapper::SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom) { if (myClientcb) myClientcb->SignalPlayerGameInvitation(gameId, playerIdWho, playerIdFrom); } -void ServerGuiWrapper::SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason) { if (myClientcb) myClientcb->SignalRejectedGameInvitation(gameId, playerIdWho, reason); } +void ServerGuiWrapper::SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom) +{ + if (myClientcb) myClientcb->SignalSelfGameInvitation(gameId, playerIdFrom); +} +void ServerGuiWrapper::SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom) +{ + if (myClientcb) myClientcb->SignalPlayerGameInvitation(gameId, playerIdWho, playerIdFrom); +} +void ServerGuiWrapper::SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason) +{ + if (myClientcb) myClientcb->SignalRejectedGameInvitation(gameId, playerIdWho, reason); +} diff --git a/src/gui/generic/serverguiwrapper.h b/src/gui/generic/serverguiwrapper.h index cddd2425..81860276 100644 --- a/src/gui/generic/serverguiwrapper.h +++ b/src/gui/generic/serverguiwrapper.h @@ -28,146 +28,150 @@ class gameTableImpl; class ServerGuiWrapper : public GuiInterface { public: - ServerGuiWrapper(ConfigFile *config, ClientCallback *clientcb, ServerCallback *servercb, IrcCallback *irccb); - ~ServerGuiWrapper(); + ServerGuiWrapper(ConfigFile *config, ClientCallback *clientcb, ServerCallback *servercb, IrcCallback *irccb); + ~ServerGuiWrapper(); - void initGui(int speed); + void initGui(int speed); - boost::shared_ptr getSession(); - void setSession(boost::shared_ptr session); + boost::shared_ptr getSession(); + void setSession(boost::shared_ptr session); - gameTableImpl* getMyW() const {return NULL;} - guiLog* getMyGuiLog() const {return NULL;} + gameTableImpl* getMyW() const { + return NULL; + } + guiLog* getMyGuiLog() const { + return NULL; + } - void refreshSet() const; - void refreshCash() const; - void refreshAction(int =-1, int =-1) const; - void refreshChangePlayer() const; - void refreshPot() const; - void refreshGroupbox(int =-1, int =-1) const; - void refreshAll() const; - void refreshPlayerName() const; - void refreshButton() const; - void refreshGameLabels(GameState state) const; + void refreshSet() const; + void refreshCash() const; + void refreshAction(int =-1, int =-1) const; + void refreshChangePlayer() const; + void refreshPot() const; + void refreshGroupbox(int =-1, int =-1) const; + void refreshAll() const; + void refreshPlayerName() const; + void refreshButton() const; + void refreshGameLabels(GameState state) const; - void setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const; + void setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const; - void waitForGuiUpdateDone() const; + void waitForGuiUpdateDone() const; - void dealBeRoCards(int); - void dealHoleCards(); - void dealFlopCards(); - void dealTurnCard(); - void dealRiverCard(); + void dealBeRoCards(int); + void dealHoleCards(); + void dealFlopCards(); + void dealTurnCard(); + void dealRiverCard(); - void nextPlayerAnimation(); + void nextPlayerAnimation(); - void beRoAnimation2(int); + void beRoAnimation2(int); - void preflopAnimation1(); - void preflopAnimation2(); + void preflopAnimation1(); + void preflopAnimation2(); - void flopAnimation1(); - void flopAnimation2(); + void flopAnimation1(); + void flopAnimation2(); - void turnAnimation1(); - void turnAnimation2(); + void turnAnimation1(); + void turnAnimation2(); - void riverAnimation1(); - void riverAnimation2(); + void riverAnimation1(); + void riverAnimation2(); - void postRiverAnimation1(); - void postRiverRunAnimation1(); + void postRiverAnimation1(); + void postRiverRunAnimation1(); - void flipHolecardsAllIn(); + void flipHolecardsAllIn(); - void nextRoundCleanGui(); + void nextRoundCleanGui(); - void meInAction(); - void updateMyButtonsState(); - void disableMyButtons(); - void startTimeoutAnimation(int playerNum, int timeoutSec); - void stopTimeoutAnimation(int playerNum); + void meInAction(); + void updateMyButtonsState(); + void disableMyButtons(); + void startTimeoutAnimation(int playerNum, int timeoutSec); + void stopTimeoutAnimation(int playerNum); - void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick); - void changeVoteOnKickButtonsState(bool showHide); - void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick); - void endVoteOnKick(); + void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick); + void changeVoteOnKickButtonsState(bool showHide); + void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick); + void endVoteOnKick(); - void logPlayerActionMsg(std::string playerName, int playerID, int action, int setValue) ; - void logNewGameHandMsg(int gameID, int handID) ; - void logPlayerWinsMsg(std::string playerName, int pot, bool main); - void logPlayerSitsOut(std::string playerName); - void logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName); - void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1) ; - void logFlipHoleCardsMsg(std::string playerName, int playerID, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows") ; - void logPlayerWinGame(std::string playerName, int gameID); - void flushLogAtGame(int gameID); - void flushLogAtHand(); + void logPlayerActionMsg(std::string playerName, int playerID, int action, int setValue) ; + void logNewGameHandMsg(int gameID, int handID) ; + void logPlayerWinsMsg(std::string playerName, int pot, bool main); + void logPlayerSitsOut(std::string playerName); + void logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName); + void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1) ; + void logFlipHoleCardsMsg(std::string playerName, int playerID, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows") ; + void logPlayerWinGame(std::string playerName, int gameID); + void flushLogAtGame(int gameID); + void flushLogAtHand(); - void SignalNetClientConnect(int actionID); - void SignalNetClientGameInfo(int actionID); - void SignalNetClientError(int errorID, int osErrorID); - void SignalNetClientNotification(int notificationId); - void SignalNetClientStatsUpdate(const ServerStats &stats); - void SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec); - void SignalNetClientRemovedFromGame(int notificationId); - void SignalNetClientSelfJoined(unsigned playerId, const std::string &playerName, bool isGameAdmin); - void SignalNetClientPlayerJoined(unsigned playerId, const std::string &playerName, bool isGameAdmin); - void SignalNetClientPlayerChanged(unsigned playerId, const std::string &newPlayerName); - void SignalNetClientPlayerLeft(unsigned playerId, const std::string &playerName, int removeReason); - void SignalNetClientNewGameAdmin(unsigned playerId, const std::string &playerName); - void SignalNetClientGameChatMsg(const std::string &playerName, const std::string &msg); - void SignalNetClientLobbyChatMsg(const std::string &playerName, const std::string &msg); - void SignalNetClientWaitDialog(); - void SignalNetClientWarningAutoFoldInRankingGame(unsigned remainingAutoFolds); + void SignalNetClientConnect(int actionID); + void SignalNetClientGameInfo(int actionID); + void SignalNetClientError(int errorID, int osErrorID); + void SignalNetClientNotification(int notificationId); + void SignalNetClientStatsUpdate(const ServerStats &stats); + void SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec); + void SignalNetClientRemovedFromGame(int notificationId); + void SignalNetClientSelfJoined(unsigned playerId, const std::string &playerName, bool isGameAdmin); + void SignalNetClientPlayerJoined(unsigned playerId, const std::string &playerName, bool isGameAdmin); + void SignalNetClientPlayerChanged(unsigned playerId, const std::string &newPlayerName); + void SignalNetClientPlayerLeft(unsigned playerId, const std::string &playerName, int removeReason); + void SignalNetClientNewGameAdmin(unsigned playerId, const std::string &playerName); + void SignalNetClientGameChatMsg(const std::string &playerName, const std::string &msg); + void SignalNetClientLobbyChatMsg(const std::string &playerName, const std::string &msg); + void SignalNetClientWaitDialog(); + void SignalNetClientWarningAutoFoldInRankingGame(unsigned remainingAutoFolds); - void SignalNetClientGameListNew(unsigned gameId); - void SignalNetClientGameListRemove(unsigned gameId); - void SignalNetClientGameListUpdateMode(unsigned gameId, GameMode mode); - void SignalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId); - void SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId); - void SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId); - void SignalNetClientGameStart(boost::shared_ptr game); + void SignalNetClientGameListNew(unsigned gameId); + void SignalNetClientGameListRemove(unsigned gameId); + void SignalNetClientGameListUpdateMode(unsigned gameId, GameMode mode); + void SignalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId); + void SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId); + void SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId); + void SignalNetClientGameStart(boost::shared_ptr game); - void SignalNetClientServerListAdd(unsigned serverId); - void SignalNetClientServerListClear(); - void SignalNetClientServerListShow(); + void SignalNetClientServerListAdd(unsigned serverId); + void SignalNetClientServerListClear(); + void SignalNetClientServerListShow(); - void SignalNetClientLoginShow(); + void SignalNetClientLoginShow(); void SignalNetClientPostRiverShowCards(unsigned playerId); - void SignalNetServerSuccess(int actionID); - void SignalNetServerError(int errorID, int osErrorID); + void SignalNetServerSuccess(int actionID); + void SignalNetServerError(int errorID, int osErrorID); - void SignalIrcConnect(const std::string &server); - void SignalIrcSelfJoined(const std::string &nickName, const std::string &channel); - void SignalIrcPlayerJoined(const std::string &nickName); - void SignalIrcPlayerChanged(const std::string &oldNick, const std::string &newNick); - void SignalIrcPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); - void SignalIrcPlayerLeft(const std::string &nickName); - void SignalIrcChatMsg(const std::string &nickName, const std::string &msg); - void SignalNetClientMsgBox(const std::string &msg); - void SignalNetClientMsgBox(unsigned msgId); - void SignalIrcError(int errorCode); - void SignalIrcServerError(int errorCode); - void SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName); - void SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); - void SignalLobbyPlayerLeft(unsigned playerId); + void SignalIrcConnect(const std::string &server); + void SignalIrcSelfJoined(const std::string &nickName, const std::string &channel); + void SignalIrcPlayerJoined(const std::string &nickName); + void SignalIrcPlayerChanged(const std::string &oldNick, const std::string &newNick); + void SignalIrcPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); + void SignalIrcPlayerLeft(const std::string &nickName); + void SignalIrcChatMsg(const std::string &nickName, const std::string &msg); + void SignalNetClientMsgBox(const std::string &msg); + void SignalNetClientMsgBox(unsigned msgId); + void SignalIrcError(int errorCode); + void SignalIrcServerError(int errorCode); + void SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName); + void SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); + void SignalLobbyPlayerLeft(unsigned playerId); - void SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom); - void SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); - void SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); + void SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom); + void SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); + void SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); private: - boost::shared_ptr mySession; - ConfigFile *myConfig; + boost::shared_ptr mySession; + ConfigFile *myConfig; - ClientCallback *myClientcb; - ServerCallback *myServercb; - IrcCallback *myIrccb; + ClientCallback *myClientcb; + ServerCallback *myServercb; + IrcCallback *myIrccb; }; #endif diff --git a/src/gui/guiinterface.h b/src/gui/guiinterface.h index 58f731ea..7096cb5c 100644 --- a/src/gui/guiinterface.h +++ b/src/gui/guiinterface.h @@ -31,84 +31,85 @@ class guiLog; class Session; class gameTableImpl; -class GuiInterface : public ClientCallback, public ServerCallback, public IrcCallback { +class GuiInterface : public ClientCallback, public ServerCallback, public IrcCallback +{ public: - virtual ~GuiInterface(); + virtual ~GuiInterface(); - virtual void initGui(int speed) =0; + virtual void initGui(int speed) =0; - virtual boost::shared_ptr getSession() =0; - virtual void setSession(boost::shared_ptr session) =0; + virtual boost::shared_ptr getSession() =0; + virtual void setSession(boost::shared_ptr session) =0; - virtual gameTableImpl *getMyW() const=0; - virtual guiLog* getMyGuiLog() const=0; + virtual gameTableImpl *getMyW() const=0; + virtual guiLog* getMyGuiLog() const=0; - //refresh-Funktionen - virtual void refreshSet() const=0; - virtual void refreshCash() const=0; - virtual void refreshAction(int =-1, int =-1) const=0; - virtual void refreshChangePlayer() const=0; - virtual void refreshPot() const=0; - virtual void refreshGroupbox(int =-1, int =-1) const=0; - virtual void refreshAll() const=0; - virtual void refreshPlayerName() const=0; - virtual void refreshButton() const =0; - virtual void refreshGameLabels(GameState state) const=0; + //refresh-Funktionen + virtual void refreshSet() const=0; + virtual void refreshCash() const=0; + virtual void refreshAction(int =-1, int =-1) const=0; + virtual void refreshChangePlayer() const=0; + virtual void refreshPot() const=0; + virtual void refreshGroupbox(int =-1, int =-1) const=0; + virtual void refreshAll() const=0; + virtual void refreshPlayerName() const=0; + virtual void refreshButton() const =0; + virtual void refreshGameLabels(GameState state) const=0; - virtual void setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const=0; - virtual void waitForGuiUpdateDone() const=0; + virtual void setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const=0; + virtual void waitForGuiUpdateDone() const=0; - // Karten-Funktionen - virtual void dealBeRoCards(int) =0; - virtual void dealHoleCards()=0; - virtual void dealFlopCards()=0; - virtual void dealTurnCard()=0; - virtual void dealRiverCard()=0; + // Karten-Funktionen + virtual void dealBeRoCards(int) =0; + virtual void dealHoleCards()=0; + virtual void dealFlopCards()=0; + virtual void dealTurnCard()=0; + virtual void dealRiverCard()=0; - virtual void nextPlayerAnimation()=0; + virtual void nextPlayerAnimation()=0; - virtual void beRoAnimation2(int)=0; + virtual void beRoAnimation2(int)=0; - virtual void preflopAnimation1()=0; - virtual void preflopAnimation2()=0; + virtual void preflopAnimation1()=0; + virtual void preflopAnimation2()=0; - virtual void flopAnimation1()=0; - virtual void flopAnimation2()=0; + virtual void flopAnimation1()=0; + virtual void flopAnimation2()=0; - virtual void turnAnimation1()=0; - virtual void turnAnimation2()=0; + virtual void turnAnimation1()=0; + virtual void turnAnimation2()=0; - virtual void riverAnimation1()=0; - virtual void riverAnimation2()=0; + virtual void riverAnimation1()=0; + virtual void riverAnimation2()=0; - virtual void postRiverAnimation1()=0; - virtual void postRiverRunAnimation1()=0; - virtual void flipHolecardsAllIn()=0; + virtual void postRiverAnimation1()=0; + virtual void postRiverRunAnimation1()=0; + virtual void flipHolecardsAllIn()=0; - virtual void nextRoundCleanGui()=0; - virtual void meInAction()=0; - virtual void updateMyButtonsState()=0; - virtual void disableMyButtons()=0; - virtual void startTimeoutAnimation(int playerNum, int timeoutSec) =0; - virtual void stopTimeoutAnimation(int playerNum) =0; + virtual void nextRoundCleanGui()=0; + virtual void meInAction()=0; + virtual void updateMyButtonsState()=0; + virtual void disableMyButtons()=0; + virtual void startTimeoutAnimation(int playerNum, int timeoutSec) =0; + virtual void stopTimeoutAnimation(int playerNum) =0; - virtual void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick) =0; - virtual void changeVoteOnKickButtonsState(bool showHide) =0; - virtual void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick) =0; - virtual void endVoteOnKick() =0; + virtual void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick) =0; + virtual void changeVoteOnKickButtonsState(bool showHide) =0; + virtual void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick) =0; + virtual void endVoteOnKick() =0; - //log.cpp - virtual void logPlayerActionMsg(std::string playName, int playerID, int action, int setValue) =0; - virtual void logNewGameHandMsg(int gameID, int HandID) =0; - virtual void logPlayerWinsMsg(std::string playerName, int pot, bool main) = 0; - virtual void logPlayerSitsOut(std::string playerName) = 0; - virtual void logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName) =0; - virtual void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1) = 0; - virtual void logFlipHoleCardsMsg(std::string playerName, int playerID, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows") = 0; - virtual void logPlayerWinGame(std::string playerName, int gameID) =0; - virtual void flushLogAtGame(int gameID) =0; - virtual void flushLogAtHand() =0; + //log.cpp + virtual void logPlayerActionMsg(std::string playName, int playerID, int action, int setValue) =0; + virtual void logNewGameHandMsg(int gameID, int HandID) =0; + virtual void logPlayerWinsMsg(std::string playerName, int pot, bool main) = 0; + virtual void logPlayerSitsOut(std::string playerName) = 0; + virtual void logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName) =0; + virtual void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1) = 0; + virtual void logFlipHoleCardsMsg(std::string playerName, int playerID, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows") = 0; + virtual void logPlayerWinGame(std::string playerName, int gameID) =0; + virtual void flushLogAtGame(int gameID) =0; + virtual void flushLogAtHand() =0; }; diff --git a/src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp b/src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp index 8787e3b4..8a1af5de 100755 --- a/src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp +++ b/src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp @@ -24,12 +24,12 @@ aboutPokerthImpl::aboutPokerthImpl(QWidget *parent, ConfigFile *c) - : QDialog(parent), myConfig(c) + : QDialog(parent), myConfig(c) { #ifdef __APPLE__ setWindowModality(Qt::ApplicationModal); setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); -#endif +#endif setupUi(this); myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); @@ -51,9 +51,9 @@ aboutPokerthImpl::aboutPokerthImpl(QWidget *parent, ConfigFile *c) textBrowser_licence->setHtml(gplString); } } - - - label_logo->setPixmap(QPixmap(":/gfx/logoChip3D.png")); + + + label_logo->setPixmap(QPixmap(":/gfx/logoChip3D.png")); label_pokerthVersion->setStyleSheet("QLabel { font-size: 16px; font-weight: bold;}"); label_pokerthVersion->setText(QString(tr("PokerTH %1").arg(POKERTH_BETA_RELEASE_STRING))); diff --git a/src/gui/qt/aboutpokerth/aboutpokerthimpl.h b/src/gui/qt/aboutpokerth/aboutpokerthimpl.h index 9a075e86..37219c23 100755 --- a/src/gui/qt/aboutpokerth/aboutpokerthimpl.h +++ b/src/gui/qt/aboutpokerth/aboutpokerthimpl.h @@ -24,10 +24,11 @@ class ConfigFile; -class aboutPokerthImpl: public QDialog, public Ui::aboutPokerth { -Q_OBJECT +class aboutPokerthImpl: public QDialog, public Ui::aboutPokerth +{ + Q_OBJECT public: - aboutPokerthImpl(QWidget *parent = 0, ConfigFile *c =0); + aboutPokerthImpl(QWidget *parent = 0, ConfigFile *c =0); private: diff --git a/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.cpp b/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.cpp index fd225ff6..84b98bad 100644 --- a/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.cpp +++ b/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.cpp @@ -23,66 +23,73 @@ changeCompleteBlindsDialogImpl::changeCompleteBlindsDialogImpl(QWidget *parent, ConfigFile *c) - : QDialog(parent), myConfig(c), settingsCorrect(TRUE) + : QDialog(parent), myConfig(c), settingsCorrect(TRUE) { #ifdef __APPLE__ setWindowModality(Qt::ApplicationModal); setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); -#endif +#endif setupUi(this); connect( pushButton_add, SIGNAL( clicked() ), this, SLOT( addBlindValueToList() ) ); connect( pushButton_delete, SIGNAL( clicked() ), this, SLOT( removeBlindFromList() ) ); connect( spinBox_firstSmallBlind, SIGNAL( valueChanged(int) ), this, SLOT( updateSpinBoxInputMinimum(int) ) ); - + } -void changeCompleteBlindsDialogImpl::exec() { +void changeCompleteBlindsDialogImpl::exec() +{ QDialog::exec(); } -void changeCompleteBlindsDialogImpl::updateSpinBoxInputMinimum(int value) { spinBox_input->setMinimum(value+1); } +void changeCompleteBlindsDialogImpl::updateSpinBoxInputMinimum(int value) +{ + spinBox_input->setMinimum(value+1); +} -void changeCompleteBlindsDialogImpl::addBlindValueToList() { +void changeCompleteBlindsDialogImpl::addBlindValueToList() +{ - if(listWidget_blinds->count() == 30) { + if(listWidget_blinds->count() == 30) { QMessageBox::warning(this, tr("Manual Blinds Order"), - tr("You cannot set more than 30 manual blinds."), - QMessageBox::Close); } - else { + tr("You cannot set more than 30 manual blinds."), + QMessageBox::Close); + } else { listWidget_blinds->addItem(QString::number(spinBox_input->value(),10)); sortBlindsList(); } } -void changeCompleteBlindsDialogImpl::removeBlindFromList() { +void changeCompleteBlindsDialogImpl::removeBlindFromList() +{ listWidget_blinds->takeItem(listWidget_blinds->currentRow()); sortBlindsList(); } -void changeCompleteBlindsDialogImpl::sortBlindsList() { +void changeCompleteBlindsDialogImpl::sortBlindsList() +{ int i; QList tempIntList; QStringList tempStringList; bool ok = TRUE; - + for(i=0; icount(); i++) { // std::cout << listWidget_blinds->item(i)->text().toInt(&ok,10) << "\n"; - tempIntList << listWidget_blinds->item(i)->text().toInt(&ok,10); + tempIntList << listWidget_blinds->item(i)->text().toInt(&ok,10); } qStableSort(tempIntList.begin(), tempIntList.end()); -// +// for(i=0; iclear(); listWidget_blinds->addItems(tempStringList); } diff --git a/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.h b/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.h index 35a73e00..a5878d3c 100644 --- a/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.h +++ b/src/gui/qt/changecompleteblindsdialog/changecompleteblindsdialogimpl.h @@ -27,24 +27,27 @@ class ConfigFile; -class changeCompleteBlindsDialogImpl: public QDialog, public Ui::changeCompleteBlindsDialog { -Q_OBJECT +class changeCompleteBlindsDialogImpl: public QDialog, public Ui::changeCompleteBlindsDialog +{ + Q_OBJECT public: - changeCompleteBlindsDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); - + changeCompleteBlindsDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); + void exec(); - + public slots: - bool getSettingsCorrect() const { return settingsCorrect;} - + bool getSettingsCorrect() const { + return settingsCorrect; + } + void updateSpinBoxInputMinimum(int); void addBlindValueToList(); void removeBlindFromList(); void sortBlindsList(); private: - + ConfigFile* myConfig; bool settingsCorrect; diff --git a/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp b/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp index 83ee65f7..7722d15a 100644 --- a/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp +++ b/src/gui/qt/changecontentdialog/changecontentdialogimpl.cpp @@ -23,88 +23,89 @@ #include "configfile.h" changeContentDialogImpl::changeContentDialogImpl(QWidget *parent, ConfigFile *config, DialogType t) - : QDialog(parent), myConfig(config), myType(t) + : QDialog(parent), myConfig(config), myType(t) { #ifdef __APPLE__ - setWindowModality(Qt::ApplicationModal); - setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); -#endif - setupUi(this); + setWindowModality(Qt::ApplicationModal); + setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); +#endif + setupUi(this); - switch (myType) { - case CHANGE_HUMAN_PLAYER_NAME: { + switch (myType) { + case CHANGE_HUMAN_PLAYER_NAME: { - label_Message->setText(tr("You cannot join Internet-Game-Lobby with \"Human Player\" as nickname.\nPlease choose another one.")); - label_lineLabel->setText(tr("Nick name:")); - lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); - lineEdit->setMaxLength(12); - checkBox->hide(); - this->setGeometry(this->x(), this->y(), this->width(), this->height()-20 ); - } - break; - case CHANGE_NICK_ALREADY_IN_USE: { - label_Message->setText(tr("Your player name is already used by another player.\nPlease choose a different name.")); - label_lineLabel->setText(tr("Nick name:")); - lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); - lineEdit->setMaxLength(12); - } - break; - case CHANGE_NICK_INVALID: { - label_Message->setText(tr("The player name is too short, too long or invalid. Please choose another one.")); - label_lineLabel->setText(tr("Nick name:")); - lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); - lineEdit->setMaxLength(12); - } - break; - case CHANGE_INET_GAME_NAME_IN_USE: { - label_Message->setText(tr("There is already a game with your chosen game name.\nPlease choose another one!")); - label_lineLabel->setText(tr("Game name:")); - lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str())); - lineEdit->setMaxLength(48); - } - break; - case CHANGE_INET_BAD_GAME_NAME: { - label_Message->setText(tr("There is a forbidden word in your chosen game name.\nPlease choose another one!")); - label_lineLabel->setText(tr("Game name:")); - lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str())); - lineEdit->setMaxLength(48); - } - break; - } + label_Message->setText(tr("You cannot join Internet-Game-Lobby with \"Human Player\" as nickname.\nPlease choose another one.")); + label_lineLabel->setText(tr("Nick name:")); + lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); + lineEdit->setMaxLength(12); + checkBox->hide(); + this->setGeometry(this->x(), this->y(), this->width(), this->height()-20 ); + } + break; + case CHANGE_NICK_ALREADY_IN_USE: { + label_Message->setText(tr("Your player name is already used by another player.\nPlease choose a different name.")); + label_lineLabel->setText(tr("Nick name:")); + lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); + lineEdit->setMaxLength(12); + } + break; + case CHANGE_NICK_INVALID: { + label_Message->setText(tr("The player name is too short, too long or invalid. Please choose another one.")); + label_lineLabel->setText(tr("Nick name:")); + lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); + lineEdit->setMaxLength(12); + } + break; + case CHANGE_INET_GAME_NAME_IN_USE: { + label_Message->setText(tr("There is already a game with your chosen game name.\nPlease choose another one!")); + label_lineLabel->setText(tr("Game name:")); + lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str())); + lineEdit->setMaxLength(48); + } + break; + case CHANGE_INET_BAD_GAME_NAME: { + label_Message->setText(tr("There is a forbidden word in your chosen game name.\nPlease choose another one!")); + label_lineLabel->setText(tr("Game name:")); + lineEdit->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str())); + lineEdit->setMaxLength(48); + } + break; + } - connect(this, SIGNAL(accepted ()), this, SLOT(saveContent())); + connect(this, SIGNAL(accepted ()), this, SLOT(saveContent())); } -void changeContentDialogImpl::saveContent() { +void changeContentDialogImpl::saveContent() +{ - switch (myType) { - case CHANGE_HUMAN_PLAYER_NAME: { - myConfig->writeConfigString("MyName", lineEdit->text().toUtf8().constData()); - } - break; - case CHANGE_NICK_ALREADY_IN_USE: { - if(checkBox->isChecked()) { - myConfig->writeConfigString("MyName", lineEdit->text().toUtf8().constData()); - } - } - break; - case CHANGE_NICK_INVALID: { - if(checkBox->isChecked()) { - myConfig->writeConfigString("MyName", lineEdit->text().toUtf8().constData()); - } - } - break; - case CHANGE_INET_BAD_GAME_NAME: - case CHANGE_INET_GAME_NAME_IN_USE: { - if(checkBox->isChecked()) { - myConfig->writeConfigString("InternetGameName", lineEdit->text().toUtf8().constData()); - } - } - break; - } + switch (myType) { + case CHANGE_HUMAN_PLAYER_NAME: { + myConfig->writeConfigString("MyName", lineEdit->text().toUtf8().constData()); + } + break; + case CHANGE_NICK_ALREADY_IN_USE: { + if(checkBox->isChecked()) { + myConfig->writeConfigString("MyName", lineEdit->text().toUtf8().constData()); + } + } + break; + case CHANGE_NICK_INVALID: { + if(checkBox->isChecked()) { + myConfig->writeConfigString("MyName", lineEdit->text().toUtf8().constData()); + } + } + break; + case CHANGE_INET_BAD_GAME_NAME: + case CHANGE_INET_GAME_NAME_IN_USE: { + if(checkBox->isChecked()) { + myConfig->writeConfigString("InternetGameName", lineEdit->text().toUtf8().constData()); + } + } + break; + } - //write buffer to disc - myConfig->writeBuffer(); + //write buffer to disc + myConfig->writeBuffer(); } diff --git a/src/gui/qt/changecontentdialog/changecontentdialogimpl.h b/src/gui/qt/changecontentdialog/changecontentdialogimpl.h index d8fca7e4..36b1424d 100644 --- a/src/gui/qt/changecontentdialog/changecontentdialogimpl.h +++ b/src/gui/qt/changecontentdialog/changecontentdialogimpl.h @@ -28,18 +28,19 @@ enum DialogType { CHANGE_HUMAN_PLAYER_NAME=0, CHANGE_NICK_ALREADY_IN_USE, CHANGE class ConfigFile; -class changeContentDialogImpl: public QDialog, public Ui::changeContentDialog { - Q_OBJECT +class changeContentDialogImpl: public QDialog, public Ui::changeContentDialog +{ + Q_OBJECT public: - changeContentDialogImpl(QWidget *parent, ConfigFile *config, DialogType t); + changeContentDialogImpl(QWidget *parent, ConfigFile *config, DialogType t); public slots: - void saveContent(); + void saveContent(); -private: - ConfigFile *myConfig; - DialogType myType; +private: + ConfigFile *myConfig; + DialogType myType; }; diff --git a/src/gui/qt/chattools/chattools.cpp b/src/gui/qt/chattools/chattools.cpp index fd547996..1d591116 100644 --- a/src/gui/qt/chattools/chattools.cpp +++ b/src/gui/qt/chattools/chattools.cpp @@ -30,8 +30,8 @@ using namespace std; ChatTools::ChatTools(QLineEdit* l, ConfigFile *c, ChatType ct, QTextBrowser *b, QStandardItemModel *m, gameLobbyDialogImpl *lo) : nickAutoCompletitionCounter(0), myLineEdit(l), myNickListModel(m), myNickStringList(NULL), myTextBrowser(b), myChatType(ct), myConfig(c), myNick(""), myLobby(lo) { - myNick = QString::fromUtf8(myConfig->readConfigString("MyName").c_str()); - ignoreList = myConfig->readConfigStringList("PlayerIgnoreList"); + myNick = QString::fromUtf8(myConfig->readConfigString("MyName").c_str()); + ignoreList = myConfig->readConfigStringList("PlayerIgnoreList"); } @@ -39,197 +39,211 @@ ChatTools::~ChatTools() { } -void ChatTools::sendMessage() { +void ChatTools::sendMessage() +{ - if(myLineEdit->text().size() && mySession) { - fillChatLinesHistory(myLineEdit->text()); - if(myChatType == INGAME_CHAT) { - mySession->sendGameChatMessage(myLineEdit->text().toUtf8().constData()); - } - else { - mySession->sendLobbyChatMessage(myLineEdit->text().toUtf8().constData()); - } - myLineEdit->setText(""); - } + if(myLineEdit->text().size() && mySession) { + fillChatLinesHistory(myLineEdit->text()); + if(myChatType == INGAME_CHAT) { + mySession->sendGameChatMessage(myLineEdit->text().toUtf8().constData()); + } else { + mySession->sendLobbyChatMessage(myLineEdit->text().toUtf8().constData()); + } + myLineEdit->setText(""); + } } -void ChatTools::receiveMessage(QString playerName, QString message) { +void ChatTools::receiveMessage(QString playerName, QString message) +{ - if(myTextBrowser) { + if(myTextBrowser) { - message = message.replace("<","<"); - message = message.replace(">",">"); + message = message.replace("<","<"); + message = message.replace(">",">"); - //refresh myNick if it was changed during runtime - myNick = QString::fromUtf8(myConfig->readConfigString("MyName").c_str()); + //refresh myNick if it was changed during runtime + myNick = QString::fromUtf8(myConfig->readConfigString("MyName").c_str()); - QString tempMsg; + QString tempMsg; - if(myChatType == INET_LOBBY_CHAT && playerName == "(chat bot)" && message.startsWith(myNick)) { + if(myChatType == INET_LOBBY_CHAT && playerName == "(chat bot)" && message.startsWith(myNick)) { - tempMsg = QString(""+message+""); - //play beep sound only in INET-lobby-chat - if(myLobby->isVisible() && myConfig->readConfigInt("PlayLobbyChatNotification")) { - myLobby->getMyW()->getMySDLPlayer()->playSound("lobbychatnotify",0); - } - } - else if(message.contains(myNick, Qt::CaseInsensitive)) { + tempMsg = QString(""+message+""); + //play beep sound only in INET-lobby-chat + if(myLobby->isVisible() && myConfig->readConfigInt("PlayLobbyChatNotification")) { + myLobby->getMyW()->getMySDLPlayer()->playSound("lobbychatnotify",0); + } + } else if(message.contains(myNick, Qt::CaseInsensitive)) { - switch (myChatType) { - case INET_LOBBY_CHAT: { - tempMsg = QString("palette().link().color().name()+";\">"+message+""); - //play beep sound only in INET-lobby-chat - // TODO dont play when message is from yourself - if(myLobby->isVisible() && myConfig->readConfigInt("PlayLobbyChatNotification")) { - myLobby->getMyW()->getMySDLPlayer()->playSound("lobbychatnotify",0); - } - } - break; - case LAN_LOBBY_CHAT: tempMsg = QString(""+message+""); - break; - case INGAME_CHAT: tempMsg = QString("getChatTextNickNotifyColor()+";\">"+message+""); - break; - default: tempMsg = message; - } - } - else if(playerName == myNick) { - switch (myChatType) { - case INET_LOBBY_CHAT: tempMsg = QString("palette().link().color().name()+";\">"+message+""); - break; - case LAN_LOBBY_CHAT: tempMsg = QString(""+message+""); - break; - case INGAME_CHAT: tempMsg = QString("getChatLogTextColor()+";\">"+message+""); - break; - default: tempMsg = message; - } - } - else { - switch (myChatType) { - case INET_LOBBY_CHAT: tempMsg = QString("palette().text().color().name()+";\">"+message+""); - break; - case LAN_LOBBY_CHAT: tempMsg = QString(""+message+""); - break; - case INGAME_CHAT: tempMsg = QString("getChatLogTextColor()+";\">"+message+""); - break; - default: tempMsg = message; - } + switch (myChatType) { + case INET_LOBBY_CHAT: { + tempMsg = QString("palette().link().color().name()+";\">"+message+""); + //play beep sound only in INET-lobby-chat + // TODO dont play when message is from yourself + if(myLobby->isVisible() && myConfig->readConfigInt("PlayLobbyChatNotification")) { + myLobby->getMyW()->getMySDLPlayer()->playSound("lobbychatnotify",0); + } + } + break; + case LAN_LOBBY_CHAT: + tempMsg = QString(""+message+""); + break; + case INGAME_CHAT: + tempMsg = QString("getChatTextNickNotifyColor()+";\">"+message+""); + break; + default: + tempMsg = message; + } + } else if(playerName == myNick) { + switch (myChatType) { + case INET_LOBBY_CHAT: + tempMsg = QString("palette().link().color().name()+";\">"+message+""); + break; + case LAN_LOBBY_CHAT: + tempMsg = QString(""+message+""); + break; + case INGAME_CHAT: + tempMsg = QString("getChatLogTextColor()+";\">"+message+""); + break; + default: + tempMsg = message; + } + } else { + switch (myChatType) { + case INET_LOBBY_CHAT: + tempMsg = QString("palette().text().color().name()+";\">"+message+""); + break; + case LAN_LOBBY_CHAT: + tempMsg = QString(""+message+""); + break; + case INGAME_CHAT: + tempMsg = QString("getChatLogTextColor()+";\">"+message+""); + break; + default: + tempMsg = message; + } - } + } - bool nickFoundOnIgnoreList = false; - list::iterator it1; + bool nickFoundOnIgnoreList = false; + list::iterator it1; for(it1=ignoreList.begin(); it1 != ignoreList.end(); ++it1) { - if(playerName == QString::fromUtf8(it1->c_str())) { - nickFoundOnIgnoreList = true; - } - } + if(playerName == QString::fromUtf8(it1->c_str())) { + nickFoundOnIgnoreList = true; + } + } - if(!nickFoundOnIgnoreList) { + if(!nickFoundOnIgnoreList) { if(message.indexOf(QString("/me "))==0) { myTextBrowser->append(tempMsg.replace("/me ","*"+playerName+" ")+""); - } - else { - myTextBrowser->append(playerName + ": " + tempMsg); - } - } - } + } else { + myTextBrowser->append(playerName + ": " + tempMsg); + } + } + } } -void ChatTools::clearChat() { +void ChatTools::clearChat() +{ - if(myTextBrowser) - myTextBrowser->clear(); + if(myTextBrowser) + myTextBrowser->clear(); } -void ChatTools::checkInputLength(QString string) { +void ChatTools::checkInputLength(QString string) +{ - if(string.toUtf8().length() > 120) myLineEdit->setMaxLength(string.length()); + if(string.toUtf8().length() > 120) myLineEdit->setMaxLength(string.length()); } -void ChatTools::fillChatLinesHistory(QString fillString) { +void ChatTools::fillChatLinesHistory(QString fillString) +{ - chatLinesHistory << fillString; - if(chatLinesHistory.size() > 50) chatLinesHistory.removeFirst(); + chatLinesHistory << fillString; + if(chatLinesHistory.size() > 50) chatLinesHistory.removeFirst(); } -void ChatTools::showChatHistoryIndex(int index) { +void ChatTools::showChatHistoryIndex(int index) +{ - if(index <= chatLinesHistory.size()) { + if(index <= chatLinesHistory.size()) { - // cout << chatLinesHistory.size() << " : " << index << endl; - if(index > 0) - myLineEdit->setText(chatLinesHistory.at(chatLinesHistory.size()-(index))); - else - myLineEdit->setText(""); - } + // cout << chatLinesHistory.size() << " : " << index << endl; + if(index > 0) + myLineEdit->setText(chatLinesHistory.at(chatLinesHistory.size()-(index))); + else + myLineEdit->setText(""); + } } -void ChatTools::nickAutoCompletition() { +void ChatTools::nickAutoCompletition() +{ - QString myChatString = myLineEdit->text(); - QStringList myChatStringList = myChatString.split(" "); + QString myChatString = myLineEdit->text(); + QStringList myChatStringList = myChatString.split(" "); - QStringList matchStringList; + QStringList matchStringList; - if(nickAutoCompletitionCounter == 0) { + if(nickAutoCompletitionCounter == 0) { - if(myNickListModel) { - int it = 0; - while (myNickListModel->item(it)) { - QString text = myNickListModel->item(it, 0)->data(Qt::DisplayRole).toString(); - if(text.startsWith(myChatStringList.last(), Qt::CaseInsensitive) && myChatStringList.last() != "") { - matchStringList << text; - } - ++it; - } - } + if(myNickListModel) { + int it = 0; + while (myNickListModel->item(it)) { + QString text = myNickListModel->item(it, 0)->data(Qt::DisplayRole).toString(); + if(text.startsWith(myChatStringList.last(), Qt::CaseInsensitive) && myChatStringList.last() != "") { + matchStringList << text; + } + ++it; + } + } - if(!myNickStringList.isEmpty()) { + if(!myNickStringList.isEmpty()) { - QStringListIterator it(myNickStringList); - while (it.hasNext()) { - QString next = it.next(); - if (next.startsWith(myChatStringList.last(), Qt::CaseInsensitive) && myChatStringList.last() != "") - matchStringList << next; - } - } - } + QStringListIterator it(myNickStringList); + while (it.hasNext()) { + QString next = it.next(); + if (next.startsWith(myChatStringList.last(), Qt::CaseInsensitive) && myChatStringList.last() != "") + matchStringList << next; + } + } + } - if(!matchStringList.isEmpty() || nickAutoCompletitionCounter > 0) { + if(!matchStringList.isEmpty() || nickAutoCompletitionCounter > 0) { - myChatStringList.removeLast(); + myChatStringList.removeLast(); - // cout << nickAutoCompletitionCounter << endl; + // cout << nickAutoCompletitionCounter << endl; - if(nickAutoCompletitionCounter == 0) { - //first one - lastChatString = myChatStringList.join(" "); - lastMatchStringList = matchStringList; - } + if(nickAutoCompletitionCounter == 0) { + //first one + lastChatString = myChatStringList.join(" "); + lastMatchStringList = matchStringList; + } - if(nickAutoCompletitionCounter == lastMatchStringList.size()) nickAutoCompletitionCounter = 0; + if(nickAutoCompletitionCounter == lastMatchStringList.size()) nickAutoCompletitionCounter = 0; - // cout << nickAutoCompletitionCounter << "\n"; + // cout << nickAutoCompletitionCounter << "\n"; - if(lastChatString == "") - myLineEdit->setText(lastMatchStringList.at(nickAutoCompletitionCounter)+": "); - else - myLineEdit->setText(lastChatString+" "+lastMatchStringList.at(nickAutoCompletitionCounter)+" "); + if(lastChatString == "") + myLineEdit->setText(lastMatchStringList.at(nickAutoCompletitionCounter)+": "); + else + myLineEdit->setText(lastChatString+" "+lastMatchStringList.at(nickAutoCompletitionCounter)+" "); - nickAutoCompletitionCounter++; - } + nickAutoCompletitionCounter++; + } } -void ChatTools::setChatTextEdited() { +void ChatTools::setChatTextEdited() +{ - nickAutoCompletitionCounter = 0; + nickAutoCompletitionCounter = 0; } void ChatTools::refreshIgnoreList() { - ignoreList = myConfig->readConfigStringList("PlayerIgnoreList"); + ignoreList = myConfig->readConfigStringList("PlayerIgnoreList"); } diff --git a/src/gui/qt/chattools/chattools.h b/src/gui/qt/chattools/chattools.h index 7573d6c2..187d44ed 100644 --- a/src/gui/qt/chattools/chattools.h +++ b/src/gui/qt/chattools/chattools.h @@ -34,58 +34,70 @@ class gameLobbyDialogImpl; class ChatTools : public QObject { - Q_OBJECT + Q_OBJECT public: - ChatTools(QLineEdit*, ConfigFile*, ChatType, QTextBrowser *b = NULL, QStandardItemModel *m = NULL, gameLobbyDialogImpl *lo = NULL); + ChatTools(QLineEdit*, ConfigFile*, ChatType, QTextBrowser *b = NULL, QStandardItemModel *m = NULL, gameLobbyDialogImpl *lo = NULL); - ~ChatTools(); + ~ChatTools(); - void setSession(boost::shared_ptr session) { mySession = session; } + void setSession(boost::shared_ptr session) { + mySession = session; + } public slots: - void sendMessage(); - void receiveMessage(QString playerName, QString message); - void clearChat(); - void checkInputLength(QString string); + void sendMessage(); + void receiveMessage(QString playerName, QString message); + void clearChat(); + void checkInputLength(QString string); - void fillChatLinesHistory(QString fillString); - void showChatHistoryIndex(int index); - int getChatLinesHistorySize() { return chatLinesHistory.size(); } + void fillChatLinesHistory(QString fillString); + void showChatHistoryIndex(int index); + int getChatLinesHistorySize() { + return chatLinesHistory.size(); + } - void nickAutoCompletition(); - void setChatTextEdited(); + void nickAutoCompletition(); + void setChatTextEdited(); - void setPlayerNicksList(QStringList value) { myNickStringList = value; } - void setMyNick ( const QString& theValue ) { myNick = theValue; } - QString getMyNick () { return myNick; } + void setPlayerNicksList(QStringList value) { + myNickStringList = value; + } + void setMyNick ( const QString& theValue ) { + myNick = theValue; + } + QString getMyNick () { + return myNick; + } - void setMyStyle ( GameTableStyleReader* theValue ) { myStyle = theValue; } - void refreshIgnoreList(); + void setMyStyle ( GameTableStyleReader* theValue ) { + myStyle = theValue; + } + void refreshIgnoreList(); private: - QStringList chatLinesHistory; - QString lastChatString; - QStringList lastMatchStringList; - int nickAutoCompletitionCounter; + QStringList chatLinesHistory; + QString lastChatString; + QStringList lastMatchStringList; + int nickAutoCompletitionCounter; - QLineEdit *myLineEdit; - QStandardItemModel *myNickListModel; - QStringList myNickStringList; - QTextBrowser *myTextBrowser; - boost::shared_ptr mySession; - ChatType myChatType; - ConfigFile *myConfig; + QLineEdit *myLineEdit; + QStandardItemModel *myNickListModel; + QStringList myNickStringList; + QTextBrowser *myTextBrowser; + boost::shared_ptr mySession; + ChatType myChatType; + ConfigFile *myConfig; - QString myNick; + QString myNick; - GameTableStyleReader *myStyle; - gameLobbyDialogImpl *myLobby; + GameTableStyleReader *myStyle; + gameLobbyDialogImpl *myLobby; - std::list ignoreList; + std::list ignoreList; }; #endif diff --git a/src/gui/qt/connecttoserverdialog/connecttoserverdialogimpl.cpp b/src/gui/qt/connecttoserverdialog/connecttoserverdialogimpl.cpp index 83053905..bfc8de79 100644 --- a/src/gui/qt/connecttoserverdialog/connecttoserverdialogimpl.cpp +++ b/src/gui/qt/connecttoserverdialog/connecttoserverdialogimpl.cpp @@ -21,13 +21,13 @@ #include connectToServerDialogImpl::connectToServerDialogImpl(QWidget *parent) - : QDialog(parent) + : QDialog(parent) { #ifdef __APPLE__ setWindowModality(Qt::ApplicationModal); setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); -#endif - setupUi(this); +#endif + setupUi(this); } void connectToServerDialogImpl::exec() @@ -38,26 +38,37 @@ void connectToServerDialogImpl::exec() QDialog::exec(); } -void connectToServerDialogImpl::refresh(int actionID) { +void connectToServerDialogImpl::refresh(int actionID) +{ bool skip = false; switch (actionID) { - case MSG_SOCK_INIT_DONE: { label_actionMessage->setText(tr("Resolving address...")); } - break; - case MSG_SOCK_SERVER_LIST_DONE : { label_actionMessage->setText(tr("Reading server list...")); } - break; - case MSG_SOCK_RESOLVE_DONE: { label_actionMessage->setText(tr("Connecting to server...")); } - break; - case MSG_SOCK_CONNECT_DONE: { label_actionMessage->setText(tr("Starting session...")); } - break; - case MSG_SOCK_SESSION_DONE: { label_actionMessage->setText(tr("Connection established!")); } - break; - default: skip = true; + case MSG_SOCK_INIT_DONE: { + label_actionMessage->setText(tr("Resolving address...")); + } + break; + case MSG_SOCK_SERVER_LIST_DONE : { + label_actionMessage->setText(tr("Reading server list...")); + } + break; + case MSG_SOCK_RESOLVE_DONE: { + label_actionMessage->setText(tr("Connecting to server...")); + } + break; + case MSG_SOCK_CONNECT_DONE: { + label_actionMessage->setText(tr("Starting session...")); + } + break; + case MSG_SOCK_SESSION_DONE: { + label_actionMessage->setText(tr("Connection established!")); + } + break; + default: + skip = true; } - if (!skip) - { + if (!skip) { progressBar->setValue(actionID*(100/MSG_SOCK_LIMIT_CONNECT)); if (actionID == MSG_SOCK_LIMIT_CONNECT) diff --git a/src/gui/qt/connecttoserverdialog/connecttoserverdialogimpl.h b/src/gui/qt/connecttoserverdialog/connecttoserverdialogimpl.h index 7c4d47ae..71c844e4 100644 --- a/src/gui/qt/connecttoserverdialog/connecttoserverdialogimpl.h +++ b/src/gui/qt/connecttoserverdialog/connecttoserverdialogimpl.h @@ -26,10 +26,11 @@ #include -class connectToServerDialogImpl: public QDialog, public Ui::connectToServerDialog { -Q_OBJECT +class connectToServerDialogImpl: public QDialog, public Ui::connectToServerDialog +{ + Q_OBJECT public: - connectToServerDialogImpl(QWidget *parent = 0); + connectToServerDialogImpl(QWidget *parent = 0); void exec(); diff --git a/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp index 4ce99e26..9f49fd6a 100644 --- a/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp +++ b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.cpp @@ -25,55 +25,59 @@ createInternetGameDialogImpl::createInternetGameDialogImpl(QWidget *parent, ConfigFile *c) - : QDialog(parent), myConfig(c), currentGuestMode(false), currentPlayerName("") + : QDialog(parent), myConfig(c), currentGuestMode(false), currentPlayerName("") { #ifdef __APPLE__ setWindowModality(Qt::ApplicationModal); setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); -#endif - setupUi(this); +#endif + setupUi(this); - comboBox_gameType->setItemData(0, GAME_TYPE_NORMAL, Qt::UserRole); - comboBox_gameType->setItemData(1, GAME_TYPE_REGISTERED_ONLY, Qt::UserRole); - comboBox_gameType->setItemData(2, GAME_TYPE_INVITE_ONLY, Qt::UserRole); - comboBox_gameType->setItemData(3, GAME_TYPE_RANKING, Qt::UserRole); + comboBox_gameType->setItemData(0, GAME_TYPE_NORMAL, Qt::UserRole); + comboBox_gameType->setItemData(1, GAME_TYPE_REGISTERED_ONLY, Qt::UserRole); + comboBox_gameType->setItemData(2, GAME_TYPE_INVITE_ONLY, Qt::UserRole); + comboBox_gameType->setItemData(3, GAME_TYPE_RANKING, Qt::UserRole); myChangeCompleteBlindsDialog = new changeCompleteBlindsDialogImpl; - startBlind = new QLabel(tr("First small blind: $%1").arg(RANKING_GAME_START_SBLIND)); - raiseMode = new QLabel(tr("Double blinds every %1'th hand").arg(RANKING_GAME_RAISE_EVERY_HAND)); - startBlind->hide(); - raiseMode->hide(); - gridLayout1->addWidget(startBlind, 0, 0, 1, 1); - gridLayout1->addWidget(raiseMode, 1, 0, 1, 1); + startBlind = new QLabel(tr("First small blind: $%1").arg(RANKING_GAME_START_SBLIND)); + raiseMode = new QLabel(tr("Double blinds every %1'th hand").arg(RANKING_GAME_RAISE_EVERY_HAND)); + startBlind->hide(); + raiseMode->hide(); + gridLayout1->addWidget(startBlind, 0, 0, 1, 1); + gridLayout1->addWidget(raiseMode, 1, 0, 1, 1); connect( radioButton_changeBlindsSettings, SIGNAL( clicked(bool) ), this, SLOT( callChangeBlindsDialog(bool) ) ); connect( pushButton_cancel, SIGNAL( clicked() ), this, SLOT( cancel() ) ); connect( pushButton_createGame, SIGNAL( clicked() ), this, SLOT( createGame() ) ); - connect( checkBox_Password, SIGNAL( toggled(bool) ), this, SLOT( clearGamePassword(bool)) ); - connect( comboBox_gameType, SIGNAL(currentIndexChanged(int)), this, SLOT( gameTypeChanged() ) ); + connect( checkBox_Password, SIGNAL( toggled(bool) ), this, SLOT( clearGamePassword(bool)) ); + connect( comboBox_gameType, SIGNAL(currentIndexChanged(int)), this, SLOT( gameTypeChanged() ) ); } -void createInternetGameDialogImpl::exec(bool guestMode, QString playerName) { - - currentGuestMode = guestMode; - currentPlayerName = playerName; - fillFormular(guestMode, playerName); +void createInternetGameDialogImpl::exec(bool guestMode, QString playerName) +{ + + currentGuestMode = guestMode; + currentPlayerName = playerName; + fillFormular(guestMode, playerName); QDialog::exec(); } -void createInternetGameDialogImpl::createGame() { - +void createInternetGameDialogImpl::createGame() +{ + } -void createInternetGameDialogImpl::cancel() { - +void createInternetGameDialogImpl::cancel() +{ + } -void createInternetGameDialogImpl::fillFormular(bool guestMode, QString playerName) { - +void createInternetGameDialogImpl::fillFormular(bool guestMode, QString playerName) +{ + //Network Game Settings spinBox_netDelayBetweenHands->setValue(myConfig->readConfigInt("NetDelayBetweenHands")); spinBox_netTimeOutPlayerAction->setValue(myConfig->readConfigInt("NetTimeOutPlayerAction")); @@ -83,36 +87,42 @@ void createInternetGameDialogImpl::fillFormular(bool guestMode, QString playerNa } - if(guestMode) { - comboBox_gameType->setCurrentIndex(0); - comboBox_gameType->setDisabled(true); - lineEdit_gameName->setText(tr("%1's game").arg(playerName)); - lineEdit_gameName->setDisabled(true); + if(guestMode) { + comboBox_gameType->setCurrentIndex(0); + comboBox_gameType->setDisabled(true); + lineEdit_gameName->setText(tr("%1's game").arg(playerName)); + lineEdit_gameName->setDisabled(true); - } - else { - comboBox_gameType->setDisabled(false); - comboBox_gameType->setCurrentIndex(myConfig->readConfigInt("InternetGameType")); - lineEdit_gameName->setDisabled(false); - lineEdit_gameName->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str())); - } + } else { + comboBox_gameType->setDisabled(false); + comboBox_gameType->setCurrentIndex(myConfig->readConfigInt("InternetGameType")); + lineEdit_gameName->setDisabled(false); + lineEdit_gameName->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str())); + } - gameTypeChanged(); + gameTypeChanged(); } -void createInternetGameDialogImpl::keyPressEvent ( QKeyEvent * event ) { +void createInternetGameDialogImpl::keyPressEvent ( QKeyEvent * event ) +{ - if (event->key() == 16777220) { pushButton_createGame->click(); } //ENTER - + if (event->key() == 16777220) { + pushButton_createGame->click(); //ENTER + } + } -void createInternetGameDialogImpl::clearGamePassword(bool clear) { +void createInternetGameDialogImpl::clearGamePassword(bool clear) +{ - if(!clear) { lineEdit_Password->clear(); } + if(!clear) { + lineEdit_Password->clear(); + } } -void createInternetGameDialogImpl::callChangeBlindsDialog(bool show) { +void createInternetGameDialogImpl::callChangeBlindsDialog(bool show) +{ if(show) { myChangeCompleteBlindsDialog->exec(); @@ -124,100 +134,100 @@ void createInternetGameDialogImpl::callChangeBlindsDialog(bool show) { } } -void createInternetGameDialogImpl::gameTypeChanged() { +void createInternetGameDialogImpl::gameTypeChanged() +{ - switch (comboBox_gameType->currentIndex()) { + switch (comboBox_gameType->currentIndex()) { - case GAME_TYPE_NORMAL-1: { - checkBox_Password->setDisabled(FALSE); - spinBox_startCash->setDisabled(FALSE); - spinBox_quantityPlayers->setDisabled(FALSE); - spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers")); - spinBox_startCash->setValue(myConfig->readConfigInt("NetStartCash")); - radioButton_useSavedBlindsSettings->show(); - radioButton_changeBlindsSettings->show(); - startBlind->hide(); - raiseMode->hide(); - } + case GAME_TYPE_NORMAL-1: { + checkBox_Password->setDisabled(FALSE); + spinBox_startCash->setDisabled(FALSE); + spinBox_quantityPlayers->setDisabled(FALSE); + spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers")); + spinBox_startCash->setValue(myConfig->readConfigInt("NetStartCash")); + radioButton_useSavedBlindsSettings->show(); + radioButton_changeBlindsSettings->show(); + startBlind->hide(); + raiseMode->hide(); + } - break; - case GAME_TYPE_REGISTERED_ONLY-1: { - checkBox_Password->setDisabled(FALSE); - spinBox_startCash->setDisabled(FALSE); - spinBox_quantityPlayers->setDisabled(FALSE); - spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers")); - spinBox_startCash->setValue(myConfig->readConfigInt("NetStartCash")); - radioButton_useSavedBlindsSettings->show(); - radioButton_changeBlindsSettings->show(); - startBlind->hide(); - raiseMode->hide(); - } - break; - case GAME_TYPE_INVITE_ONLY-1: { - checkBox_Password->setChecked(FALSE); - checkBox_Password->setDisabled(TRUE); - spinBox_startCash->setDisabled(FALSE); - spinBox_quantityPlayers->setDisabled(FALSE); - spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers")); - spinBox_startCash->setValue(myConfig->readConfigInt("NetStartCash")); - radioButton_useSavedBlindsSettings->show(); - radioButton_changeBlindsSettings->show(); - startBlind->hide(); - raiseMode->hide(); + break; + case GAME_TYPE_REGISTERED_ONLY-1: { + checkBox_Password->setDisabled(FALSE); + spinBox_startCash->setDisabled(FALSE); + spinBox_quantityPlayers->setDisabled(FALSE); + spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers")); + spinBox_startCash->setValue(myConfig->readConfigInt("NetStartCash")); + radioButton_useSavedBlindsSettings->show(); + radioButton_changeBlindsSettings->show(); + startBlind->hide(); + raiseMode->hide(); + } + break; + case GAME_TYPE_INVITE_ONLY-1: { + checkBox_Password->setChecked(FALSE); + checkBox_Password->setDisabled(TRUE); + spinBox_startCash->setDisabled(FALSE); + spinBox_quantityPlayers->setDisabled(FALSE); + spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers")); + spinBox_startCash->setValue(myConfig->readConfigInt("NetStartCash")); + radioButton_useSavedBlindsSettings->show(); + radioButton_changeBlindsSettings->show(); + startBlind->hide(); + raiseMode->hide(); - } - break; - case GAME_TYPE_RANKING-1: { - checkBox_Password->setChecked(FALSE); - checkBox_Password->setDisabled(TRUE); + } + break; + case GAME_TYPE_RANKING-1: { + checkBox_Password->setChecked(FALSE); + checkBox_Password->setDisabled(TRUE); - spinBox_startCash->setValue(RANKING_GAME_START_CASH); - spinBox_startCash->setDisabled(TRUE); - spinBox_quantityPlayers->setValue(RANKING_GAME_NUMBER_OF_PLAYERS); - spinBox_quantityPlayers->setDisabled(TRUE); - radioButton_useSavedBlindsSettings->hide(); - radioButton_changeBlindsSettings->hide(); - startBlind->show(); - raiseMode->show(); + spinBox_startCash->setValue(RANKING_GAME_START_CASH); + spinBox_startCash->setDisabled(TRUE); + spinBox_quantityPlayers->setValue(RANKING_GAME_NUMBER_OF_PLAYERS); + spinBox_quantityPlayers->setDisabled(TRUE); + radioButton_useSavedBlindsSettings->hide(); + radioButton_changeBlindsSettings->hide(); + startBlind->show(); + raiseMode->show(); - } - break; - } + } + break; + } - if(comboBox_gameType->currentIndex() == GAME_TYPE_RANKING-1) { - //set static values - myChangeCompleteBlindsDialog->spinBox_firstSmallBlind->setValue(RANKING_GAME_START_SBLIND); - myChangeCompleteBlindsDialog->radioButton_raiseBlindsAtHands->setChecked(TRUE); - myChangeCompleteBlindsDialog->radioButton_raiseBlindsAtMinutes->setChecked(FALSE); - myChangeCompleteBlindsDialog->spinBox_raiseSmallBlindEveryHands->setValue(11); - myChangeCompleteBlindsDialog->radioButton_alwaysDoubleBlinds->setChecked(TRUE); - myChangeCompleteBlindsDialog->radioButton_manualBlindsOrder->setChecked(FALSE); - myChangeCompleteBlindsDialog->listWidget_blinds->clear(); - } - else { - //read config values - myChangeCompleteBlindsDialog->spinBox_firstSmallBlind->setValue(myConfig->readConfigInt("NetFirstSmallBlind")); - myChangeCompleteBlindsDialog->radioButton_raiseBlindsAtHands->setChecked(myConfig->readConfigInt("NetRaiseBlindsAtHands")); - myChangeCompleteBlindsDialog->radioButton_raiseBlindsAtMinutes->setChecked(myConfig->readConfigInt("NetRaiseBlindsAtMinutes")); - myChangeCompleteBlindsDialog->spinBox_raiseSmallBlindEveryHands->setValue(myConfig->readConfigInt("NetRaiseSmallBlindEveryHands")); - myChangeCompleteBlindsDialog->spinBox_raiseSmallBlindEveryMinutes->setValue(myConfig->readConfigInt("NetRaiseSmallBlindEveryMinutes")); - myChangeCompleteBlindsDialog->radioButton_alwaysDoubleBlinds->setChecked(myConfig->readConfigInt("NetAlwaysDoubleBlinds")); - myChangeCompleteBlindsDialog->radioButton_manualBlindsOrder->setChecked(myConfig->readConfigInt("NetManualBlindsOrder")); + if(comboBox_gameType->currentIndex() == GAME_TYPE_RANKING-1) { + //set static values + myChangeCompleteBlindsDialog->spinBox_firstSmallBlind->setValue(RANKING_GAME_START_SBLIND); + myChangeCompleteBlindsDialog->radioButton_raiseBlindsAtHands->setChecked(TRUE); + myChangeCompleteBlindsDialog->radioButton_raiseBlindsAtMinutes->setChecked(FALSE); + myChangeCompleteBlindsDialog->spinBox_raiseSmallBlindEveryHands->setValue(11); + myChangeCompleteBlindsDialog->radioButton_alwaysDoubleBlinds->setChecked(TRUE); + myChangeCompleteBlindsDialog->radioButton_manualBlindsOrder->setChecked(FALSE); + myChangeCompleteBlindsDialog->listWidget_blinds->clear(); + } else { + //read config values + myChangeCompleteBlindsDialog->spinBox_firstSmallBlind->setValue(myConfig->readConfigInt("NetFirstSmallBlind")); + myChangeCompleteBlindsDialog->radioButton_raiseBlindsAtHands->setChecked(myConfig->readConfigInt("NetRaiseBlindsAtHands")); + myChangeCompleteBlindsDialog->radioButton_raiseBlindsAtMinutes->setChecked(myConfig->readConfigInt("NetRaiseBlindsAtMinutes")); + myChangeCompleteBlindsDialog->spinBox_raiseSmallBlindEveryHands->setValue(myConfig->readConfigInt("NetRaiseSmallBlindEveryHands")); + myChangeCompleteBlindsDialog->spinBox_raiseSmallBlindEveryMinutes->setValue(myConfig->readConfigInt("NetRaiseSmallBlindEveryMinutes")); + myChangeCompleteBlindsDialog->radioButton_alwaysDoubleBlinds->setChecked(myConfig->readConfigInt("NetAlwaysDoubleBlinds")); + myChangeCompleteBlindsDialog->radioButton_manualBlindsOrder->setChecked(myConfig->readConfigInt("NetManualBlindsOrder")); - myChangeCompleteBlindsDialog->listWidget_blinds->clear(); - myChangeCompleteBlindsDialog->spinBox_input->setMinimum(myChangeCompleteBlindsDialog->spinBox_firstSmallBlind->value()+1); + myChangeCompleteBlindsDialog->listWidget_blinds->clear(); + myChangeCompleteBlindsDialog->spinBox_input->setMinimum(myChangeCompleteBlindsDialog->spinBox_firstSmallBlind->value()+1); - std::list myBlindsList = myConfig->readConfigIntList("NetManualBlindsList"); - std::list::iterator it1; + std::list myBlindsList = myConfig->readConfigIntList("NetManualBlindsList"); + std::list::iterator it1; for(it1= myBlindsList.begin(); it1 != myBlindsList.end(); ++it1) { - myChangeCompleteBlindsDialog->listWidget_blinds->addItem(QString::number(*it1,10)); - } - myChangeCompleteBlindsDialog->sortBlindsList(); + myChangeCompleteBlindsDialog->listWidget_blinds->addItem(QString::number(*it1,10)); + } + myChangeCompleteBlindsDialog->sortBlindsList(); - myChangeCompleteBlindsDialog->radioButton_afterThisAlwaysDoubleBlinds->setChecked(myConfig->readConfigInt("NetAfterMBAlwaysDoubleBlinds")); - myChangeCompleteBlindsDialog->radioButton_afterThisAlwaysRaiseAbout->setChecked(myConfig->readConfigInt("NetAfterMBAlwaysRaiseAbout")); - myChangeCompleteBlindsDialog->spinBox_afterThisAlwaysRaiseValue->setValue(myConfig->readConfigInt("NetAfterMBAlwaysRaiseValue")); - myChangeCompleteBlindsDialog->radioButton_afterThisStayAtLastBlind->setChecked(myConfig->readConfigInt("NetAfterMBStayAtLastBlind")); - } + myChangeCompleteBlindsDialog->radioButton_afterThisAlwaysDoubleBlinds->setChecked(myConfig->readConfigInt("NetAfterMBAlwaysDoubleBlinds")); + myChangeCompleteBlindsDialog->radioButton_afterThisAlwaysRaiseAbout->setChecked(myConfig->readConfigInt("NetAfterMBAlwaysRaiseAbout")); + myChangeCompleteBlindsDialog->spinBox_afterThisAlwaysRaiseValue->setValue(myConfig->readConfigInt("NetAfterMBAlwaysRaiseValue")); + myChangeCompleteBlindsDialog->radioButton_afterThisStayAtLastBlind->setChecked(myConfig->readConfigInt("NetAfterMBStayAtLastBlind")); + } } diff --git a/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.h b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.h index 22b2422b..bc3be3d9 100644 --- a/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.h +++ b/src/gui/qt/createinternetgamedialog/createinternetgamedialogimpl.h @@ -29,32 +29,35 @@ class Session; class ConfigFile; class changeCompleteBlindsDialogImpl; -class createInternetGameDialogImpl: public QDialog, public Ui::createInternetGameDialog { -Q_OBJECT +class createInternetGameDialogImpl: public QDialog, public Ui::createInternetGameDialog +{ + Q_OBJECT public: - createInternetGameDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); + createInternetGameDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); - void exec(bool guestMode, QString playerName); - changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() { return myChangeCompleteBlindsDialog; } + void exec(bool guestMode, QString playerName); + changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() { + return myChangeCompleteBlindsDialog; + } public slots: void createGame(); void cancel(); - void fillFormular(bool guestMode, QString playerName); + void fillFormular(bool guestMode, QString playerName); void keyPressEvent ( QKeyEvent * event ); void clearGamePassword(bool); - void gameTypeChanged(); + void gameTypeChanged(); void callChangeBlindsDialog(bool); private: - - ConfigFile *myConfig; + + ConfigFile *myConfig; changeCompleteBlindsDialogImpl *myChangeCompleteBlindsDialog; - bool currentGuestMode; - QString currentPlayerName; - QLabel *startBlind; - QLabel *raiseMode; + bool currentGuestMode; + QString currentPlayerName; + QLabel *startBlind; + QLabel *raiseMode; }; diff --git a/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp b/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp index 64be9a83..f587c8c6 100644 --- a/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp +++ b/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.cpp @@ -23,14 +23,14 @@ #include "changecompleteblindsdialogimpl.h" createNetworkGameDialogImpl::createNetworkGameDialogImpl(QWidget *parent, ConfigFile *c) - : QDialog(parent), myConfig(c) + : QDialog(parent), myConfig(c) { #ifdef __APPLE__ setWindowModality(Qt::ApplicationModal); setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); -#endif - setupUi(this); - +#endif + setupUi(this); + myChangeCompleteBlindsDialog = new changeCompleteBlindsDialogImpl; fillFormular(); @@ -47,22 +47,26 @@ createNetworkGameDialogImpl::createNetworkGameDialogImpl(QWidget *parent, Config } -void createNetworkGameDialogImpl::exec() { - +void createNetworkGameDialogImpl::exec() +{ + fillFormular(); QDialog::exec(); } -void createNetworkGameDialogImpl::createGame() { - +void createNetworkGameDialogImpl::createGame() +{ + } -void createNetworkGameDialogImpl::cancel() { - +void createNetworkGameDialogImpl::cancel() +{ + } -void createNetworkGameDialogImpl::fillFormular() { - +void createNetworkGameDialogImpl::fillFormular() +{ + //Network Game Settings spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers")); spinBox_startCash->setValue(myConfig->readConfigInt("NetStartCash")); @@ -83,32 +87,37 @@ void createNetworkGameDialogImpl::fillFormular() { std::list myBlindsList = myConfig->readConfigIntList("NetManualBlindsList"); std::list::iterator it1; - + for(it1= myBlindsList.begin(); it1 != myBlindsList.end(); ++it1) { myChangeCompleteBlindsDialog->listWidget_blinds->addItem(QString::number(*it1,10)); } myChangeCompleteBlindsDialog->sortBlindsList(); - + myChangeCompleteBlindsDialog->radioButton_afterThisAlwaysDoubleBlinds->setChecked(myConfig->readConfigInt("NetAfterMBAlwaysDoubleBlinds")); myChangeCompleteBlindsDialog->radioButton_afterThisAlwaysRaiseAbout->setChecked(myConfig->readConfigInt("NetAfterMBAlwaysRaiseAbout")); myChangeCompleteBlindsDialog->spinBox_afterThisAlwaysRaiseValue->setValue(myConfig->readConfigInt("NetAfterMBAlwaysRaiseValue")); myChangeCompleteBlindsDialog->radioButton_afterThisStayAtLastBlind->setChecked(myConfig->readConfigInt("NetAfterMBStayAtLastBlind")); } -void createNetworkGameDialogImpl::showDialog() { - +void createNetworkGameDialogImpl::showDialog() +{ + fillFormular(); exec(); } -void createNetworkGameDialogImpl::keyPressEvent ( QKeyEvent * event ) { +void createNetworkGameDialogImpl::keyPressEvent ( QKeyEvent * event ) +{ - if (event->key() == 16777220) { pushButton_createGame->click(); } //ENTER - + if (event->key() == 16777220) { + pushButton_createGame->click(); //ENTER + } + } -void createNetworkGameDialogImpl::callChangeBlindsDialog(bool show) { +void createNetworkGameDialogImpl::callChangeBlindsDialog(bool show) +{ if(show) { myChangeCompleteBlindsDialog->exec(); diff --git a/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.h b/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.h index ff6bc70b..52a7463c 100644 --- a/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.h +++ b/src/gui/qt/createnetworkgamedialog/createnetworkgamedialogimpl.h @@ -30,13 +30,16 @@ class ConfigFile; class changeCompleteBlindsDialogImpl; -class createNetworkGameDialogImpl: public QDialog, public Ui::createNetworkGameDialog { -Q_OBJECT +class createNetworkGameDialogImpl: public QDialog, public Ui::createNetworkGameDialog +{ + Q_OBJECT public: - createNetworkGameDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); + createNetworkGameDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); void exec(); - changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() { return myChangeCompleteBlindsDialog; } + changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() { + return myChangeCompleteBlindsDialog; + } public slots: @@ -48,8 +51,8 @@ public slots: void callChangeBlindsDialog(bool); private: - - ConfigFile *myConfig; + + ConfigFile *myConfig; changeCompleteBlindsDialogImpl *myChangeCompleteBlindsDialog; }; diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp index 9c4541cd..9c7f52e8 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp @@ -2,7 +2,7 @@ // // C++ Implementation: gamelobbydialogimpl // -// Description: +// Description: // // // Author: FThauer FHammer LMay , (C) 2007 @@ -26,1582 +26,1600 @@ using namespace std; gameLobbyDialogImpl::gameLobbyDialogImpl(startWindowImpl *parent, ConfigFile *c) - : QDialog(parent), myW(NULL), myStartWindow(parent), myConfig(c), currentGameName(""), myPlayerId(0), isGameAdministrator(false), inGame(false), guestMode(false), blinkingButtonAnimationState(true), myChat(NULL), keyUpCounter(0), infoMsgToShowId(0), currentInvitationGameId(0), inviteDialogIsCurrentlyShown(false), autoStartTimerCounter(0) + : QDialog(parent), myW(NULL), myStartWindow(parent), myConfig(c), currentGameName(""), myPlayerId(0), isGameAdministrator(false), inGame(false), guestMode(false), blinkingButtonAnimationState(true), myChat(NULL), keyUpCounter(0), infoMsgToShowId(0), currentInvitationGameId(0), inviteDialogIsCurrentlyShown(false), autoStartTimerCounter(0) { #ifdef __APPLE__ - setWindowModality(Qt::ApplicationModal); - setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); -#endif - setupUi(this); - - myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); - - //wait start game message - waitStartGameMsgBox = new QMessageBox(this); - waitStartGameMsgBox->setText(tr("Starting game. Please wait ...")); - waitStartGameMsgBox->setWindowModality(Qt::NonModal); -#ifdef __APPLE__ - waitStartGameMsgBox->setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); + setWindowModality(Qt::ApplicationModal); + setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); #endif - waitStartGameMsgBox->setStandardButtons(QMessageBox::NoButton); + setupUi(this); - waitStartGameMsgBoxTimer = new QTimer(this); - waitStartGameMsgBoxTimer->setSingleShot(TRUE); - blinkingButtonAnimationTimer = new QTimer(this); - blinkingButtonAnimationTimer->setInterval(1000); - autoStartTimer = new QTimer(this); - autoStartTimer->setInterval(1000); - showInfoMsgBoxTimer = new QTimer(this); - showInfoMsgBoxTimer->setSingleShot(TRUE); + myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); - //fetch button colors for blinking - groupBox_GameInfo->setEnabled(true); - pushButton_StartGame->setEnabled(true); - defaultStartButtonColor = pushButton_StartGame->palette().button().color(); - defaultStartButtonTextColor = pushButton_StartGame->palette().buttonText().color(); - pushButton_StartGame->setEnabled(false); - groupBox_GameInfo->setEnabled(false); - disabledStartButtonColor = pushButton_StartGame->palette().button().color(); - disabledStartButtonTextColor = pushButton_StartGame->palette().buttonText().color(); + //wait start game message + waitStartGameMsgBox = new QMessageBox(this); + waitStartGameMsgBox->setText(tr("Starting game. Please wait ...")); + waitStartGameMsgBox->setWindowModality(Qt::NonModal); +#ifdef __APPLE__ + waitStartGameMsgBox->setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); +#endif + waitStartGameMsgBox->setStandardButtons(QMessageBox::NoButton); - //prepare overlay - autoStartTimerOverlay = new QLabel(scrollArea_gameInfos); - autoStartTimerOverlay->hide(); - autoStartTimerOverlay->setWordWrap(TRUE); - autoStartTimerOverlay->setMaximumWidth(190); - autoStartTimerOverlay->setMinimumWidth(190); - autoStartTimerOverlay->setTextFormat(Qt::RichText); - autoStartTimerOverlay->setAlignment(Qt::AlignCenter); - autoStartTimerOverlay->setAutoFillBackground(TRUE); - autoStartTimerOverlay->setFrameStyle(QFrame::StyledPanel); - QPalette p; - p.setColor(QPalette::Background, QColor(255, 255, 255, 210)); - autoStartTimerOverlay->setPalette(p); + waitStartGameMsgBoxTimer = new QTimer(this); + waitStartGameMsgBoxTimer->setSingleShot(TRUE); + blinkingButtonAnimationTimer = new QTimer(this); + blinkingButtonAnimationTimer->setInterval(1000); + autoStartTimer = new QTimer(this); + autoStartTimer->setInterval(1000); + showInfoMsgBoxTimer = new QTimer(this); + showInfoMsgBoxTimer->setSingleShot(TRUE); + + //fetch button colors for blinking + groupBox_GameInfo->setEnabled(true); + pushButton_StartGame->setEnabled(true); + defaultStartButtonColor = pushButton_StartGame->palette().button().color(); + defaultStartButtonTextColor = pushButton_StartGame->palette().buttonText().color(); + pushButton_StartGame->setEnabled(false); + groupBox_GameInfo->setEnabled(false); + disabledStartButtonColor = pushButton_StartGame->palette().button().color(); + disabledStartButtonTextColor = pushButton_StartGame->palette().buttonText().color(); + + //prepare overlay + autoStartTimerOverlay = new QLabel(scrollArea_gameInfos); + autoStartTimerOverlay->hide(); + autoStartTimerOverlay->setWordWrap(TRUE); + autoStartTimerOverlay->setMaximumWidth(190); + autoStartTimerOverlay->setMinimumWidth(190); + autoStartTimerOverlay->setTextFormat(Qt::RichText); + autoStartTimerOverlay->setAlignment(Qt::AlignCenter); + autoStartTimerOverlay->setAutoFillBackground(TRUE); + autoStartTimerOverlay->setFrameStyle(QFrame::StyledPanel); + QPalette p; + p.setColor(QPalette::Background, QColor(255, 255, 255, 210)); + autoStartTimerOverlay->setPalette(p); - myGameListModel = new QStandardItemModel(this); - myGameListSortFilterProxyModel = new MyGameListSortFilterProxyModel(this); - myGameListSortFilterProxyModel->setSourceModel(myGameListModel); - myGameListSortFilterProxyModel->setDynamicSortFilter(TRUE); - treeView_GameList->setModel(myGameListSortFilterProxyModel); + myGameListModel = new QStandardItemModel(this); + myGameListSortFilterProxyModel = new MyGameListSortFilterProxyModel(this); + myGameListSortFilterProxyModel->setSourceModel(myGameListModel); + myGameListSortFilterProxyModel->setDynamicSortFilter(TRUE); + treeView_GameList->setModel(myGameListSortFilterProxyModel); - myGameListSelectionModel = treeView_GameList->selectionModel(); + myGameListSelectionModel = treeView_GameList->selectionModel(); - QStringList headerList; - headerList << tr("Game") << tr("Players") << tr("State") << tr("R") << tr("P"); - myGameListModel->setHorizontalHeaderLabels(headerList); + QStringList headerList; + headerList << tr("Game") << tr("Players") << tr("State") << tr("R") << tr("P"); + myGameListModel->setHorizontalHeaderLabels(headerList); - treeView_GameList->setColumnWidth(0,190); - treeView_GameList->setColumnWidth(1,65); - treeView_GameList->setColumnWidth(2,65); - treeView_GameList->setColumnWidth(3,40); - treeView_GameList->setColumnWidth(4,40); + treeView_GameList->setColumnWidth(0,190); + treeView_GameList->setColumnWidth(1,65); + treeView_GameList->setColumnWidth(2,65); + treeView_GameList->setColumnWidth(3,40); + treeView_GameList->setColumnWidth(4,40); - treeView_GameList->setStyleSheet("QTreeView {background-color: white; background-image: url(\""+myAppDataPath +"gfx/gui/misc/background_gamelist.png\"); background-attachment: fixed; background-position: top center ; background-repeat: no-repeat;}"); - treeView_GameList->setAutoFillBackground(TRUE); + treeView_GameList->setStyleSheet("QTreeView {background-color: white; background-image: url(\""+myAppDataPath +"gfx/gui/misc/background_gamelist.png\"); background-attachment: fixed; background-position: top center ; background-repeat: no-repeat;}"); + treeView_GameList->setAutoFillBackground(TRUE); - myNickListModel = new QStandardItemModel(this); - myNickListSortFilterProxyModel = new MyNickListSortFilterProxyModel(this); - myNickListSortFilterProxyModel->setSourceModel(myNickListModel); - myNickListSortFilterProxyModel->setDynamicSortFilter(TRUE); - myNickListSortFilterProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); + myNickListModel = new QStandardItemModel(this); + myNickListSortFilterProxyModel = new MyNickListSortFilterProxyModel(this); + myNickListSortFilterProxyModel->setSourceModel(myNickListModel); + myNickListSortFilterProxyModel->setDynamicSortFilter(TRUE); + myNickListSortFilterProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); - treeView_NickList->setModel(myNickListSortFilterProxyModel); - myNickListSelectionModel = treeView_NickList->selectionModel(); + treeView_NickList->setModel(myNickListSortFilterProxyModel); + myNickListSelectionModel = treeView_NickList->selectionModel(); - QStringList headerList2; - headerList2 << tr("Available Players"); - myNickListModel->setHorizontalHeaderLabels(headerList2); - treeView_NickList->sortByColumn(0, Qt::AscendingOrder); + QStringList headerList2; + headerList2 << tr("Available Players"); + myNickListModel->setHorizontalHeaderLabels(headerList2); + treeView_NickList->sortByColumn(0, Qt::AscendingOrder); - myChat = new ChatTools(lineEdit_ChatInput, myConfig, INET_LOBBY_CHAT, textBrowser_ChatDisplay, myNickListModel, this); + myChat = new ChatTools(lineEdit_ChatInput, myConfig, INET_LOBBY_CHAT, textBrowser_ChatDisplay, myNickListModel, this); - nickListContextMenu = new QMenu(); - nickListInviteAction = new QAction(QIcon(":/gfx/list_add_user.png"), tr("Invite player"), nickListContextMenu); - nickListContextMenu->addAction(nickListInviteAction); - nickListIgnorePlayerAction = new QAction(QIcon(":/gfx/im-ban-user.png"), tr("Ignore player"), nickListContextMenu); - nickListContextMenu->addAction(nickListIgnorePlayerAction); - nickListPlayerInfoSubMenu = nickListContextMenu->addMenu(QIcon(":/gfx/dialog-information.png"), tr("Player infos ...")); - nickListPlayerInGameInfo = new QAction(nickListContextMenu); - nickListPlayerInfoSubMenu->addAction(nickListPlayerInGameInfo); + nickListContextMenu = new QMenu(); + nickListInviteAction = new QAction(QIcon(":/gfx/list_add_user.png"), tr("Invite player"), nickListContextMenu); + nickListContextMenu->addAction(nickListInviteAction); + nickListIgnorePlayerAction = new QAction(QIcon(":/gfx/im-ban-user.png"), tr("Ignore player"), nickListContextMenu); + nickListContextMenu->addAction(nickListIgnorePlayerAction); + nickListPlayerInfoSubMenu = nickListContextMenu->addMenu(QIcon(":/gfx/dialog-information.png"), tr("Player infos ...")); + nickListPlayerInGameInfo = new QAction(nickListContextMenu); + nickListPlayerInfoSubMenu->addAction(nickListPlayerInGameInfo); - connect( pushButton_CreateGame, SIGNAL( clicked() ), this, SLOT( createGame() ) ); - connect( pushButton_JoinGame, SIGNAL( clicked() ), this, SLOT( joinGame() ) ); - connect( pushButton_joinAnyGame, SIGNAL( clicked() ), this, SLOT( joinAnyGame() ) ); - connect( pushButton_StartGame, SIGNAL( clicked() ), this, SLOT( startGame() ) ); - connect( pushButton_Kick, SIGNAL( clicked() ), this, SLOT( kickPlayer() ) ); - connect( pushButton_Leave, SIGNAL( clicked() ), this, SLOT( leaveGame() ) ); - connect( myGameListSelectionModel, SIGNAL( currentChanged (const QModelIndex &, const QModelIndex &) ), this, SLOT( gameSelected(const QModelIndex &) ) ); - connect( treeView_GameList, SIGNAL( doubleClicked (const QModelIndex &) ), this, SLOT( joinGame() ) ); - connect( treeView_GameList->header(), SIGNAL( sortIndicatorChanged ( int , Qt::SortOrder )), this, SLOT( changeGameListSorting() ) ); - connect( treeWidget_connectedPlayers, SIGNAL( currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT( playerSelected(QTreeWidgetItem*, QTreeWidgetItem*) ) ); - connect( lineEdit_ChatInput, SIGNAL( returnPressed () ), myChat, SLOT( sendMessage() ) ); - connect( lineEdit_ChatInput, SIGNAL( textChanged (QString) ), myChat, SLOT( checkInputLength(QString) ) ); - connect( lineEdit_ChatInput, SIGNAL( textEdited (QString) ), myChat, SLOT( setChatTextEdited() ) ); - connect( waitStartGameMsgBoxTimer, SIGNAL(timeout()), this, SLOT( showWaitStartGameMsgBox() )); - connect( blinkingButtonAnimationTimer, SIGNAL(timeout()), this, SLOT( blinkingStartButtonAnimation() )); - connect( autoStartTimer, SIGNAL(timeout()), this, SLOT( updateAutoStartTimer() )); - connect( showInfoMsgBoxTimer, SIGNAL(timeout()), this, SLOT( showInfoMsgBox() )); - connect( comboBox_gameListFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changeGameListFilter(int))); - connect( comboBox_nickListFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changeNickListFilter(int))); - connect( treeView_NickList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT( showNickListContextMenu(QPoint) ) ); - connect( nickListInviteAction, SIGNAL(triggered()), this, SLOT( invitePlayerToCurrentGame() )); - connect( nickListIgnorePlayerAction, SIGNAL(triggered()), this, SLOT( putPlayerOnIgnoreList() )); - connect( lineEdit_searchForPlayers, SIGNAL(textChanged(QString)),this, SLOT(searchForPlayerRegExpChanged())); + connect( pushButton_CreateGame, SIGNAL( clicked() ), this, SLOT( createGame() ) ); + connect( pushButton_JoinGame, SIGNAL( clicked() ), this, SLOT( joinGame() ) ); + connect( pushButton_joinAnyGame, SIGNAL( clicked() ), this, SLOT( joinAnyGame() ) ); + connect( pushButton_StartGame, SIGNAL( clicked() ), this, SLOT( startGame() ) ); + connect( pushButton_Kick, SIGNAL( clicked() ), this, SLOT( kickPlayer() ) ); + connect( pushButton_Leave, SIGNAL( clicked() ), this, SLOT( leaveGame() ) ); + connect( myGameListSelectionModel, SIGNAL( currentChanged (const QModelIndex &, const QModelIndex &) ), this, SLOT( gameSelected(const QModelIndex &) ) ); + connect( treeView_GameList, SIGNAL( doubleClicked (const QModelIndex &) ), this, SLOT( joinGame() ) ); + connect( treeView_GameList->header(), SIGNAL( sortIndicatorChanged ( int , Qt::SortOrder )), this, SLOT( changeGameListSorting() ) ); + connect( treeWidget_connectedPlayers, SIGNAL( currentItemChanged ( QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT( playerSelected(QTreeWidgetItem*, QTreeWidgetItem*) ) ); + connect( lineEdit_ChatInput, SIGNAL( returnPressed () ), myChat, SLOT( sendMessage() ) ); + connect( lineEdit_ChatInput, SIGNAL( textChanged (QString) ), myChat, SLOT( checkInputLength(QString) ) ); + connect( lineEdit_ChatInput, SIGNAL( textEdited (QString) ), myChat, SLOT( setChatTextEdited() ) ); + connect( waitStartGameMsgBoxTimer, SIGNAL(timeout()), this, SLOT( showWaitStartGameMsgBox() )); + connect( blinkingButtonAnimationTimer, SIGNAL(timeout()), this, SLOT( blinkingStartButtonAnimation() )); + connect( autoStartTimer, SIGNAL(timeout()), this, SLOT( updateAutoStartTimer() )); + connect( showInfoMsgBoxTimer, SIGNAL(timeout()), this, SLOT( showInfoMsgBox() )); + connect( comboBox_gameListFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changeGameListFilter(int))); + connect( comboBox_nickListFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changeNickListFilter(int))); + connect( treeView_NickList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT( showNickListContextMenu(QPoint) ) ); + connect( nickListInviteAction, SIGNAL(triggered()), this, SLOT( invitePlayerToCurrentGame() )); + connect( nickListIgnorePlayerAction, SIGNAL(triggered()), this, SLOT( putPlayerOnIgnoreList() )); + connect( lineEdit_searchForPlayers, SIGNAL(textChanged(QString)),this, SLOT(searchForPlayerRegExpChanged())); - lineEdit_searchForPlayers->installEventFilter(this); - lineEdit_ChatInput->installEventFilter(this); + lineEdit_searchForPlayers->installEventFilter(this); + lineEdit_ChatInput->installEventFilter(this); - clearDialog(); + clearDialog(); } void gameLobbyDialogImpl::exec() { - if(myConfig->readConfigInt("UseLobbyChat")) { - groupBox_lobbyChat->show(); - } - else { - groupBox_lobbyChat->hide(); - } - readDialogSettings(); + if(myConfig->readConfigInt("UseLobbyChat")) { + groupBox_lobbyChat->show(); + } else { + groupBox_lobbyChat->hide(); + } + readDialogSettings(); - PlayerInfo playerInfo(mySession->getClientPlayerInfo(mySession->getClientUniquePlayerId())); - if(playerInfo.isGuest) { - guestUserMode(); - } - else { - registeredUserMode(); - } + PlayerInfo playerInfo(mySession->getClientPlayerInfo(mySession->getClientUniquePlayerId())); + if(playerInfo.isGuest) { + guestUserMode(); + } else { + registeredUserMode(); + } - QDialog::exec(); + QDialog::exec(); - waitStartGameMsgBoxTimer->stop(); - waitStartGameMsgBox->hide(); + waitStartGameMsgBoxTimer->stop(); + waitStartGameMsgBox->hide(); } gameLobbyDialogImpl::~gameLobbyDialogImpl() { - delete myChat; - myChat = NULL; + delete myChat; + myChat = NULL; } -void gameLobbyDialogImpl::setSession(boost::shared_ptr session) { - mySession = session; - myChat->setSession(mySession); +void gameLobbyDialogImpl::setSession(boost::shared_ptr session) +{ + mySession = session; + myChat->setSession(mySession); } void gameLobbyDialogImpl::createGame() { - assert(mySession); + assert(mySession); - myCreateInternetGameDialog = new createInternetGameDialogImpl(this, myConfig); - PlayerInfo playerInfo(mySession->getClientPlayerInfo(mySession->getClientUniquePlayerId())); - myCreateInternetGameDialog->exec(guestMode, QString::fromUtf8(playerInfo.playerName.c_str())); + myCreateInternetGameDialog = new createInternetGameDialogImpl(this, myConfig); + PlayerInfo playerInfo(mySession->getClientPlayerInfo(mySession->getClientUniquePlayerId())); + myCreateInternetGameDialog->exec(guestMode, QString::fromUtf8(playerInfo.playerName.c_str())); - if (myCreateInternetGameDialog->result() == QDialog::Accepted ) { + if (myCreateInternetGameDialog->result() == QDialog::Accepted ) { - GameData gameData; - // Set Game Data - gameData.maxNumberOfPlayers = myCreateInternetGameDialog->spinBox_quantityPlayers->value(); - gameData.startMoney = myCreateInternetGameDialog->spinBox_startCash->value(); - gameData.firstSmallBlind = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value(); + GameData gameData; + // Set Game Data + gameData.maxNumberOfPlayers = myCreateInternetGameDialog->spinBox_quantityPlayers->value(); + gameData.startMoney = myCreateInternetGameDialog->spinBox_startCash->value(); + gameData.firstSmallBlind = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value(); - if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) { - gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER; - gameData.raiseSmallBlindEveryHandsValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value(); - } - else { - gameData.raiseIntervalMode = RAISE_ON_MINUTES; - gameData.raiseSmallBlindEveryMinutesValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value(); - } + if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) { + gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER; + gameData.raiseSmallBlindEveryHandsValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value(); + } else { + gameData.raiseIntervalMode = RAISE_ON_MINUTES; + gameData.raiseSmallBlindEveryMinutesValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value(); + } - if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) { - gameData.raiseMode = DOUBLE_BLINDS; - } - else { - gameData.raiseMode = MANUAL_BLINDS_ORDER; - std::list tempBlindList; - int i; - bool ok = TRUE; - for(i=0; igetChangeCompleteBlindsDialog()->listWidget_blinds->count(); i++) { - tempBlindList.push_back(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->listWidget_blinds->item(i)->text().toInt(&ok,10)); - } - gameData.manualBlindsList = tempBlindList; + if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) { + gameData.raiseMode = DOUBLE_BLINDS; + } else { + gameData.raiseMode = MANUAL_BLINDS_ORDER; + std::list tempBlindList; + int i; + bool ok = TRUE; + for(i=0; igetChangeCompleteBlindsDialog()->listWidget_blinds->count(); i++) { + tempBlindList.push_back(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->listWidget_blinds->item(i)->text().toInt(&ok,10)); + } + gameData.manualBlindsList = tempBlindList; - if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; } - else { - if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysRaiseAbout->isChecked()) { - gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT; - gameData.afterMBAlwaysRaiseValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_afterThisAlwaysRaiseValue->value(); - } - else { gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; } - } - } + if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) { + gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; + } else { + if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysRaiseAbout->isChecked()) { + gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT; + gameData.afterMBAlwaysRaiseValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_afterThisAlwaysRaiseValue->value(); + } else { + gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; + } + } + } - gameData.guiSpeed = myConfig->readConfigInt("GameSpeed"); - gameData.delayBetweenHandsSec = myCreateInternetGameDialog->spinBox_netDelayBetweenHands->value(); - gameData.playerActionTimeoutSec = myCreateInternetGameDialog->spinBox_netTimeOutPlayerAction->value(); - gameData.gameType = GameType(myCreateInternetGameDialog->comboBox_gameType->itemData(myCreateInternetGameDialog->comboBox_gameType->currentIndex(), Qt::UserRole).toInt()); + gameData.guiSpeed = myConfig->readConfigInt("GameSpeed"); + gameData.delayBetweenHandsSec = myCreateInternetGameDialog->spinBox_netDelayBetweenHands->value(); + gameData.playerActionTimeoutSec = myCreateInternetGameDialog->spinBox_netTimeOutPlayerAction->value(); + gameData.gameType = GameType(myCreateInternetGameDialog->comboBox_gameType->itemData(myCreateInternetGameDialog->comboBox_gameType->currentIndex(), Qt::UserRole).toInt()); - currentGameName = myCreateInternetGameDialog->lineEdit_gameName->text(); + currentGameName = myCreateInternetGameDialog->lineEdit_gameName->text(); - switch (gameData.gameType) { - case GAME_TYPE_NORMAL: { - label_typeIcon->setPixmap(QPixmap(":/gfx/player_play.png")); - label_typeText->setText(tr("Standard")); - } - break; - case GAME_TYPE_REGISTERED_ONLY: { - label_typeIcon->setPixmap(QPixmap(":/gfx/registered.png")); - label_typeText->setText(tr("Registered players only")); - } - break; - case GAME_TYPE_INVITE_ONLY: { - label_typeIcon->setPixmap(QPixmap(":/gfx/list_add_user.png")); - label_typeText->setText(tr("Invited players only")); - } - break; - case GAME_TYPE_RANKING: { - label_typeIcon->setPixmap(QPixmap(":/gfx/cup.png")); - label_typeText->setText(tr("Ranking game")); - } - break; - } + switch (gameData.gameType) { + case GAME_TYPE_NORMAL: { + label_typeIcon->setPixmap(QPixmap(":/gfx/player_play.png")); + label_typeText->setText(tr("Standard")); + } + break; + case GAME_TYPE_REGISTERED_ONLY: { + label_typeIcon->setPixmap(QPixmap(":/gfx/registered.png")); + label_typeText->setText(tr("Registered players only")); + } + break; + case GAME_TYPE_INVITE_ONLY: { + label_typeIcon->setPixmap(QPixmap(":/gfx/list_add_user.png")); + label_typeText->setText(tr("Invited players only")); + } + break; + case GAME_TYPE_RANKING: { + label_typeIcon->setPixmap(QPixmap(":/gfx/cup.png")); + label_typeText->setText(tr("Ranking game")); + } + break; + } - showGameDescription(TRUE); + showGameDescription(TRUE); - label_SmallBlind->setText(QString("%L1").arg(gameData.firstSmallBlind)); - label_StartCash->setText(QString("%L1").arg(gameData.startMoney)); + label_SmallBlind->setText(QString("%L1").arg(gameData.firstSmallBlind)); + label_StartCash->setText(QString("%L1").arg(gameData.startMoney)); - QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); - header->setText(0, tr("Connected players - max. %1").arg(gameData.maxNumberOfPlayers)); - header->setData(0, Qt::UserRole, gameData.maxNumberOfPlayers); + QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); + header->setText(0, tr("Connected players - max. %1").arg(gameData.maxNumberOfPlayers)); + header->setData(0, Qt::UserRole, gameData.maxNumberOfPlayers); - updateDialogBlinds(gameData); + updateDialogBlinds(gameData); - label_TimeoutForPlayerAction->setText(QString::number(gameData.playerActionTimeoutSec)); + label_TimeoutForPlayerAction->setText(QString::number(gameData.playerActionTimeoutSec)); - mySession->clientCreateGame(gameData, currentGameName.toUtf8().constData(), myCreateInternetGameDialog->lineEdit_Password->text().toUtf8().constData()); + mySession->clientCreateGame(gameData, currentGameName.toUtf8().constData(), myCreateInternetGameDialog->lineEdit_Password->text().toUtf8().constData()); - } + } } void gameLobbyDialogImpl::joinGame() { - assert(mySession); - QItemSelectionModel *selection = treeView_GameList->selectionModel(); - if (!inGame && selection->hasSelection()) - { - unsigned gameId = selection->selectedRows().first().data(Qt::UserRole).toUInt(); - GameInfo info(mySession->getClientGameInfo(gameId)); - bool ok = true; - QString password; - //if private ask for password - if (info.isPasswordProtected) { - password = QInputDialog::getText(this, tr("Joining a private Game"), - tr("You are about to join a private game. Please enter the password!"), QLineEdit::Password, (""), &ok); - } + assert(mySession); + QItemSelectionModel *selection = treeView_GameList->selectionModel(); + if (!inGame && selection->hasSelection()) { + unsigned gameId = selection->selectedRows().first().data(Qt::UserRole).toUInt(); + GameInfo info(mySession->getClientGameInfo(gameId)); + bool ok = true; + QString password; + //if private ask for password + if (info.isPasswordProtected) { + password = QInputDialog::getText(this, tr("Joining a private Game"), + tr("You are about to join a private game. Please enter the password!"), QLineEdit::Password, (""), &ok); + } - if (ok) - mySession->clientJoinGame(gameId, password.toUtf8().constData()); - } + if (ok) + mySession->clientJoinGame(gameId, password.toUtf8().constData()); + } } -void gameLobbyDialogImpl::joinAnyGame() { +void gameLobbyDialogImpl::joinAnyGame() +{ - if(comboBox_gameListFilter->currentIndex() != 3 && comboBox_gameListFilter->currentIndex() != 0) comboBox_gameListFilter->setCurrentIndex(0); + if(comboBox_gameListFilter->currentIndex() != 3 && comboBox_gameListFilter->currentIndex() != 0) comboBox_gameListFilter->setCurrentIndex(0); - bool found = FALSE; + bool found = FALSE; - int it = 0; - int gameToJoinId = 0; - int mostConnectedPlayers = 0; + int it = 0; + int gameToJoinId = 0; + int mostConnectedPlayers = 0; - while (myGameListModel->item(it)) { + while (myGameListModel->item(it)) { - int players = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",0,0).toInt(); - int maxPlayers = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",1,1).toInt(); - if (myGameListModel->item(it, 2)->data(16) == "open" && myGameListModel->item(it, 4)->data(16) == "nonpriv" && players < maxPlayers) - { - if(players > mostConnectedPlayers) { - mostConnectedPlayers = players; - gameToJoinId = it; - } - found = TRUE; - } - it++; - } + int players = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",0,0).toInt(); + int maxPlayers = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",1,1).toInt(); + if (myGameListModel->item(it, 2)->data(16) == "open" && myGameListModel->item(it, 4)->data(16) == "nonpriv" && players < maxPlayers) { + if(players > mostConnectedPlayers) { + mostConnectedPlayers = players; + gameToJoinId = it; + } + found = TRUE; + } + it++; + } - if(found) { - treeView_GameList->setCurrentIndex(myGameListSortFilterProxyModel->mapFromSource(myGameListModel->item(gameToJoinId)->index())); - joinGame(); - } + if(found) { + treeView_GameList->setCurrentIndex(myGameListSortFilterProxyModel->mapFromSource(myGameListModel->item(gameToJoinId)->index())); + joinGame(); + } } -void gameLobbyDialogImpl::refresh(int actionID) { +void gameLobbyDialogImpl::refresh(int actionID) +{ - if (actionID == MSG_NET_GAME_CLIENT_START) { - myGameListModel->clear(); - myGameListSelectionModel->clear(); - myGameListSelectionModel->clearSelection(); - myGameListSortFilterProxyModel->clear(); + if (actionID == MSG_NET_GAME_CLIENT_START) { + myGameListModel->clear(); + myGameListSelectionModel->clear(); + myGameListSelectionModel->clearSelection(); + myGameListSortFilterProxyModel->clear(); - myNickListModel->clear(); - myNickListSelectionModel->clear(); - myNickListSelectionModel->clearSelection();; + myNickListModel->clear(); + myNickListSelectionModel->clear(); + myNickListSelectionModel->clearSelection();; - QStringList headerList; - headerList << tr("Game") << tr("Players") << tr("State") << tr("T") << tr("P"); - myGameListModel->setHorizontalHeaderLabels(headerList); - treeView_GameList->setColumnWidth(0,190); - treeView_GameList->setColumnWidth(1,65); - treeView_GameList->setColumnWidth(2,65); - treeView_GameList->setColumnWidth(3,40); - treeView_GameList->setColumnWidth(4,40); + QStringList headerList; + headerList << tr("Game") << tr("Players") << tr("State") << tr("T") << tr("P"); + myGameListModel->setHorizontalHeaderLabels(headerList); + treeView_GameList->setColumnWidth(0,190); + treeView_GameList->setColumnWidth(1,65); + treeView_GameList->setColumnWidth(2,65); + treeView_GameList->setColumnWidth(3,40); + treeView_GameList->setColumnWidth(4,40); - QStringList headerList2; - headerList2 << tr("Available Players"); - myNickListModel->setHorizontalHeaderLabels(headerList2); + QStringList headerList2; + headerList2 << tr("Available Players"); + myNickListModel->setHorizontalHeaderLabels(headerList2); - //stop waitStartGameMsgBox - waitStartGameMsgBoxTimer->stop(); - waitStartGameMsgBox->hide(); + //stop waitStartGameMsgBox + waitStartGameMsgBoxTimer->stop(); + waitStartGameMsgBox->hide(); - this->accept(); - myW->show(); - } - else if(actionID == MSG_NET_GAME_CLIENT_SYNCSTART) { + this->accept(); + myW->show(); + } else if(actionID == MSG_NET_GAME_CLIENT_SYNCSTART) { - waitStartGameMsgBoxTimer->start(2000); - } + waitStartGameMsgBoxTimer->start(2000); + } } void gameLobbyDialogImpl::removedFromGame(int /*reason*/) { - inGame = false; - isGameAdministrator = false; - leftGameDialogUpdate(); + inGame = false; + isGameAdministrator = false; + leftGameDialogUpdate(); } void gameLobbyDialogImpl::gameSelected(const QModelIndex &index) { - if (!inGame && index.isValid() ) - { - pushButton_JoinGame->setEnabled(true); + if (!inGame && index.isValid() ) { + pushButton_JoinGame->setEnabled(true); - currentGameName = myGameListModel->item(myGameListSortFilterProxyModel->mapToSource(index).row(), 0)->text(); + currentGameName = myGameListModel->item(myGameListSortFilterProxyModel->mapToSource(index).row(), 0)->text(); - groupBox_GameInfo->setEnabled(true); - groupBox_GameInfo->setTitle(tr("Game Info") + " - " + currentGameName); + groupBox_GameInfo->setEnabled(true); + groupBox_GameInfo->setTitle(tr("Game Info") + " - " + currentGameName); - assert(mySession); - GameInfo info(mySession->getClientGameInfo(myGameListModel->item(myGameListSortFilterProxyModel->mapToSource(index).row(), 0)->data(Qt::UserRole).toUInt())); + assert(mySession); + GameInfo info(mySession->getClientGameInfo(myGameListModel->item(myGameListSortFilterProxyModel->mapToSource(index).row(), 0)->data(Qt::UserRole).toUInt())); - switch (info.data.gameType) { - case GAME_TYPE_NORMAL: { - label_typeIcon->setPixmap(QPixmap(":/gfx/player_play.png")); - label_typeText->setText(tr("Standard")); - } - break; - case GAME_TYPE_REGISTERED_ONLY: { - label_typeIcon->setPixmap(QPixmap(":/gfx/registered.png")); - label_typeText->setText(tr("Registered players only")); - } - break; - case GAME_TYPE_INVITE_ONLY: { - label_typeIcon->setPixmap(QPixmap(":/gfx/list_add_user.png")); - label_typeText->setText(tr("Invited players only")); - } - break; - case GAME_TYPE_RANKING: { - label_typeIcon->setPixmap(QPixmap(":/gfx/cup.png")); - label_typeText->setText(tr("Ranking game")); - } - break; - } + switch (info.data.gameType) { + case GAME_TYPE_NORMAL: { + label_typeIcon->setPixmap(QPixmap(":/gfx/player_play.png")); + label_typeText->setText(tr("Standard")); + } + break; + case GAME_TYPE_REGISTERED_ONLY: { + label_typeIcon->setPixmap(QPixmap(":/gfx/registered.png")); + label_typeText->setText(tr("Registered players only")); + } + break; + case GAME_TYPE_INVITE_ONLY: { + label_typeIcon->setPixmap(QPixmap(":/gfx/list_add_user.png")); + label_typeText->setText(tr("Invited players only")); + } + break; + case GAME_TYPE_RANKING: { + label_typeIcon->setPixmap(QPixmap(":/gfx/cup.png")); + label_typeText->setText(tr("Ranking game")); + } + break; + } - showGameDescription(TRUE); - label_SmallBlind->setText(QString("%L1").arg(info.data.firstSmallBlind)); - label_StartCash->setText(QString("%L1").arg(info.data.startMoney)); - // label_MaximumNumberOfPlayers->setText(QString::number(info.data.maxNumberOfPlayers));s - updateDialogBlinds(info.data); + showGameDescription(TRUE); + label_SmallBlind->setText(QString("%L1").arg(info.data.firstSmallBlind)); + label_StartCash->setText(QString("%L1").arg(info.data.startMoney)); + // label_MaximumNumberOfPlayers->setText(QString::number(info.data.maxNumberOfPlayers));s + updateDialogBlinds(info.data); - label_TimeoutForPlayerAction->setText(QString::number(info.data.playerActionTimeoutSec)); + label_TimeoutForPlayerAction->setText(QString::number(info.data.playerActionTimeoutSec)); - treeWidget_connectedPlayers->clear(); - PlayerIdList::const_iterator i = info.players.begin(); - PlayerIdList::const_iterator end = info.players.end(); - while (i != end) - { - bool admin = info.adminPlayerId == *i; - PlayerInfo playerInfo(mySession->getClientPlayerInfo(*i)); - addConnectedPlayer(*i, QString::fromUtf8(playerInfo.playerName.c_str()), admin); - ++i; - } + treeWidget_connectedPlayers->clear(); + PlayerIdList::const_iterator i = info.players.begin(); + PlayerIdList::const_iterator end = info.players.end(); + while (i != end) { + bool admin = info.adminPlayerId == *i; + PlayerInfo playerInfo(mySession->getClientPlayerInfo(*i)); + addConnectedPlayer(*i, QString::fromUtf8(playerInfo.playerName.c_str()), admin); + ++i; + } - QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); - header->setText(0, tr("Connected players - Max. %1").arg(info.data.maxNumberOfPlayers)); - header->setData(0, Qt::UserRole, info.data.maxNumberOfPlayers); + QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); + header->setText(0, tr("Connected players - Max. %1").arg(info.data.maxNumberOfPlayers)); + header->setData(0, Qt::UserRole, info.data.maxNumberOfPlayers); #ifdef __APPLE__ - // Dirty workaround for a Qt redraw bug on Mac OS. - treeWidget_connectedPlayers->setFocus(); - treeView_GameList->setFocus(); + // Dirty workaround for a Qt redraw bug on Mac OS. + treeWidget_connectedPlayers->setFocus(); + treeView_GameList->setFocus(); #endif - } + } } void gameLobbyDialogImpl::updateGameItem(QList itemList, unsigned gameId) { - assert(mySession); - GameInfo info(mySession->getClientGameInfo(gameId)); + assert(mySession); + GameInfo info(mySession->getClientGameInfo(gameId)); - itemList.at(0)->setData(gameId, Qt::UserRole); - itemList.at(0)->setData(QString::fromUtf8(info.name.c_str()), Qt::DisplayRole); + itemList.at(0)->setData(gameId, Qt::UserRole); + itemList.at(0)->setData(QString::fromUtf8(info.name.c_str()), Qt::DisplayRole); - PlayerIdList::const_iterator i = info.players.begin(); - PlayerIdList::const_iterator end = info.players.end(); + PlayerIdList::const_iterator i = info.players.begin(); + PlayerIdList::const_iterator end = info.players.end(); - while (i != end) - { - if(myPlayerId == *i) { - itemList.at(0)->setData( "MeInThisGame", 16); - itemList.at(0)->setBackground(QBrush(QColor(0, 255, 0, 127))); - itemList.at(1)->setBackground(QBrush(QColor(0, 255, 0, 127))); - itemList.at(2)->setBackground(QBrush(QColor(0, 255, 0, 127))); - itemList.at(3)->setBackground(QBrush(QColor(0, 255, 0, 127))); - itemList.at(4)->setBackground(QBrush(QColor(0, 255, 0, 127))); - break; - } - else { - itemList.at(0)->setData( "", 16); - itemList.at(0)->setBackground(QBrush()); - itemList.at(1)->setBackground(QBrush()); - itemList.at(2)->setBackground(QBrush()); - itemList.at(3)->setBackground(QBrush()); - itemList.at(4)->setBackground(QBrush()); - } - ++i; - } + while (i != end) { + if(myPlayerId == *i) { + itemList.at(0)->setData( "MeInThisGame", 16); + itemList.at(0)->setBackground(QBrush(QColor(0, 255, 0, 127))); + itemList.at(1)->setBackground(QBrush(QColor(0, 255, 0, 127))); + itemList.at(2)->setBackground(QBrush(QColor(0, 255, 0, 127))); + itemList.at(3)->setBackground(QBrush(QColor(0, 255, 0, 127))); + itemList.at(4)->setBackground(QBrush(QColor(0, 255, 0, 127))); + break; + } else { + itemList.at(0)->setData( "", 16); + itemList.at(0)->setBackground(QBrush()); + itemList.at(1)->setBackground(QBrush()); + itemList.at(2)->setBackground(QBrush()); + itemList.at(3)->setBackground(QBrush()); + itemList.at(4)->setBackground(QBrush()); + } + ++i; + } - QString playerStr; - playerStr.sprintf("%u/%u", (unsigned)info.players.size(), (unsigned)info.data.maxNumberOfPlayers); - itemList.at(1)->setData(playerStr, Qt::DisplayRole); - if((unsigned)info.players.size() == (unsigned)info.data.maxNumberOfPlayers) { itemList.at(1)->setData("totalfull", 16); } - else { itemList.at(1)->setData("nonfull", 16); }\ + QString playerStr; + playerStr.sprintf("%u/%u", (unsigned)info.players.size(), (unsigned)info.data.maxNumberOfPlayers); + itemList.at(1)->setData(playerStr, Qt::DisplayRole); + if((unsigned)info.players.size() == (unsigned)info.data.maxNumberOfPlayers) { + itemList.at(1)->setData("totalfull", 16); + } else { + itemList.at(1)->setData("nonfull", 16); + }\ - if (info.mode == GAME_MODE_STARTED) { - itemList.at(2)->setData(tr("running"), Qt::DisplayRole); - itemList.at(2)->setData("running", 16); - } - else { - itemList.at(2)->setData(tr("open"), Qt::DisplayRole); - itemList.at(2)->setData("open", 16); - } + if (info.mode == GAME_MODE_STARTED) { + itemList.at(2)->setData(tr("running"), Qt::DisplayRole); + itemList.at(2)->setData("running", 16); + } else { + itemList.at(2)->setData(tr("open"), Qt::DisplayRole); + itemList.at(2)->setData("open", 16); + } - switch (info.data.gameType) { - case GAME_TYPE_NORMAL: { - itemList.at(3)->setIcon(QIcon(":/gfx/player_play.png")); - itemList.at(3)->setData("", Qt::DisplayRole); - itemList.at(3)->setData("standard", 16); - } - break; - case GAME_TYPE_REGISTERED_ONLY: { - itemList.at(3)->setIcon(QIcon(":/gfx/registered.png")); - itemList.at(3)->setData(" ", Qt::DisplayRole); - itemList.at(3)->setData("registered", 16); - } - break; - case GAME_TYPE_INVITE_ONLY: { - itemList.at(3)->setIcon(QIcon(":/gfx/list_add_user.png")); - itemList.at(3)->setData(" ", Qt::DisplayRole); - itemList.at(3)->setData("invited", 16); - } - break; - case GAME_TYPE_RANKING: { - itemList.at(3)->setIcon(QIcon(":/gfx/cup.png")); - itemList.at(3)->setData(" ", Qt::DisplayRole); - itemList.at(3)->setData("ranking", 16); - } - break; - } + switch (info.data.gameType) { + case GAME_TYPE_NORMAL: { + itemList.at(3)->setIcon(QIcon(":/gfx/player_play.png")); + itemList.at(3)->setData("", Qt::DisplayRole); + itemList.at(3)->setData("standard", 16); + } + break; + case GAME_TYPE_REGISTERED_ONLY: { + itemList.at(3)->setIcon(QIcon(":/gfx/registered.png")); + itemList.at(3)->setData(" ", Qt::DisplayRole); + itemList.at(3)->setData("registered", 16); + } + break; + case GAME_TYPE_INVITE_ONLY: { + itemList.at(3)->setIcon(QIcon(":/gfx/list_add_user.png")); + itemList.at(3)->setData(" ", Qt::DisplayRole); + itemList.at(3)->setData("invited", 16); + } + break; + case GAME_TYPE_RANKING: { + itemList.at(3)->setIcon(QIcon(":/gfx/cup.png")); + itemList.at(3)->setData(" ", Qt::DisplayRole); + itemList.at(3)->setData("ranking", 16); + } + break; + } - if (info.isPasswordProtected) { - itemList.at(4)->setIcon(QIcon(":/gfx/lock.png")); - itemList.at(4)->setData(" ", Qt::DisplayRole); - itemList.at(4)->setData("private", 16); - } - else { - itemList.at(4)->setData("", Qt::DisplayRole); - itemList.at(4)->setData("nonpriv", 16); - } + if (info.isPasswordProtected) { + itemList.at(4)->setIcon(QIcon(":/gfx/lock.png")); + itemList.at(4)->setData(" ", Qt::DisplayRole); + itemList.at(4)->setData("private", 16); + } else { + itemList.at(4)->setData("", Qt::DisplayRole); + itemList.at(4)->setData("nonpriv", 16); + } - // treeView_GameList->sortByColumn(myConfig->readConfigInt("DlgGameLobbyGameListSortingSection"), (Qt::SortOrder)myConfig->readConfigInt("DlgGameLobbyGameListSortingOrder") ); - refreshGameStats(); + // treeView_GameList->sortByColumn(myConfig->readConfigInt("DlgGameLobbyGameListSortingSection"), (Qt::SortOrder)myConfig->readConfigInt("DlgGameLobbyGameListSortingOrder") ); + refreshGameStats(); } void gameLobbyDialogImpl::addGame(unsigned gameId) { - QList itemList; - QStandardItem *item1 = new QStandardItem(); - QStandardItem *item2 = new QStandardItem(); - QStandardItem *item3 = new QStandardItem(); - QStandardItem *item4 = new QStandardItem(); - QStandardItem *item5 = new QStandardItem(); - itemList << item1 << item2 << item3 << item4 << item5; + QList itemList; + QStandardItem *item1 = new QStandardItem(); + QStandardItem *item2 = new QStandardItem(); + QStandardItem *item3 = new QStandardItem(); + QStandardItem *item4 = new QStandardItem(); + QStandardItem *item5 = new QStandardItem(); + itemList << item1 << item2 << item3 << item4 << item5; - myGameListModel->appendRow(itemList); + myGameListModel->appendRow(itemList); - updateGameItem(itemList, gameId); + updateGameItem(itemList, gameId); } void gameLobbyDialogImpl::updateGameMode(unsigned gameId, int /*newMode*/) { - int it = 0; - while (myGameListModel->item(it)) { - if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) - { - QList itemList; - itemList << myGameListModel->item(it, 0) << myGameListModel->item(it, 1) << myGameListModel->item(it, 2) << myGameListModel->item(it, 3) << myGameListModel->item(it, 4); - updateGameItem(itemList, gameId); - break; - } - it++; - } + int it = 0; + while (myGameListModel->item(it)) { + if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) { + QList itemList; + itemList << myGameListModel->item(it, 0) << myGameListModel->item(it, 1) << myGameListModel->item(it, 2) << myGameListModel->item(it, 3) << myGameListModel->item(it, 4); + updateGameItem(itemList, gameId); + break; + } + it++; + } } void gameLobbyDialogImpl::updateGameAdmin(unsigned /*gameId*/, unsigned adminPlayerId) { - newGameAdmin(adminPlayerId, ""); + newGameAdmin(adminPlayerId, ""); } void gameLobbyDialogImpl::removeGame(unsigned gameId) { - int it = 0; - while (myGameListModel->item(it)) { - if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) - { - myGameListModel->removeRow(it); - break; - } - it++; - } + int it = 0; + while (myGameListModel->item(it)) { + if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) { + myGameListModel->removeRow(it); + break; + } + it++; + } - refreshGameStats(); + refreshGameStats(); } -void gameLobbyDialogImpl::refreshGameStats() { +void gameLobbyDialogImpl::refreshGameStats() +{ - int runningGamesCounter = 0; - int openGamesCounter = 0; + int runningGamesCounter = 0; + int openGamesCounter = 0; - int it = 0; - while (myGameListModel->item(it)) { - if (myGameListModel->item(it, 2)->data(16) == "running") { runningGamesCounter++; } - if (myGameListModel->item(it, 2)->data(16) == "open") { openGamesCounter++; } - ++it; - } + int it = 0; + while (myGameListModel->item(it)) { + if (myGameListModel->item(it, 2)->data(16) == "running") { + runningGamesCounter++; + } + if (myGameListModel->item(it, 2)->data(16) == "open") { + openGamesCounter++; + } + ++it; + } - label_openGamesCounter->setText("| "+tr("running games: %1").arg(runningGamesCounter)); - label_runningGamesCounter->setText("| "+tr("open games: %1").arg(openGamesCounter)); + label_openGamesCounter->setText("| "+tr("running games: %1").arg(runningGamesCounter)); + label_runningGamesCounter->setText("| "+tr("open games: %1").arg(openGamesCounter)); - //refresh joinAnyGameButton state - joinAnyGameButtonRefresh(); + //refresh joinAnyGameButton state + joinAnyGameButtonRefresh(); } -void gameLobbyDialogImpl::refreshPlayerStats() { +void gameLobbyDialogImpl::refreshPlayerStats() +{ - ServerStats stats = mySession->getClientStats(); - label_connectedPlayersCounter->setText(tr("connected players: %1").arg(myNickListModel->rowCount())); + ServerStats stats = mySession->getClientStats(); + label_connectedPlayersCounter->setText(tr("connected players: %1").arg(myNickListModel->rowCount())); } void gameLobbyDialogImpl::gameAddPlayer(unsigned gameId, unsigned playerId) { - if (!inGame) - { - QItemSelectionModel *selection = treeView_GameList->selectionModel(); - if (selection->hasSelection()) { - if(selection->selectedRows().at(0).data(Qt::UserRole).toUInt() == gameId) { - assert(mySession); - GameInfo info(mySession->getClientGameInfo(gameId)); - bool admin = info.adminPlayerId == playerId; - PlayerInfo playerInfo(mySession->getClientPlayerInfo(playerId)); + if (!inGame) { + QItemSelectionModel *selection = treeView_GameList->selectionModel(); + if (selection->hasSelection()) { + if(selection->selectedRows().at(0).data(Qt::UserRole).toUInt() == gameId) { + assert(mySession); + GameInfo info(mySession->getClientGameInfo(gameId)); + bool admin = info.adminPlayerId == playerId; + PlayerInfo playerInfo(mySession->getClientPlayerInfo(playerId)); - addConnectedPlayer(playerId, QString::fromUtf8(playerInfo.playerName.c_str()), admin); - } - } - } + addConnectedPlayer(playerId, QString::fromUtf8(playerInfo.playerName.c_str()), admin); + } + } + } - int it = 0; - while (myGameListModel->item(it)) { - if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) { - QList itemList; - itemList << myGameListModel->item(it, 0) << myGameListModel->item(it, 1) << myGameListModel->item(it, 2) << myGameListModel->item(it, 3) << myGameListModel->item(it, 4); + int it = 0; + while (myGameListModel->item(it)) { + if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) { + QList itemList; + itemList << myGameListModel->item(it, 0) << myGameListModel->item(it, 1) << myGameListModel->item(it, 2) << myGameListModel->item(it, 3) << myGameListModel->item(it, 4); - updateGameItem(itemList, gameId); - break; - } - it++; - } + updateGameItem(itemList, gameId); + break; + } + it++; + } - //mark player as active - int it1 = 0; - while (myNickListModel->item(it1)) { - if (myNickListModel->item(it1, 0)->data(Qt::UserRole) == playerId) { - myNickListModel->item(it1, 0)->setData("active", 34); - break; - } - ++it1; - } + //mark player as active + int it1 = 0; + while (myNickListModel->item(it1)) { + if (myNickListModel->item(it1, 0)->data(Qt::UserRole) == playerId) { + myNickListModel->item(it1, 0)->setData("active", 34); + break; + } + ++it1; + } } void gameLobbyDialogImpl::gameRemovePlayer(unsigned gameId, unsigned playerId) { - if (!inGame) - { - QItemSelectionModel *selection = treeView_GameList->selectionModel(); - if (selection->hasSelection()) { - if(selection->selectedRows().at(0).data(Qt::UserRole).toUInt() == gameId) { - assert(mySession); - PlayerInfo info(mySession->getClientPlayerInfo(playerId)); - removePlayer(playerId, QString::fromUtf8(info.playerName.c_str())); - } - } - } + if (!inGame) { + QItemSelectionModel *selection = treeView_GameList->selectionModel(); + if (selection->hasSelection()) { + if(selection->selectedRows().at(0).data(Qt::UserRole).toUInt() == gameId) { + assert(mySession); + PlayerInfo info(mySession->getClientPlayerInfo(playerId)); + removePlayer(playerId, QString::fromUtf8(info.playerName.c_str())); + } + } + } - int it = 0; - while (myGameListModel->item(it)) { - if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) { - QList itemList; - itemList << myGameListModel->item(it, 0) << myGameListModel->item(it, 1) << myGameListModel->item(it, 2) << myGameListModel->item(it, 3) << myGameListModel->item(it, 4); + int it = 0; + while (myGameListModel->item(it)) { + if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) { + QList itemList; + itemList << myGameListModel->item(it, 0) << myGameListModel->item(it, 1) << myGameListModel->item(it, 2) << myGameListModel->item(it, 3) << myGameListModel->item(it, 4); - updateGameItem(itemList, gameId); - break; - } - ++it; - } + updateGameItem(itemList, gameId); + break; + } + ++it; + } - //mark player as idle again - int it1 = 0; - while (myNickListModel->item(it1)) { - if (myNickListModel->item(it1, 0)->data(Qt::UserRole) == playerId) { - myNickListModel->item(it1, 0)->setData("idle", 34); - break; - } - ++it1; - } + //mark player as idle again + int it1 = 0; + while (myNickListModel->item(it1)) { + if (myNickListModel->item(it1, 0)->data(Qt::UserRole) == playerId) { + myNickListModel->item(it1, 0)->setData("idle", 34); + break; + } + ++it1; + } } void gameLobbyDialogImpl::updateStats(ServerStats /*stats*/) { - refreshPlayerStats(); + refreshPlayerStats(); } void gameLobbyDialogImpl::clearDialog() { - groupBox_GameInfo->setTitle(tr("Game Info")); - groupBox_GameInfo->setEnabled(false); - currentGameName = ""; + groupBox_GameInfo->setTitle(tr("Game Info")); + groupBox_GameInfo->setEnabled(false); + currentGameName = ""; - QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); - header->setText(0, tr("Connected players")); - header->setData(0, Qt::UserRole, 0); + QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); + header->setText(0, tr("Connected players")); + header->setData(0, Qt::UserRole, 0); - showGameDescription(FALSE); - label_typeIcon->setText(" "); - label_typeText->setText(" "); - label_SmallBlind->setText(""); - label_StartCash->setText(""); - label_blindsRaiseIntervall->setText(""); - label_blindsRaiseMode->setText(""); - label_blindsList->setText(""); - label_TimeoutForPlayerAction->setText(""); + showGameDescription(FALSE); + label_typeIcon->setText(" "); + label_typeText->setText(" "); + label_SmallBlind->setText(""); + label_StartCash->setText(""); + label_blindsRaiseIntervall->setText(""); + label_blindsRaiseMode->setText(""); + label_blindsList->setText(""); + label_TimeoutForPlayerAction->setText(""); - myGameListModel->clear(); - myGameListSelectionModel->clear(); - myGameListSelectionModel->clearSelection(); - myGameListSortFilterProxyModel->clear(); - treeView_GameList->show(); - treeWidget_connectedPlayers->clear(); + myGameListModel->clear(); + myGameListSelectionModel->clear(); + myGameListSelectionModel->clearSelection(); + myGameListSortFilterProxyModel->clear(); + treeView_GameList->show(); + treeWidget_connectedPlayers->clear(); - pushButton_Leave->hide(); - pushButton_Kick->hide(); - pushButton_Kick->setEnabled(false); - pushButton_StartGame->hide(); - checkBox_fillUpWithComputerOpponents->hide(); - pushButton_CreateGame->show(); - pushButton_JoinGame->show(); - pushButton_JoinGame->setEnabled(false); - pushButton_joinAnyGame->show(); - pushButton_joinAnyGame->setEnabled(false); + pushButton_Leave->hide(); + pushButton_Kick->hide(); + pushButton_Kick->setEnabled(false); + pushButton_StartGame->hide(); + checkBox_fillUpWithComputerOpponents->hide(); + pushButton_CreateGame->show(); + pushButton_JoinGame->show(); + pushButton_JoinGame->setEnabled(false); + pushButton_joinAnyGame->show(); + pushButton_joinAnyGame->setEnabled(false); - QStringList headerList; - headerList << tr("Game") << tr("Players") << tr("State") << tr("T") << tr("P"); - myGameListModel->setHorizontalHeaderLabels(headerList); - treeView_GameList->setColumnWidth(0,190); - treeView_GameList->setColumnWidth(1,65); - treeView_GameList->setColumnWidth(2,65); - treeView_GameList->setColumnWidth(3,40); - treeView_GameList->setColumnWidth(4,40); + QStringList headerList; + headerList << tr("Game") << tr("Players") << tr("State") << tr("T") << tr("P"); + myGameListModel->setHorizontalHeaderLabels(headerList); + treeView_GameList->setColumnWidth(0,190); + treeView_GameList->setColumnWidth(1,65); + treeView_GameList->setColumnWidth(2,65); + treeView_GameList->setColumnWidth(3,40); + treeView_GameList->setColumnWidth(4,40); - pushButton_CreateGame->clearFocus(); - lineEdit_ChatInput->setFocus(); - myChat->clearChat(); + pushButton_CreateGame->clearFocus(); + lineEdit_ChatInput->setFocus(); + myChat->clearChat(); - myNickListModel->clear(); - myNickListSelectionModel->clear(); - myNickListSelectionModel->clearSelection();; - QStringList headerList2; - headerList2 << tr("Available Players"); - myNickListModel->setHorizontalHeaderLabels(headerList2); - myNickListModel->sort(0, treeView_NickList->header()->sortIndicatorOrder()); + myNickListModel->clear(); + myNickListSelectionModel->clear(); + myNickListSelectionModel->clearSelection();; + QStringList headerList2; + headerList2 << tr("Available Players"); + myNickListModel->setHorizontalHeaderLabels(headerList2); + myNickListModel->sort(0, treeView_NickList->header()->sortIndicatorOrder()); - inGame = false; - isGameAdministrator = false; - myPlayerId = 0; + inGame = false; + isGameAdministrator = false; + myPlayerId = 0; - showGameDescription(FALSE); + showGameDescription(FALSE); - label_connectedPlayersCounter->setText(tr("connected players: %1").arg(0)); - label_openGamesCounter->setText("| "+tr("running games: %1").arg(0)); - label_runningGamesCounter->setText("| "+tr("open games: %1").arg(0)); + label_connectedPlayersCounter->setText(tr("connected players: %1").arg(0)); + label_openGamesCounter->setText("| "+tr("running games: %1").arg(0)); + label_runningGamesCounter->setText("| "+tr("open games: %1").arg(0)); - readDialogSettings(); + readDialogSettings(); } -void gameLobbyDialogImpl::checkPlayerQuantity() { +void gameLobbyDialogImpl::checkPlayerQuantity() +{ - assert(mySession); - GameInfo info(mySession->getClientGameInfo(mySession->getClientCurrentGameId())); + assert(mySession); + GameInfo info(mySession->getClientGameInfo(mySession->getClientCurrentGameId())); - if(isGameAdministrator && info.data.gameType != GAME_TYPE_RANKING){ + if(isGameAdministrator && info.data.gameType != GAME_TYPE_RANKING) { - pushButton_Kick->show(); - pushButton_StartGame->show(); - checkBox_fillUpWithComputerOpponents->show(); + pushButton_Kick->show(); + pushButton_StartGame->show(); + checkBox_fillUpWithComputerOpponents->show(); - if (treeWidget_connectedPlayers->topLevelItemCount() >= 2) { - pushButton_StartGame->setEnabled(true); + if (treeWidget_connectedPlayers->topLevelItemCount() >= 2) { + pushButton_StartGame->setEnabled(true); - if(treeWidget_connectedPlayers->topLevelItemCount() == treeWidget_connectedPlayers->headerItem()->data(0, Qt::UserRole).toInt()) { - blinkingButtonAnimationTimer->start(); - } - else { - blinkingButtonAnimationTimer->stop(); - blinkingButtonAnimationState = false; - blinkingStartButtonAnimation(); - } - } - else { - pushButton_StartGame->setEnabled(false); - blinkingButtonAnimationTimer->stop(); - blinkingButtonAnimationState = false; - blinkingStartButtonAnimation(); - } - } + if(treeWidget_connectedPlayers->topLevelItemCount() == treeWidget_connectedPlayers->headerItem()->data(0, Qt::UserRole).toInt()) { + blinkingButtonAnimationTimer->start(); + } else { + blinkingButtonAnimationTimer->stop(); + blinkingButtonAnimationState = false; + blinkingStartButtonAnimation(); + } + } else { + pushButton_StartGame->setEnabled(false); + blinkingButtonAnimationTimer->stop(); + blinkingButtonAnimationState = false; + blinkingStartButtonAnimation(); + } + } - //general actions - if(treeWidget_connectedPlayers->topLevelItemCount() < treeWidget_connectedPlayers->headerItem()->data(0, Qt::UserRole).toInt()) { - autoStartTimerOverlay->hide(); - autoStartTimer->stop(); - } + //general actions + if(treeWidget_connectedPlayers->topLevelItemCount() < treeWidget_connectedPlayers->headerItem()->data(0, Qt::UserRole).toInt()) { + autoStartTimerOverlay->hide(); + autoStartTimer->stop(); + } } -void gameLobbyDialogImpl::blinkingStartButtonAnimation() { +void gameLobbyDialogImpl::blinkingStartButtonAnimation() +{ - if(blinkingButtonAnimationState) { - QPalette p = pushButton_StartGame->palette(); - p.setColor(QPalette::Button, QColor(Qt::red)); - p.setColor(QPalette::ButtonText, QColor(Qt::white)); - pushButton_StartGame->setPalette(p); - blinkingButtonAnimationState = false; - } - else { - if(pushButton_StartGame->isEnabled()) { - QPalette p = pushButton_StartGame->palette(); - p.setColor(QPalette::Button, defaultStartButtonColor); - p.setColor(QPalette::ButtonText, defaultStartButtonTextColor); - pushButton_StartGame->setPalette(p); - blinkingButtonAnimationState = true; - } - else { - QPalette p = pushButton_StartGame->palette(); - p.setColor(QPalette::Button, disabledStartButtonColor); - p.setColor(QPalette::ButtonText, disabledStartButtonTextColor); - pushButton_StartGame->setPalette(p); - blinkingButtonAnimationState = true; - } - } + if(blinkingButtonAnimationState) { + QPalette p = pushButton_StartGame->palette(); + p.setColor(QPalette::Button, QColor(Qt::red)); + p.setColor(QPalette::ButtonText, QColor(Qt::white)); + pushButton_StartGame->setPalette(p); + blinkingButtonAnimationState = false; + } else { + if(pushButton_StartGame->isEnabled()) { + QPalette p = pushButton_StartGame->palette(); + p.setColor(QPalette::Button, defaultStartButtonColor); + p.setColor(QPalette::ButtonText, defaultStartButtonTextColor); + pushButton_StartGame->setPalette(p); + blinkingButtonAnimationState = true; + } else { + QPalette p = pushButton_StartGame->palette(); + p.setColor(QPalette::Button, disabledStartButtonColor); + p.setColor(QPalette::ButtonText, disabledStartButtonTextColor); + pushButton_StartGame->setPalette(p); + blinkingButtonAnimationState = true; + } + } } -void gameLobbyDialogImpl::joinedNetworkGame(unsigned playerId, QString playerName, bool isGameAdmin) { +void gameLobbyDialogImpl::joinedNetworkGame(unsigned playerId, QString playerName, bool isGameAdmin) +{ - // Update dialog - inGame = true; - joinedGameDialogUpdate(); + // Update dialog + inGame = true; + joinedGameDialogUpdate(); - myPlayerId = playerId; - isGameAdministrator = isGameAdmin; - addConnectedPlayer(playerId, playerName, isGameAdmin); + myPlayerId = playerId; + isGameAdministrator = isGameAdmin; + addConnectedPlayer(playerId, playerName, isGameAdmin); - //show msgBox about invite only game - assert(mySession); - if(mySession->getClientGameInfo(mySession->getClientCurrentGameId()).data.gameType == GAME_TYPE_INVITE_ONLY) { - infoMsgToShowId = 2; - showInfoMsgBoxTimer->start(1000); - } + //show msgBox about invite only game + assert(mySession); + if(mySession->getClientGameInfo(mySession->getClientCurrentGameId()).data.gameType == GAME_TYPE_INVITE_ONLY) { + infoMsgToShowId = 2; + showInfoMsgBoxTimer->start(1000); + } - // if(!myGameListSelectionModel->hasSelection() && mySession->getClientGameInfo(mySession->getClientCurrentGameId()).data.gameType == GAME_TYPE_INVITE_ONLY) { - // int it = 0; - // while (myGameListModel->item(it)) { - // if (myGameListModel->item(it, 0)->data(Qt::UserRole) == mySession->getClientCurrentGameId()) { - // gameSelected(treeView_GameList->model()->index(it,0), true); - // break; - // } - // it++; - // } - // } + // if(!myGameListSelectionModel->hasSelection() && mySession->getClientGameInfo(mySession->getClientCurrentGameId()).data.gameType == GAME_TYPE_INVITE_ONLY) { + // int it = 0; + // while (myGameListModel->item(it)) { + // if (myGameListModel->item(it, 0)->data(Qt::UserRole) == mySession->getClientCurrentGameId()) { + // gameSelected(treeView_GameList->model()->index(it,0), true); + // break; + // } + // it++; + // } + // } } -void gameLobbyDialogImpl::addConnectedPlayer(unsigned playerId, QString playerName, bool isGameAdmin) { +void gameLobbyDialogImpl::addConnectedPlayer(unsigned playerId, QString playerName, bool isGameAdmin) +{ - QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_connectedPlayers, 0); - item->setData(0, Qt::UserRole, playerId); - item->setData(0, Qt::DisplayRole, playerName); + QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_connectedPlayers, 0); + item->setData(0, Qt::UserRole, playerId); + item->setData(0, Qt::DisplayRole, playerName); - if(isGameAdmin) item->setBackground(0, QBrush(QColor(0, 255, 0, 127))); + if(isGameAdmin) item->setBackground(0, QBrush(QColor(0, 255, 0, 127))); - if(this->isVisible() && inGame && myConfig->readConfigInt("PlayNetworkGameNotification")) { - if(treeWidget_connectedPlayers->topLevelItemCount() < treeWidget_connectedPlayers->headerItem()->data(0, Qt::UserRole).toInt()) { - myW->getMySDLPlayer()->playSound("playerconnected", 0); - } - else { - myW->getMySDLPlayer()->playSound("onlinegameready", 0); - showAutoStartTimer(); - } - } + if(this->isVisible() && inGame && myConfig->readConfigInt("PlayNetworkGameNotification")) { + if(treeWidget_connectedPlayers->topLevelItemCount() < treeWidget_connectedPlayers->headerItem()->data(0, Qt::UserRole).toInt()) { + myW->getMySDLPlayer()->playSound("playerconnected", 0); + } else { + myW->getMySDLPlayer()->playSound("onlinegameready", 0); + showAutoStartTimer(); + } + } - checkPlayerQuantity(); + checkPlayerQuantity(); - if (inGame) - refreshConnectedPlayerAvatars(); + if (inGame) + refreshConnectedPlayerAvatars(); } -void gameLobbyDialogImpl::updatePlayer(unsigned playerId, QString newPlayerName) { +void gameLobbyDialogImpl::updatePlayer(unsigned playerId, QString newPlayerName) +{ - //rename player in connected players list - QTreeWidgetItemIterator it(treeWidget_connectedPlayers); - while (*it) { - if ((*it)->data(0, Qt::UserRole) == playerId) - { - (*it)->setData(0, Qt::DisplayRole, newPlayerName); - break; - } - ++it; - } + //rename player in connected players list + QTreeWidgetItemIterator it(treeWidget_connectedPlayers); + while (*it) { + if ((*it)->data(0, Qt::UserRole) == playerId) { + (*it)->setData(0, Qt::DisplayRole, newPlayerName); + break; + } + ++it; + } - if (inGame) - refreshConnectedPlayerAvatars(); + if (inGame) + refreshConnectedPlayerAvatars(); - //also rename player in nick-list - QString oldNick; - int it1 = 0; - while (myNickListModel->item(it1)) { - if (myNickListModel->item(it1, 0)->data(Qt::UserRole) == playerId) { - oldNick = myNickListModel->item(it1, 0)->text(); - myNickListModel->item(it1, 0)->setText(newPlayerName); + //also rename player in nick-list + QString oldNick; + int it1 = 0; + while (myNickListModel->item(it1)) { + if (myNickListModel->item(it1, 0)->data(Qt::UserRole) == playerId) { + oldNick = myNickListModel->item(it1, 0)->text(); + myNickListModel->item(it1, 0)->setText(newPlayerName); - PlayerInfo playerInfo(mySession->getClientPlayerInfo(playerId)); - QString countryString = QString::fromUtf8(playerInfo.countryCode.c_str()).toLower(); - myNickListModel->item(it1, 0)->setData(countryString, 33); - if(playerInfo.isGuest || countryString.isEmpty()) { - myNickListModel->item(it1, 0)->setIcon(QIcon(":/cflags/cflags/undefined.png")); - } - else { - myNickListModel->item(it1, 0)->setIcon(QIcon(QString(":/cflags/cflags/%1.png").arg(countryString))); - } + PlayerInfo playerInfo(mySession->getClientPlayerInfo(playerId)); + QString countryString = QString::fromUtf8(playerInfo.countryCode.c_str()).toLower(); + myNickListModel->item(it1, 0)->setData(countryString, 33); + if(playerInfo.isGuest || countryString.isEmpty()) { + myNickListModel->item(it1, 0)->setIcon(QIcon(":/cflags/cflags/undefined.png")); + } else { + myNickListModel->item(it1, 0)->setIcon(QIcon(QString(":/cflags/cflags/%1.png").arg(countryString))); + } - unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerId); - if(gameIdOfPlayer) { myNickListModel->item(it1, 0)->setData("active", 34); } - else { myNickListModel->item(it1, 0)->setData("idle", 34); } + unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerId); + if(gameIdOfPlayer) { + myNickListModel->item(it1, 0)->setData("active", 34); + } else { + myNickListModel->item(it1, 0)->setData("idle", 34); + } - break; - } + break; + } - ++it1; - } + ++it1; + } - if (myChat->getMyNick() == oldNick) { - myChat->setMyNick(newPlayerName); - } + if (myChat->getMyNick() == oldNick) { + myChat->setMyNick(newPlayerName); + } } -void gameLobbyDialogImpl::removePlayer(unsigned playerId, QString) { +void gameLobbyDialogImpl::removePlayer(unsigned playerId, QString) +{ - QTreeWidgetItemIterator it(treeWidget_connectedPlayers); - while (*it) { - if ((*it)->data(0, Qt::UserRole) == playerId) - { - treeWidget_connectedPlayers->takeTopLevelItem(treeWidget_connectedPlayers->indexOfTopLevelItem(*it)); - break; - } - ++it; - } + QTreeWidgetItemIterator it(treeWidget_connectedPlayers); + while (*it) { + if ((*it)->data(0, Qt::UserRole) == playerId) { + treeWidget_connectedPlayers->takeTopLevelItem(treeWidget_connectedPlayers->indexOfTopLevelItem(*it)); + break; + } + ++it; + } - checkPlayerQuantity(); + checkPlayerQuantity(); } void gameLobbyDialogImpl::playerLeftLobby(unsigned playerId) { - int it1 = 0; - while (myNickListModel->item(it1)) { - if (myNickListModel->item(it1, 0)->data(Qt::UserRole) == playerId) { - myNickListModel->removeRow(it1);; - break; - } - ++it1; - } + int it1 = 0; + while (myNickListModel->item(it1)) { + if (myNickListModel->item(it1, 0)->data(Qt::UserRole) == playerId) { + myNickListModel->removeRow(it1);; + break; + } + ++it1; + } - refreshPlayerStats(); + refreshPlayerStats(); } void gameLobbyDialogImpl::playerJoinedLobby(unsigned playerId, QString /*playerName TODO remove*/) { - PlayerInfo playerInfo(mySession->getClientPlayerInfo(playerId)); - QString countryString = QString::fromUtf8(playerInfo.countryCode.c_str()).toLower(); + PlayerInfo playerInfo(mySession->getClientPlayerInfo(playerId)); + QString countryString = QString::fromUtf8(playerInfo.countryCode.c_str()).toLower(); - QStandardItem *item = new QStandardItem; - item->setText(QString::fromUtf8(playerInfo.playerName.c_str())); - item->setData(playerId, Qt::UserRole); - item->setData(countryString, 33); - if(playerInfo.isGuest || countryString.isEmpty()) { - item->setIcon(QIcon(":/cflags/cflags/undefined.png")); - } - else { - item->setIcon(QIcon(QString(":/cflags/cflags/%1.png").arg(countryString))); - } + QStandardItem *item = new QStandardItem; + item->setText(QString::fromUtf8(playerInfo.playerName.c_str())); + item->setData(playerId, Qt::UserRole); + item->setData(countryString, 33); + if(playerInfo.isGuest || countryString.isEmpty()) { + item->setIcon(QIcon(":/cflags/cflags/undefined.png")); + } else { + item->setIcon(QIcon(QString(":/cflags/cflags/%1.png").arg(countryString))); + } - unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerId); - if(gameIdOfPlayer) { item->setData("active", 34); } - else { item->setData("idle", 34); } + unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerId); + if(gameIdOfPlayer) { + item->setData("active", 34); + } else { + item->setData("idle", 34); + } - myNickListModel->appendRow(item); + myNickListModel->appendRow(item); - refreshPlayerStats(); + refreshPlayerStats(); } void gameLobbyDialogImpl::newGameAdmin(unsigned playerId, QString) { - QTreeWidgetItemIterator it(treeWidget_connectedPlayers); - while (*it) { - if ((*it)->data(0, Qt::UserRole) == playerId) { - (*it)->setBackground(0, QBrush(QColor(0, 255, 0, 127))); - } - ++it; - } + QTreeWidgetItemIterator it(treeWidget_connectedPlayers); + while (*it) { + if ((*it)->data(0, Qt::UserRole) == playerId) { + (*it)->setBackground(0, QBrush(QColor(0, 255, 0, 127))); + } + ++it; + } - if (inGame && myPlayerId == playerId) - { - isGameAdministrator = true; - checkPlayerQuantity(); - } + if (inGame && myPlayerId == playerId) { + isGameAdministrator = true; + checkPlayerQuantity(); + } } -void gameLobbyDialogImpl::refreshConnectedPlayerAvatars() { +void gameLobbyDialogImpl::refreshConnectedPlayerAvatars() +{ - QTreeWidgetItemIterator it(treeWidget_connectedPlayers); - while (*it) { + QTreeWidgetItemIterator it(treeWidget_connectedPlayers); + while (*it) { - std::string myAvatarFileName; - PlayerInfo playerInfo(mySession->getClientPlayerInfo((*it)->data(0, Qt::UserRole).toUInt())); + std::string myAvatarFileName; + PlayerInfo playerInfo(mySession->getClientPlayerInfo((*it)->data(0, Qt::UserRole).toUInt())); - if(mySession->getAvatarFile(playerInfo.avatar, myAvatarFileName)) { + if(mySession->getAvatarFile(playerInfo.avatar, myAvatarFileName)) { - QString myAvatarString(QString::fromUtf8(myAvatarFileName.c_str())); - QFile myAvatarFile(myAvatarString); - if(myAvatarFile.exists()) { + QString myAvatarString(QString::fromUtf8(myAvatarFileName.c_str())); + QFile myAvatarFile(myAvatarString); + if(myAvatarFile.exists()) { - QPixmap tempAvatar(myAvatarString); - QPixmap myAvatarPixmap(25,26); - myAvatarPixmap.fill(Qt::transparent); - QPainter p(&myAvatarPixmap); - p.drawPixmap (0,0,25,25, tempAvatar.scaled(25,25,Qt::KeepAspectRatio,Qt::SmoothTransformation)); + QPixmap tempAvatar(myAvatarString); + QPixmap myAvatarPixmap(25,26); + myAvatarPixmap.fill(Qt::transparent); + QPainter p(&myAvatarPixmap); + p.drawPixmap (0,0,25,25, tempAvatar.scaled(25,25,Qt::KeepAspectRatio,Qt::SmoothTransformation)); - (*it)->setIcon(0, QIcon(myAvatarPixmap)); - } - } - ++it; - } + (*it)->setIcon(0, QIcon(myAvatarPixmap)); + } + } + ++it; + } } -void gameLobbyDialogImpl::joinedGameDialogUpdate() { +void gameLobbyDialogImpl::joinedGameDialogUpdate() +{ - groupBox_GameInfo->setEnabled(true); - groupBox_GameInfo->setTitle(currentGameName); - treeWidget_connectedPlayers->clear(); - pushButton_CreateGame->hide(); - pushButton_JoinGame->hide(); - pushButton_joinAnyGame->hide(); - pushButton_Leave->show(); + groupBox_GameInfo->setEnabled(true); + groupBox_GameInfo->setTitle(currentGameName); + treeWidget_connectedPlayers->clear(); + pushButton_CreateGame->hide(); + pushButton_JoinGame->hide(); + pushButton_joinAnyGame->hide(); + pushButton_Leave->show(); - //this was added to show game infos even if no game was selected (e.g. invite only game) - assert(mySession); - GameInfo info(mySession->getClientGameInfo(mySession->getClientCurrentGameId())); + //this was added to show game infos even if no game was selected (e.g. invite only game) + assert(mySession); + GameInfo info(mySession->getClientGameInfo(mySession->getClientCurrentGameId())); - groupBox_GameInfo->setTitle(tr("Game Info") + " - " + QString::fromUtf8(info.name.c_str())); + groupBox_GameInfo->setTitle(tr("Game Info") + " - " + QString::fromUtf8(info.name.c_str())); - switch (info.data.gameType) { - case GAME_TYPE_NORMAL: { - label_typeIcon->setPixmap(QPixmap(":/gfx/player_play.png")); - label_typeText->setText(tr("Standard")); - } - break; - case GAME_TYPE_REGISTERED_ONLY: { - label_typeIcon->setPixmap(QPixmap(":/gfx/registered.png")); - label_typeText->setText(tr("Registered players only")); - } - break; - case GAME_TYPE_INVITE_ONLY: { - label_typeIcon->setPixmap(QPixmap(":/gfx/list_add_user.png")); - label_typeText->setText(tr("Invited players only")); - } - break; - case GAME_TYPE_RANKING: { - label_typeIcon->setPixmap(QPixmap(":/gfx/cup.png")); - label_typeText->setText(tr("Ranking game")); - } - break; - } + switch (info.data.gameType) { + case GAME_TYPE_NORMAL: { + label_typeIcon->setPixmap(QPixmap(":/gfx/player_play.png")); + label_typeText->setText(tr("Standard")); + } + break; + case GAME_TYPE_REGISTERED_ONLY: { + label_typeIcon->setPixmap(QPixmap(":/gfx/registered.png")); + label_typeText->setText(tr("Registered players only")); + } + break; + case GAME_TYPE_INVITE_ONLY: { + label_typeIcon->setPixmap(QPixmap(":/gfx/list_add_user.png")); + label_typeText->setText(tr("Invited players only")); + } + break; + case GAME_TYPE_RANKING: { + label_typeIcon->setPixmap(QPixmap(":/gfx/cup.png")); + label_typeText->setText(tr("Ranking game")); + } + break; + } - showGameDescription(TRUE); - label_SmallBlind->setText(QString("%L1").arg(info.data.firstSmallBlind)); - label_StartCash->setText(QString("%L1").arg(info.data.startMoney)); - updateDialogBlinds(info.data); - label_TimeoutForPlayerAction->setText(QString::number(info.data.playerActionTimeoutSec)); + showGameDescription(TRUE); + label_SmallBlind->setText(QString("%L1").arg(info.data.firstSmallBlind)); + label_StartCash->setText(QString("%L1").arg(info.data.startMoney)); + updateDialogBlinds(info.data); + label_TimeoutForPlayerAction->setText(QString::number(info.data.playerActionTimeoutSec)); - QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); - header->setText(0, tr("Connected players - Max. %1").arg(info.data.maxNumberOfPlayers)); - header->setData(0, Qt::UserRole, info.data.maxNumberOfPlayers); + QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); + header->setText(0, tr("Connected players - Max. %1").arg(info.data.maxNumberOfPlayers)); + header->setData(0, Qt::UserRole, info.data.maxNumberOfPlayers); } -void gameLobbyDialogImpl::leftGameDialogUpdate() { +void gameLobbyDialogImpl::leftGameDialogUpdate() +{ - // un-select current game. - treeView_GameList->clearSelection(); + // un-select current game. + treeView_GameList->clearSelection(); - groupBox_GameInfo->setTitle(tr("Game Info")); - groupBox_GameInfo->setEnabled(false); - currentGameName = ""; + groupBox_GameInfo->setTitle(tr("Game Info")); + groupBox_GameInfo->setEnabled(false); + currentGameName = ""; - QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); - header->setText(0, tr("Connected players")); - header->setData(0, Qt::UserRole, 0); + QTreeWidgetItem *header = treeWidget_connectedPlayers->headerItem(); + header->setText(0, tr("Connected players")); + header->setData(0, Qt::UserRole, 0); - showGameDescription(FALSE); - label_typeIcon->setText(" "); - label_typeText->setText(" "); - label_SmallBlind->setText(""); - label_StartCash->setText(""); - label_blindsRaiseIntervall->setText(""); - label_blindsRaiseMode->setText(""); - label_blindsList->setText(""); - label_TimeoutForPlayerAction->setText(""); + showGameDescription(FALSE); + label_typeIcon->setText(" "); + label_typeText->setText(" "); + label_SmallBlind->setText(""); + label_StartCash->setText(""); + label_blindsRaiseIntervall->setText(""); + label_blindsRaiseMode->setText(""); + label_blindsList->setText(""); + label_TimeoutForPlayerAction->setText(""); - treeWidget_connectedPlayers->clear(); - pushButton_StartGame->hide(); - pushButton_Leave->hide(); - pushButton_Kick->hide(); - pushButton_Kick->setEnabled(false); - checkBox_fillUpWithComputerOpponents->hide(); - pushButton_CreateGame->show(); - pushButton_JoinGame->show(); - pushButton_JoinGame->setEnabled(false); - pushButton_joinAnyGame->show(); - joinAnyGameButtonRefresh(); + treeWidget_connectedPlayers->clear(); + pushButton_StartGame->hide(); + pushButton_Leave->hide(); + pushButton_Kick->hide(); + pushButton_Kick->setEnabled(false); + checkBox_fillUpWithComputerOpponents->hide(); + pushButton_CreateGame->show(); + pushButton_JoinGame->show(); + pushButton_JoinGame->setEnabled(false); + pushButton_joinAnyGame->show(); + joinAnyGameButtonRefresh(); - lineEdit_ChatInput->setFocus(); + lineEdit_ChatInput->setFocus(); } -void gameLobbyDialogImpl::updateDialogBlinds(const GameData &gameData) { +void gameLobbyDialogImpl::updateDialogBlinds(const GameData &gameData) +{ - if(gameData.raiseIntervalMode == RAISE_ON_HANDNUMBER) { label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryHandsValue)+" "+tr("hands")); } - else { label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryMinutesValue)+" "+tr("minutes")); } - if(gameData.raiseMode == DOUBLE_BLINDS) { - label_blindsRaiseMode->setText(tr("double blinds")); - label_blindsList->hide(); - label_gameDesc6->hide(); - } - else { - label_blindsRaiseMode->setText(tr("manual blinds order")); - label_blindsList->show(); - label_gameDesc6->show(); + if(gameData.raiseIntervalMode == RAISE_ON_HANDNUMBER) { + label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryHandsValue)+" "+tr("hands")); + } else { + label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryMinutesValue)+" "+tr("minutes")); + } + if(gameData.raiseMode == DOUBLE_BLINDS) { + label_blindsRaiseMode->setText(tr("double blinds")); + label_blindsList->hide(); + label_gameDesc6->hide(); + } else { + label_blindsRaiseMode->setText(tr("manual blinds order")); + label_blindsList->show(); + label_gameDesc6->show(); - QString blindsListString; - std::list::const_iterator it1; + QString blindsListString; + std::list::const_iterator it1; for(it1= gameData.manualBlindsList.begin(); it1 != gameData.manualBlindsList.end(); ++it1) { - blindsListString.append(QString("%L1").arg(*it1)).append(", "); - } - blindsListString.remove(blindsListString.length()-2,2); - label_blindsList->setText(blindsListString); - } + blindsListString.append(QString("%L1").arg(*it1)).append(", "); + } + blindsListString.remove(blindsListString.length()-2,2); + label_blindsList->setText(blindsListString); + } } -void gameLobbyDialogImpl::playerSelected(QTreeWidgetItem* item, QTreeWidgetItem*) { +void gameLobbyDialogImpl::playerSelected(QTreeWidgetItem* item, QTreeWidgetItem*) +{ - if (item) - pushButton_Kick->setEnabled(isGameAdministrator); + if (item) + pushButton_Kick->setEnabled(isGameAdministrator); } -void gameLobbyDialogImpl::startGame() { +void gameLobbyDialogImpl::startGame() +{ - assert(mySession); - mySession->sendStartEvent(checkBox_fillUpWithComputerOpponents->isChecked()); + assert(mySession); + mySession->sendStartEvent(checkBox_fillUpWithComputerOpponents->isChecked()); } -void gameLobbyDialogImpl::leaveGame() { +void gameLobbyDialogImpl::leaveGame() +{ - assert(mySession); - mySession->sendLeaveCurrentGame(); + assert(mySession); + mySession->sendLeaveCurrentGame(); - //stop autoStartTimerOverlay - autoStartTimerOverlay->hide(); - autoStartTimer->stop(); + //stop autoStartTimerOverlay + autoStartTimerOverlay->hide(); + autoStartTimer->stop(); - //stop waitStartGameMsgBox - waitStartGameMsgBoxTimer->stop(); - waitStartGameMsgBox->hide(); + //stop waitStartGameMsgBox + waitStartGameMsgBoxTimer->stop(); + waitStartGameMsgBox->hide(); } -void gameLobbyDialogImpl::kickPlayer() { +void gameLobbyDialogImpl::kickPlayer() +{ - QTreeWidgetItem *item = treeWidget_connectedPlayers->currentItem(); - if (item) - { - QString playerName = item->text(0); - if(playerName == QString::fromUtf8(myConfig->readConfigString("MyName").c_str())) { - { QMessageBox::warning(this, tr("Server Error"), - tr("You should not kick yourself from this game!"), - QMessageBox::Close); } - } - else { - assert(mySession); - mySession->kickPlayer(item->data(0, Qt::UserRole).toUInt()); - } - } - pushButton_Kick->setEnabled(false); + QTreeWidgetItem *item = treeWidget_connectedPlayers->currentItem(); + if (item) { + QString playerName = item->text(0); + if(playerName == QString::fromUtf8(myConfig->readConfigString("MyName").c_str())) { + { + QMessageBox::warning(this, tr("Server Error"), + tr("You should not kick yourself from this game!"), + QMessageBox::Close); + } + } else { + assert(mySession); + mySession->kickPlayer(item->data(0, Qt::UserRole).toUInt()); + } + } + pushButton_Kick->setEnabled(false); } -void gameLobbyDialogImpl::keyPressEvent ( QKeyEvent * event ) { +void gameLobbyDialogImpl::keyPressEvent ( QKeyEvent * event ) +{ - // qDebug() << event->key() << "\n"; + // qDebug() << event->key() << "\n"; - if (event->key() == Qt::Key_Enter && lineEdit_ChatInput->hasFocus()) { myChat->sendMessage(); } + if (event->key() == Qt::Key_Enter && lineEdit_ChatInput->hasFocus()) { + myChat->sendMessage(); + } - if (event->key() == Qt::Key_Up && lineEdit_ChatInput->hasFocus()) { - if((keyUpCounter + 1) <= myChat->getChatLinesHistorySize()) { keyUpCounter++; } - // std::cout << "Up keyUpCounter: " << keyUpCounter << "\n"; - myChat->showChatHistoryIndex(keyUpCounter); - } - else if(event->key() == Qt::Key_Down && lineEdit_ChatInput->hasFocus()) { - if((keyUpCounter - 1) >= 0) { keyUpCounter--; } - // std::cout << "Down keyUpCounter: " << keyUpCounter << "\n"; - myChat->showChatHistoryIndex(keyUpCounter); - } - else { keyUpCounter = 0; } + if (event->key() == Qt::Key_Up && lineEdit_ChatInput->hasFocus()) { + if((keyUpCounter + 1) <= myChat->getChatLinesHistorySize()) { + keyUpCounter++; + } + // std::cout << "Up keyUpCounter: " << keyUpCounter << "\n"; + myChat->showChatHistoryIndex(keyUpCounter); + } else if(event->key() == Qt::Key_Down && lineEdit_ChatInput->hasFocus()) { + if((keyUpCounter - 1) >= 0) { + keyUpCounter--; + } + // std::cout << "Down keyUpCounter: " << keyUpCounter << "\n"; + myChat->showChatHistoryIndex(keyUpCounter); + } else { + keyUpCounter = 0; + } - // if (event->key() == Qt::Key_Tab) event->ignore(); else { /*blah*/ } + // if (event->key() == Qt::Key_Tab) event->ignore(); else { /*blah*/ } - // if (event->key() == Qt::Key_N) showInvitationDialog(); - // if (event->key() == Qt::Key_M) guestUserMode(); + // if (event->key() == Qt::Key_N) showInvitationDialog(); + // if (event->key() == Qt::Key_M) guestUserMode(); } bool gameLobbyDialogImpl::eventFilter(QObject *obj, QEvent *event) { - QKeyEvent *keyEvent = static_cast(event); - QFocusEvent *focusEvent = static_cast(event); + QKeyEvent *keyEvent = static_cast(event); + QFocusEvent *focusEvent = static_cast(event); - if (obj == lineEdit_ChatInput && lineEdit_ChatInput->text() != "" && event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Tab) { - myChat->nickAutoCompletition(); - return true; - } - else if (obj == lineEdit_searchForPlayers && focusEvent->gotFocus() && lineEdit_searchForPlayers->text() == tr("search for player ...")) { - lineEdit_searchForPlayers->clear(); - return QDialog::eventFilter(obj, event); - } - else { - // pass the event on to the parent class - return QDialog::eventFilter(obj, event); - } + if (obj == lineEdit_ChatInput && lineEdit_ChatInput->text() != "" && event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Tab) { + myChat->nickAutoCompletition(); + return true; + } else if (obj == lineEdit_searchForPlayers && focusEvent->gotFocus() && lineEdit_searchForPlayers->text() == tr("search for player ...")) { + lineEdit_searchForPlayers->clear(); + return QDialog::eventFilter(obj, event); + } else { + // pass the event on to the parent class + return QDialog::eventFilter(obj, event); + } } -bool gameLobbyDialogImpl::event ( QEvent * event ) { +bool gameLobbyDialogImpl::event ( QEvent * event ) +{ - return QDialog::event(event); + return QDialog::event(event); } -void gameLobbyDialogImpl::showGameDescription(bool show) { +void gameLobbyDialogImpl::showGameDescription(bool show) +{ - if(show) { - label_gameType->show(); - label_gameDesc2->show(); - label_gameDesc3->show(); - label_gameDesc4->show(); - label_gameDesc5->show(); - label_gameDesc6->show(); - label_gameDesc7->show(); - } - else { - label_gameType->hide(); - label_gameDesc2->hide(); - label_gameDesc3->hide(); - label_gameDesc4->hide(); - label_gameDesc5->hide(); - label_gameDesc6->hide(); - label_gameDesc7->hide(); - } + if(show) { + label_gameType->show(); + label_gameDesc2->show(); + label_gameDesc3->show(); + label_gameDesc4->show(); + label_gameDesc5->show(); + label_gameDesc6->show(); + label_gameDesc7->show(); + } else { + label_gameType->hide(); + label_gameDesc2->hide(); + label_gameDesc3->hide(); + label_gameDesc4->hide(); + label_gameDesc5->hide(); + label_gameDesc6->hide(); + label_gameDesc7->hide(); + } } -void gameLobbyDialogImpl::showWaitStartGameMsgBox() { +void gameLobbyDialogImpl::showWaitStartGameMsgBox() +{ - if(this->isVisible()) { - waitStartGameMsgBox->show(); - waitStartGameMsgBox->raise(); - waitStartGameMsgBox->activateWindow(); - } + if(this->isVisible()) { + waitStartGameMsgBox->show(); + waitStartGameMsgBox->raise(); + waitStartGameMsgBox->activateWindow(); + } } -void gameLobbyDialogImpl::joinAnyGameButtonRefresh() { +void gameLobbyDialogImpl::joinAnyGameButtonRefresh() +{ - int openNonPrivateNonFullGamesCounter = 0; + int openNonPrivateNonFullGamesCounter = 0; - int it = 0; - while (myGameListModel->item(it)) { + int it = 0; + while (myGameListModel->item(it)) { - int players = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",0,0).toInt(); - int maxPlayers = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",1,1).toInt(); - if (myGameListModel->item(it, 2)->data(16) == "open" && myGameListModel->item(it, 4)->data(16) == "nonpriv" && players < maxPlayers) { - openNonPrivateNonFullGamesCounter++; - } - ++it; - } + int players = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",0,0).toInt(); + int maxPlayers = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",1,1).toInt(); + if (myGameListModel->item(it, 2)->data(16) == "open" && myGameListModel->item(it, 4)->data(16) == "nonpriv" && players < maxPlayers) { + openNonPrivateNonFullGamesCounter++; + } + ++it; + } - if(openNonPrivateNonFullGamesCounter) pushButton_joinAnyGame->setEnabled(TRUE); - else pushButton_joinAnyGame->setEnabled(FALSE); + if(openNonPrivateNonFullGamesCounter) pushButton_joinAnyGame->setEnabled(TRUE); + else pushButton_joinAnyGame->setEnabled(FALSE); } void gameLobbyDialogImpl::reject() { - myStartWindow->show(); - QDialog::reject(); + myStartWindow->show(); + QDialog::reject(); } void gameLobbyDialogImpl::closeEvent(QCloseEvent *event) { - event->accept(); - //stop waitStartGameMsgBox - waitStartGameMsgBoxTimer->stop(); - waitStartGameMsgBox->hide(); + event->accept(); + //stop waitStartGameMsgBox + waitStartGameMsgBoxTimer->stop(); + waitStartGameMsgBox->hide(); } void gameLobbyDialogImpl::writeDialogSettings(int saveMode) { - switch(saveMode) { - case 0: { - QHeaderView *header = treeView_GameList->header(); - myConfig->writeConfigInt("DlgGameLobbyGameListSortingSection", header->sortIndicatorSection()); - myConfig->writeConfigInt("DlgGameLobbyGameListSortingOrder", header->sortIndicatorOrder()); - } - break; - case 1: { - myConfig->writeConfigInt("DlgGameLobbyGameListFilterIndex", comboBox_gameListFilter->currentIndex()); - } - break; - case 2: { - myConfig->writeConfigInt("DlgGameLobbyNickListSortFilterIndex", comboBox_nickListFilter->currentIndex()); - } - break; - default:; - } + switch(saveMode) { + case 0: { + QHeaderView *header = treeView_GameList->header(); + myConfig->writeConfigInt("DlgGameLobbyGameListSortingSection", header->sortIndicatorSection()); + myConfig->writeConfigInt("DlgGameLobbyGameListSortingOrder", header->sortIndicatorOrder()); + } + break; + case 1: { + myConfig->writeConfigInt("DlgGameLobbyGameListFilterIndex", comboBox_gameListFilter->currentIndex()); + } + break; + case 2: { + myConfig->writeConfigInt("DlgGameLobbyNickListSortFilterIndex", comboBox_nickListFilter->currentIndex()); + } + break; + default: + ; + } - myConfig->writeBuffer(); + myConfig->writeBuffer(); } void gameLobbyDialogImpl::readDialogSettings() { - comboBox_gameListFilter->setCurrentIndex(myConfig->readConfigInt("DlgGameLobbyGameListFilterIndex")); - treeView_GameList->sortByColumn(myConfig->readConfigInt("DlgGameLobbyGameListSortingSection"), (Qt::SortOrder)myConfig->readConfigInt("DlgGameLobbyGameListSortingOrder") ); - comboBox_nickListFilter->setCurrentIndex(myConfig->readConfigInt("DlgGameLobbyNickListSortFilterIndex")); + comboBox_gameListFilter->setCurrentIndex(myConfig->readConfigInt("DlgGameLobbyGameListFilterIndex")); + treeView_GameList->sortByColumn(myConfig->readConfigInt("DlgGameLobbyGameListSortingSection"), (Qt::SortOrder)myConfig->readConfigInt("DlgGameLobbyGameListSortingOrder") ); + comboBox_nickListFilter->setCurrentIndex(myConfig->readConfigInt("DlgGameLobbyNickListSortFilterIndex")); } -void gameLobbyDialogImpl::changeGameListFilter(int index) { +void gameLobbyDialogImpl::changeGameListFilter(int index) +{ - switch(index) { - case 0: { - myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp()); - myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp()); - myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); - myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp()); - } - break; - case 1: { - myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp()); - myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); - myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); - myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp()); - } - break; - case 2: { - myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); - myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); - myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); - myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp()); - } - break; - case 3: { - myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); - myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); - myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); - myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp("nonpriv", Qt::CaseInsensitive, QRegExp::FixedString)); - } - break; - case 4: { - myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); - myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); - myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); - myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp("private", Qt::CaseInsensitive, QRegExp::FixedString)); - } - break; - default:; - } - myGameListSortFilterProxyModel->setFilterRegExp(QString()); - myGameListSortFilterProxyModel->setFilterKeyColumn(0); + switch(index) { + case 0: { + myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp()); + myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp()); + myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); + myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp()); + } + break; + case 1: { + myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp()); + myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); + myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); + myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp()); + } + break; + case 2: { + myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); + myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); + myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); + myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp()); + } + break; + case 3: { + myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); + myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); + myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); + myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp("nonpriv", Qt::CaseInsensitive, QRegExp::FixedString)); + } + break; + case 4: { + myGameListSortFilterProxyModel->setColumn1RegExp(QRegExp("nonfull", Qt::CaseInsensitive, QRegExp::FixedString)); + myGameListSortFilterProxyModel->setColumn2RegExp(QRegExp("open", Qt::CaseInsensitive, QRegExp::FixedString)); + myGameListSortFilterProxyModel->setColumn3RegExp(QRegExp()); + myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp("private", Qt::CaseInsensitive, QRegExp::FixedString)); + } + break; + default: + ; + } + myGameListSortFilterProxyModel->setFilterRegExp(QString()); + myGameListSortFilterProxyModel->setFilterKeyColumn(0); - writeDialogSettings(1); + writeDialogSettings(1); - if(index) treeView_GameList->setStyleSheet("QTreeView { border-radius: 4px; border: 2px solid blue; background-color: white; background-image: url(\""+myAppDataPath +"gfx/gui/misc/background_gamelist.png\"); background-attachment: fixed; background-position: top center ; background-repeat: no-repeat;}"); - else treeView_GameList->setStyleSheet("QTreeView { background-color: white; background-image: url(\""+myAppDataPath +"gfx/gui/misc/background_gamelist.png\"); background-attachment: fixed; background-position: top center ; background-repeat: no-repeat;}"); + if(index) treeView_GameList->setStyleSheet("QTreeView { border-radius: 4px; border: 2px solid blue; background-color: white; background-image: url(\""+myAppDataPath +"gfx/gui/misc/background_gamelist.png\"); background-attachment: fixed; background-position: top center ; background-repeat: no-repeat;}"); + else treeView_GameList->setStyleSheet("QTreeView { background-color: white; background-image: url(\""+myAppDataPath +"gfx/gui/misc/background_gamelist.png\"); background-attachment: fixed; background-position: top center ; background-repeat: no-repeat;}"); } void gameLobbyDialogImpl::changeNickListFilter(int state) { - myNickListSortFilterProxyModel->setFilterState(state); - myNickListModel->sort(0, Qt::DescendingOrder); + myNickListSortFilterProxyModel->setFilterState(state); + myNickListModel->sort(0, Qt::DescendingOrder); - myNickListSortFilterProxyModel->setFilterRegExp(QString()); - myNickListSortFilterProxyModel->setFilterKeyColumn(0); + myNickListSortFilterProxyModel->setFilterRegExp(QString()); + myNickListSortFilterProxyModel->setFilterKeyColumn(0); - writeDialogSettings(2); + writeDialogSettings(2); } -void gameLobbyDialogImpl::changeGameListSorting() { +void gameLobbyDialogImpl::changeGameListSorting() +{ - writeDialogSettings(0); + writeDialogSettings(0); } void gameLobbyDialogImpl::registeredUserMode() { - lineEdit_ChatInput->clear(); - lineEdit_ChatInput->setEnabled(true); - guestMode = false; + lineEdit_ChatInput->clear(); + lineEdit_ChatInput->setEnabled(true); + guestMode = false; } void gameLobbyDialogImpl::guestUserMode() { - lineEdit_ChatInput->setText(tr("Chat is only available to registered players.")); - lineEdit_ChatInput->setDisabled(true); - guestMode = true; + lineEdit_ChatInput->setText(tr("Chat is only available to registered players.")); + lineEdit_ChatInput->setDisabled(true); + guestMode = true; } void gameLobbyDialogImpl::showNickListContextMenu(QPoint p) { - if(myNickListModel->rowCount() && myNickListSelectionModel->currentIndex().isValid()) { + if(myNickListModel->rowCount() && myNickListSelectionModel->currentIndex().isValid()) { - assert(mySession); + assert(mySession); unsigned playerUid = myNickListSelectionModel->currentIndex().data(Qt::UserRole).toUInt(); - if(inGame && mySession->getClientGameInfo(mySession->getClientCurrentGameId()).data.gameType == GAME_TYPE_INVITE_ONLY && playerUid != mySession->getClientUniquePlayerId() && !mySession->getClientPlayerInfo(playerUid).isGuest) { + if(inGame && mySession->getClientGameInfo(mySession->getClientCurrentGameId()).data.gameType == GAME_TYPE_INVITE_ONLY && playerUid != mySession->getClientUniquePlayerId() && !mySession->getClientPlayerInfo(playerUid).isGuest) { - nickListInviteAction->setEnabled(true); - nickListInviteAction->setText(tr("Invite %1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str()))); + nickListInviteAction->setEnabled(true); + nickListInviteAction->setText(tr("Invite %1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str()))); - } - else { - nickListInviteAction->setText(tr("Invite player ...")); - nickListInviteAction->setEnabled(false); - } + } else { + nickListInviteAction->setText(tr("Invite player ...")); + nickListInviteAction->setEnabled(false); + } - if(playerUid != mySession->getClientUniquePlayerId() && !mySession->getClientPlayerInfo(playerUid).isGuest) { + if(playerUid != mySession->getClientUniquePlayerId() && !mySession->getClientPlayerInfo(playerUid).isGuest) { - nickListIgnorePlayerAction->setEnabled(true); - nickListIgnorePlayerAction->setText(tr("Ignore %1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str()))); - } - else { + nickListIgnorePlayerAction->setEnabled(true); + nickListIgnorePlayerAction->setText(tr("Ignore %1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str()))); + } else { - nickListIgnorePlayerAction->setEnabled(false); - nickListIgnorePlayerAction->setText(tr("Ignore player ...")); - } + nickListIgnorePlayerAction->setEnabled(false); + nickListIgnorePlayerAction->setText(tr("Ignore player ...")); + } - unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerUid); - QString playerInGameInfoString; - if(gameIdOfPlayer) { - playerInGameInfoString = tr("%1 is playing in \"%2\".").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str())).arg(QString::fromUtf8(mySession->getClientGameInfo(gameIdOfPlayer).name.c_str())); - } - else { - playerInGameInfoString = tr("%1 is not playing at the moment.").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str())); - } - nickListPlayerInGameInfo->setText(playerInGameInfoString); + unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerUid); + QString playerInGameInfoString; + if(gameIdOfPlayer) { + playerInGameInfoString = tr("%1 is playing in \"%2\".").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str())).arg(QString::fromUtf8(mySession->getClientGameInfo(gameIdOfPlayer).name.c_str())); + } else { + playerInGameInfoString = tr("%1 is not playing at the moment.").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str())); + } + nickListPlayerInGameInfo->setText(playerInGameInfoString); - //popup a little more to the right to avaoid double click action - QPoint tempPoint = p; - tempPoint.setX(p.x()+5); - nickListContextMenu->popup(treeView_NickList->mapToGlobal(tempPoint)); - } + //popup a little more to the right to avaoid double click action + QPoint tempPoint = p; + tempPoint.setX(p.x()+5); + nickListContextMenu->popup(treeView_NickList->mapToGlobal(tempPoint)); + } } void gameLobbyDialogImpl::invitePlayerToCurrentGame() { - if(myNickListSelectionModel->currentIndex().isValid()) { - mySession->invitePlayerToCurrentGame(myNickListSelectionModel->currentIndex().data(Qt::UserRole).toUInt()); - } + if(myNickListSelectionModel->currentIndex().isValid()) { + mySession->invitePlayerToCurrentGame(myNickListSelectionModel->currentIndex().data(Qt::UserRole).toUInt()); + } } void gameLobbyDialogImpl::showInfoMsgBox() { - switch(infoMsgToShowId) { - case 2: { - myMessageDialogImpl dialog(myConfig, this); - dialog.exec(2, tr("You have entered a game with type \"invite-only\".\nFeel free to invite other players by right-clicking on their nick in the available players list."), tr("PokerTH - Info Message"), QPixmap(":/gfx/ktip.png"), QDialogButtonBox::Ok, true); - } - break; - default:; - break; - } + switch(infoMsgToShowId) { + case 2: { + myMessageDialogImpl dialog(myConfig, this); + dialog.exec(2, tr("You have entered a game with type \"invite-only\".\nFeel free to invite other players by right-clicking on their nick in the available players list."), tr("PokerTH - Info Message"), QPixmap(":/gfx/ktip.png"), QDialogButtonBox::Ok, true); + } + break; + default: + ; + break; + } } void gameLobbyDialogImpl::showInvitationDialog(unsigned gameId, unsigned playerIdFrom) { - if(inviteDialogIsCurrentlyShown || playerIsOnIgnoreList(playerIdFrom)) { + if(inviteDialogIsCurrentlyShown || playerIsOnIgnoreList(playerIdFrom)) { - mySession->rejectGameInvitation(gameId, DENY_GAME_INVITATION_BUSY); - } - else { + mySession->rejectGameInvitation(gameId, DENY_GAME_INVITATION_BUSY); + } else { - inviteDialogIsCurrentlyShown = true; + inviteDialogIsCurrentlyShown = true; - myMessageDialogImpl dialog(myConfig, this); - if(dialog.exec(3, tr("You have been invited to the game %1 by %2.
Would you like to join this game?").arg(QString::fromUtf8(mySession->getClientGameInfo(gameId).name.c_str())).arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdFrom).playerName.c_str())), tr("PokerTH - Info Message"), QPixmap(":/gfx/list_add_user_64.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, false)) { + myMessageDialogImpl dialog(myConfig, this); + if(dialog.exec(3, tr("You have been invited to the game %1 by %2.
Would you like to join this game?").arg(QString::fromUtf8(mySession->getClientGameInfo(gameId).name.c_str())).arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdFrom).playerName.c_str())), tr("PokerTH - Info Message"), QPixmap(":/gfx/list_add_user_64.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, false)) { - mySession->acceptGameInvitation(gameId); - inviteDialogIsCurrentlyShown = false; - } - else { - mySession->rejectGameInvitation(gameId, DENY_GAME_INVITATION_NO); - inviteDialogIsCurrentlyShown = false; - } - } + mySession->acceptGameInvitation(gameId); + inviteDialogIsCurrentlyShown = false; + } else { + mySession->rejectGameInvitation(gameId, DENY_GAME_INVITATION_NO); + inviteDialogIsCurrentlyShown = false; + } + } } void gameLobbyDialogImpl::chatInfoPlayerInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom) { - textBrowser_ChatDisplay->append(tr("%1 has been invited to %2 by %3.").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdWho).playerName.c_str())).arg(QString::fromUtf8(mySession->getClientGameInfo(gameId).name.c_str())).arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdFrom).playerName.c_str()))); + textBrowser_ChatDisplay->append(tr("%1 has been invited to %2 by %3.").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdWho).playerName.c_str())).arg(QString::fromUtf8(mySession->getClientGameInfo(gameId).name.c_str())).arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdFrom).playerName.c_str()))); } void gameLobbyDialogImpl::chatInfoPlayerRejectedInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason) { - QString string; - if(reason == DENY_GAME_INVITATION_NO) string = tr("%1 has rejected the invitation to %2."); + QString string; + if(reason == DENY_GAME_INVITATION_NO) string = tr("%1 has rejected the invitation to %2."); - if(reason == DENY_GAME_INVITATION_BUSY) string = tr("%1 cannot join %2 because he is busy."); + if(reason == DENY_GAME_INVITATION_BUSY) string = tr("%1 cannot join %2 because he is busy."); - textBrowser_ChatDisplay->append(string.arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdWho).playerName.c_str())).arg(QString::fromUtf8(mySession->getClientGameInfo(gameId).name.c_str()))); + textBrowser_ChatDisplay->append(string.arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerIdWho).playerName.c_str())).arg(QString::fromUtf8(mySession->getClientGameInfo(gameId).name.c_str()))); } -bool gameLobbyDialogImpl::playerIsOnIgnoreList(unsigned playerId) { +bool gameLobbyDialogImpl::playerIsOnIgnoreList(unsigned playerId) +{ - list playerIgnoreList = myConfig->readConfigStringList("PlayerIgnoreList"); - list::iterator it1; + list playerIgnoreList = myConfig->readConfigStringList("PlayerIgnoreList"); + list::iterator it1; for(it1= playerIgnoreList.begin(); it1 != playerIgnoreList.end(); ++it1) { - if(QString::fromUtf8(mySession->getClientPlayerInfo(playerId).playerName.c_str()) == QString::fromUtf8(it1->c_str())) { - return true; - } - } - return false; + if(QString::fromUtf8(mySession->getClientPlayerInfo(playerId).playerName.c_str()) == QString::fromUtf8(it1->c_str())) { + return true; + } + } + return false; } -void gameLobbyDialogImpl::putPlayerOnIgnoreList() { +void gameLobbyDialogImpl::putPlayerOnIgnoreList() +{ - if(myNickListSelectionModel->currentIndex().isValid()) { + if(myNickListSelectionModel->currentIndex().isValid()) { - unsigned playerId = myNickListSelectionModel->currentIndex().data(Qt::UserRole).toUInt(); + unsigned playerId = myNickListSelectionModel->currentIndex().data(Qt::UserRole).toUInt(); - if(!playerIsOnIgnoreList(playerId)) { + if(!playerIsOnIgnoreList(playerId)) { - myMessageDialogImpl dialog(myConfig, this); - if(dialog.exec(4, tr("You will no longer receive chat messages or game invitations from this user.
Do you really want to put player %1 on your ignore list?").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerId).playerName.c_str())), tr("PokerTH - Question"), QPixmap(":/gfx/im-ban-user_64.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, false ) == QDialog::Accepted) { + myMessageDialogImpl dialog(myConfig, this); + if(dialog.exec(4, tr("You will no longer receive chat messages or game invitations from this user.
Do you really want to put player %1 on your ignore list?").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerId).playerName.c_str())), tr("PokerTH - Question"), QPixmap(":/gfx/im-ban-user_64.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, false ) == QDialog::Accepted) { - list playerIgnoreList = myConfig->readConfigStringList("PlayerIgnoreList"); - playerIgnoreList.push_back(QString("%1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerId).playerName.c_str())).toUtf8().constData()); - myConfig->writeConfigStringList("PlayerIgnoreList", playerIgnoreList); - myConfig->writeBuffer(); + list playerIgnoreList = myConfig->readConfigStringList("PlayerIgnoreList"); + playerIgnoreList.push_back(QString("%1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerId).playerName.c_str())).toUtf8().constData()); + myConfig->writeConfigStringList("PlayerIgnoreList", playerIgnoreList); + myConfig->writeBuffer(); - myChat->refreshIgnoreList(); - } - } - } + myChat->refreshIgnoreList(); + } + } + } } void gameLobbyDialogImpl::searchForPlayerRegExpChanged() { - QRegExp regExp(lineEdit_searchForPlayers->text(), Qt::CaseInsensitive); - myNickListSortFilterProxyModel->setFilterRegExp(regExp); + QRegExp regExp(lineEdit_searchForPlayers->text(), Qt::CaseInsensitive); + myNickListSortFilterProxyModel->setFilterRegExp(regExp); } void gameLobbyDialogImpl::showAutoStartTimer() { - autoStartTimerOverlay->show(); - autoStartTimerOverlay->setGeometry(((scrollArea_gameInfos->geometry().width()-190)/2), ((scrollArea_gameInfos->geometry().height()-50)/2), 190, 50); + autoStartTimerOverlay->show(); + autoStartTimerOverlay->setGeometry(((scrollArea_gameInfos->geometry().width()-190)/2), ((scrollArea_gameInfos->geometry().height()-50)/2), 190, 50); - QString string(tr("The game will start in
%1 seconds.").arg(6)); - autoStartTimerOverlay->setText(""+string+""); - autoStartTimerCounter = 6; - autoStartTimer->start(1000); + QString string(tr("The game will start in
%1 seconds.").arg(6)); + autoStartTimerOverlay->setText(""+string+""); + autoStartTimerCounter = 6; + autoStartTimer->start(1000); } void gameLobbyDialogImpl::updateAutoStartTimer() { - --autoStartTimerCounter; - if(autoStartTimerCounter) { - QString string(tr("The game will start in
%1 seconds.").arg(autoStartTimerCounter)); - autoStartTimerOverlay->setText(""+string+""); - } - else { - autoStartTimer->stop(); - autoStartTimerOverlay->hide(); - } + --autoStartTimerCounter; + if(autoStartTimerCounter) { + QString string(tr("The game will start in
%1 seconds.").arg(autoStartTimerCounter)); + autoStartTimerOverlay->setText(""+string+""); + } else { + autoStartTimer->stop(); + autoStartTimerOverlay->hide(); + } } diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h index bfcbbd20..1060ce4f 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.h @@ -1,7 +1,7 @@ // // C++ Interface: gamelobbydialogimpl // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -35,134 +35,148 @@ class MyNickListSortFilterProxyModel; @author FThauer FHammer */ -class gameLobbyDialogImpl: public QDialog, public Ui::gameLobbyDialog { - Q_OBJECT +class gameLobbyDialogImpl: public QDialog, public Ui::gameLobbyDialog +{ + Q_OBJECT public: - gameLobbyDialogImpl(startWindowImpl *parent = 0, ConfigFile* = 0); + gameLobbyDialogImpl(startWindowImpl *parent = 0, ConfigFile* = 0); - ~gameLobbyDialogImpl(); + ~gameLobbyDialogImpl(); - void exec(); + void exec(); - ChatTools *getMyChat() { return myChat; } + ChatTools *getMyChat() { + return myChat; + } - void setSession(boost::shared_ptr session); - boost::shared_ptr getSession() { assert(mySession.get()); return mySession; } + void setSession(boost::shared_ptr session); + boost::shared_ptr getSession() { + assert(mySession.get()); + return mySession; + } - void setMyW ( gameTableImpl* theValue ) { myW = theValue; } + void setMyW ( gameTableImpl* theValue ) { + myW = theValue; + } public slots: - void createGame(); - void joinGame(); - void joinAnyGame(); - void gameSelected(const QModelIndex &); - void updateGameItem(QList , unsigned gameId); - void addGame(unsigned gameId); - void updateGameMode(unsigned gameId, int newMode); - void updateGameAdmin(unsigned gameId, unsigned adminPlayerId); - void removeGame(unsigned gameId); - void gameAddPlayer(unsigned gameId, unsigned playerId); - void gameRemovePlayer(unsigned gameId, unsigned playerId); - void playerJoinedLobby(unsigned playerId, QString playerName); - void playerLeftLobby(unsigned playerId); - void updateStats(ServerStats stats); - void refreshGameStats(); - void refreshPlayerStats(); - void setCurrentGameName ( const QString& theValue ) { currentGameName = theValue; } - QString getCurrentGameName() const { return currentGameName; } - gameTableImpl* getMyW() const { return myW; } - void checkPlayerQuantity(); - void blinkingStartButtonAnimation(); - void joinedNetworkGame(unsigned, QString, bool); - void addConnectedPlayer(unsigned, QString, bool); - void updatePlayer(unsigned, QString); - void removePlayer(unsigned, QString); - void newGameAdmin(unsigned, QString); - void refreshConnectedPlayerAvatars(); - void playerSelected(QTreeWidgetItem*, QTreeWidgetItem*); - void refresh(int actionID); - void removedFromGame(int reason); - void startGame(); - void leaveGame(); - void kickPlayer(); - void joinedGameDialogUpdate(); - void leftGameDialogUpdate(); - void updateDialogBlinds(const GameData &gameData); - void clearDialog(); - void keyPressEvent(QKeyEvent * keyEvent); - bool event(QEvent * event); - void showGameDescription(bool show); - void showWaitStartGameMsgBox(); - void joinAnyGameButtonRefresh(); - void reject(); - void closeEvent(QCloseEvent *event); - void writeDialogSettings(int); - void readDialogSettings(); - void changeGameListFilter(int); - void changeNickListFilter(int); - void changeGameListSorting(); - void registeredUserMode(); - void guestUserMode(); - void showNickListContextMenu(QPoint); - void invitePlayerToCurrentGame(); - void showInfoMsgBox(); - void showInvitationDialog(unsigned gameId, unsigned playerIdFrom); - void chatInfoPlayerInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); - void chatInfoPlayerRejectedInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); - void putPlayerOnIgnoreList(); - bool playerIsOnIgnoreList(unsigned playerid); - void searchForPlayerRegExpChanged(); - void showAutoStartTimer(); - void updateAutoStartTimer(); + void createGame(); + void joinGame(); + void joinAnyGame(); + void gameSelected(const QModelIndex &); + void updateGameItem(QList , unsigned gameId); + void addGame(unsigned gameId); + void updateGameMode(unsigned gameId, int newMode); + void updateGameAdmin(unsigned gameId, unsigned adminPlayerId); + void removeGame(unsigned gameId); + void gameAddPlayer(unsigned gameId, unsigned playerId); + void gameRemovePlayer(unsigned gameId, unsigned playerId); + void playerJoinedLobby(unsigned playerId, QString playerName); + void playerLeftLobby(unsigned playerId); + void updateStats(ServerStats stats); + void refreshGameStats(); + void refreshPlayerStats(); + void setCurrentGameName ( const QString& theValue ) { + currentGameName = theValue; + } + QString getCurrentGameName() const { + return currentGameName; + } + gameTableImpl* getMyW() const { + return myW; + } + void checkPlayerQuantity(); + void blinkingStartButtonAnimation(); + void joinedNetworkGame(unsigned, QString, bool); + void addConnectedPlayer(unsigned, QString, bool); + void updatePlayer(unsigned, QString); + void removePlayer(unsigned, QString); + void newGameAdmin(unsigned, QString); + void refreshConnectedPlayerAvatars(); + void playerSelected(QTreeWidgetItem*, QTreeWidgetItem*); + void refresh(int actionID); + void removedFromGame(int reason); + void startGame(); + void leaveGame(); + void kickPlayer(); + void joinedGameDialogUpdate(); + void leftGameDialogUpdate(); + void updateDialogBlinds(const GameData &gameData); + void clearDialog(); + void keyPressEvent(QKeyEvent * keyEvent); + bool event(QEvent * event); + void showGameDescription(bool show); + void showWaitStartGameMsgBox(); + void joinAnyGameButtonRefresh(); + void reject(); + void closeEvent(QCloseEvent *event); + void writeDialogSettings(int); + void readDialogSettings(); + void changeGameListFilter(int); + void changeNickListFilter(int); + void changeGameListSorting(); + void registeredUserMode(); + void guestUserMode(); + void showNickListContextMenu(QPoint); + void invitePlayerToCurrentGame(); + void showInfoMsgBox(); + void showInvitationDialog(unsigned gameId, unsigned playerIdFrom); + void chatInfoPlayerInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); + void chatInfoPlayerRejectedInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); + void putPlayerOnIgnoreList(); + bool playerIsOnIgnoreList(unsigned playerid); + void searchForPlayerRegExpChanged(); + void showAutoStartTimer(); + void updateAutoStartTimer(); private: - gameTableImpl* myW; - startWindowImpl* myStartWindow; - ConfigFile *myConfig; - boost::shared_ptr mySession; - createInternetGameDialogImpl *myCreateInternetGameDialog; - QString currentGameName; - unsigned myPlayerId; - bool isGameAdministrator; - bool inGame; - bool guestMode; + gameTableImpl* myW; + startWindowImpl* myStartWindow; + ConfigFile *myConfig; + boost::shared_ptr mySession; + createInternetGameDialogImpl *myCreateInternetGameDialog; + QString currentGameName; + unsigned myPlayerId; + bool isGameAdministrator; + bool inGame; + bool guestMode; - QString myAppDataPath; - QMessageBox *waitStartGameMsgBox; - QTimer *waitStartGameMsgBoxTimer; - QTimer *blinkingButtonAnimationTimer; - QTimer *showInfoMsgBoxTimer; - QTimer *autoStartTimer; - bool blinkingButtonAnimationState; - QColor defaultStartButtonColor; - QColor defaultStartButtonTextColor; - QColor disabledStartButtonColor; - QColor disabledStartButtonTextColor; - ChatTools *myChat; - int keyUpCounter; - QStandardItemModel *myGameListModel; - QItemSelectionModel *myGameListSelectionModel; - MyGameListSortFilterProxyModel *myGameListSortFilterProxyModel; - QMenu *nickListContextMenu; - QAction *nickListInviteAction; - QAction *nickListIgnorePlayerAction; - QMenu *nickListPlayerInfoSubMenu; - QAction *nickListPlayerInGameInfo; - int infoMsgToShowId; - int currentInvitationGameId; - bool inviteDialogIsCurrentlyShown; + QString myAppDataPath; + QMessageBox *waitStartGameMsgBox; + QTimer *waitStartGameMsgBoxTimer; + QTimer *blinkingButtonAnimationTimer; + QTimer *showInfoMsgBoxTimer; + QTimer *autoStartTimer; + bool blinkingButtonAnimationState; + QColor defaultStartButtonColor; + QColor defaultStartButtonTextColor; + QColor disabledStartButtonColor; + QColor disabledStartButtonTextColor; + ChatTools *myChat; + int keyUpCounter; + QStandardItemModel *myGameListModel; + QItemSelectionModel *myGameListSelectionModel; + MyGameListSortFilterProxyModel *myGameListSortFilterProxyModel; + QMenu *nickListContextMenu; + QAction *nickListInviteAction; + QAction *nickListIgnorePlayerAction; + QMenu *nickListPlayerInfoSubMenu; + QAction *nickListPlayerInGameInfo; + int infoMsgToShowId; + int currentInvitationGameId; + bool inviteDialogIsCurrentlyShown; - QStandardItemModel *myNickListModel; - QItemSelectionModel *myNickListSelectionModel; - MyNickListSortFilterProxyModel *myNickListSortFilterProxyModel; + QStandardItemModel *myNickListModel; + QItemSelectionModel *myNickListSelectionModel; + MyNickListSortFilterProxyModel *myNickListSortFilterProxyModel; - QLabel *autoStartTimerOverlay; - int autoStartTimerCounter; + QLabel *autoStartTimerOverlay; + int autoStartTimerCounter; protected: - bool eventFilter(QObject *obj, QEvent *event); + bool eventFilter(QObject *obj, QEvent *event); }; diff --git a/src/gui/qt/gamelobbydialog/mygamelistsortfilterproxymodel.cpp b/src/gui/qt/gamelobbydialog/mygamelistsortfilterproxymodel.cpp index b23b1463..bd52d861 100644 --- a/src/gui/qt/gamelobbydialog/mygamelistsortfilterproxymodel.cpp +++ b/src/gui/qt/gamelobbydialog/mygamelistsortfilterproxymodel.cpp @@ -3,21 +3,22 @@ #include MyGameListSortFilterProxyModel::MyGameListSortFilterProxyModel(QObject *parent) - : QSortFilterProxyModel(parent) + : QSortFilterProxyModel(parent) { } -bool MyGameListSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { +bool MyGameListSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const +{ QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent); QModelIndex index1 = sourceModel()->index(sourceRow, 1, sourceParent); QModelIndex index2 = sourceModel()->index(sourceRow, 2, sourceParent); QModelIndex index3 = sourceModel()->index(sourceRow, 3, sourceParent); - QModelIndex index4 = sourceModel()->index(sourceRow, 4, sourceParent); + QModelIndex index4 = sourceModel()->index(sourceRow, 4, sourceParent); - return ((sourceModel()->data(index1, 16).toString().contains(column1RegExp) - && sourceModel()->data(index2, 16).toString().contains(column2RegExp) - && sourceModel()->data(index3, 16).toString().contains(column3RegExp) - && sourceModel()->data(index4, 16).toString().contains(column4RegExp)) || sourceModel()->data(index0, 16) == "MeInThisGame"); + return ((sourceModel()->data(index1, 16).toString().contains(column1RegExp) + && sourceModel()->data(index2, 16).toString().contains(column2RegExp) + && sourceModel()->data(index3, 16).toString().contains(column3RegExp) + && sourceModel()->data(index4, 16).toString().contains(column4RegExp)) || sourceModel()->data(index0, 16) == "MeInThisGame"); } diff --git a/src/gui/qt/gamelobbydialog/mygamelistsortfilterproxymodel.h b/src/gui/qt/gamelobbydialog/mygamelistsortfilterproxymodel.h index f1f2c34c..dc51debf 100644 --- a/src/gui/qt/gamelobbydialog/mygamelistsortfilterproxymodel.h +++ b/src/gui/qt/gamelobbydialog/mygamelistsortfilterproxymodel.h @@ -4,24 +4,32 @@ #include class MyGameListSortFilterProxyModel : public QSortFilterProxyModel -{ -Q_OBJECT +{ + Q_OBJECT - public: - MyGameListSortFilterProxyModel(QObject *parent = 0); - void setColumn1RegExp(QRegExp column1) { column1RegExp = column1; } - void setColumn2RegExp(QRegExp column2) { column2RegExp = column2; } - void setColumn3RegExp(QRegExp column3) { column3RegExp = column3; } - void setColumn4RegExp(QRegExp column4) { column4RegExp = column4; } - - protected: - bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; +public: + MyGameListSortFilterProxyModel(QObject *parent = 0); + void setColumn1RegExp(QRegExp column1) { + column1RegExp = column1; + } + void setColumn2RegExp(QRegExp column2) { + column2RegExp = column2; + } + void setColumn3RegExp(QRegExp column3) { + column3RegExp = column3; + } + void setColumn4RegExp(QRegExp column4) { + column4RegExp = column4; + } - private: - QRegExp column1RegExp; - QRegExp column2RegExp; - QRegExp column3RegExp; - QRegExp column4RegExp; +protected: + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + +private: + QRegExp column1RegExp; + QRegExp column2RegExp; + QRegExp column3RegExp; + QRegExp column4RegExp; }; diff --git a/src/gui/qt/gamelobbydialog/mygamelisttreewidget.cpp b/src/gui/qt/gamelobbydialog/mygamelisttreewidget.cpp index 0e2a2d09..69a63b9f 100644 --- a/src/gui/qt/gamelobbydialog/mygamelisttreewidget.cpp +++ b/src/gui/qt/gamelobbydialog/mygamelisttreewidget.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -16,9 +16,9 @@ using namespace std; MyGameListTreeWidget::MyGameListTreeWidget(QDialog* parent) - : QTreeWidget(parent) + : QTreeWidget(parent) { - + //set the pixmap cache size in the main function only one time QPixmapCache::setCacheLimit(1024); } @@ -28,13 +28,14 @@ MyGameListTreeWidget::~MyGameListTreeWidget() { } -void MyGameListTreeWidget::setGameListBackgroundImage(QString pmString) { - +void MyGameListTreeWidget::setGameListBackgroundImage(QString pmString) +{ + gameListBGPixmap.load(pmString); } // void MyGameListTreeWidget::paintEvent(QPaintEvent *event) { -// +// // /* QPainter painter(viewport()); // QVector rects = event->region().rects(); // for (int i = 0; i < rects.count(); i++) { @@ -46,16 +47,17 @@ void MyGameListTreeWidget::setGameListBackgroundImage(QString pmString) { // } // painter.end(); // QTreeWidget::paintEvent(event);*/ -// +// // QPainter painter(viewport()); // painter.drawPixmap(50, 5, gameListBGPixmap); -// +// // QTreeWidget::paintEvent(event); // } -void MyGameListTreeWidget::scrollContentsBy ( int dx, int dy ) { +void MyGameListTreeWidget::scrollContentsBy ( int dx, int dy ) +{ viewport()->update(); - + QTreeWidget::scrollContentsBy ( dx,dy ); } diff --git a/src/gui/qt/gamelobbydialog/mygamelisttreewidget.h b/src/gui/qt/gamelobbydialog/mygamelisttreewidget.h index 0a859a89..6b894054 100644 --- a/src/gui/qt/gamelobbydialog/mygamelisttreewidget.h +++ b/src/gui/qt/gamelobbydialog/mygamelisttreewidget.h @@ -1,7 +1,7 @@ // // C++ Interface: MyGameListTreeWidget // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -17,20 +17,20 @@ class MyGameListTreeWidget : public QTreeWidget { -Q_OBJECT + Q_OBJECT public: - MyGameListTreeWidget(QDialog*); + MyGameListTreeWidget(QDialog*); - ~MyGameListTreeWidget(); + ~MyGameListTreeWidget(); public slots: - + // void paintEvent(QPaintEvent *); void setGameListBackgroundImage(QString pmString); void scrollContentsBy ( int dx, int dy ); -private: +private: QPixmap gameListBGPixmap; diff --git a/src/gui/qt/gamelobbydialog/mynicklistsortfilterproxymodel.cpp b/src/gui/qt/gamelobbydialog/mynicklistsortfilterproxymodel.cpp index 5e83acae..daa60252 100644 --- a/src/gui/qt/gamelobbydialog/mynicklistsortfilterproxymodel.cpp +++ b/src/gui/qt/gamelobbydialog/mynicklistsortfilterproxymodel.cpp @@ -3,59 +3,59 @@ #include MyNickListSortFilterProxyModel::MyNickListSortFilterProxyModel(QObject *parent) - : QSortFilterProxyModel(parent), filterState(0) + : QSortFilterProxyModel(parent), filterState(0) { } bool MyNickListSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { - switch(filterState) { + switch(filterState) { - case 0: { - return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); - } - break; - case 1: { - return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); - } - break; - case 2: { - QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent); - return sourceModel()->data(index0, 34).toString().contains("idle") && QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); - } - break; + case 0: { + return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); + } + break; + case 1: { + return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); + } + break; + case 2: { + QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent); + return sourceModel()->data(index0, 34).toString().contains("idle") && QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); + } + break; - } + } - return false; + return false; } bool MyNickListSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { - switch(filterState) { + switch(filterState) { - case 0: { - return QSortFilterProxyModel::lessThan(left, right); - } - break; - case 1: { - QString leftCountryAndName(sourceModel()->data(left, 33).toString().toUpper()+sourceModel()->data(left, Qt::DisplayRole).toString().toLower()); - QString rightCountryAndName(sourceModel()->data(right, 33).toString().toUpper()+sourceModel()->data(right, Qt::DisplayRole).toString().toLower()); - return leftCountryAndName < rightCountryAndName; - } - break; - case 2: { - return QSortFilterProxyModel::lessThan(left, right); - } - break; - } + case 0: { + return QSortFilterProxyModel::lessThan(left, right); + } + break; + case 1: { + QString leftCountryAndName(sourceModel()->data(left, 33).toString().toUpper()+sourceModel()->data(left, Qt::DisplayRole).toString().toLower()); + QString rightCountryAndName(sourceModel()->data(right, 33).toString().toUpper()+sourceModel()->data(right, Qt::DisplayRole).toString().toLower()); + return leftCountryAndName < rightCountryAndName; + } + break; + case 2: { + return QSortFilterProxyModel::lessThan(left, right); + } + break; + } - return false; + return false; } void MyNickListSortFilterProxyModel::setFilterState(int state) { - filterState = state; + filterState = state; } diff --git a/src/gui/qt/gamelobbydialog/mynicklistsortfilterproxymodel.h b/src/gui/qt/gamelobbydialog/mynicklistsortfilterproxymodel.h index bdae0094..6c20ccb5 100644 --- a/src/gui/qt/gamelobbydialog/mynicklistsortfilterproxymodel.h +++ b/src/gui/qt/gamelobbydialog/mynicklistsortfilterproxymodel.h @@ -4,21 +4,21 @@ #include class MyNickListSortFilterProxyModel : public QSortFilterProxyModel -{ - Q_OBJECT +{ + Q_OBJECT public: - MyNickListSortFilterProxyModel(QObject *parent = 0); + MyNickListSortFilterProxyModel(QObject *parent = 0); - void setFilterState(int state); + void setFilterState(int state); protected: - bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; - bool lessThan(const QModelIndex &left, const QModelIndex &right) const; + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + bool lessThan(const QModelIndex &left, const QModelIndex &right) const; private: - int filterState; + int filterState; }; diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index 218c56af..dfe61a1d 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -58,198 +58,197 @@ using namespace std; gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) - : QMainWindow(parent), myChat(NULL), myConfig(c), gameSpeed(0), myActionIsBet(0), myActionIsRaise(0), pushButtonBetRaiseIsChecked(FALSE), pushButtonCallCheckIsChecked(FALSE), pushButtonFoldIsChecked(FALSE), pushButtonAllInIsChecked(FALSE), myButtonsAreCheckable(FALSE), breakAfterCurrentHand(FALSE), currentGameOver(FALSE), betSliderChangedByInput(FALSE), guestMode(FALSE), myLastPreActionBetValue(0) + : QMainWindow(parent), myChat(NULL), myConfig(c), gameSpeed(0), myActionIsBet(0), myActionIsRaise(0), pushButtonBetRaiseIsChecked(FALSE), pushButtonCallCheckIsChecked(FALSE), pushButtonFoldIsChecked(FALSE), pushButtonAllInIsChecked(FALSE), myButtonsAreCheckable(FALSE), breakAfterCurrentHand(FALSE), currentGameOver(FALSE), betSliderChangedByInput(FALSE), guestMode(FALSE), myLastPreActionBetValue(0) { - int i; + int i; - // this->setStyle(new QPlastiqueStyle); + // this->setStyle(new QPlastiqueStyle); - //for statistic development - for(i=0; i<15; i++) { - statisticArray[i] = 0; - } - //////////////////////////// + //for statistic development + for(i=0; i<15; i++) { + statisticArray[i] = 0; + } + //////////////////////////// - myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); + myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); - setupUi(this); + setupUi(this); - //Sound - mySDLPlayer = new SDLPlayer(myConfig); + //Sound + mySDLPlayer = new SDLPlayer(myConfig); - // Init game table style - myGameTableStyle = new GameTableStyleReader(myConfig, this); - myGameTableStyle->readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentGameTableStyle").c_str())); + // Init game table style + myGameTableStyle = new GameTableStyleReader(myConfig, this); + myGameTableStyle->readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentGameTableStyle").c_str())); - // Init card deck style - myCardDeckStyle = new CardDeckStyleReader(myConfig, this); - myCardDeckStyle->readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentCardDeckStyle").c_str())); + // Init card deck style + myCardDeckStyle = new CardDeckStyleReader(myConfig, this); + myCardDeckStyle->readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentCardDeckStyle").c_str())); - //Player0 pixmapCardsLabel needs Myw - pixmapLabel_card0b->setMyW(this); - pixmapLabel_card0a->setMyW(this); + //Player0 pixmapCardsLabel needs Myw + pixmapLabel_card0b->setMyW(this); + pixmapLabel_card0a->setMyW(this); - //set myStyle to widgets wich needs it - label_chance->setMyStyle(myGameTableStyle); + //set myStyle to widgets wich needs it + label_chance->setMyStyle(myGameTableStyle); - //Flipside festlegen; - if (myConfig->readConfigInt("FlipsideOwn") && myConfig->readConfigString("FlipsideOwnFile") != "") { - flipside = QPixmap::fromImage(QImage(QString::fromUtf8(myConfig->readConfigString("FlipsideOwnFile").c_str()))); - } - else { - flipside = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+"flipside.png")); - } + //Flipside festlegen; + if (myConfig->readConfigInt("FlipsideOwn") && myConfig->readConfigString("FlipsideOwnFile") != "") { + flipside = QPixmap::fromImage(QImage(QString::fromUtf8(myConfig->readConfigString("FlipsideOwnFile").c_str()))); + } else { + flipside = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+"flipside.png")); + } - //Flipside Animation noch nicht erledigt - flipHolecardsAllInAlreadyDone = FALSE; + //Flipside Animation noch nicht erledigt + flipHolecardsAllInAlreadyDone = FALSE; - //Toolboxen verstecken? - if (!myConfig->readConfigInt("ShowRightToolBox")) { - groupBox_RightToolBox->hide(); - } - if (!myConfig->readConfigInt("ShowLeftToolBox")) { - groupBox_LeftToolBox->hide(); - } + //Toolboxen verstecken? + if (!myConfig->readConfigInt("ShowRightToolBox")) { + groupBox_RightToolBox->hide(); + } + if (!myConfig->readConfigInt("ShowLeftToolBox")) { + groupBox_LeftToolBox->hide(); + } - //CardsChanceMonitor show/hide - if (!myConfig->readConfigInt("ShowCardsChanceMonitor")) { - tabWidget_Right->removeTab(2); - tabWidget_Right->setCurrentIndex(0); - } + //CardsChanceMonitor show/hide + if (!myConfig->readConfigInt("ShowCardsChanceMonitor")) { + tabWidget_Right->removeTab(2); + tabWidget_Right->setCurrentIndex(0); + } - // userWidgetsArray init - userWidgetsArray[0] = pushButton_BetRaise; - userWidgetsArray[1] = pushButton_CallCheck; - userWidgetsArray[2] = pushButton_Fold; - userWidgetsArray[3] = spinBox_betValue; - userWidgetsArray[4] = horizontalSlider_bet; - userWidgetsArray[5] = pushButton_AllIn; + // userWidgetsArray init + userWidgetsArray[0] = pushButton_BetRaise; + userWidgetsArray[1] = pushButton_CallCheck; + userWidgetsArray[2] = pushButton_Fold; + userWidgetsArray[3] = spinBox_betValue; + userWidgetsArray[4] = horizontalSlider_bet; + userWidgetsArray[5] = pushButton_AllIn; - //hide userWidgets - for(i=0; i<6; i++) { - userWidgetsArray[i]->hide(); - } + //hide userWidgets + for(i=0; i<6; i++) { + userWidgetsArray[i]->hide(); + } - //Timer Objekt erstellen - dealFlopCards0Timer = new QTimer(this); - dealFlopCards1Timer = new QTimer(this); - dealFlopCards2Timer = new QTimer(this); - dealFlopCards3Timer = new QTimer(this); - dealFlopCards4Timer = new QTimer(this); - dealFlopCards5Timer = new QTimer(this); - dealFlopCards6Timer = new QTimer(this); - dealTurnCards0Timer = new QTimer(this); - dealTurnCards1Timer = new QTimer(this); - dealTurnCards2Timer = new QTimer(this); - dealRiverCards0Timer = new QTimer(this); - dealRiverCards1Timer = new QTimer(this); - dealRiverCards2Timer = new QTimer(this); + //Timer Objekt erstellen + dealFlopCards0Timer = new QTimer(this); + dealFlopCards1Timer = new QTimer(this); + dealFlopCards2Timer = new QTimer(this); + dealFlopCards3Timer = new QTimer(this); + dealFlopCards4Timer = new QTimer(this); + dealFlopCards5Timer = new QTimer(this); + dealFlopCards6Timer = new QTimer(this); + dealTurnCards0Timer = new QTimer(this); + dealTurnCards1Timer = new QTimer(this); + dealTurnCards2Timer = new QTimer(this); + dealRiverCards0Timer = new QTimer(this); + dealRiverCards1Timer = new QTimer(this); + dealRiverCards2Timer = new QTimer(this); - nextPlayerAnimationTimer = new QTimer(this); - preflopAnimation1Timer = new QTimer(this); - preflopAnimation2Timer = new QTimer(this); - flopAnimation1Timer = new QTimer(this); - flopAnimation2Timer = new QTimer(this); - turnAnimation1Timer = new QTimer(this); - turnAnimation2Timer = new QTimer(this); - riverAnimation1Timer = new QTimer(this); - riverAnimation2Timer = new QTimer(this); + nextPlayerAnimationTimer = new QTimer(this); + preflopAnimation1Timer = new QTimer(this); + preflopAnimation2Timer = new QTimer(this); + flopAnimation1Timer = new QTimer(this); + flopAnimation2Timer = new QTimer(this); + turnAnimation1Timer = new QTimer(this); + turnAnimation2Timer = new QTimer(this); + riverAnimation1Timer = new QTimer(this); + riverAnimation2Timer = new QTimer(this); - postRiverAnimation1Timer = new QTimer(this); - postRiverRunAnimation1Timer = new QTimer(this); - postRiverRunAnimation2Timer = new QTimer(this); - postRiverRunAnimation2_flipHoleCards1Timer = new QTimer(this); - postRiverRunAnimation2_flipHoleCards2Timer = new QTimer(this); - postRiverRunAnimation3Timer = new QTimer(this); - postRiverRunAnimation5Timer = new QTimer(this); - potDistributeTimer = new QTimer(this); - postRiverRunAnimation6Timer = new QTimer(this); + postRiverAnimation1Timer = new QTimer(this); + postRiverRunAnimation1Timer = new QTimer(this); + postRiverRunAnimation2Timer = new QTimer(this); + postRiverRunAnimation2_flipHoleCards1Timer = new QTimer(this); + postRiverRunAnimation2_flipHoleCards2Timer = new QTimer(this); + postRiverRunAnimation3Timer = new QTimer(this); + postRiverRunAnimation5Timer = new QTimer(this); + potDistributeTimer = new QTimer(this); + postRiverRunAnimation6Timer = new QTimer(this); - blinkingStartButtonAnimationTimer = new QTimer(this); - voteOnKickTimeoutTimer = new QTimer(this); + blinkingStartButtonAnimationTimer = new QTimer(this); + voteOnKickTimeoutTimer = new QTimer(this); - dealFlopCards0Timer->setSingleShot(TRUE); - dealFlopCards1Timer->setSingleShot(TRUE); - dealFlopCards2Timer->setSingleShot(TRUE); - dealFlopCards3Timer->setSingleShot(TRUE); - dealFlopCards4Timer->setSingleShot(TRUE); - dealFlopCards5Timer->setSingleShot(TRUE); - dealFlopCards6Timer->setSingleShot(TRUE); - dealTurnCards0Timer->setSingleShot(TRUE); - dealTurnCards1Timer->setSingleShot(TRUE); - dealTurnCards2Timer->setSingleShot(TRUE); - dealRiverCards0Timer->setSingleShot(TRUE); - dealRiverCards1Timer->setSingleShot(TRUE); - dealRiverCards2Timer->setSingleShot(TRUE); + dealFlopCards0Timer->setSingleShot(TRUE); + dealFlopCards1Timer->setSingleShot(TRUE); + dealFlopCards2Timer->setSingleShot(TRUE); + dealFlopCards3Timer->setSingleShot(TRUE); + dealFlopCards4Timer->setSingleShot(TRUE); + dealFlopCards5Timer->setSingleShot(TRUE); + dealFlopCards6Timer->setSingleShot(TRUE); + dealTurnCards0Timer->setSingleShot(TRUE); + dealTurnCards1Timer->setSingleShot(TRUE); + dealTurnCards2Timer->setSingleShot(TRUE); + dealRiverCards0Timer->setSingleShot(TRUE); + dealRiverCards1Timer->setSingleShot(TRUE); + dealRiverCards2Timer->setSingleShot(TRUE); - nextPlayerAnimationTimer->setSingleShot(TRUE); - preflopAnimation1Timer->setSingleShot(TRUE); - preflopAnimation2Timer->setSingleShot(TRUE); - flopAnimation1Timer->setSingleShot(TRUE); - flopAnimation2Timer->setSingleShot(TRUE); - turnAnimation1Timer->setSingleShot(TRUE); - turnAnimation2Timer->setSingleShot(TRUE); - riverAnimation1Timer->setSingleShot(TRUE); - riverAnimation2Timer->setSingleShot(TRUE); + nextPlayerAnimationTimer->setSingleShot(TRUE); + preflopAnimation1Timer->setSingleShot(TRUE); + preflopAnimation2Timer->setSingleShot(TRUE); + flopAnimation1Timer->setSingleShot(TRUE); + flopAnimation2Timer->setSingleShot(TRUE); + turnAnimation1Timer->setSingleShot(TRUE); + turnAnimation2Timer->setSingleShot(TRUE); + riverAnimation1Timer->setSingleShot(TRUE); + riverAnimation2Timer->setSingleShot(TRUE); - postRiverAnimation1Timer->setSingleShot(TRUE); - postRiverRunAnimation1Timer->setSingleShot(TRUE); - postRiverRunAnimation2Timer->setSingleShot(TRUE); - postRiverRunAnimation3Timer->setSingleShot(TRUE); - postRiverRunAnimation5Timer->setSingleShot(TRUE); - postRiverRunAnimation6Timer->setSingleShot(TRUE); + postRiverAnimation1Timer->setSingleShot(TRUE); + postRiverRunAnimation1Timer->setSingleShot(TRUE); + postRiverRunAnimation2Timer->setSingleShot(TRUE); + postRiverRunAnimation3Timer->setSingleShot(TRUE); + postRiverRunAnimation5Timer->setSingleShot(TRUE); + postRiverRunAnimation6Timer->setSingleShot(TRUE); - playerStarsArray[1][0]=label_Star10; - playerStarsArray[2][0]=label_Star20; - playerStarsArray[3][0]=label_Star30; - playerStarsArray[4][0]=label_Star40; - playerStarsArray[5][0]=label_Star50; - playerStarsArray[1][1]=label_Star11; - playerStarsArray[2][1]=label_Star21; - playerStarsArray[3][1]=label_Star31; - playerStarsArray[4][1]=label_Star41; - playerStarsArray[5][1]=label_Star51; - playerStarsArray[1][2]=label_Star12; - playerStarsArray[2][2]=label_Star22; - playerStarsArray[3][2]=label_Star32; - playerStarsArray[4][2]=label_Star42; - playerStarsArray[5][2]=label_Star52; - playerStarsArray[1][3]=label_Star13; - playerStarsArray[2][3]=label_Star23; - playerStarsArray[3][3]=label_Star33; - playerStarsArray[4][3]=label_Star43; - playerStarsArray[5][3]=label_Star53; - playerStarsArray[1][4]=label_Star14; - playerStarsArray[2][4]=label_Star24; - playerStarsArray[3][4]=label_Star34; - playerStarsArray[4][4]=label_Star44; - playerStarsArray[5][4]=label_Star54; - playerStarsArray[1][5]=label_Star15; - playerStarsArray[2][5]=label_Star25; - playerStarsArray[3][5]=label_Star35; - playerStarsArray[4][5]=label_Star45; - playerStarsArray[5][5]=label_Star55; - playerStarsArray[1][6]=label_Star16; - playerStarsArray[2][6]=label_Star26; - playerStarsArray[3][6]=label_Star36; - playerStarsArray[4][6]=label_Star46; - playerStarsArray[5][6]=label_Star56; - playerStarsArray[1][7]=label_Star17; - playerStarsArray[2][7]=label_Star27; - playerStarsArray[3][7]=label_Star37; - playerStarsArray[4][7]=label_Star47; - playerStarsArray[5][7]=label_Star57; - playerStarsArray[1][8]=label_Star18; - playerStarsArray[2][8]=label_Star28; - playerStarsArray[3][8]=label_Star38; - playerStarsArray[4][8]=label_Star48; - playerStarsArray[5][8]=label_Star58; - playerStarsArray[1][9]=label_Star19; - playerStarsArray[2][9]=label_Star29; - playerStarsArray[3][9]=label_Star39; - playerStarsArray[4][9]=label_Star49; - playerStarsArray[5][9]=label_Star59; + playerStarsArray[1][0]=label_Star10; + playerStarsArray[2][0]=label_Star20; + playerStarsArray[3][0]=label_Star30; + playerStarsArray[4][0]=label_Star40; + playerStarsArray[5][0]=label_Star50; + playerStarsArray[1][1]=label_Star11; + playerStarsArray[2][1]=label_Star21; + playerStarsArray[3][1]=label_Star31; + playerStarsArray[4][1]=label_Star41; + playerStarsArray[5][1]=label_Star51; + playerStarsArray[1][2]=label_Star12; + playerStarsArray[2][2]=label_Star22; + playerStarsArray[3][2]=label_Star32; + playerStarsArray[4][2]=label_Star42; + playerStarsArray[5][2]=label_Star52; + playerStarsArray[1][3]=label_Star13; + playerStarsArray[2][3]=label_Star23; + playerStarsArray[3][3]=label_Star33; + playerStarsArray[4][3]=label_Star43; + playerStarsArray[5][3]=label_Star53; + playerStarsArray[1][4]=label_Star14; + playerStarsArray[2][4]=label_Star24; + playerStarsArray[3][4]=label_Star34; + playerStarsArray[4][4]=label_Star44; + playerStarsArray[5][4]=label_Star54; + playerStarsArray[1][5]=label_Star15; + playerStarsArray[2][5]=label_Star25; + playerStarsArray[3][5]=label_Star35; + playerStarsArray[4][5]=label_Star45; + playerStarsArray[5][5]=label_Star55; + playerStarsArray[1][6]=label_Star16; + playerStarsArray[2][6]=label_Star26; + playerStarsArray[3][6]=label_Star36; + playerStarsArray[4][6]=label_Star46; + playerStarsArray[5][6]=label_Star56; + playerStarsArray[1][7]=label_Star17; + playerStarsArray[2][7]=label_Star27; + playerStarsArray[3][7]=label_Star37; + playerStarsArray[4][7]=label_Star47; + playerStarsArray[5][7]=label_Star57; + playerStarsArray[1][8]=label_Star18; + playerStarsArray[2][8]=label_Star28; + playerStarsArray[3][8]=label_Star38; + playerStarsArray[4][8]=label_Star48; + playerStarsArray[5][8]=label_Star58; + playerStarsArray[1][9]=label_Star19; + playerStarsArray[2][9]=label_Star29; + playerStarsArray[3][9]=label_Star39; + playerStarsArray[4][9]=label_Star49; + playerStarsArray[5][9]=label_Star59; @@ -261,655 +260,685 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) - // buttonLabelArray init - buttonLabelArray[0] = textLabel_Button0; - buttonLabelArray[1] = textLabel_Button1; - buttonLabelArray[2] = textLabel_Button2; - buttonLabelArray[3] = textLabel_Button3; - buttonLabelArray[4] = textLabel_Button4; - buttonLabelArray[5] = textLabel_Button5; - buttonLabelArray[6] = textLabel_Button6; - buttonLabelArray[7] = textLabel_Button7; - buttonLabelArray[8] = textLabel_Button8; - buttonLabelArray[9] = textLabel_Button9; + // buttonLabelArray init + buttonLabelArray[0] = textLabel_Button0; + buttonLabelArray[1] = textLabel_Button1; + buttonLabelArray[2] = textLabel_Button2; + buttonLabelArray[3] = textLabel_Button3; + buttonLabelArray[4] = textLabel_Button4; + buttonLabelArray[5] = textLabel_Button5; + buttonLabelArray[6] = textLabel_Button6; + buttonLabelArray[7] = textLabel_Button7; + buttonLabelArray[8] = textLabel_Button8; + buttonLabelArray[9] = textLabel_Button9; - // cashLabelArray init - cashLabelArray[0] = textLabel_Cash0; - cashLabelArray[1] = textLabel_Cash1; - cashLabelArray[2] = textLabel_Cash2; - cashLabelArray[3] = textLabel_Cash3; - cashLabelArray[4] = textLabel_Cash4; - cashLabelArray[5] = textLabel_Cash5; - cashLabelArray[6] = textLabel_Cash6; - cashLabelArray[7] = textLabel_Cash7; - cashLabelArray[8] = textLabel_Cash8; - cashLabelArray[9] = textLabel_Cash9; + // cashLabelArray init + cashLabelArray[0] = textLabel_Cash0; + cashLabelArray[1] = textLabel_Cash1; + cashLabelArray[2] = textLabel_Cash2; + cashLabelArray[3] = textLabel_Cash3; + cashLabelArray[4] = textLabel_Cash4; + cashLabelArray[5] = textLabel_Cash5; + cashLabelArray[6] = textLabel_Cash6; + cashLabelArray[7] = textLabel_Cash7; + cashLabelArray[8] = textLabel_Cash8; + cashLabelArray[9] = textLabel_Cash9; - playerTipLabelArray[0] = label_playerTip0; - playerTipLabelArray[1] = label_playerTip1; - playerTipLabelArray[2] = label_playerTip2; - playerTipLabelArray[3] = label_playerTip3; - playerTipLabelArray[4] = label_playerTip4; - playerTipLabelArray[5] = label_playerTip5; - playerTipLabelArray[6] = label_playerTip6; - playerTipLabelArray[7] = label_playerTip7; - playerTipLabelArray[8] = label_playerTip8; - playerTipLabelArray[9] = label_playerTip9; + playerTipLabelArray[0] = label_playerTip0; + playerTipLabelArray[1] = label_playerTip1; + playerTipLabelArray[2] = label_playerTip2; + playerTipLabelArray[3] = label_playerTip3; + playerTipLabelArray[4] = label_playerTip4; + playerTipLabelArray[5] = label_playerTip5; + playerTipLabelArray[6] = label_playerTip6; + playerTipLabelArray[7] = label_playerTip7; + playerTipLabelArray[8] = label_playerTip8; + playerTipLabelArray[9] = label_playerTip9; - // playerNameLabelArray init - playerNameLabelArray[0] = label_PlayerName0; - playerNameLabelArray[1] = label_PlayerName1; - playerNameLabelArray[2] = label_PlayerName2; - playerNameLabelArray[3] = label_PlayerName3; - playerNameLabelArray[4] = label_PlayerName4; - playerNameLabelArray[5] = label_PlayerName5; - playerNameLabelArray[6] = label_PlayerName6; - playerNameLabelArray[7] = label_PlayerName7; - playerNameLabelArray[8] = label_PlayerName8; - playerNameLabelArray[9] = label_PlayerName9; - for (i=0; isetMyW(this); - } + // playerNameLabelArray init + playerNameLabelArray[0] = label_PlayerName0; + playerNameLabelArray[1] = label_PlayerName1; + playerNameLabelArray[2] = label_PlayerName2; + playerNameLabelArray[3] = label_PlayerName3; + playerNameLabelArray[4] = label_PlayerName4; + playerNameLabelArray[5] = label_PlayerName5; + playerNameLabelArray[6] = label_PlayerName6; + playerNameLabelArray[7] = label_PlayerName7; + playerNameLabelArray[8] = label_PlayerName8; + playerNameLabelArray[9] = label_PlayerName9; + for (i=0; isetMyW(this); + } - // playerAvatarLabelArray init - playerAvatarLabelArray[0] = label_Avatar0; - playerAvatarLabelArray[1] = label_Avatar1; - playerAvatarLabelArray[2] = label_Avatar2; - playerAvatarLabelArray[3] = label_Avatar3; - playerAvatarLabelArray[4] = label_Avatar4; - playerAvatarLabelArray[5] = label_Avatar5; - playerAvatarLabelArray[6] = label_Avatar6; - playerAvatarLabelArray[7] = label_Avatar7; - playerAvatarLabelArray[8] = label_Avatar8; - playerAvatarLabelArray[9] = label_Avatar9; - for (i=0; isetMyW(this); - playerAvatarLabelArray[i]->setMyId(i); - } + // playerAvatarLabelArray init + playerAvatarLabelArray[0] = label_Avatar0; + playerAvatarLabelArray[1] = label_Avatar1; + playerAvatarLabelArray[2] = label_Avatar2; + playerAvatarLabelArray[3] = label_Avatar3; + playerAvatarLabelArray[4] = label_Avatar4; + playerAvatarLabelArray[5] = label_Avatar5; + playerAvatarLabelArray[6] = label_Avatar6; + playerAvatarLabelArray[7] = label_Avatar7; + playerAvatarLabelArray[8] = label_Avatar8; + playerAvatarLabelArray[9] = label_Avatar9; + for (i=0; isetMyW(this); + playerAvatarLabelArray[i]->setMyId(i); + } - // timeoutLabelArray init - timeoutLabelArray[0] = label_Timeout0; - timeoutLabelArray[1] = label_Timeout1; - timeoutLabelArray[2] = label_Timeout2; - timeoutLabelArray[3] = label_Timeout3; - timeoutLabelArray[4] = label_Timeout4; - timeoutLabelArray[5] = label_Timeout5; - timeoutLabelArray[6] = label_Timeout6; - timeoutLabelArray[7] = label_Timeout7; - timeoutLabelArray[8] = label_Timeout8; - timeoutLabelArray[9] = label_Timeout9; - for (i=0; isetMyW(this); } + // timeoutLabelArray init + timeoutLabelArray[0] = label_Timeout0; + timeoutLabelArray[1] = label_Timeout1; + timeoutLabelArray[2] = label_Timeout2; + timeoutLabelArray[3] = label_Timeout3; + timeoutLabelArray[4] = label_Timeout4; + timeoutLabelArray[5] = label_Timeout5; + timeoutLabelArray[6] = label_Timeout6; + timeoutLabelArray[7] = label_Timeout7; + timeoutLabelArray[8] = label_Timeout8; + timeoutLabelArray[9] = label_Timeout9; + for (i=0; isetMyW(this); + } - // setLabelArray init - setLabelArray[0] = textLabel_Set0; - setLabelArray[1] = textLabel_Set1; - setLabelArray[2] = textLabel_Set2; - setLabelArray[3] = textLabel_Set3; - setLabelArray[4] = textLabel_Set4; - setLabelArray[5] = textLabel_Set5; - setLabelArray[6] = textLabel_Set6; - setLabelArray[7] = textLabel_Set7; - setLabelArray[8] = textLabel_Set8; - setLabelArray[9] = textLabel_Set9; - for (i=0; isetMyW(this); } - label_Timeout0->setMyW(this); + // setLabelArray init + setLabelArray[0] = textLabel_Set0; + setLabelArray[1] = textLabel_Set1; + setLabelArray[2] = textLabel_Set2; + setLabelArray[3] = textLabel_Set3; + setLabelArray[4] = textLabel_Set4; + setLabelArray[5] = textLabel_Set5; + setLabelArray[6] = textLabel_Set6; + setLabelArray[7] = textLabel_Set7; + setLabelArray[8] = textLabel_Set8; + setLabelArray[9] = textLabel_Set9; + for (i=0; isetMyW(this); + } + label_Timeout0->setMyW(this); - // statusLabelArray init - actionLabelArray[0] = textLabel_Status0; - actionLabelArray[1] = textLabel_Status1; - actionLabelArray[2] = textLabel_Status2; - actionLabelArray[3] = textLabel_Status3; - actionLabelArray[4] = textLabel_Status4; - actionLabelArray[5] = textLabel_Status5; - actionLabelArray[6] = textLabel_Status6; - actionLabelArray[7] = textLabel_Status7; - actionLabelArray[8] = textLabel_Status8; - actionLabelArray[9] = textLabel_Status9; + // statusLabelArray init + actionLabelArray[0] = textLabel_Status0; + actionLabelArray[1] = textLabel_Status1; + actionLabelArray[2] = textLabel_Status2; + actionLabelArray[3] = textLabel_Status3; + actionLabelArray[4] = textLabel_Status4; + actionLabelArray[5] = textLabel_Status5; + actionLabelArray[6] = textLabel_Status6; + actionLabelArray[7] = textLabel_Status7; + actionLabelArray[8] = textLabel_Status8; + actionLabelArray[9] = textLabel_Status9; - textLabel_Status0->setMyW(this); + textLabel_Status0->setMyW(this); - // GroupBoxArray init - groupBoxArray[0] = groupBox0; - groupBoxArray[1] = groupBox1; - groupBoxArray[2] = groupBox2; - groupBoxArray[3] = groupBox3; - groupBoxArray[4] = groupBox4; - groupBoxArray[5] = groupBox5; - groupBoxArray[6] = groupBox6; - groupBoxArray[7] = groupBox7; - groupBoxArray[8] = groupBox8; - groupBoxArray[9] = groupBox9; + // GroupBoxArray init + groupBoxArray[0] = groupBox0; + groupBoxArray[1] = groupBox1; + groupBoxArray[2] = groupBox2; + groupBoxArray[3] = groupBox3; + groupBoxArray[4] = groupBox4; + groupBoxArray[5] = groupBox5; + groupBoxArray[6] = groupBox6; + groupBoxArray[7] = groupBox7; + groupBoxArray[8] = groupBox8; + groupBoxArray[9] = groupBox9; - // boardCardsArray init - boardCardsArray[0] = pixmapLabel_cardBoard0; - boardCardsArray[1] = pixmapLabel_cardBoard1; - boardCardsArray[2] = pixmapLabel_cardBoard2; - boardCardsArray[3] = pixmapLabel_cardBoard3; - boardCardsArray[4] = pixmapLabel_cardBoard4; + // boardCardsArray init + boardCardsArray[0] = pixmapLabel_cardBoard0; + boardCardsArray[1] = pixmapLabel_cardBoard1; + boardCardsArray[2] = pixmapLabel_cardBoard2; + boardCardsArray[3] = pixmapLabel_cardBoard3; + boardCardsArray[4] = pixmapLabel_cardBoard4; - // holeCardsArray int - holeCardsArray[0][0] = pixmapLabel_card0a; - holeCardsArray[0][1] = pixmapLabel_card0b; - holeCardsArray[1][0] = pixmapLabel_card1a; - holeCardsArray[1][1] = pixmapLabel_card1b; - holeCardsArray[2][0] = pixmapLabel_card2a; - holeCardsArray[2][1] = pixmapLabel_card2b; - holeCardsArray[3][0] = pixmapLabel_card3a; - holeCardsArray[3][1] = pixmapLabel_card3b; - holeCardsArray[4][0] = pixmapLabel_card4a; - holeCardsArray[4][1] = pixmapLabel_card4b; - holeCardsArray[5][0] = pixmapLabel_card5a; - holeCardsArray[5][1] = pixmapLabel_card5b; - holeCardsArray[6][0] = pixmapLabel_card6a; - holeCardsArray[6][1] = pixmapLabel_card6b; - holeCardsArray[7][0] = pixmapLabel_card7a; - holeCardsArray[7][1] = pixmapLabel_card7b; - holeCardsArray[8][0] = pixmapLabel_card8a; - holeCardsArray[8][1] = pixmapLabel_card8b; - holeCardsArray[9][0] = pixmapLabel_card9a; - holeCardsArray[9][1] = pixmapLabel_card9b; + // holeCardsArray int + holeCardsArray[0][0] = pixmapLabel_card0a; + holeCardsArray[0][1] = pixmapLabel_card0b; + holeCardsArray[1][0] = pixmapLabel_card1a; + holeCardsArray[1][1] = pixmapLabel_card1b; + holeCardsArray[2][0] = pixmapLabel_card2a; + holeCardsArray[2][1] = pixmapLabel_card2b; + holeCardsArray[3][0] = pixmapLabel_card3a; + holeCardsArray[3][1] = pixmapLabel_card3b; + holeCardsArray[4][0] = pixmapLabel_card4a; + holeCardsArray[4][1] = pixmapLabel_card4b; + holeCardsArray[5][0] = pixmapLabel_card5a; + holeCardsArray[5][1] = pixmapLabel_card5b; + holeCardsArray[6][0] = pixmapLabel_card6a; + holeCardsArray[6][1] = pixmapLabel_card6b; + holeCardsArray[7][0] = pixmapLabel_card7a; + holeCardsArray[7][1] = pixmapLabel_card7b; + holeCardsArray[8][0] = pixmapLabel_card8a; + holeCardsArray[8][1] = pixmapLabel_card8b; + holeCardsArray[9][0] = pixmapLabel_card9a; + holeCardsArray[9][1] = pixmapLabel_card9b; - pushButton_showMyCards->hide(); + pushButton_showMyCards->hide(); - //style Game Table - refreshGameTableStyle(); + //style Game Table + refreshGameTableStyle(); - //raise actionLable above just inserted mypixmaplabel - for (i=0; iraise(); } + //raise actionLable above just inserted mypixmaplabel + for (i=0; iraise(); + } - //raise board cards - for (i=0; i<5; i++) { boardCardsArray[i]->raise(); } + //raise board cards + for (i=0; i<5; i++) { + boardCardsArray[i]->raise(); + } - //fix for away string bug in righttabwidget on windows + //fix for away string bug in righttabwidget on windows #if (defined _WIN32) || (defined __APPLE__) - tabWidget_Right->setTabText(0, " "+tabWidget_Right->tabText(0)+" "); - tabWidget_Right->setTabText(1, " "+tabWidget_Right->tabText(1)+" "); - tabWidget_Right->setTabText(2, " "+tabWidget_Right->tabText(2)+" "); - tabWidget_Left->setTabText(0, " "+tabWidget_Left->tabText(0)+" "); - tabWidget_Left->setTabText(1, " "+tabWidget_Left->tabText(1)+" "); - tabWidget_Left->setTabText(2, " "+tabWidget_Left->tabText(2)+" "); - tabWidget_Left->setTabText(3, " "+tabWidget_Left->tabText(3)+" "); + tabWidget_Right->setTabText(0, " "+tabWidget_Right->tabText(0)+" "); + tabWidget_Right->setTabText(1, " "+tabWidget_Right->tabText(1)+" "); + tabWidget_Right->setTabText(2, " "+tabWidget_Right->tabText(2)+" "); + tabWidget_Left->setTabText(0, " "+tabWidget_Left->tabText(0)+" "); + tabWidget_Left->setTabText(1, " "+tabWidget_Left->tabText(1)+" "); + tabWidget_Left->setTabText(2, " "+tabWidget_Left->tabText(2)+" "); + tabWidget_Left->setTabText(3, " "+tabWidget_Left->tabText(3)+" "); #endif - //resize stop-button depending on translation - QFontMetrics tempMetrics = this->fontMetrics(); - int width = tempMetrics.width(tr("Stop")); - pushButton_break->setMinimumSize(width+10,20); + //resize stop-button depending on translation + QFontMetrics tempMetrics = this->fontMetrics(); + int width = tempMetrics.width(tr("Stop")); + pushButton_break->setMinimumSize(width+10,20); - //Clear Focus - groupBox_LeftToolBox->clearFocus(); - groupBox_RightToolBox->clearFocus(); + //Clear Focus + groupBox_LeftToolBox->clearFocus(); + groupBox_RightToolBox->clearFocus(); - //set Focus to gametable - this->setFocus(); + //set Focus to gametable + this->setFocus(); - //windowicon - // QString windowIconString(); - this->setWindowIcon(QIcon(myAppDataPath+"gfx/gui/misc/windowicon.png")); + //windowicon + // QString windowIconString(); + this->setWindowIcon(QIcon(myAppDataPath+"gfx/gui/misc/windowicon.png")); - //Statusbar - if(myConfig->readConfigInt("ShowStatusbarMessages")) { + //Statusbar + if(myConfig->readConfigInt("ShowStatusbarMessages")) { #ifdef __APPLE__ - // statusBar()->showMessage(tr("Cmd+N to start a new game")); + // statusBar()->showMessage(tr("Cmd+N to start a new game")); #else - // statusBar()->showMessage(tr("Ctrl+N to start a new game")); + // statusBar()->showMessage(tr("Ctrl+N to start a new game")); #endif - } - - // Dialogs - myChat = new ChatTools(lineEdit_ChatInput, myConfig, INGAME_CHAT, textBrowser_Chat); - myChat->setMyStyle(myGameTableStyle); - - lineEdit_ChatInput->installEventFilter(this); - this->installEventFilter(this); - - //set WindowTitle dynamically - this->setWindowTitle(QString(tr("PokerTH %1 - The Open-Source Texas Holdem Engine").arg(POKERTH_BETA_RELEASE_STRING))); - - // create universal messageDialgo - myUniversalMessageDialog = new myMessageDialogImpl(myConfig, this); - myUniversalMessageDialog->setParent(this); - - - - //Connects - connect(pushButton_tipSave, SIGNAL( clicked(bool) ), playerAvatarLabelArray[0], SLOT ( setPlayerTip() ) ); - connect(dealFlopCards0Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards1() )); - connect(dealFlopCards1Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards2() )); - connect(dealFlopCards2Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards3() )); - connect(dealFlopCards3Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards4() )); - connect(dealFlopCards4Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards5() )); - connect(dealFlopCards5Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards6() )); - connect(dealFlopCards6Timer, SIGNAL(timeout()), this, SLOT( handSwitchRounds() )); - connect(dealTurnCards0Timer, SIGNAL(timeout()), this, SLOT( dealTurnCards1() )); - connect(dealTurnCards1Timer, SIGNAL(timeout()), this, SLOT( dealTurnCards2() )); - connect(dealTurnCards2Timer, SIGNAL(timeout()), this, SLOT( handSwitchRounds() )); - connect(dealRiverCards0Timer, SIGNAL(timeout()), this, SLOT( dealRiverCards1() )); - connect(dealRiverCards1Timer, SIGNAL(timeout()), this, SLOT( dealRiverCards2() )); - connect(dealRiverCards2Timer, SIGNAL(timeout()), this, SLOT( handSwitchRounds() )); - - connect(nextPlayerAnimationTimer, SIGNAL(timeout()), this, SLOT( handSwitchRounds() )); - connect(preflopAnimation1Timer, SIGNAL(timeout()), this, SLOT( preflopAnimation1Action() )); - connect(preflopAnimation2Timer, SIGNAL(timeout()), this, SLOT( preflopAnimation2Action() )); - connect(flopAnimation1Timer, SIGNAL(timeout()), this, SLOT( flopAnimation1Action() )); - connect(flopAnimation2Timer, SIGNAL(timeout()), this, SLOT( flopAnimation2Action() )); - connect(turnAnimation1Timer, SIGNAL(timeout()), this, SLOT( turnAnimation1Action() )); - connect(turnAnimation2Timer, SIGNAL(timeout()), this, SLOT( turnAnimation2Action() )); - connect(riverAnimation1Timer, SIGNAL(timeout()), this, SLOT( riverAnimation1Action() )); - connect(riverAnimation2Timer, SIGNAL(timeout()), this, SLOT( riverAnimation2Action() )); - - connect(postRiverAnimation1Timer, SIGNAL(timeout()), this, SLOT( postRiverAnimation1Action() )); - connect(postRiverRunAnimation1Timer, SIGNAL(timeout()), this, SLOT( postRiverRunAnimation2() )); - connect(postRiverRunAnimation2Timer, SIGNAL(timeout()), this, SLOT( postRiverRunAnimation3() )); - connect(postRiverRunAnimation3Timer, SIGNAL(timeout()), this, SLOT( postRiverRunAnimation4() )); - connect(potDistributeTimer, SIGNAL(timeout()), this, SLOT(postRiverRunAnimation5())); - connect(postRiverRunAnimation5Timer, SIGNAL(timeout()), this, SLOT( postRiverRunAnimation6() )); - connect(postRiverRunAnimation6Timer, SIGNAL(timeout()), this, SLOT( startNewHand() )); - - connect(blinkingStartButtonAnimationTimer, SIGNAL(timeout()), this, SLOT( blinkingStartButtonAnimationAction())); - connect(voteOnKickTimeoutTimer, SIGNAL(timeout()), this, SLOT(nextVoteOnKickTimeoutAnimationFrame())); - - connect( actionConfigure_PokerTH, SIGNAL( triggered() ), this, SLOT( callSettingsDialog() ) ); - connect( actionClose, SIGNAL( triggered() ), this, SLOT( closeGameTable()) ); - connect( actionFullScreen, SIGNAL( triggered() ), this, SLOT( switchFullscreen() ) ); - connect( actionShowHideChat, SIGNAL( triggered() ), this, SLOT( switchChatWindow() ) ); - connect( actionShowHideHelp, SIGNAL( triggered() ), this, SLOT( switchHelpWindow() ) ); - connect( actionShowHideLog, SIGNAL( triggered() ), this, SLOT( switchLogWindow() ) ); - connect( actionShowHideAway, SIGNAL( triggered() ), this, SLOT( switchAwayWindow() ) ); - connect( actionShowHideChance, SIGNAL( triggered() ), this, SLOT( switchChanceWindow() ) ); - - connect( pushButton_BetRaise, SIGNAL( clicked(bool) ), this, SLOT( pushButtonBetRaiseClicked(bool) ) ); - connect( pushButton_Fold, SIGNAL( clicked(bool) ), this, SLOT( pushButtonFoldClicked(bool) ) ); - connect( pushButton_CallCheck, SIGNAL( clicked(bool) ), this, SLOT( pushButtonCallCheckClicked(bool) ) ); - connect( pushButton_AllIn, SIGNAL( clicked(bool) ), this, SLOT(pushButtonAllInClicked(bool) ) ); - connect( horizontalSlider_bet, SIGNAL( valueChanged(int)), this, SLOT ( changeSpinBoxBetValue(int) ) ); - connect( spinBox_betValue, SIGNAL( valueChanged(int)), this, SLOT ( spinBoxBetValueChanged(int) ) ); - - connect( horizontalSlider_speed, SIGNAL( valueChanged(int)), this, SLOT ( setGameSpeed(int) ) ); - connect( pushButton_break, SIGNAL( clicked()), this, SLOT ( breakButtonClicked() ) ); // auch wieder starten!!!! - - connect( tabWidget_Left, SIGNAL( currentChanged(int) ), this, SLOT( tabSwitchAction() ) ); - connect( lineEdit_ChatInput, SIGNAL( returnPressed () ), this, SLOT( sendChatMessage() ) ); - connect( lineEdit_ChatInput, SIGNAL( textChanged (QString) ), this, SLOT( checkChatInputLength(QString) ) ); - connect( lineEdit_ChatInput, SIGNAL( textEdited (QString) ), myChat, SLOT( setChatTextEdited() ) ); - - connect( radioButton_manualAction, SIGNAL( clicked() ) , this, SLOT( changePlayingMode() ) ); - connect( radioButton_autoCheckFold, SIGNAL( clicked() ) , this, SLOT( changePlayingMode() ) ); - connect( radioButton_autoCheckCallAny, SIGNAL( clicked() ), this, SLOT( changePlayingMode() ) ); - - connect( pushButton_voteOnKickYes, SIGNAL( clicked() ), this, SLOT( voteOnKickYes() ) ); - connect( pushButton_voteOnKickNo, SIGNAL( clicked() ), this, SLOT( voteOnKickNo() ) ); - - connect( pushButton_showMyCards, SIGNAL( clicked() ), this, SLOT( sendShowMyCardsSignal() ) ); - for(i=0;i<=9;i++)connect( playerTipLabelArray[i], SIGNAL( linkActivated(QString) ), playerAvatarLabelArray[i], SLOT(startChangePlayerTip(QString) ) ); - for(i=0;i<=9;i++) - { - for(int j=1;j<=5;j++) - { - connect( playerStarsArray[j][i], SIGNAL( linkActivated(QString) ), playerAvatarLabelArray[i], SLOT(setPlayerRating(QString) ) ); } - } - //Nachrichten Thread-Save - connect(this, SIGNAL(signalInitGui(int)), this, SLOT(initGui(int))); - connect(this, SIGNAL(signalRefreshSet()), this, SLOT(refreshSet())); - connect(this, SIGNAL(signalRefreshCash()), this, SLOT(refreshCash())); - connect(this, SIGNAL(signalRefreshAction(int, int)), this, SLOT(refreshAction(int, int))); - connect(this, SIGNAL(signalRefreshChangePlayer()), this, SLOT(refreshChangePlayer())); - connect(this, SIGNAL(signalRefreshPot()), this, SLOT(refreshPot())); - connect(this, SIGNAL(signalRefreshGroupbox(int, int)), this, SLOT(refreshGroupbox(int, int))); - connect(this, SIGNAL(signalRefreshAll()), this, SLOT(refreshAll())); - connect(this, SIGNAL(signalRefreshPlayerName()), this, SLOT(refreshPlayerName())); - connect(this, SIGNAL(signalRefreshButton()), this, SLOT(refreshButton())); - connect(this, SIGNAL(signalRefreshGameLabels(int)), this, SLOT(refreshGameLabels(int))); - connect(this, SIGNAL(signalSetPlayerAvatar(int, QString)), this, SLOT(setPlayerAvatar(int, QString))); - connect(this, SIGNAL(signalGuiUpdateDone()), this, SLOT(guiUpdateDone())); - connect(this, SIGNAL(signalMeInAction()), this, SLOT(meInAction())); - connect(this, SIGNAL(signalDisableMyButtons()), this, SLOT(disableMyButtons())); - connect(this, SIGNAL(signalUpdateMyButtonsState()), this, SLOT(updateMyButtonsState())); - connect(this, SIGNAL(signalStartTimeoutAnimation(int, int)), this, SLOT(startTimeoutAnimation(int, int))); - connect(this, SIGNAL(signalStopTimeoutAnimation(int)), this, SLOT(stopTimeoutAnimation(int))); - connect(this, SIGNAL(signalDealBeRoCards(int)), this, SLOT(dealBeRoCards(int))); - connect(this, SIGNAL(signalDealHoleCards()), this, SLOT(dealHoleCards())); - connect(this, SIGNAL(signalDealFlopCards0()), this, SLOT(dealFlopCards0())); - connect(this, SIGNAL(signalDealTurnCards0()), this, SLOT(dealTurnCards0())); - connect(this, SIGNAL(signalDealRiverCards0()), this, SLOT(dealRiverCards0())); - connect(this, SIGNAL(signalNextPlayerAnimation()), this, SLOT(nextPlayerAnimation())); - connect(this, SIGNAL(signalBeRoAnimation2(int)), this, SLOT(beRoAnimation2(int))); - connect(this, SIGNAL(signalPreflopAnimation1()), this, SLOT(preflopAnimation1())); - connect(this, SIGNAL(signalPreflopAnimation2()), this, SLOT(preflopAnimation2())); - connect(this, SIGNAL(signalFlopAnimation1()), this, SLOT(flopAnimation1())); - connect(this, SIGNAL(signalFlopAnimation2()), this, SLOT(flopAnimation2())); - connect(this, SIGNAL(signalTurnAnimation1()), this, SLOT(turnAnimation1())); - connect(this, SIGNAL(signalTurnAnimation2()), this, SLOT(turnAnimation2())); - connect(this, SIGNAL(signalRiverAnimation1()), this, SLOT(riverAnimation1())); - connect(this, SIGNAL(signalRiverAnimation2()), this, SLOT(riverAnimation2())); - connect(this, SIGNAL(signalPostRiverAnimation1()), this, SLOT(postRiverAnimation1())); - connect(this, SIGNAL(signalPostRiverRunAnimation1()), this, SLOT(postRiverRunAnimation1())); - connect(this, SIGNAL(signalPostRiverShowCards(unsigned)), this, SLOT(showHoleCards(unsigned))); - connect(this, SIGNAL(signalFlipHolecardsAllIn()), this, SLOT(flipHolecardsAllIn())); - connect(this, SIGNAL(signalNextRoundCleanGui()), this, SLOT(nextRoundCleanGui())); - connect(this, SIGNAL(signalStartVoteOnKick(unsigned, unsigned, int, int)), this, SLOT(startVoteOnKick(unsigned, unsigned, int, int))); - connect(this, SIGNAL(signalChangeVoteOnKickButtonsState(bool)), this, SLOT(changeVoteOnKickButtonsState(bool))); - connect(this, SIGNAL(signalEndVoteOnKick()), this, SLOT(endVoteOnKick())); - connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned)), this, SLOT(netClientPlayerLeft(unsigned))); - connect(this, SIGNAL(signalWarningAutoFoldInRankingGame(unsigned)), this, SLOT(showWarningAutoFoldInRankingGame(unsigned))); + // Dialogs + myChat = new ChatTools(lineEdit_ChatInput, myConfig, INGAME_CHAT, textBrowser_Chat); + myChat->setMyStyle(myGameTableStyle); + + lineEdit_ChatInput->installEventFilter(this); + this->installEventFilter(this); + + //set WindowTitle dynamically + this->setWindowTitle(QString(tr("PokerTH %1 - The Open-Source Texas Holdem Engine").arg(POKERTH_BETA_RELEASE_STRING))); + + // create universal messageDialgo + myUniversalMessageDialog = new myMessageDialogImpl(myConfig, this); + myUniversalMessageDialog->setParent(this); + + + + //Connects + connect(pushButton_tipSave, SIGNAL( clicked(bool) ), playerAvatarLabelArray[0], SLOT ( setPlayerTip() ) ); + connect(dealFlopCards0Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards1() )); + connect(dealFlopCards1Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards2() )); + connect(dealFlopCards2Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards3() )); + connect(dealFlopCards3Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards4() )); + connect(dealFlopCards4Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards5() )); + connect(dealFlopCards5Timer, SIGNAL(timeout()), this, SLOT( dealFlopCards6() )); + connect(dealFlopCards6Timer, SIGNAL(timeout()), this, SLOT( handSwitchRounds() )); + connect(dealTurnCards0Timer, SIGNAL(timeout()), this, SLOT( dealTurnCards1() )); + connect(dealTurnCards1Timer, SIGNAL(timeout()), this, SLOT( dealTurnCards2() )); + connect(dealTurnCards2Timer, SIGNAL(timeout()), this, SLOT( handSwitchRounds() )); + connect(dealRiverCards0Timer, SIGNAL(timeout()), this, SLOT( dealRiverCards1() )); + connect(dealRiverCards1Timer, SIGNAL(timeout()), this, SLOT( dealRiverCards2() )); + connect(dealRiverCards2Timer, SIGNAL(timeout()), this, SLOT( handSwitchRounds() )); + + connect(nextPlayerAnimationTimer, SIGNAL(timeout()), this, SLOT( handSwitchRounds() )); + connect(preflopAnimation1Timer, SIGNAL(timeout()), this, SLOT( preflopAnimation1Action() )); + connect(preflopAnimation2Timer, SIGNAL(timeout()), this, SLOT( preflopAnimation2Action() )); + connect(flopAnimation1Timer, SIGNAL(timeout()), this, SLOT( flopAnimation1Action() )); + connect(flopAnimation2Timer, SIGNAL(timeout()), this, SLOT( flopAnimation2Action() )); + connect(turnAnimation1Timer, SIGNAL(timeout()), this, SLOT( turnAnimation1Action() )); + connect(turnAnimation2Timer, SIGNAL(timeout()), this, SLOT( turnAnimation2Action() )); + connect(riverAnimation1Timer, SIGNAL(timeout()), this, SLOT( riverAnimation1Action() )); + connect(riverAnimation2Timer, SIGNAL(timeout()), this, SLOT( riverAnimation2Action() )); + + connect(postRiverAnimation1Timer, SIGNAL(timeout()), this, SLOT( postRiverAnimation1Action() )); + connect(postRiverRunAnimation1Timer, SIGNAL(timeout()), this, SLOT( postRiverRunAnimation2() )); + connect(postRiverRunAnimation2Timer, SIGNAL(timeout()), this, SLOT( postRiverRunAnimation3() )); + connect(postRiverRunAnimation3Timer, SIGNAL(timeout()), this, SLOT( postRiverRunAnimation4() )); + connect(potDistributeTimer, SIGNAL(timeout()), this, SLOT(postRiverRunAnimation5())); + connect(postRiverRunAnimation5Timer, SIGNAL(timeout()), this, SLOT( postRiverRunAnimation6() )); + connect(postRiverRunAnimation6Timer, SIGNAL(timeout()), this, SLOT( startNewHand() )); + + connect(blinkingStartButtonAnimationTimer, SIGNAL(timeout()), this, SLOT( blinkingStartButtonAnimationAction())); + connect(voteOnKickTimeoutTimer, SIGNAL(timeout()), this, SLOT(nextVoteOnKickTimeoutAnimationFrame())); + + connect( actionConfigure_PokerTH, SIGNAL( triggered() ), this, SLOT( callSettingsDialog() ) ); + connect( actionClose, SIGNAL( triggered() ), this, SLOT( closeGameTable()) ); + connect( actionFullScreen, SIGNAL( triggered() ), this, SLOT( switchFullscreen() ) ); + connect( actionShowHideChat, SIGNAL( triggered() ), this, SLOT( switchChatWindow() ) ); + connect( actionShowHideHelp, SIGNAL( triggered() ), this, SLOT( switchHelpWindow() ) ); + connect( actionShowHideLog, SIGNAL( triggered() ), this, SLOT( switchLogWindow() ) ); + connect( actionShowHideAway, SIGNAL( triggered() ), this, SLOT( switchAwayWindow() ) ); + connect( actionShowHideChance, SIGNAL( triggered() ), this, SLOT( switchChanceWindow() ) ); + + connect( pushButton_BetRaise, SIGNAL( clicked(bool) ), this, SLOT( pushButtonBetRaiseClicked(bool) ) ); + connect( pushButton_Fold, SIGNAL( clicked(bool) ), this, SLOT( pushButtonFoldClicked(bool) ) ); + connect( pushButton_CallCheck, SIGNAL( clicked(bool) ), this, SLOT( pushButtonCallCheckClicked(bool) ) ); + connect( pushButton_AllIn, SIGNAL( clicked(bool) ), this, SLOT(pushButtonAllInClicked(bool) ) ); + connect( horizontalSlider_bet, SIGNAL( valueChanged(int)), this, SLOT ( changeSpinBoxBetValue(int) ) ); + connect( spinBox_betValue, SIGNAL( valueChanged(int)), this, SLOT ( spinBoxBetValueChanged(int) ) ); + + connect( horizontalSlider_speed, SIGNAL( valueChanged(int)), this, SLOT ( setGameSpeed(int) ) ); + connect( pushButton_break, SIGNAL( clicked()), this, SLOT ( breakButtonClicked() ) ); // auch wieder starten!!!! + + connect( tabWidget_Left, SIGNAL( currentChanged(int) ), this, SLOT( tabSwitchAction() ) ); + connect( lineEdit_ChatInput, SIGNAL( returnPressed () ), this, SLOT( sendChatMessage() ) ); + connect( lineEdit_ChatInput, SIGNAL( textChanged (QString) ), this, SLOT( checkChatInputLength(QString) ) ); + connect( lineEdit_ChatInput, SIGNAL( textEdited (QString) ), myChat, SLOT( setChatTextEdited() ) ); + + connect( radioButton_manualAction, SIGNAL( clicked() ) , this, SLOT( changePlayingMode() ) ); + connect( radioButton_autoCheckFold, SIGNAL( clicked() ) , this, SLOT( changePlayingMode() ) ); + connect( radioButton_autoCheckCallAny, SIGNAL( clicked() ), this, SLOT( changePlayingMode() ) ); + + connect( pushButton_voteOnKickYes, SIGNAL( clicked() ), this, SLOT( voteOnKickYes() ) ); + connect( pushButton_voteOnKickNo, SIGNAL( clicked() ), this, SLOT( voteOnKickNo() ) ); + + connect( pushButton_showMyCards, SIGNAL( clicked() ), this, SLOT( sendShowMyCardsSignal() ) ); + for(i=0; i<=9; i++)connect( playerTipLabelArray[i], SIGNAL( linkActivated(QString) ), playerAvatarLabelArray[i], SLOT(startChangePlayerTip(QString) ) ); + for(i=0; i<=9; i++) { + for(int j=1; j<=5; j++) { + connect( playerStarsArray[j][i], SIGNAL( linkActivated(QString) ), playerAvatarLabelArray[i], SLOT(setPlayerRating(QString) ) ); + } + } + //Nachrichten Thread-Save + connect(this, SIGNAL(signalInitGui(int)), this, SLOT(initGui(int))); + connect(this, SIGNAL(signalRefreshSet()), this, SLOT(refreshSet())); + connect(this, SIGNAL(signalRefreshCash()), this, SLOT(refreshCash())); + connect(this, SIGNAL(signalRefreshAction(int, int)), this, SLOT(refreshAction(int, int))); + connect(this, SIGNAL(signalRefreshChangePlayer()), this, SLOT(refreshChangePlayer())); + connect(this, SIGNAL(signalRefreshPot()), this, SLOT(refreshPot())); + connect(this, SIGNAL(signalRefreshGroupbox(int, int)), this, SLOT(refreshGroupbox(int, int))); + connect(this, SIGNAL(signalRefreshAll()), this, SLOT(refreshAll())); + connect(this, SIGNAL(signalRefreshPlayerName()), this, SLOT(refreshPlayerName())); + connect(this, SIGNAL(signalRefreshButton()), this, SLOT(refreshButton())); + connect(this, SIGNAL(signalRefreshGameLabels(int)), this, SLOT(refreshGameLabels(int))); + connect(this, SIGNAL(signalSetPlayerAvatar(int, QString)), this, SLOT(setPlayerAvatar(int, QString))); + connect(this, SIGNAL(signalGuiUpdateDone()), this, SLOT(guiUpdateDone())); + connect(this, SIGNAL(signalMeInAction()), this, SLOT(meInAction())); + connect(this, SIGNAL(signalDisableMyButtons()), this, SLOT(disableMyButtons())); + connect(this, SIGNAL(signalUpdateMyButtonsState()), this, SLOT(updateMyButtonsState())); + connect(this, SIGNAL(signalStartTimeoutAnimation(int, int)), this, SLOT(startTimeoutAnimation(int, int))); + connect(this, SIGNAL(signalStopTimeoutAnimation(int)), this, SLOT(stopTimeoutAnimation(int))); + connect(this, SIGNAL(signalDealBeRoCards(int)), this, SLOT(dealBeRoCards(int))); + connect(this, SIGNAL(signalDealHoleCards()), this, SLOT(dealHoleCards())); + connect(this, SIGNAL(signalDealFlopCards0()), this, SLOT(dealFlopCards0())); + connect(this, SIGNAL(signalDealTurnCards0()), this, SLOT(dealTurnCards0())); + connect(this, SIGNAL(signalDealRiverCards0()), this, SLOT(dealRiverCards0())); + connect(this, SIGNAL(signalNextPlayerAnimation()), this, SLOT(nextPlayerAnimation())); + connect(this, SIGNAL(signalBeRoAnimation2(int)), this, SLOT(beRoAnimation2(int))); + connect(this, SIGNAL(signalPreflopAnimation1()), this, SLOT(preflopAnimation1())); + connect(this, SIGNAL(signalPreflopAnimation2()), this, SLOT(preflopAnimation2())); + connect(this, SIGNAL(signalFlopAnimation1()), this, SLOT(flopAnimation1())); + connect(this, SIGNAL(signalFlopAnimation2()), this, SLOT(flopAnimation2())); + connect(this, SIGNAL(signalTurnAnimation1()), this, SLOT(turnAnimation1())); + connect(this, SIGNAL(signalTurnAnimation2()), this, SLOT(turnAnimation2())); + connect(this, SIGNAL(signalRiverAnimation1()), this, SLOT(riverAnimation1())); + connect(this, SIGNAL(signalRiverAnimation2()), this, SLOT(riverAnimation2())); + connect(this, SIGNAL(signalPostRiverAnimation1()), this, SLOT(postRiverAnimation1())); + connect(this, SIGNAL(signalPostRiverRunAnimation1()), this, SLOT(postRiverRunAnimation1())); + connect(this, SIGNAL(signalPostRiverShowCards(unsigned)), this, SLOT(showHoleCards(unsigned))); + connect(this, SIGNAL(signalFlipHolecardsAllIn()), this, SLOT(flipHolecardsAllIn())); + connect(this, SIGNAL(signalNextRoundCleanGui()), this, SLOT(nextRoundCleanGui())); + connect(this, SIGNAL(signalStartVoteOnKick(unsigned, unsigned, int, int)), this, SLOT(startVoteOnKick(unsigned, unsigned, int, int))); + connect(this, SIGNAL(signalChangeVoteOnKickButtonsState(bool)), this, SLOT(changeVoteOnKickButtonsState(bool))); + connect(this, SIGNAL(signalEndVoteOnKick()), this, SLOT(endVoteOnKick())); + + connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned)), this, SLOT(netClientPlayerLeft(unsigned))); + connect(this, SIGNAL(signalWarningAutoFoldInRankingGame(unsigned)), this, SLOT(showWarningAutoFoldInRankingGame(unsigned))); } -gameTableImpl::~gameTableImpl() { +gameTableImpl::~gameTableImpl() +{ } -void gameTableImpl::callSettingsDialog() { myStartWindow->callSettingsDialog(); } +void gameTableImpl::callSettingsDialog() +{ + myStartWindow->callSettingsDialog(); +} -void gameTableImpl::applySettings(settingsDialogImpl* mySettingsDialog) { +void gameTableImpl::applySettings(settingsDialogImpl* mySettingsDialog) +{ - //apply card deck style - myCardDeckStyle->readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentCardDeckStyle").c_str())); - //apply game table style - myGameTableStyle->readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentGameTableStyle").c_str())); + //apply card deck style + myCardDeckStyle->readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentCardDeckStyle").c_str())); + //apply game table style + myGameTableStyle->readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentGameTableStyle").c_str())); - //Toolbox verstecken? - if (myConfig->readConfigInt("ShowLeftToolBox")) { groupBox_LeftToolBox->show(); } - else { groupBox_LeftToolBox->hide(); } + //Toolbox verstecken? + if (myConfig->readConfigInt("ShowLeftToolBox")) { + groupBox_LeftToolBox->show(); + } else { + groupBox_LeftToolBox->hide(); + } - if (myConfig->readConfigInt("ShowRightToolBox")) { groupBox_RightToolBox->show(); } - else { groupBox_RightToolBox->hide(); } + if (myConfig->readConfigInt("ShowRightToolBox")) { + groupBox_RightToolBox->show(); + } else { + groupBox_RightToolBox->hide(); + } - //cardschancemonitor show/hide - if (!myConfig->readConfigInt("ShowCardsChanceMonitor")) { - tabWidget_Right->removeTab(2); - tabWidget_Right->setCurrentIndex(0); - } - else { - if(tabWidget_Right->widget(2) != tab_Chance) - tabWidget_Right->insertTab(2, tab_Chance, QString(tr("Chance"))); - } + //cardschancemonitor show/hide + if (!myConfig->readConfigInt("ShowCardsChanceMonitor")) { + tabWidget_Right->removeTab(2); + tabWidget_Right->setCurrentIndex(0); + } else { + if(tabWidget_Right->widget(2) != tab_Chance) + tabWidget_Right->insertTab(2, tab_Chance, QString(tr("Chance"))); + } - //Add avatar (if set) + //Add avatar (if set) myStartWindow->getSession()->addOwnAvatar(QString::fromUtf8(myConfig->readConfigString("MyAvatar").c_str()).toLocal8Bit().constData()); - //Falls Spielernamen geändert wurden --> neu zeichnen --> erst beim nächsten Neustart neu ausgelesen - if (mySettingsDialog->getPlayerNickIsChanged() && myStartWindow->getSession()->getCurrentGame() && !myStartWindow->getSession()->isNetworkClientRunning()) { + //Falls Spielernamen geändert wurden --> neu zeichnen --> erst beim nächsten Neustart neu ausgelesen + if (mySettingsDialog->getPlayerNickIsChanged() && myStartWindow->getSession()->getCurrentGame() && !myStartWindow->getSession()->isNetworkClientRunning()) { boost::shared_ptr currentGame = myStartWindow->getSession()->getCurrentGame(); - PlayerListIterator it = currentGame->getSeatsList()->begin(); - (*it)->setMyName(mySettingsDialog->lineEdit_HumanPlayerName->text().toUtf8().constData()); - (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent1Name->text().toUtf8().constData()); - (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent2Name->text().toUtf8().constData()); - (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent3Name->text().toUtf8().constData()); - (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent4Name->text().toUtf8().constData()); - (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent5Name->text().toUtf8().constData()); - (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent6Name->text().toUtf8().constData()); - (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent7Name->text().toUtf8().constData()); - (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent8Name->text().toUtf8().constData()); - (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent9Name->text().toUtf8().constData()); - mySettingsDialog->setPlayerNickIsChanged(FALSE); + PlayerListIterator it = currentGame->getSeatsList()->begin(); + (*it)->setMyName(mySettingsDialog->lineEdit_HumanPlayerName->text().toUtf8().constData()); + (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent1Name->text().toUtf8().constData()); + (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent2Name->text().toUtf8().constData()); + (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent3Name->text().toUtf8().constData()); + (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent4Name->text().toUtf8().constData()); + (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent5Name->text().toUtf8().constData()); + (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent6Name->text().toUtf8().constData()); + (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent7Name->text().toUtf8().constData()); + (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent8Name->text().toUtf8().constData()); + (*(++it))->setMyName(mySettingsDialog->lineEdit_Opponent9Name->text().toUtf8().constData()); + mySettingsDialog->setPlayerNickIsChanged(FALSE); - refreshPlayerName(); - } + refreshPlayerName(); + } - if(myStartWindow->getSession()->getCurrentGame() && !myStartWindow->getSession()->isNetworkClientRunning()) { + if(myStartWindow->getSession()->getCurrentGame() && !myStartWindow->getSession()->isNetworkClientRunning()) { boost::shared_ptr currentGame = myStartWindow->getSession()->getCurrentGame(); - PlayerListIterator it = currentGame->getSeatsList()->begin(); - (*it)->setMyAvatar(mySettingsDialog->pushButton_HumanPlayerAvatar->getMyLink().toUtf8().constData()); - (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent1Avatar->getMyLink().toUtf8().constData()); - (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent2Avatar->getMyLink().toUtf8().constData()); - (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent3Avatar->getMyLink().toUtf8().constData()); - (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent4Avatar->getMyLink().toUtf8().constData()); - (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent5Avatar->getMyLink().toUtf8().constData()); - (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent6Avatar->getMyLink().toUtf8().constData()); - (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent7Avatar->getMyLink().toUtf8().constData()); - (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent8Avatar->getMyLink().toUtf8().constData()); - (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent9Avatar->getMyLink().toUtf8().constData()); + PlayerListIterator it = currentGame->getSeatsList()->begin(); + (*it)->setMyAvatar(mySettingsDialog->pushButton_HumanPlayerAvatar->getMyLink().toUtf8().constData()); + (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent1Avatar->getMyLink().toUtf8().constData()); + (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent2Avatar->getMyLink().toUtf8().constData()); + (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent3Avatar->getMyLink().toUtf8().constData()); + (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent4Avatar->getMyLink().toUtf8().constData()); + (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent5Avatar->getMyLink().toUtf8().constData()); + (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent6Avatar->getMyLink().toUtf8().constData()); + (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent7Avatar->getMyLink().toUtf8().constData()); + (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent8Avatar->getMyLink().toUtf8().constData()); + (*(++it))->setMyAvatar(mySettingsDialog->pushButton_Opponent9Avatar->getMyLink().toUtf8().constData()); - //avatar refresh - refreshPlayerAvatar(); - } + //avatar refresh + refreshPlayerAvatar(); + } - //refresh board cards if game is running - if(myStartWindow->getSession()->getCurrentGame()) { + //refresh board cards if game is running + if(myStartWindow->getSession()->getCurrentGame()) { - int tempBoardCardsArray[5]; - myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray); - GameState currentState = myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->getMyBeRoID(); - if(currentState >= GAME_STATE_FLOP && currentState <= GAME_STATE_POST_RIVER) - for(int i=0; i<3; i++) { - QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[i], 10)+".png")); - boardCardsArray[i]->setPixmap(card, FALSE); - } - if(currentState >= GAME_STATE_TURN && currentState <= GAME_STATE_POST_RIVER) { - QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[3], 10)+".png")); - boardCardsArray[3]->setPixmap(card, FALSE); - } - if(currentState == GAME_STATE_RIVER || currentState == GAME_STATE_POST_RIVER) { - QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[4], 10)+".png")); - boardCardsArray[4]->setPixmap(card, FALSE); - } - } + int tempBoardCardsArray[5]; + myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray); + GameState currentState = myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->getMyBeRoID(); + if(currentState >= GAME_STATE_FLOP && currentState <= GAME_STATE_POST_RIVER) + for(int i=0; i<3; i++) { + QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[i], 10)+".png")); + boardCardsArray[i]->setPixmap(card, FALSE); + } + if(currentState >= GAME_STATE_TURN && currentState <= GAME_STATE_POST_RIVER) { + QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[3], 10)+".png")); + boardCardsArray[3]->setPixmap(card, FALSE); + } + if(currentState == GAME_STATE_RIVER || currentState == GAME_STATE_POST_RIVER) { + QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[4], 10)+".png")); + boardCardsArray[4]->setPixmap(card, FALSE); + } + } - //Flipside refresh - if (myConfig->readConfigInt("FlipsideOwn") && myConfig->readConfigString("FlipsideOwnFile") != "") { - flipside = QPixmap::fromImage(QImage(QString::fromUtf8(myConfig->readConfigString("FlipsideOwnFile").c_str()))); - } - else { - flipside = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+"flipside.png")); - } - int j,k; - for (j=1; jgetIsFlipside()) { - holeCardsArray[j][k]->setPixmap(flipside, TRUE); - } - } - } + //Flipside refresh + if (myConfig->readConfigInt("FlipsideOwn") && myConfig->readConfigString("FlipsideOwnFile") != "") { + flipside = QPixmap::fromImage(QImage(QString::fromUtf8(myConfig->readConfigString("FlipsideOwnFile").c_str()))); + } else { + flipside = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+"flipside.png")); + } + int j,k; + for (j=1; jgetIsFlipside()) { + holeCardsArray[j][k]->setPixmap(flipside, TRUE); + } + } + } - //Check for anti-peek mode - if(myStartWindow->getSession()->getCurrentGame()) { - // check if human player is already active - boost::shared_ptr humanPlayer = myStartWindow->getSession()->getCurrentGame()->getSeatsList()->front(); - if(humanPlayer->getMyActiveStatus()) { + //Check for anti-peek mode + if(myStartWindow->getSession()->getCurrentGame()) { + // check if human player is already active + boost::shared_ptr humanPlayer = myStartWindow->getSession()->getCurrentGame()->getSeatsList()->front(); + if(humanPlayer->getMyActiveStatus()) { - QPixmap tempCardsPixmapArray[2]; - int tempCardsIntArray[2]; + QPixmap tempCardsPixmapArray[2]; + int tempCardsIntArray[2]; - humanPlayer->getMyCards(tempCardsIntArray); - if(myConfig->readConfigInt("AntiPeekMode")) { - holeCardsArray[0][0]->setPixmap(flipside, TRUE); - tempCardsPixmapArray[0] = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempCardsIntArray[0], 10)+".png")); - holeCardsArray[0][0]->setHiddenFrontPixmap(tempCardsPixmapArray[0]); - holeCardsArray[0][1]->setPixmap(flipside, TRUE); - tempCardsPixmapArray[1]= QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempCardsIntArray[1], 10)+".png")); - holeCardsArray[0][1]->setHiddenFrontPixmap(tempCardsPixmapArray[1]); - } - else { - tempCardsPixmapArray[0]= QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempCardsIntArray[0], 10)+".png")); - holeCardsArray[0][0]->setPixmap(tempCardsPixmapArray[0],FALSE); - tempCardsPixmapArray[1]= QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempCardsIntArray[1], 10)+".png")); - holeCardsArray[0][1]->setPixmap(tempCardsPixmapArray[1],FALSE); - } - } - } + humanPlayer->getMyCards(tempCardsIntArray); + if(myConfig->readConfigInt("AntiPeekMode")) { + holeCardsArray[0][0]->setPixmap(flipside, TRUE); + tempCardsPixmapArray[0] = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempCardsIntArray[0], 10)+".png")); + holeCardsArray[0][0]->setHiddenFrontPixmap(tempCardsPixmapArray[0]); + holeCardsArray[0][1]->setPixmap(flipside, TRUE); + tempCardsPixmapArray[1]= QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempCardsIntArray[1], 10)+".png")); + holeCardsArray[0][1]->setHiddenFrontPixmap(tempCardsPixmapArray[1]); + } else { + tempCardsPixmapArray[0]= QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempCardsIntArray[0], 10)+".png")); + holeCardsArray[0][0]->setPixmap(tempCardsPixmapArray[0],FALSE); + tempCardsPixmapArray[1]= QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempCardsIntArray[1], 10)+".png")); + holeCardsArray[0][1]->setPixmap(tempCardsPixmapArray[1],FALSE); + } + } + } - refreshGameTableStyle(); - // qDebug() << "table: " << myGameTableStyle->getStyleDescription() << myGameTableStyle->getState(); - if(this->isVisible() && myGameTableStyle->getState() != GT_STYLE_OK) myGameTableStyle->showErrorMessage(); + refreshGameTableStyle(); + // qDebug() << "table: " << myGameTableStyle->getStyleDescription() << myGameTableStyle->getState(); + if(this->isVisible() && myGameTableStyle->getState() != GT_STYLE_OK) myGameTableStyle->showErrorMessage(); - //blind buttons refresh - if(myStartWindow->getSession()->getCurrentGame()) { - refreshButton(); - refreshGroupbox(); - provideMyActions(); - } + //blind buttons refresh + if(myStartWindow->getSession()->getCurrentGame()) { + refreshButton(); + refreshGroupbox(); + provideMyActions(); + } - // Re-init audio. - mySDLPlayer->audioDone(); - mySDLPlayer->initAudio(); + // Re-init audio. + mySDLPlayer->audioDone(); + mySDLPlayer->initAudio(); } void gameTableImpl::initGui(int speed) { - //kill running Singleshots!!! - stopTimer(); + //kill running Singleshots!!! + stopTimer(); - label_Pot->setText(PotString); - label_Total->setText(TotalString+":"); - label_Sets->setText(BetsString+":"); - label_handNumber->setText(HandString+":"); - label_gameNumber->setText(GameString+":"); + label_Pot->setText(PotString); + label_Total->setText(TotalString+":"); + label_Sets->setText(BetsString+":"); + label_handNumber->setText(HandString+":"); + label_gameNumber->setText(GameString+":"); - groupBox_RightToolBox->setDisabled(FALSE); - groupBox_LeftToolBox->setDisabled(FALSE); + groupBox_RightToolBox->setDisabled(FALSE); + groupBox_LeftToolBox->setDisabled(FALSE); - //show human player buttons - for(int i=0; i<6; i++) { - userWidgetsArray[i]->show(); - } + //show human player buttons + for(int i=0; i<6; i++) { + userWidgetsArray[i]->show(); + } - //set minimum gui speed to prevent gui lags on fast inet games - if( myStartWindow->getSession()->isNetworkClientRunning() ) { horizontalSlider_speed->setMinimum(speed); } - else { horizontalSlider_speed->setMinimum(1); } + //set minimum gui speed to prevent gui lags on fast inet games + if( myStartWindow->getSession()->isNetworkClientRunning() ) { + horizontalSlider_speed->setMinimum(speed); + } else { + horizontalSlider_speed->setMinimum(1); + } - //set speeds for local game and for first network game - if( !myStartWindow->getSession()->isNetworkClientRunning() || (myStartWindow->getSession()->isNetworkClientRunning() && !myStartWindow->getSession()->getCurrentGame()) ) { + //set speeds for local game and for first network game + if( !myStartWindow->getSession()->isNetworkClientRunning() || (myStartWindow->getSession()->isNetworkClientRunning() && !myStartWindow->getSession()->getCurrentGame()) ) { - guiGameSpeed = speed; - //positioning Slider - horizontalSlider_speed->setValue(guiGameSpeed); - setSpeeds(); - } + guiGameSpeed = speed; + //positioning Slider + horizontalSlider_speed->setValue(guiGameSpeed); + setSpeeds(); + } - //set session for chat - myChat->setSession(this->getSession()); + //set session for chat + myChat->setSession(this->getSession()); } -boost::shared_ptr gameTableImpl::getSession() { assert(myStartWindow->getSession().get()); return myStartWindow->getSession(); } +boost::shared_ptr gameTableImpl::getSession() +{ + assert(myStartWindow->getSession().get()); + return myStartWindow->getSession(); +} //refresh-Funktionen -void gameTableImpl::refreshSet() { +void gameTableImpl::refreshSet() +{ boost::shared_ptr currentGame = myStartWindow->getSession()->getCurrentGame(); - PlayerListConstIterator it_c; - PlayerList seatsList = currentGame->getSeatsList(); + PlayerListConstIterator it_c; + PlayerList seatsList = currentGame->getSeatsList(); for (it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c) { - if( (*it_c)->getMySet() == 0 ) - setLabelArray[(*it_c)->getMyID()]->setText(""); - else - setLabelArray[(*it_c)->getMyID()]->setText("$"+QString("%L1").arg((*it_c)->getMySet())); - } + if( (*it_c)->getMySet() == 0 ) + setLabelArray[(*it_c)->getMyID()]->setText(""); + else + setLabelArray[(*it_c)->getMyID()]->setText("$"+QString("%L1").arg((*it_c)->getMySet())); + } } -void gameTableImpl::refreshButton() { +void gameTableImpl::refreshButton() +{ - QPixmap dealerButton = QPixmap::fromImage(QImage(myGameTableStyle->getDealerPuck())); - QPixmap smallblindButton = QPixmap::fromImage(QImage(myGameTableStyle->getSmallBlindPuck())); - QPixmap bigblindButton = QPixmap::fromImage(QImage(myGameTableStyle->getBigBlindPuck())); - QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png")); + QPixmap dealerButton = QPixmap::fromImage(QImage(myGameTableStyle->getDealerPuck())); + QPixmap smallblindButton = QPixmap::fromImage(QImage(myGameTableStyle->getSmallBlindPuck())); + QPixmap bigblindButton = QPixmap::fromImage(QImage(myGameTableStyle->getBigBlindPuck())); + QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png")); boost::shared_ptr currentGame = myStartWindow->getSession()->getCurrentGame(); - PlayerListConstIterator it_c; - PlayerList seatsList = currentGame->getSeatsList(); - PlayerList activePlayerList = currentGame->getActivePlayerList(); + PlayerListConstIterator it_c; + PlayerList seatsList = currentGame->getSeatsList(); + PlayerList activePlayerList = currentGame->getActivePlayerList(); for (it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c) { - if( (*it_c)->getMyActiveStatus() ) { - if( activePlayerList->size() > 2 ) { - switch ( (*it_c)->getMyButton() ) { + if( (*it_c)->getMyActiveStatus() ) { + if( activePlayerList->size() > 2 ) { + switch ( (*it_c)->getMyButton() ) { - case 1 : buttonLabelArray[(*it_c)->getMyID()]->setPixmap(dealerButton); - break; - case 2 : { - if(myConfig->readConfigInt("ShowBlindButtons")) - buttonLabelArray[(*it_c)->getMyID()]->setPixmap(smallblindButton); - else - buttonLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); - } - break; - case 3 : { - if(myConfig->readConfigInt("ShowBlindButtons")) - buttonLabelArray[(*it_c)->getMyID()]->setPixmap(bigblindButton); - else - buttonLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); - } - break; - default: buttonLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); + case 1 : + buttonLabelArray[(*it_c)->getMyID()]->setPixmap(dealerButton); + break; + case 2 : { + if(myConfig->readConfigInt("ShowBlindButtons")) + buttonLabelArray[(*it_c)->getMyID()]->setPixmap(smallblindButton); + else + buttonLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); + } + break; + case 3 : { + if(myConfig->readConfigInt("ShowBlindButtons")) + buttonLabelArray[(*it_c)->getMyID()]->setPixmap(bigblindButton); + else + buttonLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); + } + break; + default: + buttonLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); - } - } - else { - switch ((*it_c)->getMyButton()) { + } + } else { + switch ((*it_c)->getMyButton()) { - case 2 : buttonLabelArray[(*it_c)->getMyID()]->setPixmap(dealerButton); - break; - case 3 : { - if(myConfig->readConfigInt("ShowBlindButtons")) - buttonLabelArray[(*it_c)->getMyID()]->setPixmap(bigblindButton); - else - buttonLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); - } - break; - default: buttonLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); + case 2 : + buttonLabelArray[(*it_c)->getMyID()]->setPixmap(dealerButton); + break; + case 3 : { + if(myConfig->readConfigInt("ShowBlindButtons")) + buttonLabelArray[(*it_c)->getMyID()]->setPixmap(bigblindButton); + else + buttonLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); + } + break; + default: + buttonLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); - } - } - } - else { buttonLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); } - } + } + } + } else { + buttonLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); + } + } } -void gameTableImpl::refreshPlayerName() { +void gameTableImpl::refreshPlayerName() +{ - if(myStartWindow->getSession()->getCurrentGame()) { + if(myStartWindow->getSession()->getCurrentGame()) { - boost::shared_ptr currentGame = myStartWindow->getSession()->getCurrentGame(); - PlayerListConstIterator it_c; + boost::shared_ptr currentGame = myStartWindow->getSession()->getCurrentGame(); + PlayerListConstIterator it_c; PlayerList seatsList = currentGame->getSeatsList(); for (it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c) { - if((*it_c)->getMyActiveStatus()) { + if((*it_c)->getMyActiveStatus()) { - bool guest = myStartWindow->getSession()->getClientPlayerInfo((*it_c)->getMyUniqueID()).isGuest; - bool computerPlayer = false; - if((*it_c)->getMyType() == PLAYER_TYPE_COMPUTER) { computerPlayer = true; } + bool guest = myStartWindow->getSession()->getClientPlayerInfo((*it_c)->getMyUniqueID()).isGuest; + bool computerPlayer = false; + if((*it_c)->getMyType() == PLAYER_TYPE_COMPUTER) { + computerPlayer = true; + } - playerNameLabelArray[(*it_c)->getMyID()]->setText(QString::fromUtf8((*it_c)->getMyName().c_str()), FALSE, guest, computerPlayer ); + playerNameLabelArray[(*it_c)->getMyID()]->setText(QString::fromUtf8((*it_c)->getMyName().c_str()), FALSE, guest, computerPlayer ); - } - else { - if((myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK)) { - if((*it_c)->getMyStayOnTableStatus() == TRUE && (*it_c)->getMyType() != PLAYER_TYPE_COMPUTER) { + } else { + if((myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK)) { + if((*it_c)->getMyStayOnTableStatus() == TRUE && (*it_c)->getMyType() != PLAYER_TYPE_COMPUTER) { - bool guest = myStartWindow->getSession()->getClientPlayerInfo((*it_c)->getMyUniqueID()).isGuest; - bool computerPlayer = false; - if((*it_c)->getMyType() == PLAYER_TYPE_COMPUTER) { computerPlayer = true; } - playerNameLabelArray[(*it_c)->getMyID()]->setText(QString::fromUtf8((*it_c)->getMyName().c_str()), TRUE, guest, computerPlayer); + bool guest = myStartWindow->getSession()->getClientPlayerInfo((*it_c)->getMyUniqueID()).isGuest; + bool computerPlayer = false; + if((*it_c)->getMyType() == PLAYER_TYPE_COMPUTER) { + computerPlayer = true; + } + playerNameLabelArray[(*it_c)->getMyID()]->setText(QString::fromUtf8((*it_c)->getMyName().c_str()), TRUE, guest, computerPlayer); - - } - else { - playerNameLabelArray[(*it_c)->getMyID()]->setText(""); - } - } - else { - playerNameLabelArray[(*it_c)->getMyID()]->setText(""); - } - } - } - } - playerAvatarLabelArray[0]->refreshTooltips(); + } else { + playerNameLabelArray[(*it_c)->getMyID()]->setText(""); + } + } else { + playerNameLabelArray[(*it_c)->getMyID()]->setText(""); + } + } + } + } + + playerAvatarLabelArray[0]->refreshTooltips(); } -void gameTableImpl::refreshPlayerAvatar() { +void gameTableImpl::refreshPlayerAvatar() +{ - if(myStartWindow->getSession()->getCurrentGame()) { + if(myStartWindow->getSession()->getCurrentGame()) { - QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png")); + QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png")); boost::shared_ptr currentGame = myStartWindow->getSession()->getCurrentGame(); int seatPlace; @@ -917,2635 +946,2867 @@ void gameTableImpl::refreshPlayerAvatar() { PlayerList seatsList = currentGame->getSeatsList(); for (it_c=seatsList->begin(), seatPlace=0; it_c!=seatsList->end(); ++it_c, seatPlace++) { - QString countryString(QString(myStartWindow->getSession()->getClientPlayerInfo((*it_c)->getMyUniqueID()).countryCode.c_str()).toLower()); - countryString = QString(":/cflags/cflags/%1.png").arg(countryString); + QString countryString(QString(myStartWindow->getSession()->getClientPlayerInfo((*it_c)->getMyUniqueID()).countryCode.c_str()).toLower()); + countryString = QString(":/cflags/cflags/%1.png").arg(countryString); - if((*it_c)->getMyActiveStatus()) { + if((*it_c)->getMyActiveStatus()) { QFile myAvatarFile(QString::fromUtf8((*it_c)->getMyAvatar().c_str())); - if((*it_c)->getMyAvatar() == "" || !myAvatarFile.exists()) { - playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmapAndCountry(QPixmap::fromImage(QImage(myGameTableStyle->getDefaultAvatar())),countryString,seatPlace); - } - else { - playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmapAndCountry(QPixmap::fromImage(QImage(QString::fromUtf8((*it_c)->getMyAvatar().c_str()))),countryString,seatPlace); - } - } - else { - if((myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK)) { - if((*it_c)->getMyStayOnTableStatus() == TRUE && (*it_c)->getMyType() != PLAYER_TYPE_COMPUTER) { + if((*it_c)->getMyAvatar() == "" || !myAvatarFile.exists()) { + playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmapAndCountry(QPixmap::fromImage(QImage(myGameTableStyle->getDefaultAvatar())),countryString,seatPlace); + } else { + playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmapAndCountry(QPixmap::fromImage(QImage(QString::fromUtf8((*it_c)->getMyAvatar().c_str()))),countryString,seatPlace); + } + } else { + if((myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK)) { + if((*it_c)->getMyStayOnTableStatus() == TRUE && (*it_c)->getMyType() != PLAYER_TYPE_COMPUTER) { QFile myAvatarFile(QString::fromUtf8((*it_c)->getMyAvatar().c_str())); - if((*it_c)->getMyAvatar() == "" || !myAvatarFile.exists()) { - playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmapAndCountry(QPixmap::fromImage(QImage(myGameTableStyle->getDefaultAvatar())), countryString, seatPlace, TRUE); - } - else { - playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmapAndCountry(QPixmap::fromImage(QImage(QString::fromUtf8((*it_c)->getMyAvatar().c_str()))),countryString,seatPlace, TRUE); - } - } - else { - playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); - } - } - else { - playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); - } - } - } - } + if((*it_c)->getMyAvatar() == "" || !myAvatarFile.exists()) { + playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmapAndCountry(QPixmap::fromImage(QImage(myGameTableStyle->getDefaultAvatar())), countryString, seatPlace, TRUE); + } else { + playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmapAndCountry(QPixmap::fromImage(QImage(QString::fromUtf8((*it_c)->getMyAvatar().c_str()))),countryString,seatPlace, TRUE); + } + } else { + playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); + } + } else { + playerAvatarLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); + } + } + } + } } -void gameTableImpl::setPlayerAvatar(int myID, QString myAvatar) { +void gameTableImpl::setPlayerAvatar(int myID, QString myAvatar) +{ - if(myStartWindow->getSession()->getCurrentGame()) { + if(myStartWindow->getSession()->getCurrentGame()) { - boost::shared_ptr tmpPlayer = myStartWindow->getSession()->getCurrentGame()->getPlayerByUniqueId(myID); - if (tmpPlayer.get()) { + boost::shared_ptr tmpPlayer = myStartWindow->getSession()->getCurrentGame()->getPlayerByUniqueId(myID); + if (tmpPlayer.get()) { - QFile myAvatarFile(myAvatar); - if(myAvatarFile.exists()) { - playerAvatarLabelArray[tmpPlayer->getMyID()]->setPixmap(myAvatar); - tmpPlayer->setMyAvatar(myAvatar.toUtf8().constData()); - } - else { - playerAvatarLabelArray[tmpPlayer->getMyID()]->setPixmap(QPixmap::fromImage(QImage(myGameTableStyle->getDefaultAvatar()))); - tmpPlayer->setMyAvatar(""); - } - } - } + QFile myAvatarFile(myAvatar); + if(myAvatarFile.exists()) { + playerAvatarLabelArray[tmpPlayer->getMyID()]->setPixmap(myAvatar); + tmpPlayer->setMyAvatar(myAvatar.toUtf8().constData()); + } else { + playerAvatarLabelArray[tmpPlayer->getMyID()]->setPixmap(QPixmap::fromImage(QImage(myGameTableStyle->getDefaultAvatar()))); + tmpPlayer->setMyAvatar(""); + } + } + } } -void gameTableImpl::refreshAction(int playerID, int playerAction) { +void gameTableImpl::refreshAction(int playerID, int playerAction) +{ - QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png")); - QPixmap action; + QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png")); + QPixmap action; - QStringList actionArray; - actionArray << "" << "fold" << "check" << "call" << "bet" << "raise" << "allin"; + QStringList actionArray; + actionArray << "" << "fold" << "check" << "call" << "bet" << "raise" << "allin"; boost::shared_ptr currentGame = myStartWindow->getSession()->getCurrentGame(); - if(playerID == -1 || playerAction == -1) { + if(playerID == -1 || playerAction == -1) { - PlayerListConstIterator it_c; + PlayerListConstIterator it_c; PlayerList seatsList = currentGame->getSeatsList(); for (it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c) { - //if no action --> clear Pixmap - if( (*it_c)->getMyAction() == 0) { - actionLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); - } - else { - //paint action pixmap - actionLabelArray[(*it_c)->getMyID()]->setPixmap(QPixmap::fromImage(QImage(myGameTableStyle->getActionPic((*it_c)->getMyAction())))); - } + //if no action --> clear Pixmap + if( (*it_c)->getMyAction() == 0) { + actionLabelArray[(*it_c)->getMyID()]->setPixmap(onePix); + } else { + //paint action pixmap + actionLabelArray[(*it_c)->getMyID()]->setPixmap(QPixmap::fromImage(QImage(myGameTableStyle->getActionPic((*it_c)->getMyAction())))); + } - if ((*it_c)->getMyAction()==1) { + if ((*it_c)->getMyAction()==1) { - if((*it_c)->getMyID() != 0) { - holeCardsArray[(*it_c)->getMyID()][0]->setPixmap(onePix, FALSE); - holeCardsArray[(*it_c)->getMyID()][1]->setPixmap(onePix, FALSE); - } - } - } - } - else { - //if no action --> clear Pixmap - if(playerAction == 0) { - actionLabelArray[playerID]->setPixmap(onePix); - } - else { + if((*it_c)->getMyID() != 0) { + holeCardsArray[(*it_c)->getMyID()][0]->setPixmap(onePix, FALSE); + holeCardsArray[(*it_c)->getMyID()][1]->setPixmap(onePix, FALSE); + } + } + } + } else { + //if no action --> clear Pixmap + if(playerAction == 0) { + actionLabelArray[playerID]->setPixmap(onePix); + } else { - // paint action pixmap and raise - actionLabelArray[playerID]->setPixmap(QPixmap::fromImage(QImage(myGameTableStyle->getActionPic(playerAction)))); + // paint action pixmap and raise + actionLabelArray[playerID]->setPixmap(QPixmap::fromImage(QImage(myGameTableStyle->getActionPic(playerAction)))); - //play sounds if exist - if(myConfig->readConfigInt("PlayGameActions")) - mySDLPlayer->playSound(actionArray[playerAction].toStdString(), playerID); - } + //play sounds if exist + if(myConfig->readConfigInt("PlayGameActions")) + mySDLPlayer->playSound(actionArray[playerAction].toStdString(), playerID); + } - if (playerAction == 1) { // FOLD + if (playerAction == 1) { // FOLD - if (playerID == 0) { - holeCardsArray[0][0]->startFadeOut(10); - holeCardsArray[0][1]->startFadeOut(10); - } - else { - holeCardsArray[playerID][0]->setPixmap(onePix, FALSE); - holeCardsArray[playerID][1]->setPixmap(onePix, FALSE); - } - } - } + if (playerID == 0) { + holeCardsArray[0][0]->startFadeOut(10); + holeCardsArray[0][1]->startFadeOut(10); + } else { + holeCardsArray[playerID][0]->setPixmap(onePix, FALSE); + holeCardsArray[playerID][1]->setPixmap(onePix, FALSE); + } + } + } } -void gameTableImpl::refreshCash() { +void gameTableImpl::refreshCash() +{ boost::shared_ptr currentGame = myStartWindow->getSession()->getCurrentGame(); - PlayerListConstIterator it_c; + PlayerListConstIterator it_c; PlayerList seatsList = currentGame->getSeatsList(); for (it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c) { - if((*it_c)->getMyActiveStatus()) { + if((*it_c)->getMyActiveStatus()) { - cashLabelArray[(*it_c)->getMyID()]->setText("$"+QString("%L1").arg((*it_c)->getMyCash())); + cashLabelArray[(*it_c)->getMyID()]->setText("$"+QString("%L1").arg((*it_c)->getMyCash())); - } else { - cashLabelArray[(*it_c)->getMyID()]->setText(""); - } - } + } else { + cashLabelArray[(*it_c)->getMyID()]->setText(""); + } + } } -void gameTableImpl::refreshGroupbox(int playerID, int status) { +void gameTableImpl::refreshGroupbox(int playerID, int status) +{ - int j; + int j; - if(playerID == -1 || status == -1) { + if(playerID == -1 || status == -1) { boost::shared_ptr currentGame = myStartWindow->getSession()->getCurrentGame(); - PlayerListConstIterator it_c; + PlayerListConstIterator it_c; PlayerList seatsList = currentGame->getSeatsList(); for (it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c) { - if((*it_c)->getMyTurn()) { - //Groupbox glow wenn der Spiele dran ist. - myGameTableStyle->setPlayerSeatActiveStyle(groupBoxArray[(*it_c)->getMyID()]); - } else { - //Groupbox auf Hintergrundfarbe setzen wenn der Spiele nicht dran aber aktiv ist. - if((*it_c)->getMyActiveStatus()) { - if((*it_c)->getMyID()==0) { - //show buttons - for(j=0; j<6; j++) { - userWidgetsArray[j]->show(); - } - } - myGameTableStyle->setPlayerSeatInactiveStyle(groupBoxArray[(*it_c)->getMyID()]); + if((*it_c)->getMyTurn()) { + //Groupbox glow wenn der Spiele dran ist. + myGameTableStyle->setPlayerSeatActiveStyle(groupBoxArray[(*it_c)->getMyID()]); + } else { + //Groupbox auf Hintergrundfarbe setzen wenn der Spiele nicht dran aber aktiv ist. + if((*it_c)->getMyActiveStatus()) { + if((*it_c)->getMyID()==0) { + //show buttons + for(j=0; j<6; j++) { + userWidgetsArray[j]->show(); + } + } + myGameTableStyle->setPlayerSeatInactiveStyle(groupBoxArray[(*it_c)->getMyID()]); - } - //Groupbox verdunkeln wenn der Spiele inactive ist. - else { - if((*it_c)->getMyID()==0) { - //hide buttons - for(j=0; j<6; j++) { - userWidgetsArray[j]->hide(); - } - //disable anti-peek front after player is out - holeCardsArray[0][0]->signalFastFlipCards(FALSE); - holeCardsArray[0][1]->signalFastFlipCards(FALSE); - } - myGameTableStyle->setPlayerSeatInactiveStyle(groupBoxArray[(*it_c)->getMyID()]); - } - } - } - } - else { - switch(status) { + } + //Groupbox verdunkeln wenn der Spiele inactive ist. + else { + if((*it_c)->getMyID()==0) { + //hide buttons + for(j=0; j<6; j++) { + userWidgetsArray[j]->hide(); + } + //disable anti-peek front after player is out + holeCardsArray[0][0]->signalFastFlipCards(FALSE); + holeCardsArray[0][1]->signalFastFlipCards(FALSE); + } + myGameTableStyle->setPlayerSeatInactiveStyle(groupBoxArray[(*it_c)->getMyID()]); + } + } + } + } else { + switch(status) { - //inactive - case 0: { - if (!playerID) { - //hide buttons - for(j=0; j<6; j++) { - userWidgetsArray[j]->hide(); - } - //disable anti-peek front after player is out - holeCardsArray[0][0]->signalFastFlipCards(FALSE); - holeCardsArray[0][1]->signalFastFlipCards(FALSE); - } - myGameTableStyle->setPlayerSeatInactiveStyle(groupBoxArray[playerID]); - } - break; - //active but fold - case 1: { - if (!playerID) { - //show buttons - for(j=0; j<6; j++) { - userWidgetsArray[j]->show(); - } - } - myGameTableStyle->setPlayerSeatInactiveStyle(groupBoxArray[playerID]); - } - break; - //active in action - case 2: { - myGameTableStyle->setPlayerSeatActiveStyle(groupBoxArray[playerID]); - } - break; - //active not in action - case 3: { - myGameTableStyle->setPlayerSeatInactiveStyle(groupBoxArray[playerID]); - } - break; - default: {} - } - } + //inactive + case 0: { + if (!playerID) { + //hide buttons + for(j=0; j<6; j++) { + userWidgetsArray[j]->hide(); + } + //disable anti-peek front after player is out + holeCardsArray[0][0]->signalFastFlipCards(FALSE); + holeCardsArray[0][1]->signalFastFlipCards(FALSE); + } + myGameTableStyle->setPlayerSeatInactiveStyle(groupBoxArray[playerID]); + } + break; + //active but fold + case 1: { + if (!playerID) { + //show buttons + for(j=0; j<6; j++) { + userWidgetsArray[j]->show(); + } + } + myGameTableStyle->setPlayerSeatInactiveStyle(groupBoxArray[playerID]); + } + break; + //active in action + case 2: { + myGameTableStyle->setPlayerSeatActiveStyle(groupBoxArray[playerID]); + } + break; + //active not in action + case 3: { + myGameTableStyle->setPlayerSeatInactiveStyle(groupBoxArray[playerID]); + } + break; + default: + {} + } + } } -void gameTableImpl::refreshGameLabels(int gameState) { +void gameTableImpl::refreshGameLabels(int gameState) +{ - switch(gameState) { - case 0: { - textLabel_handLabel->setText(PreflopString); - } break; - case 1: { - textLabel_handLabel->setText(FlopString); - } break; - case 2: { - textLabel_handLabel->setText(TurnString); - } break; - case 3: { - textLabel_handLabel->setText(RiverString); - } break; - case 4: { - textLabel_handLabel->setText(""); - } break; - default: { - textLabel_handLabel->setText("!!! ERROR !!!"); - } - } + switch(gameState) { + case 0: { + textLabel_handLabel->setText(PreflopString); + } + break; + case 1: { + textLabel_handLabel->setText(FlopString); + } + break; + case 2: { + textLabel_handLabel->setText(TurnString); + } + break; + case 3: { + textLabel_handLabel->setText(RiverString); + } + break; + case 4: { + textLabel_handLabel->setText(""); + } + break; + default: { + textLabel_handLabel->setText("!!! ERROR !!!"); + } + } - label_handNumberValue->setText(QString::number(myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getMyID(),10)); - label_gameNumberValue->setText(QString::number(myStartWindow->getSession()->getCurrentGame()->getMyGameID(),10)); + label_handNumberValue->setText(QString::number(myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getMyID(),10)); + label_gameNumberValue->setText(QString::number(myStartWindow->getSession()->getCurrentGame()->getMyGameID(),10)); } -void gameTableImpl::refreshAll() { +void gameTableImpl::refreshAll() +{ - refreshSet(); - refreshButton(); + refreshSet(); + refreshButton(); boost::shared_ptr currentGame = myStartWindow->getSession()->getCurrentGame(); - PlayerListConstIterator it_c; + PlayerListConstIterator it_c; PlayerList seatsList = currentGame->getSeatsList(); for (it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c) { - refreshAction( (*it_c)->getMyID(), (*it_c)->getMyAction()); - } + refreshAction( (*it_c)->getMyID(), (*it_c)->getMyAction()); + } - refreshCash(); - refreshGroupbox(); - refreshPlayerName(); - refreshPlayerAvatar(); + refreshCash(); + refreshGroupbox(); + refreshPlayerName(); + refreshPlayerAvatar(); } -void gameTableImpl::refreshChangePlayer() { +void gameTableImpl::refreshChangePlayer() +{ - refreshSet(); + refreshSet(); boost::shared_ptr currentGame = myStartWindow->getSession()->getCurrentGame(); - PlayerListConstIterator it_c; + PlayerListConstIterator it_c; PlayerList seatsList = currentGame->getSeatsList(); for (it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c) { - refreshAction( (*it_c)->getMyID(), (*it_c)->getMyAction()); - } + refreshAction( (*it_c)->getMyID(), (*it_c)->getMyAction()); + } - refreshCash(); + refreshCash(); } -void gameTableImpl::refreshPot() { - boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); +void gameTableImpl::refreshPot() +{ + boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); - textLabel_Sets->setText("$"+QString("%L1").arg(currentHand->getBoard()->getSets())); - textLabel_Pot->setText("$"+QString("%L1").arg(currentHand->getBoard()->getPot())); + textLabel_Sets->setText("$"+QString("%L1").arg(currentHand->getBoard()->getSets())); + textLabel_Pot->setText("$"+QString("%L1").arg(currentHand->getBoard()->getPot())); } -void gameTableImpl::guiUpdateDone() { - guiUpdateSemaphore.release(); +void gameTableImpl::guiUpdateDone() +{ + guiUpdateSemaphore.release(); } -void gameTableImpl::waitForGuiUpdateDone() { - guiUpdateSemaphore.acquire(); +void gameTableImpl::waitForGuiUpdateDone() +{ + guiUpdateSemaphore.acquire(); } -void gameTableImpl::dealHoleCards() { +void gameTableImpl::dealHoleCards() +{ - int i,k; - for (i=0; isetFadeOutAction(FALSE); - holeCardsArray[i][k]->stopFlipCardsAnimation(); - } - } + int i,k; + for (i=0; isetFadeOutAction(FALSE); + holeCardsArray[i][k]->stopFlipCardsAnimation(); + } + } - QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png")); + QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png")); - //TempArrays - QPixmap tempCardsPixmapArray[2]; - int tempCardsIntArray[2]; + //TempArrays + QPixmap tempCardsPixmapArray[2]; + int tempCardsIntArray[2]; - // Karten der Gegner und eigene Karten austeilen - int j; + // Karten der Gegner und eigene Karten austeilen + int j; boost::shared_ptr currentGame = myStartWindow->getSession()->getCurrentGame(); - PlayerListConstIterator it_c; - PlayerList seatsList = currentGame->getSeatsList(); + PlayerListConstIterator it_c; + PlayerList seatsList = currentGame->getSeatsList(); for (it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c) { - (*it_c)->getMyCards(tempCardsIntArray); - for(j=0; j<2; j++) { - if((*it_c)->getMyActiveStatus()) { - if (( (*it_c)->getMyID() == 0)/* || DEBUG_MODE*/) { - tempCardsPixmapArray[j].load(myCardDeckStyle->getCurrentDir()+QString::number(tempCardsIntArray[j], 10)+".png"); - if(myConfig->readConfigInt("AntiPeekMode")) { - holeCardsArray[(*it_c)->getMyID()][j]->setPixmap(flipside, TRUE); - holeCardsArray[(*it_c)->getMyID()][j]->setFront(flipside); - holeCardsArray[(*it_c)->getMyID()][j]->setHiddenFrontPixmap(tempCardsPixmapArray[j]); - } - else { - holeCardsArray[(*it_c)->getMyID()][j]->setPixmap(tempCardsPixmapArray[j],FALSE); - holeCardsArray[(*it_c)->getMyID()][j]->setFront(tempCardsPixmapArray[j]); - } - } - else { - holeCardsArray[(*it_c)->getMyID()][j]->setPixmap(flipside, TRUE); - holeCardsArray[(*it_c)->getMyID()][j]->setFlipsidePix(flipside); - } - } - else { + (*it_c)->getMyCards(tempCardsIntArray); + for(j=0; j<2; j++) { + if((*it_c)->getMyActiveStatus()) { + if (( (*it_c)->getMyID() == 0)/* || DEBUG_MODE*/) { + tempCardsPixmapArray[j].load(myCardDeckStyle->getCurrentDir()+QString::number(tempCardsIntArray[j], 10)+".png"); + if(myConfig->readConfigInt("AntiPeekMode")) { + holeCardsArray[(*it_c)->getMyID()][j]->setPixmap(flipside, TRUE); + holeCardsArray[(*it_c)->getMyID()][j]->setFront(flipside); + holeCardsArray[(*it_c)->getMyID()][j]->setHiddenFrontPixmap(tempCardsPixmapArray[j]); + } else { + holeCardsArray[(*it_c)->getMyID()][j]->setPixmap(tempCardsPixmapArray[j],FALSE); + holeCardsArray[(*it_c)->getMyID()][j]->setFront(tempCardsPixmapArray[j]); + } + } else { + holeCardsArray[(*it_c)->getMyID()][j]->setPixmap(flipside, TRUE); + holeCardsArray[(*it_c)->getMyID()][j]->setFlipsidePix(flipside); + } + } else { - holeCardsArray[(*it_c)->getMyID()][j]->setPixmap(onePix, FALSE); - } - } - } + holeCardsArray[(*it_c)->getMyID()][j]->setPixmap(onePix, FALSE); + } + } + } - //fix press mouse button during bankrupt with anti-peek-mode - this->mouseOverFlipCards(FALSE); + //fix press mouse button during bankrupt with anti-peek-mode + this->mouseOverFlipCards(FALSE); - //refresh CardsChanceMonitor Tool - refreshCardsChance(GAME_STATE_PREFLOP); + //refresh CardsChanceMonitor Tool + refreshCardsChance(GAME_STATE_PREFLOP); } -void gameTableImpl::dealBeRoCards(int myBeRoID) { +void gameTableImpl::dealBeRoCards(int myBeRoID) +{ - uncheckMyButtons(); - myButtonsCheckable(FALSE); - resetMyButtonsCheckStateMemory(); - clearMyButtons(); + uncheckMyButtons(); + myButtonsCheckable(FALSE); + resetMyButtonsCheckStateMemory(); + clearMyButtons(); - horizontalSlider_bet->setDisabled(TRUE); - spinBox_betValue->setDisabled(TRUE); + horizontalSlider_bet->setDisabled(TRUE); + spinBox_betValue->setDisabled(TRUE); - switch(myBeRoID) { + switch(myBeRoID) { - case 1: { dealFlopCards0(); } - break; - case 2: { dealTurnCards0(); } - break; - case 3: { dealRiverCards0(); } - break; - default: { cout << "dealBeRoCards() Error" << endl; } - } + case 1: { + dealFlopCards0(); + } + break; + case 2: { + dealTurnCards0(); + } + break; + case 3: { + dealRiverCards0(); + } + break; + default: { + cout << "dealBeRoCards() Error" << endl; + } + } } -void gameTableImpl::dealFlopCards0() { dealFlopCards0Timer->start(preDealCardsSpeed); } - -void gameTableImpl::dealFlopCards1() { - - boardCardsArray[0]->setPixmap(flipside, TRUE); - dealFlopCards1Timer->start(dealCardsSpeed); +void gameTableImpl::dealFlopCards0() +{ + dealFlopCards0Timer->start(preDealCardsSpeed); } -void gameTableImpl::dealFlopCards2() { +void gameTableImpl::dealFlopCards1() +{ - boardCardsArray[1]->setPixmap(flipside, TRUE); - dealFlopCards2Timer->start(dealCardsSpeed); + boardCardsArray[0]->setPixmap(flipside, TRUE); + dealFlopCards1Timer->start(dealCardsSpeed); } -void gameTableImpl::dealFlopCards3() { +void gameTableImpl::dealFlopCards2() +{ - boardCardsArray[2]->setPixmap(flipside, TRUE); - dealFlopCards3Timer->start(dealCardsSpeed); + boardCardsArray[1]->setPixmap(flipside, TRUE); + dealFlopCards2Timer->start(dealCardsSpeed); } -void gameTableImpl::dealFlopCards4() { +void gameTableImpl::dealFlopCards3() +{ - int tempBoardCardsArray[5]; - - myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray); - QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[0], 10)+".png")); - - //Config? mit oder ohne Eye-Candy? - if(myConfig->readConfigInt("ShowFlipCardsAnimation")) { - //with Eye-Candy - boardCardsArray[0]->startFlipCards(guiGameSpeed, card, flipside); - } - else { - //without Eye-Candy - boardCardsArray[0]->setFront(card); - boardCardsArray[0]->setPixmap(card, FALSE); - } - dealFlopCards4Timer->start(dealCardsSpeed); + boardCardsArray[2]->setPixmap(flipside, TRUE); + dealFlopCards3Timer->start(dealCardsSpeed); } -void gameTableImpl::dealFlopCards5() { +void gameTableImpl::dealFlopCards4() +{ - int tempBoardCardsArray[5]; - myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray); - QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[1], 10)+".png")); + int tempBoardCardsArray[5]; - //Config? mit oder ohne Eye-Candy? - if(myConfig->readConfigInt("ShowFlipCardsAnimation")) { - //with Eye-Candy - boardCardsArray[1]->startFlipCards(guiGameSpeed, card, flipside); - } - else { - //without Eye-Candy - boardCardsArray[1]->setFront(card); - boardCardsArray[1]->setPixmap(card, FALSE); - } - dealFlopCards5Timer->start(dealCardsSpeed); + myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray); + QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[0], 10)+".png")); + + //Config? mit oder ohne Eye-Candy? + if(myConfig->readConfigInt("ShowFlipCardsAnimation")) { + //with Eye-Candy + boardCardsArray[0]->startFlipCards(guiGameSpeed, card, flipside); + } else { + //without Eye-Candy + boardCardsArray[0]->setFront(card); + boardCardsArray[0]->setPixmap(card, FALSE); + } + dealFlopCards4Timer->start(dealCardsSpeed); } -void gameTableImpl::dealFlopCards6() { +void gameTableImpl::dealFlopCards5() +{ - int tempBoardCardsArray[5]; - myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray); - QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[2], 10)+".png")); + int tempBoardCardsArray[5]; + myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray); + QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[1], 10)+".png")); - //Config? mit oder ohne Eye-Candy? - if(myConfig->readConfigInt("ShowFlipCardsAnimation")) { - //with Eye-Candy - boardCardsArray[2]->startFlipCards(guiGameSpeed, card, flipside); - } - else { - //without Eye-Candy - boardCardsArray[2]->setFront(card); - boardCardsArray[2]->setPixmap(card, FALSE); - } - - // stable - // wenn alle All In - if(myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getAllInCondition()) { dealFlopCards6Timer->start(AllInDealCardsSpeed); } - // sonst normale Variante - else { - updateMyButtonsState(0); //mode 0 == called from dealberocards - dealFlopCards6Timer->start(postDealCardsSpeed); - } - - //refresh CardsChanceMonitor Tool - refreshCardsChance(GAME_STATE_FLOP); + //Config? mit oder ohne Eye-Candy? + if(myConfig->readConfigInt("ShowFlipCardsAnimation")) { + //with Eye-Candy + boardCardsArray[1]->startFlipCards(guiGameSpeed, card, flipside); + } else { + //without Eye-Candy + boardCardsArray[1]->setFront(card); + boardCardsArray[1]->setPixmap(card, FALSE); + } + dealFlopCards5Timer->start(dealCardsSpeed); } -void gameTableImpl::dealTurnCards0() { dealTurnCards0Timer->start(preDealCardsSpeed); } +void gameTableImpl::dealFlopCards6() +{ -void gameTableImpl::dealTurnCards1() { + int tempBoardCardsArray[5]; + myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray); + QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[2], 10)+".png")); - boardCardsArray[3]->setPixmap(flipside, TRUE); - dealTurnCards1Timer->start(dealCardsSpeed); + //Config? mit oder ohne Eye-Candy? + if(myConfig->readConfigInt("ShowFlipCardsAnimation")) { + //with Eye-Candy + boardCardsArray[2]->startFlipCards(guiGameSpeed, card, flipside); + } else { + //without Eye-Candy + boardCardsArray[2]->setFront(card); + boardCardsArray[2]->setPixmap(card, FALSE); + } + + // stable + // wenn alle All In + if(myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getAllInCondition()) { + dealFlopCards6Timer->start(AllInDealCardsSpeed); + } + // sonst normale Variante + else { + updateMyButtonsState(0); //mode 0 == called from dealberocards + dealFlopCards6Timer->start(postDealCardsSpeed); + } + + //refresh CardsChanceMonitor Tool + refreshCardsChance(GAME_STATE_FLOP); } -void gameTableImpl::dealTurnCards2() { - - int tempBoardCardsArray[5]; - myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray); - QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[3], 10)+".png")); - - //Config? mit oder ohne Eye-Candy? - if(myConfig->readConfigInt("ShowFlipCardsAnimation")) { - //with Eye-Candy - boardCardsArray[3]->startFlipCards(guiGameSpeed, card, flipside); - } - else { - //without Eye-Candy - boardCardsArray[3]->setFront(card); - boardCardsArray[3]->setPixmap(card, FALSE); - } - - // stable - // wenn alle All In - if(myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getAllInCondition()) { dealTurnCards2Timer->start(AllInDealCardsSpeed); - } - // sonst normale Variante - else { - updateMyButtonsState(0); //mode 0 == called from dealberocards - dealTurnCards2Timer->start(postDealCardsSpeed); - } - //refresh CardsChanceMonitor Tool - refreshCardsChance(GAME_STATE_TURN); +void gameTableImpl::dealTurnCards0() +{ + dealTurnCards0Timer->start(preDealCardsSpeed); } -void gameTableImpl::dealRiverCards0() { dealRiverCards0Timer->start(preDealCardsSpeed); } +void gameTableImpl::dealTurnCards1() +{ -void gameTableImpl::dealRiverCards1() { - - boardCardsArray[4]->setPixmap(flipside, TRUE); - - // QTimer::singleShot(dealCardsSpeed, this, SLOT( dealRiverCards2() )); - dealRiverCards1Timer->start(dealCardsSpeed); + boardCardsArray[3]->setPixmap(flipside, TRUE); + dealTurnCards1Timer->start(dealCardsSpeed); } -void gameTableImpl::dealRiverCards2() { +void gameTableImpl::dealTurnCards2() +{ - int tempBoardCardsArray[5]; - myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray); - QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[4], 10)+".png")); + int tempBoardCardsArray[5]; + myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray); + QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[3], 10)+".png")); - //Config? mit oder ohne Eye-Candy? - if(myConfig->readConfigInt("ShowFlipCardsAnimation")) { - //with Eye-Candy - boardCardsArray[4]->startFlipCards(guiGameSpeed, card, flipside); - } - else { - //without Eye-Candy - boardCardsArray[4]->setFront(card); - boardCardsArray[4]->setPixmap(card, FALSE); - } + //Config? mit oder ohne Eye-Candy? + if(myConfig->readConfigInt("ShowFlipCardsAnimation")) { + //with Eye-Candy + boardCardsArray[3]->startFlipCards(guiGameSpeed, card, flipside); + } else { + //without Eye-Candy + boardCardsArray[3]->setFront(card); + boardCardsArray[3]->setPixmap(card, FALSE); + } - // stable - // wenn alle All In - if(myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getAllInCondition()) { dealRiverCards2Timer->start(AllInDealCardsSpeed); } - // sonst normale Variante - else { - updateMyButtonsState(0); //mode 0 == called from dealberocards - dealRiverCards2Timer->start(postDealCardsSpeed); - } - //refresh CardsChanceMonitor Tool - refreshCardsChance(GAME_STATE_RIVER); + // stable + // wenn alle All In + if(myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getAllInCondition()) { + dealTurnCards2Timer->start(AllInDealCardsSpeed); + } + // sonst normale Variante + else { + updateMyButtonsState(0); //mode 0 == called from dealberocards + dealTurnCards2Timer->start(postDealCardsSpeed); + } + //refresh CardsChanceMonitor Tool + refreshCardsChance(GAME_STATE_TURN); } -void gameTableImpl::provideMyActions(int mode) { +void gameTableImpl::dealRiverCards0() +{ + dealRiverCards0Timer->start(preDealCardsSpeed); +} - QString pushButtonFoldString; - QString pushButtonBetRaiseString; - QString lastPushButtonBetRaiseString = pushButton_BetRaise->text(); - QString pushButtonCallCheckString; - QString pushButtonAllInString; - QString lastPushButtonCallCheckString = pushButton_CallCheck->text(); +void gameTableImpl::dealRiverCards1() +{ + + boardCardsArray[4]->setPixmap(flipside, TRUE); + + // QTimer::singleShot(dealCardsSpeed, this, SLOT( dealRiverCards2() )); + dealRiverCards1Timer->start(dealCardsSpeed); +} + +void gameTableImpl::dealRiverCards2() +{ + + int tempBoardCardsArray[5]; + myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(tempBoardCardsArray); + QPixmap card = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempBoardCardsArray[4], 10)+".png")); + + //Config? mit oder ohne Eye-Candy? + if(myConfig->readConfigInt("ShowFlipCardsAnimation")) { + //with Eye-Candy + boardCardsArray[4]->startFlipCards(guiGameSpeed, card, flipside); + } else { + //without Eye-Candy + boardCardsArray[4]->setFront(card); + boardCardsArray[4]->setPixmap(card, FALSE); + } + + // stable + // wenn alle All In + if(myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getAllInCondition()) { + dealRiverCards2Timer->start(AllInDealCardsSpeed); + } + // sonst normale Variante + else { + updateMyButtonsState(0); //mode 0 == called from dealberocards + dealRiverCards2Timer->start(postDealCardsSpeed); + } + //refresh CardsChanceMonitor Tool + refreshCardsChance(GAME_STATE_RIVER); +} + +void gameTableImpl::provideMyActions(int mode) +{ + + QString pushButtonFoldString; + QString pushButtonBetRaiseString; + QString lastPushButtonBetRaiseString = pushButton_BetRaise->text(); + QString pushButtonCallCheckString; + QString pushButtonAllInString; + QString lastPushButtonCallCheckString = pushButton_CallCheck->text(); boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); - boost::shared_ptr humanPlayer = currentHand->getSeatsList()->front(); + boost::shared_ptr humanPlayer = currentHand->getSeatsList()->front(); PlayerList activePlayerList = currentHand->getActivePlayerList(); - //really disabled buttons if human player is fold/all-in or ... and not called from dealberocards - if(/*pushButton_BetRaise->isCheckable() && */mode != 0 && (humanPlayer->getMyAction() == PLAYER_ACTION_ALLIN || humanPlayer->getMyAction() == PLAYER_ACTION_FOLD || (humanPlayer->getMySet() == currentHand->getCurrentBeRo()->getHighestSet() && (humanPlayer->getMyAction() != PLAYER_ACTION_NONE)))) { + //really disabled buttons if human player is fold/all-in or ... and not called from dealberocards + if(/*pushButton_BetRaise->isCheckable() && */mode != 0 && (humanPlayer->getMyAction() == PLAYER_ACTION_ALLIN || humanPlayer->getMyAction() == PLAYER_ACTION_FOLD || (humanPlayer->getMySet() == currentHand->getCurrentBeRo()->getHighestSet() && (humanPlayer->getMyAction() != PLAYER_ACTION_NONE)))) { - pushButton_BetRaise->setText(""); - pushButton_CallCheck->setText(""); - pushButton_Fold->setText(""); - pushButton_AllIn->setText(""); + pushButton_BetRaise->setText(""); + pushButton_CallCheck->setText(""); + pushButton_Fold->setText(""); + pushButton_AllIn->setText(""); - horizontalSlider_bet->setDisabled(TRUE); - spinBox_betValue->setDisabled(TRUE); + horizontalSlider_bet->setDisabled(TRUE); + spinBox_betValue->setDisabled(TRUE); - myButtonsCheckable(FALSE); + myButtonsCheckable(FALSE); - refreshActionButtonFKeyIndicator(1); - } - else { - horizontalSlider_bet->setEnabled(TRUE); - spinBox_betValue->setEnabled(TRUE); + refreshActionButtonFKeyIndicator(1); + } else { + horizontalSlider_bet->setEnabled(TRUE); + spinBox_betValue->setEnabled(TRUE); - //show available actions on buttons - if(currentHand->getCurrentRound() == 0) { // preflop + //show available actions on buttons + if(currentHand->getCurrentRound() == 0) { // preflop - if (humanPlayer->getMyCash()+humanPlayer->getMySet() > currentHand->getCurrentBeRo()->getHighestSet() && !currentHand->getCurrentBeRo()->getFullBetRule()) { - pushButtonBetRaiseString = RaiseString+"\n$"+QString("%L1").arg(getMyBetAmount()); - } + if (humanPlayer->getMyCash()+humanPlayer->getMySet() > currentHand->getCurrentBeRo()->getHighestSet() && !currentHand->getCurrentBeRo()->getFullBetRule()) { + pushButtonBetRaiseString = RaiseString+"\n$"+QString("%L1").arg(getMyBetAmount()); + } - if (humanPlayer->getMySet()== currentHand->getCurrentBeRo()->getHighestSet() && humanPlayer->getMyButton() == 3) { pushButtonCallCheckString = CheckString; } - else { pushButtonCallCheckString = CallString+"\n$"+QString("%L1").arg(getMyCallAmount()); } + if (humanPlayer->getMySet()== currentHand->getCurrentBeRo()->getHighestSet() && humanPlayer->getMyButton() == 3) { + pushButtonCallCheckString = CheckString; + } else { + pushButtonCallCheckString = CallString+"\n$"+QString("%L1").arg(getMyCallAmount()); + } - pushButtonFoldString = FoldString; - if(!currentHand->getCurrentBeRo()->getFullBetRule()) { - pushButtonAllInString = AllInString; - } - } - else { // flop,turn,river + pushButtonFoldString = FoldString; + if(!currentHand->getCurrentBeRo()->getFullBetRule()) { + pushButtonAllInString = AllInString; + } + } else { // flop,turn,river - if (currentHand->getCurrentBeRo()->getHighestSet() == 0 && pushButton_Fold->isCheckable() ) { - pushButtonFoldString = CheckString+" /\n"+FoldString; - } - else { pushButtonFoldString = FoldString; } - if (currentHand->getCurrentBeRo()->getHighestSet() == 0) { + if (currentHand->getCurrentBeRo()->getHighestSet() == 0 && pushButton_Fold->isCheckable() ) { + pushButtonFoldString = CheckString+" /\n"+FoldString; + } else { + pushButtonFoldString = FoldString; + } + if (currentHand->getCurrentBeRo()->getHighestSet() == 0) { - pushButtonCallCheckString = CheckString; - pushButtonBetRaiseString = BetString+"\n$"+QString("%L1").arg(getMyBetAmount()); - } - if (currentHand->getCurrentBeRo()->getHighestSet() > 0 && currentHand->getCurrentBeRo()->getHighestSet() > humanPlayer->getMySet()) { - pushButtonCallCheckString = CallString+"\n$"+QString("%L1").arg(getMyCallAmount()); - if (humanPlayer->getMyCash()+humanPlayer->getMySet() > currentHand->getCurrentBeRo()->getHighestSet() && !currentHand->getCurrentBeRo()->getFullBetRule()) { - pushButtonBetRaiseString = RaiseString+"\n$"+QString("%L1").arg(getMyBetAmount()); - } - } - if(!currentHand->getCurrentBeRo()->getFullBetRule()) { - pushButtonAllInString = AllInString; - } - } + pushButtonCallCheckString = CheckString; + pushButtonBetRaiseString = BetString+"\n$"+QString("%L1").arg(getMyBetAmount()); + } + if (currentHand->getCurrentBeRo()->getHighestSet() > 0 && currentHand->getCurrentBeRo()->getHighestSet() > humanPlayer->getMySet()) { + pushButtonCallCheckString = CallString+"\n$"+QString("%L1").arg(getMyCallAmount()); + if (humanPlayer->getMyCash()+humanPlayer->getMySet() > currentHand->getCurrentBeRo()->getHighestSet() && !currentHand->getCurrentBeRo()->getFullBetRule()) { + pushButtonBetRaiseString = RaiseString+"\n$"+QString("%L1").arg(getMyBetAmount()); + } + } + if(!currentHand->getCurrentBeRo()->getFullBetRule()) { + pushButtonAllInString = AllInString; + } + } - if(mode == 0) { - if( humanPlayer->getMyAction() != PLAYER_ACTION_FOLD ) { - pushButtonBetRaiseString = BetString+"\n$"+QString("%L1").arg(getMyBetAmount()); - pushButtonCallCheckString = CheckString; - if( (activePlayerList->size() > 2 && humanPlayer->getMyButton() == BUTTON_SMALL_BLIND ) || ( activePlayerList->size() <= 2 && humanPlayer->getMyButton() == BUTTON_BIG_BLIND)) { pushButtonFoldString = FoldString; } - else { pushButtonFoldString = CheckString+" /\n"+FoldString; } + if(mode == 0) { + if( humanPlayer->getMyAction() != PLAYER_ACTION_FOLD ) { + pushButtonBetRaiseString = BetString+"\n$"+QString("%L1").arg(getMyBetAmount()); + pushButtonCallCheckString = CheckString; + if( (activePlayerList->size() > 2 && humanPlayer->getMyButton() == BUTTON_SMALL_BLIND ) || ( activePlayerList->size() <= 2 && humanPlayer->getMyButton() == BUTTON_BIG_BLIND)) { + pushButtonFoldString = FoldString; + } else { + pushButtonFoldString = CheckString+" /\n"+FoldString; + } - pushButtonAllInString = AllInString; - } - else { - pushButtonBetRaiseString = ""; - pushButtonCallCheckString = ""; - pushButtonFoldString = ""; - pushButtonAllInString = ""; - horizontalSlider_bet->setDisabled(TRUE); - spinBox_betValue->setDisabled(TRUE); + pushButtonAllInString = AllInString; + } else { + pushButtonBetRaiseString = ""; + pushButtonCallCheckString = ""; + pushButtonFoldString = ""; + pushButtonAllInString = ""; + horizontalSlider_bet->setDisabled(TRUE); + spinBox_betValue->setDisabled(TRUE); - myButtonsCheckable(FALSE); + myButtonsCheckable(FALSE); - } - } + } + } - //if text changed on checked button --> uncheck to prevent unwanted actions - if((pushButtonCallCheckString != lastPushButtonCallCheckString && pushButton_CallCheck->isChecked())) { + //if text changed on checked button --> uncheck to prevent unwanted actions + if((pushButtonCallCheckString != lastPushButtonCallCheckString && pushButton_CallCheck->isChecked())) { - // cout << "jo" << endl; - uncheckMyButtons(); - resetMyButtonsCheckStateMemory(); - } + // cout << "jo" << endl; + uncheckMyButtons(); + resetMyButtonsCheckStateMemory(); + } - if(pushButtonBetRaiseString == "") { + if(pushButtonBetRaiseString == "") { - horizontalSlider_bet->setDisabled(TRUE); - spinBox_betValue->setDisabled(TRUE); - } + horizontalSlider_bet->setDisabled(TRUE); + spinBox_betValue->setDisabled(TRUE); + } - pushButton_Fold->setText(pushButtonFoldString); - pushButton_BetRaise->setText(pushButtonBetRaiseString); - pushButton_CallCheck->setText(pushButtonCallCheckString); - pushButton_AllIn->setText(pushButtonAllInString); + pushButton_Fold->setText(pushButtonFoldString); + pushButton_BetRaise->setText(pushButtonBetRaiseString); + pushButton_CallCheck->setText(pushButtonCallCheckString); + pushButton_AllIn->setText(pushButtonAllInString); - refreshActionButtonFKeyIndicator(); - // myBetRaise(); + refreshActionButtonFKeyIndicator(); + // myBetRaise(); - if(pushButton_BetRaise->text().startsWith(RaiseString)) { + if(pushButton_BetRaise->text().startsWith(RaiseString)) { - horizontalSlider_bet->setMinimum(currentHand->getCurrentBeRo()->getHighestSet() - humanPlayer->getMySet() + currentHand->getCurrentBeRo()->getMinimumRaise()); - horizontalSlider_bet->setMaximum(humanPlayer->getMyCash()); - horizontalSlider_bet->setSingleStep(10); - spinBox_betValue->setMinimum(currentHand->getCurrentBeRo()->getHighestSet() - humanPlayer->getMySet() + currentHand->getCurrentBeRo()->getMinimumRaise()); - spinBox_betValue->setMaximum(humanPlayer->getMyCash()); - changeSpinBoxBetValue(horizontalSlider_bet->value()); + horizontalSlider_bet->setMinimum(currentHand->getCurrentBeRo()->getHighestSet() - humanPlayer->getMySet() + currentHand->getCurrentBeRo()->getMinimumRaise()); + horizontalSlider_bet->setMaximum(humanPlayer->getMyCash()); + horizontalSlider_bet->setSingleStep(10); + spinBox_betValue->setMinimum(currentHand->getCurrentBeRo()->getHighestSet() - humanPlayer->getMySet() + currentHand->getCurrentBeRo()->getMinimumRaise()); + spinBox_betValue->setMaximum(humanPlayer->getMyCash()); + changeSpinBoxBetValue(horizontalSlider_bet->value()); - myActionIsRaise = 1; - } - else if(pushButton_BetRaise->text().startsWith(BetString)) { + myActionIsRaise = 1; + } else if(pushButton_BetRaise->text().startsWith(BetString)) { - horizontalSlider_bet->setMinimum(currentHand->getSmallBlind()*2); - horizontalSlider_bet->setMaximum(humanPlayer->getMyCash()); - horizontalSlider_bet->setSingleStep(10); - spinBox_betValue->setMinimum(currentHand->getSmallBlind()*2); - spinBox_betValue->setMaximum(humanPlayer->getMyCash()); - changeSpinBoxBetValue(horizontalSlider_bet->value()); + horizontalSlider_bet->setMinimum(currentHand->getSmallBlind()*2); + horizontalSlider_bet->setMaximum(humanPlayer->getMyCash()); + horizontalSlider_bet->setSingleStep(10); + spinBox_betValue->setMinimum(currentHand->getSmallBlind()*2); + spinBox_betValue->setMaximum(humanPlayer->getMyCash()); + changeSpinBoxBetValue(horizontalSlider_bet->value()); - myActionIsBet = 1; - } - else {} + myActionIsBet = 1; + } else {} - //if value changed on bet/raise button --> uncheck to prevent unwanted actions - int lastBetValue = lastPushButtonBetRaiseString.simplified().remove(QRegExp("[^0-9]")).toInt(); + //if value changed on bet/raise button --> uncheck to prevent unwanted actions + int lastBetValue = lastPushButtonBetRaiseString.simplified().remove(QRegExp("[^0-9]")).toInt(); - if((lastBetValue < horizontalSlider_bet->minimum() && pushButton_BetRaise->isChecked())) { + if((lastBetValue < horizontalSlider_bet->minimum() && pushButton_BetRaise->isChecked())) { - uncheckMyButtons(); - resetMyButtonsCheckStateMemory(); - } + uncheckMyButtons(); + resetMyButtonsCheckStateMemory(); + } - if((myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK) && !lineEdit_ChatInput->hasFocus() && myConfig->readConfigInt("EnableBetInputFocusSwitch")) { - spinBox_betValue->setFocus(); - spinBox_betValue->selectAll(); - } + if((myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK) && !lineEdit_ChatInput->hasFocus() && myConfig->readConfigInt("EnableBetInputFocusSwitch")) { + spinBox_betValue->setFocus(); + spinBox_betValue->selectAll(); + } - if(myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_LOCAL) { - spinBox_betValue->setFocus(); - spinBox_betValue->selectAll(); - } + if(myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_LOCAL) { + spinBox_betValue->setFocus(); + spinBox_betValue->selectAll(); + } - } + } } -void gameTableImpl::meInAction() { +void gameTableImpl::meInAction() +{ - myButtonsCheckable(FALSE); + myButtonsCheckable(FALSE); - horizontalSlider_bet->setEnabled(TRUE); - spinBox_betValue->setEnabled(TRUE); + horizontalSlider_bet->setEnabled(TRUE); + spinBox_betValue->setEnabled(TRUE); - if((myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK) && lineEdit_ChatInput->text() == "" && myConfig->readConfigInt("EnableBetInputFocusSwitch")) { - spinBox_betValue->setFocus(); - spinBox_betValue->selectAll(); - } + if((myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK) && lineEdit_ChatInput->text() == "" && myConfig->readConfigInt("EnableBetInputFocusSwitch")) { + spinBox_betValue->setFocus(); + spinBox_betValue->selectAll(); + } - // if(this->isMinimized()){ - // this->showNormal(); - // this->activateWindow(); - // this->raise(); - // } - // else if(!this->isActiveWindow()) { - // this->showMinimized(); - // this->activateWindow(); - // this->raise(); - // this->showNormal(); - // this->activateWindow(); - // this->raise(); - // - // } + // if(this->isMinimized()){ + // this->showNormal(); + // this->activateWindow(); + // this->raise(); + // } + // else if(!this->isActiveWindow()) { + // this->showMinimized(); + // this->activateWindow(); + // this->raise(); + // this->showNormal(); + // this->activateWindow(); + // this->raise(); + // + // } - myActionIsRaise = 0; - myActionIsBet = 0; + myActionIsRaise = 0; + myActionIsBet = 0; - if(myConfig->readConfigInt("ShowStatusbarMessages")) { - if ( myConfig->readConfigInt("AlternateFKeysUserActionMode") == 0 ) { - // // statusBar()->showMessage(tr("F1 - Fold | F2 - Check/Call | F3 - Bet/Raise | F4 - All-In"), 15000); - } else { - // statusBar()->showMessage(tr("F1 - All-In | F2 - Bet/Raise | F3 - Check/Call | F4 - Fold"), 15000); - } - } + if(myConfig->readConfigInt("ShowStatusbarMessages")) { + if ( myConfig->readConfigInt("AlternateFKeysUserActionMode") == 0 ) { + // // statusBar()->showMessage(tr("F1 - Fold | F2 - Check/Call | F3 - Bet/Raise | F4 - All-In"), 15000); + } else { + // statusBar()->showMessage(tr("F1 - All-In | F2 - Bet/Raise | F3 - Check/Call | F4 - Fold"), 15000); + } + } - QString lastPushButtonFoldString = pushButton_Fold->text(); + QString lastPushButtonFoldString = pushButton_Fold->text(); - //paint actions on buttons - provideMyActions(); + //paint actions on buttons + provideMyActions(); - //do remembered action - if( pushButtonBetRaiseIsChecked ) { pushButton_BetRaise->click(); pushButtonBetRaiseIsChecked = FALSE;} - if( pushButtonCallCheckIsChecked ) { pushButton_CallCheck->click(); pushButtonCallCheckIsChecked = FALSE;} - if( pushButtonFoldIsChecked ) { - if(lastPushButtonFoldString == CheckString+" /\n"+FoldString && pushButton_CallCheck->text() == CheckString) { - pushButton_CallCheck->click(); - } - else { - pushButton_Fold->click(); - } - pushButtonFoldIsChecked = FALSE; - } - if( pushButtonAllInIsChecked ) { pushButton_AllIn->click(); pushButtonAllInIsChecked = FALSE;} + //do remembered action + if( pushButtonBetRaiseIsChecked ) { + pushButton_BetRaise->click(); + pushButtonBetRaiseIsChecked = FALSE; + } + if( pushButtonCallCheckIsChecked ) { + pushButton_CallCheck->click(); + pushButtonCallCheckIsChecked = FALSE; + } + if( pushButtonFoldIsChecked ) { + if(lastPushButtonFoldString == CheckString+" /\n"+FoldString && pushButton_CallCheck->text() == CheckString) { + pushButton_CallCheck->click(); + } else { + pushButton_Fold->click(); + } + pushButtonFoldIsChecked = FALSE; + } + if( pushButtonAllInIsChecked ) { + pushButton_AllIn->click(); + pushButtonAllInIsChecked = FALSE; + } - //automatic mode - switch (playingMode) { - case 0: // Manual mode - break; - case 1: // Auto check / call all - myCallCheck(); - break; - case 2: // Auto check / fold all - if (pushButton_CallCheck->text() == CheckString) { - myCheck(); - } else { - myFold(); - } - break; - } + //automatic mode + switch (playingMode) { + case 0: // Manual mode + break; + case 1: // Auto check / call all + myCallCheck(); + break; + case 2: // Auto check / fold all + if (pushButton_CallCheck->text() == CheckString) { + myCheck(); + } else { + myFold(); + } + break; + } } -void gameTableImpl::startTimeoutAnimation(int playerId, int timeoutSec) { - assert(playerId >= 0 && playerId < myStartWindow->getSession()->getCurrentGame()->getStartQuantityPlayers()); +void gameTableImpl::startTimeoutAnimation(int playerId, int timeoutSec) +{ + assert(playerId >= 0 && playerId < myStartWindow->getSession()->getCurrentGame()->getStartQuantityPlayers()); - //beep for player 0 - if(playerId) { timeoutLabelArray[playerId]->startTimeOutAnimation(timeoutSec, FALSE); } - else { timeoutLabelArray[playerId]->startTimeOutAnimation(timeoutSec, TRUE); } + //beep for player 0 + if(playerId) { + timeoutLabelArray[playerId]->startTimeOutAnimation(timeoutSec, FALSE); + } else { + timeoutLabelArray[playerId]->startTimeOutAnimation(timeoutSec, TRUE); + } } -void gameTableImpl::stopTimeoutAnimation(int playerId) { - assert(playerId >= 0 && playerId < myStartWindow->getSession()->getCurrentGame()->getStartQuantityPlayers()); - timeoutLabelArray[playerId]->stopTimeOutAnimation(); +void gameTableImpl::stopTimeoutAnimation(int playerId) +{ + assert(playerId >= 0 && playerId < myStartWindow->getSession()->getCurrentGame()->getStartQuantityPlayers()); + timeoutLabelArray[playerId]->stopTimeOutAnimation(); } -void gameTableImpl::disableMyButtons() { +void gameTableImpl::disableMyButtons() +{ - boost::shared_ptr humanPlayer = myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getSeatsList()->front(); + boost::shared_ptr humanPlayer = myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getSeatsList()->front(); - clearMyButtons(); + clearMyButtons(); - //clear userWidgets - horizontalSlider_bet->setDisabled(TRUE); - spinBox_betValue->setDisabled(TRUE); - horizontalSlider_bet->setMinimum(0); - horizontalSlider_bet->setMaximum(humanPlayer->getMyCash()); - spinBox_betValue->setMinimum(0); - spinBox_betValue->setMaximum(humanPlayer->getMyCash()); - spinBox_betValue->clear(); - horizontalSlider_bet->setValue(0); + //clear userWidgets + horizontalSlider_bet->setDisabled(TRUE); + spinBox_betValue->setDisabled(TRUE); + horizontalSlider_bet->setMinimum(0); + horizontalSlider_bet->setMaximum(humanPlayer->getMyCash()); + spinBox_betValue->setMinimum(0); + spinBox_betValue->setMaximum(humanPlayer->getMyCash()); + spinBox_betValue->clear(); + horizontalSlider_bet->setValue(0); #ifdef _WIN32 - QString humanPlayerButtonFontSize = "13"; -#else - QString humanPlayerButtonFontSize = "12"; + QString humanPlayerButtonFontSize = "13"; +#else + QString humanPlayerButtonFontSize = "12"; #endif } -void gameTableImpl::myCallCheck() { +void gameTableImpl::myCallCheck() +{ - if(pushButton_CallCheck->text().startsWith(CallString)) { myCall(); } - if(pushButton_CallCheck->text() == CheckString) { myCheck(); } + if(pushButton_CallCheck->text().startsWith(CallString)) { + myCall(); + } + if(pushButton_CallCheck->text() == CheckString) { + myCheck(); + } } -void gameTableImpl::myFold(){ +void gameTableImpl::myFold() +{ - if(pushButton_Fold->text() == FoldString) { + if(pushButton_Fold->text() == FoldString) { - boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); - boost::shared_ptr humanPlayer = currentHand->getSeatsList()->front(); - humanPlayer->setMyAction(1); - humanPlayer->setMyTurn(0); + boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); + boost::shared_ptr humanPlayer = currentHand->getSeatsList()->front(); + humanPlayer->setMyAction(1); + humanPlayer->setMyTurn(0); - //set that i was the last active player. need this for unhighlighting groupbox - currentHand->setLastPlayersTurn(0); + //set that i was the last active player. need this for unhighlighting groupbox + currentHand->setLastPlayersTurn(0); - // statusBar()->clearMessage(); + // statusBar()->clearMessage(); - //Spiel läuft weiter - myActionDone(); - } + //Spiel läuft weiter + myActionDone(); + } } -void gameTableImpl::myCheck() { +void gameTableImpl::myCheck() +{ - boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); - boost::shared_ptr humanPlayer = currentHand->getSeatsList()->front(); - humanPlayer->setMyTurn(0); - humanPlayer->setMyAction(2); + boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); + boost::shared_ptr humanPlayer = currentHand->getSeatsList()->front(); + humanPlayer->setMyTurn(0); + humanPlayer->setMyAction(2); - //set that i was the last active player. need this for unhighlighting groupbox - currentHand->setLastPlayersTurn(0); + //set that i was the last active player. need this for unhighlighting groupbox + currentHand->setLastPlayersTurn(0); - // statusBar()->clearMessage(); + // statusBar()->clearMessage(); - //Spiel läuft weiter - myActionDone(); + //Spiel läuft weiter + myActionDone(); } -int gameTableImpl::getMyCallAmount() { +int gameTableImpl::getMyCallAmount() +{ - int tempHighestSet = 0; + int tempHighestSet = 0; - boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); - boost::shared_ptr humanPlayer = currentHand->getSeatsList()->front(); - tempHighestSet = currentHand->getCurrentBeRo()->getHighestSet(); + boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); + boost::shared_ptr humanPlayer = currentHand->getSeatsList()->front(); + tempHighestSet = currentHand->getCurrentBeRo()->getHighestSet(); - if (humanPlayer->getMyCash() + humanPlayer->getMySet() <= tempHighestSet) { + if (humanPlayer->getMyCash() + humanPlayer->getMySet() <= tempHighestSet) { - return humanPlayer->getMyCash(); - } - else { - return tempHighestSet - humanPlayer->getMySet(); - } + return humanPlayer->getMyCash(); + } else { + return tempHighestSet - humanPlayer->getMySet(); + } } -int gameTableImpl::getBetRaisePushButtonValue() { +int gameTableImpl::getBetRaisePushButtonValue() +{ - int betValue = pushButton_BetRaise->text().simplified().remove(QRegExp("[^0-9]")).toInt(); - return betValue; + int betValue = pushButton_BetRaise->text().simplified().remove(QRegExp("[^0-9]")).toInt(); + return betValue; } -int gameTableImpl::getMyBetAmount() { +int gameTableImpl::getMyBetAmount() +{ - boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); - boost::shared_ptr humanPlayer = currentHand->getSeatsList()->front(); + boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); + boost::shared_ptr humanPlayer = currentHand->getSeatsList()->front(); - int betValue = getBetRaisePushButtonValue(); - int minimum; + int betValue = getBetRaisePushButtonValue(); + int minimum; - minimum = currentHand->getCurrentBeRo()->getHighestSet() - humanPlayer->getMySet() + currentHand->getCurrentBeRo()->getMinimumRaise(); + minimum = currentHand->getCurrentBeRo()->getHighestSet() - humanPlayer->getMySet() + currentHand->getCurrentBeRo()->getMinimumRaise(); - if(betValue < minimum) { - return min(minimum,humanPlayer->getMyCash()); - } - else { - return betValue; - } + if(betValue < minimum) { + return min(minimum,humanPlayer->getMyCash()); + } else { + return betValue; + } } -void gameTableImpl::myCall(){ +void gameTableImpl::myCall() +{ - int tempHighestSet = 0; - boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); - boost::shared_ptr humanPlayer = currentHand->getSeatsList()->front(); + int tempHighestSet = 0; + boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); + boost::shared_ptr humanPlayer = currentHand->getSeatsList()->front(); - tempHighestSet = currentHand->getCurrentBeRo()->getHighestSet(); + tempHighestSet = currentHand->getCurrentBeRo()->getHighestSet(); - if (humanPlayer->getMyCash() + humanPlayer->getMySet() <= tempHighestSet) { + if (humanPlayer->getMyCash() + humanPlayer->getMySet() <= tempHighestSet) { - humanPlayer->setMySet(humanPlayer->getMyCash()); - humanPlayer->setMyCash(0); - humanPlayer->setMyAction(6); - } - else { - humanPlayer->setMySet(tempHighestSet - humanPlayer->getMySet()); - humanPlayer->setMyAction(3); - } - humanPlayer->setMyTurn(0); + humanPlayer->setMySet(humanPlayer->getMyCash()); + humanPlayer->setMyCash(0); + humanPlayer->setMyAction(6); + } else { + humanPlayer->setMySet(tempHighestSet - humanPlayer->getMySet()); + humanPlayer->setMyAction(3); + } + humanPlayer->setMyTurn(0); - currentHand->getBoard()->collectSets(); - refreshPot(); + currentHand->getBoard()->collectSets(); + refreshPot(); - //set that i was the last active player. need this for unhighlighting groupbox - currentHand->setLastPlayersTurn(0); + //set that i was the last active player. need this for unhighlighting groupbox + currentHand->setLastPlayersTurn(0); - // statusBar()->clearMessage(); + // statusBar()->clearMessage(); - //Spiel läuft weiter - myActionDone(); + //Spiel läuft weiter + myActionDone(); } -void gameTableImpl::mySet(){ +void gameTableImpl::mySet() +{ - if(pushButton_BetRaise->text() != "") { + if(pushButton_BetRaise->text() != "") { - boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); - boost::shared_ptr humanPlayer = currentHand->getSeatsList()->front(); + boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); + boost::shared_ptr humanPlayer = currentHand->getSeatsList()->front(); - int tempCash = humanPlayer->getMyCash(); + int tempCash = humanPlayer->getMyCash(); - // cout << "Set-Value " << getBetRaisePushButtonValue() << endl; - humanPlayer->setMySet(getBetRaisePushButtonValue()); + // cout << "Set-Value " << getBetRaisePushButtonValue() << endl; + humanPlayer->setMySet(getBetRaisePushButtonValue()); - if (getBetRaisePushButtonValue() >= tempCash ) { + if (getBetRaisePushButtonValue() >= tempCash ) { - humanPlayer->setMySet(humanPlayer->getMyCash()); - humanPlayer->setMyCash(0); - humanPlayer->setMyAction(6); + humanPlayer->setMySet(humanPlayer->getMyCash()); + humanPlayer->setMyCash(0); + humanPlayer->setMyAction(6); - // full bet rule - if(currentHand->getCurrentBeRo()->getHighestSet() + currentHand->getCurrentBeRo()->getMinimumRaise() > humanPlayer->getMySet()) { - currentHand->getCurrentBeRo()->setFullBetRule(true); - } - } + // full bet rule + if(currentHand->getCurrentBeRo()->getHighestSet() + currentHand->getCurrentBeRo()->getMinimumRaise() > humanPlayer->getMySet()) { + currentHand->getCurrentBeRo()->setFullBetRule(true); + } + } - if(myActionIsRaise) { - //do not if allIn - if(humanPlayer->getMyAction() != 6) { - humanPlayer->setMyAction(5); - } - myActionIsRaise = 0; + if(myActionIsRaise) { + //do not if allIn + if(humanPlayer->getMyAction() != 6) { + humanPlayer->setMyAction(5); + } + myActionIsRaise = 0; - currentHand->getCurrentBeRo()->setMinimumRaise(humanPlayer->getMySet() - currentHand->getCurrentBeRo()->getHighestSet()); - } + currentHand->getCurrentBeRo()->setMinimumRaise(humanPlayer->getMySet() - currentHand->getCurrentBeRo()->getHighestSet()); + } - if(myActionIsBet) { - //do not if allIn - if(humanPlayer->getMyAction() != 6) { - humanPlayer->setMyAction(4); - } - myActionIsBet = 0; + if(myActionIsBet) { + //do not if allIn + if(humanPlayer->getMyAction() != 6) { + humanPlayer->setMyAction(4); + } + myActionIsBet = 0; - currentHand->getCurrentBeRo()->setMinimumRaise(humanPlayer->getMySet()); - } + currentHand->getCurrentBeRo()->setMinimumRaise(humanPlayer->getMySet()); + } - currentHand->getCurrentBeRo()->setHighestSet(humanPlayer->getMySet()); + currentHand->getCurrentBeRo()->setHighestSet(humanPlayer->getMySet()); - humanPlayer->setMyTurn(0); + humanPlayer->setMyTurn(0); - currentHand->getBoard()->collectSets(); - refreshPot(); + currentHand->getBoard()->collectSets(); + refreshPot(); - // statusBar()->clearMessage(); + // statusBar()->clearMessage(); - //set that i was the last active player. need this for unhighlighting groupbox - currentHand->setLastPlayersTurn(0); + //set that i was the last active player. need this for unhighlighting groupbox + currentHand->setLastPlayersTurn(0); - // lastPlayerAction für Karten umblättern reihenfolge setzrn - currentHand->setLastActionPlayer(humanPlayer->getMyUniqueID()); + // lastPlayerAction für Karten umblättern reihenfolge setzrn + currentHand->setLastActionPlayer(humanPlayer->getMyUniqueID()); - //Spiel läuft weiter - myActionDone(); - } + //Spiel läuft weiter + myActionDone(); + } } -void gameTableImpl::myAllIn(){ +void gameTableImpl::myAllIn() +{ - if(pushButton_AllIn->text() == AllInString) { + if(pushButton_AllIn->text() == AllInString) { - boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); - boost::shared_ptr humanPlayer = currentHand->getSeatsList()->front(); + boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); + boost::shared_ptr humanPlayer = currentHand->getSeatsList()->front(); - humanPlayer->setMySet(humanPlayer->getMyCash()); - humanPlayer->setMyCash(0); - humanPlayer->setMyAction(6); + humanPlayer->setMySet(humanPlayer->getMyCash()); + humanPlayer->setMyCash(0); + humanPlayer->setMyAction(6); - // full bet rule - if(currentHand->getCurrentBeRo()->getHighestSet() + currentHand->getCurrentBeRo()->getMinimumRaise() > humanPlayer->getMySet()) { - currentHand->getCurrentBeRo()->setFullBetRule(true); - } + // full bet rule + if(currentHand->getCurrentBeRo()->getHighestSet() + currentHand->getCurrentBeRo()->getMinimumRaise() > humanPlayer->getMySet()) { + currentHand->getCurrentBeRo()->setFullBetRule(true); + } - if(humanPlayer->getMySet() > currentHand->getCurrentBeRo()->getHighestSet()) { - currentHand->getCurrentBeRo()->setMinimumRaise(humanPlayer->getMySet() - currentHand->getCurrentBeRo()->getHighestSet()); + if(humanPlayer->getMySet() > currentHand->getCurrentBeRo()->getHighestSet()) { + currentHand->getCurrentBeRo()->setMinimumRaise(humanPlayer->getMySet() - currentHand->getCurrentBeRo()->getHighestSet()); - currentHand->getCurrentBeRo()->setHighestSet(humanPlayer->getMySet()); + currentHand->getCurrentBeRo()->setHighestSet(humanPlayer->getMySet()); - // lastPlayerAction für Karten umblättern reihenfolge setzrn - currentHand->setLastActionPlayer(humanPlayer->getMyUniqueID()); + // lastPlayerAction für Karten umblättern reihenfolge setzrn + currentHand->setLastActionPlayer(humanPlayer->getMyUniqueID()); - } + } - humanPlayer->setMyTurn(0); + humanPlayer->setMyTurn(0); - currentHand->getBoard()->collectSets(); - refreshPot(); + currentHand->getBoard()->collectSets(); + refreshPot(); - //set that i was the last active player. need this for unhighlighting groupbox - currentHand->setLastPlayersTurn(0); + //set that i was the last active player. need this for unhighlighting groupbox + currentHand->setLastPlayersTurn(0); - //Spiel läuft weiter - myActionDone(); - } + //Spiel läuft weiter + myActionDone(); + } } -void gameTableImpl::pushButtonBetRaiseClicked(bool checked) { +void gameTableImpl::pushButtonBetRaiseClicked(bool checked) +{ - if (pushButton_BetRaise->isCheckable()) { - if(checked) { - pushButton_CallCheck->setChecked(FALSE); - pushButton_Fold->setChecked(FALSE); - pushButton_AllIn->setChecked(FALSE); + if (pushButton_BetRaise->isCheckable()) { + if(checked) { + pushButton_CallCheck->setChecked(FALSE); + pushButton_Fold->setChecked(FALSE); + pushButton_AllIn->setChecked(FALSE); - pushButtonCallCheckIsChecked = FALSE; - pushButtonFoldIsChecked = FALSE; - pushButtonAllInIsChecked = FALSE; + pushButtonCallCheckIsChecked = FALSE; + pushButtonFoldIsChecked = FALSE; + pushButtonAllInIsChecked = FALSE; - pushButtonBetRaiseIsChecked = TRUE; + pushButtonBetRaiseIsChecked = TRUE; - if(!radioButton_manualAction->isChecked()) - radioButton_manualAction->click(); + if(!radioButton_manualAction->isChecked()) + radioButton_manualAction->click(); - // myLastPreActionBetValue = spinBox_betValue->value(); + // myLastPreActionBetValue = spinBox_betValue->value(); - } - else { - pushButtonBetRaiseIsChecked = FALSE; - myLastPreActionBetValue = 0; - } - } - else { - mySet(); - } + } else { + pushButtonBetRaiseIsChecked = FALSE; + myLastPreActionBetValue = 0; + } + } else { + mySet(); + } } -void gameTableImpl::pushButtonCallCheckClicked(bool checked) { +void gameTableImpl::pushButtonCallCheckClicked(bool checked) +{ - if (pushButton_CallCheck->isCheckable()) { - if(checked) { - pushButton_Fold->setChecked(FALSE); - pushButton_BetRaise->setChecked(FALSE); - pushButton_AllIn->setChecked(FALSE); + if (pushButton_CallCheck->isCheckable()) { + if(checked) { + pushButton_Fold->setChecked(FALSE); + pushButton_BetRaise->setChecked(FALSE); + pushButton_AllIn->setChecked(FALSE); - pushButtonAllInIsChecked = FALSE; - pushButtonFoldIsChecked = FALSE; - pushButtonBetRaiseIsChecked = FALSE; + pushButtonAllInIsChecked = FALSE; + pushButtonFoldIsChecked = FALSE; + pushButtonBetRaiseIsChecked = FALSE; - pushButtonCallCheckIsChecked = TRUE; + pushButtonCallCheckIsChecked = TRUE; - if(!radioButton_manualAction->isChecked()) - radioButton_manualAction->click(); - } - else { - pushButtonCallCheckIsChecked = FALSE; - } - } - else { - myCallCheck(); - } + if(!radioButton_manualAction->isChecked()) + radioButton_manualAction->click(); + } else { + pushButtonCallCheckIsChecked = FALSE; + } + } else { + myCallCheck(); + } } -void gameTableImpl::pushButtonFoldClicked(bool checked) { +void gameTableImpl::pushButtonFoldClicked(bool checked) +{ - if (pushButton_Fold->isCheckable()) { - if(checked) { - pushButton_CallCheck->setChecked(FALSE); - pushButton_BetRaise->setChecked(FALSE); - pushButton_AllIn->setChecked(FALSE); + if (pushButton_Fold->isCheckable()) { + if(checked) { + pushButton_CallCheck->setChecked(FALSE); + pushButton_BetRaise->setChecked(FALSE); + pushButton_AllIn->setChecked(FALSE); - pushButtonAllInIsChecked = FALSE; - pushButtonCallCheckIsChecked = FALSE; - pushButtonBetRaiseIsChecked = FALSE; + pushButtonAllInIsChecked = FALSE; + pushButtonCallCheckIsChecked = FALSE; + pushButtonBetRaiseIsChecked = FALSE; - pushButtonFoldIsChecked = TRUE; + pushButtonFoldIsChecked = TRUE; - if(!radioButton_manualAction->isChecked()) - radioButton_manualAction->click(); - } - else { - pushButtonFoldIsChecked = FALSE; - } - } - else { - myFold(); - } + if(!radioButton_manualAction->isChecked()) + radioButton_manualAction->click(); + } else { + pushButtonFoldIsChecked = FALSE; + } + } else { + myFold(); + } } -void gameTableImpl::pushButtonAllInClicked(bool checked) { +void gameTableImpl::pushButtonAllInClicked(bool checked) +{ - if (pushButton_AllIn->isCheckable()) { - if(checked) { - pushButton_CallCheck->setChecked(FALSE); - pushButton_BetRaise->setChecked(FALSE); - pushButton_Fold->setChecked(FALSE); + if (pushButton_AllIn->isCheckable()) { + if(checked) { + pushButton_CallCheck->setChecked(FALSE); + pushButton_BetRaise->setChecked(FALSE); + pushButton_Fold->setChecked(FALSE); - pushButtonFoldIsChecked = FALSE; - pushButtonCallCheckIsChecked = FALSE; - pushButtonBetRaiseIsChecked = FALSE; + pushButtonFoldIsChecked = FALSE; + pushButtonCallCheckIsChecked = FALSE; + pushButtonBetRaiseIsChecked = FALSE; - pushButtonAllInIsChecked = TRUE; + pushButtonAllInIsChecked = TRUE; - if(!radioButton_manualAction->isChecked()) - radioButton_manualAction->click(); - } - else { - pushButtonAllInIsChecked = FALSE; - } - } - else { - myAllIn(); - } + if(!radioButton_manualAction->isChecked()) + radioButton_manualAction->click(); + } else { + pushButtonAllInIsChecked = FALSE; + } + } else { + myAllIn(); + } } -void gameTableImpl::myActionDone() { +void gameTableImpl::myActionDone() +{ - // If a network client is running, we need - // to transfer the action to the server. - myStartWindow->getSession()->sendClientPlayerAction(); + // If a network client is running, we need + // to transfer the action to the server. + myStartWindow->getSession()->sendClientPlayerAction(); - // TODO: Should not call in networking game. - disableMyButtons(); + // TODO: Should not call in networking game. + disableMyButtons(); - if (!myStartWindow->getSession()->isNetworkClientRunning()) - nextPlayerAnimation(); + if (!myStartWindow->getSession()->isNetworkClientRunning()) + nextPlayerAnimation(); - //prevent escape button working while allIn - myActionIsRaise = 0; - myActionIsBet = 0; + //prevent escape button working while allIn + myActionIsRaise = 0; + myActionIsBet = 0; } -void gameTableImpl::nextPlayerAnimation() { +void gameTableImpl::nextPlayerAnimation() +{ - boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); + boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); - //refresh Change Player - refreshSet(); + //refresh Change Player + refreshSet(); - PlayerListConstIterator it_c; - PlayerList seatsList = currentHand->getSeatsList(); + PlayerListConstIterator it_c; + PlayerList seatsList = currentHand->getSeatsList(); for (it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c) { - if((*it_c)->getMyID() == currentHand->getLastPlayersTurn()) break; - } + if((*it_c)->getMyID() == currentHand->getLastPlayersTurn()) break; + } - if(currentHand->getLastPlayersTurn() != -1) { - refreshAction(currentHand->getLastPlayersTurn(), (*it_c)->getMyAction()); - } - refreshCash(); + if(currentHand->getLastPlayersTurn() != -1) { + refreshAction(currentHand->getLastPlayersTurn(), (*it_c)->getMyAction()); + } + refreshCash(); - //refresh actions for human player - updateMyButtonsState(); + //refresh actions for human player + updateMyButtonsState(); - nextPlayerAnimationTimer->start(nextPlayerSpeed1); + nextPlayerAnimationTimer->start(nextPlayerSpeed1); } -void gameTableImpl::beRoAnimation2(int myBeRoID) { +void gameTableImpl::beRoAnimation2(int myBeRoID) +{ - switch(myBeRoID) { + switch(myBeRoID) { - case 0: { preflopAnimation2(); } - break; - case 1: { flopAnimation2(); } - break; - case 2: { turnAnimation2(); } - break; - case 3: { riverAnimation2(); } - break; - default: { cout << "beRoAnimation2() Error" << endl; } - } + case 0: { + preflopAnimation2(); + } + break; + case 1: { + flopAnimation2(); + } + break; + case 2: { + turnAnimation2(); + } + break; + case 3: { + riverAnimation2(); + } + break; + default: { + cout << "beRoAnimation2() Error" << endl; + } + } } -void gameTableImpl::preflopAnimation1() { preflopAnimation1Timer->start(nextPlayerSpeed2); } -void gameTableImpl::preflopAnimation1Action() { myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->run(); } +void gameTableImpl::preflopAnimation1() +{ + preflopAnimation1Timer->start(nextPlayerSpeed2); +} +void gameTableImpl::preflopAnimation1Action() +{ + myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->run(); +} -void gameTableImpl::preflopAnimation2() { preflopAnimation2Timer->start(preflopNextPlayerSpeed); } -void gameTableImpl::preflopAnimation2Action() { myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->nextPlayer(); } +void gameTableImpl::preflopAnimation2() +{ + preflopAnimation2Timer->start(preflopNextPlayerSpeed); +} +void gameTableImpl::preflopAnimation2Action() +{ + myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->nextPlayer(); +} -void gameTableImpl::flopAnimation1() { flopAnimation1Timer->start(nextPlayerSpeed2); } -void gameTableImpl::flopAnimation1Action() { myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->run(); } +void gameTableImpl::flopAnimation1() +{ + flopAnimation1Timer->start(nextPlayerSpeed2); +} +void gameTableImpl::flopAnimation1Action() +{ + myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->run(); +} -void gameTableImpl::flopAnimation2() { flopAnimation2Timer->start(nextPlayerSpeed3); } -void gameTableImpl::flopAnimation2Action() { myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->nextPlayer(); } +void gameTableImpl::flopAnimation2() +{ + flopAnimation2Timer->start(nextPlayerSpeed3); +} +void gameTableImpl::flopAnimation2Action() +{ + myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->nextPlayer(); +} -void gameTableImpl::turnAnimation1() { turnAnimation1Timer->start(nextPlayerSpeed2); } -void gameTableImpl::turnAnimation1Action() { myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->run(); } +void gameTableImpl::turnAnimation1() +{ + turnAnimation1Timer->start(nextPlayerSpeed2); +} +void gameTableImpl::turnAnimation1Action() +{ + myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->run(); +} -void gameTableImpl::turnAnimation2() { turnAnimation2Timer->start(nextPlayerSpeed3); } -void gameTableImpl::turnAnimation2Action() { myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->nextPlayer(); } +void gameTableImpl::turnAnimation2() +{ + turnAnimation2Timer->start(nextPlayerSpeed3); +} +void gameTableImpl::turnAnimation2Action() +{ + myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->nextPlayer(); +} -void gameTableImpl::riverAnimation1() { riverAnimation1Timer->start(nextPlayerSpeed2); } -void gameTableImpl::riverAnimation1Action() { myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->run(); } +void gameTableImpl::riverAnimation1() +{ + riverAnimation1Timer->start(nextPlayerSpeed2); +} +void gameTableImpl::riverAnimation1Action() +{ + myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->run(); +} -void gameTableImpl::riverAnimation2() { riverAnimation2Timer->start(nextPlayerSpeed3); } -void gameTableImpl::riverAnimation2Action() { myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->nextPlayer(); } +void gameTableImpl::riverAnimation2() +{ + riverAnimation2Timer->start(nextPlayerSpeed3); +} +void gameTableImpl::riverAnimation2Action() +{ + myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->nextPlayer(); +} -void gameTableImpl::postRiverAnimation1() { postRiverAnimation1Timer->start(nextPlayerSpeed2); } -void gameTableImpl::postRiverAnimation1Action() { myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->postRiverRun(); } +void gameTableImpl::postRiverAnimation1() +{ + postRiverAnimation1Timer->start(nextPlayerSpeed2); +} +void gameTableImpl::postRiverAnimation1Action() +{ + myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getCurrentBeRo()->postRiverRun(); +} -void gameTableImpl::postRiverRunAnimation1() { postRiverRunAnimation1Timer->start(postRiverRunAnimationSpeed); } +void gameTableImpl::postRiverRunAnimation1() +{ + postRiverRunAnimation1Timer->start(postRiverRunAnimationSpeed); +} -void gameTableImpl::postRiverRunAnimation2() { +void gameTableImpl::postRiverRunAnimation2() +{ - uncheckMyButtons(); - myButtonsCheckable(FALSE); - clearMyButtons(); - resetMyButtonsCheckStateMemory(); + uncheckMyButtons(); + myButtonsCheckable(FALSE); + clearMyButtons(); + resetMyButtonsCheckStateMemory(); - horizontalSlider_bet->setDisabled(TRUE); - spinBox_betValue->setDisabled(TRUE); + horizontalSlider_bet->setDisabled(TRUE); + spinBox_betValue->setDisabled(TRUE); boost::shared_ptr currentGame = myStartWindow->getSession()->getCurrentGame(); - bool internetOrNetworkGame = (myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK); + bool internetOrNetworkGame = (myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK); - int nonfoldPlayersCounter = 0; - PlayerListConstIterator it_c; + int nonfoldPlayersCounter = 0; + PlayerListConstIterator it_c; PlayerList activePlayerList = currentGame->getActivePlayerList(); for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - if ((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) - nonfoldPlayersCounter++; - } + if ((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) + nonfoldPlayersCounter++; + } - if(nonfoldPlayersCounter!=1) { + if(nonfoldPlayersCounter!=1) { - if(!flipHolecardsAllInAlreadyDone) { + if(!flipHolecardsAllInAlreadyDone) { for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD && (*it_c)->checkIfINeedToShowCards()) { + if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD && (*it_c)->checkIfINeedToShowCards()) { - showHoleCards((*it_c)->getMyUniqueID()); - } + showHoleCards((*it_c)->getMyUniqueID()); + } - //if human player dont need to show cards he gets the button "show cards" in internet or network game - if( internetOrNetworkGame && (*it_c)->getMyID() == 0 && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && !(*it_c)->checkIfINeedToShowCards()) { + //if human player dont need to show cards he gets the button "show cards" in internet or network game + if( internetOrNetworkGame && (*it_c)->getMyID() == 0 && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && !(*it_c)->checkIfINeedToShowCards()) { - showShowMyCardsButton(); - } - } - //Wenn einmal umgedreht dann fertig!! - flipHolecardsAllInAlreadyDone = TRUE; - } - else { + showShowMyCardsButton(); + } + } + //Wenn einmal umgedreht dann fertig!! + flipHolecardsAllInAlreadyDone = TRUE; + } else { for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { - //set Player value (logging) for all in already shown cards - (*it_c)->setMyCardsFlip(1,3); - } - } - } - postRiverRunAnimation2Timer->start(postRiverRunAnimationSpeed); - } - else { + if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { + //set Player value (logging) for all in already shown cards + (*it_c)->setMyCardsFlip(1,3); + } + } + } + postRiverRunAnimation2Timer->start(postRiverRunAnimationSpeed); + } else { - //display show! button if human player is active and the latest non foldedone - boost::shared_ptr humanPlayer = myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getSeatsList()->front(); - if( internetOrNetworkGame && humanPlayer->getMyActiveStatus() && humanPlayer->getMyAction() != PLAYER_ACTION_FOLD) { + //display show! button if human player is active and the latest non foldedone + boost::shared_ptr humanPlayer = myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getSeatsList()->front(); + if( internetOrNetworkGame && humanPlayer->getMyActiveStatus() && humanPlayer->getMyAction() != PLAYER_ACTION_FOLD) { - showShowMyCardsButton(); - } + showShowMyCardsButton(); + } - postRiverRunAnimation3(); - } + postRiverRunAnimation3(); + } } -void gameTableImpl::postRiverRunAnimation3() { +void gameTableImpl::postRiverRunAnimation3() +{ - boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); + boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); - int nonfoldPlayerCounter = 0; - PlayerListConstIterator it_c; + int nonfoldPlayerCounter = 0; + PlayerListConstIterator it_c; - PlayerList activePlayerList = currentHand->getActivePlayerList(); + PlayerList activePlayerList = currentHand->getActivePlayerList(); for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { - nonfoldPlayerCounter++; - } - } + if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { + nonfoldPlayerCounter++; + } + } - list winners = currentHand->getBoard()->getWinners(); + list winners = currentHand->getBoard()->getWinners(); for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD && (*it_c)->getMyCardsValueInt() == currentHand->getCurrentBeRo()->getHighestCardsValue() ) { + if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD && (*it_c)->getMyCardsValueInt() == currentHand->getCurrentBeRo()->getHighestCardsValue() ) { - //Show "Winner" label - actionLabelArray[(*it_c)->getMyID()]->setPixmap(QPixmap::fromImage(QImage(myGameTableStyle->getActionPic(7)))); + //Show "Winner" label + actionLabelArray[(*it_c)->getMyID()]->setPixmap(QPixmap::fromImage(QImage(myGameTableStyle->getActionPic(7)))); - //show winnercards if more than one player is active TODO - if ( nonfoldPlayerCounter != 1 && myConfig->readConfigInt("ShowFadeOutCardsAnimation")) { + //show winnercards if more than one player is active TODO + if ( nonfoldPlayerCounter != 1 && myConfig->readConfigInt("ShowFadeOutCardsAnimation")) { - int j; - int bestHandPos[5]; - (*it_c)->getMyBestHandPosition(bestHandPos); + int j; + int bestHandPos[5]; + (*it_c)->getMyBestHandPosition(bestHandPos); - bool index0 = TRUE; - for(j=0; j<5; j++) { - if (bestHandPos[j] == 0 ) { index0 = FALSE; } - } - if (index0) { holeCardsArray[(*it_c)->getMyID()][0]->startFadeOut(guiGameSpeed); /*cout << "Fade Out index0" << endl;*/} - //index 1 testen - bool index1 = TRUE; - for(j=0; j<5; j++) { - if (bestHandPos[j] == 1 ) { index1 = FALSE; } - } - if (index1) { holeCardsArray[(*it_c)->getMyID()][1]->startFadeOut(guiGameSpeed); /*cout << "Fade Out index1" << endl;*/} - //index 2 testen - bool index2 = TRUE; - for(j=0; j<5; j++) { - if (bestHandPos[j] == 2 ) { index2 = FALSE; } - } - if (index2) { boardCardsArray[0]->startFadeOut(guiGameSpeed); /*cout << "Fade Out index2" << endl;*/} - //index 3 testen - bool index3 = TRUE; - for(j=0; j<5; j++) { - if (bestHandPos[j] == 3 ) { index3 = FALSE; } - } - if (index3) { boardCardsArray[1]->startFadeOut(guiGameSpeed); /*cout << "Fade Out index3" << endl;*/} - //index 4 testen - bool index4 = TRUE; - for(j=0; j<5; j++) { - if (bestHandPos[j] == 4 ) { index4 = FALSE; } - } - if (index4) { boardCardsArray[2]->startFadeOut(guiGameSpeed); /*cout << "Fade Out index4" << endl;*/} - //index 5 testen - bool index5 = TRUE; - for(j=0; j<5; j++) { - if (bestHandPos[j] == 5 ) { index5 = FALSE; } - } - if (index5) { boardCardsArray[3]->startFadeOut(guiGameSpeed); /*cout << "Fade Out index5" << endl;*/} - //index 6 testen - bool index6 = TRUE; - for(j=0; j<5; j++) { - if (bestHandPos[j] == 6 ) { index6 = FALSE; } - } - if (index6) { boardCardsArray[4]->startFadeOut(guiGameSpeed); /*cout << "Fade Out index6" << endl;*/} - } - //Pot-Verteilung Loggen - //Pro Spieler den Cash aus dem Player und dem Label auslesen. Player_cash - Label_cash = Gewinnsumme - int pot = (*it_c)->getLastMoneyWon(); - //Wenn River dann auch das Blatt loggen! - // if (textLabel_handLabel->text() == "River") { + bool index0 = TRUE; + for(j=0; j<5; j++) { + if (bestHandPos[j] == 0 ) { + index0 = FALSE; + } + } + if (index0) { + holeCardsArray[(*it_c)->getMyID()][0]->startFadeOut(guiGameSpeed); /*cout << "Fade Out index0" << endl;*/ + } + //index 1 testen + bool index1 = TRUE; + for(j=0; j<5; j++) { + if (bestHandPos[j] == 1 ) { + index1 = FALSE; + } + } + if (index1) { + holeCardsArray[(*it_c)->getMyID()][1]->startFadeOut(guiGameSpeed); /*cout << "Fade Out index1" << endl;*/ + } + //index 2 testen + bool index2 = TRUE; + for(j=0; j<5; j++) { + if (bestHandPos[j] == 2 ) { + index2 = FALSE; + } + } + if (index2) { + boardCardsArray[0]->startFadeOut(guiGameSpeed); /*cout << "Fade Out index2" << endl;*/ + } + //index 3 testen + bool index3 = TRUE; + for(j=0; j<5; j++) { + if (bestHandPos[j] == 3 ) { + index3 = FALSE; + } + } + if (index3) { + boardCardsArray[1]->startFadeOut(guiGameSpeed); /*cout << "Fade Out index3" << endl;*/ + } + //index 4 testen + bool index4 = TRUE; + for(j=0; j<5; j++) { + if (bestHandPos[j] == 4 ) { + index4 = FALSE; + } + } + if (index4) { + boardCardsArray[2]->startFadeOut(guiGameSpeed); /*cout << "Fade Out index4" << endl;*/ + } + //index 5 testen + bool index5 = TRUE; + for(j=0; j<5; j++) { + if (bestHandPos[j] == 5 ) { + index5 = FALSE; + } + } + if (index5) { + boardCardsArray[3]->startFadeOut(guiGameSpeed); /*cout << "Fade Out index5" << endl;*/ + } + //index 6 testen + bool index6 = TRUE; + for(j=0; j<5; j++) { + if (bestHandPos[j] == 6 ) { + index6 = FALSE; + } + } + if (index6) { + boardCardsArray[4]->startFadeOut(guiGameSpeed); /*cout << "Fade Out index6" << endl;*/ + } + } + //Pot-Verteilung Loggen + //Pro Spieler den Cash aus dem Player und dem Label auslesen. Player_cash - Label_cash = Gewinnsumme + int pot = (*it_c)->getLastMoneyWon(); + //Wenn River dann auch das Blatt loggen! + // if (textLabel_handLabel->text() == "River") { - //set Player value (logging) - (*it_c)->setMyWinnerState(true, pot); + //set Player value (logging) + (*it_c)->setMyWinnerState(true, pot); - // } - // else { - // myLog->logPlayerWinsMsg(i, pot); - // } - } - else { + // } + // else { + // myLog->logPlayerWinsMsg(i, pot); + // } + } else { - if( activePlayerList->size() != 1 && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && myConfig->readConfigInt("ShowFadeOutCardsAnimation") - ) { + if( activePlayerList->size() != 1 && (*it_c)->getMyAction() != PLAYER_ACTION_FOLD && myConfig->readConfigInt("ShowFadeOutCardsAnimation") + ) { - //aufgedeckte Gegner auch ausblenden - holeCardsArray[(*it_c)->getMyID()][0]->startFadeOut(guiGameSpeed); - holeCardsArray[(*it_c)->getMyID()][1]->startFadeOut(guiGameSpeed); - } - } - } + //aufgedeckte Gegner auch ausblenden + holeCardsArray[(*it_c)->getMyID()][0]->startFadeOut(guiGameSpeed); + holeCardsArray[(*it_c)->getMyID()][1]->startFadeOut(guiGameSpeed); + } + } + } - // log side pot winners -> TODO - list::iterator it_int; + // log side pot winners -> TODO + list::iterator it_int; for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD && (*it_c)->getMyCardsValueInt() != currentHand->getCurrentBeRo()->getHighestCardsValue() ) { + if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD && (*it_c)->getMyCardsValueInt() != currentHand->getCurrentBeRo()->getHighestCardsValue() ) { for(it_int = winners.begin(); it_int != winners.end(); ++it_int) { - if((*it_int) == (*it_c)->getMyUniqueID()) { - int pot = (*it_c)->getLastMoneyWon(); - (*it_c)->setMyWinnerState(false, pot); - } - } + if((*it_int) == (*it_c)->getMyUniqueID()) { + int pot = (*it_c)->getLastMoneyWon(); + (*it_c)->setMyWinnerState(false, pot); + } + } - } - } + } + } for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - if((*it_c)->getMyCash() == 0) { - currentHand->getGuiInterface()->logPlayerSitsOut((*it_c)->getMyName()); - } - } + if((*it_c)->getMyCash() == 0) { + currentHand->getGuiInterface()->logPlayerSitsOut((*it_c)->getMyName()); + } + } - textBrowser_Log->append(""); + textBrowser_Log->append(""); - postRiverRunAnimation3Timer->start(postRiverRunAnimationSpeed/2); + postRiverRunAnimation3Timer->start(postRiverRunAnimationSpeed/2); } -void gameTableImpl::postRiverRunAnimation4() { +void gameTableImpl::postRiverRunAnimation4() +{ - distributePotAnimCounter=0; - potDistributeTimer->start(winnerBlinkSpeed); + distributePotAnimCounter=0; + potDistributeTimer->start(winnerBlinkSpeed); } -void gameTableImpl::postRiverRunAnimation5() { +void gameTableImpl::postRiverRunAnimation5() +{ - boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); - PlayerList activePlayerList = currentHand->getActivePlayerList(); - PlayerListConstIterator it_c; + boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); + PlayerList activePlayerList = currentHand->getActivePlayerList(); + PlayerListConstIterator it_c; - if (distributePotAnimCounter<10) { + if (distributePotAnimCounter<10) { - if (distributePotAnimCounter==0 || distributePotAnimCounter==2 || distributePotAnimCounter==4 || distributePotAnimCounter==6 || distributePotAnimCounter==8) { + if (distributePotAnimCounter==0 || distributePotAnimCounter==2 || distributePotAnimCounter==4 || distributePotAnimCounter==6 || distributePotAnimCounter==8) { - label_Pot->setText(""); + label_Pot->setText(""); for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD && (*it_c)->getMyCardsValueInt() == currentHand->getCurrentBeRo()->getHighestCardsValue() ) { + if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD && (*it_c)->getMyCardsValueInt() == currentHand->getCurrentBeRo()->getHighestCardsValue() ) { - playerNameLabelArray[(*it_c)->getMyID()]->hide(); - } - } - } - else { - label_Pot->setText(PotString); + playerNameLabelArray[(*it_c)->getMyID()]->hide(); + } + } + } else { + label_Pot->setText(PotString); for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD && (*it_c)->getMyCardsValueInt() == currentHand->getCurrentBeRo()->getHighestCardsValue() ) { + if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD && (*it_c)->getMyCardsValueInt() == currentHand->getCurrentBeRo()->getHighestCardsValue() ) { - playerNameLabelArray[(*it_c)->getMyID()]->show(); - } - } - } + playerNameLabelArray[(*it_c)->getMyID()]->show(); + } + } + } - distributePotAnimCounter++; - } - else { - potDistributeTimer->stop(); - postRiverRunAnimation5Timer->start(gameSpeed); - } + distributePotAnimCounter++; + } else { + potDistributeTimer->stop(); + postRiverRunAnimation5Timer->start(gameSpeed); + } } -void gameTableImpl::postRiverRunAnimation6() { +void gameTableImpl::postRiverRunAnimation6() +{ - //GUI HACK show every nick label - int i; - for (i=0; ishow(); - } + //GUI HACK show every nick label + int i; + for (i=0; ishow(); + } - boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); + boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); - refreshCash(); - refreshPot(); + refreshCash(); + refreshPot(); - // TODO HACK - // Check for network client, do not start new hand if client is running. - if (myStartWindow->getSession()->isNetworkClientRunning()) - return; + // TODO HACK + // Check for network client, do not start new hand if client is running. + if (myStartWindow->getSession()->isNetworkClientRunning()) + return; - // wenn nur noch ein Spieler aktive "neues Spiel"-Dialog anzeigen - int playersPositiveCashCounter = 0; + // wenn nur noch ein Spieler aktive "neues Spiel"-Dialog anzeigen + int playersPositiveCashCounter = 0; - PlayerListConstIterator it_c; - PlayerList activePlayerList = currentHand->getActivePlayerList(); + PlayerListConstIterator it_c; + PlayerList activePlayerList = currentHand->getActivePlayerList(); for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - if ((*it_c)->getMyCash() > 0) playersPositiveCashCounter++; - } + if ((*it_c)->getMyCash() > 0) playersPositiveCashCounter++; + } - if (playersPositiveCashCounter==1) { + if (playersPositiveCashCounter==1) { for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - if ((*it_c)->getMyCash() > 0) { - currentHand->getGuiInterface()->logPlayerWinGame((*it_c)->getMyName(), myStartWindow->getSession()->getCurrentGame()->getMyGameID()); - } - } + if ((*it_c)->getMyCash() > 0) { + currentHand->getGuiInterface()->logPlayerWinGame((*it_c)->getMyName(), myStartWindow->getSession()->getCurrentGame()->getMyGameID()); + } + } - if( !DEBUG_MODE ) { + if( !DEBUG_MODE ) { - if(myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_LOCAL) { - currentGameOver = TRUE; - pushButton_break->setDisabled(FALSE); - QFontMetrics tempMetrics = this->fontMetrics(); - int width = tempMetrics.width(tr("Start")); - pushButton_break->setMinimumSize(width+10,20); - pushButton_break->setText(tr("Start")); - blinkingStartButtonAnimationTimer->start(500); - } - } - else { - myStartWindow->callNewGameDialog(); - //Bei Cancel nichts machen!!! - } - return; - } + if(myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_LOCAL) { + currentGameOver = TRUE; + pushButton_break->setDisabled(FALSE); + QFontMetrics tempMetrics = this->fontMetrics(); + int width = tempMetrics.width(tr("Start")); + pushButton_break->setMinimumSize(width+10,20); + pushButton_break->setText(tr("Start")); + blinkingStartButtonAnimationTimer->start(500); + } + } else { + myStartWindow->callNewGameDialog(); + //Bei Cancel nichts machen!!! + } + return; + } - postRiverRunAnimation6Timer->start(newRoundSpeed); + postRiverRunAnimation6Timer->start(newRoundSpeed); } void gameTableImpl::showHoleCards(unsigned playerId, bool allIn) { - boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); - //TempArrays - QPixmap tempCardsPixmapArray[2]; - int tempCardsIntArray[2]; - int showFlipcardAnimation = myConfig->readConfigInt("ShowFlipCardsAnimation"); - int j; - PlayerListConstIterator it_c; - PlayerList activePlayerList = currentHand->getActivePlayerList(); + boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); + //TempArrays + QPixmap tempCardsPixmapArray[2]; + int tempCardsIntArray[2]; + int showFlipcardAnimation = myConfig->readConfigInt("ShowFlipCardsAnimation"); + int j; + PlayerListConstIterator it_c; + PlayerList activePlayerList = currentHand->getActivePlayerList(); for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - if((*it_c)->getMyUniqueID() == playerId) { + if((*it_c)->getMyUniqueID() == playerId) { - (*it_c)->getMyCards(tempCardsIntArray); - for(j=0; j<2; j++) { + (*it_c)->getMyCards(tempCardsIntArray); + for(j=0; j<2; j++) { - if(showFlipcardAnimation) { // with Eye-Candy - holeCardsArray[(*it_c)->getMyID()][j]->startFlipCards(guiGameSpeed, QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempCardsIntArray[j], 10)+".png")), flipside); - } - else { //without Eye-Candy - tempCardsPixmapArray[j] = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempCardsIntArray[j], 10)+".png")); - holeCardsArray[(*it_c)->getMyID()][j]->setPixmap(tempCardsPixmapArray[j], FALSE); - } - } - //set Player value (logging) - if(currentHand->getCurrentRound() < 3 || allIn) { - (*it_c)->setMyCardsFlip(1,2); //for bero before postriver or allin just log the hole cards - } - else { - (*it_c)->setMyCardsFlip(1,1); //for postriver log the value - } - } - } + if(showFlipcardAnimation) { // with Eye-Candy + holeCardsArray[(*it_c)->getMyID()][j]->startFlipCards(guiGameSpeed, QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempCardsIntArray[j], 10)+".png")), flipside); + } else { //without Eye-Candy + tempCardsPixmapArray[j] = QPixmap::fromImage(QImage(myCardDeckStyle->getCurrentDir()+QString::number(tempCardsIntArray[j], 10)+".png")); + holeCardsArray[(*it_c)->getMyID()][j]->setPixmap(tempCardsPixmapArray[j], FALSE); + } + } + //set Player value (logging) + if(currentHand->getCurrentRound() < 3 || allIn) { + (*it_c)->setMyCardsFlip(1,2); //for bero before postriver or allin just log the hole cards + } else { + (*it_c)->setMyCardsFlip(1,1); //for postriver log the value + } + } + } } -void gameTableImpl::flipHolecardsAllIn() { +void gameTableImpl::flipHolecardsAllIn() +{ boost::shared_ptr currentGame = myStartWindow->getSession()->getCurrentGame(); - if(!flipHolecardsAllInAlreadyDone) { - //Aktive Spieler zählen --> wenn nur noch einer nicht-folded dann keine Karten umdrehen - int nonfoldPlayersCounter = 0; - PlayerListConstIterator it_c; + if(!flipHolecardsAllInAlreadyDone) { + //Aktive Spieler zählen --> wenn nur noch einer nicht-folded dann keine Karten umdrehen + int nonfoldPlayersCounter = 0; + PlayerListConstIterator it_c; PlayerList activePlayerList = currentGame->getActivePlayerList(); for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - if ((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) nonfoldPlayersCounter++; - } + if ((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) nonfoldPlayersCounter++; + } - if(nonfoldPlayersCounter!=1) { + if(nonfoldPlayersCounter!=1) { for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { + if((*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { - showHoleCards((*it_c)->getMyUniqueID()); - } - } - } + showHoleCards((*it_c)->getMyUniqueID()); + } + } + } - //Wenn einmal umgedreht dann fertig!! - flipHolecardsAllInAlreadyDone = TRUE; - } + //Wenn einmal umgedreht dann fertig!! + flipHolecardsAllInAlreadyDone = TRUE; + } } -void gameTableImpl::startNewHand() { +void gameTableImpl::startNewHand() +{ - if( !breakAfterCurrentHand){ - myStartWindow->getSession()->getCurrentGame()->initHand(); - myStartWindow->getSession()->getCurrentGame()->startHand(); - } - else { + if( !breakAfterCurrentHand) { + myStartWindow->getSession()->getCurrentGame()->initHand(); + myStartWindow->getSession()->getCurrentGame()->startHand(); + } else { - if(myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_LOCAL) { - pushButton_break->setDisabled(FALSE); + if(myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_LOCAL) { + pushButton_break->setDisabled(FALSE); - QFontMetrics tempMetrics = this->fontMetrics(); - int width = tempMetrics.width(tr("Start")); - pushButton_break->setMinimumSize(width+10,20); + QFontMetrics tempMetrics = this->fontMetrics(); + int width = tempMetrics.width(tr("Start")); + pushButton_break->setMinimumSize(width+10,20); - pushButton_break->setText(tr("Start")); - breakAfterCurrentHand=FALSE; + pushButton_break->setText(tr("Start")); + breakAfterCurrentHand=FALSE; - blinkingStartButtonAnimationTimer->start(500); - } - } + blinkingStartButtonAnimationTimer->start(500); + } + } } -void gameTableImpl::handSwitchRounds() { myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->switchRounds(); +void gameTableImpl::handSwitchRounds() +{ + myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->switchRounds(); } -void gameTableImpl::nextRoundCleanGui() { +void gameTableImpl::nextRoundCleanGui() +{ - int i,j; + int i,j; - // GUI bereinigen - Bilder löschen, Animationen unterbrechen - QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png")); - for (i=0; i<5; i++ ) { - boardCardsArray[i]->setPixmap(onePix, FALSE); - boardCardsArray[i]->setFadeOutAction(FALSE); - boardCardsArray[i]->stopFlipCardsAnimation(); + // GUI bereinigen - Bilder löschen, Animationen unterbrechen + QPixmap onePix = QPixmap::fromImage(QImage(myAppDataPath +"gfx/gui/misc/1px.png")); + for (i=0; i<5; i++ ) { + boardCardsArray[i]->setPixmap(onePix, FALSE); + boardCardsArray[i]->setFadeOutAction(FALSE); + boardCardsArray[i]->stopFlipCardsAnimation(); - } - for (i=0; istopTimeOutAnimation(); - for ( j=0; j<=1; j++ ) { - holeCardsArray[i][j]->setFadeOutAction(FALSE); - holeCardsArray[i][j]->stopFlipCardsAnimation(); - } - } + } + for (i=0; istopTimeOutAnimation(); + for ( j=0; j<=1; j++ ) { + holeCardsArray[i][j]->setFadeOutAction(FALSE); + holeCardsArray[i][j]->stopFlipCardsAnimation(); + } + } - // for startNewGame during human player is active - if(myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getSeatsList()->front()->getMyActiveStatus() == 1) { - disableMyButtons(); - } + // for startNewGame during human player is active + if(myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getSeatsList()->front()->getMyActiveStatus() == 1) { + disableMyButtons(); + } - textLabel_handLabel->setText(""); + textLabel_handLabel->setText(""); - refreshAll(); + refreshAll(); - flipHolecardsAllInAlreadyDone = FALSE; + flipHolecardsAllInAlreadyDone = FALSE; - //Wenn Pause zwischen den Hands in der Konfiguration steht den Stop Button drücken! - if (myConfig->readConfigInt("PauseBetweenHands") /*&& blinkingStartButtonAnimationTimer->isActive() == FALSE*/ && myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_LOCAL) { - pushButton_break->click(); - } - else { - //FIX STRG+N Bug - pushButton_break->setEnabled(TRUE); - breakAfterCurrentHand=FALSE; - } + //Wenn Pause zwischen den Hands in der Konfiguration steht den Stop Button drücken! + if (myConfig->readConfigInt("PauseBetweenHands") /*&& blinkingStartButtonAnimationTimer->isActive() == FALSE*/ && myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_LOCAL) { + pushButton_break->click(); + } else { + //FIX STRG+N Bug + pushButton_break->setEnabled(TRUE); + breakAfterCurrentHand=FALSE; + } - //Clean breakbutton - if(myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_LOCAL) { - blinkingStartButtonAnimationTimer->stop(); - myGameTableStyle->setBreakButtonStyle(pushButton_break,0); - blinkingStartButtonAnimationTimer->stop(); - QFontMetrics tempMetrics = this->fontMetrics(); - int width = tempMetrics.width(tr("Stop")); - pushButton_break->setMinimumSize(width+10,20); - pushButton_break->setText(tr("Stop")); - } - //Clear Statusbarmessage - // statusBar()->clearMessage(); + //Clean breakbutton + if(myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_LOCAL) { + blinkingStartButtonAnimationTimer->stop(); + myGameTableStyle->setBreakButtonStyle(pushButton_break,0); + blinkingStartButtonAnimationTimer->stop(); + QFontMetrics tempMetrics = this->fontMetrics(); + int width = tempMetrics.width(tr("Stop")); + pushButton_break->setMinimumSize(width+10,20); + pushButton_break->setText(tr("Stop")); + } + //Clear Statusbarmessage + // statusBar()->clearMessage(); - //fix press mouse button during bankrupt with anti-peek-mode - this->mouseOverFlipCards(FALSE); + //fix press mouse button during bankrupt with anti-peek-mode + this->mouseOverFlipCards(FALSE); - horizontalSlider_bet->setDisabled(TRUE); - spinBox_betValue->setDisabled(TRUE); + horizontalSlider_bet->setDisabled(TRUE); + spinBox_betValue->setDisabled(TRUE); - uncheckMyButtons(); - myButtonsCheckable(FALSE); - resetMyButtonsCheckStateMemory(); - clearMyButtons(); - pushButton_showMyCards->hide(); + uncheckMyButtons(); + myButtonsCheckable(FALSE); + resetMyButtonsCheckStateMemory(); + clearMyButtons(); + pushButton_showMyCards->hide(); } -void gameTableImpl::stopTimer() { +void gameTableImpl::stopTimer() +{ - dealFlopCards0Timer->stop(); - dealFlopCards1Timer->stop(); - dealFlopCards2Timer->stop(); - dealFlopCards3Timer->stop(); - dealFlopCards4Timer->stop(); - dealFlopCards5Timer->stop(); - dealFlopCards6Timer->stop(); - dealTurnCards0Timer->stop(); - dealTurnCards1Timer->stop(); - dealTurnCards2Timer->stop(); - dealRiverCards0Timer->stop(); - dealRiverCards1Timer->stop(); - dealRiverCards2Timer->stop(); + dealFlopCards0Timer->stop(); + dealFlopCards1Timer->stop(); + dealFlopCards2Timer->stop(); + dealFlopCards3Timer->stop(); + dealFlopCards4Timer->stop(); + dealFlopCards5Timer->stop(); + dealFlopCards6Timer->stop(); + dealTurnCards0Timer->stop(); + dealTurnCards1Timer->stop(); + dealTurnCards2Timer->stop(); + dealRiverCards0Timer->stop(); + dealRiverCards1Timer->stop(); + dealRiverCards2Timer->stop(); - nextPlayerAnimationTimer->stop(); - preflopAnimation1Timer->stop(); - preflopAnimation2Timer->stop(); - flopAnimation1Timer->stop(); - flopAnimation2Timer->stop(); - turnAnimation1Timer->stop(); - turnAnimation2Timer->stop(); - riverAnimation1Timer->stop(); - riverAnimation2Timer->stop(); + nextPlayerAnimationTimer->stop(); + preflopAnimation1Timer->stop(); + preflopAnimation2Timer->stop(); + flopAnimation1Timer->stop(); + flopAnimation2Timer->stop(); + turnAnimation1Timer->stop(); + turnAnimation2Timer->stop(); + riverAnimation1Timer->stop(); + riverAnimation2Timer->stop(); - postRiverAnimation1Timer->stop(); - postRiverRunAnimation1Timer->stop(); - postRiverRunAnimation2Timer->stop(); - postRiverRunAnimation3Timer->stop(); - postRiverRunAnimation5Timer->stop(); - postRiverRunAnimation6Timer->stop(); - potDistributeTimer->stop(); + postRiverAnimation1Timer->stop(); + postRiverRunAnimation1Timer->stop(); + postRiverRunAnimation2Timer->stop(); + postRiverRunAnimation3Timer->stop(); + postRiverRunAnimation5Timer->stop(); + postRiverRunAnimation6Timer->stop(); + potDistributeTimer->stop(); } -void gameTableImpl::setSpeeds() { +void gameTableImpl::setSpeeds() +{ - gameSpeed = (11-guiGameSpeed)*10; - dealCardsSpeed = (gameSpeed/2)*10; //milliseconds - preDealCardsSpeed = dealCardsSpeed*2; //Zeit for Karten aufdecken auf dem Board (Flop, Turn, River) - postDealCardsSpeed = dealCardsSpeed*3; //Zeit nach Karten aufdecken auf dem Board (Flop, Turn, River) - AllInDealCardsSpeed = dealCardsSpeed*4; //Zeit nach Karten aufdecken auf dem Board (Flop, Turn, River) bei AllIn - postRiverRunAnimationSpeed = gameSpeed*18; - winnerBlinkSpeed = gameSpeed*3; //milliseconds - newRoundSpeed = gameSpeed*35; - nextPlayerSpeed1 = gameSpeed*10; // Zeit zwischen dem Setzen des Spielers und dem Verdunkeln - nextPlayerSpeed2 = gameSpeed*4; // Zeit zwischen Verdunkeln des einen und aufhellen des anderen Spielers - nextPlayerSpeed3 = gameSpeed*7; // Zeit bis zwischen Aufhellen und Aktion - preflopNextPlayerSpeed = gameSpeed*10; // Zeit bis zwischen Aufhellen und Aktion im Preflop (etwas langsamer da nicht gerechnet wird. ) + gameSpeed = (11-guiGameSpeed)*10; + dealCardsSpeed = (gameSpeed/2)*10; //milliseconds + preDealCardsSpeed = dealCardsSpeed*2; //Zeit for Karten aufdecken auf dem Board (Flop, Turn, River) + postDealCardsSpeed = dealCardsSpeed*3; //Zeit nach Karten aufdecken auf dem Board (Flop, Turn, River) + AllInDealCardsSpeed = dealCardsSpeed*4; //Zeit nach Karten aufdecken auf dem Board (Flop, Turn, River) bei AllIn + postRiverRunAnimationSpeed = gameSpeed*18; + winnerBlinkSpeed = gameSpeed*3; //milliseconds + newRoundSpeed = gameSpeed*35; + nextPlayerSpeed1 = gameSpeed*10; // Zeit zwischen dem Setzen des Spielers und dem Verdunkeln + nextPlayerSpeed2 = gameSpeed*4; // Zeit zwischen Verdunkeln des einen und aufhellen des anderen Spielers + nextPlayerSpeed3 = gameSpeed*7; // Zeit bis zwischen Aufhellen und Aktion + preflopNextPlayerSpeed = gameSpeed*10; // Zeit bis zwischen Aufhellen und Aktion im Preflop (etwas langsamer da nicht gerechnet wird. ) } -void gameTableImpl::breakButtonClicked() { +void gameTableImpl::breakButtonClicked() +{ - if (pushButton_break->text() == tr("Stop")) { - pushButton_break->setDisabled(TRUE); - breakAfterCurrentHand=TRUE; - } - else if (pushButton_break->text() == tr("Lobby")) { - leaveCurrentNetworkGame(); - } - else if (pushButton_break->text() == tr("Start")) { + if (pushButton_break->text() == tr("Stop")) { + pushButton_break->setDisabled(TRUE); + breakAfterCurrentHand=TRUE; + } else if (pushButton_break->text() == tr("Lobby")) { + leaveCurrentNetworkGame(); + } else if (pushButton_break->text() == tr("Start")) { - blinkingStartButtonAnimationTimer->stop(); - //Set default Color - myGameTableStyle->setBreakButtonStyle(pushButton_break,0); - QFontMetrics tempMetrics = this->fontMetrics(); - int width = tempMetrics.width(tr("Stop")); - pushButton_break->setMinimumSize(width+10,20); + blinkingStartButtonAnimationTimer->stop(); + //Set default Color + myGameTableStyle->setBreakButtonStyle(pushButton_break,0); + QFontMetrics tempMetrics = this->fontMetrics(); + int width = tempMetrics.width(tr("Stop")); + pushButton_break->setMinimumSize(width+10,20); - pushButton_break->setText(tr("Stop")); + pushButton_break->setText(tr("Stop")); - if(currentGameOver) { - currentGameOver = FALSE; - myStartWindow->callNewGameDialog(); - //Bei Cancel nichts machen!!! - } - else { - startNewHand(); - } - } + if(currentGameOver) { + currentGameOver = FALSE; + myStartWindow->callNewGameDialog(); + //Bei Cancel nichts machen!!! + } else { + startNewHand(); + } + } } -void gameTableImpl::keyPressEvent ( QKeyEvent * event ) { +void gameTableImpl::keyPressEvent ( QKeyEvent * event ) +{ - // cout << event->key() << endl; + // cout << event->key() << endl; - //bool ctrlPressed = FALSE; + //bool ctrlPressed = FALSE; - if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return ) /*ENTER*/ { - if(spinBox_betValue->hasFocus()) { - pushButton_BetRaise->click(); - } - } - if (event->key() == Qt::Key_F1) { - if (myConfig->readConfigInt("AlternateFKeysUserActionMode") == 0) { - pushButton_Fold->click(); - } else { - pushButton_AllIn->click(); - } - } - if (event->key() == Qt::Key_F2) { - if (myConfig->readConfigInt("AlternateFKeysUserActionMode") == 0) { - pushButton_CallCheck->click(); - } else { - pushButton_BetRaise->click(); - } + if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return ) { /*ENTER*/ + if(spinBox_betValue->hasFocus()) { + pushButton_BetRaise->click(); + } + } + if (event->key() == Qt::Key_F1) { + if (myConfig->readConfigInt("AlternateFKeysUserActionMode") == 0) { + pushButton_Fold->click(); + } else { + pushButton_AllIn->click(); + } + } + if (event->key() == Qt::Key_F2) { + if (myConfig->readConfigInt("AlternateFKeysUserActionMode") == 0) { + pushButton_CallCheck->click(); + } else { + pushButton_BetRaise->click(); + } - } - if (event->key() == Qt::Key_F3 ) { - if (myConfig->readConfigInt("AlternateFKeysUserActionMode") == 0) { - pushButton_BetRaise->click(); - } else { - pushButton_CallCheck->click(); - } - } - if (event->key() == Qt::Key_F4) { - if (myConfig->readConfigInt("AlternateFKeysUserActionMode") == 0) { - pushButton_AllIn->click(); - } else { - pushButton_Fold->click(); - } - } - if (event->key() == Qt::Key_F5) { pushButton_showMyCards->click(); } + } + if (event->key() == Qt::Key_F3 ) { + if (myConfig->readConfigInt("AlternateFKeysUserActionMode") == 0) { + pushButton_BetRaise->click(); + } else { + pushButton_CallCheck->click(); + } + } + if (event->key() == Qt::Key_F4) { + if (myConfig->readConfigInt("AlternateFKeysUserActionMode") == 0) { + pushButton_AllIn->click(); + } else { + pushButton_Fold->click(); + } + } + if (event->key() == Qt::Key_F5) { + pushButton_showMyCards->click(); + } - if (event->key() == Qt::Key_F6) { radioButton_manualAction->click(); } - if (event->key() == Qt::Key_F7) { radioButton_autoCheckFold->click(); } - if (event->key() == Qt::Key_F8) { radioButton_autoCheckCallAny->click(); } - if (event->key() == Qt::Key_Shift) { - if(myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_LOCAL) { - pushButton_break->click(); - //ctrlPressed = TRUE; - } - } - // if (event->key() == Qt::Key_Escape && (myActionIsBet || myActionIsRaise)) { - // meInAction(); - // } - if (event->key() == Qt::Key_Up && lineEdit_ChatInput->hasFocus()) { - if((keyUpDownChatCounter + 1) <= myChat->getChatLinesHistorySize()) { keyUpDownChatCounter++; } - // std::cout << "Up keyUpDownChatCounter: " << keyUpDownChatCounter << "\n"; - myChat->showChatHistoryIndex(keyUpDownChatCounter); - } - else if(event->key() == Qt::Key_Down && lineEdit_ChatInput->hasFocus()) { - if((keyUpDownChatCounter - 1) >= 0) { keyUpDownChatCounter--; } - // std::cout << "Down keyUpDownChatCounter: " << keyUpDownChatCounter << "\n"; - myChat->showChatHistoryIndex(keyUpDownChatCounter); - } - else { keyUpDownChatCounter = 0; } + if (event->key() == Qt::Key_F6) { + radioButton_manualAction->click(); + } + if (event->key() == Qt::Key_F7) { + radioButton_autoCheckFold->click(); + } + if (event->key() == Qt::Key_F8) { + radioButton_autoCheckCallAny->click(); + } + if (event->key() == Qt::Key_Shift) { + if(myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_LOCAL) { + pushButton_break->click(); + //ctrlPressed = TRUE; + } + } + // if (event->key() == Qt::Key_Escape && (myActionIsBet || myActionIsRaise)) { + // meInAction(); + // } + if (event->key() == Qt::Key_Up && lineEdit_ChatInput->hasFocus()) { + if((keyUpDownChatCounter + 1) <= myChat->getChatLinesHistorySize()) { + keyUpDownChatCounter++; + } + // std::cout << "Up keyUpDownChatCounter: " << keyUpDownChatCounter << "\n"; + myChat->showChatHistoryIndex(keyUpDownChatCounter); + } else if(event->key() == Qt::Key_Down && lineEdit_ChatInput->hasFocus()) { + if((keyUpDownChatCounter - 1) >= 0) { + keyUpDownChatCounter--; + } + // std::cout << "Down keyUpDownChatCounter: " << keyUpDownChatCounter << "\n"; + myChat->showChatHistoryIndex(keyUpDownChatCounter); + } else { + keyUpDownChatCounter = 0; + } - //TESTING UNIT - // if (event->key() == Qt::Key_M) { showShowMyCardsButton(); } + //TESTING UNIT + // if (event->key() == Qt::Key_M) { showShowMyCardsButton(); } } -void gameTableImpl::changePlayingMode() { +void gameTableImpl::changePlayingMode() +{ - int mode = -1; + int mode = -1; - if(radioButton_manualAction->isChecked()) { mode=0; } - if(radioButton_autoCheckFold->isChecked()) { mode=2; } - if(radioButton_autoCheckCallAny->isChecked()) { mode=1; } + if(radioButton_manualAction->isChecked()) { + mode=0; + } + if(radioButton_autoCheckFold->isChecked()) { + mode=2; + } + if(radioButton_autoCheckCallAny->isChecked()) { + mode=1; + } - switch (mode) { + switch (mode) { - // case 0: { statusBar()->showMessage(tr("Manual mode set. You've got to choose yourself now."), 5000); } - break; - // case 1: { statusBar()->showMessage(tr("Auto mode set: Check or call any."), 5000); } - break; - // case 2: { statusBar()->showMessage(tr("Auto mode set: Check or fold."), 5000); } - break; - default: { /*cout << "changePlayingMode ERROR!!!!" << endl;*/ } + // case 0: { statusBar()->showMessage(tr("Manual mode set. You've got to choose yourself now."), 5000); } + break; + // case 1: { statusBar()->showMessage(tr("Auto mode set: Check or call any."), 5000); } + break; + // case 2: { statusBar()->showMessage(tr("Auto mode set: Check or fold."), 5000); } + break; + default: { + /*cout << "changePlayingMode ERROR!!!!" << endl;*/ + } - } + } - playingMode = mode; + playingMode = mode; } bool gameTableImpl::eventFilter(QObject *obj, QEvent *event) { - QKeyEvent *keyEvent = static_cast(event); + QKeyEvent *keyEvent = static_cast(event); - if (/*obj == lineEdit_ChatInput && lineEdit_ChatInput->text() != "" && */event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Tab) { - myChat->nickAutoCompletition(); - return true; - } - else if (event->type() == QEvent::Close) { - event->ignore(); - closeGameTable(); - return true; - } - else { - // pass the event on to the parent class - return QMainWindow::eventFilter(obj, event); - } + if (/*obj == lineEdit_ChatInput && lineEdit_ChatInput->text() != "" && */event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Tab) { + myChat->nickAutoCompletition(); + return true; + } else if (event->type() == QEvent::Close) { + event->ignore(); + closeGameTable(); + return true; + } else { + // pass the event on to the parent class + return QMainWindow::eventFilter(obj, event); + } } -void gameTableImpl::switchChatWindow() { +void gameTableImpl::switchChatWindow() +{ - int tab = 1; - if (groupBox_LeftToolBox->isHidden()) { - tabWidget_Left->setCurrentIndex(tab); - groupBox_LeftToolBox->show(); - } else { - if (tabWidget_Left->currentIndex() == tab) { - groupBox_LeftToolBox->hide(); - } else { - tabWidget_Left->setCurrentIndex(tab); - } - } + int tab = 1; + if (groupBox_LeftToolBox->isHidden()) { + tabWidget_Left->setCurrentIndex(tab); + groupBox_LeftToolBox->show(); + } else { + if (tabWidget_Left->currentIndex() == tab) { + groupBox_LeftToolBox->hide(); + } else { + tabWidget_Left->setCurrentIndex(tab); + } + } } -void gameTableImpl::switchHelpWindow() { +void gameTableImpl::switchHelpWindow() +{ - int tab = 0; - if (groupBox_LeftToolBox->isHidden()) { - tabWidget_Left->setCurrentIndex(tab); - groupBox_LeftToolBox->show(); - } else { - if (tabWidget_Left->currentIndex() == tab) { - groupBox_LeftToolBox->hide(); - } else { - tabWidget_Left->setCurrentIndex(tab); - } - } + int tab = 0; + if (groupBox_LeftToolBox->isHidden()) { + tabWidget_Left->setCurrentIndex(tab); + groupBox_LeftToolBox->show(); + } else { + if (tabWidget_Left->currentIndex() == tab) { + groupBox_LeftToolBox->hide(); + } else { + tabWidget_Left->setCurrentIndex(tab); + } + } } -void gameTableImpl::switchLogWindow() { +void gameTableImpl::switchLogWindow() +{ - int tab = 0; - if (groupBox_RightToolBox->isHidden()) { - tabWidget_Right->setCurrentIndex(tab); - groupBox_RightToolBox->show(); - } else { - if (tabWidget_Right->currentIndex() == tab) { - groupBox_RightToolBox->hide(); - } else { - tabWidget_Right->setCurrentIndex(tab); - } - } + int tab = 0; + if (groupBox_RightToolBox->isHidden()) { + tabWidget_Right->setCurrentIndex(tab); + groupBox_RightToolBox->show(); + } else { + if (tabWidget_Right->currentIndex() == tab) { + groupBox_RightToolBox->hide(); + } else { + tabWidget_Right->setCurrentIndex(tab); + } + } } -void gameTableImpl::switchAwayWindow() { +void gameTableImpl::switchAwayWindow() +{ - int tab = 1; - if (groupBox_RightToolBox->isHidden()) { - tabWidget_Right->setCurrentIndex(tab); - groupBox_RightToolBox->show(); - } else { - if (tabWidget_Right->currentIndex() == tab) { - groupBox_RightToolBox->hide(); - } else { - tabWidget_Right->setCurrentIndex(tab); - } - } + int tab = 1; + if (groupBox_RightToolBox->isHidden()) { + tabWidget_Right->setCurrentIndex(tab); + groupBox_RightToolBox->show(); + } else { + if (tabWidget_Right->currentIndex() == tab) { + groupBox_RightToolBox->hide(); + } else { + tabWidget_Right->setCurrentIndex(tab); + } + } } -void gameTableImpl::switchChanceWindow() { +void gameTableImpl::switchChanceWindow() +{ - int tab = 2; - if (groupBox_RightToolBox->isHidden()) { - tabWidget_Right->setCurrentIndex(tab); - groupBox_RightToolBox->show(); - } else { - if (tabWidget_Right->currentIndex() == tab) { - groupBox_RightToolBox->hide(); - } else { - tabWidget_Right->setCurrentIndex(tab); - } - } + int tab = 2; + if (groupBox_RightToolBox->isHidden()) { + tabWidget_Right->setCurrentIndex(tab); + groupBox_RightToolBox->show(); + } else { + if (tabWidget_Right->currentIndex() == tab) { + groupBox_RightToolBox->hide(); + } else { + tabWidget_Right->setCurrentIndex(tab); + } + } } -void gameTableImpl::switchFullscreen() { +void gameTableImpl::switchFullscreen() +{ - if (this->isFullScreen()) { - this->showNormal(); - } - else { - this->showFullScreen(); - } + if (this->isFullScreen()) { + this->showNormal(); + } else { + this->showFullScreen(); + } } -void gameTableImpl::blinkingStartButtonAnimationAction() { +void gameTableImpl::blinkingStartButtonAnimationAction() +{ - QString style = pushButton_break->styleSheet(); + QString style = pushButton_break->styleSheet(); - if(style.contains("QPushButton:enabled { background-color: #"+myGameTableStyle->getBreakLobbyButtonBgColor())) { - myGameTableStyle->setBreakButtonStyle(pushButton_break,1); - } - else { - myGameTableStyle->setBreakButtonStyle(pushButton_break,0); - } + if(style.contains("QPushButton:enabled { background-color: #"+myGameTableStyle->getBreakLobbyButtonBgColor())) { + myGameTableStyle->setBreakButtonStyle(pushButton_break,1); + } else { + myGameTableStyle->setBreakButtonStyle(pushButton_break,0); + } } -void gameTableImpl::sendChatMessage() { myChat->sendMessage(); } -void gameTableImpl::checkChatInputLength(QString string) { myChat->checkInputLength(string); } - - -void gameTableImpl::tabSwitchAction() { - - switch(tabWidget_Left->currentIndex()) { - - case 1: { lineEdit_ChatInput->setFocus(); } - break; - default: { lineEdit_ChatInput->clearFocus(); } - - } +void gameTableImpl::sendChatMessage() +{ + myChat->sendMessage(); +} +void gameTableImpl::checkChatInputLength(QString string) +{ + myChat->checkInputLength(string); } -void gameTableImpl::localGameModification() { +void gameTableImpl::tabSwitchAction() +{ - tabWidget_Left->setCurrentIndex(0); - tabWidget_Left->removeTab(1); - tabWidget_Left->removeTab(1); - tabWidget_Left->removeTab(1); + switch(tabWidget_Left->currentIndex()) { - int i; - for (i=0; istopTimeOutAnimation(); - playerAvatarLabelArray[i]->setEnabledContextMenu(FALSE); - } + case 1: { + lineEdit_ChatInput->setFocus(); + } + break; + default: { + lineEdit_ChatInput->clearFocus(); + } - pushButton_break->show(); - QFontMetrics tempMetrics = this->fontMetrics(); - int width = tempMetrics.width(tr("Stop")); - pushButton_break->setText(tr("Stop")); - pushButton_break->setMinimumSize(width+10,20); - - //Set the playing mode to "manual" - radioButton_manualAction->click(); - - //clear log - textBrowser_Log->clear(); - - //restore saved windows geometry - restoreGameTableGeometry(); - - if(myGameTableStyle->getState() != GT_STYLE_OK) myGameTableStyle->showErrorMessage(); + } } -void gameTableImpl::networkGameModification() { - if(tabWidget_Left->widget(1) != tab_Chat) - tabWidget_Left->insertTab(1, tab_Chat, QString(tr("Chat"))); /*TODO text abgeschnitten --> stylesheets*/ +void gameTableImpl::localGameModification() +{ - tabWidget_Left->removeTab(2); - tabWidget_Left->removeTab(2); + tabWidget_Left->setCurrentIndex(0); + tabWidget_Left->removeTab(1); + tabWidget_Left->removeTab(1); + tabWidget_Left->removeTab(1); - tabWidget_Left->setCurrentIndex(1); - myChat->clearChat(); + int i; + for (i=0; istopTimeOutAnimation(); + playerAvatarLabelArray[i]->setEnabledContextMenu(FALSE); + } - int i; - for (i=0; isetEnabledContextMenu(TRUE); - playerAvatarLabelArray[i]->setVoteOnKickContextMenuEnabled(TRUE); - playerAvatarLabelArray[i]->setVoteRunning(FALSE); - } + pushButton_break->show(); + QFontMetrics tempMetrics = this->fontMetrics(); + int width = tempMetrics.width(tr("Stop")); + pushButton_break->setText(tr("Stop")); + pushButton_break->setMinimumSize(width+10,20); - if(myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET) { - pushButton_break->show(); - QFontMetrics tempMetrics = this->fontMetrics(); - int width = tempMetrics.width(tr("Lobby")); - pushButton_break->setText(tr("Lobby")); - pushButton_break->setMinimumSize(width+10,20); - myGameTableStyle->setBreakButtonStyle(pushButton_break,0); - blinkingStartButtonAnimationTimer->stop(); - } - if(myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK) { + //Set the playing mode to "manual" + radioButton_manualAction->click(); - pushButton_break->hide(); - } - //Set the playing mode to "manual" - radioButton_manualAction->click(); + //clear log + textBrowser_Log->clear(); - //clear log - textBrowser_Log->clear(); + //restore saved windows geometry + restoreGameTableGeometry(); - //restore saved windows geometry - restoreGameTableGeometry(); + if(myGameTableStyle->getState() != GT_STYLE_OK) myGameTableStyle->showErrorMessage(); +} - if(myStartWindow->getSession()->getClientPlayerInfo(myStartWindow->getSession()->getClientUniquePlayerId()).isGuest) { - guestUserMode(); - } - else { registeredUserMode(); } +void gameTableImpl::networkGameModification() +{ - blinkingStartButtonAnimationTimer->stop(); - myGameTableStyle->setBreakButtonStyle(pushButton_break,0); + if(tabWidget_Left->widget(1) != tab_Chat) + tabWidget_Left->insertTab(1, tab_Chat, QString(tr("Chat"))); /*TODO text abgeschnitten --> stylesheets*/ + + tabWidget_Left->removeTab(2); + tabWidget_Left->removeTab(2); + + tabWidget_Left->setCurrentIndex(1); + myChat->clearChat(); + + int i; + for (i=0; isetEnabledContextMenu(TRUE); + playerAvatarLabelArray[i]->setVoteOnKickContextMenuEnabled(TRUE); + playerAvatarLabelArray[i]->setVoteRunning(FALSE); + } + + if(myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET) { + pushButton_break->show(); + QFontMetrics tempMetrics = this->fontMetrics(); + int width = tempMetrics.width(tr("Lobby")); + pushButton_break->setText(tr("Lobby")); + pushButton_break->setMinimumSize(width+10,20); + myGameTableStyle->setBreakButtonStyle(pushButton_break,0); + blinkingStartButtonAnimationTimer->stop(); + } + if(myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK) { + + pushButton_break->hide(); + } + //Set the playing mode to "manual" + radioButton_manualAction->click(); + + //clear log + textBrowser_Log->clear(); + + //restore saved windows geometry + restoreGameTableGeometry(); + + if(myStartWindow->getSession()->getClientPlayerInfo(myStartWindow->getSession()->getClientUniquePlayerId()).isGuest) { + guestUserMode(); + } else { + registeredUserMode(); + } + + blinkingStartButtonAnimationTimer->stop(); + myGameTableStyle->setBreakButtonStyle(pushButton_break,0); } -void gameTableImpl::mouseOverFlipCards(bool front) { +void gameTableImpl::mouseOverFlipCards(bool front) +{ - if(myStartWindow->getSession()->getCurrentGame()) { - if(myConfig->readConfigInt("AntiPeekMode") && myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getSeatsList()->front()->getMyActiveStatus()/* && myStartWindow->getSession()->getCurrentGame()->getSeatsList()->front()->getMyAction() != PLAYER_ACTION_FOLD*/){ - holeCardsArray[0][0]->signalFastFlipCards(front); - holeCardsArray[0][1]->signalFastFlipCards(front); - } - } + if(myStartWindow->getSession()->getCurrentGame()) { + if(myConfig->readConfigInt("AntiPeekMode") && myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getSeatsList()->front()->getMyActiveStatus()/* && myStartWindow->getSession()->getCurrentGame()->getSeatsList()->front()->getMyAction() != PLAYER_ACTION_FOLD*/) { + holeCardsArray[0][0]->signalFastFlipCards(front); + holeCardsArray[0][1]->signalFastFlipCards(front); + } + } } -void gameTableImpl::updateMyButtonsState(int mode) { +void gameTableImpl::updateMyButtonsState(int mode) +{ boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); if(currentHand->getLastPlayersTurn() == 0) { - myButtonsCheckable(FALSE); - clearMyButtons(); - } - else { + myButtonsCheckable(FALSE); + clearMyButtons(); + } else { if(currentHand->getSeatsList()->front()->getMyAction() != PLAYER_ACTION_ALLIN) { // dont show pre-actions after flip cards when allin - myButtonsCheckable(TRUE); - provideMyActions(mode); - } - } + myButtonsCheckable(TRUE); + provideMyActions(mode); + } + } } -void gameTableImpl::uncheckMyButtons() { +void gameTableImpl::uncheckMyButtons() +{ - pushButton_BetRaise->setChecked(FALSE); - pushButton_CallCheck->setChecked(FALSE); - pushButton_Fold->setChecked(FALSE); - pushButton_AllIn->setChecked(FALSE); + pushButton_BetRaise->setChecked(FALSE); + pushButton_CallCheck->setChecked(FALSE); + pushButton_Fold->setChecked(FALSE); + pushButton_AllIn->setChecked(FALSE); } -void gameTableImpl::resetMyButtonsCheckStateMemory() { +void gameTableImpl::resetMyButtonsCheckStateMemory() +{ - pushButtonCallCheckIsChecked = FALSE; - pushButtonFoldIsChecked = FALSE; - pushButtonAllInIsChecked = FALSE; - pushButtonBetRaiseIsChecked = FALSE; + pushButtonCallCheckIsChecked = FALSE; + pushButtonFoldIsChecked = FALSE; + pushButtonAllInIsChecked = FALSE; + pushButtonBetRaiseIsChecked = FALSE; } -void gameTableImpl::clearMyButtons() { +void gameTableImpl::clearMyButtons() +{ - refreshActionButtonFKeyIndicator(1); + refreshActionButtonFKeyIndicator(1); - pushButton_BetRaise->setText(""); - pushButton_CallCheck->setText(""); - pushButton_Fold->setText(""); - pushButton_AllIn->setText(""); + pushButton_BetRaise->setText(""); + pushButton_CallCheck->setText(""); + pushButton_Fold->setText(""); + pushButton_AllIn->setText(""); } -void gameTableImpl::myButtonsCheckable(bool state) { +void gameTableImpl::myButtonsCheckable(bool state) +{ boost::shared_ptr currentHand = myStartWindow->getSession()->getCurrentGame()->getCurrentHand(); - if(state) { - //checkable + if(state) { + //checkable - // exception: full bet rule - if(!currentHand->getCurrentBeRo()->getFullBetRule()) { - pushButton_BetRaise->setCheckable(TRUE); - } - pushButton_CallCheck->setCheckable(TRUE); - pushButton_Fold->setCheckable(TRUE); - pushButton_AllIn->setCheckable(TRUE); + // exception: full bet rule + if(!currentHand->getCurrentBeRo()->getFullBetRule()) { + pushButton_BetRaise->setCheckable(TRUE); + } + pushButton_CallCheck->setCheckable(TRUE); + pushButton_Fold->setCheckable(TRUE); + pushButton_AllIn->setCheckable(TRUE); - //design - myGameTableStyle->setButtonsStyle(pushButton_BetRaise, pushButton_CallCheck, pushButton_Fold, pushButton_AllIn, 2); + //design + myGameTableStyle->setButtonsStyle(pushButton_BetRaise, pushButton_CallCheck, pushButton_Fold, pushButton_AllIn, 2); - myButtonsAreCheckable = TRUE; - } - else { - //not checkable + myButtonsAreCheckable = TRUE; + } else { + //not checkable - pushButton_BetRaise->setCheckable(FALSE); - pushButton_CallCheck->setCheckable(FALSE); - pushButton_Fold->setCheckable(FALSE); - pushButton_AllIn->setCheckable(FALSE); + pushButton_BetRaise->setCheckable(FALSE); + pushButton_CallCheck->setCheckable(FALSE); + pushButton_Fold->setCheckable(FALSE); + pushButton_AllIn->setCheckable(FALSE); - QString hover; - if(pushButton_AllIn->text()==AllInString) { - myGameTableStyle->setButtonsStyle(pushButton_BetRaise, pushButton_CallCheck, pushButton_Fold, pushButton_AllIn, 0); - } - else { - myGameTableStyle->setButtonsStyle(pushButton_BetRaise, pushButton_CallCheck, pushButton_Fold, pushButton_AllIn, 1); - } + QString hover; + if(pushButton_AllIn->text()==AllInString) { + myGameTableStyle->setButtonsStyle(pushButton_BetRaise, pushButton_CallCheck, pushButton_Fold, pushButton_AllIn, 0); + } else { + myGameTableStyle->setButtonsStyle(pushButton_BetRaise, pushButton_CallCheck, pushButton_Fold, pushButton_AllIn, 1); + } - myButtonsAreCheckable = FALSE; - } + myButtonsAreCheckable = FALSE; + } } -void gameTableImpl::showMaximized () { - this->showFullScreen (); +void gameTableImpl::showMaximized () +{ + this->showFullScreen (); } -void gameTableImpl::closeGameTable() { +void gameTableImpl::closeGameTable() +{ - if (myStartWindow->getMyServerGuiInterface() && myStartWindow->getMyServerGuiInterface()->getSession()->isNetworkServerRunning()) { + if (myStartWindow->getMyServerGuiInterface() && myStartWindow->getMyServerGuiInterface()->getSession()->isNetworkServerRunning()) { - QMessageBox msgBox(QMessageBox::Warning, tr("Closing PokerTH during network game"), - tr("You are the hosting server. Do you want to close PokerTH anyway?"), QMessageBox::Yes | QMessageBox::No, this); + QMessageBox msgBox(QMessageBox::Warning, tr("Closing PokerTH during network game"), + tr("You are the hosting server. Do you want to close PokerTH anyway?"), QMessageBox::Yes | QMessageBox::No, this); - if (msgBox.exec() == QMessageBox::Yes ) { - myStartWindow->getSession()->terminateNetworkClient(); - stopTimer(); - if (myStartWindow->getMyServerGuiInterface()) myStartWindow->getMyServerGuiInterface()->getSession()->terminateNetworkServer(); - saveGameTableGeometry(); - myStartWindow->show(); - this->hide(); - } - } - else { + if (msgBox.exec() == QMessageBox::Yes ) { + myStartWindow->getSession()->terminateNetworkClient(); + stopTimer(); + if (myStartWindow->getMyServerGuiInterface()) myStartWindow->getMyServerGuiInterface()->getSession()->terminateNetworkServer(); + saveGameTableGeometry(); + myStartWindow->show(); + this->hide(); + } + } else { - bool close = true; + bool close = true; - if(myUniversalMessageDialog->checkIfMesssageWillBeDisplayed(6) && (myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK ) && this->isVisible()) { - if (myUniversalMessageDialog->exec(6, tr("Really want to exit?"), tr("PokerTH - Close Table?"), QPixmap(":/gfx/logoChip3D.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, true) == QDialog::Rejected) { - close = false; - } - } + if(myUniversalMessageDialog->checkIfMesssageWillBeDisplayed(6) && (myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET || myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK ) && this->isVisible()) { + if (myUniversalMessageDialog->exec(6, tr("Really want to exit?"), tr("PokerTH - Close Table?"), QPixmap(":/gfx/logoChip3D.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, true) == QDialog::Rejected) { + close = false; + } + } - if(close) { - //now really close the table - myStartWindow->getSession()->terminateNetworkClient(); - stopTimer(); - saveGameTableGeometry(); - myStartWindow->show(); - this->hide(); - } - } + if(close) { + //now really close the table + myStartWindow->getSession()->terminateNetworkClient(); + stopTimer(); + saveGameTableGeometry(); + myStartWindow->show(); + this->hide(); + } + } } -void gameTableImpl::changeSpinBoxBetValue(int value) { +void gameTableImpl::changeSpinBoxBetValue(int value) +{ - if(betSliderChangedByInput) { - //prevent interval cutting of spinBox_betValue input from code below - betSliderChangedByInput = FALSE; - } - else { - int temp; - if(horizontalSlider_bet->maximum() <= 1000 ) { - temp = (int)((value/10)*10); - } - else if(horizontalSlider_bet->maximum() > 1000 && horizontalSlider_bet->maximum() <= 10000) { - temp = (int)((value/50)*50); - } - else if(horizontalSlider_bet->maximum() > 10000 && horizontalSlider_bet->maximum() <= 100000) { - temp = (int)((value/500)*500); - } - else { - temp = (int)((value/5000)*5000); - } + if(betSliderChangedByInput) { + //prevent interval cutting of spinBox_betValue input from code below + betSliderChangedByInput = FALSE; + } else { + int temp; + if(horizontalSlider_bet->maximum() <= 1000 ) { + temp = (int)((value/10)*10); + } else if(horizontalSlider_bet->maximum() > 1000 && horizontalSlider_bet->maximum() <= 10000) { + temp = (int)((value/50)*50); + } else if(horizontalSlider_bet->maximum() > 10000 && horizontalSlider_bet->maximum() <= 100000) { + temp = (int)((value/500)*500); + } else { + temp = (int)((value/5000)*5000); + } - if(temp < horizontalSlider_bet->minimum()) - spinBox_betValue->setValue(horizontalSlider_bet->minimum()); - else - spinBox_betValue->setValue(temp); - } + if(temp < horizontalSlider_bet->minimum()) + spinBox_betValue->setValue(horizontalSlider_bet->minimum()); + else + spinBox_betValue->setValue(temp); + } } -void gameTableImpl::spinBoxBetValueChanged(int value) { +void gameTableImpl::spinBoxBetValueChanged(int value) +{ - if(horizontalSlider_bet->isEnabled()) { + if(horizontalSlider_bet->isEnabled()) { - QString betRaise = pushButton_BetRaise->text().section("\n",0 ,0); + QString betRaise = pushButton_BetRaise->text().section("\n",0 ,0); - if(value >= horizontalSlider_bet->minimum()) { + if(value >= horizontalSlider_bet->minimum()) { - if(value > horizontalSlider_bet->maximum()) { // print the maximum - pushButton_BetRaise->setText(betRaise + "\n$" + QString("%L1").arg(horizontalSlider_bet->maximum())); - betSliderChangedByInput = TRUE; - horizontalSlider_bet->setValue(horizontalSlider_bet->maximum()); - } - else { // really print the value - pushButton_BetRaise->setText(betRaise + "\n$" + QString("%L1").arg(value)); - betSliderChangedByInput = TRUE; - horizontalSlider_bet->setValue(value); - } - } - else { // print the minimum - pushButton_BetRaise->setText(betRaise + "\n$" + QString("%L1").arg(horizontalSlider_bet->minimum())); - betSliderChangedByInput = TRUE; - horizontalSlider_bet->setValue(horizontalSlider_bet->minimum()); - } - } + if(value > horizontalSlider_bet->maximum()) { // print the maximum + pushButton_BetRaise->setText(betRaise + "\n$" + QString("%L1").arg(horizontalSlider_bet->maximum())); + betSliderChangedByInput = TRUE; + horizontalSlider_bet->setValue(horizontalSlider_bet->maximum()); + } else { // really print the value + pushButton_BetRaise->setText(betRaise + "\n$" + QString("%L1").arg(value)); + betSliderChangedByInput = TRUE; + horizontalSlider_bet->setValue(value); + } + } else { // print the minimum + pushButton_BetRaise->setText(betRaise + "\n$" + QString("%L1").arg(horizontalSlider_bet->minimum())); + betSliderChangedByInput = TRUE; + horizontalSlider_bet->setValue(horizontalSlider_bet->minimum()); + } + } } -void gameTableImpl::leaveCurrentNetworkGame() { +void gameTableImpl::leaveCurrentNetworkGame() +{ - if (myStartWindow->getSession()->isNetworkClientRunning()) { + if (myStartWindow->getSession()->isNetworkClientRunning()) { - if(!myUniversalMessageDialog->checkIfMesssageWillBeDisplayed(1)) { + if(!myUniversalMessageDialog->checkIfMesssageWillBeDisplayed(1)) { - assert(myStartWindow->getSession()); - myStartWindow->getSession()->sendLeaveCurrentGame(); - } - else { - if (myUniversalMessageDialog->exec(1, tr("Attention! Do you really want to leave the current game\nand go back to the lobby?"), tr("PokerTH - Internet Game Message"), QPixmap(":/gfx/logoChip3D.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, true) == QDialog::Accepted) { - assert(myStartWindow->getSession()); - myStartWindow->getSession()->sendLeaveCurrentGame(); - } - } - } + assert(myStartWindow->getSession()); + myStartWindow->getSession()->sendLeaveCurrentGame(); + } else { + if (myUniversalMessageDialog->exec(1, tr("Attention! Do you really want to leave the current game\nand go back to the lobby?"), tr("PokerTH - Internet Game Message"), QPixmap(":/gfx/logoChip3D.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, true) == QDialog::Accepted) { + assert(myStartWindow->getSession()); + myStartWindow->getSession()->sendLeaveCurrentGame(); + } + } + } } -void gameTableImpl::triggerVoteOnKick(int id) { +void gameTableImpl::triggerVoteOnKick(int id) +{ - assert(myStartWindow->getSession()->getCurrentGame()); - PlayerList seatList = myStartWindow->getSession()->getCurrentGame()->getSeatsList(); - int playerCount = static_cast(seatList->size()); - if (id < playerCount) - { - PlayerListIterator pos = seatList->begin(); - advance(pos, id); - myStartWindow->getSession()->startVoteKickPlayer((*pos)->getMyUniqueID()); - } + assert(myStartWindow->getSession()->getCurrentGame()); + PlayerList seatList = myStartWindow->getSession()->getCurrentGame()->getSeatsList(); + int playerCount = static_cast(seatList->size()); + if (id < playerCount) { + PlayerListIterator pos = seatList->begin(); + advance(pos, id); + myStartWindow->getSession()->startVoteKickPlayer((*pos)->getMyUniqueID()); + } } void gameTableImpl::startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick) { - if(tabWidget_Left->widget(2) != tab_Kick) - tabWidget_Left->insertTab(2, tab_Kick, QString(tr("Kick"))); + if(tabWidget_Left->widget(2) != tab_Kick) + tabWidget_Left->insertTab(2, tab_Kick, QString(tr("Kick"))); - tabWidget_Left->setCurrentIndex(2); - pushButton_voteOnKickNo->hide(); - pushButton_voteOnKickYes->hide(); - label_kickUser->clear(); - label_kickVoteTimeout->clear(); + tabWidget_Left->setCurrentIndex(2); + pushButton_voteOnKickNo->hide(); + pushButton_voteOnKickYes->hide(); + label_kickUser->clear(); + label_kickVoteTimeout->clear(); - voteOnKickTimeoutSecs = timeoutSec; + voteOnKickTimeoutSecs = timeoutSec; - playerAboutToBeKickedId = playerId; - refreshVotesMonitor(1, numVotesNeededToKick); + playerAboutToBeKickedId = playerId; + refreshVotesMonitor(1, numVotesNeededToKick); - PlayerInfo info(myStartWindow->getSession()->getClientPlayerInfo(voteStarterPlayerId)); - label_voteStarterNick->setText(""+QString::fromUtf8(info.playerName.c_str())+""); + PlayerInfo info(myStartWindow->getSession()->getClientPlayerInfo(voteStarterPlayerId)); + label_voteStarterNick->setText(""+QString::fromUtf8(info.playerName.c_str())+""); - startVoteOnKickTimeout(); + startVoteOnKickTimeout(); - int i; - for (i=0; isetVoteRunning(TRUE); - } + int i; + for (i=0; isetVoteRunning(TRUE); + } } void gameTableImpl::changeVoteOnKickButtonsState(bool showHide) { - if(showHide) { + if(showHide) { - PlayerInfo info(myStartWindow->getSession()->getClientPlayerInfo(playerAboutToBeKickedId)); - label_kickUser->setText(tr("Do you want to kick %1
from this game?").arg(QString::fromUtf8(info.playerName.c_str()))); + PlayerInfo info(myStartWindow->getSession()->getClientPlayerInfo(playerAboutToBeKickedId)); + label_kickUser->setText(tr("Do you want to kick %1
from this game?").arg(QString::fromUtf8(info.playerName.c_str()))); - pushButton_voteOnKickNo->show(); - pushButton_voteOnKickYes->show(); - } - else { - label_kickUser->clear(); - pushButton_voteOnKickNo->hide(); - pushButton_voteOnKickYes->hide(); - } + pushButton_voteOnKickNo->show(); + pushButton_voteOnKickYes->show(); + } else { + label_kickUser->clear(); + pushButton_voteOnKickNo->hide(); + pushButton_voteOnKickYes->hide(); + } } void gameTableImpl::endVoteOnKick() { - stopVoteOnKickTimeout(); - tabWidget_Left->removeTab(2); + stopVoteOnKickTimeout(); + tabWidget_Left->removeTab(2); - int i; - for (i=0; isetVoteRunning(FALSE); - } + int i; + for (i=0; isetVoteRunning(FALSE); + } } void gameTableImpl::voteOnKickYes() { - changeVoteOnKickButtonsState(false); - myStartWindow->getSession()->voteKick(true); + changeVoteOnKickButtonsState(false); + myStartWindow->getSession()->voteKick(true); } void gameTableImpl::voteOnKickNo() { - changeVoteOnKickButtonsState(false); - myStartWindow->getSession()->voteKick(false); + changeVoteOnKickButtonsState(false); + myStartWindow->getSession()->voteKick(false); } void gameTableImpl::startVoteOnKickTimeout() { - voteOnKickRealTimer.reset(); - voteOnKickRealTimer.start(); - voteOnKickTimeoutTimer->start(1000); + voteOnKickRealTimer.reset(); + voteOnKickRealTimer.start(); + voteOnKickTimeoutTimer->start(1000); } void gameTableImpl::stopVoteOnKickTimeout() { - voteOnKickRealTimer.reset(); - voteOnKickTimeoutTimer->stop(); + voteOnKickRealTimer.reset(); + voteOnKickTimeoutTimer->stop(); } void gameTableImpl::nextVoteOnKickTimeoutAnimationFrame() { - if(voteOnKickTimeoutSecs-voteOnKickRealTimer.elapsed().total_seconds() > 0) - label_kickVoteTimeout->setText(tr("%1 secs left").arg(voteOnKickTimeoutSecs-voteOnKickRealTimer.elapsed().total_seconds())); - else - label_kickVoteTimeout->setText(tr("%1 secs left").arg(0)); + if(voteOnKickTimeoutSecs-voteOnKickRealTimer.elapsed().total_seconds() > 0) + label_kickVoteTimeout->setText(tr("%1 secs left").arg(voteOnKickTimeoutSecs-voteOnKickRealTimer.elapsed().total_seconds())); + else + label_kickVoteTimeout->setText(tr("%1 secs left").arg(0)); } void gameTableImpl::refreshVotesMonitor(int currentVotes, int numVotesNeededToKick) { - QString currentVotesString; - if(currentVotes == 1) currentVotesString = tr("vote"); - else currentVotesString = tr("votes"); + QString currentVotesString; + if(currentVotes == 1) currentVotesString = tr("vote"); + else currentVotesString = tr("votes"); - if((*myStartWindow->getSession()->getCurrentGame()->getSeatsList()->begin())->getMyUniqueID() != playerAboutToBeKickedId) { - PlayerInfo info(myStartWindow->getSession()->getClientPlayerInfo(playerAboutToBeKickedId)); - label_votesMonitor->setText(tr("Player %1 has %2 %3
against him. %4 vote(s) needed to kick.").arg(QString::fromUtf8(info.playerName.c_str())).arg(currentVotes).arg(currentVotesString).arg(numVotesNeededToKick-currentVotes)); - } - else { - label_votesMonitor->setText(tr("You have %1 %2 against you.
%3 vote(s) needed to kick.").arg(currentVotes).arg(currentVotesString).arg(numVotesNeededToKick-currentVotes)); - } + if((*myStartWindow->getSession()->getCurrentGame()->getSeatsList()->begin())->getMyUniqueID() != playerAboutToBeKickedId) { + PlayerInfo info(myStartWindow->getSession()->getClientPlayerInfo(playerAboutToBeKickedId)); + label_votesMonitor->setText(tr("Player %1 has %2 %3
against him. %4 vote(s) needed to kick.").arg(QString::fromUtf8(info.playerName.c_str())).arg(currentVotes).arg(currentVotesString).arg(numVotesNeededToKick-currentVotes)); + } else { + label_votesMonitor->setText(tr("You have %1 %2 against you.
%3 vote(s) needed to kick.").arg(currentVotes).arg(currentVotesString).arg(numVotesNeededToKick-currentVotes)); + } } void gameTableImpl::refreshCardsChance(GameState bero) { - CardsValue* myCardsValue = new CardsValue; + CardsValue* myCardsValue = new CardsValue; - if(myConfig->readConfigInt("ShowCardsChanceMonitor")) { + if(myConfig->readConfigInt("ShowCardsChanceMonitor")) { - boost::shared_ptr humanPlayer = myStartWindow->getSession()->getCurrentGame()->getSeatsList()->front(); - if(humanPlayer->getMyActiveStatus() && humanPlayer->getMyAction() != PLAYER_ACTION_FOLD) { - int boardCards[5]; - int holeCards[2]; + boost::shared_ptr humanPlayer = myStartWindow->getSession()->getCurrentGame()->getSeatsList()->front(); + if(humanPlayer->getMyActiveStatus() && humanPlayer->getMyAction() != PLAYER_ACTION_FOLD) { + int boardCards[5]; + int holeCards[2]; - humanPlayer->getMyCards(holeCards); - myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(boardCards); + humanPlayer->getMyCards(holeCards); + myStartWindow->getSession()->getCurrentGame()->getCurrentHand()->getBoard()->getMyCards(boardCards); - label_chance->refreshChance(myCardsValue->calcCardsChance(bero, holeCards, boardCards)); - } - else { - label_chance->resetChance(); - } - } + label_chance->refreshChance(myCardsValue->calcCardsChance(bero, holeCards, boardCards)); + } else { + label_chance->resetChance(); + } + } - delete myCardsValue; + delete myCardsValue; } void gameTableImpl::refreshActionButtonFKeyIndicator(bool clear) { - if(clear) { - pushButton_AllIn->setFKeyText(""); - pushButton_BetRaise->setFKeyText(""); - pushButton_CallCheck->setFKeyText(""); - pushButton_Fold->setFKeyText(""); - } - else { - if(myConfig->readConfigInt("AlternateFKeysUserActionMode") == 0 ){ - if(!pushButton_AllIn->text().isEmpty()) pushButton_AllIn->setFKeyText("F4"); - if(!pushButton_BetRaise->text().isEmpty()) pushButton_BetRaise->setFKeyText("F3"); - if(!pushButton_CallCheck->text().isEmpty()) pushButton_CallCheck->setFKeyText("F2"); - if(!pushButton_Fold->text().isEmpty()) pushButton_Fold->setFKeyText("F1"); - } - else { - if(!pushButton_AllIn->text().isEmpty()) pushButton_AllIn->setFKeyText("F1"); - if(!pushButton_BetRaise->text().isEmpty()) pushButton_BetRaise->setFKeyText("F2"); - if(!pushButton_CallCheck->text().isEmpty()) pushButton_CallCheck->setFKeyText("F3"); - if(!pushButton_Fold->text().isEmpty()) pushButton_Fold->setFKeyText("F4"); - } - } + if(clear) { + pushButton_AllIn->setFKeyText(""); + pushButton_BetRaise->setFKeyText(""); + pushButton_CallCheck->setFKeyText(""); + pushButton_Fold->setFKeyText(""); + } else { + if(myConfig->readConfigInt("AlternateFKeysUserActionMode") == 0 ) { + if(!pushButton_AllIn->text().isEmpty()) pushButton_AllIn->setFKeyText("F4"); + if(!pushButton_BetRaise->text().isEmpty()) pushButton_BetRaise->setFKeyText("F3"); + if(!pushButton_CallCheck->text().isEmpty()) pushButton_CallCheck->setFKeyText("F2"); + if(!pushButton_Fold->text().isEmpty()) pushButton_Fold->setFKeyText("F1"); + } else { + if(!pushButton_AllIn->text().isEmpty()) pushButton_AllIn->setFKeyText("F1"); + if(!pushButton_BetRaise->text().isEmpty()) pushButton_BetRaise->setFKeyText("F2"); + if(!pushButton_CallCheck->text().isEmpty()) pushButton_CallCheck->setFKeyText("F3"); + if(!pushButton_Fold->text().isEmpty()) pushButton_Fold->setFKeyText("F4"); + } + } } void gameTableImpl::refreshGameTableStyle() { - myGameTableStyle->setWindowsGeometry(this); - myGameTableStyle->setChatLogStyle(textBrowser_Log); - myGameTableStyle->setChatLogStyle(textBrowser_Chat); + myGameTableStyle->setWindowsGeometry(this); + myGameTableStyle->setChatLogStyle(textBrowser_Log); + myGameTableStyle->setChatLogStyle(textBrowser_Chat); myGameTableStyle->setChatLogStyle(textEdit_tipInput); - myGameTableStyle->setChatInputStyle(lineEdit_ChatInput); + myGameTableStyle->setChatInputStyle(lineEdit_ChatInput); - int i; - for (i=0; isetCashLabelStyle(cashLabelArray[i]); - myGameTableStyle->setSetLabelStyle(setLabelArray[i]); - myGameTableStyle->setPlayerNameLabelStyle(playerNameLabelArray[i]); - } + myGameTableStyle->setCashLabelStyle(cashLabelArray[i]); + myGameTableStyle->setSetLabelStyle(setLabelArray[i]); + myGameTableStyle->setPlayerNameLabelStyle(playerNameLabelArray[i]); + } - myGameTableStyle->setSmallFontBoardStyle(label_Sets); - myGameTableStyle->setSmallFontBoardStyle(label_Total); - myGameTableStyle->setSmallFontBoardStyle(textLabel_Sets); - myGameTableStyle->setSmallFontBoardStyle(textLabel_Pot); - myGameTableStyle->setSmallFontBoardStyle(label_handNumber); - myGameTableStyle->setSmallFontBoardStyle(label_gameNumber); - myGameTableStyle->setSmallFontBoardStyle(label_handNumberValue); - myGameTableStyle->setSmallFontBoardStyle(label_gameNumberValue); - myGameTableStyle->setBigFontBoardStyle(textLabel_handLabel); - myGameTableStyle->setBigFontBoardStyle(label_Pot); - myGameTableStyle->setCardHolderStyle(label_CardHolder0,0); - myGameTableStyle->setCardHolderStyle(label_CardHolder1,0); - myGameTableStyle->setCardHolderStyle(label_CardHolder2,0); - myGameTableStyle->setCardHolderStyle(label_CardHolder3,1); - myGameTableStyle->setCardHolderStyle(label_CardHolder4,2); - myGameTableStyle->setTableBackground(this); - myGameTableStyle->setMenuBarStyle(menubar); - myGameTableStyle->setBreakButtonStyle(pushButton_break,0); + myGameTableStyle->setSmallFontBoardStyle(label_Sets); + myGameTableStyle->setSmallFontBoardStyle(label_Total); + myGameTableStyle->setSmallFontBoardStyle(textLabel_Sets); + myGameTableStyle->setSmallFontBoardStyle(textLabel_Pot); + myGameTableStyle->setSmallFontBoardStyle(label_handNumber); + myGameTableStyle->setSmallFontBoardStyle(label_gameNumber); + myGameTableStyle->setSmallFontBoardStyle(label_handNumberValue); + myGameTableStyle->setSmallFontBoardStyle(label_gameNumberValue); + myGameTableStyle->setBigFontBoardStyle(textLabel_handLabel); + myGameTableStyle->setBigFontBoardStyle(label_Pot); + myGameTableStyle->setCardHolderStyle(label_CardHolder0,0); + myGameTableStyle->setCardHolderStyle(label_CardHolder1,0); + myGameTableStyle->setCardHolderStyle(label_CardHolder2,0); + myGameTableStyle->setCardHolderStyle(label_CardHolder3,1); + myGameTableStyle->setCardHolderStyle(label_CardHolder4,2); + myGameTableStyle->setTableBackground(this); + myGameTableStyle->setMenuBarStyle(menubar); + myGameTableStyle->setBreakButtonStyle(pushButton_break,0); myGameTableStyle->setBreakButtonStyle(pushButton_tipSave,0); - myGameTableStyle->setSpeedStringStyle(label_speedString); - myGameTableStyle->setSpeedStringStyle(label_speedValue); - myGameTableStyle->setVoteButtonStyle(pushButton_voteOnKickYes); - myGameTableStyle->setVoteButtonStyle(pushButton_voteOnKickNo); - myGameTableStyle->setVoteStringsStyle(label_timeout); - myGameTableStyle->setVoteStringsStyle(label_kickVoteTimeout); - myGameTableStyle->setVoteStringsStyle(label_kickUser); - myGameTableStyle->setVoteStringsStyle(label_votesMonitor); - myGameTableStyle->setVoteStringsStyle(label_voteStarterNick); - myGameTableStyle->setVoteStringsStyle(label_votestartedby); + myGameTableStyle->setSpeedStringStyle(label_speedString); + myGameTableStyle->setSpeedStringStyle(label_speedValue); + myGameTableStyle->setVoteButtonStyle(pushButton_voteOnKickYes); + myGameTableStyle->setVoteButtonStyle(pushButton_voteOnKickNo); + myGameTableStyle->setVoteStringsStyle(label_timeout); + myGameTableStyle->setVoteStringsStyle(label_kickVoteTimeout); + myGameTableStyle->setVoteStringsStyle(label_kickUser); + myGameTableStyle->setVoteStringsStyle(label_votesMonitor); + myGameTableStyle->setVoteStringsStyle(label_voteStarterNick); + myGameTableStyle->setVoteStringsStyle(label_votestartedby); - for (i=0; isetPlayerSeatInactiveStyle(groupBoxArray[i]); - } - //Human player button - myGameTableStyle->setButtonsStyle(pushButton_BetRaise, pushButton_CallCheck, pushButton_Fold, pushButton_AllIn, 0); - myGameTableStyle->setShowMyCardsButtonStyle(pushButton_showMyCards); + myGameTableStyle->setPlayerSeatInactiveStyle(groupBoxArray[i]); + } + //Human player button + myGameTableStyle->setButtonsStyle(pushButton_BetRaise, pushButton_CallCheck, pushButton_Fold, pushButton_AllIn, 0); + myGameTableStyle->setShowMyCardsButtonStyle(pushButton_showMyCards); - myGameTableStyle->setBetValueInputStyle(spinBox_betValue); - myGameTableStyle->setSliderStyle(horizontalSlider_bet); - myGameTableStyle->setSliderStyle(horizontalSlider_speed); + myGameTableStyle->setBetValueInputStyle(spinBox_betValue); + myGameTableStyle->setSliderStyle(horizontalSlider_bet); + myGameTableStyle->setSliderStyle(horizontalSlider_speed); - // away radiobuttons - myGameTableStyle->setAwayRadioButtonsStyle(radioButton_manualAction); - myGameTableStyle->setAwayRadioButtonsStyle(radioButton_autoCheckFold); - myGameTableStyle->setAwayRadioButtonsStyle(radioButton_autoCheckCallAny); + // away radiobuttons + myGameTableStyle->setAwayRadioButtonsStyle(radioButton_manualAction); + myGameTableStyle->setAwayRadioButtonsStyle(radioButton_autoCheckFold); + myGameTableStyle->setAwayRadioButtonsStyle(radioButton_autoCheckCallAny); - myGameTableStyle->setToolBoxBackground(groupBox_RightToolBox); - myGameTableStyle->setToolBoxBackground(groupBox_LeftToolBox); + myGameTableStyle->setToolBoxBackground(groupBox_RightToolBox); + myGameTableStyle->setToolBoxBackground(groupBox_LeftToolBox); - myGameTableStyle->setTabWidgetStyle(tabWidget_Right, tabWidget_Right->getMyTabBar()); - myGameTableStyle->setTabWidgetStyle(tabWidget_Left, tabWidget_Left->getMyTabBar()); + myGameTableStyle->setTabWidgetStyle(tabWidget_Right, tabWidget_Right->getMyTabBar()); + myGameTableStyle->setTabWidgetStyle(tabWidget_Left, tabWidget_Left->getMyTabBar()); - label_Handranking->setPixmap(myGameTableStyle->getHandRanking()); + label_Handranking->setPixmap(myGameTableStyle->getHandRanking()); - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getActionCallI18NString() == "NULL") { CallString = "Call"; } - else { CallString = myGameTableStyle->getActionCallI18NString(); } - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getActionCheckI18NString() == "NULL") { CheckString = "Check"; } - else { CheckString = myGameTableStyle->getActionCheckI18NString(); } - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getActionBetI18NString() == "NULL") { BetString = "Bet"; } - else { BetString = myGameTableStyle->getActionBetI18NString(); } - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getActionRaiseI18NString() == "NULL") { RaiseString = "Raise"; } - else { RaiseString = myGameTableStyle->getActionRaiseI18NString(); } - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getActionFoldI18NString() == "NULL") { FoldString = "Fold"; } - else { FoldString = myGameTableStyle->getActionFoldI18NString(); } - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getActionAllInI18NString() == "NULL") { AllInString = "All-In"; } - else { AllInString = myGameTableStyle->getActionAllInI18NString(); } - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getPotI18NString() == "NULL") { PotString = "Pot"; } - else { PotString = myGameTableStyle->getPotI18NString(); } - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getTotalI18NString() == "NULL") { TotalString = "Total"; } - else { TotalString = myGameTableStyle->getTotalI18NString(); } - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getBetsI18NString() == "NULL") { BetsString = "Bets"; } - else { BetsString = myGameTableStyle->getBetsI18NString(); } - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getGameI18NString() == "NULL") { GameString = "Game"; } - else { GameString = myGameTableStyle->getGameI18NString(); } - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getHandI18NString() == "NULL") { HandString = "Hand"; } - else { HandString = myGameTableStyle->getHandI18NString(); } - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getPreflopI18NString() == "NULL") { PreflopString = "Preflop"; } - else { PreflopString = myGameTableStyle->getPreflopI18NString(); } - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getFlopI18NString() == "NULL") { FlopString = "Flop"; } - else { FlopString = myGameTableStyle->getFlopI18NString(); } - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getTurnI18NString() == "NULL") { TurnString = "Turn"; } - else { TurnString = myGameTableStyle->getTurnI18NString(); } - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getRiverI18NString() == "NULL") { RiverString = "River"; } - else { RiverString = myGameTableStyle->getRiverI18NString(); } + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getActionCallI18NString() == "NULL") { + CallString = "Call"; + } else { + CallString = myGameTableStyle->getActionCallI18NString(); + } + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getActionCheckI18NString() == "NULL") { + CheckString = "Check"; + } else { + CheckString = myGameTableStyle->getActionCheckI18NString(); + } + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getActionBetI18NString() == "NULL") { + BetString = "Bet"; + } else { + BetString = myGameTableStyle->getActionBetI18NString(); + } + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getActionRaiseI18NString() == "NULL") { + RaiseString = "Raise"; + } else { + RaiseString = myGameTableStyle->getActionRaiseI18NString(); + } + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getActionFoldI18NString() == "NULL") { + FoldString = "Fold"; + } else { + FoldString = myGameTableStyle->getActionFoldI18NString(); + } + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getActionAllInI18NString() == "NULL") { + AllInString = "All-In"; + } else { + AllInString = myGameTableStyle->getActionAllInI18NString(); + } + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getPotI18NString() == "NULL") { + PotString = "Pot"; + } else { + PotString = myGameTableStyle->getPotI18NString(); + } + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getTotalI18NString() == "NULL") { + TotalString = "Total"; + } else { + TotalString = myGameTableStyle->getTotalI18NString(); + } + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getBetsI18NString() == "NULL") { + BetsString = "Bets"; + } else { + BetsString = myGameTableStyle->getBetsI18NString(); + } + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getGameI18NString() == "NULL") { + GameString = "Game"; + } else { + GameString = myGameTableStyle->getGameI18NString(); + } + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getHandI18NString() == "NULL") { + HandString = "Hand"; + } else { + HandString = myGameTableStyle->getHandI18NString(); + } + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getPreflopI18NString() == "NULL") { + PreflopString = "Preflop"; + } else { + PreflopString = myGameTableStyle->getPreflopI18NString(); + } + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getFlopI18NString() == "NULL") { + FlopString = "Flop"; + } else { + FlopString = myGameTableStyle->getFlopI18NString(); + } + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getTurnI18NString() == "NULL") { + TurnString = "Turn"; + } else { + TurnString = myGameTableStyle->getTurnI18NString(); + } + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || myGameTableStyle->getRiverI18NString() == "NULL") { + RiverString = "River"; + } else { + RiverString = myGameTableStyle->getRiverI18NString(); + } - label_Pot->setText(PotString); - label_Total->setText(TotalString+":"); - label_Sets->setText(BetsString+":"); - label_handNumber->setText(HandString+":"); - label_gameNumber->setText(GameString+":"); + label_Pot->setText(PotString); + label_Total->setText(TotalString+":"); + label_Sets->setText(BetsString+":"); + label_handNumber->setText(HandString+":"); + label_gameNumber->setText(GameString+":"); } void gameTableImpl::saveGameTableGeometry() { - if(this->isFullScreen()) { - myConfig->writeConfigInt("GameTableFullScreenSave", 1); - } - else { - myConfig->writeConfigInt("GameTableFullScreenSave", 0); - myConfig->writeConfigInt("GameTableHeightSave", this->height()); - myConfig->writeConfigInt("GameTableWidthSave", this->width()); - } - myConfig->writeBuffer(); + if(this->isFullScreen()) { + myConfig->writeConfigInt("GameTableFullScreenSave", 1); + } else { + myConfig->writeConfigInt("GameTableFullScreenSave", 0); + myConfig->writeConfigInt("GameTableHeightSave", this->height()); + myConfig->writeConfigInt("GameTableWidthSave", this->width()); + } + myConfig->writeBuffer(); } void gameTableImpl::restoreGameTableGeometry() { - if(myConfig->readConfigInt("GameTableFullScreenSave")) { - if(actionFullScreen->isEnabled()) this->showFullScreen(); - } - else { - //resize only if style size allow this and if NOT fixed windows size - if(!myGameTableStyle->getIfFixedWindowSize().toInt() && myConfig->readConfigInt("GameTableHeightSave") <= myGameTableStyle->getMaximumWindowHeight().toInt() && myConfig->readConfigInt("GameTableHeightSave") >= myGameTableStyle->getMinimumWindowHeight().toInt() && myConfig->readConfigInt("GameTableWidthSave") <= myGameTableStyle->getMaximumWindowWidth().toInt() && myConfig->readConfigInt("GameTableWidthSave") >= myGameTableStyle->getMinimumWindowWidth().toInt()){ + if(myConfig->readConfigInt("GameTableFullScreenSave")) { + if(actionFullScreen->isEnabled()) this->showFullScreen(); + } else { + //resize only if style size allow this and if NOT fixed windows size + if(!myGameTableStyle->getIfFixedWindowSize().toInt() && myConfig->readConfigInt("GameTableHeightSave") <= myGameTableStyle->getMaximumWindowHeight().toInt() && myConfig->readConfigInt("GameTableHeightSave") >= myGameTableStyle->getMinimumWindowHeight().toInt() && myConfig->readConfigInt("GameTableWidthSave") <= myGameTableStyle->getMaximumWindowWidth().toInt() && myConfig->readConfigInt("GameTableWidthSave") >= myGameTableStyle->getMinimumWindowWidth().toInt()) { - this->resize(myConfig->readConfigInt("GameTableWidthSave"), myConfig->readConfigInt("GameTableHeightSave")); - } - } + this->resize(myConfig->readConfigInt("GameTableWidthSave"), myConfig->readConfigInt("GameTableHeightSave")); + } + } } -void gameTableImpl::netClientPlayerLeft(unsigned playerId) { +void gameTableImpl::netClientPlayerLeft(unsigned playerId) +{ - if (myStartWindow->getSession()->getCurrentGame() && myStartWindow->getSession()->isNetworkClientRunning()) { + if (myStartWindow->getSession()->getCurrentGame() && myStartWindow->getSession()->isNetworkClientRunning()) { - boost::shared_ptr tmpPlayer = myStartWindow->getSession()->getCurrentGame()->getPlayerByUniqueId(playerId); - if (tmpPlayer.get()) { - tmpPlayer->setMyStayOnTableStatus(0); - refreshPlayerAvatar(); - refreshPlayerName(); - } - } + boost::shared_ptr tmpPlayer = myStartWindow->getSession()->getCurrentGame()->getPlayerByUniqueId(playerId); + if (tmpPlayer.get()) { + tmpPlayer->setMyStayOnTableStatus(0); + refreshPlayerAvatar(); + refreshPlayerName(); + } + } } void gameTableImpl::registeredUserMode() { - lineEdit_ChatInput->clear(); - lineEdit_ChatInput->setEnabled(true); - guestMode = false; + lineEdit_ChatInput->clear(); + lineEdit_ChatInput->setEnabled(true); + guestMode = false; } void gameTableImpl::guestUserMode() { - lineEdit_ChatInput->setText(tr("Chat is only available to registered players.")); - lineEdit_ChatInput->setDisabled(true); - guestMode = true; + lineEdit_ChatInput->setText(tr("Chat is only available to registered players.")); + lineEdit_ChatInput->setDisabled(true); + guestMode = true; } void gameTableImpl::showShowMyCardsButton() { - pushButton_showMyCards->show(); - pushButton_showMyCards->raise(); + pushButton_showMyCards->show(); + pushButton_showMyCards->raise(); } void gameTableImpl::sendShowMyCardsSignal() { - if(pushButton_showMyCards->isVisible()) { + if(pushButton_showMyCards->isVisible()) { - myStartWindow->getSession()->showMyCards(); + myStartWindow->getSession()->showMyCards(); - pushButton_showMyCards->hide(); - } + pushButton_showMyCards->hide(); + } } void gameTableImpl::showWarningAutoFoldInRankingGame(unsigned remainingAutoFolds) { - QMessageBox::warning(this, tr("PokerTH - Warning"), - tr("You have triggered a warning level of timeouts in a ranking game.\n" - "After %1 additional timeouts the server needs to kick you to provide a better game flow!\n\n" - "If you are temporarily away, you can use the \"away\" tools in the tool box on the right.").arg(remainingAutoFolds), - QMessageBox::Ok); - tabWidget_Right->setCurrentIndex(1); + QMessageBox::warning(this, tr("PokerTH - Warning"), + tr("You have triggered a warning level of timeouts in a ranking game.\n" + "After %1 additional timeouts the server needs to kick you to provide a better game flow!\n\n" + "If you are temporarily away, you can use the \"away\" tools in the tool box on the right.").arg(remainingAutoFolds), + QMessageBox::Ok); + tabWidget_Right->setCurrentIndex(1); } -void gameTableImpl::closeMessageBoxes() { +void gameTableImpl::closeMessageBoxes() +{ - myUniversalMessageDialog->close(); + myUniversalMessageDialog->close(); } diff --git a/src/gui/qt/gametable/gametableimpl.h b/src/gui/qt/gametable/gametableimpl.h index f952bea3..487391ef 100755 --- a/src/gui/qt/gametable/gametableimpl.h +++ b/src/gui/qt/gametable/gametableimpl.h @@ -51,407 +51,425 @@ class CardDeckStyleReader; class SDLPlayer; -class gameTableImpl: public QMainWindow, public Ui::gameTable { - Q_OBJECT +class gameTableImpl: public QMainWindow, public Ui::gameTable +{ + Q_OBJECT public: - gameTableImpl(ConfigFile *c = 0, QMainWindow *parent = 0); + gameTableImpl(ConfigFile *c = 0, QMainWindow *parent = 0); - ~gameTableImpl(); + ~gameTableImpl(); - boost::shared_ptr getSession(); - SDLPlayer* getMySDLPlayer() const { return mySDLPlayer; } - ChatTools* getMyChat() const { return myChat; } - ConfigFile* getMyConfig() const { return myConfig; } - GameTableStyleReader* getMyGameTableStyle() const { return myGameTableStyle; } - bool getGuestMode() const { return guestMode; } + boost::shared_ptr getSession(); + SDLPlayer* getMySDLPlayer() const { + return mySDLPlayer; + } + ChatTools* getMyChat() const { + return myChat; + } + ConfigFile* getMyConfig() const { + return myConfig; + } + GameTableStyleReader* getMyGameTableStyle() const { + return myGameTableStyle; + } + bool getGuestMode() const { + return guestMode; + } - void setStartWindow(startWindowImpl* s) { myStartWindow = s; } - void setGuiLog(guiLog* l) { myGuiLog = l; } + void setStartWindow(startWindowImpl* s) { + myStartWindow = s; + } + void setGuiLog(guiLog* l) { + myGuiLog = l; + } - void setSpeeds(); + void setSpeeds(); signals: - void signalInitGui(int speed); + void signalInitGui(int speed); - void signalShowClientDialog(); + void signalShowClientDialog(); - void signalRefreshSet(); - void signalRefreshCash(); - void signalRefreshAction(int =-1, int=-1); - void signalRefreshChangePlayer(); - void signalRefreshPot(); - void signalRefreshGroupbox(int =-1, int =-1); - void signalRefreshAll(); - void signalRefreshPlayerName(); - void signalRefreshButton(); - void signalRefreshGameLabels(int); + void signalRefreshSet(); + void signalRefreshCash(); + void signalRefreshAction(int =-1, int=-1); + void signalRefreshChangePlayer(); + void signalRefreshPot(); + void signalRefreshGroupbox(int =-1, int =-1); + void signalRefreshAll(); + void signalRefreshPlayerName(); + void signalRefreshButton(); + void signalRefreshGameLabels(int); - void signalSetPlayerAvatar(int, QString); - void signalGuiUpdateDone(); + void signalSetPlayerAvatar(int, QString); + void signalGuiUpdateDone(); - void signalMeInAction(); - void signalUpdateMyButtonsState(); - void signalDisableMyButtons(); - void signalStartTimeoutAnimation(int playerId, int timeoutSec); - void signalStopTimeoutAnimation(int playerId); + void signalMeInAction(); + void signalUpdateMyButtonsState(); + void signalDisableMyButtons(); + void signalStartTimeoutAnimation(int playerId, int timeoutSec); + void signalStopTimeoutAnimation(int playerId); - void signalDealBeRoCards(int myBeRoID); + void signalDealBeRoCards(int myBeRoID); - void signalDealHoleCards(); - void signalDealFlopCards0(); - void signalDealTurnCards0(); - void signalDealRiverCards0(); + void signalDealHoleCards(); + void signalDealFlopCards0(); + void signalDealTurnCards0(); + void signalDealRiverCards0(); - void signalNextPlayerAnimation(); + void signalNextPlayerAnimation(); - void signalBeRoAnimation2(int); + void signalBeRoAnimation2(int); - void signalPreflopAnimation1(); - void signalPreflopAnimation2(); - void signalFlopAnimation1(); - void signalFlopAnimation2(); - void signalTurnAnimation1(); - void signalTurnAnimation2(); - void signalRiverAnimation1(); - void signalRiverAnimation2(); - void signalPostRiverAnimation1(); - void signalPostRiverRunAnimation1(); - void signalPostRiverShowCards(unsigned playerId); + void signalPreflopAnimation1(); + void signalPreflopAnimation2(); + void signalFlopAnimation1(); + void signalFlopAnimation2(); + void signalTurnAnimation1(); + void signalTurnAnimation2(); + void signalRiverAnimation1(); + void signalRiverAnimation2(); + void signalPostRiverAnimation1(); + void signalPostRiverRunAnimation1(); + void signalPostRiverShowCards(unsigned playerId); - void signalFlipHolecardsAllIn(); - void signalNextRoundCleanGui(); - void signalStartVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick); - void signalChangeVoteOnKickButtonsState(bool showHide); - void signalEndVoteOnKick(); - void signalNetClientPlayerLeft(unsigned playerId); - void signalWarningAutoFoldInRankingGame(unsigned remainingAutoFolds); + void signalFlipHolecardsAllIn(); + void signalNextRoundCleanGui(); + void signalStartVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick); + void signalChangeVoteOnKickButtonsState(bool showHide); + void signalEndVoteOnKick(); + void signalNetClientPlayerLeft(unsigned playerId); + void signalWarningAutoFoldInRankingGame(unsigned remainingAutoFolds); public slots: - void initGui(int speed); - - //refresh-Funktionen - void refreshSet(); - void refreshCash(); - void refreshAction(int =-1, int=-1); - void refreshChangePlayer(); - void refreshPot(); - void refreshGroupbox(int =-1, int =-1); - void refreshAll(); - void refreshPlayerName(); - void refreshGameLabels(int); - void refreshButton(); - void refreshPlayerAvatar(); - void refreshActionButtonFKeyIndicator(bool =0); - void setPlayerAvatar(int myID, QString myAvatar); - - void guiUpdateDone(); - void waitForGuiUpdateDone(); + void initGui(int speed); + + //refresh-Funktionen + void refreshSet(); + void refreshCash(); + void refreshAction(int =-1, int=-1); + void refreshChangePlayer(); + void refreshPot(); + void refreshGroupbox(int =-1, int =-1); + void refreshAll(); + void refreshPlayerName(); + void refreshGameLabels(int); + void refreshButton(); + void refreshPlayerAvatar(); + void refreshActionButtonFKeyIndicator(bool =0); + void setPlayerAvatar(int myID, QString myAvatar); + + void guiUpdateDone(); + void waitForGuiUpdateDone(); + + // Karten-Funktionen + void dealHoleCards(); - // Karten-Funktionen - void dealHoleCards(); + //Spieler-Funktionen + void provideMyActions(int mode = -1); //mode 0 == called from dealberocards + void meInAction(); + void disableMyButtons(); + void startTimeoutAnimation(int playerId, int timoutSec); + void stopTimeoutAnimation(int playerId); - //Spieler-Funktionen - void provideMyActions(int mode = -1); //mode 0 == called from dealberocards - void meInAction(); - void disableMyButtons(); - void startTimeoutAnimation(int playerId, int timoutSec); - void stopTimeoutAnimation(int playerId); + void setGameSpeed(const int theValue) { + guiGameSpeed = theValue; // Achtung Faktor 10!!! + setSpeeds(); + } - void setGameSpeed(const int theValue) { guiGameSpeed = theValue; setSpeeds(); } // Achtung Faktor 10!!! + void callSettingsDialog(); + void applySettings(settingsDialogImpl*); - void callSettingsDialog(); - void applySettings(settingsDialogImpl*); + void pushButtonBetRaiseClicked(bool checked); + void pushButtonCallCheckClicked(bool checked); + void pushButtonFoldClicked(bool checked); + void pushButtonAllInClicked(bool checked); - void pushButtonBetRaiseClicked(bool checked); - void pushButtonCallCheckClicked(bool checked); - void pushButtonFoldClicked(bool checked); - void pushButtonAllInClicked(bool checked); + void myCallCheck(); - void myCallCheck(); + void myFold(); + void myCheck(); + int getMyCallAmount(); + int getBetRaisePushButtonValue(); + int getMyBetAmount(); + void myCall(); + void mySet(); + void myAllIn(); - void myFold(); - void myCheck(); - int getMyCallAmount(); - int getBetRaisePushButtonValue(); - int getMyBetAmount(); - void myCall(); - void mySet(); - void myAllIn(); + void myActionDone(); - void myActionDone(); + void dealBeRoCards(int); - void dealBeRoCards(int); + void dealFlopCards0(); + void dealFlopCards1(); + void dealFlopCards2(); + void dealFlopCards3(); + void dealFlopCards4(); + void dealFlopCards5(); + void dealFlopCards6(); - void dealFlopCards0(); - void dealFlopCards1(); - void dealFlopCards2(); - void dealFlopCards3(); - void dealFlopCards4(); - void dealFlopCards5(); - void dealFlopCards6(); + void dealTurnCards0(); + void dealTurnCards1(); + void dealTurnCards2(); + + void dealRiverCards0(); + void dealRiverCards1(); + void dealRiverCards2(); + + void nextPlayerAnimation(); + + void beRoAnimation2(int); + + void preflopAnimation1(); + void preflopAnimation1Action(); + void preflopAnimation2(); + void preflopAnimation2Action(); - void dealTurnCards0(); - void dealTurnCards1(); - void dealTurnCards2(); + void flopAnimation1(); + void flopAnimation1Action(); + void flopAnimation2(); + void flopAnimation2Action(); - void dealRiverCards0(); - void dealRiverCards1(); - void dealRiverCards2(); + void turnAnimation1(); + void turnAnimation1Action(); + void turnAnimation2(); + void turnAnimation2Action(); - void nextPlayerAnimation(); - - void beRoAnimation2(int); - - void preflopAnimation1(); - void preflopAnimation1Action(); - void preflopAnimation2(); - void preflopAnimation2Action(); - - void flopAnimation1(); - void flopAnimation1Action(); - void flopAnimation2(); - void flopAnimation2Action(); - - void turnAnimation1(); - void turnAnimation1Action(); - void turnAnimation2(); - void turnAnimation2Action(); - - void riverAnimation1(); - void riverAnimation1Action(); - void riverAnimation2(); - void riverAnimation2Action(); - - void postRiverAnimation1(); - void postRiverAnimation1Action(); - - void postRiverRunAnimation1(); - void postRiverRunAnimation2(); - void postRiverRunAnimation3(); - void postRiverRunAnimation4(); - void postRiverRunAnimation5(); - void postRiverRunAnimation6(); - - void showHoleCards(unsigned playerId, bool allIn = false); - - void refreshCardsChance(GameState); - - void blinkingStartButtonAnimationAction(); - - void flipHolecardsAllIn(); - void triggerVoteOnKick(int id); - - void handSwitchRounds(); - - void startNewHand(); - - void stopTimer(); - - void nextRoundCleanGui(); - - void breakButtonClicked(); - - void keyPressEvent ( QKeyEvent*); - bool eventFilter(QObject *obj, QEvent *event); - - void switchChatWindow(); - void switchHelpWindow(); - void switchLogWindow(); - void switchAwayWindow(); - void switchChanceWindow(); - void switchFullscreen(); - - void sendChatMessage(); - void checkChatInputLength(QString); - void tabSwitchAction(); - - void leaveCurrentNetworkGame(); - - void localGameModification(); - void networkGameModification(); - - void mouseOverFlipCards(bool front); - - void updateMyButtonsState(int mode = -1); //mode 0 == called from dealberocards - void uncheckMyButtons(); - void resetMyButtonsCheckStateMemory(); - void clearMyButtons(); - void myButtonsCheckable(bool state); - - void changePlayingMode(); - void changeSpinBoxBetValue(int); - void spinBoxBetValueChanged(int); - - void showMaximized (); - void closeGameTable(); - - void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick); - void changeVoteOnKickButtonsState(bool showHide); - void endVoteOnKick(); - void voteOnKickYes(); - void voteOnKickNo(); - void startVoteOnKickTimeout(); - void stopVoteOnKickTimeout(); - void nextVoteOnKickTimeoutAnimationFrame(); - void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick); - - void refreshGameTableStyle(); - void saveGameTableGeometry(); - void restoreGameTableGeometry(); - - void netClientPlayerLeft(unsigned playerId); - void registeredUserMode(); - void guestUserMode(); - - void showShowMyCardsButton(); - void sendShowMyCardsSignal(); - - void showWarningAutoFoldInRankingGame(unsigned); - void closeMessageBoxes(); - -private: - - boost::shared_ptr myServerGuiInterface; - guiLog *myGuiLog; - ChatTools *myChat; - ConfigFile *myConfig; - - //Timer - QTimer *potDistributeTimer; - QTimer *timer; - QTimer *dealFlopCards0Timer; - QTimer *dealFlopCards1Timer; - QTimer *dealFlopCards2Timer; - QTimer *dealFlopCards3Timer; - QTimer *dealFlopCards4Timer; - QTimer *dealFlopCards5Timer; - QTimer *dealFlopCards6Timer; - QTimer *dealTurnCards0Timer; - QTimer *dealTurnCards1Timer; - QTimer *dealTurnCards2Timer; - QTimer *dealRiverCards0Timer; - QTimer *dealRiverCards1Timer; - QTimer *dealRiverCards2Timer; - - QTimer *nextPlayerAnimationTimer; - QTimer *preflopAnimation1Timer; - QTimer *preflopAnimation2Timer; - QTimer *flopAnimation1Timer; - QTimer *flopAnimation2Timer; - QTimer *turnAnimation1Timer; - QTimer *turnAnimation2Timer; - QTimer *riverAnimation1Timer; - QTimer *riverAnimation2Timer; - - QTimer *postRiverAnimation1Timer; - QTimer *postRiverRunAnimation1Timer; - QTimer *postRiverRunAnimation2Timer; - QTimer *postRiverRunAnimation2_flipHoleCards1Timer; - QTimer *postRiverRunAnimation2_flipHoleCards2Timer; - QTimer *postRiverRunAnimation3Timer; - QTimer *postRiverRunAnimation5Timer; - QTimer *postRiverRunAnimation6Timer; - - QTimer *blinkingStartButtonAnimationTimer; - QTimer *voteOnKickTimeoutTimer; - boost::timers::portable::microsec_timer voteOnKickRealTimer; - - QWidget *userWidgetsArray[6]; - QLabel *buttonLabelArray[MAX_NUMBER_OF_PLAYERS]; - QLabel *cashLabelArray[MAX_NUMBER_OF_PLAYERS]; - QLabel *cashTopLabelArray[MAX_NUMBER_OF_PLAYERS]; - MySetLabel *setLabelArray[MAX_NUMBER_OF_PLAYERS]; - QLabel *actionLabelArray[MAX_NUMBER_OF_PLAYERS]; - MyNameLabel *playerNameLabelArray[MAX_NUMBER_OF_PLAYERS]; - MyAvatarLabel *playerAvatarLabelArray[MAX_NUMBER_OF_PLAYERS]; - MyTimeoutLabel *timeoutLabelArray[MAX_NUMBER_OF_PLAYERS]; - QLabel *playerStarsArray[6][MAX_NUMBER_OF_PLAYERS]; - - QGroupBox *groupBoxArray[MAX_NUMBER_OF_PLAYERS]; - MyCardsPixmapLabel *boardCardsArray[5]; - MyCardsPixmapLabel *holeCardsArray[MAX_NUMBER_OF_PLAYERS][2]; - - QLabel *playerTipLabelArray[MAX_NUMBER_OF_PLAYERS]; - QPixmap flipside; - - // Dialogs - startWindowImpl *myStartWindow; - myMessageDialogImpl *myUniversalMessageDialog; - - //Sound - SDLPlayer *mySDLPlayer; - QString myAppDataPath; - - int distributePotAnimCounter; - int playingMode; - - QString font2String; - QString font1String; - - //Speed - int guiGameSpeed; - int gameSpeed; - int dealCardsSpeed; - int preDealCardsSpeed; - int postDealCardsSpeed; - int AllInDealCardsSpeed; - int postRiverRunAnimationSpeed; - int winnerBlinkSpeed; - int newRoundSpeed; - int nextPlayerSpeed1; - int nextPlayerSpeed2; - int nextPlayerSpeed3; - int preflopNextPlayerSpeed; - int nextOpponentSpeed; - - bool myActionIsBet; - bool myActionIsRaise; - bool pushButtonBetRaiseIsChecked; - bool pushButtonCallCheckIsChecked; - bool pushButtonFoldIsChecked; - bool pushButtonAllInIsChecked; - bool myButtonsAreCheckable; - bool breakAfterCurrentHand; - bool currentGameOver; - bool flipHolecardsAllInAlreadyDone; - bool betSliderChangedByInput; - bool guestMode; - - // statistic testing - int statisticArray[15]; - - QSemaphore guiUpdateSemaphore; - - int keyUpDownChatCounter; - int myLastPreActionBetValue; - - int voteOnKickTimeoutSecs; - unsigned playerAboutToBeKickedId; - - GameTableStyleReader *myGameTableStyle; - CardDeckStyleReader *myCardDeckStyle; - - QString AllInString; - QString RaiseString; - QString BetString; - QString CallString; - QString CheckString; - QString FoldString; - QString PotString; - QString TotalString; - QString BetsString; - QString GameString; - QString HandString; - QString PreflopString; - QString FlopString; - QString TurnString; - QString RiverString; - - friend class MyAvatarLabel; - friend class GuiWrapper; + void riverAnimation1(); + void riverAnimation1Action(); + void riverAnimation2(); + void riverAnimation2Action(); + + void postRiverAnimation1(); + void postRiverAnimation1Action(); + + void postRiverRunAnimation1(); + void postRiverRunAnimation2(); + void postRiverRunAnimation3(); + void postRiverRunAnimation4(); + void postRiverRunAnimation5(); + void postRiverRunAnimation6(); + + void showHoleCards(unsigned playerId, bool allIn = false); + + void refreshCardsChance(GameState); + + void blinkingStartButtonAnimationAction(); + + void flipHolecardsAllIn(); + void triggerVoteOnKick(int id); + + void handSwitchRounds(); + + void startNewHand(); + + void stopTimer(); + + void nextRoundCleanGui(); + + void breakButtonClicked(); + + void keyPressEvent ( QKeyEvent*); + bool eventFilter(QObject *obj, QEvent *event); + + void switchChatWindow(); + void switchHelpWindow(); + void switchLogWindow(); + void switchAwayWindow(); + void switchChanceWindow(); + void switchFullscreen(); + + void sendChatMessage(); + void checkChatInputLength(QString); + void tabSwitchAction(); + + void leaveCurrentNetworkGame(); + + void localGameModification(); + void networkGameModification(); + + void mouseOverFlipCards(bool front); + + void updateMyButtonsState(int mode = -1); //mode 0 == called from dealberocards + void uncheckMyButtons(); + void resetMyButtonsCheckStateMemory(); + void clearMyButtons(); + void myButtonsCheckable(bool state); + + void changePlayingMode(); + void changeSpinBoxBetValue(int); + void spinBoxBetValueChanged(int); + + void showMaximized (); + void closeGameTable(); + + void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick); + void changeVoteOnKickButtonsState(bool showHide); + void endVoteOnKick(); + void voteOnKickYes(); + void voteOnKickNo(); + void startVoteOnKickTimeout(); + void stopVoteOnKickTimeout(); + void nextVoteOnKickTimeoutAnimationFrame(); + void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick); + + void refreshGameTableStyle(); + void saveGameTableGeometry(); + void restoreGameTableGeometry(); + + void netClientPlayerLeft(unsigned playerId); + void registeredUserMode(); + void guestUserMode(); + + void showShowMyCardsButton(); + void sendShowMyCardsSignal(); + + void showWarningAutoFoldInRankingGame(unsigned); + void closeMessageBoxes(); + +private: + + boost::shared_ptr myServerGuiInterface; + guiLog *myGuiLog; + ChatTools *myChat; + ConfigFile *myConfig; + + //Timer + QTimer *potDistributeTimer; + QTimer *timer; + QTimer *dealFlopCards0Timer; + QTimer *dealFlopCards1Timer; + QTimer *dealFlopCards2Timer; + QTimer *dealFlopCards3Timer; + QTimer *dealFlopCards4Timer; + QTimer *dealFlopCards5Timer; + QTimer *dealFlopCards6Timer; + QTimer *dealTurnCards0Timer; + QTimer *dealTurnCards1Timer; + QTimer *dealTurnCards2Timer; + QTimer *dealRiverCards0Timer; + QTimer *dealRiverCards1Timer; + QTimer *dealRiverCards2Timer; + + QTimer *nextPlayerAnimationTimer; + QTimer *preflopAnimation1Timer; + QTimer *preflopAnimation2Timer; + QTimer *flopAnimation1Timer; + QTimer *flopAnimation2Timer; + QTimer *turnAnimation1Timer; + QTimer *turnAnimation2Timer; + QTimer *riverAnimation1Timer; + QTimer *riverAnimation2Timer; + + QTimer *postRiverAnimation1Timer; + QTimer *postRiverRunAnimation1Timer; + QTimer *postRiverRunAnimation2Timer; + QTimer *postRiverRunAnimation2_flipHoleCards1Timer; + QTimer *postRiverRunAnimation2_flipHoleCards2Timer; + QTimer *postRiverRunAnimation3Timer; + QTimer *postRiverRunAnimation5Timer; + QTimer *postRiverRunAnimation6Timer; + + QTimer *blinkingStartButtonAnimationTimer; + QTimer *voteOnKickTimeoutTimer; + boost::timers::portable::microsec_timer voteOnKickRealTimer; + + QWidget *userWidgetsArray[6]; + QLabel *buttonLabelArray[MAX_NUMBER_OF_PLAYERS]; + QLabel *cashLabelArray[MAX_NUMBER_OF_PLAYERS]; + QLabel *cashTopLabelArray[MAX_NUMBER_OF_PLAYERS]; + MySetLabel *setLabelArray[MAX_NUMBER_OF_PLAYERS]; + QLabel *actionLabelArray[MAX_NUMBER_OF_PLAYERS]; + MyNameLabel *playerNameLabelArray[MAX_NUMBER_OF_PLAYERS]; + MyAvatarLabel *playerAvatarLabelArray[MAX_NUMBER_OF_PLAYERS]; + MyTimeoutLabel *timeoutLabelArray[MAX_NUMBER_OF_PLAYERS]; + QLabel *playerStarsArray[6][MAX_NUMBER_OF_PLAYERS]; + + QGroupBox *groupBoxArray[MAX_NUMBER_OF_PLAYERS]; + MyCardsPixmapLabel *boardCardsArray[5]; + MyCardsPixmapLabel *holeCardsArray[MAX_NUMBER_OF_PLAYERS][2]; + + QLabel *playerTipLabelArray[MAX_NUMBER_OF_PLAYERS]; + QPixmap flipside; + + // Dialogs + startWindowImpl *myStartWindow; + myMessageDialogImpl *myUniversalMessageDialog; + + //Sound + SDLPlayer *mySDLPlayer; + QString myAppDataPath; + + int distributePotAnimCounter; + int playingMode; + + QString font2String; + QString font1String; + + //Speed + int guiGameSpeed; + int gameSpeed; + int dealCardsSpeed; + int preDealCardsSpeed; + int postDealCardsSpeed; + int AllInDealCardsSpeed; + int postRiverRunAnimationSpeed; + int winnerBlinkSpeed; + int newRoundSpeed; + int nextPlayerSpeed1; + int nextPlayerSpeed2; + int nextPlayerSpeed3; + int preflopNextPlayerSpeed; + int nextOpponentSpeed; + + bool myActionIsBet; + bool myActionIsRaise; + bool pushButtonBetRaiseIsChecked; + bool pushButtonCallCheckIsChecked; + bool pushButtonFoldIsChecked; + bool pushButtonAllInIsChecked; + bool myButtonsAreCheckable; + bool breakAfterCurrentHand; + bool currentGameOver; + bool flipHolecardsAllInAlreadyDone; + bool betSliderChangedByInput; + bool guestMode; + + // statistic testing + int statisticArray[15]; + + QSemaphore guiUpdateSemaphore; + + int keyUpDownChatCounter; + int myLastPreActionBetValue; + + int voteOnKickTimeoutSecs; + unsigned playerAboutToBeKickedId; + + GameTableStyleReader *myGameTableStyle; + CardDeckStyleReader *myCardDeckStyle; + + QString AllInString; + QString RaiseString; + QString BetString; + QString CallString; + QString CheckString; + QString FoldString; + QString PotString; + QString TotalString; + QString BetsString; + QString GameString; + QString HandString; + QString PreflopString; + QString FlopString; + QString TurnString; + QString RiverString; + + friend class MyAvatarLabel; + friend class GuiWrapper; }; #endif diff --git a/src/gui/qt/gametable/log/guilog.cpp b/src/gui/qt/gametable/log/guilog.cpp index eb0fd362..47f78a36 100644 --- a/src/gui/qt/gametable/log/guilog.cpp +++ b/src/gui/qt/gametable/log/guilog.cpp @@ -31,142 +31,152 @@ using namespace std; guiLog::guiLog(gameTableImpl* w, ConfigFile *c) : myW(w), myConfig(c), myLogDir(0), myHtmlLogFile(0), mySqliteLogDb(0) { - myW->setGuiLog(this); - myStyle = myW->getMyGameTableStyle(); + myW->setGuiLog(this); + myStyle = myW->getMyGameTableStyle(); - myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); + myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); - connect(this, SIGNAL(signalLogPlayerActionMsg(QString, int, int, int)), this, SLOT(logPlayerActionMsg(QString, int, int, int))); - connect(this, SIGNAL(signalLogNewGameHandMsg(int, int)), this, SLOT(logNewGameHandMsg(int, int))); - connect(this, SIGNAL(signalLogNewBlindsSetsMsg(int, int, QString, QString)), this, SLOT(logNewBlindsSetsMsg(int, int, QString, QString))); - connect(this, SIGNAL(signalLogPlayerWinsMsg(QString, int, bool)), this, SLOT(logPlayerWinsMsg(QString, int, bool))); - connect(this, SIGNAL(signalLogPlayerSitsOut(QString)), this, SLOT(logPlayerSitsOut(QString))); - connect(this, SIGNAL(signalLogDealBoardCardsMsg(int, int, int, int, int, int)), this, SLOT(logDealBoardCardsMsg(int, int, int, int, int, int))); - connect(this, SIGNAL(signalLogFlipHoleCardsMsg(QString, int, int, int, int, QString)), this, SLOT(logFlipHoleCardsMsg(QString, int, int, int, int, QString))); - connect(this, SIGNAL(signalLogPlayerLeftMsg(QString, int)), this, SLOT(logPlayerLeftMsg(QString, int))); - connect(this, SIGNAL(signalLogNewGameAdminMsg(QString)), this, SLOT(logNewGameAdminMsg(QString))); - connect(this, SIGNAL(signalLogPlayerWinGame(QString, int)), this, SLOT(logPlayerWinGame(QString, int))); - connect(this, SIGNAL(signalFlushLogAtGame(int)), this, SLOT(flushLogAtGame(int))); - connect(this, SIGNAL(signalFlushLogAtHand()), this, SLOT(flushLogAtHand())); + connect(this, SIGNAL(signalLogPlayerActionMsg(QString, int, int, int)), this, SLOT(logPlayerActionMsg(QString, int, int, int))); + connect(this, SIGNAL(signalLogNewGameHandMsg(int, int)), this, SLOT(logNewGameHandMsg(int, int))); + connect(this, SIGNAL(signalLogNewBlindsSetsMsg(int, int, QString, QString)), this, SLOT(logNewBlindsSetsMsg(int, int, QString, QString))); + connect(this, SIGNAL(signalLogPlayerWinsMsg(QString, int, bool)), this, SLOT(logPlayerWinsMsg(QString, int, bool))); + connect(this, SIGNAL(signalLogPlayerSitsOut(QString)), this, SLOT(logPlayerSitsOut(QString))); + connect(this, SIGNAL(signalLogDealBoardCardsMsg(int, int, int, int, int, int)), this, SLOT(logDealBoardCardsMsg(int, int, int, int, int, int))); + connect(this, SIGNAL(signalLogFlipHoleCardsMsg(QString, int, int, int, int, QString)), this, SLOT(logFlipHoleCardsMsg(QString, int, int, int, int, QString))); + connect(this, SIGNAL(signalLogPlayerLeftMsg(QString, int)), this, SLOT(logPlayerLeftMsg(QString, int))); + connect(this, SIGNAL(signalLogNewGameAdminMsg(QString)), this, SLOT(logNewGameAdminMsg(QString))); + connect(this, SIGNAL(signalLogPlayerWinGame(QString, int)), this, SLOT(logPlayerWinGame(QString, int))); + connect(this, SIGNAL(signalFlushLogAtGame(int)), this, SLOT(flushLogAtGame(int))); + connect(this, SIGNAL(signalFlushLogAtHand()), this, SLOT(flushLogAtHand())); - logFileStreamString = ""; - lastGameID = 0; + logFileStreamString = ""; + lastGameID = 0; - if(myConfig->readConfigInt("LogOnOff")) { - //if write logfiles is enabled + if(myConfig->readConfigInt("LogOnOff")) { + //if write logfiles is enabled - QDir logDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str())); + QDir logDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str())); - if(myConfig->readConfigString("LogDir") != "" && logDir.exists()) { + if(myConfig->readConfigString("LogDir") != "" && logDir.exists()) { - int i; + int i; - if(HTML_LOG) { + if(HTML_LOG) { - myLogDir = new QDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str())); - QDateTime currentTime = QDateTime::currentDateTime(); - myHtmlLogFile = new QFile(myLogDir->absolutePath()+"/pokerth-log-"+currentTime.toString("yyyy-MM-dd_hh.mm.ss")+".html"); + myLogDir = new QDir(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str())); + QDateTime currentTime = QDateTime::currentDateTime(); + myHtmlLogFile = new QFile(myLogDir->absolutePath()+"/pokerth-log-"+currentTime.toString("yyyy-MM-dd_hh.mm.ss")+".html"); - //Logo-Pixmap extrahieren - QPixmap logoChipPixmapFile(":/gfx/logoChip3D.png"); - logoChipPixmapFile.save(myLogDir->absolutePath()+"/logo.png"); + //Logo-Pixmap extrahieren + QPixmap logoChipPixmapFile(":/gfx/logoChip3D.png"); + logoChipPixmapFile.save(myLogDir->absolutePath()+"/logo.png"); // myW->textBrowser_Log->append(myHtmlLogFile->fileName()); - // erstelle html-Datei - myHtmlLogFile->open( QIODevice::WriteOnly ); - QTextStream stream( myHtmlLogFile ); - stream << "\n"; - stream << "\n"; - stream << ""; - stream << "\n"; - stream << "\n"; - stream << "\n"; - stream << QString("

Log-File for PokerTH %1 Session started on ").arg(POKERTH_BETA_RELEASE_STRING)+QDate::currentDate().toString("yyyy-MM-dd")+" at "+QTime::currentTime().toString("hh:mm:ss")+"

\n"; - myHtmlLogFile->close(); + // erstelle html-Datei + myHtmlLogFile->open( QIODevice::WriteOnly ); + QTextStream stream( myHtmlLogFile ); + stream << "\n"; + stream << "\n"; + stream << ""; + stream << "\n"; + stream << "\n"; + stream << "\n"; + stream << QString("

Log-File for PokerTH %1 Session started on ").arg(POKERTH_BETA_RELEASE_STRING)+QDate::currentDate().toString("yyyy-MM-dd")+" at "+QTime::currentTime().toString("hh:mm:ss")+"

\n"; + myHtmlLogFile->close(); - } + } - // delete old log files - int daysUntilWaste = myConfig->readConfigInt("LogStoreDuration"); + // delete old log files + int daysUntilWaste = myConfig->readConfigInt("LogStoreDuration"); - QStringList filters("pokerth-log*"); - QStringList logFileList = myLogDir->entryList(filters, QDir::Files); + QStringList filters("pokerth-log*"); + QStringList logFileList = myLogDir->entryList(filters, QDir::Files); - for(i=0; i daysUntilWaste) { + if (dateOfFile.daysTo(today) > daysUntilWaste) { - // cout << QString::QString(myLogDir->absolutePath()+"/"+logFileList.at(i)).toStdString() << endl; - QFile fileToDelete(myLogDir->absolutePath()+"/"+logFileList.at(i)); - fileToDelete.remove(); - } + // cout << QString::QString(myLogDir->absolutePath()+"/"+logFileList.at(i)).toStdString() << endl; + QFile fileToDelete(myLogDir->absolutePath()+"/"+logFileList.at(i)); + fileToDelete.remove(); + } - } + } - } else { - cout << "Log directory doesn't exist. Cannot create log files"; - } - } + } else { + cout << "Log directory doesn't exist. Cannot create log files"; + } + } } guiLog::~guiLog() { - delete myLogDir; - delete myHtmlLogFile; + delete myLogDir; + delete myHtmlLogFile; } -void guiLog::logPlayerActionMsg(QString msg, int playerID, int action, int setValue) { +void guiLog::logPlayerActionMsg(QString msg, int playerID, int action, int setValue) +{ switch (action) { - case 1: msg += " folds."; + case 1: + msg += " folds."; break; - case 2: msg += " checks."; + case 2: + msg += " checks."; break; - case 3: msg += " calls "; + case 3: + msg += " calls "; break; - case 4: msg += " bets "; + case 4: + msg += " bets "; break; - case 5: msg += " bets "; + case 5: + msg += " bets "; break; - case 6: msg += " is all in with "; + case 6: + msg += " is all in with "; break; - default: msg += "ERROR"; + default: + msg += "ERROR"; } - - if (action >= 3) { msg += "$"+QString::number(setValue,10)+"."; } - - myW->textBrowser_Log->append("getChatLogTextColor()+";\">"+msg+""); + + if (action >= 3) { + msg += "$"+QString::number(setValue,10)+"."; + } + + myW->textBrowser_Log->append("getChatLogTextColor()+";\">"+msg+""); if(myConfig->readConfigInt("LogOnOff")) { - //if write logfiles is enabled + //if write logfiles is enabled - if(HTML_LOG) { + if(HTML_LOG) { - logFileStreamString += msg+"
\n"; + logFileStreamString += msg+"
\n"; - if(myConfig->readConfigInt("LogInterval") == 0) { - writeLogFileStream(logFileStreamString); - logFileStreamString = ""; - } + if(myConfig->readConfigInt("LogInterval") == 0) { + writeLogFileStream(logFileStreamString); + logFileStreamString = ""; + } - } + } - if(SQLITE_LOG) { + if(SQLITE_LOG) { // if(mySqliteLogDb->isOpen()) { @@ -193,86 +203,87 @@ void guiLog::logPlayerActionMsg(QString msg, int playerID, int action, int setVa // QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel); // } - } + } } } -void guiLog::logNewGameHandMsg(int gameID, int handID) { +void guiLog::logNewGameHandMsg(int gameID, int handID) +{ PlayerListConstIterator it_c; boost::shared_ptr currentHand = myW->getSession()->getCurrentGame()->getCurrentHand(); - PlayerList activePlayerList = currentHand->getActivePlayerList(); + PlayerList activePlayerList = currentHand->getActivePlayerList(); - myW->textBrowser_Log->append("getChatLogTextColor()+"; font-size:large; font-weight:bold\">## Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+" ##"); + myW->textBrowser_Log->append("getChatLogTextColor()+"; font-size:large; font-weight:bold\">## Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+" ##"); if(myConfig->readConfigInt("LogOnOff")) { - //if write logfiles is enabled + //if write logfiles is enabled - if(HTML_LOG) { + if(HTML_LOG) { - logFileStreamString += "

Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+"
"; - logFileStreamString += "BLIND LEVEL: $"+QString::number(currentHand->getSmallBlind())+" / $"+QString::number(currentHand->getSmallBlind()*2)+"
"; + logFileStreamString += "

Game: "+QString::number(gameID,10)+" | Hand: "+QString::number(handID,10)+"
"; + logFileStreamString += "BLIND LEVEL: $"+QString::number(currentHand->getSmallBlind())+" / $"+QString::number(currentHand->getSmallBlind()*2)+"
"; - //print cash only for active players + //print cash only for active players for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - logFileStreamString += "Seat " + QString::number((*it_c)->getMyID()+1,10) + ": " + QString::fromUtf8((*it_c)->getMyName().c_str()) + " ($" + QString::number((*it_c)->getMyCash()+(*it_c)->getMySet(),10)+")
"; + logFileStreamString += "Seat " + QString::number((*it_c)->getMyID()+1,10) + ": " + QString::fromUtf8((*it_c)->getMyName().c_str()) + " ($" + QString::number((*it_c)->getMyCash()+(*it_c)->getMySet(),10)+")
"; - } + } - } + } - if(SQLITE_LOG) { + if(SQLITE_LOG) { - string sql; - char *errmsg; + string sql; + char *errmsg; - if( mySqliteLogDb != 0 ) { + if( mySqliteLogDb != 0 ) { - if(handID == 1) { - // start of a game -> insert game data + 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(i); - } - sql += ") VALUES ("; - sql += boost::lexical_cast(gameID); - sql += "," + boost::lexical_cast(myW->getSession()->getCurrentGame()->getStartCash()); - sql += "," + boost::lexical_cast(myW->getSession()->getCurrentGame()->getStartSmallBlind()); - sql += "," + boost::lexical_cast(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; - } + 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(myW->getSession()->getCurrentGame()->getStartCash()); + sql += "," + boost::lexical_cast(myW->getSession()->getCurrentGame()->getStartSmallBlind()); + sql += "," + boost::lexical_cast(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 ("; + // 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"; @@ -299,7 +310,7 @@ void guiLog::logNewGameHandMsg(int gameID, int handID) { //// } // sql += ")"; - } + } // if(mySqliteLogDb->isOpen()) { @@ -371,74 +382,76 @@ void guiLog::logNewGameHandMsg(int gameID, int handID) { // } - } + } } } -void guiLog::logNewBlindsSetsMsg(int sbSet, int bbSet, QString sbName, QString bbName) { +void guiLog::logNewBlindsSetsMsg(int sbSet, int bbSet, QString sbName, QString bbName) +{ - // log blinds - myW->textBrowser_Log->append("getChatLogTextColor()+";\">"+sbName+" posts small blind ($"+QString::number(sbSet,10)+")"); - myW->textBrowser_Log->append("getChatLogTextColor()+";\">"+bbName+" posts big blind ($"+QString::number(bbSet,10)+")"); + // log blinds + myW->textBrowser_Log->append("getChatLogTextColor()+";\">"+sbName+" posts small blind ($"+QString::number(sbSet,10)+")"); + myW->textBrowser_Log->append("getChatLogTextColor()+";\">"+bbName+" posts big blind ($"+QString::number(bbSet,10)+")"); - if(myConfig->readConfigInt("LogOnOff")) { - //if write logfiles is enabled + if(myConfig->readConfigInt("LogOnOff")) { + //if write logfiles is enabled - if(HTML_LOG) { + if(HTML_LOG) { - logFileStreamString += "BLINDS: "; + logFileStreamString += "BLINDS: "; - logFileStreamString += sbName+" ($"+QString::number(sbSet,10)+"), "; - logFileStreamString += bbName+" ($"+QString::number(bbSet,10)+")"; + logFileStreamString += sbName+" ($"+QString::number(sbSet,10)+"), "; + logFileStreamString += bbName+" ($"+QString::number(bbSet,10)+")"; - PlayerListConstIterator it_c; + PlayerListConstIterator it_c; boost::shared_ptr currentGame = myW->getSession()->getCurrentGame(); PlayerList activePlayerList = currentGame->getActivePlayerList(); for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { - if(activePlayerList->size() > 2) { - if((*it_c)->getMyButton() == BUTTON_DEALER) { + if(activePlayerList->size() > 2) { + if((*it_c)->getMyButton() == BUTTON_DEALER) { - logFileStreamString += "
" + QString::fromUtf8((*it_c)->getMyName().c_str()) + " starts as dealer."; - break; - } - } else { - if((*it_c)->getMyButton() == BUTTON_SMALL_BLIND) { + logFileStreamString += "
" + QString::fromUtf8((*it_c)->getMyName().c_str()) + " starts as dealer."; + break; + } + } else { + if((*it_c)->getMyButton() == BUTTON_SMALL_BLIND) { - logFileStreamString += "
" + QString::fromUtf8((*it_c)->getMyName().c_str()) + " starts as dealer."; - break; - } - } - } + logFileStreamString += "
" + QString::fromUtf8((*it_c)->getMyName().c_str()) + " starts as dealer."; + break; + } + } + } - logFileStreamString += "

PREFLOP"; - logFileStreamString += "
\n"; + logFileStreamString += "

PREFLOP"; + logFileStreamString += "
\n"; - } + } - if(SQLITE_LOG) { + if(SQLITE_LOG) { - } + } - } + } } -void guiLog::logPlayerWinsMsg(QString playerName, int pot, bool main) { +void guiLog::logPlayerWinsMsg(QString playerName, int pot, bool main) +{ if(main) { myW->textBrowser_Log->append("getLogWinnerMainPotColor()+";\">"+playerName+" wins $"+QString::number(pot,10)+""); } else { myW->textBrowser_Log->append("getLogWinnerSidePotColor()+";\">"+playerName+" wins $"+QString::number(pot,10)+" (side pot)"); } - + if(myConfig->readConfigInt("LogOnOff")) { - //if write logfiles is enabled + //if write logfiles is enabled logFileStreamString += "
"+playerName+" wins $"+QString::number(pot,10); if(!main) { @@ -446,73 +459,83 @@ void guiLog::logPlayerWinsMsg(QString playerName, int pot, bool main) { } logFileStreamString += "\n"; - if(myConfig->readConfigInt("LogInterval") == 0) { + if(myConfig->readConfigInt("LogInterval") == 0) { writeLogFileStream(logFileStreamString); logFileStreamString = ""; } } } -void guiLog::logPlayerSitsOut(QString playerName) { +void guiLog::logPlayerSitsOut(QString playerName) +{ myW->textBrowser_Log->append("getLogPlayerSitsOutColor()+";\">"+playerName+" sits out"); - + if(myConfig->readConfigInt("LogOnOff")) { logFileStreamString += "
"+playerName+" sits out\n"; - if(myConfig->readConfigInt("LogInterval") == 0) { + if(myConfig->readConfigInt("LogInterval") == 0) { writeLogFileStream(logFileStreamString); logFileStreamString = ""; } } } -void guiLog::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4, int card5) { - +void guiLog::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4, int card5) +{ + QString round; - + switch (roundID) { - case 1: round = "Flop"; - myW->textBrowser_Log->append("getLogPlayerSitsOutColor()+";\">--- "+round+" --- "+"["+translateCardCode(card1).at(0)+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+translateCardCode(card3).at(1)+"]"); + case 1: + round = "Flop"; + myW->textBrowser_Log->append("getLogPlayerSitsOutColor()+";\">--- "+round+" --- "+"["+translateCardCode(card1).at(0)+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+translateCardCode(card3).at(1)+"]"); break; - case 2: round = "Turn"; - myW->textBrowser_Log->append("getLogPlayerSitsOutColor()+";\">--- "+round+" --- "+"["+translateCardCode(card1).at(0)+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+translateCardCode(card3).at(1)+","+translateCardCode(card4).at(0)+translateCardCode(card4).at(1)+"]"); + case 2: + round = "Turn"; + myW->textBrowser_Log->append("getLogPlayerSitsOutColor()+";\">--- "+round+" --- "+"["+translateCardCode(card1).at(0)+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+translateCardCode(card3).at(1)+","+translateCardCode(card4).at(0)+translateCardCode(card4).at(1)+"]"); break; - case 3: round = "River"; - myW->textBrowser_Log->append("getLogPlayerSitsOutColor()+";\">--- "+round+" --- "+"["+translateCardCode(card1).at(0)+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+translateCardCode(card3).at(1)+","+translateCardCode(card4).at(0)+translateCardCode(card4).at(1)+","+translateCardCode(card5).at(0)+translateCardCode(card5).at(1)+"]"); + case 3: + round = "River"; + myW->textBrowser_Log->append("getLogPlayerSitsOutColor()+";\">--- "+round+" --- "+"["+translateCardCode(card1).at(0)+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+translateCardCode(card3).at(1)+","+translateCardCode(card4).at(0)+translateCardCode(card4).at(1)+","+translateCardCode(card5).at(0)+translateCardCode(card5).at(1)+"]"); break; - default: round = "ERROR"; + default: + round = "ERROR"; } if(myConfig->readConfigInt("LogOnOff")) { - //if write logfiles is enabled + //if write logfiles is enabled - if(HTML_LOG) { + if(HTML_LOG) { - switch (roundID) { + switch (roundID) { - case 1: round = "Flop"; - logFileStreamString += "
"+round.toUpper()+" [board cards "+translateCardCode(card1).at(0)+""+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+""+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+""+translateCardCode(card3).at(1)+"]"+"
\n"; - break; - case 2: round = "Turn"; - logFileStreamString += "
"+round.toUpper()+" [board cards "+translateCardCode(card1).at(0)+""+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+""+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+""+translateCardCode(card3).at(1)+","+translateCardCode(card4).at(0)+""+translateCardCode(card4).at(1)+"]"+"
\n"; - break; - case 3: round = "River"; - logFileStreamString += "
"+round.toUpper()+" [board cards "+translateCardCode(card1).at(0)+""+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+""+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+""+translateCardCode(card3).at(1)+","+translateCardCode(card4).at(0)+""+translateCardCode(card4).at(1)+","+translateCardCode(card5).at(0)+""+translateCardCode(card5).at(1)+"]"+"
\n"; - break; - default: round = "ERROR"; - } + case 1: + round = "Flop"; + logFileStreamString += "
"+round.toUpper()+" [board cards "+translateCardCode(card1).at(0)+""+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+""+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+""+translateCardCode(card3).at(1)+"]"+"
\n"; + break; + case 2: + round = "Turn"; + logFileStreamString += "
"+round.toUpper()+" [board cards "+translateCardCode(card1).at(0)+""+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+""+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+""+translateCardCode(card3).at(1)+","+translateCardCode(card4).at(0)+""+translateCardCode(card4).at(1)+"]"+"
\n"; + break; + case 3: + round = "River"; + logFileStreamString += "
"+round.toUpper()+" [board cards "+translateCardCode(card1).at(0)+""+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+""+translateCardCode(card2).at(1)+","+translateCardCode(card3).at(0)+""+translateCardCode(card3).at(1)+","+translateCardCode(card4).at(0)+""+translateCardCode(card4).at(1)+","+translateCardCode(card5).at(0)+""+translateCardCode(card5).at(1)+"]"+"
\n"; + break; + default: + round = "ERROR"; + } - if(myConfig->readConfigInt("LogInterval") == 0) { - writeLogFileStream(logFileStreamString); - logFileStreamString = ""; - } + if(myConfig->readConfigInt("LogInterval") == 0) { + writeLogFileStream(logFileStreamString); + logFileStreamString = ""; + } - } + } - if(SQLITE_LOG) { + if(SQLITE_LOG) { // if(mySqliteLogDb->isOpen()) { @@ -552,55 +575,55 @@ void guiLog::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, // QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel); // } - } + } } } -void guiLog::logFlipHoleCardsMsg(QString playerName, int playerID, int card1, int card2, int cardsValueInt, QString showHas) { +void guiLog::logFlipHoleCardsMsg(QString playerName, int playerID, int card1, int card2, int cardsValueInt, QString showHas) +{ - QString tempHandName; + QString tempHandName; if (cardsValueInt != -1) { - - tempHandName = determineHandName(cardsValueInt); - myW->textBrowser_Log->append("getChatLogTextColor()+";\">"+playerName+" "+showHas+" \""+tempHandName+"\""); + tempHandName = determineHandName(cardsValueInt); + + myW->textBrowser_Log->append("getChatLogTextColor()+";\">"+playerName+" "+showHas+" \""+tempHandName+"\""); + + } else { + + myW->textBrowser_Log->append("getChatLogTextColor()+";\">"+playerName+" "+showHas+" ["+translateCardCode(card1).at(0)+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+translateCardCode(card2).at(1)+"]"); } - else { - myW->textBrowser_Log->append("getChatLogTextColor()+";\">"+playerName+" "+showHas+" ["+translateCardCode(card1).at(0)+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+translateCardCode(card2).at(1)+"]"); - - } + if(myConfig->readConfigInt("LogOnOff")) { + //if write logfiles is enabled - if(myConfig->readConfigInt("LogOnOff")) { - //if write logfiles is enabled + if(HTML_LOG) { - if(HTML_LOG) { + if (cardsValueInt != -1) { - if (cardsValueInt != -1) { + tempHandName = determineHandName(cardsValueInt); - tempHandName = determineHandName(cardsValueInt); + logFileStreamString += playerName+" "+showHas+" [ "+translateCardCode(card1).at(0)+""+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+""+translateCardCode(card2).at(1)+"] - "+tempHandName+"
\n"; - logFileStreamString += playerName+" "+showHas+" [ "+translateCardCode(card1).at(0)+""+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+""+translateCardCode(card2).at(1)+"] - "+tempHandName+"
\n"; + if(myConfig->readConfigInt("LogInterval") == 0) { + writeLogFileStream(logFileStreamString); + logFileStreamString = ""; + } - if(myConfig->readConfigInt("LogInterval") == 0) { - writeLogFileStream(logFileStreamString); - logFileStreamString = ""; - } + } else { - } else { + logFileStreamString += playerName+" "+showHas+" ["+translateCardCode(card1).at(0)+""+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+""+translateCardCode(card2).at(1)+"]"+"
\n"; + if(myConfig->readConfigInt("LogInterval") == 0) { + writeLogFileStream(logFileStreamString); + logFileStreamString = ""; + } + } + } - logFileStreamString += playerName+" "+showHas+" ["+translateCardCode(card1).at(0)+""+translateCardCode(card1).at(1)+","+translateCardCode(card2).at(0)+""+translateCardCode(card2).at(1)+"]"+"
\n"; - if(myConfig->readConfigInt("LogInterval") == 0) { - writeLogFileStream(logFileStreamString); - logFileStreamString = ""; - } - } - } - - if(SQLITE_LOG) { + if(SQLITE_LOG) { // if(mySqliteLogDb->isOpen()) { @@ -620,55 +643,58 @@ void guiLog::logFlipHoleCardsMsg(QString playerName, int playerID, int card1, in // QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel); // } - } + } + + } - } - } -void guiLog::logPlayerLeftMsg(QString playerName, int wasKicked) { +void guiLog::logPlayerLeftMsg(QString playerName, int wasKicked) +{ QString action; if(wasKicked) action = "was kicked from"; else action = "has left"; - myW->textBrowser_Log->append( "getChatLogTextColor()+";\">"+playerName+" "+action+" the game!"); - + myW->textBrowser_Log->append( "getChatLogTextColor()+";\">"+playerName+" "+action+" the game!"); + if(myConfig->readConfigInt("LogOnOff")) { - + logFileStreamString += ""+playerName+" "+action+" the game!
\n"; - if(myConfig->readConfigInt("LogInterval") == 0) { + if(myConfig->readConfigInt("LogInterval") == 0) { writeLogFileStream(logFileStreamString); logFileStreamString = ""; } } } -void guiLog::logNewGameAdminMsg(QString playerName) { +void guiLog::logNewGameAdminMsg(QString playerName) +{ myW->textBrowser_Log->append( "getLogNewGameAdminColor()+";\">"+playerName+" is game admin now!"); - + if(myConfig->readConfigInt("LogOnOff")) { - + logFileStreamString += ""+playerName+" is game admin now!
\n"; - if(myConfig->readConfigInt("LogInterval") == 0) { + if(myConfig->readConfigInt("LogInterval") == 0) { writeLogFileStream(logFileStreamString); logFileStreamString = ""; } } } -void guiLog::logPlayerWinGame(QString playerName, int gameID) { +void guiLog::logPlayerWinGame(QString playerName, int gameID) +{ myW->textBrowser_Log->append( ""+playerName+" wins game " + QString::number(gameID,10) +"!
"); - + if(myConfig->readConfigInt("LogOnOff")) { - + logFileStreamString += "

"+playerName+" wins game " + QString::number(gameID,10) +"!
\n"; - if(myConfig->readConfigInt("LogInterval") == 0) { + if(myConfig->readConfigInt("LogInterval") == 0) { writeLogFileStream(logFileStreamString); logFileStreamString = ""; } @@ -676,61 +702,82 @@ void guiLog::logPlayerWinGame(QString playerName, int gameID) { } -QStringList guiLog::translateCardCode(int cardCode) { +QStringList guiLog::translateCardCode(int cardCode) +{ int value = cardCode%13; int color = cardCode/13; - + QStringList cardString; - + switch (value) { - - case 0: cardString << "2"; + + case 0: + cardString << "2"; break; - case 1: cardString << "3"; + case 1: + cardString << "3"; break; - case 2: cardString << "4"; + case 2: + cardString << "4"; break; - case 3: cardString << "5"; + case 3: + cardString << "5"; break; - case 4: cardString << "6"; + case 4: + cardString << "6"; break; - case 5: cardString << "7"; + case 5: + cardString << "7"; break; - case 6: cardString << "8"; + case 6: + cardString << "8"; break; - case 7: cardString << "9"; + case 7: + cardString << "9"; break; - case 8: cardString << "T"; + case 8: + cardString << "T"; break; - case 9: cardString << "J"; + case 9: + cardString << "J"; break; - case 10: cardString << "Q"; + case 10: + cardString << "Q"; break; - case 11: cardString << "K"; + case 11: + cardString << "K"; break; - case 12: cardString << "A"; + case 12: + cardString << "A"; break; - default: cardString << "ERROR"; + default: + cardString << "ERROR"; } switch (color) { - - case 0: cardString << "d"; + + case 0: + cardString << "d"; break; - case 1: cardString << "h"; + case 1: + cardString << "h"; break; - case 2: cardString << "s"; + case 2: + cardString << "s"; break; - case 3: cardString << "c"; + case 3: + cardString << "c"; break; - default: cardString << "ERROR"; + default: + cardString << "ERROR"; } - + return cardString; } -QStringList guiLog::translateCardsValueCode(int cardsValueCode) { +QStringList guiLog::translateCardsValueCode(int cardsValueCode) +{ QStringList cardString; @@ -752,784 +799,1127 @@ QStringList guiLog::translateCardsValueCode(int cardsValueCode) { switch (firstPart) { // Royal Flush - case 9: cardString << "Royal Flush"; + case 9: + cardString << "Royal Flush"; break; // Straight Flush - case 8: { - cardString << "Straight Flush, "; - switch(secondPart) { - case 11: cardString << "King high"; - break; - case 10: cardString << "Queen high"; - break; - case 9: cardString << "Jack high"; - break; - case 8: cardString << "Ten high"; - break; - case 7: cardString << "Nine high"; - break; - case 6: cardString << "Eight high"; - break; - case 5: cardString << "Seven high"; - break; - case 4: cardString << "Six high"; - break; - case 3: cardString << "Five high"; - break; - default: cardString << "ERROR"; - } + case 8: { + cardString << "Straight Flush, "; + switch(secondPart) { + case 11: + cardString << "King high"; + break; + case 10: + cardString << "Queen high"; + break; + case 9: + cardString << "Jack high"; + break; + case 8: + cardString << "Ten high"; + break; + case 7: + cardString << "Nine high"; + break; + case 6: + cardString << "Eight high"; + break; + case 5: + cardString << "Seven high"; + break; + case 4: + cardString << "Six high"; + break; + case 3: + cardString << "Five high"; + break; + default: + cardString << "ERROR"; } - break; - // Four of a Kind - case 7: { - cardString << "Four of a Kind, "; - switch(secondPart) { - case 12: cardString << "Aces"; - break; - case 11: cardString << "Kings"; - break; - case 10: cardString << "Queens"; - break; - case 9: cardString << "Jacks"; - break; - case 8: cardString << "Tens"; - break; - case 7: cardString << "Nines"; - break; - case 6: cardString << "Eights"; - break; - case 5: cardString << "Sevens"; - break; - case 4: cardString << "Sixes"; - break; - case 3: cardString << "Fives"; - break; - case 2: cardString << "Fours"; - break; - case 1: cardString << "Threes"; - break; - case 0: cardString << "Deuces"; - break; - default: cardString << "ERROR"; - } - // Kicker - switch(thirdPart) { - case 12: cardString << "Ace"; - break; - case 11: cardString << "King"; - break; - case 10: cardString << "Queen"; - break; - case 9: cardString << "Jack"; - break; - case 8: cardString << "Ten"; - break; - case 7: cardString << "Nine"; - break; - case 6: cardString << "Eight"; - break; - case 5: cardString << "Seven"; - break; - case 4: cardString << "Six"; - break; - case 3: cardString << "Five"; - break; - case 2: cardString << "Four"; - break; - case 1: cardString << "Three"; - break; - case 0: cardString << "Deuce"; - break; - default: cardString << "ERROR"; - } + } + break; + // Four of a Kind + case 7: { + cardString << "Four of a Kind, "; + switch(secondPart) { + case 12: + cardString << "Aces"; + break; + case 11: + cardString << "Kings"; + break; + case 10: + cardString << "Queens"; + break; + case 9: + cardString << "Jacks"; + break; + case 8: + cardString << "Tens"; + break; + case 7: + cardString << "Nines"; + break; + case 6: + cardString << "Eights"; + break; + case 5: + cardString << "Sevens"; + break; + case 4: + cardString << "Sixes"; + break; + case 3: + cardString << "Fives"; + break; + case 2: + cardString << "Fours"; + break; + case 1: + cardString << "Threes"; + break; + case 0: + cardString << "Deuces"; + break; + default: + cardString << "ERROR"; } - break; - // Full House - case 6: { - cardString << "Full House, "; - //Drilling - switch(secondPart) { - case 12: cardString << "Aces full of "; - break; - case 11: cardString << "Kings full of "; - break; - case 10: cardString << "Queens full of "; - break; - case 9: cardString << "Jacks full of "; - break; - case 8: cardString << "Tens full of "; - break; - case 7: cardString << "Nines full of "; - break; - case 6: cardString << "Eights full of "; - break; - case 5: cardString << "Sevens full of "; - break; - case 4: cardString << "Sixes full of "; - break; - case 3: cardString << "Fives full of "; - break; - case 2: cardString << "Fours full of "; - break; - case 1: cardString << "Threes full of "; - break; - case 0: cardString << "Deuces full of "; - break; - default: cardString << "ERROR"; - } - //Pärchen - switch(thirdPart) { - case 12: cardString << "Aces"; - break; - case 11: cardString << "Kings"; - break; - case 10: cardString << "Queens"; - break; - case 9: cardString << "Jacks"; - break; - case 8: cardString << "Tens"; - break; - case 7: cardString << "Nines"; - break; - case 6: cardString << "Eights"; - break; - case 5: cardString << "Sevens"; - break; - case 4: cardString << "Sixes"; - break; - case 3: cardString << "Fives"; - break; - case 2: cardString << "Fours"; - break; - case 1: cardString << "Threes"; - break; - case 0: cardString << "Deuces"; - break; - default: cardString << "ERROR"; - } + // Kicker + switch(thirdPart) { + case 12: + cardString << "Ace"; + break; + case 11: + cardString << "King"; + break; + case 10: + cardString << "Queen"; + break; + case 9: + cardString << "Jack"; + break; + case 8: + cardString << "Ten"; + break; + case 7: + cardString << "Nine"; + break; + case 6: + cardString << "Eight"; + break; + case 5: + cardString << "Seven"; + break; + case 4: + cardString << "Six"; + break; + case 3: + cardString << "Five"; + break; + case 2: + cardString << "Four"; + break; + case 1: + cardString << "Three"; + break; + case 0: + cardString << "Deuce"; + break; + default: + cardString << "ERROR"; } - break; - // Flush - case 5: { - cardString << "Flush, "; - //highest Card - switch(secondPart) { - case 12: cardString << "Ace high"; - break; - case 11: cardString << "King high"; - break; - case 10: cardString << "Queen high"; - break; - case 9: cardString << "Jack high"; - break; - case 8: cardString << "Ten high"; - break; - case 7: cardString << "Nine high"; - break; - case 6: cardString << "Eight high"; - break; - case 5: cardString << "Seven high"; - break; - case 4: cardString << "Six high"; - break; - default: cardString << "ERROR"; - } - // Kicker 1 - switch(thirdPart) { - case 12: cardString << "Ace"; - break; - case 11: cardString << "King"; - break; - case 10: cardString << "Queen"; - break; - case 9: cardString << "Jack"; - break; - case 8: cardString << "Ten"; - break; - case 7: cardString << "Nine"; - break; - case 6: cardString << "Eight"; - break; - case 5: cardString << "Seven"; - break; - case 4: cardString << "Six"; - break; - case 3: cardString << "Five"; - break; - case 2: cardString << "Four"; - break; - case 1: cardString << "Three"; - break; - case 0: cardString << "Deuce"; - break; - default: cardString << "ERROR"; - } - //Kicker 2 - switch(fourthPart) { - case 12: cardString << "Ace"; - break; - case 11: cardString << "King"; - break; - case 10: cardString << "Queen"; - break; - case 9: cardString << "Jack"; - break; - case 8: cardString << "Ten"; - break; - case 7: cardString << "Nine"; - break; - case 6: cardString << "Eight"; - break; - case 5: cardString << "Seven"; - break; - case 4: cardString << "Six"; - break; - case 3: cardString << "Five"; - break; - case 2: cardString << "Four"; - break; - case 1: cardString << "Three"; - break; - case 0: cardString << "Deuce"; - break; - default: cardString << "ERROR"; - } - //Kicker 3 - switch(fifthPartA) { - case 9: cardString << "Jack"; - break; - case 8: cardString << "Ten"; - break; - case 7: cardString << "Nine"; - break; - case 6: cardString << "Eight"; - break; - case 5: cardString << "Seven"; - break; - case 4: cardString << "Six"; - break; - case 3: cardString << "Five"; - break; - case 2: cardString << "Four"; - break; - case 1: cardString << "Three"; - break; - case 0: cardString << "Deuce"; - break; - default: cardString << "ERROR"; - } - //Kicker 4 - switch(fifthPartB) { - case 9: cardString << "Jack"; - break; - case 8: cardString << "Ten"; - break; - case 7: cardString << "Nine"; - break; - case 6: cardString << "Eight"; - break; - case 5: cardString << "Seven"; - break; - case 4: cardString << "Six"; - break; - case 3: cardString << "Five"; - break; - case 2: cardString << "Four"; - break; - case 1: cardString << "Three"; - break; - case 0: cardString << "Deuce"; - break; - default: cardString << "ERROR"; - } + } + break; + // Full House + case 6: { + cardString << "Full House, "; + //Drilling + switch(secondPart) { + case 12: + cardString << "Aces full of "; + break; + case 11: + cardString << "Kings full of "; + break; + case 10: + cardString << "Queens full of "; + break; + case 9: + cardString << "Jacks full of "; + break; + case 8: + cardString << "Tens full of "; + break; + case 7: + cardString << "Nines full of "; + break; + case 6: + cardString << "Eights full of "; + break; + case 5: + cardString << "Sevens full of "; + break; + case 4: + cardString << "Sixes full of "; + break; + case 3: + cardString << "Fives full of "; + break; + case 2: + cardString << "Fours full of "; + break; + case 1: + cardString << "Threes full of "; + break; + case 0: + cardString << "Deuces full of "; + break; + default: + cardString << "ERROR"; } - break; - // Straight - case 4: { - cardString << "Straight, "; - switch(secondPart) { - case 12: cardString << "Ace high"; - break; - case 11: cardString << "King high"; - break; - case 10: cardString << "Queen high"; - break; - case 9: cardString << "Jack high"; - break; - case 8: cardString << "Ten high"; - break; - case 7: cardString << "Nine high"; - break; - case 6: cardString << "Eight high"; - break; - case 5: cardString << "Seven high"; - break; - case 4: cardString << "Six high"; - break; - case 3: cardString << "Five high"; - break; - default: cardString << "ERROR"; - } + //Pärchen + switch(thirdPart) { + case 12: + cardString << "Aces"; + break; + case 11: + cardString << "Kings"; + break; + case 10: + cardString << "Queens"; + break; + case 9: + cardString << "Jacks"; + break; + case 8: + cardString << "Tens"; + break; + case 7: + cardString << "Nines"; + break; + case 6: + cardString << "Eights"; + break; + case 5: + cardString << "Sevens"; + break; + case 4: + cardString << "Sixes"; + break; + case 3: + cardString << "Fives"; + break; + case 2: + cardString << "Fours"; + break; + case 1: + cardString << "Threes"; + break; + case 0: + cardString << "Deuces"; + break; + default: + cardString << "ERROR"; } - break; - // Three of a Kind - case 3: { - cardString << "Three of a Kind, "; - switch(secondPart) { - case 12: cardString << "Aces"; - break; - case 11: cardString << "Kings"; - break; - case 10: cardString << "Queens"; - break; - case 9: cardString << "Jacks"; - break; - case 8: cardString << "Tens"; - break; - case 7: cardString << "Nines"; - break; - case 6: cardString << "Eights"; - break; - case 5: cardString << "Sevens"; - break; - case 4: cardString << "Sixes"; - break; - case 3: cardString << "Fives"; - break; - case 2: cardString << "Fours"; - break; - case 1: cardString << "Threes"; - break; - case 0: cardString << "Deuces"; - break; - default: cardString << "ERROR"; - } - //Kicker 1 - switch(thirdPart) { - case 12: cardString << "Ace"; - break; - case 11: cardString << "King"; - break; - case 10: cardString << "Queen"; - break; - case 9: cardString << "Jack"; - break; - case 8: cardString << "Ten"; - break; - case 7: cardString << "Nine"; - break; - case 6: cardString << "Eight"; - break; - case 5: cardString << "Seven"; - break; - case 4: cardString << "Six"; - break; - case 3: cardString << "Five"; - break; - case 2: cardString << "Four"; - break; - case 1: cardString << "Three"; - break; - case 0: cardString << "Deuce"; - break; - default: cardString << "ERROR"; - } - //Kicker 2 - switch(fourthPart) { - case 12: cardString << "Ace"; - break; - case 11: cardString << "King"; - break; - case 10: cardString << "Queen"; - break; - case 9: cardString << "Jack"; - break; - case 8: cardString << "Ten"; - break; - case 7: cardString << "Nine"; - break; - case 6: cardString << "Eight"; - break; - case 5: cardString << "Seven"; - break; - case 4: cardString << "Six"; - break; - case 3: cardString << "Five"; - break; - case 2: cardString << "Four"; - break; - case 1: cardString << "Three"; - break; - case 0: cardString << "Deuce"; - break; - default: cardString << "ERROR"; - } + } + break; + // Flush + case 5: { + cardString << "Flush, "; + //highest Card + switch(secondPart) { + case 12: + cardString << "Ace high"; + break; + case 11: + cardString << "King high"; + break; + case 10: + cardString << "Queen high"; + break; + case 9: + cardString << "Jack high"; + break; + case 8: + cardString << "Ten high"; + break; + case 7: + cardString << "Nine high"; + break; + case 6: + cardString << "Eight high"; + break; + case 5: + cardString << "Seven high"; + break; + case 4: + cardString << "Six high"; + break; + default: + cardString << "ERROR"; } - break; - // Two Pairs - case 2: { - cardString << "Two Pairs, "; - // erster Pair - switch(secondPart) { - case 12: cardString << "Aces and "; - break; - case 11: cardString << "Kings and "; - break; - case 10: cardString << "Queens and "; - break; - case 9: cardString << "Jacks and "; - break; - case 8: cardString << "Tens and "; - break; - case 7: cardString << "Nines and "; - break; - case 6: cardString << "Eights and "; - break; - case 5: cardString << "Sevens and "; - break; - case 4: cardString << "Sixes and "; - break; - case 3: cardString << "Fives and "; - break; - case 2: cardString << "Fours and "; - break; - case 1: cardString << "Threes and "; - break; - case 0: cardString << "Deuces and "; - break; - default: cardString << "ERROR"; - } - // zweiter Pair - switch(thirdPart) { - case 12: cardString << "Aces"; - break; - case 11: cardString << "Kings"; - break; - case 10: cardString << "Queens"; - break; - case 9: cardString << "Jacks"; - break; - case 8: cardString << "Tens"; - break; - case 7: cardString << "Nines"; - break; - case 6: cardString << "Eights"; - break; - case 5: cardString << "Sevens"; - break; - case 4: cardString << "Sixes"; - break; - case 3: cardString << "Fives"; - break; - case 2: cardString << "Fours"; - break; - case 1: cardString << "Threes"; - break; - case 0: cardString << "Deuces"; - break; - default: cardString << "ERROR"; - } - //Kicker - switch(fourthPart) { - case 12: cardString << "Ace"; - break; - case 11: cardString << "King"; - break; - case 10: cardString << "Queen"; - break; - case 9: cardString << "Jack"; - break; - case 8: cardString << "Ten"; - break; - case 7: cardString << "Nine"; - break; - case 6: cardString << "Eight"; - break; - case 5: cardString << "Seven"; - break; - case 4: cardString << "Six"; - break; - case 3: cardString << "Five"; - break; - case 2: cardString << "Four"; - break; - case 1: cardString << "Three"; - break; - case 0: cardString << "Deuce"; - break; - default: cardString << "ERROR"; - } + // Kicker 1 + switch(thirdPart) { + case 12: + cardString << "Ace"; + break; + case 11: + cardString << "King"; + break; + case 10: + cardString << "Queen"; + break; + case 9: + cardString << "Jack"; + break; + case 8: + cardString << "Ten"; + break; + case 7: + cardString << "Nine"; + break; + case 6: + cardString << "Eight"; + break; + case 5: + cardString << "Seven"; + break; + case 4: + cardString << "Six"; + break; + case 3: + cardString << "Five"; + break; + case 2: + cardString << "Four"; + break; + case 1: + cardString << "Three"; + break; + case 0: + cardString << "Deuce"; + break; + default: + cardString << "ERROR"; } - break; - // One Pair - case 1: { - cardString << "One Pair, "; - // Pair - switch(secondPart) { - case 12: cardString << "Aces"; - break; - case 11: cardString << "Kings"; - break; - case 10: cardString << "Queens"; - break; - case 9: cardString << "Jacks"; - break; - case 8: cardString << "Tens"; - break; - case 7: cardString << "Nines"; - break; - case 6: cardString << "Eights"; - break; - case 5: cardString << "Sevens"; - break; - case 4: cardString << "Sixes"; - break; - case 3: cardString << "Fives"; - break; - case 2: cardString << "Fours"; - break; - case 1: cardString << "Threes"; - break; - case 0: cardString << "Deuces"; - break; - default: cardString << "ERROR"; - } - // Kicker 1 - switch(thirdPart) { - case 12: cardString << "Ace"; - break; - case 11: cardString << "King"; - break; - case 10: cardString << "Queen"; - break; - case 9: cardString << "Jack"; - break; - case 8: cardString << "Ten"; - break; - case 7: cardString << "Nine"; - break; - case 6: cardString << "Eight"; - break; - case 5: cardString << "Seven"; - break; - case 4: cardString << "Six"; - break; - case 3: cardString << "Five"; - break; - case 2: cardString << "Four"; - break; - case 1: cardString << "Three"; - break; - case 0: cardString << "Deuce"; - break; - default: cardString << "ERROR"; - } - //Kicker 2 - switch(fourthPart) { - case 12: cardString << "Ace"; - break; - case 11: cardString << "King"; - break; - case 10: cardString << "Queen"; - break; - case 9: cardString << "Jack"; - break; - case 8: cardString << "Ten"; - break; - case 7: cardString << "Nine"; - break; - case 6: cardString << "Eight"; - break; - case 5: cardString << "Seven"; - break; - case 4: cardString << "Six"; - break; - case 3: cardString << "Five"; - break; - case 2: cardString << "Four"; - break; - case 1: cardString << "Three"; - break; - case 0: cardString << "Deuce"; - break; - default: cardString << "ERROR"; - } - //Kicker 3 - switch(fifthPart) { - case 12: cardString << "Ace"; - break; - case 11: cardString << "King"; - break; - case 10: cardString << "Queen"; - break; - case 9: cardString << "Jack"; - break; - case 8: cardString << "Ten"; - break; - case 7: cardString << "Nine"; - break; - case 6: cardString << "Eight"; - break; - case 5: cardString << "Seven"; - break; - case 4: cardString << "Six"; - break; - case 3: cardString << "Five"; - break; - case 2: cardString << "Four"; - break; - case 1: cardString << "Three"; - break; - case 0: cardString << "Deuce"; - break; - default: cardString << "ERROR"; - } + //Kicker 2 + switch(fourthPart) { + case 12: + cardString << "Ace"; + break; + case 11: + cardString << "King"; + break; + case 10: + cardString << "Queen"; + break; + case 9: + cardString << "Jack"; + break; + case 8: + cardString << "Ten"; + break; + case 7: + cardString << "Nine"; + break; + case 6: + cardString << "Eight"; + break; + case 5: + cardString << "Seven"; + break; + case 4: + cardString << "Six"; + break; + case 3: + cardString << "Five"; + break; + case 2: + cardString << "Four"; + break; + case 1: + cardString << "Three"; + break; + case 0: + cardString << "Deuce"; + break; + default: + cardString << "ERROR"; } - break; - // Highest Card - case 0: { - cardString << "High Card, "; - // Kicker 1 - switch(secondPart) { - case 12: cardString << "Ace"; - break; - case 11: cardString << "King"; - break; - case 10: cardString << "Queen"; - break; - case 9: cardString << "Jack"; - break; - case 8: cardString << "Ten"; - break; - case 7: cardString << "Nine"; - break; - case 6: cardString << "Eight"; - break; - case 5: cardString << "Seven"; - break; - case 4: cardString << "Six"; - break; - case 3: cardString << "Five"; - break; - case 2: cardString << "Four"; - break; - case 1: cardString << "Three"; - break; - case 0: cardString << "Deuces"; - break; - default: cardString << "ERROR"; - } - // Kicker 2 - switch(thirdPart) { - case 12: cardString << "Ace"; - break; - case 11: cardString << "King"; - break; - case 10: cardString << "Queen"; - break; - case 9: cardString << "Jack"; - break; - case 8: cardString << "Ten"; - break; - case 7: cardString << "Nine"; - break; - case 6: cardString << "Eight"; - break; - case 5: cardString << "Seven"; - break; - case 4: cardString << "Six"; - break; - case 3: cardString << "Five"; - break; - case 2: cardString << "Four"; - break; - case 1: cardString << "Three"; - break; - case 0: cardString << "Deuce"; - break; - default: cardString << "ERROR"; - } - //Kicker 3 - switch(fourthPart) { - case 12: cardString << "Ace"; - break; - case 11: cardString << "King"; - break; - case 10: cardString << "Queen"; - break; - case 9: cardString << "Jack"; - break; - case 8: cardString << "Ten"; - break; - case 7: cardString << "Nine"; - break; - case 6: cardString << "Eight"; - break; - case 5: cardString << "Seven"; - break; - case 4: cardString << "Six"; - break; - case 3: cardString << "Five"; - break; - case 2: cardString << "Four"; - break; - case 1: cardString << "Three"; - break; - case 0: cardString << "Deuce"; - break; - default: cardString << "ERROR"; - } - //Kicker 4 - switch(fifthPartA) { - case 9: cardString << "Jack"; - break; - case 8: cardString << "Ten"; - break; - case 7: cardString << "Nine"; - break; - case 6: cardString << "Eight"; - break; - case 5: cardString << "Seven"; - break; - case 4: cardString << "Six"; - break; - case 3: cardString << "Five"; - break; - case 2: cardString << "Four"; - break; - case 1: cardString << "Three"; - break; - case 0: cardString << "Deuce"; - break; - default: cardString << "ERROR"; - } - //Kicker 5 - switch(fifthPartB) { - case 9: cardString << "Jack"; - break; - case 8: cardString << "Ten"; - break; - case 7: cardString << "Nine"; - break; - case 6: cardString << "Eight"; - break; - case 5: cardString << "Seven"; - break; - case 4: cardString << "Six"; - break; - case 3: cardString << "Five"; - break; - case 2: cardString << "Four"; - break; - case 1: cardString << "Three"; - break; - case 0: cardString << "Deuce"; - break; - default: cardString << "ERROR"; - } + //Kicker 3 + switch(fifthPartA) { + case 9: + cardString << "Jack"; + break; + case 8: + cardString << "Ten"; + break; + case 7: + cardString << "Nine"; + break; + case 6: + cardString << "Eight"; + break; + case 5: + cardString << "Seven"; + break; + case 4: + cardString << "Six"; + break; + case 3: + cardString << "Five"; + break; + case 2: + cardString << "Four"; + break; + case 1: + cardString << "Three"; + break; + case 0: + cardString << "Deuce"; + break; + default: + cardString << "ERROR"; } - break; - default: cardString << "ERROR"; + //Kicker 4 + switch(fifthPartB) { + case 9: + cardString << "Jack"; + break; + case 8: + cardString << "Ten"; + break; + case 7: + cardString << "Nine"; + break; + case 6: + cardString << "Eight"; + break; + case 5: + cardString << "Seven"; + break; + case 4: + cardString << "Six"; + break; + case 3: + cardString << "Five"; + break; + case 2: + cardString << "Four"; + break; + case 1: + cardString << "Three"; + break; + case 0: + cardString << "Deuce"; + break; + default: + cardString << "ERROR"; + } + } + break; + // Straight + case 4: { + cardString << "Straight, "; + switch(secondPart) { + case 12: + cardString << "Ace high"; + break; + case 11: + cardString << "King high"; + break; + case 10: + cardString << "Queen high"; + break; + case 9: + cardString << "Jack high"; + break; + case 8: + cardString << "Ten high"; + break; + case 7: + cardString << "Nine high"; + break; + case 6: + cardString << "Eight high"; + break; + case 5: + cardString << "Seven high"; + break; + case 4: + cardString << "Six high"; + break; + case 3: + cardString << "Five high"; + break; + default: + cardString << "ERROR"; + } + } + break; + // Three of a Kind + case 3: { + cardString << "Three of a Kind, "; + switch(secondPart) { + case 12: + cardString << "Aces"; + break; + case 11: + cardString << "Kings"; + break; + case 10: + cardString << "Queens"; + break; + case 9: + cardString << "Jacks"; + break; + case 8: + cardString << "Tens"; + break; + case 7: + cardString << "Nines"; + break; + case 6: + cardString << "Eights"; + break; + case 5: + cardString << "Sevens"; + break; + case 4: + cardString << "Sixes"; + break; + case 3: + cardString << "Fives"; + break; + case 2: + cardString << "Fours"; + break; + case 1: + cardString << "Threes"; + break; + case 0: + cardString << "Deuces"; + break; + default: + cardString << "ERROR"; + } + //Kicker 1 + switch(thirdPart) { + case 12: + cardString << "Ace"; + break; + case 11: + cardString << "King"; + break; + case 10: + cardString << "Queen"; + break; + case 9: + cardString << "Jack"; + break; + case 8: + cardString << "Ten"; + break; + case 7: + cardString << "Nine"; + break; + case 6: + cardString << "Eight"; + break; + case 5: + cardString << "Seven"; + break; + case 4: + cardString << "Six"; + break; + case 3: + cardString << "Five"; + break; + case 2: + cardString << "Four"; + break; + case 1: + cardString << "Three"; + break; + case 0: + cardString << "Deuce"; + break; + default: + cardString << "ERROR"; + } + //Kicker 2 + switch(fourthPart) { + case 12: + cardString << "Ace"; + break; + case 11: + cardString << "King"; + break; + case 10: + cardString << "Queen"; + break; + case 9: + cardString << "Jack"; + break; + case 8: + cardString << "Ten"; + break; + case 7: + cardString << "Nine"; + break; + case 6: + cardString << "Eight"; + break; + case 5: + cardString << "Seven"; + break; + case 4: + cardString << "Six"; + break; + case 3: + cardString << "Five"; + break; + case 2: + cardString << "Four"; + break; + case 1: + cardString << "Three"; + break; + case 0: + cardString << "Deuce"; + break; + default: + cardString << "ERROR"; + } + } + break; + // Two Pairs + case 2: { + cardString << "Two Pairs, "; + // erster Pair + switch(secondPart) { + case 12: + cardString << "Aces and "; + break; + case 11: + cardString << "Kings and "; + break; + case 10: + cardString << "Queens and "; + break; + case 9: + cardString << "Jacks and "; + break; + case 8: + cardString << "Tens and "; + break; + case 7: + cardString << "Nines and "; + break; + case 6: + cardString << "Eights and "; + break; + case 5: + cardString << "Sevens and "; + break; + case 4: + cardString << "Sixes and "; + break; + case 3: + cardString << "Fives and "; + break; + case 2: + cardString << "Fours and "; + break; + case 1: + cardString << "Threes and "; + break; + case 0: + cardString << "Deuces and "; + break; + default: + cardString << "ERROR"; + } + // zweiter Pair + switch(thirdPart) { + case 12: + cardString << "Aces"; + break; + case 11: + cardString << "Kings"; + break; + case 10: + cardString << "Queens"; + break; + case 9: + cardString << "Jacks"; + break; + case 8: + cardString << "Tens"; + break; + case 7: + cardString << "Nines"; + break; + case 6: + cardString << "Eights"; + break; + case 5: + cardString << "Sevens"; + break; + case 4: + cardString << "Sixes"; + break; + case 3: + cardString << "Fives"; + break; + case 2: + cardString << "Fours"; + break; + case 1: + cardString << "Threes"; + break; + case 0: + cardString << "Deuces"; + break; + default: + cardString << "ERROR"; + } + //Kicker + switch(fourthPart) { + case 12: + cardString << "Ace"; + break; + case 11: + cardString << "King"; + break; + case 10: + cardString << "Queen"; + break; + case 9: + cardString << "Jack"; + break; + case 8: + cardString << "Ten"; + break; + case 7: + cardString << "Nine"; + break; + case 6: + cardString << "Eight"; + break; + case 5: + cardString << "Seven"; + break; + case 4: + cardString << "Six"; + break; + case 3: + cardString << "Five"; + break; + case 2: + cardString << "Four"; + break; + case 1: + cardString << "Three"; + break; + case 0: + cardString << "Deuce"; + break; + default: + cardString << "ERROR"; + } + } + break; + // One Pair + case 1: { + cardString << "One Pair, "; + // Pair + switch(secondPart) { + case 12: + cardString << "Aces"; + break; + case 11: + cardString << "Kings"; + break; + case 10: + cardString << "Queens"; + break; + case 9: + cardString << "Jacks"; + break; + case 8: + cardString << "Tens"; + break; + case 7: + cardString << "Nines"; + break; + case 6: + cardString << "Eights"; + break; + case 5: + cardString << "Sevens"; + break; + case 4: + cardString << "Sixes"; + break; + case 3: + cardString << "Fives"; + break; + case 2: + cardString << "Fours"; + break; + case 1: + cardString << "Threes"; + break; + case 0: + cardString << "Deuces"; + break; + default: + cardString << "ERROR"; + } + // Kicker 1 + switch(thirdPart) { + case 12: + cardString << "Ace"; + break; + case 11: + cardString << "King"; + break; + case 10: + cardString << "Queen"; + break; + case 9: + cardString << "Jack"; + break; + case 8: + cardString << "Ten"; + break; + case 7: + cardString << "Nine"; + break; + case 6: + cardString << "Eight"; + break; + case 5: + cardString << "Seven"; + break; + case 4: + cardString << "Six"; + break; + case 3: + cardString << "Five"; + break; + case 2: + cardString << "Four"; + break; + case 1: + cardString << "Three"; + break; + case 0: + cardString << "Deuce"; + break; + default: + cardString << "ERROR"; + } + //Kicker 2 + switch(fourthPart) { + case 12: + cardString << "Ace"; + break; + case 11: + cardString << "King"; + break; + case 10: + cardString << "Queen"; + break; + case 9: + cardString << "Jack"; + break; + case 8: + cardString << "Ten"; + break; + case 7: + cardString << "Nine"; + break; + case 6: + cardString << "Eight"; + break; + case 5: + cardString << "Seven"; + break; + case 4: + cardString << "Six"; + break; + case 3: + cardString << "Five"; + break; + case 2: + cardString << "Four"; + break; + case 1: + cardString << "Three"; + break; + case 0: + cardString << "Deuce"; + break; + default: + cardString << "ERROR"; + } + //Kicker 3 + switch(fifthPart) { + case 12: + cardString << "Ace"; + break; + case 11: + cardString << "King"; + break; + case 10: + cardString << "Queen"; + break; + case 9: + cardString << "Jack"; + break; + case 8: + cardString << "Ten"; + break; + case 7: + cardString << "Nine"; + break; + case 6: + cardString << "Eight"; + break; + case 5: + cardString << "Seven"; + break; + case 4: + cardString << "Six"; + break; + case 3: + cardString << "Five"; + break; + case 2: + cardString << "Four"; + break; + case 1: + cardString << "Three"; + break; + case 0: + cardString << "Deuce"; + break; + default: + cardString << "ERROR"; + } + } + break; + // Highest Card + case 0: { + cardString << "High Card, "; + // Kicker 1 + switch(secondPart) { + case 12: + cardString << "Ace"; + break; + case 11: + cardString << "King"; + break; + case 10: + cardString << "Queen"; + break; + case 9: + cardString << "Jack"; + break; + case 8: + cardString << "Ten"; + break; + case 7: + cardString << "Nine"; + break; + case 6: + cardString << "Eight"; + break; + case 5: + cardString << "Seven"; + break; + case 4: + cardString << "Six"; + break; + case 3: + cardString << "Five"; + break; + case 2: + cardString << "Four"; + break; + case 1: + cardString << "Three"; + break; + case 0: + cardString << "Deuces"; + break; + default: + cardString << "ERROR"; + } + // Kicker 2 + switch(thirdPart) { + case 12: + cardString << "Ace"; + break; + case 11: + cardString << "King"; + break; + case 10: + cardString << "Queen"; + break; + case 9: + cardString << "Jack"; + break; + case 8: + cardString << "Ten"; + break; + case 7: + cardString << "Nine"; + break; + case 6: + cardString << "Eight"; + break; + case 5: + cardString << "Seven"; + break; + case 4: + cardString << "Six"; + break; + case 3: + cardString << "Five"; + break; + case 2: + cardString << "Four"; + break; + case 1: + cardString << "Three"; + break; + case 0: + cardString << "Deuce"; + break; + default: + cardString << "ERROR"; + } + //Kicker 3 + switch(fourthPart) { + case 12: + cardString << "Ace"; + break; + case 11: + cardString << "King"; + break; + case 10: + cardString << "Queen"; + break; + case 9: + cardString << "Jack"; + break; + case 8: + cardString << "Ten"; + break; + case 7: + cardString << "Nine"; + break; + case 6: + cardString << "Eight"; + break; + case 5: + cardString << "Seven"; + break; + case 4: + cardString << "Six"; + break; + case 3: + cardString << "Five"; + break; + case 2: + cardString << "Four"; + break; + case 1: + cardString << "Three"; + break; + case 0: + cardString << "Deuce"; + break; + default: + cardString << "ERROR"; + } + //Kicker 4 + switch(fifthPartA) { + case 9: + cardString << "Jack"; + break; + case 8: + cardString << "Ten"; + break; + case 7: + cardString << "Nine"; + break; + case 6: + cardString << "Eight"; + break; + case 5: + cardString << "Seven"; + break; + case 4: + cardString << "Six"; + break; + case 3: + cardString << "Five"; + break; + case 2: + cardString << "Four"; + break; + case 1: + cardString << "Three"; + break; + case 0: + cardString << "Deuce"; + break; + default: + cardString << "ERROR"; + } + //Kicker 5 + switch(fifthPartB) { + case 9: + cardString << "Jack"; + break; + case 8: + cardString << "Ten"; + break; + case 7: + cardString << "Nine"; + break; + case 6: + cardString << "Eight"; + break; + case 5: + cardString << "Seven"; + break; + case 4: + cardString << "Six"; + break; + case 3: + cardString << "Five"; + break; + case 2: + cardString << "Four"; + break; + case 1: + cardString << "Three"; + break; + case 0: + cardString << "Deuce"; + break; + default: + cardString << "ERROR"; + } + } + break; + default: + cardString << "ERROR"; } @@ -1537,7 +1927,8 @@ QStringList guiLog::translateCardsValueCode(int cardsValueCode) { } -QString guiLog::determineHandName(int myCardsValueInt) { +QString guiLog::determineHandName(int myCardsValueInt) +{ list shownCardsValueInt; list sameHandCardsValueInt; @@ -1545,10 +1936,10 @@ QString guiLog::determineHandName(int myCardsValueInt) { bool equal = false; boost::shared_ptr currentGame = myW->getSession()->getCurrentGame(); PlayerListConstIterator it_c; - PlayerList activePlayerList = currentGame->getActivePlayerList(); + PlayerList activePlayerList = currentGame->getActivePlayerList(); // collect cardsValueInt of all players who will show their cards - for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { + for(it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) { if( (*it_c)->getMyAction() != PLAYER_ACTION_FOLD) { shownCardsValueInt.push_back( (*it_c)->getMyCardsValueInt()); @@ -1568,205 +1959,84 @@ QString guiLog::determineHandName(int myCardsValueInt) { switch(myCardsValueInt/100000000) { // Royal Flush - case 9: { - handName = translateCardsValueCode(myCardsValueInt).at(0); - } - break; - // Straight Flush - case 8: { - handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1); - } - break; - // Four of a kind - case 7: { + case 9: { + handName = translateCardsValueCode(myCardsValueInt).at(0); + } + break; + // Straight Flush + case 8: { + handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1); + } + break; + // Four of a kind + case 7: { - handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1); + handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1); - // same hand detection - for(it = shownCardsValueInt.begin(); it != shownCardsValueInt.end(); ++it) { - if(((*it)/1000000) == (myCardsValueInt/1000000)) { - sameHandCardsValueInt.push_back(*it); - } + // same hand detection + for(it = shownCardsValueInt.begin(); it != shownCardsValueInt.end(); ++it) { + if(((*it)/1000000) == (myCardsValueInt/1000000)) { + sameHandCardsValueInt.push_back(*it); } - - // 1.same hands existing - if(!(sameHandCardsValueInt.empty())) { - // first kicker? - for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { - if(((*it)/10000) == (myCardsValueInt/10000)) { - equal = true; - ++it; - } else { - different = true; - it = sameHandCardsValueInt.erase(it); - } - } - if(different) { - handName += ", fifth card " + translateCardsValueCode(myCardsValueInt).at(2); - } - - } - } - break; - // Full House - case 6: { - handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1)+translateCardsValueCode(myCardsValueInt).at(2); - } - break; - // Flush - case 5: { - handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1); - - // same hand detection - for(it = shownCardsValueInt.begin(); it != shownCardsValueInt.end(); ++it) { - if(((*it)/1000000) == (myCardsValueInt/1000000)) { - sameHandCardsValueInt.push_back(*it); - } - } - - // 1.same hands existing - if(!(sameHandCardsValueInt.empty())) { - // first kicker? - for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { - if(((*it)/10000) == (myCardsValueInt/10000)) { - equal = true; - ++it; - } else { - different = true; - it = sameHandCardsValueInt.erase(it); - } - } - if(different) { - handName += ", second card " + translateCardsValueCode(myCardsValueInt).at(2); - } - // 2.there are still same hands - if(equal) { - different = false; - equal = false; - // second kicker? - for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { - if(((*it)/100) == (myCardsValueInt/100)) { - equal = true; - ++it; - } else { - different = true; - it = sameHandCardsValueInt.erase(it); - } - } - if(different) { - handName += ", third card " + translateCardsValueCode(myCardsValueInt).at(3); - } - // 3.there are still same hands - if(equal) { - different = false; - equal = false; - // third kicker? - for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { - if(((*it)/10) == (myCardsValueInt/10)) { - equal = true; - ++it; - } else { - different = true; - it = sameHandCardsValueInt.erase(it); - } - } - if(different) { - handName += ", fourth card " + translateCardsValueCode(myCardsValueInt).at(4); - } - // 4.there are still same hands - if(equal) { - different = false; - equal = false; - // third kicker? - for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { - if((*it) == myCardsValueInt) { - equal = true; - ++it; - } else { - different = true; - it = sameHandCardsValueInt.erase(it); - } - } - if(different) { - handName += ", fifth card " + translateCardsValueCode(myCardsValueInt).at(5); - } - } - } - } - } - - } - break; - // Straight - case 4: { - handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1); - } - break; - // Three of a kind - case 3: { - handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1); - - // same hand detection - for(it = shownCardsValueInt.begin(); it != shownCardsValueInt.end(); ++it) { - if(((*it)/1000000) == (myCardsValueInt/1000000)) { - sameHandCardsValueInt.push_back(*it); - } - } - - // 1.same hands existing - if(!(sameHandCardsValueInt.empty())) { - // first kicker? - for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { - if(((*it)/10000) == (myCardsValueInt/10000)) { - equal = true; - ++it; - } else { - different = true; - it = sameHandCardsValueInt.erase(it); - } - } - if(different) { - handName += ", fourth card " + translateCardsValueCode(myCardsValueInt).at(2); - } - // 2.there are still same hands - if(equal) { - different = false; - equal = false; - // second kicker? - for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { - if(((*it)/100) == (myCardsValueInt/100)) { - equal = true; - ++it; - } else { - different = true; - it = sameHandCardsValueInt.erase(it); - } - } - if(different) { - handName += ", fifth card " + translateCardsValueCode(myCardsValueInt).at(3); - } - } - } - - } - break; - // Two Pairs - case 2: { - - handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1)+translateCardsValueCode(myCardsValueInt).at(2); - - // same hand detection - for(it = shownCardsValueInt.begin(); it != shownCardsValueInt.end(); ++it) { + // 1.same hands existing + if(!(sameHandCardsValueInt.empty())) { + // first kicker? + for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { if(((*it)/10000) == (myCardsValueInt/10000)) { - sameHandCardsValueInt.push_back(*it); + equal = true; + ++it; + } else { + different = true; + it = sameHandCardsValueInt.erase(it); } } + if(different) { + handName += ", fifth card " + translateCardsValueCode(myCardsValueInt).at(2); + } - // 1.same hands existing - if(!(sameHandCardsValueInt.empty())) { - // first kicker? + } + + } + break; + // Full House + case 6: { + handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1)+translateCardsValueCode(myCardsValueInt).at(2); + } + break; + // Flush + case 5: { + + handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1); + + // same hand detection + for(it = shownCardsValueInt.begin(); it != shownCardsValueInt.end(); ++it) { + if(((*it)/1000000) == (myCardsValueInt/1000000)) { + sameHandCardsValueInt.push_back(*it); + } + } + + // 1.same hands existing + if(!(sameHandCardsValueInt.empty())) { + // first kicker? + for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { + if(((*it)/10000) == (myCardsValueInt/10000)) { + equal = true; + ++it; + } else { + different = true; + it = sameHandCardsValueInt.erase(it); + } + } + if(different) { + handName += ", second card " + translateCardsValueCode(myCardsValueInt).at(2); + } + // 2.there are still same hands + if(equal) { + different = false; + equal = false; + // second kicker? for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { if(((*it)/100) == (myCardsValueInt/100)) { equal = true; @@ -1777,47 +2047,15 @@ QString guiLog::determineHandName(int myCardsValueInt) { } } if(different) { - handName += ", fifth card " + translateCardsValueCode(myCardsValueInt).at(3); + handName += ", third card " + translateCardsValueCode(myCardsValueInt).at(3); } - - } - - } - break; - // Pair - case 1: { - - handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1); - - // same hand detection - for(it = shownCardsValueInt.begin(); it != shownCardsValueInt.end(); ++it) { - if(((*it)/1000000) == (myCardsValueInt/1000000)) { - sameHandCardsValueInt.push_back(*it); - } - } - - // 1.same hands existing - if(!(sameHandCardsValueInt.empty())) { - // first kicker? - for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { - if(((*it)/10000) == (myCardsValueInt/10000)) { - equal = true; - ++it; - } else { - different = true; - it = sameHandCardsValueInt.erase(it); - } - } - if(different) { - handName += ", third card " + translateCardsValueCode(myCardsValueInt).at(2); - } - // 2.there are still same hands + // 3.there are still same hands if(equal) { different = false; equal = false; - // second kicker? + // third kicker? for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { - if(((*it)/100) == (myCardsValueInt/100)) { + if(((*it)/10) == (myCardsValueInt/10)) { equal = true; ++it; } else { @@ -1826,9 +2064,9 @@ QString guiLog::determineHandName(int myCardsValueInt) { } } if(different) { - handName += ", fourth card " + translateCardsValueCode(myCardsValueInt).at(3); + handName += ", fourth card " + translateCardsValueCode(myCardsValueInt).at(4); } - // 3.there are still same hands + // 4.there are still same hands if(equal) { different = false; equal = false; @@ -1843,31 +2081,53 @@ QString guiLog::determineHandName(int myCardsValueInt) { } } if(different) { - handName += ", fifth card " + translateCardsValueCode(myCardsValueInt).at(4); + handName += ", fifth card " + translateCardsValueCode(myCardsValueInt).at(5); } } } } - } - break; - // highestCard - case 0: { - handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1); + } + break; + // Straight + case 4: { + handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1); + } + break; + // Three of a kind + case 3: { + handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1); - // same hand detection - for(it = shownCardsValueInt.begin(); it != shownCardsValueInt.end(); ++it) { - if(((*it)/1000000) == (myCardsValueInt/1000000)) { - sameHandCardsValueInt.push_back(*it); + // same hand detection + for(it = shownCardsValueInt.begin(); it != shownCardsValueInt.end(); ++it) { + if(((*it)/1000000) == (myCardsValueInt/1000000)) { + sameHandCardsValueInt.push_back(*it); + } + } + + // 1.same hands existing + if(!(sameHandCardsValueInt.empty())) { + // first kicker? + for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { + if(((*it)/10000) == (myCardsValueInt/10000)) { + equal = true; + ++it; + } else { + different = true; + it = sameHandCardsValueInt.erase(it); } } - - // 1.same hands existing - if(!(sameHandCardsValueInt.empty())) { - // first kicker? + if(different) { + handName += ", fourth card " + translateCardsValueCode(myCardsValueInt).at(2); + } + // 2.there are still same hands + if(equal) { + different = false; + equal = false; + // second kicker? for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { - if(((*it)/10000) == (myCardsValueInt/10000)) { + if(((*it)/100) == (myCardsValueInt/100)) { equal = true; ++it; } else { @@ -1876,15 +2136,96 @@ QString guiLog::determineHandName(int myCardsValueInt) { } } if(different) { - handName += ", second card " + translateCardsValueCode(myCardsValueInt).at(2); + handName += ", fifth card " + translateCardsValueCode(myCardsValueInt).at(3); } - // 2.there are still same hands + } + } + + } + break; + // Two Pairs + case 2: { + + handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1)+translateCardsValueCode(myCardsValueInt).at(2); + + // same hand detection + for(it = shownCardsValueInt.begin(); it != shownCardsValueInt.end(); ++it) { + if(((*it)/10000) == (myCardsValueInt/10000)) { + sameHandCardsValueInt.push_back(*it); + } + } + + // 1.same hands existing + if(!(sameHandCardsValueInt.empty())) { + // first kicker? + for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { + if(((*it)/100) == (myCardsValueInt/100)) { + equal = true; + ++it; + } else { + different = true; + it = sameHandCardsValueInt.erase(it); + } + } + if(different) { + handName += ", fifth card " + translateCardsValueCode(myCardsValueInt).at(3); + } + + } + + } + break; + // Pair + case 1: { + + handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1); + + // same hand detection + for(it = shownCardsValueInt.begin(); it != shownCardsValueInt.end(); ++it) { + if(((*it)/1000000) == (myCardsValueInt/1000000)) { + sameHandCardsValueInt.push_back(*it); + } + } + + // 1.same hands existing + if(!(sameHandCardsValueInt.empty())) { + // first kicker? + for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { + if(((*it)/10000) == (myCardsValueInt/10000)) { + equal = true; + ++it; + } else { + different = true; + it = sameHandCardsValueInt.erase(it); + } + } + if(different) { + handName += ", third card " + translateCardsValueCode(myCardsValueInt).at(2); + } + // 2.there are still same hands + if(equal) { + different = false; + equal = false; + // second kicker? + for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { + if(((*it)/100) == (myCardsValueInt/100)) { + equal = true; + ++it; + } else { + different = true; + it = sameHandCardsValueInt.erase(it); + } + } + if(different) { + handName += ", fourth card " + translateCardsValueCode(myCardsValueInt).at(3); + } + // 3.there are still same hands if(equal) { different = false; equal = false; - // second kicker? + // third kicker? for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { - if(((*it)/100) == (myCardsValueInt/100)) { + if((*it) == myCardsValueInt) { equal = true; ++it; } else { @@ -1893,15 +2234,82 @@ QString guiLog::determineHandName(int myCardsValueInt) { } } if(different) { - handName += ", third card " + translateCardsValueCode(myCardsValueInt).at(3); + handName += ", fifth card " + translateCardsValueCode(myCardsValueInt).at(4); } - // 3.there are still same hands + } + } + } + + } + break; + // highestCard + case 0: { + + handName = translateCardsValueCode(myCardsValueInt).at(0)+translateCardsValueCode(myCardsValueInt).at(1); + + // same hand detection + for(it = shownCardsValueInt.begin(); it != shownCardsValueInt.end(); ++it) { + if(((*it)/1000000) == (myCardsValueInt/1000000)) { + sameHandCardsValueInt.push_back(*it); + } + } + + // 1.same hands existing + if(!(sameHandCardsValueInt.empty())) { + // first kicker? + for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { + if(((*it)/10000) == (myCardsValueInt/10000)) { + equal = true; + ++it; + } else { + different = true; + it = sameHandCardsValueInt.erase(it); + } + } + if(different) { + handName += ", second card " + translateCardsValueCode(myCardsValueInt).at(2); + } + // 2.there are still same hands + if(equal) { + different = false; + equal = false; + // second kicker? + for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { + if(((*it)/100) == (myCardsValueInt/100)) { + equal = true; + ++it; + } else { + different = true; + it = sameHandCardsValueInt.erase(it); + } + } + if(different) { + handName += ", third card " + translateCardsValueCode(myCardsValueInt).at(3); + } + // 3.there are still same hands + if(equal) { + different = false; + equal = false; + // third kicker? + for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { + if(((*it)/10) == (myCardsValueInt/10)) { + equal = true; + ++it; + } else { + different = true; + it = sameHandCardsValueInt.erase(it); + } + } + if(different) { + handName += ", fourth card " + translateCardsValueCode(myCardsValueInt).at(4); + } + // 4.there are still same hands if(equal) { different = false; equal = false; // third kicker? for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { - if(((*it)/10) == (myCardsValueInt/10)) { + if((*it) == myCardsValueInt) { equal = true; ++it; } else { @@ -1910,72 +2318,61 @@ QString guiLog::determineHandName(int myCardsValueInt) { } } if(different) { - handName += ", fourth card " + translateCardsValueCode(myCardsValueInt).at(4); - } - // 4.there are still same hands - if(equal) { - different = false; - equal = false; - // third kicker? - for(it = sameHandCardsValueInt.begin(); it != sameHandCardsValueInt.end(); ) { - if((*it) == myCardsValueInt) { - equal = true; - ++it; - } else { - different = true; - it = sameHandCardsValueInt.erase(it); - } - } - if(different) { - handName += ", fifth card " + translateCardsValueCode(myCardsValueInt).at(5); - } + handName += ", fifth card " + translateCardsValueCode(myCardsValueInt).at(5); } } } } - } - break; - default: {} + + } + break; + default: + {} } return handName; } -void guiLog::writeLogFileStream(QString streamString) { +void guiLog::writeLogFileStream(QString streamString) +{ - if(myHtmlLogFile) { - if(myHtmlLogFile->open( QIODevice::ReadWrite )) { - QTextStream stream( myHtmlLogFile ); + if(myHtmlLogFile) { + if(myHtmlLogFile->open( QIODevice::ReadWrite )) { + QTextStream stream( myHtmlLogFile ); stream.readAll(); stream << streamString; - myHtmlLogFile->close(); + myHtmlLogFile->close(); + } else { + cout << "Could not open log-file to write log-messages!" << endl; } - else { cout << "Could not open log-file to write log-messages!" << endl; } + } else { + cout << "Could not find log-file to write log-messages!" << endl; } - else { cout << "Could not find log-file to write log-messages!" << endl; } } -void guiLog::flushLogAtHand() { +void guiLog::flushLogAtHand() +{ if(myConfig->readConfigInt("LogOnOff")) { if(myConfig->readConfigInt("LogInterval") < 2) { - // write for log after every action and after every hand + // write for log after every action and after every hand writeLogFileStream(logFileStreamString); logFileStreamString = ""; } } } -void guiLog::flushLogAtGame(int gameID) { +void guiLog::flushLogAtGame(int gameID) +{ - if(myConfig->readConfigInt("LogOnOff")) { - // write for log after every game - if(gameID > lastGameID) { - writeLogFileStream(logFileStreamString); - logFileStreamString = ""; - lastGameID = gameID; - } - } + if(myConfig->readConfigInt("LogOnOff")) { + // write for log after every game + if(gameID > lastGameID) { + writeLogFileStream(logFileStreamString); + logFileStreamString = ""; + lastGameID = gameID; + } + } } diff --git a/src/gui/qt/gametable/log/guilog.h b/src/gui/qt/gametable/log/guilog.h index f40aaecd..93123537 100644 --- a/src/gui/qt/gametable/log/guilog.h +++ b/src/gui/qt/gametable/log/guilog.h @@ -35,22 +35,22 @@ class GameTableStyleReader; class guiLog : public QObject { -Q_OBJECT + Q_OBJECT public: - guiLog(gameTableImpl*, ConfigFile *c); + guiLog(gameTableImpl*, ConfigFile *c); - ~guiLog(); + ~guiLog(); public slots: - 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); void logPlayerSitsOut(QString playerName); void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1); - void logFlipHoleCardsMsg(QString playerName, int playerID, int card1, int card2, int cardsValueInt = -1, QString showHas = "shows"); + void logFlipHoleCardsMsg(QString playerName, int playerID, int card1, int card2, int cardsValueInt = -1, QString showHas = "shows"); void logPlayerLeftMsg(QString playerName, int wasKicked); void logNewGameAdminMsg(QString playerName); void logPlayerWinGame(QString playerName, int gameID); @@ -66,13 +66,13 @@ public: void writeLogFileStream(QString string); signals: - void signalLogPlayerActionMsg(QString playerName, int playerID, int action, int setValue); + void signalLogPlayerActionMsg(QString playerName, int playerID, int action, int setValue); void signalLogNewGameHandMsg(int gameID, int handID); void signalLogNewBlindsSetsMsg(int sbSet, int bbSet, QString sbName, QString bbName); void signalLogPlayerWinsMsg(QString playerName, int pot, bool main); void signalLogPlayerSitsOut(QString playerName); void signalLogDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1); - void signalLogFlipHoleCardsMsg(QString playerName, int playerID, int card1, int card2, int cardsValueInt = -1, QString showHas = "shows"); + void signalLogFlipHoleCardsMsg(QString playerName, int playerID, int card1, int card2, int cardsValueInt = -1, QString showHas = "shows"); void signalLogPlayerLeftMsg(QString playerName, int wasKicked); void signalLogNewGameAdminMsg(QString playerName); void signalLogPlayerWinGame(QString playerName, int gameID); @@ -87,14 +87,14 @@ private: ConfigFile *myConfig; QTextStream stream; QDir *myLogDir; - QFile *myHtmlLogFile; - sqlite3 *mySqliteLogDb; + QFile *myHtmlLogFile; + sqlite3 *mySqliteLogDb; QString logFileStreamString; QString myAppDataPath; GameTableStyleReader *myStyle; -friend class GuiWrapper; + friend class GuiWrapper; }; #endif diff --git a/src/gui/qt/gametable/myactionbutton.cpp b/src/gui/qt/gametable/myactionbutton.cpp index 23de17a2..e2189b98 100644 --- a/src/gui/qt/gametable/myactionbutton.cpp +++ b/src/gui/qt/gametable/myactionbutton.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -15,7 +15,7 @@ using namespace std; MyActionButton::MyActionButton(QGroupBox* parent) - : QPushButton(parent), myStyle(NULL) + : QPushButton(parent), myStyle(NULL) { } @@ -25,23 +25,22 @@ MyActionButton::~MyActionButton() } -void MyActionButton::paintEvent(QPaintEvent * event) { +void MyActionButton::paintEvent(QPaintEvent * event) +{ - QPushButton::paintEvent(event); + QPushButton::paintEvent(event); - QPainter painter(this); - painter.setPen(QColor("#"+myStyle->getFKeyIndicatorColor())); - painter.setOpacity(0.5); - QFont f= painter.font(); - f.setPixelSize(9); - painter.setFont(f); - if(objectName()==("pushButton_AllIn")) { - painter.drawText(6,6,15,15,Qt::AlignLeft,fKeyText); - } - else if(objectName()==("pushButton_showMyCards")){ - painter.drawText(6,6,15,15,Qt::AlignLeft,QString("F5")); - } - else { - painter.drawText(8,15,15,15,Qt::AlignLeft,fKeyText); - } + QPainter painter(this); + painter.setPen(QColor("#"+myStyle->getFKeyIndicatorColor())); + painter.setOpacity(0.5); + QFont f= painter.font(); + f.setPixelSize(9); + painter.setFont(f); + if(objectName()==("pushButton_AllIn")) { + painter.drawText(6,6,15,15,Qt::AlignLeft,fKeyText); + } else if(objectName()==("pushButton_showMyCards")) { + painter.drawText(6,6,15,15,Qt::AlignLeft,QString("F5")); + } else { + painter.drawText(8,15,15,15,Qt::AlignLeft,fKeyText); + } } diff --git a/src/gui/qt/gametable/myactionbutton.h b/src/gui/qt/gametable/myactionbutton.h index a2f22837..f29a0aa5 100644 --- a/src/gui/qt/gametable/myactionbutton.h +++ b/src/gui/qt/gametable/myactionbutton.h @@ -1,7 +1,7 @@ // // C++ Interface: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -20,14 +20,18 @@ class GameTableStyleReader; class MyActionButton : public QPushButton { public: - MyActionButton(QGroupBox*); + MyActionButton(QGroupBox*); - ~MyActionButton(); + ~MyActionButton(); - void paintEvent(QPaintEvent * event); - void setFKeyText ( const QString& theValue ){fKeyText = theValue;} + void paintEvent(QPaintEvent * event); + void setFKeyText ( const QString& theValue ) { + fKeyText = theValue; + } - void setMyStyle ( GameTableStyleReader* theValue ) { myStyle = theValue; } + void setMyStyle ( GameTableStyleReader* theValue ) { + myStyle = theValue; + } private: diff --git a/src/gui/qt/gametable/myavatarlabel.cpp b/src/gui/qt/gametable/myavatarlabel.cpp index e8f2078f..57d6a4a8 100644 --- a/src/gui/qt/gametable/myavatarlabel.cpp +++ b/src/gui/qt/gametable/myavatarlabel.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -22,24 +22,24 @@ using namespace std; MyAvatarLabel::MyAvatarLabel(QGroupBox* parent) - : QLabel(parent), voteRunning(FALSE), transparent(FALSE) + : QLabel(parent), voteRunning(FALSE), transparent(FALSE) { - myContextMenu = new QMenu; - action_EditTip = new QAction(QIcon(), tr("Add/Edit/Remove tooltip"), myContextMenu); - myContextMenu->addAction(action_EditTip); - action_VoteForKick = new QAction(QIcon(":/gfx/list_remove_user.png"), tr("Start vote to kick this player"), myContextMenu); - myContextMenu->addAction(action_VoteForKick); - action_IgnorePlayer = new QAction(QIcon(":/gfx/im-ban-user.png"), tr("Ignore Player"), myContextMenu); - myContextMenu->addAction(action_IgnorePlayer); - action_ReportBadAvatar = new QAction(QIcon(":/gfx/emblem-important.png"), tr("Report inappropriate avatar"), myContextMenu); - myContextMenu->addAction(action_ReportBadAvatar); + myContextMenu = new QMenu; + action_EditTip = new QAction(QIcon(), tr("Add/Edit/Remove tooltip"), myContextMenu); + myContextMenu->addAction(action_EditTip); + action_VoteForKick = new QAction(QIcon(":/gfx/list_remove_user.png"), tr("Start vote to kick this player"), myContextMenu); + myContextMenu->addAction(action_VoteForKick); + action_IgnorePlayer = new QAction(QIcon(":/gfx/im-ban-user.png"), tr("Ignore Player"), myContextMenu); + myContextMenu->addAction(action_IgnorePlayer); + action_ReportBadAvatar = new QAction(QIcon(":/gfx/emblem-important.png"), tr("Report inappropriate avatar"), myContextMenu); + myContextMenu->addAction(action_ReportBadAvatar); - connect( action_VoteForKick, SIGNAL ( triggered() ), this, SLOT ( sendTriggerVoteOnKickSignal() ) ); - connect( action_IgnorePlayer, SIGNAL ( triggered() ), this, SLOT ( putPlayerOnIgnoreList() ) ); - connect( action_ReportBadAvatar, SIGNAL ( triggered() ), this, SLOT ( reportBadAvatar() ) ); - connect( action_EditTip, SIGNAL( triggered() ), this, SLOT ( startEditTip() ) ); + connect( action_VoteForKick, SIGNAL ( triggered() ), this, SLOT ( sendTriggerVoteOnKickSignal() ) ); + connect( action_IgnorePlayer, SIGNAL ( triggered() ), this, SLOT ( putPlayerOnIgnoreList() ) ); + connect( action_ReportBadAvatar, SIGNAL ( triggered() ), this, SLOT ( reportBadAvatar() ) ); + connect( action_EditTip, SIGNAL( triggered() ), this, SLOT ( startEditTip() ) ); } @@ -47,395 +47,377 @@ MyAvatarLabel::~MyAvatarLabel() { } -void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) { +void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) +{ - assert(myW->getSession()->getCurrentGame()); - if (myW->getSession()->isNetworkClientRunning()) { + assert(myW->getSession()->getCurrentGame()); + if (myW->getSession()->isNetworkClientRunning()) { - boost::shared_ptr humanPlayer = myW->getSession()->getCurrentGame()->getSeatsList()->front(); - //only active players are allowed to start a vote - if(humanPlayer->getMyActiveStatus()) { + boost::shared_ptr humanPlayer = myW->getSession()->getCurrentGame()->getSeatsList()->front(); + //only active players are allowed to start a vote + if(humanPlayer->getMyActiveStatus()) { boost::shared_ptr currentGame = myW->getSession()->getCurrentGame(); - PlayerListConstIterator it_c; - int activePlayerCounter=0; - PlayerList seatList = currentGame->getSeatsList(); + PlayerListConstIterator it_c; + int activePlayerCounter=0; + PlayerList seatList = currentGame->getSeatsList(); for (it_c=seatList->begin(); it_c!=seatList->end(); ++it_c) { - if((*it_c)->getMyActiveStatus()) activePlayerCounter++; - } - GameInfo info(myW->getSession()->getClientGameInfo(myW->getSession()->getClientCurrentGameId())); - - if(activePlayerCounter > 2 && !voteRunning && info.data.gameType != GAME_TYPE_RANKING && !myW->getGuestMode()) { - setVoteOnKickContextMenuEnabled(TRUE); - } - else { - setVoteOnKickContextMenuEnabled(FALSE); - } - - action_IgnorePlayer->setEnabled(true); - action_EditTip->setEnabled(true); - int j=0; - for (it_c=seatList->begin(); it_c!=seatList->end(); ++it_c) { - - if(myId == j) { - if(j == 0) - { - action_EditTip->setDisabled(true); + if((*it_c)->getMyActiveStatus()) activePlayerCounter++; } - if(myW->myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK) - { - action_EditTip->setDisabled(true); + GameInfo info(myW->getSession()->getClientGameInfo(myW->getSession()->getClientCurrentGameId())); + + if(activePlayerCounter > 2 && !voteRunning && info.data.gameType != GAME_TYPE_RANKING && !myW->getGuestMode()) { + setVoteOnKickContextMenuEnabled(TRUE); + } else { + setVoteOnKickContextMenuEnabled(FALSE); } - - if(myW->getSession()->getClientPlayerInfo((*it_c)->getMyUniqueID()).isGuest) { - action_IgnorePlayer->setDisabled(true); - action_EditTip->setDisabled(true); - } - if(myW->getSession()->getGameType() == Session::GAME_TYPE_INTERNET && !((*it_c)->getMyAvatar().empty()) ) { - action_ReportBadAvatar->setVisible(TRUE); - } - else { - action_ReportBadAvatar->setVisible(FALSE); - } - } - j++; - } - - int i=0; + action_IgnorePlayer->setEnabled(true); + action_EditTip->setEnabled(true); + int j=0; for (it_c=seatList->begin(); it_c!=seatList->end(); ++it_c) { - //also inactive player which stays on table can be voted to kick - if(myContextMenuEnabled && myId != 0 && myId == i && (*it_c)->getMyType() != PLAYER_TYPE_COMPUTER && ( (*it_c)->getMyActiveStatus() || (*it_c)->getMyStayOnTableStatus() ) ) - showContextMenu(event->globalPos()); + if(myId == j) { + if(j == 0) { + action_EditTip->setDisabled(true); + } + if(myW->myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK) { + action_EditTip->setDisabled(true); + } - i++; - } - } - } + if(myW->getSession()->getClientPlayerInfo((*it_c)->getMyUniqueID()).isGuest) { + action_IgnorePlayer->setDisabled(true); + action_EditTip->setDisabled(true); + } + + if(myW->getSession()->getGameType() == Session::GAME_TYPE_INTERNET && !((*it_c)->getMyAvatar().empty()) ) { + action_ReportBadAvatar->setVisible(TRUE); + } else { + action_ReportBadAvatar->setVisible(FALSE); + } + } + j++; + } + + int i=0; + for (it_c=seatList->begin(); it_c!=seatList->end(); ++it_c) { + + //also inactive player which stays on table can be voted to kick + if(myContextMenuEnabled && myId != 0 && myId == i && (*it_c)->getMyType() != PLAYER_TYPE_COMPUTER && ( (*it_c)->getMyActiveStatus() || (*it_c)->getMyStayOnTableStatus() ) ) + showContextMenu(event->globalPos()); + + i++; + } + } + } } -void MyAvatarLabel::showContextMenu(const QPoint &pos) { +void MyAvatarLabel::showContextMenu(const QPoint &pos) +{ - myContextMenu->popup(pos); + myContextMenu->popup(pos); } void MyAvatarLabel::setPlayerRating(QString playerInfo) { -int found=0; -QStringList playerInfoList=playerInfo.split("\"", QString::KeepEmptyParts, Qt::CaseSensitive), tipInfo; -boost::shared_ptr currentGame = myW->myStartWindow->getSession()->getCurrentGame(); -PlayerListConstIterator it_c; -PlayerList seatsList = currentGame->getSeatsList(); -std::list tipsList = myW->getMyConfig()->readConfigStringList("PlayerTooltips"); -std::list result; -std::string separator="(!#$%)"; -std::list::iterator iterator; -for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) { - tipInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive); - if(tipInfo.at(0)==playerInfoList.at(0)) - { - result.push_back(tipInfo.at(0).toUtf8().constData()+separator+tipInfo.at(1).toUtf8().constData()+separator+playerInfoList.at(1).toUtf8().constData()+separator); - found=1; - } - else - { - result.push_back(tipInfo.at(0).toUtf8().constData()+separator+tipInfo.at(1).toUtf8().constData()+separator+tipInfo.at(2).toUtf8().constData()+separator); - } -} -if(found==0) - { - result.push_back(playerInfoList.at(0).toUtf8().constData()+separator+separator+playerInfoList.at(1).toUtf8().constData()+separator); - } -myW->getMyConfig()->writeConfigStringList("PlayerTooltips", result); -myW->getMyConfig()->writeBuffer(); -refreshStars(); + int found=0; + QStringList playerInfoList=playerInfo.split("\"", QString::KeepEmptyParts, Qt::CaseSensitive), tipInfo; + boost::shared_ptr currentGame = myW->myStartWindow->getSession()->getCurrentGame(); + PlayerListConstIterator it_c; + PlayerList seatsList = currentGame->getSeatsList(); + std::list tipsList = myW->getMyConfig()->readConfigStringList("PlayerTooltips"); + std::list result; + std::string separator="(!#$%)"; + std::list::iterator iterator; + for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) { + tipInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive); + if(tipInfo.at(0)==playerInfoList.at(0)) { + result.push_back(tipInfo.at(0).toUtf8().constData()+separator+tipInfo.at(1).toUtf8().constData()+separator+playerInfoList.at(1).toUtf8().constData()+separator); + found=1; + } else { + result.push_back(tipInfo.at(0).toUtf8().constData()+separator+tipInfo.at(1).toUtf8().constData()+separator+tipInfo.at(2).toUtf8().constData()+separator); + } + } + if(found==0) { + result.push_back(playerInfoList.at(0).toUtf8().constData()+separator+separator+playerInfoList.at(1).toUtf8().constData()+separator); + } + myW->getMyConfig()->writeConfigStringList("PlayerTooltips", result); + myW->getMyConfig()->writeBuffer(); + refreshStars(); } -void MyAvatarLabel::startChangePlayerTip(QString playerName) -{ - if(myW->tabWidget_Left->widget(2) == myW->tab_Kick) - { - myW->tabWidget_Left->insertTab(3, myW->tab_editTip, playerName); - myW->tabWidget_Left->setCurrentIndex(3); - } - else - { - myW->tabWidget_Left->insertTab(2, myW->tab_editTip, playerName); - myW->tabWidget_Left->setCurrentIndex(2); - } -myW->textEdit_tipInput->setPlainText(getPlayerTip(playerName)); -} +void MyAvatarLabel::startChangePlayerTip(QString playerName) +{ + if(myW->tabWidget_Left->widget(2) == myW->tab_Kick) { + myW->tabWidget_Left->insertTab(3, myW->tab_editTip, playerName); + myW->tabWidget_Left->setCurrentIndex(3); + } else { + myW->tabWidget_Left->insertTab(2, myW->tab_editTip, playerName); + myW->tabWidget_Left->setCurrentIndex(2); + } + myW->textEdit_tipInput->setPlainText(getPlayerTip(playerName)); +} void MyAvatarLabel::refreshStars() { -boost::shared_ptr curGame = myW->myStartWindow->getSession()->getCurrentGame(); -PlayerListConstIterator it_c; -int seatPlace; -PlayerList seatsList = curGame->getSeatsList(); -for (seatPlace=0,it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c, seatPlace++) { - for(int i=1;i<=5;i++)myW->playerStarsArray[i][seatPlace]->setText(""); - if(myW->myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET && !myW->getSession()->getClientPlayerInfo((*it_c)->getMyUniqueID()).isGuest && (*it_c)->getMyType() != PLAYER_TYPE_COMPUTER) - if((*it_c)->getMyStayOnTableStatus() == TRUE && (*it_c)->getMyName()!="" && seatPlace!=0) { - int playerStars=getPlayerRating(QString::fromUtf8((*it_c)->getMyName().c_str())); - for(int i=1;i<=5;i++) - { - myW->playerStarsArray[i][seatPlace]->setText(""); - } - for(int i=1;i<=playerStars;i++) - { - myW->playerStarsArray[i][seatPlace]->setText(""); - } + boost::shared_ptr curGame = myW->myStartWindow->getSession()->getCurrentGame(); + PlayerListConstIterator it_c; + int seatPlace; + PlayerList seatsList = curGame->getSeatsList(); + for (seatPlace=0,it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c, seatPlace++) { + for(int i=1; i<=5; i++)myW->playerStarsArray[i][seatPlace]->setText(""); + if(myW->myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET && !myW->getSession()->getClientPlayerInfo((*it_c)->getMyUniqueID()).isGuest && (*it_c)->getMyType() != PLAYER_TYPE_COMPUTER) + if((*it_c)->getMyStayOnTableStatus() == TRUE && (*it_c)->getMyName()!="" && seatPlace!=0) { + int playerStars=getPlayerRating(QString::fromUtf8((*it_c)->getMyName().c_str())); + for(int i=1; i<=5; i++) { + myW->playerStarsArray[i][seatPlace]->setText(""); + } + for(int i=1; i<=playerStars; i++) { + myW->playerStarsArray[i][seatPlace]->setText(""); + } + } } } -} -void MyAvatarLabel::refreshTooltips() { +void MyAvatarLabel::refreshTooltips() +{ boost::shared_ptr currentGame = myW->myStartWindow->getSession()->getCurrentGame(); - PlayerListConstIterator it_c; + PlayerListConstIterator it_c; int seatPlace; - PlayerList seatsList = currentGame->getSeatsList(); - for (seatPlace=0,it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c, seatPlace++) { - if((*it_c)->getMyStayOnTableStatus() == TRUE || (*it_c)->getMyActiveStatus()) { - bool computerPlayer = false; - if((*it_c)->getMyType() == PLAYER_TYPE_COMPUTER) { computerPlayer = true; } - if(!computerPlayer && getPlayerTip(QString::fromUtf8((*it_c)->getMyName().c_str()))!="") - { - myW->playerTipLabelArray[(*it_c)->getMyID()]->setText(QString("getMyName().c_str())+"\'>i"); - myW->playerTipLabelArray[(*it_c)->getMyID()]->setToolTip( getPlayerTip(QString::fromUtf8((*it_c)->getMyName().c_str())) ); - myW->playerAvatarLabelArray[(*it_c)->getMyID()]->setToolTip( getPlayerTip(QString::fromUtf8((*it_c)->getMyName().c_str())) ); - } - else - { - myW->playerTipLabelArray[(*it_c)->getMyID()]->setText(""); - myW->playerTipLabelArray[(*it_c)->getMyID()]->setToolTip(""); - myW->playerAvatarLabelArray[(*it_c)->getMyID()]->setToolTip(""); - } - } - else - { - myW->playerTipLabelArray[(*it_c)->getMyID()]->setText(""); - myW->playerTipLabelArray[(*it_c)->getMyID()]->setToolTip(""); - myW->playerAvatarLabelArray[(*it_c)->getMyID()]->setToolTip(""); + PlayerList seatsList = currentGame->getSeatsList(); + for (seatPlace=0,it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c, seatPlace++) { + if((*it_c)->getMyStayOnTableStatus() == TRUE || (*it_c)->getMyActiveStatus()) { + bool computerPlayer = false; + if((*it_c)->getMyType() == PLAYER_TYPE_COMPUTER) { + computerPlayer = true; + } + if(!computerPlayer && getPlayerTip(QString::fromUtf8((*it_c)->getMyName().c_str()))!="") { + myW->playerTipLabelArray[(*it_c)->getMyID()]->setText(QString("getMyName().c_str())+"\'>i"); + myW->playerTipLabelArray[(*it_c)->getMyID()]->setToolTip( getPlayerTip(QString::fromUtf8((*it_c)->getMyName().c_str())) ); + myW->playerAvatarLabelArray[(*it_c)->getMyID()]->setToolTip( getPlayerTip(QString::fromUtf8((*it_c)->getMyName().c_str())) ); + } else { + myW->playerTipLabelArray[(*it_c)->getMyID()]->setText(""); + myW->playerTipLabelArray[(*it_c)->getMyID()]->setToolTip(""); + myW->playerAvatarLabelArray[(*it_c)->getMyID()]->setToolTip(""); + } + } else { + myW->playerTipLabelArray[(*it_c)->getMyID()]->setText(""); + myW->playerTipLabelArray[(*it_c)->getMyID()]->setToolTip(""); + myW->playerAvatarLabelArray[(*it_c)->getMyID()]->setToolTip(""); - } + } - } -refreshStars(); + } + refreshStars(); } int MyAvatarLabel::getPlayerRating(QString playerName) { -std::list tipsList = myW->getMyConfig()->readConfigStringList("PlayerTooltips"); -std::list::iterator iterator; -QStringList playerInfo; -QString result="0"; -for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) { - playerInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive); - if(playerInfo.at(0)==playerName) - { - result=playerInfo.at(2); - break; + std::list tipsList = myW->getMyConfig()->readConfigStringList("PlayerTooltips"); + std::list::iterator iterator; + QStringList playerInfo; + QString result="0"; + for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) { + playerInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive); + if(playerInfo.at(0)==playerName) { + result=playerInfo.at(2); + break; } - } -return result.toInt(); + } + return result.toInt(); } QString MyAvatarLabel::getPlayerTip(QString playerName) { -std::list tipsList = myW->getMyConfig()->readConfigStringList("PlayerTooltips"); -std::list::iterator iterator; -QStringList playerInfo; -for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) { - playerInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive); - if(playerInfo.at(0)==playerName)return playerInfo.at(1); - } -return QString(""); + std::list tipsList = myW->getMyConfig()->readConfigStringList("PlayerTooltips"); + std::list::iterator iterator; + QStringList playerInfo; + for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) { + playerInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive); + if(playerInfo.at(0)==playerName)return playerInfo.at(1); + } + return QString(""); } void MyAvatarLabel::setPlayerTip() { -int found=0; -std::string rating="1", separator="(!#$%)"; -std::string tip = std::string((const char*)myW->textEdit_tipInput->toPlainText().toUtf8()); -std::string playerName; -if(myW->tabWidget_Left->widget(2) == myW->tab_editTip)playerName = myW->tabWidget_Left->tabText(2).toUtf8().constData(); -if(myW->tabWidget_Left->widget(3) == myW->tab_editTip)playerName = myW->tabWidget_Left->tabText(3).toUtf8().constData(); -QStringList playerInfo; -std::list tipsList = myW->getMyConfig()->readConfigStringList("PlayerTooltips"); -std::list result; -std::list::iterator iterator; -for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) { - playerInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive); - if(QString::fromUtf8(playerName.c_str())==playerInfo.at(0)) - { - result.push_back(playerName+separator+QString::fromUtf8(tip.c_str()).toUtf8().constData()+separator+playerInfo.at(2).toStdString()+separator); - found=1; - } - else - { - result.push_back(playerInfo.at(0).toUtf8().constData()+separator+playerInfo.at(1).toUtf8().constData()+separator+playerInfo.at(2).toStdString()+separator); - } -} -if(found==0) - { - result.push_back(playerName.c_str()+separator+QString::fromUtf8(tip.c_str()).toUtf8().constData()+separator+QString("0").toStdString()+separator); - } -myW->getMyConfig()->writeConfigStringList("PlayerTooltips", result); -myW->getMyConfig()->writeBuffer(); + int found=0; + std::string rating="1", separator="(!#$%)"; + std::string tip = std::string((const char*)myW->textEdit_tipInput->toPlainText().toUtf8()); + std::string playerName; + if(myW->tabWidget_Left->widget(2) == myW->tab_editTip)playerName = myW->tabWidget_Left->tabText(2).toUtf8().constData(); + if(myW->tabWidget_Left->widget(3) == myW->tab_editTip)playerName = myW->tabWidget_Left->tabText(3).toUtf8().constData(); + QStringList playerInfo; + std::list tipsList = myW->getMyConfig()->readConfigStringList("PlayerTooltips"); + std::list result; + std::list::iterator iterator; + for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) { + playerInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive); + if(QString::fromUtf8(playerName.c_str())==playerInfo.at(0)) { + result.push_back(playerName+separator+QString::fromUtf8(tip.c_str()).toUtf8().constData()+separator+playerInfo.at(2).toStdString()+separator); + found=1; + } else { + result.push_back(playerInfo.at(0).toUtf8().constData()+separator+playerInfo.at(1).toUtf8().constData()+separator+playerInfo.at(2).toStdString()+separator); + } + } + if(found==0) { + result.push_back(playerName.c_str()+separator+QString::fromUtf8(tip.c_str()).toUtf8().constData()+separator+QString("0").toStdString()+separator); + } + myW->getMyConfig()->writeConfigStringList("PlayerTooltips", result); + myW->getMyConfig()->writeBuffer(); -if(myW->tabWidget_Left->widget(3) == myW->tab_editTip) - { - myW->tabWidget_Left->removeTab(3); - } - else if(myW->tabWidget_Left->widget(2) == myW->tab_editTip) - { - myW->tabWidget_Left->removeTab(2); - } -refreshTooltips(); + if(myW->tabWidget_Left->widget(3) == myW->tab_editTip) { + myW->tabWidget_Left->removeTab(3); + } else if(myW->tabWidget_Left->widget(2) == myW->tab_editTip) { + myW->tabWidget_Left->removeTab(2); + } + refreshTooltips(); } void MyAvatarLabel::sendTriggerVoteOnKickSignal() { - myW->triggerVoteOnKick(myId); + myW->triggerVoteOnKick(myId); } void MyAvatarLabel::setEnabledContextMenu(bool b) { - myContextMenuEnabled = b; + myContextMenuEnabled = b; } void MyAvatarLabel::setVoteOnKickContextMenuEnabled(bool b) { - action_VoteForKick->setEnabled(b); + action_VoteForKick->setEnabled(b); } -void MyAvatarLabel::setPixmap ( const QPixmap &pix, const bool trans) { +void MyAvatarLabel::setPixmap ( const QPixmap &pix, const bool trans) +{ - myPixmap = pix.scaled(50,50, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - transparent = trans; - update(); + myPixmap = pix.scaled(50,50, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + transparent = trans; + update(); } -void MyAvatarLabel::setPixmapAndCountry ( const QPixmap &pix,QString countryString, int seatPlace, const bool trans) { - - QPixmap resultAvatar(pix.scaled(50,50, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - QPainter painter(&resultAvatar); - int showCountryFlags = myW->getMyConfig()->readConfigInt("ShowCountryFlagInAvatar"); - if(showCountryFlags && !countryString.isEmpty()) - { - if(seatPlace<=2||seatPlace>=8) - { - painter.drawPixmap(resultAvatar.width()-(QPixmap(countryString)).width(),resultAvatar.height()-(QPixmap(countryString)).height(),QPixmap(countryString)); - } - else - { - painter.drawPixmap(resultAvatar.width()-(QPixmap(countryString)).width(),0,QPixmap(countryString)); +void MyAvatarLabel::setPixmapAndCountry ( const QPixmap &pix,QString countryString, int seatPlace, const bool trans) +{ + + QPixmap resultAvatar(pix.scaled(50,50, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + QPainter painter(&resultAvatar); + int showCountryFlags = myW->getMyConfig()->readConfigInt("ShowCountryFlagInAvatar"); + if(showCountryFlags && !countryString.isEmpty()) { + if(seatPlace<=2||seatPlace>=8) { + painter.drawPixmap(resultAvatar.width()-(QPixmap(countryString)).width(),resultAvatar.height()-(QPixmap(countryString)).height(),QPixmap(countryString)); + } else { + painter.drawPixmap(resultAvatar.width()-(QPixmap(countryString)).width(),0,QPixmap(countryString)); + } } - } - painter.end(); - myPixmap = resultAvatar; - transparent = trans; - update(); + painter.end(); + myPixmap = resultAvatar; + transparent = trans; + update(); } -void MyAvatarLabel::paintEvent(QPaintEvent*) { +void MyAvatarLabel::paintEvent(QPaintEvent*) +{ - QPainter painter(this); - if(transparent) - painter.setOpacity(0.4); - else - painter.setOpacity(1.0); + QPainter painter(this); + if(transparent) + painter.setOpacity(0.4); + else + painter.setOpacity(1.0); - painter.drawPixmap(0,0,myPixmap); + painter.drawPixmap(0,0,myPixmap); } -bool MyAvatarLabel::playerIsOnIgnoreList(QString playerName) { +bool MyAvatarLabel::playerIsOnIgnoreList(QString playerName) +{ - list playerIgnoreList = myW->getMyConfig()->readConfigStringList("PlayerIgnoreList"); - list::iterator it1; + list playerIgnoreList = myW->getMyConfig()->readConfigStringList("PlayerIgnoreList"); + list::iterator it1; for(it1= playerIgnoreList.begin(); it1 != playerIgnoreList.end(); ++it1) { - if(playerName == QString::fromUtf8(it1->c_str())) { - return true; - } - } - return false; + if(playerName == QString::fromUtf8(it1->c_str())) { + return true; + } + } + return false; } -void MyAvatarLabel::putPlayerOnIgnoreList() { +void MyAvatarLabel::putPlayerOnIgnoreList() +{ - QStringList list; - PlayerListConstIterator it_c; - PlayerList seatList = myW->getSession()->getCurrentGame()->getSeatsList(); + QStringList list; + PlayerListConstIterator it_c; + PlayerList seatList = myW->getSession()->getCurrentGame()->getSeatsList(); for (it_c=seatList->begin(); it_c!=seatList->end(); ++it_c) { - list << QString::fromUtf8((*it_c)->getMyName().c_str()); - } + list << QString::fromUtf8((*it_c)->getMyName().c_str()); + } - if(!playerIsOnIgnoreList(list.at(myId))) { + if(!playerIsOnIgnoreList(list.at(myId))) { - myMessageDialogImpl dialog(myW->getMyConfig(), this); - if(dialog.exec(4, tr("You will no longer receive chat messages or game invitations from this user.
Do you really want to put player %1 on ignore list?").arg(list.at(myId)), tr("PokerTH - Question"), QPixmap(":/gfx/im-ban-user_64.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, false ) == QDialog::Accepted) { + myMessageDialogImpl dialog(myW->getMyConfig(), this); + if(dialog.exec(4, tr("You will no longer receive chat messages or game invitations from this user.
Do you really want to put player %1 on ignore list?").arg(list.at(myId)), tr("PokerTH - Question"), QPixmap(":/gfx/im-ban-user_64.png"), QDialogButtonBox::Yes|QDialogButtonBox::No, false ) == QDialog::Accepted) { - std::list playerIgnoreList = myW->getMyConfig()->readConfigStringList("PlayerIgnoreList"); - playerIgnoreList.push_back(list.at(myId).toUtf8().constData()); - myW->getMyConfig()->writeConfigStringList("PlayerIgnoreList", playerIgnoreList); - myW->getMyConfig()->writeBuffer(); + std::list playerIgnoreList = myW->getMyConfig()->readConfigStringList("PlayerIgnoreList"); + playerIgnoreList.push_back(list.at(myId).toUtf8().constData()); + myW->getMyConfig()->writeConfigStringList("PlayerIgnoreList", playerIgnoreList); + myW->getMyConfig()->writeBuffer(); - myW->getMyChat()->refreshIgnoreList(); - } - } -} - -void MyAvatarLabel::reportBadAvatar() { - - boost::shared_ptr currentGame = myW->getSession()->getCurrentGame(); - int j=0; - PlayerListConstIterator it_c; - PlayerList seatList = currentGame->getSeatsList(); - for (it_c=seatList->begin(); it_c!=seatList->end(); ++it_c) { - - if(myId == j) { - - QString avatar = QString::fromUtf8((*it_c)->getMyAvatar().c_str()); - if(!avatar.isEmpty()) { - - QString nick = QString::fromUtf8((*it_c)->getMyName().c_str()); - int ret = QMessageBox::question(this, tr("PokerTH - Question"), - tr("Are you sure you want to report the avatar of \"%1\" as inappropriate?").arg(nick), QMessageBox::Yes | QMessageBox::No); - - if(ret == QMessageBox::Yes) { - QFileInfo fi(avatar); - myW->getSession()->reportBadAvatar((*it_c)->getMyUniqueID(), fi.baseName().toStdString()); - } - } - break; - } - j++; - } -} - - -void MyAvatarLabel::startEditTip() { - boost::shared_ptr currentGame = myW->getSession()->getCurrentGame(); - int j=0; - PlayerListConstIterator it_c; - PlayerList seatList = currentGame->getSeatsList(); - for (it_c=seatList->begin(); it_c!=seatList->end(); ++it_c) { - if(myId == j) { - QString nick = QString::fromUtf8((*it_c)->getMyName().c_str()); - startChangePlayerTip(nick); - break; + myW->getMyChat()->refreshIgnoreList(); } - j++; + } +} + +void MyAvatarLabel::reportBadAvatar() +{ + + boost::shared_ptr currentGame = myW->getSession()->getCurrentGame(); + int j=0; + PlayerListConstIterator it_c; + PlayerList seatList = currentGame->getSeatsList(); + for (it_c=seatList->begin(); it_c!=seatList->end(); ++it_c) { + + if(myId == j) { + + QString avatar = QString::fromUtf8((*it_c)->getMyAvatar().c_str()); + if(!avatar.isEmpty()) { + + QString nick = QString::fromUtf8((*it_c)->getMyName().c_str()); + int ret = QMessageBox::question(this, tr("PokerTH - Question"), + tr("Are you sure you want to report the avatar of \"%1\" as inappropriate?").arg(nick), QMessageBox::Yes | QMessageBox::No); + + if(ret == QMessageBox::Yes) { + QFileInfo fi(avatar); + myW->getSession()->reportBadAvatar((*it_c)->getMyUniqueID(), fi.baseName().toStdString()); + } + } + break; + } + j++; + } +} + + +void MyAvatarLabel::startEditTip() +{ + boost::shared_ptr currentGame = myW->getSession()->getCurrentGame(); + int j=0; + PlayerListConstIterator it_c; + PlayerList seatList = currentGame->getSeatsList(); + for (it_c=seatList->begin(); it_c!=seatList->end(); ++it_c) { + if(myId == j) { + QString nick = QString::fromUtf8((*it_c)->getMyName().c_str()); + startChangePlayerTip(nick); + break; + } + j++; } } diff --git a/src/gui/qt/gametable/myavatarlabel.h b/src/gui/qt/gametable/myavatarlabel.h index 643d7170..d1f36f66 100644 --- a/src/gui/qt/gametable/myavatarlabel.h +++ b/src/gui/qt/gametable/myavatarlabel.h @@ -1,7 +1,7 @@ // // C++ Interface: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -22,53 +22,61 @@ class startWindowImpl; class MyAvatarLabel : public QLabel { -Q_OBJECT + Q_OBJECT public: - MyAvatarLabel(QGroupBox*); - ~MyAvatarLabel(); + MyAvatarLabel(QGroupBox*); + ~MyAvatarLabel(); - void setMyW(gameTableImpl* theValue) { myW = theValue; } - void setMyId ( int theValue ) { myId = theValue; } + void setMyW(gameTableImpl* theValue) { + myW = theValue; + } + void setMyId ( int theValue ) { + myId = theValue; + } void contextMenuEvent ( QContextMenuEvent * event ); QString getPlayerTip(QString); int getPlayerRating(QString); public slots: - + void showContextMenu(const QPoint &pos); - void sendTriggerVoteOnKickSignal(); + void sendTriggerVoteOnKickSignal(); void setEnabledContextMenu(bool); void setVoteOnKickContextMenuEnabled(bool); - void setVoteRunning ( bool theValue ) { voteRunning = theValue; } - void setPixmap ( const QPixmap &, const bool = FALSE); + void setVoteRunning ( bool theValue ) { + voteRunning = theValue; + } + void setPixmap ( const QPixmap &, const bool = FALSE); void setPixmapAndCountry ( const QPixmap &, QString country, int seatPlace, const bool = FALSE); - void setPixmapPath ( const QString theValue) { myPath = theValue; } - void paintEvent(QPaintEvent*); - void putPlayerOnIgnoreList(); - bool playerIsOnIgnoreList(QString playerName); - void reportBadAvatar(); + void setPixmapPath ( const QString theValue) { + myPath = theValue; + } + void paintEvent(QPaintEvent*); + void putPlayerOnIgnoreList(); + bool playerIsOnIgnoreList(QString playerName); + void reportBadAvatar(); void startEditTip(); void startChangePlayerTip(QString playerName); void setPlayerTip(); void setPlayerRating(QString); void refreshTooltips(); void refreshStars(); -private: +private: gameTableImpl *myW; QMenu *myContextMenu; QAction *action_VoteForKick; - QAction *action_IgnorePlayer; - QAction *action_ReportBadAvatar; + QAction *action_IgnorePlayer; + QAction *action_ReportBadAvatar; QAction *action_EditTip; - QPixmap myPixmap; - QString myPath; + QPixmap myPixmap; + QString myPath; int myId; - bool myContextMenuEnabled; + bool myContextMenuEnabled; bool voteRunning; - bool transparent; + bool transparent; }; #endif diff --git a/src/gui/qt/gametable/mycardspixmaplabel.cpp b/src/gui/qt/gametable/mycardspixmaplabel.cpp index 6556e755..cb112537 100755 --- a/src/gui/qt/gametable/mycardspixmaplabel.cpp +++ b/src/gui/qt/gametable/mycardspixmaplabel.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -14,7 +14,7 @@ // using namespace std; MyCardsPixmapLabel::MyCardsPixmapLabel(QGroupBox* parent) - : QLabel(parent), myW(NULL) + : QLabel(parent), myW(NULL) { this->setMouseTracking(TRUE); @@ -23,13 +23,13 @@ MyCardsPixmapLabel::MyCardsPixmapLabel(QGroupBox* parent) flipCardsAction1 = FALSE; flipCardsAction2 = FALSE; - mousePress = FALSE; + mousePress = FALSE; fastFlipCardsFront = FALSE; - + // rotationIntervall = 0.03; - + isFlipside = FALSE; - + fadeOutTimer = new QTimer; connect(fadeOutTimer, SIGNAL(timeout()), this, SLOT(nextFadeOutFrame())); flipCardsTimer = new QTimer; @@ -43,52 +43,61 @@ MyCardsPixmapLabel::~MyCardsPixmapLabel() { } -void MyCardsPixmapLabel::startFadeOut(int speed) { - +void MyCardsPixmapLabel::startFadeOut(int speed) +{ + frameOpacity = 1.0; - if(speed <= 4) { opacityRaiseInterval = 0.01; } - if(speed > 4 && speed <= 7) { opacityRaiseInterval = 0.02; } - if(speed > 7 && speed <= 10) { opacityRaiseInterval = 0.04; } + if(speed <= 4) { + opacityRaiseInterval = 0.01; + } + if(speed > 4 && speed <= 7) { + opacityRaiseInterval = 0.02; + } + if(speed > 7 && speed <= 10) { + opacityRaiseInterval = 0.04; + } if(speed != 11) { fadeOutAction = TRUE; frameOpacity = 1.0; fadeOutTimer->start(40); - } - + } + } -void MyCardsPixmapLabel::stopFadeOut() { +void MyCardsPixmapLabel::stopFadeOut() +{ - fadeOutTimer->stop(); - fadeOutAction = FALSE; - frameOpacity = 1.0; - update(); + fadeOutTimer->stop(); + fadeOutAction = FALSE; + frameOpacity = 1.0; + update(); } -void MyCardsPixmapLabel::nextFadeOutFrame() { +void MyCardsPixmapLabel::nextFadeOutFrame() +{ if (frameOpacity > 0.25) { frameOpacity -= opacityRaiseInterval; - update(); - } - else { - - fadeOutTimer->stop(); + update(); + } else { + + fadeOutTimer->stop(); // fadeOutAction = FALSE; } } -void MyCardsPixmapLabel::startFlipCards(int speed, const QPixmap &frontPix, const QPixmap &flipsidePix) { - - stopFadeOut(); +void MyCardsPixmapLabel::startFlipCards(int speed, const QPixmap &frontPix, const QPixmap &flipsidePix) +{ + + stopFadeOut(); stopFlipCards = FALSE; - isFlipside = FALSE; + isFlipside = FALSE; QLabel::setPixmap(frontPix); @@ -98,21 +107,30 @@ void MyCardsPixmapLabel::startFlipCards(int speed, const QPixmap &frontPix, cons front = frontPix.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);; flipside = flipsidePix.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);; - if(speed <= 4) { flipCardsScaleIntervall = 0.1; } - if(speed > 4 && speed <= 6) { flipCardsScaleIntervall = 0.20; } - if(speed > 6 && speed <= 8) { flipCardsScaleIntervall = 0.25; } - if(speed > 8 && speed <= 10) { flipCardsScaleIntervall = 0.5; } -// - + if(speed <= 4) { + flipCardsScaleIntervall = 0.1; + } + if(speed > 4 && speed <= 6) { + flipCardsScaleIntervall = 0.20; + } + if(speed > 6 && speed <= 8) { + flipCardsScaleIntervall = 0.25; + } + if(speed > 8 && speed <= 10) { + flipCardsScaleIntervall = 0.5; + } +// + if(speed != 11) { flipCardsAction1 = TRUE; flipCardsTimer->start(40); - } - + } + } -void MyCardsPixmapLabel::stopFlipCardsAnimation() { - +void MyCardsPixmapLabel::stopFlipCardsAnimation() +{ + flipCardsTimer->stop(); flipCardsAction1 = FALSE; flipCardsAction2 = FALSE; @@ -120,46 +138,47 @@ void MyCardsPixmapLabel::stopFlipCardsAnimation() { update(); } -void MyCardsPixmapLabel::nextFlipCardsFrame() { +void MyCardsPixmapLabel::nextFlipCardsFrame() +{ if (frameFlipCardsAction1Size > 0.1 ) { //erst flipside verkleinern frameFlipCardsAction1Size -= flipCardsScaleIntervall; - update(); - } - else { - if(flipCardsAction1) { + update(); + } else { + if(flipCardsAction1) { flipCardsAction1 = FALSE; flipCardsAction2 = TRUE; - } - else { + } else { //dann front vergrößern if (frameFlipCardsAction2Size < 0.9 ) { - + frameFlipCardsAction2Size += flipCardsScaleIntervall; update(); - } - else { + } else { flipCardsAction2 = FALSE; - flipCardsTimer->stop(); + flipCardsTimer->stop(); } } } } -void MyCardsPixmapLabel::setPixmap(const QPixmap &pic, const bool flipsideIs) { - +void MyCardsPixmapLabel::setPixmap(const QPixmap &pic, const bool flipsideIs) +{ + QLabel::setPixmap(pic); isFlipside = flipsideIs; } -void MyCardsPixmapLabel::setHiddenFrontPixmap ( const QPixmap &pic ) { +void MyCardsPixmapLabel::setHiddenFrontPixmap ( const QPixmap &pic ) +{ myHiddenFront = pic.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);; } -void MyCardsPixmapLabel::paintEvent(QPaintEvent * event) { +void MyCardsPixmapLabel::paintEvent(QPaintEvent * event) +{ if (!(flipCardsAction1 || flipCardsAction2 || fadeOutAction)) { QLabel::paintEvent(event); @@ -168,10 +187,10 @@ void MyCardsPixmapLabel::paintEvent(QPaintEvent * event) { if (fadeOutAction && !fastFlipCardsFront) { QPainter painter(this); painter.setOpacity(frameOpacity); - if(isFlipside) - painter.drawPixmap(0,0, flipside); - else - painter.drawPixmap(0,0, front); + if(isFlipside) + painter.drawPixmap(0,0, flipside); + else + painter.drawPixmap(0,0, front); } if (flipCardsAction1) { @@ -182,7 +201,7 @@ void MyCardsPixmapLabel::paintEvent(QPaintEvent * event) { painter2.translate(-center); painter2.drawPixmap(0,0, flipside); } - + if (flipCardsAction2) { QPainter painter3(this); QPointF center(front.width()/2.0, front.height()/2.0); @@ -192,46 +211,48 @@ void MyCardsPixmapLabel::paintEvent(QPaintEvent * event) { painter3.drawPixmap(0,0, front); } - if (fastFlipCardsFront && !flipCardsAction1 && !flipCardsAction2) { + if (fastFlipCardsFront && !flipCardsAction1 && !flipCardsAction2) { if(objectName().contains("pixmapLabel_card0")) { QPainter painter4(this); if(fadeOutAction) { painter4.setOpacity(0.25); } - painter4.drawPixmap(0,0, myHiddenFront); + painter4.drawPixmap(0,0, myHiddenFront); } } } -void MyCardsPixmapLabel::fastFlipCards(bool front){ +void MyCardsPixmapLabel::fastFlipCards(bool front) +{ if (front) { - fastFlipCardsFront = TRUE; + fastFlipCardsFront = TRUE; update(); - } - else { - fastFlipCardsFront = FALSE; + } else { + fastFlipCardsFront = FALSE; update(); } } -void MyCardsPixmapLabel::mousePressEvent(QMouseEvent * event) { +void MyCardsPixmapLabel::mousePressEvent(QMouseEvent * event) +{ if (!mousePress && objectName().contains("pixmapLabel_card0")) { - mousePress = TRUE; - myW->mouseOverFlipCards(TRUE); - + mousePress = TRUE; + myW->mouseOverFlipCards(TRUE); + } -QLabel::mousePressEvent(event); + QLabel::mousePressEvent(event); } -void MyCardsPixmapLabel::mouseReleaseEvent(QMouseEvent * event) { +void MyCardsPixmapLabel::mouseReleaseEvent(QMouseEvent * event) +{ if (mousePress && objectName().contains("pixmapLabel_card0")) { - mousePress = FALSE; + mousePress = FALSE; myW->mouseOverFlipCards(FALSE); - } + } -QLabel::mouseReleaseEvent(event); + QLabel::mouseReleaseEvent(event); } diff --git a/src/gui/qt/gametable/mycardspixmaplabel.h b/src/gui/qt/gametable/mycardspixmaplabel.h index 3d49ac1d..67013f4a 100755 --- a/src/gui/qt/gametable/mycardspixmaplabel.h +++ b/src/gui/qt/gametable/mycardspixmaplabel.h @@ -1,7 +1,7 @@ // // C++ Interface: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -21,26 +21,38 @@ class gameTableImpl; class MyCardsPixmapLabel : public QLabel { -Q_OBJECT + Q_OBJECT public: - MyCardsPixmapLabel(QGroupBox*); + MyCardsPixmapLabel(QGroupBox*); - ~MyCardsPixmapLabel(); + ~MyCardsPixmapLabel(); - void setMyW ( gameTableImpl* theValue ) { myW = theValue; } + void setMyW ( gameTableImpl* theValue ) { + myW = theValue; + } + + void setIsFlipside(bool theValue) { + isFlipside = theValue; + } + bool getIsFlipside() const { + return isFlipside; + } + + void setFadeOutAction(bool theValue) { + fadeOutAction = theValue; + } + bool getFadeOutAction() const { + return fadeOutAction; + } - void setIsFlipside(bool theValue){ isFlipside = theValue;} - bool getIsFlipside() const{ return isFlipside;} - - void setFadeOutAction(bool theValue) { fadeOutAction = theValue; } - bool getFadeOutAction() const { return fadeOutAction;} - void startFadeOut(int); - void stopFadeOut(); + void stopFadeOut(); void startFlipCards(int, const QPixmap & , const QPixmap &); void stopFlipCardsAnimation(); - - void setFlipsidePix(QPixmap p) { flipside = p; } + + void setFlipsidePix(QPixmap p) { + flipside = p; + } void paintEvent(QPaintEvent * event); @@ -49,26 +61,28 @@ signals: public slots: - + void setPixmap ( const QPixmap &, const bool ); void setHiddenFrontPixmap ( const QPixmap &); void nextFadeOutFrame(); void nextFlipCardsFrame(); - + void fastFlipCards(bool front); -// void mouseMoveEvent ( QMouseEvent *); - +// void mouseMoveEvent ( QMouseEvent *); + void mousePressEvent ( QMouseEvent *); void mouseReleaseEvent ( QMouseEvent *); - void setFront ( const QPixmap& theValue ) { front = theValue; } - + void setFront ( const QPixmap& theValue ) { + front = theValue; + } -private: - gameTableImpl* myW; +private: + + gameTableImpl* myW; qreal frameOpacity; qreal opacityRaiseInterval; @@ -78,22 +92,22 @@ private: qreal frameFlipCardsAction2Size; QTimer *fadeOutTimer; - QTimer *flipCardsTimer; + QTimer *flipCardsTimer; bool isFlipside; bool fadeOutAction; bool flipCardsAction1; bool flipCardsAction2; bool stopFlipCards; - - bool mousePress; - bool fastFlipCardsFront; + + bool mousePress; + bool fastFlipCardsFront; QPixmap front; QPixmap flipside; QPixmap myHiddenFront; -friend class gameTableImpl; + friend class gameTableImpl; }; #endif diff --git a/src/gui/qt/gametable/mychancelabel.cpp b/src/gui/qt/gametable/mychancelabel.cpp index a17c2d30..69c6a3bd 100644 --- a/src/gui/qt/gametable/mychancelabel.cpp +++ b/src/gui/qt/gametable/mychancelabel.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -16,29 +16,29 @@ using namespace std; MyChanceLabel::MyChanceLabel(QWidget* parent) - : QLabel(parent), myW(0), myStyle(0) + : QLabel(parent), myW(0), myStyle(0) { - RFChance[0] = 0; - SFChance[0] = 0; - FOAKChance[0] = 0; - FHChance[0] = 0; - FLChance[0] = 0; - STRChance[0] = 0; - TOAKChance[0] = 0; - TPChance[0] = 0; - OPChance[0] = 0; - HCChance[0] = 0; + RFChance[0] = 0; + SFChance[0] = 0; + FOAKChance[0] = 0; + FHChance[0] = 0; + FLChance[0] = 0; + STRChance[0] = 0; + TOAKChance[0] = 0; + TPChance[0] = 0; + OPChance[0] = 0; + HCChance[0] = 0; - RFChance[1] = 0; - SFChance[1] = 0; - FOAKChance[1] = 0; - FHChance[1] = 0; - FLChance[1] = 0; - STRChance[1] = 0; - TOAKChance[1] = 0; - TPChance[1] = 0; - OPChance[1] = 0; - HCChance[1] = 0; + RFChance[1] = 0; + SFChance[1] = 0; + FOAKChance[1] = 0; + FHChance[1] = 0; + FLChance[1] = 0; + STRChance[1] = 0; + TOAKChance[1] = 0; + TPChance[1] = 0; + OPChance[1] = 0; + HCChance[1] = 0; } MyChanceLabel::~MyChanceLabel() @@ -72,19 +72,20 @@ void MyChanceLabel::refreshChance(vector< vector > chance) update(); } -void MyChanceLabel::paintEvent(QPaintEvent * /*event*/) { +void MyChanceLabel::paintEvent(QPaintEvent * /*event*/) +{ QPainter painter(this); #ifdef _WIN32 QString font1String = "font-family: \"Arial\";"; -#else - #ifdef __APPLE__ - QString font1String = "font-family: \"Lucida Grande\";"; - #else - QString font1String = "font-family: \"Nimbus Sans L\";"; - #endif +#else +#ifdef __APPLE__ + QString font1String = "font-family: \"Lucida Grande\";"; +#else + QString font1String = "font-family: \"Nimbus Sans L\";"; +#endif #endif QFont font; font.setFamily(font1String); @@ -95,56 +96,86 @@ void MyChanceLabel::paintEvent(QPaintEvent * /*event*/) { QColor possible("#"+myStyle->getChanceLabelPossibleColor()); QColor impossible("#"+myStyle->getChanceLabelImpossibleColor()); - if(RFChance[1] == 0) { painter.setPen(impossible); } - else { painter.setPen(possible); } + if(RFChance[1] == 0) { + painter.setPen(impossible); + } else { + painter.setPen(possible); + } painter.drawText(QRectF(QPointF(2,0), QPointF(85,13)),Qt::AlignRight,"Royal Flush"); painter.drawText(QRectF(QPointF(196,0), QPointF(236,13)),Qt::AlignRight,QString("%1%").arg(RFChance[0])); - if(SFChance[1] == 0) { painter.setPen(impossible); } - else { painter.setPen(possible); } + if(SFChance[1] == 0) { + painter.setPen(impossible); + } else { + painter.setPen(possible); + } painter.drawText(QRectF(QPointF(2,13), QPointF(85,26)),Qt::AlignRight,"Straight Flush"); painter.drawText(QRectF(QPointF(196,13), QPointF(236,26)),Qt::AlignRight,QString("%1%").arg(SFChance[0])); - if(FOAKChance[1] == 0) { painter.setPen(impossible); } - else { painter.setPen(possible); } + if(FOAKChance[1] == 0) { + painter.setPen(impossible); + } else { + painter.setPen(possible); + } painter.drawText(QRectF(QPointF(2,26), QPointF(85,39)),Qt::AlignRight,"Four of a Kind"); painter.drawText(QRectF(QPointF(196,26), QPointF(236,39)),Qt::AlignRight,QString("%1%").arg(FOAKChance[0])); - if(FHChance[1] == 0) { painter.setPen(impossible); } - else { painter.setPen(possible); } + if(FHChance[1] == 0) { + painter.setPen(impossible); + } else { + painter.setPen(possible); + } painter.drawText(QRectF(QPointF(2,39), QPointF(85,52)),Qt::AlignRight,"Full House"); painter.drawText(QRectF(QPointF(196,39), QPointF(236,52)),Qt::AlignRight,QString("%1%").arg(FHChance[0])); - if(FLChance[1] == 0) { painter.setPen(impossible); } - else { painter.setPen(possible); } + if(FLChance[1] == 0) { + painter.setPen(impossible); + } else { + painter.setPen(possible); + } painter.drawText(QRectF(QPointF(2,52), QPointF(85,65)),Qt::AlignRight,"Flush"); painter.drawText(QRectF(QPointF(196,52), QPointF(236,65)),Qt::AlignRight,QString("%1%").arg(FLChance[0])); - if(STRChance[1] == 0) { painter.setPen(impossible); } - else { painter.setPen(possible); } + if(STRChance[1] == 0) { + painter.setPen(impossible); + } else { + painter.setPen(possible); + } painter.drawText(QRectF(QPointF(2,65), QPointF(85,78)),Qt::AlignRight,"Straight"); painter.drawText(QRectF(QPointF(196,65), QPointF(236,78)),Qt::AlignRight,QString("%1%").arg(STRChance[0])); - if(TOAKChance[1] == 0) { painter.setPen(impossible); } - else { painter.setPen(possible); } + if(TOAKChance[1] == 0) { + painter.setPen(impossible); + } else { + painter.setPen(possible); + } painter.drawText(QRectF(QPointF(2,78), QPointF(85,91)),Qt::AlignRight,"Three of a Kind"); painter.drawText(QRectF(QPointF(196,78), QPointF(236,91)),Qt::AlignRight,QString("%1%").arg(TOAKChance[0])); - if(TPChance[1] == 0) { painter.setPen(impossible); } - else { painter.setPen(possible); } + if(TPChance[1] == 0) { + painter.setPen(impossible); + } else { + painter.setPen(possible); + } painter.drawText(QRectF(QPointF(2,91), QPointF(85,104)),Qt::AlignRight,"Two Pairs"); painter.drawText(QRectF(QPointF(196,91), QPointF(236,104)),Qt::AlignRight,QString("%1%").arg(TPChance[0])); - if(OPChance[1] == 0) { painter.setPen(impossible); } - else { painter.setPen(possible); } + if(OPChance[1] == 0) { + painter.setPen(impossible); + } else { + painter.setPen(possible); + } painter.drawText(QRectF(QPointF(2,104), QPointF(85,117)),Qt::AlignRight,"One Pair"); painter.drawText(QRectF(QPointF(196,104), QPointF(236,117)),Qt::AlignRight,QString("%1%").arg(OPChance[0])); - if(HCChance[1] == 0) { painter.setPen(impossible); } - else { painter.setPen(possible); } + if(HCChance[1] == 0) { + painter.setPen(impossible); + } else { + painter.setPen(possible); + } painter.drawText(QRectF(QPointF(2,117), QPointF(85,130)),Qt::AlignRight,"Highest Card"); painter.drawText(QRectF(QPointF(196,117), QPointF(236,130)),Qt::AlignRight,QString("%1%").arg(HCChance[0])); //Draw gfx painter.setPen(QColor(0,0,0)); - + QLinearGradient linearGrad(QPointF(89,3), QPointF(190,10)); linearGrad.setColorAt(0, Qt::blue); linearGrad.setColorAt(0.5, Qt::yellow); linearGrad.setColorAt(1, Qt::red); painter.setBrush(linearGrad); - + if(RFChance[1] != 0) painter.drawRect(89,3,(108*RFChance[0])/100,7); if(SFChance[1] != 0) painter.drawRect(89,16,(108*SFChance[0])/100,7); if(FOAKChance[1] != 0) painter.drawRect(89,29,(108*FOAKChance[0])/100,7); diff --git a/src/gui/qt/gametable/mychancelabel.h b/src/gui/qt/gametable/mychancelabel.h index 8448d34f..1b0783bb 100644 --- a/src/gui/qt/gametable/mychancelabel.h +++ b/src/gui/qt/gametable/mychancelabel.h @@ -1,7 +1,7 @@ // // C++ Interface: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -22,19 +22,23 @@ class GameTableStyleReader; class MyChanceLabel : public QLabel { -Q_OBJECT + Q_OBJECT public: - MyChanceLabel(QWidget*); + MyChanceLabel(QWidget*); - ~MyChanceLabel(); - - void setMyW ( gameTableImpl* theValue ) { myW = theValue; } - void setMyStyle ( GameTableStyleReader* theValue ) { myStyle = theValue; } + ~MyChanceLabel(); + + void setMyW ( gameTableImpl* theValue ) { + myW = theValue; + } + void setMyStyle ( GameTableStyleReader* theValue ) { + myStyle = theValue; + } void paintEvent(QPaintEvent * event); void refreshChance(std::vector< std::vector >); void resetChance(); - -private: + +private: gameTableImpl *myW; GameTableStyleReader *myStyle; diff --git a/src/gui/qt/gametable/mylefttabwidget.cpp b/src/gui/qt/gametable/mylefttabwidget.cpp index 8fc07a61..aca6bb87 100755 --- a/src/gui/qt/gametable/mylefttabwidget.cpp +++ b/src/gui/qt/gametable/mylefttabwidget.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: MyLeftTabWidget // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -12,7 +12,7 @@ #include "mylefttabwidget.h" MyLeftTabWidget::MyLeftTabWidget(QGroupBox *parent) - : QTabWidget(parent), chatBlinkTimer(0), myTabBar(0) + : QTabWidget(parent), chatBlinkTimer(0), myTabBar(0) { myTabBar = this->tabBar(); @@ -25,19 +25,33 @@ MyLeftTabWidget::~MyLeftTabWidget() { } -void MyLeftTabWidget::startBlinkChatTab() { /*chatBlinkTimer->start(500);*/ } -void MyLeftTabWidget::stopBlinkChatTab() { /*chatBlinkTimer->stop();*/ } -void MyLeftTabWidget::showDefaultChatTab() { /*myTabBar->setTabTextColor(1, QColor(240,240,240));*/ } -void MyLeftTabWidget::disableTab(int tabIndex, bool yesNo) { myTabBar->setTabEnabled(tabIndex, !yesNo); } +void MyLeftTabWidget::startBlinkChatTab() +{ + /*chatBlinkTimer->start(500);*/ +} +void MyLeftTabWidget::stopBlinkChatTab() +{ + /*chatBlinkTimer->stop();*/ +} +void MyLeftTabWidget::showDefaultChatTab() +{ + /*myTabBar->setTabTextColor(1, QColor(240,240,240));*/ +} +void MyLeftTabWidget::disableTab(int tabIndex, bool yesNo) +{ + myTabBar->setTabEnabled(tabIndex, !yesNo); +} -void MyLeftTabWidget::blinkChatTab() { +void MyLeftTabWidget::blinkChatTab() +{ //TODO doesnt work while stylesheet is set :( // if(myTabBar->tabTextColor(1).red() == 240) myTabBar->setTabTextColor(1, QColor(113,162,0)); // else myTabBar->setTabTextColor(1, QColor(240,240,240)); } -void MyLeftTabWidget::paintEvent(QPaintEvent * event) { +void MyLeftTabWidget::paintEvent(QPaintEvent * event) +{ QTabWidget::paintEvent(event); - + } diff --git a/src/gui/qt/gametable/mylefttabwidget.h b/src/gui/qt/gametable/mylefttabwidget.h index 563f2281..1ab47238 100755 --- a/src/gui/qt/gametable/mylefttabwidget.h +++ b/src/gui/qt/gametable/mylefttabwidget.h @@ -1,7 +1,7 @@ // // C++ Interface: MyLeftTabWidget // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -18,11 +18,11 @@ class MyLeftTabWidget : public QTabWidget { -Q_OBJECT + Q_OBJECT public: - MyLeftTabWidget(QGroupBox*); + MyLeftTabWidget(QGroupBox*); - ~MyLeftTabWidget(); + ~MyLeftTabWidget(); void paintEvent(QPaintEvent * event); @@ -32,12 +32,14 @@ public: void disableTab(int tabIndex, bool yesNO); public slots: - + void blinkChatTab(); - QTabBar* getMyTabBar() const { return myTabBar; } + QTabBar* getMyTabBar() const { + return myTabBar; + } -private: +private: QTimer *chatBlinkTimer; QTabBar *myTabBar; diff --git a/src/gui/qt/gametable/mymenubar.cpp b/src/gui/qt/gametable/mymenubar.cpp index e35a4ef3..27dc4b7d 100644 --- a/src/gui/qt/gametable/mymenubar.cpp +++ b/src/gui/qt/gametable/mymenubar.cpp @@ -1,15 +1,16 @@ #include "mymenubar.h" MyMenuBar::MyMenuBar(QMainWindow* parent) - : QMenuBar(parent) + : QMenuBar(parent) { #if (QT_VERSION >= 0x040501) this->setAttribute(Qt::WA_TranslucentBackground); - this->setStyleSheet("QMenuBar { border-width: 0px; border-style: none;} "); -#endif + this->setStyleSheet("QMenuBar { border-width: 0px; border-style: none;} "); +#endif } -void MyMenuBar::paintEvent(QPaintEvent *e) { +void MyMenuBar::paintEvent(QPaintEvent *e) +{ - QMenuBar::paintEvent(e); + QMenuBar::paintEvent(e); } diff --git a/src/gui/qt/gametable/mymenubar.h b/src/gui/qt/gametable/mymenubar.h index ea1b3296..2adfa023 100644 --- a/src/gui/qt/gametable/mymenubar.h +++ b/src/gui/qt/gametable/mymenubar.h @@ -6,11 +6,11 @@ class MyMenuBar : public QMenuBar { -Q_OBJECT + Q_OBJECT public: - MyMenuBar(QMainWindow*); + MyMenuBar(QMainWindow*); - void paintEvent(QPaintEvent * event); + void paintEvent(QPaintEvent * event); }; #endif diff --git a/src/gui/qt/gametable/mynamelabel.cpp b/src/gui/qt/gametable/mynamelabel.cpp index ad7e0af4..8876f7d5 100644 --- a/src/gui/qt/gametable/mynamelabel.cpp +++ b/src/gui/qt/gametable/mynamelabel.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -15,7 +15,7 @@ #include "gametablestylereader.h" MyNameLabel::MyNameLabel(QGroupBox* parent) - : QLabel(parent), myW(0) + : QLabel(parent), myW(0) { } @@ -24,44 +24,43 @@ MyNameLabel::~MyNameLabel() { } -void MyNameLabel::setText ( const QString &t, bool trans, bool guest, bool computerplayer) { +void MyNameLabel::setText ( const QString &t, bool trans, bool guest, bool computerplayer) +{ - QString text; - QColor transColor; - transColor.setNamedColor("#"+myW->getMyGameTableStyle()->getPlayerNickTextColor()); - QString red = QString::number(transColor.red()); - QString green = QString::number(transColor.green()); - QString blue = QString::number(transColor.blue()); + QString text; + QColor transColor; + transColor.setNamedColor("#"+myW->getMyGameTableStyle()->getPlayerNickTextColor()); + QString red = QString::number(transColor.red()); + QString green = QString::number(transColor.green()); + QString blue = QString::number(transColor.blue()); - if(trans) { - this->setStyleSheet("QLabel { "+ myW->getMyGameTableStyle()->getFont2String() +" font-size: "+myW->getMyGameTableStyle()->getPlayerNameLabelFontSize()+"px; font-weight: bold; color: rgba("+red+", "+green+", "+blue+", 80); }"); - } - else { - this->setStyleSheet("QLabel { "+ myW->getMyGameTableStyle()->getFont2String() +" font-size: "+myW->getMyGameTableStyle()->getPlayerNameLabelFontSize()+"px; font-weight: bold; color: #"+myW->getMyGameTableStyle()->getPlayerNickTextColor()+"; }"); - } + if(trans) { + this->setStyleSheet("QLabel { "+ myW->getMyGameTableStyle()->getFont2String() +" font-size: "+myW->getMyGameTableStyle()->getPlayerNameLabelFontSize()+"px; font-weight: bold; color: rgba("+red+", "+green+", "+blue+", 80); }"); + } else { + this->setStyleSheet("QLabel { "+ myW->getMyGameTableStyle()->getFont2String() +" font-size: "+myW->getMyGameTableStyle()->getPlayerNameLabelFontSize()+"px; font-weight: bold; color: #"+myW->getMyGameTableStyle()->getPlayerNickTextColor()+"; }"); + } - if(myW->getSession()) { + if(myW->getSession()) { - if(myW->getSession()->getGameType() == Session::GAME_TYPE_INTERNET && !guest && !computerplayer ) { + if(myW->getSession()->getGameType() == Session::GAME_TYPE_INTERNET && !guest && !computerplayer ) { // for internet game show players name with links to their profile included - this->setTextFormat(Qt::RichText); - QString linkString = QString("http://pokerth.net/redirect_user_profile.php?nick="+QUrl::toPercentEncoding(t)); + this->setTextFormat(Qt::RichText); + QString linkString = QString("http://pokerth.net/redirect_user_profile.php?nick="+QUrl::toPercentEncoding(t)); - if(trans) { - text = ""+t+""; - } - else { - text = ""+t+""; - } + if(trans) { + text = ""+t+""; + } else { + text = ""+t+""; + } - } - else { - this->setTextFormat(Qt::PlainText); - text = t; - } - } - else { text = t; } + } else { + this->setTextFormat(Qt::PlainText); + text = t; + } + } else { + text = t; + } - QLabel::setText(text); + QLabel::setText(text); } diff --git a/src/gui/qt/gametable/mynamelabel.h b/src/gui/qt/gametable/mynamelabel.h index 44b2449a..de85cafd 100644 --- a/src/gui/qt/gametable/mynamelabel.h +++ b/src/gui/qt/gametable/mynamelabel.h @@ -1,7 +1,7 @@ // // C++ Interface: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -21,20 +21,22 @@ class gameTableImpl; class MyNameLabel : public QLabel { -Q_OBJECT + Q_OBJECT public: - MyNameLabel(QGroupBox*); - ~MyNameLabel(); + MyNameLabel(QGroupBox*); + ~MyNameLabel(); - void setMyW(gameTableImpl* theValue) { myW = theValue; } + void setMyW(gameTableImpl* theValue) { + myW = theValue; + } public slots: - void setText ( const QString &, bool = FALSE, bool = FALSE, bool = FALSE); + void setText ( const QString &, bool = FALSE, bool = FALSE, bool = FALSE); private: - QString myText; - gameTableImpl *myW; + QString myText; + gameTableImpl *myW; }; diff --git a/src/gui/qt/gametable/myrighttabwidget.cpp b/src/gui/qt/gametable/myrighttabwidget.cpp index 8ce1dd7c..b436cc24 100755 --- a/src/gui/qt/gametable/myrighttabwidget.cpp +++ b/src/gui/qt/gametable/myrighttabwidget.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: MyRightTabWidget // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -15,7 +15,7 @@ using namespace std; MyRightTabWidget::MyRightTabWidget(QGroupBox *parent) - : QTabWidget(parent), myTabBar(0) + : QTabWidget(parent), myTabBar(0) { myTabBar = this->tabBar(); } @@ -24,10 +24,11 @@ MyRightTabWidget::~MyRightTabWidget() { } -void MyRightTabWidget::paintEvent(QPaintEvent * event) { +void MyRightTabWidget::paintEvent(QPaintEvent * event) +{ QTabWidget::paintEvent(event); - + } diff --git a/src/gui/qt/gametable/myrighttabwidget.h b/src/gui/qt/gametable/myrighttabwidget.h index eed3c505..b549de44 100755 --- a/src/gui/qt/gametable/myrighttabwidget.h +++ b/src/gui/qt/gametable/myrighttabwidget.h @@ -1,7 +1,7 @@ // // C++ Interface: MyRightTabWidget // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -17,22 +17,24 @@ class MyRightTabWidget : public QTabWidget { -Q_OBJECT + Q_OBJECT public: - MyRightTabWidget(QGroupBox*); + MyRightTabWidget(QGroupBox*); - ~MyRightTabWidget(); + ~MyRightTabWidget(); void paintEvent(QPaintEvent * event); - QTabBar* getMyTabBar() const { return myTabBar; } - + QTabBar* getMyTabBar() const { + return myTabBar; + } + public slots: - -private: + +private: QTabBar *myTabBar; }; diff --git a/src/gui/qt/gametable/mysetlabel.cpp b/src/gui/qt/gametable/mysetlabel.cpp index 75e9821b..7ffd0a76 100755 --- a/src/gui/qt/gametable/mysetlabel.cpp +++ b/src/gui/qt/gametable/mysetlabel.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -16,7 +16,7 @@ using namespace std; MySetLabel::MySetLabel(QGroupBox* parent) - : QLabel(parent), myW(0) + : QLabel(parent), myW(0) { } @@ -25,7 +25,8 @@ MySetLabel::~MySetLabel() { } -void MySetLabel::paintEvent(QPaintEvent * event) { +void MySetLabel::paintEvent(QPaintEvent * event) +{ - QLabel::paintEvent(event); + QLabel::paintEvent(event); } diff --git a/src/gui/qt/gametable/mysetlabel.h b/src/gui/qt/gametable/mysetlabel.h index fbb4ab9e..0d6e5d00 100644 --- a/src/gui/qt/gametable/mysetlabel.h +++ b/src/gui/qt/gametable/mysetlabel.h @@ -1,7 +1,7 @@ // // C++ Interface: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -21,21 +21,23 @@ class gameTableImpl; class MySetLabel : public QLabel { -Q_OBJECT + Q_OBJECT public: - MySetLabel(QGroupBox*); + MySetLabel(QGroupBox*); - ~MySetLabel(); + ~MySetLabel(); + + + void setMyW ( gameTableImpl* theValue ) { + myW = theValue; + } + void paintEvent(QPaintEvent * event); - - void setMyW ( gameTableImpl* theValue ) { myW = theValue; } - void paintEvent(QPaintEvent * event); - public slots: -private: +private: - gameTableImpl *myW; + gameTableImpl *myW; }; diff --git a/src/gui/qt/gametable/myslider.h b/src/gui/qt/gametable/myslider.h index 528c6d53..45afb25a 100644 --- a/src/gui/qt/gametable/myslider.h +++ b/src/gui/qt/gametable/myslider.h @@ -11,18 +11,15 @@ class Slider : public QSlider public: Slider( QWidget* parent = 0 ) - : QSlider( parent ) - { + : QSlider( parent ) { } - + Slider( Qt::Orientation orientation, QWidget* parent = 0 ) - : QSlider( orientation, parent ) - { + : QSlider( orientation, parent ) { } protected: - int pixelPosToRangeValue(int pos) const // getted from QSlider.cpp with little adapt - { + int pixelPosToRangeValue(int pos) const { // getted from QSlider.cpp with little adapt QStyleOptionSlider opt; initStyleOption(&opt); QRect gr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, this); @@ -41,24 +38,22 @@ protected: return QStyle::sliderValueFromPosition(minimum(), maximum(), pos - sliderMin, sliderMax - sliderMin, opt.upsideDown); } - - int pick(const QPoint &pt) const // getted from QSlider.cpp with little adapt - { + + int pick(const QPoint &pt) const { // getted from QSlider.cpp with little adapt return orientation() == Qt::Horizontal ? pt.x() : pt.y(); } - - virtual void mousePressEvent( QMouseEvent* ev ) // getted from QSlider.cpp with little adapt - { + + virtual void mousePressEvent( QMouseEvent* ev ) { // getted from QSlider.cpp with little adapt if (maximum() == minimum() || (ev->buttons() ^ ev->button())) { ev->ignore(); return; } - #ifdef QT_KEYPAD_NAVIGATION +#ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled()) setEditFocus(true); - #endif +#endif ev->accept(); - + //if ((ev->button() & style()->styleHint(QStyle::SH_Slider_AbsoluteSetButtons)) == ev->button()) { QStyleOptionSlider opt; @@ -84,7 +79,7 @@ protected: update(sr); setSliderDown(true); } - + QSlider::mousePressEvent( ev ); // should not be needed but as we can't update private d pointer it's needed. } }; diff --git a/src/gui/qt/gametable/mystatuslabel.cpp b/src/gui/qt/gametable/mystatuslabel.cpp index 9ba930e9..e166f69d 100755 --- a/src/gui/qt/gametable/mystatuslabel.cpp +++ b/src/gui/qt/gametable/mystatuslabel.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -16,7 +16,8 @@ using namespace std; MyStatusLabel::MyStatusLabel(QGroupBox* parent) - : QLabel(parent), myW(NULL), mousePress(false) { + : QLabel(parent), myW(NULL), mousePress(false) +{ mousePress = FALSE; @@ -26,23 +27,25 @@ MyStatusLabel::~MyStatusLabel() { } -void MyStatusLabel::mousePressEvent(QMouseEvent * event) { +void MyStatusLabel::mousePressEvent(QMouseEvent * event) +{ if (!mousePress && objectName().contains("textLabel_Status0")) { - mousePress = TRUE; - myW->mouseOverFlipCards(TRUE); - + mousePress = TRUE; + myW->mouseOverFlipCards(TRUE); + } QLabel::mousePressEvent(event); } -void MyStatusLabel::mouseReleaseEvent(QMouseEvent * event) { +void MyStatusLabel::mouseReleaseEvent(QMouseEvent * event) +{ if (mousePress && objectName().contains("textLabel_Status0")) { - mousePress = FALSE; + mousePress = FALSE; myW->mouseOverFlipCards(FALSE); - } + } QLabel::mouseReleaseEvent(event); } diff --git a/src/gui/qt/gametable/mystatuslabel.h b/src/gui/qt/gametable/mystatuslabel.h index 6e22d07a..e30b4640 100755 --- a/src/gui/qt/gametable/mystatuslabel.h +++ b/src/gui/qt/gametable/mystatuslabel.h @@ -1,7 +1,7 @@ // // C++ Interface: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -21,24 +21,26 @@ class gameTableImpl; class MyStatusLabel : public QLabel { -Q_OBJECT + Q_OBJECT public: - MyStatusLabel(QGroupBox*); + MyStatusLabel(QGroupBox*); - ~MyStatusLabel(); + ~MyStatusLabel(); - - void setMyW ( gameTableImpl* theValue ) { myW = theValue; } + + void setMyW ( gameTableImpl* theValue ) { + myW = theValue; + } void mousePressEvent ( QMouseEvent *); void mouseReleaseEvent ( QMouseEvent *); - -private: + +private: gameTableImpl *myW; bool mousePress; - + }; #endif diff --git a/src/gui/qt/gametable/mytimeoutlabel.cpp b/src/gui/qt/gametable/mytimeoutlabel.cpp index 38b77fb1..b959dec7 100644 --- a/src/gui/qt/gametable/mytimeoutlabel.cpp +++ b/src/gui/qt/gametable/mytimeoutlabel.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -16,7 +16,7 @@ using namespace std; MyTimeoutLabel::MyTimeoutLabel(QGroupBox* parent) - : QLabel(parent), timeOutAnimation(FALSE), timeOutValue(0), timeOutFrame(0), waitFrames(0), timerIntervall(0), isBeep(0), isBeepPlayed(0) + : QLabel(parent), timeOutAnimation(FALSE), timeOutValue(0), timeOutFrame(0), waitFrames(0), timerIntervall(0), isBeep(0), isBeepPlayed(0) { timeOutAnimationTimer = new QTimer; @@ -29,10 +29,10 @@ MyTimeoutLabel::~MyTimeoutLabel() { } -void MyTimeoutLabel::startTimeOutAnimation(int secs, bool beep) { +void MyTimeoutLabel::startTimeOutAnimation(int secs, bool beep) +{ - if (secs >= 4) // smaller timeouts may lead to errors/endless loops below - { + if (secs >= 4) { // smaller timeouts may lead to errors/endless loops below isBeepPlayed = FALSE; isBeep = beep; @@ -49,8 +49,7 @@ void MyTimeoutLabel::startTimeOutAnimation(int secs, bool beep) { if(secs <= 9 && secs >= 6) { //fix inaccuracies caused by integer division timerIntervall = timerIntervall + preTimerIntervall + 5; - } - else { + } else { timerIntervall = timerIntervall + preTimerIntervall; } } @@ -61,20 +60,22 @@ void MyTimeoutLabel::startTimeOutAnimation(int secs, bool beep) { realTimer.reset(); realTimer.start(); - // std::cout << timerIntervall << endl; + // std::cout << timerIntervall << endl; timeOutAnimation = TRUE; timeOutAnimationTimer->start(timerIntervall); } } -void MyTimeoutLabel::startTimeOutAnimationNow() { +void MyTimeoutLabel::startTimeOutAnimationNow() +{ timeOutAnimation = TRUE; timeOutAnimationTimer->start(83); } -void MyTimeoutLabel::stopTimeOutAnimation() { +void MyTimeoutLabel::stopTimeOutAnimation() +{ // timeOutAnimationKickOnTimer->stop(); timeOutAnimationTimer->stop(); @@ -82,24 +83,24 @@ void MyTimeoutLabel::stopTimeOutAnimation() { update(); } -void MyTimeoutLabel::nextTimeOutAnimationFrame() { +void MyTimeoutLabel::nextTimeOutAnimationFrame() +{ if(timeOutAnimationWidth >=0) { - if(timeOutFrame > waitFrames) { + if(timeOutFrame > waitFrames) { //play beep after waitFrames one time - if(isBeep && !isBeepPlayed) { + if(isBeep && !isBeepPlayed) { myW->getMySDLPlayer()->playSound("yourturn",0); isBeepPlayed = TRUE; } //save gfx ressources and never play more the 10 pps unsigned int realTimerValue = realTimer.elapsed().total_milliseconds(); - timeOutAnimationWidth = 52-(((realTimerValue-3000)*52)/((timeOutValue-3)*1000)); + timeOutAnimationWidth = 52-(((realTimerValue-3000)*52)/((timeOutValue-3)*1000)); } timeOutFrame++; update(); - } - else { + } else { stopTimeOutAnimation(); // no callback is called here. // the server initiates any action required. @@ -107,7 +108,8 @@ void MyTimeoutLabel::nextTimeOutAnimationFrame() { } -void MyTimeoutLabel::paintEvent(QPaintEvent * event) { +void MyTimeoutLabel::paintEvent(QPaintEvent * event) +{ if(!timeOutAnimation || timeOutFrame <= waitFrames) { QLabel::paintEvent(event); @@ -116,15 +118,15 @@ void MyTimeoutLabel::paintEvent(QPaintEvent * event) { if(timeOutAnimation && timeOutFrame > waitFrames) { QPainter painter(this); - - QLinearGradient linearGrad(QPointF(0, 10), QPointF(47, 10)); + + QLinearGradient linearGrad(QPointF(0, 10), QPointF(47, 10)); linearGrad.setColorAt(0, Qt::red); linearGrad.setColorAt(0.5, Qt::yellow); linearGrad.setColorAt(1, Qt::green); - + painter.setBrush(linearGrad); - + painter.setPen(QColor(0,0,0)); - painter.drawRect(0,1,timeOutAnimationWidth-1,8); + painter.drawRect(0,1,timeOutAnimationWidth-1,8); } } diff --git a/src/gui/qt/gametable/mytimeoutlabel.h b/src/gui/qt/gametable/mytimeoutlabel.h index e850edb3..00d59db7 100644 --- a/src/gui/qt/gametable/mytimeoutlabel.h +++ b/src/gui/qt/gametable/mytimeoutlabel.h @@ -1,7 +1,7 @@ // // C++ Interface: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -23,32 +23,34 @@ class gameTableImpl; class MyTimeoutLabel : public QLabel { -Q_OBJECT + Q_OBJECT public: - MyTimeoutLabel(QGroupBox*); + MyTimeoutLabel(QGroupBox*); - ~MyTimeoutLabel(); + ~MyTimeoutLabel(); + + + void setMyW ( gameTableImpl* theValue ) { + myW = theValue; + } - - void setMyW ( gameTableImpl* theValue ) { myW = theValue; } - void startTimeOutAnimation(int secs, bool beep); void stopTimeOutAnimation(); - + void paintEvent(QPaintEvent * event); - + public slots: void startTimeOutAnimationNow(); void nextTimeOutAnimationFrame(); - -private: + +private: gameTableImpl *myW; QTimer *timeOutAnimationTimer; QTimer *timeOutAnimationKickOnTimer; - + // boost::shared_ptr mySDLPlayer; boost::timers::portable::microsec_timer realTimer; @@ -63,8 +65,8 @@ private: int timerIntervall; bool isBeep; bool isBeepPlayed; - - + + }; #endif diff --git a/src/gui/qt/gametable/startsplash/startsplash.cpp b/src/gui/qt/gametable/startsplash/startsplash.cpp index 05daeb87..92fcc1aa 100755 --- a/src/gui/qt/gametable/startsplash/startsplash.cpp +++ b/src/gui/qt/gametable/startsplash/startsplash.cpp @@ -20,9 +20,9 @@ #include "startsplash.h" StartSplash::StartSplash(QPixmap &p) - : QSplashScreen(p) + : QSplashScreen(p) { - QTimer::singleShot(3000, this, SLOT(closeThis())); + QTimer::singleShot(3000, this, SLOT(closeThis())); } @@ -30,4 +30,7 @@ StartSplash::~StartSplash() { } -void StartSplash::closeThis() { this->close(); } +void StartSplash::closeThis() +{ + this->close(); +} diff --git a/src/gui/qt/gametable/startsplash/startsplash.h b/src/gui/qt/gametable/startsplash/startsplash.h index 9f189eba..e133fae9 100755 --- a/src/gui/qt/gametable/startsplash/startsplash.h +++ b/src/gui/qt/gametable/startsplash/startsplash.h @@ -1,7 +1,7 @@ // // C++ Interface: startsplash // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -18,11 +18,11 @@ class StartSplash : public QSplashScreen { -Q_OBJECT + Q_OBJECT public: - StartSplash(QPixmap& p); + StartSplash(QPixmap& p); - ~StartSplash(); + ~StartSplash(); public slots: diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index 681509ea..0fcdc8fe 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -34,164 +34,450 @@ GuiWrapper::GuiWrapper(ConfigFile *c, startWindowImpl *s) : myGuiLog(NULL), myW( { - myW = new gameTableImpl(myConfig); - myGuiLog = new guiLog(myW, myConfig); + myW = new gameTableImpl(myConfig); + myGuiLog = new guiLog(myW, myConfig); - myW->setStartWindow(myStartWindow); + myW->setStartWindow(myStartWindow); } GuiWrapper::~GuiWrapper() { - delete myGuiLog; + delete myGuiLog; } -void GuiWrapper::initGui(int speed) { myW->signalInitGui(speed); } +void GuiWrapper::initGui(int speed) +{ + myW->signalInitGui(speed); +} -boost::shared_ptr GuiWrapper::getSession() { return myStartWindow->getSession(); } -void GuiWrapper::setSession(boost::shared_ptr /*session*/) { /*myStartWindow->setSession(session);*/ } +boost::shared_ptr GuiWrapper::getSession() +{ + return myStartWindow->getSession(); +} +void GuiWrapper::setSession(boost::shared_ptr /*session*/) +{ + /*myStartWindow->setSession(session);*/ +} -void GuiWrapper::refreshSet() const { myW->signalRefreshSet(); } -void GuiWrapper::refreshCash() const { myW->signalRefreshCash(); } -void GuiWrapper::refreshAction(int playerID, int playerAction) const { myW->signalRefreshAction(playerID, playerAction); } -void GuiWrapper::refreshChangePlayer() const { myW->signalRefreshChangePlayer(); } -void GuiWrapper::refreshAll() const { myW->signalRefreshAll(); } -void GuiWrapper::refreshPot() const { myW->signalRefreshPot(); } -void GuiWrapper::refreshGroupbox(int playerID, int status) const { myW->signalRefreshGroupbox(playerID, status); } -void GuiWrapper::refreshPlayerName() const { myW->signalRefreshPlayerName(); } -void GuiWrapper::refreshButton() const { myW->signalRefreshButton(); } -void GuiWrapper::refreshGameLabels(GameState state) const { myW->signalRefreshGameLabels(state); } +void GuiWrapper::refreshSet() const +{ + myW->signalRefreshSet(); +} +void GuiWrapper::refreshCash() const +{ + myW->signalRefreshCash(); +} +void GuiWrapper::refreshAction(int playerID, int playerAction) const +{ + myW->signalRefreshAction(playerID, playerAction); +} +void GuiWrapper::refreshChangePlayer() const +{ + myW->signalRefreshChangePlayer(); +} +void GuiWrapper::refreshAll() const +{ + myW->signalRefreshAll(); +} +void GuiWrapper::refreshPot() const +{ + myW->signalRefreshPot(); +} +void GuiWrapper::refreshGroupbox(int playerID, int status) const +{ + myW->signalRefreshGroupbox(playerID, status); +} +void GuiWrapper::refreshPlayerName() const +{ + myW->signalRefreshPlayerName(); +} +void GuiWrapper::refreshButton() const +{ + myW->signalRefreshButton(); +} +void GuiWrapper::refreshGameLabels(GameState state) const +{ + myW->signalRefreshGameLabels(state); +} -void GuiWrapper::setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const { myW->signalSetPlayerAvatar(myUniqueID, QString::fromUtf8(myAvatar.c_str())); } +void GuiWrapper::setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const +{ + myW->signalSetPlayerAvatar(myUniqueID, QString::fromUtf8(myAvatar.c_str())); +} void GuiWrapper::waitForGuiUpdateDone() const { - myW->signalGuiUpdateDone(); - myW->waitForGuiUpdateDone(); + myW->signalGuiUpdateDone(); + myW->waitForGuiUpdateDone(); } -void GuiWrapper::dealBeRoCards(int myBeRoID) { myW->signalDealBeRoCards(myBeRoID); } +void GuiWrapper::dealBeRoCards(int myBeRoID) +{ + myW->signalDealBeRoCards(myBeRoID); +} -void GuiWrapper::dealHoleCards() { myW->signalDealHoleCards(); } -void GuiWrapper::dealFlopCards() { myW->signalDealFlopCards0(); } -void GuiWrapper::dealTurnCard() { myW->signalDealTurnCards0(); } -void GuiWrapper::dealRiverCard() { myW->signalDealRiverCards0(); } +void GuiWrapper::dealHoleCards() +{ + myW->signalDealHoleCards(); +} +void GuiWrapper::dealFlopCards() +{ + myW->signalDealFlopCards0(); +} +void GuiWrapper::dealTurnCard() +{ + myW->signalDealTurnCards0(); +} +void GuiWrapper::dealRiverCard() +{ + myW->signalDealRiverCards0(); +} -void GuiWrapper::nextPlayerAnimation() { myW->signalNextPlayerAnimation(); } +void GuiWrapper::nextPlayerAnimation() +{ + myW->signalNextPlayerAnimation(); +} -void GuiWrapper::beRoAnimation2(int myBeRoID) { myW->signalBeRoAnimation2(myBeRoID); } +void GuiWrapper::beRoAnimation2(int myBeRoID) +{ + myW->signalBeRoAnimation2(myBeRoID); +} -void GuiWrapper::preflopAnimation1() { myW->signalPreflopAnimation1(); } -void GuiWrapper::preflopAnimation2() { myW->signalPreflopAnimation2(); } +void GuiWrapper::preflopAnimation1() +{ + myW->signalPreflopAnimation1(); +} +void GuiWrapper::preflopAnimation2() +{ + myW->signalPreflopAnimation2(); +} -void GuiWrapper::flopAnimation1() { myW->signalFlopAnimation1(); } -void GuiWrapper::flopAnimation2() { myW->signalFlopAnimation2(); } +void GuiWrapper::flopAnimation1() +{ + myW->signalFlopAnimation1(); +} +void GuiWrapper::flopAnimation2() +{ + myW->signalFlopAnimation2(); +} -void GuiWrapper::turnAnimation1() { myW->signalTurnAnimation1(); } -void GuiWrapper::turnAnimation2() { myW->signalTurnAnimation2(); } +void GuiWrapper::turnAnimation1() +{ + myW->signalTurnAnimation1(); +} +void GuiWrapper::turnAnimation2() +{ + myW->signalTurnAnimation2(); +} -void GuiWrapper::riverAnimation1() { myW->signalRiverAnimation1(); } -void GuiWrapper::riverAnimation2() { myW->signalRiverAnimation2(); } +void GuiWrapper::riverAnimation1() +{ + myW->signalRiverAnimation1(); +} +void GuiWrapper::riverAnimation2() +{ + myW->signalRiverAnimation2(); +} -void GuiWrapper::postRiverAnimation1() { myW->signalPostRiverAnimation1(); } -void GuiWrapper::postRiverRunAnimation1() { myW->signalPostRiverRunAnimation1(); } +void GuiWrapper::postRiverAnimation1() +{ + myW->signalPostRiverAnimation1(); +} +void GuiWrapper::postRiverRunAnimation1() +{ + myW->signalPostRiverRunAnimation1(); +} -void GuiWrapper::flipHolecardsAllIn() { myW->signalFlipHolecardsAllIn(); } +void GuiWrapper::flipHolecardsAllIn() +{ + myW->signalFlipHolecardsAllIn(); +} -void GuiWrapper::nextRoundCleanGui() { myW->signalNextRoundCleanGui(); } +void GuiWrapper::nextRoundCleanGui() +{ + myW->signalNextRoundCleanGui(); +} -void GuiWrapper::meInAction() { myW->signalMeInAction(); } -void GuiWrapper::updateMyButtonsState() { myW->signalUpdateMyButtonsState(); } -void GuiWrapper::disableMyButtons() { myW->signalDisableMyButtons(); } -void GuiWrapper::startTimeoutAnimation(int playerNum, int timeoutSec) { myW->signalStartTimeoutAnimation(playerNum, timeoutSec); } -void GuiWrapper::stopTimeoutAnimation(int playerNum) { myW->signalStopTimeoutAnimation(playerNum); } +void GuiWrapper::meInAction() +{ + myW->signalMeInAction(); +} +void GuiWrapper::updateMyButtonsState() +{ + myW->signalUpdateMyButtonsState(); +} +void GuiWrapper::disableMyButtons() +{ + myW->signalDisableMyButtons(); +} +void GuiWrapper::startTimeoutAnimation(int playerNum, int timeoutSec) +{ + myW->signalStartTimeoutAnimation(playerNum, timeoutSec); +} +void GuiWrapper::stopTimeoutAnimation(int playerNum) +{ + myW->signalStopTimeoutAnimation(playerNum); +} -void GuiWrapper::startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick) { myW->signalStartVoteOnKick(playerId, voteStarterPlayerId, timeoutSec, numVotesNeededToKick); } -void GuiWrapper::changeVoteOnKickButtonsState(bool showHide) { myW->signalChangeVoteOnKickButtonsState(showHide); } -void GuiWrapper::refreshVotesMonitor(int currentVotes, int numVotesNeededToKick) { myW->refreshVotesMonitor(currentVotes, numVotesNeededToKick); } -void GuiWrapper::endVoteOnKick() { myW->signalEndVoteOnKick(); } +void GuiWrapper::startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick) +{ + myW->signalStartVoteOnKick(playerId, voteStarterPlayerId, timeoutSec, numVotesNeededToKick); +} +void GuiWrapper::changeVoteOnKickButtonsState(bool showHide) +{ + myW->signalChangeVoteOnKickButtonsState(showHide); +} +void GuiWrapper::refreshVotesMonitor(int currentVotes, int numVotesNeededToKick) +{ + myW->refreshVotesMonitor(currentVotes, numVotesNeededToKick); +} +void GuiWrapper::endVoteOnKick() +{ + myW->signalEndVoteOnKick(); +} -void GuiWrapper::logPlayerActionMsg(string playerName, int playerID, int action, int setValue) { myGuiLog->signalLogPlayerActionMsg(QString::fromUtf8(playerName.c_str()), playerID, action, setValue); } -void GuiWrapper::logNewGameHandMsg(int gameID, int handID) { myGuiLog->signalLogNewGameHandMsg(gameID, handID); } -void GuiWrapper::logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName) { myGuiLog->signalLogNewBlindsSetsMsg(sbSet, bbSet, QString::fromUtf8(sbName.c_str()), QString::fromUtf8(bbName.c_str())); } -void GuiWrapper::logPlayerWinsMsg(std::string playerName, int pot, bool main) { myGuiLog->signalLogPlayerWinsMsg(QString::fromUtf8(playerName.c_str()), pot, main); } -void GuiWrapper::logPlayerSitsOut(std::string playerName) { myGuiLog->signalLogPlayerSitsOut(QString::fromUtf8(playerName.c_str())); } -void GuiWrapper::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4, int card5) { myGuiLog->signalLogDealBoardCardsMsg(roundID, card1, card2, card3, card4, card5); } -void GuiWrapper::logFlipHoleCardsMsg(string playerName, int playerID, int card1, int card2, int cardsValueInt, string showHas) { myGuiLog->signalLogFlipHoleCardsMsg(QString::fromUtf8(playerName.c_str()), playerID, card1, card2, cardsValueInt, QString::fromUtf8(showHas.c_str())); } -void GuiWrapper::logPlayerWinGame(std::string playerName, int gameID) { myGuiLog->signalLogPlayerWinGame(QString::fromUtf8(playerName.c_str()), gameID); } -void GuiWrapper::flushLogAtGame(int gameID) { myGuiLog->signalFlushLogAtGame(gameID); } -void GuiWrapper::flushLogAtHand() { myGuiLog->signalFlushLogAtHand(); } +void GuiWrapper::logPlayerActionMsg(string playerName, int playerID, int action, int setValue) +{ + myGuiLog->signalLogPlayerActionMsg(QString::fromUtf8(playerName.c_str()), playerID, action, setValue); +} +void GuiWrapper::logNewGameHandMsg(int gameID, int handID) +{ + myGuiLog->signalLogNewGameHandMsg(gameID, handID); +} +void GuiWrapper::logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName) +{ + myGuiLog->signalLogNewBlindsSetsMsg(sbSet, bbSet, QString::fromUtf8(sbName.c_str()), QString::fromUtf8(bbName.c_str())); +} +void GuiWrapper::logPlayerWinsMsg(std::string playerName, int pot, bool main) +{ + myGuiLog->signalLogPlayerWinsMsg(QString::fromUtf8(playerName.c_str()), pot, main); +} +void GuiWrapper::logPlayerSitsOut(std::string playerName) +{ + myGuiLog->signalLogPlayerSitsOut(QString::fromUtf8(playerName.c_str())); +} +void GuiWrapper::logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4, int card5) +{ + myGuiLog->signalLogDealBoardCardsMsg(roundID, card1, card2, card3, card4, card5); +} +void GuiWrapper::logFlipHoleCardsMsg(string playerName, int playerID, int card1, int card2, int cardsValueInt, string showHas) +{ + myGuiLog->signalLogFlipHoleCardsMsg(QString::fromUtf8(playerName.c_str()), playerID, card1, card2, cardsValueInt, QString::fromUtf8(showHas.c_str())); +} +void GuiWrapper::logPlayerWinGame(std::string playerName, int gameID) +{ + myGuiLog->signalLogPlayerWinGame(QString::fromUtf8(playerName.c_str()), gameID); +} +void GuiWrapper::flushLogAtGame(int gameID) +{ + myGuiLog->signalFlushLogAtGame(gameID); +} +void GuiWrapper::flushLogAtHand() +{ + myGuiLog->signalFlushLogAtHand(); +} -void GuiWrapper::SignalNetClientConnect(int actionID) { myStartWindow->signalNetClientConnect(actionID); } -void GuiWrapper::SignalNetClientServerListAdd(unsigned serverId) { myStartWindow->signalNetClientServerListAdd(serverId); } -void GuiWrapper::SignalNetClientServerListShow() { myStartWindow->signalNetClientServerListShow(); } -void GuiWrapper::SignalNetClientLoginShow() { myStartWindow->signalNetClientLoginShow(); } -void GuiWrapper::SignalNetClientPostRiverShowCards(unsigned playerId) { myW->signalPostRiverShowCards(playerId); } -void GuiWrapper::SignalNetClientServerListClear() { myStartWindow->signalNetClientServerListClear(); } -void GuiWrapper::SignalNetClientGameInfo(int actionID) { myStartWindow->signalNetClientGameInfo(actionID); } -void GuiWrapper::SignalNetClientError(int errorID, int osErrorID) { myStartWindow->signalNetClientError(errorID, osErrorID); } -void GuiWrapper::SignalNetClientNotification(int notificationId) { myStartWindow->signalNetClientNotification(notificationId); } -void GuiWrapper::SignalNetClientStatsUpdate(const ServerStats &stats) { myStartWindow->signalNetClientStatsUpdate(stats); } -void GuiWrapper::SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec) { myStartWindow->signalNetClientShowTimeoutDialog(reason, remainingSec); } -void GuiWrapper::SignalNetClientRemovedFromGame(int notificationId) { myStartWindow->signalNetClientRemovedFromGame(notificationId); } -void GuiWrapper::SignalNetClientSelfJoined(unsigned playerId, const string &playerName, bool isGameAdmin) { myStartWindow->signalNetClientSelfJoined(playerId, QString::fromUtf8(playerName.c_str()), isGameAdmin); } -void GuiWrapper::SignalNetClientPlayerJoined(unsigned playerId, const string &playerName, bool isGameAdmin) { myStartWindow->signalNetClientPlayerJoined(playerId, QString::fromUtf8(playerName.c_str()), isGameAdmin); } +void GuiWrapper::SignalNetClientConnect(int actionID) +{ + myStartWindow->signalNetClientConnect(actionID); +} +void GuiWrapper::SignalNetClientServerListAdd(unsigned serverId) +{ + myStartWindow->signalNetClientServerListAdd(serverId); +} +void GuiWrapper::SignalNetClientServerListShow() +{ + myStartWindow->signalNetClientServerListShow(); +} +void GuiWrapper::SignalNetClientLoginShow() +{ + myStartWindow->signalNetClientLoginShow(); +} +void GuiWrapper::SignalNetClientPostRiverShowCards(unsigned playerId) +{ + myW->signalPostRiverShowCards(playerId); +} +void GuiWrapper::SignalNetClientServerListClear() +{ + myStartWindow->signalNetClientServerListClear(); +} +void GuiWrapper::SignalNetClientGameInfo(int actionID) +{ + myStartWindow->signalNetClientGameInfo(actionID); +} +void GuiWrapper::SignalNetClientError(int errorID, int osErrorID) +{ + myStartWindow->signalNetClientError(errorID, osErrorID); +} +void GuiWrapper::SignalNetClientNotification(int notificationId) +{ + myStartWindow->signalNetClientNotification(notificationId); +} +void GuiWrapper::SignalNetClientStatsUpdate(const ServerStats &stats) +{ + myStartWindow->signalNetClientStatsUpdate(stats); +} +void GuiWrapper::SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec) +{ + myStartWindow->signalNetClientShowTimeoutDialog(reason, remainingSec); +} +void GuiWrapper::SignalNetClientRemovedFromGame(int notificationId) +{ + myStartWindow->signalNetClientRemovedFromGame(notificationId); +} +void GuiWrapper::SignalNetClientSelfJoined(unsigned playerId, const string &playerName, bool isGameAdmin) +{ + myStartWindow->signalNetClientSelfJoined(playerId, QString::fromUtf8(playerName.c_str()), isGameAdmin); +} +void GuiWrapper::SignalNetClientPlayerJoined(unsigned playerId, const string &playerName, bool isGameAdmin) +{ + myStartWindow->signalNetClientPlayerJoined(playerId, QString::fromUtf8(playerName.c_str()), isGameAdmin); +} void GuiWrapper::SignalNetClientPlayerChanged(unsigned playerId, const string &newPlayerName) { - myStartWindow->signalNetClientPlayerChanged(playerId, QString::fromUtf8(newPlayerName.c_str())); + myStartWindow->signalNetClientPlayerChanged(playerId, QString::fromUtf8(newPlayerName.c_str())); } void GuiWrapper::SignalNetClientPlayerLeft(unsigned playerId, const string &playerName, int removeReason) { - QString tmpName(QString::fromUtf8(playerName.c_str())); - myStartWindow->signalNetClientPlayerLeft(playerId, tmpName); - myW->signalNetClientPlayerLeft(playerId); - if (!playerName.empty() && playerName[0] != '#') - myGuiLog->signalLogPlayerLeftMsg(tmpName, removeReason == NTF_NET_REMOVED_KICKED); + QString tmpName(QString::fromUtf8(playerName.c_str())); + myStartWindow->signalNetClientPlayerLeft(playerId, tmpName); + myW->signalNetClientPlayerLeft(playerId); + if (!playerName.empty() && playerName[0] != '#') + myGuiLog->signalLogPlayerLeftMsg(tmpName, removeReason == NTF_NET_REMOVED_KICKED); } -void GuiWrapper::SignalNetClientNewGameAdmin(unsigned playerId, const string &playerName) { +void GuiWrapper::SignalNetClientNewGameAdmin(unsigned playerId, const string &playerName) +{ - myStartWindow->signalNetClientNewGameAdmin(playerId, QString::fromUtf8(playerName.c_str())); - if (!playerName.empty() && playerName[0] != '#') - myGuiLog->signalLogNewGameAdminMsg(QString::fromUtf8(playerName.c_str())); + myStartWindow->signalNetClientNewGameAdmin(playerId, QString::fromUtf8(playerName.c_str())); + if (!playerName.empty() && playerName[0] != '#') + myGuiLog->signalLogNewGameAdminMsg(QString::fromUtf8(playerName.c_str())); } -void GuiWrapper::SignalNetClientGameListNew(unsigned gameId) { myStartWindow->signalNetClientGameListNew(gameId); } -void GuiWrapper::SignalNetClientGameListRemove(unsigned gameId) { myStartWindow->signalNetClientGameListRemove(gameId); } -void GuiWrapper::SignalNetClientGameListUpdateMode(unsigned gameId, GameMode mode) { myStartWindow->signalNetClientGameListUpdateMode(gameId, mode); } -void GuiWrapper::SignalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId) {myStartWindow->signalNetClientGameListUpdateAdmin(gameId, adminPlayerId); } -void GuiWrapper::SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId) { myStartWindow->signalNetClientGameListPlayerJoined(gameId, playerId); } -void GuiWrapper::SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId) { myStartWindow->signalNetClientGameListPlayerLeft(gameId, playerId); } -void GuiWrapper::SignalNetClientGameStart(boost::shared_ptr game) { myStartWindow->signalNetClientGameStart(game); } +void GuiWrapper::SignalNetClientGameListNew(unsigned gameId) +{ + myStartWindow->signalNetClientGameListNew(gameId); +} +void GuiWrapper::SignalNetClientGameListRemove(unsigned gameId) +{ + myStartWindow->signalNetClientGameListRemove(gameId); +} +void GuiWrapper::SignalNetClientGameListUpdateMode(unsigned gameId, GameMode mode) +{ + myStartWindow->signalNetClientGameListUpdateMode(gameId, mode); +} +void GuiWrapper::SignalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId) +{ + myStartWindow->signalNetClientGameListUpdateAdmin(gameId, adminPlayerId); +} +void GuiWrapper::SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId) +{ + myStartWindow->signalNetClientGameListPlayerJoined(gameId, playerId); +} +void GuiWrapper::SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId) +{ + myStartWindow->signalNetClientGameListPlayerLeft(gameId, playerId); +} +void GuiWrapper::SignalNetClientGameStart(boost::shared_ptr game) +{ + myStartWindow->signalNetClientGameStart(game); +} -void GuiWrapper::SignalNetClientWaitDialog() { myStartWindow->signalShowClientDialog(); } -void GuiWrapper::SignalNetClientWarningAutoFoldInRankingGame(unsigned remainingAutoFolds) { myW->signalWarningAutoFoldInRankingGame(remainingAutoFolds); } +void GuiWrapper::SignalNetClientWaitDialog() +{ + myStartWindow->signalShowClientDialog(); +} +void GuiWrapper::SignalNetClientWarningAutoFoldInRankingGame(unsigned remainingAutoFolds) +{ + myW->signalWarningAutoFoldInRankingGame(remainingAutoFolds); +} -void GuiWrapper::SignalNetClientGameChatMsg(const string &playerName, const string &msg) { myStartWindow->signalNetClientGameChatMsg(QString::fromUtf8(playerName.c_str()), QString::fromUtf8(msg.c_str())); } -void GuiWrapper::SignalNetClientLobbyChatMsg(const string &playerName, const string &msg) { myStartWindow->signalNetClientLobbyChatMsg(QString::fromUtf8(playerName.c_str()), QString::fromUtf8(msg.c_str())); } -void GuiWrapper::SignalNetClientMsgBox(const string &msg) { myStartWindow->signalNetClientMsgBox(QString::fromUtf8(msg.c_str())); } -void GuiWrapper::SignalNetClientMsgBox(unsigned msgId) { myStartWindow->signalNetClientMsgBox(msgId); } +void GuiWrapper::SignalNetClientGameChatMsg(const string &playerName, const string &msg) +{ + myStartWindow->signalNetClientGameChatMsg(QString::fromUtf8(playerName.c_str()), QString::fromUtf8(msg.c_str())); +} +void GuiWrapper::SignalNetClientLobbyChatMsg(const string &playerName, const string &msg) +{ + myStartWindow->signalNetClientLobbyChatMsg(QString::fromUtf8(playerName.c_str()), QString::fromUtf8(msg.c_str())); +} +void GuiWrapper::SignalNetClientMsgBox(const string &msg) +{ + myStartWindow->signalNetClientMsgBox(QString::fromUtf8(msg.c_str())); +} +void GuiWrapper::SignalNetClientMsgBox(unsigned msgId) +{ + myStartWindow->signalNetClientMsgBox(msgId); +} void GuiWrapper::SignalNetServerSuccess(int /*actionID*/) { } -void GuiWrapper::SignalNetServerError(int errorID, int osErrorID) { myStartWindow->signalNetServerError(errorID, osErrorID); } +void GuiWrapper::SignalNetServerError(int errorID, int osErrorID) +{ + myStartWindow->signalNetServerError(errorID, osErrorID); +} -void GuiWrapper::SignalIrcConnect(const string &/*server*/) { /*myStartWindow->signalIrcConnect(QString::fromUtf8(server.c_str()));*/ } -void GuiWrapper::SignalIrcSelfJoined(const string &/*nickName*/, const string &/*channel*/) { /*myStartWindow->signalIrcSelfJoined(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(channel.c_str()));*/ } -void GuiWrapper::SignalIrcPlayerJoined(const string &/*nickName*/) { /*myStartWindow->signalIrcPlayerJoined(QString::fromUtf8(nickName.c_str()));*/ } -void GuiWrapper::SignalIrcPlayerChanged(const string &/*oldNick*/, const string &/*newNick*/) {/* myStartWindow->signalIrcPlayerChanged(QString::fromUtf8(oldNick.c_str()), QString::fromUtf8(newNick.c_str()));*/ } -void GuiWrapper::SignalIrcPlayerKicked(const std::string &/*nickName*/, const std::string &/*byWhom*/, const std::string &/*reason*/) { /*myStartWindow->signalIrcPlayerKicked(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(byWhom.c_str()), QString::fromUtf8(reason.c_str()));*/ } -void GuiWrapper::SignalIrcPlayerLeft(const std::string &/*nickName*/) { /*myStartWindow->signalIrcPlayerLeft(QString::fromUtf8(nickName.c_str()));*/ } -void GuiWrapper::SignalIrcChatMsg(const std::string &/*nickName*/, const std::string &/*msg*/) { /*myStartWindow->signalIrcChatMessage(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(msg.c_str()));*/ } -void GuiWrapper::SignalIrcError(int /*errorCode*/) { /*myStartWindow->signalIrcError(errorCode);*/ } -void GuiWrapper::SignalIrcServerError(int /*errorCode*/) {/*myStartWindow->signalIrcServerError(errorCode);*/ } +void GuiWrapper::SignalIrcConnect(const string &/*server*/) +{ + /*myStartWindow->signalIrcConnect(QString::fromUtf8(server.c_str()));*/ +} +void GuiWrapper::SignalIrcSelfJoined(const string &/*nickName*/, const string &/*channel*/) +{ + /*myStartWindow->signalIrcSelfJoined(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(channel.c_str()));*/ +} +void GuiWrapper::SignalIrcPlayerJoined(const string &/*nickName*/) +{ + /*myStartWindow->signalIrcPlayerJoined(QString::fromUtf8(nickName.c_str()));*/ +} +void GuiWrapper::SignalIrcPlayerChanged(const string &/*oldNick*/, const string &/*newNick*/) +{ + /* myStartWindow->signalIrcPlayerChanged(QString::fromUtf8(oldNick.c_str()), QString::fromUtf8(newNick.c_str()));*/ +} +void GuiWrapper::SignalIrcPlayerKicked(const std::string &/*nickName*/, const std::string &/*byWhom*/, const std::string &/*reason*/) +{ + /*myStartWindow->signalIrcPlayerKicked(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(byWhom.c_str()), QString::fromUtf8(reason.c_str()));*/ +} +void GuiWrapper::SignalIrcPlayerLeft(const std::string &/*nickName*/) +{ + /*myStartWindow->signalIrcPlayerLeft(QString::fromUtf8(nickName.c_str()));*/ +} +void GuiWrapper::SignalIrcChatMsg(const std::string &/*nickName*/, const std::string &/*msg*/) +{ + /*myStartWindow->signalIrcChatMessage(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(msg.c_str()));*/ +} +void GuiWrapper::SignalIrcError(int /*errorCode*/) +{ + /*myStartWindow->signalIrcError(errorCode);*/ +} +void GuiWrapper::SignalIrcServerError(int /*errorCode*/) +{ + /*myStartWindow->signalIrcServerError(errorCode);*/ +} -void GuiWrapper::SignalLobbyPlayerJoined(unsigned playerId, const string &nickName) { myStartWindow->signalLobbyPlayerJoined(playerId, QString::fromUtf8(nickName.c_str())); } -void GuiWrapper::SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason) { myStartWindow->signalLobbyPlayerKicked(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(byWhom.c_str()), QString::fromUtf8(reason.c_str())); } -void GuiWrapper::SignalLobbyPlayerLeft(unsigned playerId) { myStartWindow->signalLobbyPlayerLeft(playerId); } +void GuiWrapper::SignalLobbyPlayerJoined(unsigned playerId, const string &nickName) +{ + myStartWindow->signalLobbyPlayerJoined(playerId, QString::fromUtf8(nickName.c_str())); +} +void GuiWrapper::SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason) +{ + myStartWindow->signalLobbyPlayerKicked(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(byWhom.c_str()), QString::fromUtf8(reason.c_str())); +} +void GuiWrapper::SignalLobbyPlayerLeft(unsigned playerId) +{ + myStartWindow->signalLobbyPlayerLeft(playerId); +} -void GuiWrapper::SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom) { myStartWindow->signalSelfGameInvitation(gameId, playerIdFrom); } -void GuiWrapper::SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom) { myStartWindow->signalPlayerGameInvitation(gameId, playerIdWho, playerIdFrom); } -void GuiWrapper::SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason) { myStartWindow->signalRejectedGameInvitation(gameId, playerIdWho, reason); } +void GuiWrapper::SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom) +{ + myStartWindow->signalSelfGameInvitation(gameId, playerIdFrom); +} +void GuiWrapper::SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom) +{ + myStartWindow->signalPlayerGameInvitation(gameId, playerIdWho, playerIdFrom); +} +void GuiWrapper::SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason) +{ + myStartWindow->signalRejectedGameInvitation(gameId, playerIdWho, reason); +} diff --git a/src/gui/qt/guiwrapper.h b/src/gui/qt/guiwrapper.h index 5fb0d6df..2f37e0f5 100644 --- a/src/gui/qt/guiwrapper.h +++ b/src/gui/qt/guiwrapper.h @@ -34,145 +34,149 @@ class ConfigFile; class GuiWrapper : public GuiInterface { public: - GuiWrapper(ConfigFile*, startWindowImpl*); + GuiWrapper(ConfigFile*, startWindowImpl*); - ~GuiWrapper(); + ~GuiWrapper(); - void initGui(int speed); + void initGui(int speed); - boost::shared_ptr getSession(); - void setSession(boost::shared_ptr session); + boost::shared_ptr getSession(); + void setSession(boost::shared_ptr session); - gameTableImpl* getMyW() const { return myW; } - guiLog* getMyGuiLog() const { return myGuiLog; } + gameTableImpl* getMyW() const { + return myW; + } + guiLog* getMyGuiLog() const { + return myGuiLog; + } - void refreshSet() const; - void refreshCash() const; - void refreshAction(int =-1, int =-1) const; - void refreshChangePlayer() const; - void refreshPot() const; - void refreshGroupbox(int =-1, int =-1) const; - void refreshAll() const; - void refreshPlayerName() const; - void refreshButton() const; - void refreshGameLabels(GameState state) const; + void refreshSet() const; + void refreshCash() const; + void refreshAction(int =-1, int =-1) const; + void refreshChangePlayer() const; + void refreshPot() const; + void refreshGroupbox(int =-1, int =-1) const; + void refreshAll() const; + void refreshPlayerName() const; + void refreshButton() const; + void refreshGameLabels(GameState state) const; - void setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const; + void setPlayerAvatar(int myUniqueID, const std::string &myAvatar) const; - void waitForGuiUpdateDone() const; + void waitForGuiUpdateDone() const; - void dealBeRoCards(int myBeRoID); - void dealHoleCards(); - void dealFlopCards(); - void dealTurnCard(); - void dealRiverCard(); + void dealBeRoCards(int myBeRoID); + void dealHoleCards(); + void dealFlopCards(); + void dealTurnCard(); + void dealRiverCard(); - void nextPlayerAnimation(); + void nextPlayerAnimation(); - void beRoAnimation2(int); + void beRoAnimation2(int); - void preflopAnimation1(); - void preflopAnimation2(); + void preflopAnimation1(); + void preflopAnimation2(); - void flopAnimation1(); - void flopAnimation2(); + void flopAnimation1(); + void flopAnimation2(); - void turnAnimation1(); - void turnAnimation2(); + void turnAnimation1(); + void turnAnimation2(); - void riverAnimation1(); - void riverAnimation2(); + void riverAnimation1(); + void riverAnimation2(); - void postRiverAnimation1(); - void postRiverRunAnimation1(); + void postRiverAnimation1(); + void postRiverRunAnimation1(); - void flipHolecardsAllIn(); + void flipHolecardsAllIn(); - void nextRoundCleanGui(); + void nextRoundCleanGui(); - void meInAction(); - void disableMyButtons(); - void updateMyButtonsState(); - void startTimeoutAnimation(int playerNum, int timeoutSec); - void stopTimeoutAnimation(int playerNum); + void meInAction(); + void disableMyButtons(); + void updateMyButtonsState(); + void startTimeoutAnimation(int playerNum, int timeoutSec); + void stopTimeoutAnimation(int playerNum); - void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick); - void changeVoteOnKickButtonsState(bool showHide); - void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick); - void endVoteOnKick(); + void startVoteOnKick(unsigned playerId, unsigned voteStarterPlayerId, int timeoutSec, int numVotesNeededToKick); + void changeVoteOnKickButtonsState(bool showHide); + void refreshVotesMonitor(int currentVotes, int numVotesNeededToKick); + void endVoteOnKick(); - void logPlayerActionMsg(std::string playerName, int playerID, int action, int setValue) ; - void logNewGameHandMsg(int gameID, int handID) ; - void logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName); - void logPlayerWinsMsg(std::string playerName, int pot, bool main); - void logPlayerSitsOut(std::string playerName); - void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1); - void logFlipHoleCardsMsg(std::string playerName, int playerID, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows"); - void logPlayerWinGame(std::string playerName, int gameID); - void flushLogAtGame(int gameID); - void flushLogAtHand(); + void logPlayerActionMsg(std::string playerName, int playerID, int action, int setValue) ; + void logNewGameHandMsg(int gameID, int handID) ; + void logNewBlindsSetsMsg(int sbSet, int bbSet, std::string sbName, std::string bbName); + void logPlayerWinsMsg(std::string playerName, int pot, bool main); + void logPlayerSitsOut(std::string playerName); + void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1); + void logFlipHoleCardsMsg(std::string playerName, int playerID, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows"); + void logPlayerWinGame(std::string playerName, int gameID); + void flushLogAtGame(int gameID); + void flushLogAtHand(); - void SignalNetClientConnect(int actionID); - void SignalNetClientServerListAdd(unsigned serverId); - void SignalNetClientServerListShow(); - void SignalNetClientServerListClear(); - void SignalNetClientLoginShow(); - void SignalNetClientPostRiverShowCards(unsigned playerId); - void SignalNetClientGameInfo(int actionID); - void SignalNetClientError(int errorID, int osErrorID); - void SignalNetClientNotification(int notificationId); - void SignalNetClientStatsUpdate(const ServerStats &stats); - void SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec); - void SignalNetClientRemovedFromGame(int notificationId); - void SignalNetClientSelfJoined(unsigned playerId, const std::string &playerName, bool isGameAdmin); - void SignalNetClientPlayerJoined(unsigned playerId, const std::string &playerName, bool isGameAdmin); - void SignalNetClientPlayerChanged(unsigned playerId, const std::string &newPlayerName); - void SignalNetClientPlayerLeft(unsigned playerId, const std::string &playerName, int removeReason); - void SignalNetClientNewGameAdmin(unsigned playerId, const std::string &playerName); - void SignalNetClientGameChatMsg(const std::string &playerName, const std::string &msg); - void SignalNetClientLobbyChatMsg(const std::string &playerName, const std::string &msg); - void SignalNetClientMsgBox(const std::string &msg); - void SignalNetClientMsgBox(unsigned msgId); + void SignalNetClientConnect(int actionID); + void SignalNetClientServerListAdd(unsigned serverId); + void SignalNetClientServerListShow(); + void SignalNetClientServerListClear(); + void SignalNetClientLoginShow(); + void SignalNetClientPostRiverShowCards(unsigned playerId); + void SignalNetClientGameInfo(int actionID); + void SignalNetClientError(int errorID, int osErrorID); + void SignalNetClientNotification(int notificationId); + void SignalNetClientStatsUpdate(const ServerStats &stats); + void SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec); + void SignalNetClientRemovedFromGame(int notificationId); + void SignalNetClientSelfJoined(unsigned playerId, const std::string &playerName, bool isGameAdmin); + void SignalNetClientPlayerJoined(unsigned playerId, const std::string &playerName, bool isGameAdmin); + void SignalNetClientPlayerChanged(unsigned playerId, const std::string &newPlayerName); + void SignalNetClientPlayerLeft(unsigned playerId, const std::string &playerName, int removeReason); + void SignalNetClientNewGameAdmin(unsigned playerId, const std::string &playerName); + void SignalNetClientGameChatMsg(const std::string &playerName, const std::string &msg); + void SignalNetClientLobbyChatMsg(const std::string &playerName, const std::string &msg); + void SignalNetClientMsgBox(const std::string &msg); + void SignalNetClientMsgBox(unsigned msgId); - void SignalNetClientWaitDialog(); - void SignalNetClientWarningAutoFoldInRankingGame(unsigned remainingAutoFolds); + void SignalNetClientWaitDialog(); + void SignalNetClientWarningAutoFoldInRankingGame(unsigned remainingAutoFolds); - void SignalNetClientGameListNew(unsigned gameId); - void SignalNetClientGameListRemove(unsigned gameId); - void SignalNetClientGameListUpdateMode(unsigned gameId, GameMode mode); - void SignalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId); - void SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId); - void SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId); + void SignalNetClientGameListNew(unsigned gameId); + void SignalNetClientGameListRemove(unsigned gameId); + void SignalNetClientGameListUpdateMode(unsigned gameId, GameMode mode); + void SignalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId); + void SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId); + void SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId); - void SignalNetClientGameStart(boost::shared_ptr game); + void SignalNetClientGameStart(boost::shared_ptr game); - void SignalNetServerSuccess(int actionID); - void SignalNetServerError(int errorID, int osErrorID); + void SignalNetServerSuccess(int actionID); + void SignalNetServerError(int errorID, int osErrorID); - void SignalIrcConnect(const std::string &server); - void SignalIrcSelfJoined(const std::string &nickName, const std::string &channel); - void SignalIrcPlayerJoined(const std::string &nickName); - void SignalIrcPlayerChanged(const std::string &oldNick, const std::string &newNick); - void SignalIrcPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); - void SignalIrcPlayerLeft(const std::string &nickName); - void SignalIrcChatMsg(const std::string &nickName, const std::string &msg); - void SignalIrcError(int errorCode); - void SignalIrcServerError(int errorCode); - void SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName); - void SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); - void SignalLobbyPlayerLeft(unsigned playerId); + void SignalIrcConnect(const std::string &server); + void SignalIrcSelfJoined(const std::string &nickName, const std::string &channel); + void SignalIrcPlayerJoined(const std::string &nickName); + void SignalIrcPlayerChanged(const std::string &oldNick, const std::string &newNick); + void SignalIrcPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); + void SignalIrcPlayerLeft(const std::string &nickName); + void SignalIrcChatMsg(const std::string &nickName, const std::string &msg); + void SignalIrcError(int errorCode); + void SignalIrcServerError(int errorCode); + void SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName); + void SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason); + void SignalLobbyPlayerLeft(unsigned playerId); - void SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom); - void SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); - void SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); + void SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom); + void SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); + void SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); private: - guiLog *myGuiLog; - gameTableImpl *myW; - ConfigFile *myConfig; - startWindowImpl *myStartWindow; + guiLog *myGuiLog; + gameTableImpl *myW; + ConfigFile *myConfig; + startWindowImpl *myStartWindow; }; diff --git a/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.cpp b/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.cpp index 2897a263..1b893a8b 100644 --- a/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.cpp +++ b/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.cpp @@ -4,126 +4,124 @@ #include internetGameLoginDialogImpl::internetGameLoginDialogImpl(QWidget *parent, ConfigFile *c) : - QDialog(parent), myConfig(c){ - setupUi(this); + QDialog(parent), myConfig(c) +{ + setupUi(this); - connect(groupBox_reguser, SIGNAL(toggled(bool)), this, SLOT(regUserToggled(bool))); - connect(checkBox_guest, SIGNAL(toggled(bool)), this, SLOT(guestUserToggled(bool))); - connect(lineEdit_password, SIGNAL(textEdited(QString)), this, SLOT(okButtonCheck())); - connect(lineEdit_username, SIGNAL(textEdited(QString)), this, SLOT(okButtonCheck())); + connect(groupBox_reguser, SIGNAL(toggled(bool)), this, SLOT(regUserToggled(bool))); + connect(checkBox_guest, SIGNAL(toggled(bool)), this, SLOT(guestUserToggled(bool))); + connect(lineEdit_password, SIGNAL(textEdited(QString)), this, SLOT(okButtonCheck())); + connect(lineEdit_username, SIGNAL(textEdited(QString)), this, SLOT(okButtonCheck())); } -void internetGameLoginDialogImpl::regUserToggled(bool b) { +void internetGameLoginDialogImpl::regUserToggled(bool b) +{ - checkBox_guest->setChecked(!b); + checkBox_guest->setChecked(!b); - if(b) { - if(QString::fromUtf8(myConfig->readConfigString("MyRememberedNameDuringGuestLogin").c_str()).isEmpty()) { - lineEdit_username->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); - } - else { - lineEdit_username->setText(QString::fromUtf8(myConfig->readConfigString("MyRememberedNameDuringGuestLogin").c_str())); - } - if(myConfig->readConfigInt("InternetSavePassword")) { - checkBox_rememberPassword->setChecked(true); - lineEdit_password->setText(QString::fromUtf8(QByteArray::fromBase64(myConfig->readConfigString("InternetLoginPassword").c_str()))); - } - else { - checkBox_rememberPassword->setChecked(false); - lineEdit_password->clear(); - } - } + if(b) { + if(QString::fromUtf8(myConfig->readConfigString("MyRememberedNameDuringGuestLogin").c_str()).isEmpty()) { + lineEdit_username->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); + } else { + lineEdit_username->setText(QString::fromUtf8(myConfig->readConfigString("MyRememberedNameDuringGuestLogin").c_str())); + } + if(myConfig->readConfigInt("InternetSavePassword")) { + checkBox_rememberPassword->setChecked(true); + lineEdit_password->setText(QString::fromUtf8(QByteArray::fromBase64(myConfig->readConfigString("InternetLoginPassword").c_str()))); + } else { + checkBox_rememberPassword->setChecked(false); + lineEdit_password->clear(); + } + } - okButtonCheck(); + okButtonCheck(); } -void internetGameLoginDialogImpl::guestUserToggled(bool b) { +void internetGameLoginDialogImpl::guestUserToggled(bool b) +{ - groupBox_reguser->setChecked(!b); + groupBox_reguser->setChecked(!b); - if(b) { + if(b) { - if(!lineEdit_username->text().isEmpty()) { - myConfig->writeConfigString("MyRememberedNameDuringGuestLogin", lineEdit_username->text().toUtf8().constData()); - } - checkBox_rememberPassword->setChecked(false); - lineEdit_password->clear(); - lineEdit_username->clear(); + if(!lineEdit_username->text().isEmpty()) { + myConfig->writeConfigString("MyRememberedNameDuringGuestLogin", lineEdit_username->text().toUtf8().constData()); + } + checkBox_rememberPassword->setChecked(false); + lineEdit_password->clear(); + lineEdit_username->clear(); - myConfig->writeBuffer(); - } + myConfig->writeBuffer(); + } - okButtonCheck(); + okButtonCheck(); } -void internetGameLoginDialogImpl::exec() { +void internetGameLoginDialogImpl::exec() +{ - if(myConfig->readConfigInt("InternetLoginMode") == 0) { - groupBox_reguser->setChecked(true); - lineEdit_username->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); - if(myConfig->readConfigInt("InternetSavePassword")) { - checkBox_rememberPassword->setChecked(true); - lineEdit_password->setText(QString::fromUtf8(QByteArray::fromBase64(myConfig->readConfigString("InternetLoginPassword").c_str()))); - } - else { - checkBox_rememberPassword->setChecked(false); - lineEdit_password->clear(); - } - } - else { - checkBox_guest->setChecked(true); - } + if(myConfig->readConfigInt("InternetLoginMode") == 0) { + groupBox_reguser->setChecked(true); + lineEdit_username->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); + if(myConfig->readConfigInt("InternetSavePassword")) { + checkBox_rememberPassword->setChecked(true); + lineEdit_password->setText(QString::fromUtf8(QByteArray::fromBase64(myConfig->readConfigString("InternetLoginPassword").c_str()))); + } else { + checkBox_rememberPassword->setChecked(false); + lineEdit_password->clear(); + } + } else { + checkBox_guest->setChecked(true); + } - okButtonCheck(); + okButtonCheck(); - if(groupBox_reguser->isChecked() && !checkBox_rememberPassword->isChecked() && lineEdit_password->text().isEmpty()) { - lineEdit_password->setFocus(); - } + if(groupBox_reguser->isChecked() && !checkBox_rememberPassword->isChecked() && lineEdit_password->text().isEmpty()) { + lineEdit_password->setFocus(); + } - QDialog::exec(); + QDialog::exec(); } -void internetGameLoginDialogImpl::accept() { +void internetGameLoginDialogImpl::accept() +{ - if(groupBox_reguser->isChecked()) { - myConfig->writeConfigInt("InternetLoginMode", 0); - myConfig->writeConfigString("MyName", lineEdit_username->text().toUtf8().constData()); - if(checkBox_rememberPassword->isChecked()) { - myConfig->writeConfigInt("InternetSavePassword", 1); - myConfig->writeConfigString("InternetLoginPassword", lineEdit_password->text().toUtf8().toBase64().constData()); - } - else { - myConfig->writeConfigInt("InternetSavePassword", 0); - } + if(groupBox_reguser->isChecked()) { + myConfig->writeConfigInt("InternetLoginMode", 0); + myConfig->writeConfigString("MyName", lineEdit_username->text().toUtf8().constData()); + if(checkBox_rememberPassword->isChecked()) { + myConfig->writeConfigInt("InternetSavePassword", 1); + myConfig->writeConfigString("InternetLoginPassword", lineEdit_password->text().toUtf8().toBase64().constData()); + } else { + myConfig->writeConfigInt("InternetSavePassword", 0); + } - } - else if(checkBox_guest->isChecked()) { - myConfig->writeConfigInt("InternetLoginMode", 1); - // Generate a valid guest name. - QString guestName; - int guestId; - Tools::getRandNumber(1, 99999, 1, &guestId, false); - guestName.sprintf("Guest%05d", guestId); - myConfig->writeConfigString("MyName", guestName.toUtf8().constData()); - } + } else if(checkBox_guest->isChecked()) { + myConfig->writeConfigInt("InternetLoginMode", 1); + // Generate a valid guest name. + QString guestName; + int guestId; + Tools::getRandNumber(1, 99999, 1, &guestId, false); + guestName.sprintf("Guest%05d", guestId); + myConfig->writeConfigString("MyName", guestName.toUtf8().constData()); + } - myConfig->writeBuffer(); + myConfig->writeBuffer(); - QDialog::accept(); -} + QDialog::accept(); +} -void internetGameLoginDialogImpl::okButtonCheck() { +void internetGameLoginDialogImpl::okButtonCheck() +{ - if(groupBox_reguser->isChecked()) { - if(!lineEdit_password->text().isEmpty() && !lineEdit_username->text().isEmpty()) { - pushButton_login->setEnabled(true); - } - else { - pushButton_login->setEnabled(false); - } - } - else { - pushButton_login->setEnabled(true); - } + if(groupBox_reguser->isChecked()) { + if(!lineEdit_password->text().isEmpty() && !lineEdit_username->text().isEmpty()) { + pushButton_login->setEnabled(true); + } else { + pushButton_login->setEnabled(false); + } + } else { + pushButton_login->setEnabled(true); + } } diff --git a/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.h b/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.h index 57816adb..35036850 100644 --- a/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.h +++ b/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.h @@ -5,12 +5,13 @@ class ConfigFile; -class internetGameLoginDialogImpl : public QDialog, public Ui::internetGameLoginDialog { - Q_OBJECT - +class internetGameLoginDialogImpl : public QDialog, public Ui::internetGameLoginDialog +{ + Q_OBJECT + public: - internetGameLoginDialogImpl(QWidget *parent = 0, ConfigFile *c =0); - + internetGameLoginDialogImpl(QWidget *parent = 0, ConfigFile *c =0); + void exec(); void accept(); @@ -18,9 +19,9 @@ public slots: void regUserToggled(bool); void guestUserToggled(bool); void okButtonCheck(); - + private: - + ConfigFile *myConfig; }; diff --git a/src/gui/qt/joinnetworkgamedialog/joinnetworkgamedialogimpl.cpp b/src/gui/qt/joinnetworkgamedialog/joinnetworkgamedialogimpl.cpp index 9a123392..03d123db 100644 --- a/src/gui/qt/joinnetworkgamedialog/joinnetworkgamedialogimpl.cpp +++ b/src/gui/qt/joinnetworkgamedialog/joinnetworkgamedialogimpl.cpp @@ -26,26 +26,26 @@ using namespace std; joinNetworkGameDialogImpl::joinNetworkGameDialogImpl(QWidget *parent, ConfigFile *c) - : QDialog(parent), myConfig(c) + : QDialog(parent), myConfig(c) { #ifdef __APPLE__ setWindowModality(Qt::ApplicationModal); setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); -#endif +#endif setupUi(this); // QShortcut *connectKey = new QShortcut(QKeySequence(Qt::Key_Enter), this); // connect( connectKey, SIGNAL(activated() ), pushButton_connect, SLOT( click() ) ); - if (myConfig->readConfigInt("CLA_NoWriteAccess")) { + if (myConfig->readConfigInt("CLA_NoWriteAccess")) { pushButton_save->setDisabled(TRUE); pushButton_delete->setDisabled(TRUE); treeWidget->setDisabled(TRUE); } - connect( lineEdit_ipAddress, SIGNAL( editingFinished()), this, SLOT( checkIp() ) ); - connect( lineEdit_ipAddress, SIGNAL( textChanged(QString)), this, SLOT( connectButtonTest() ) ); + connect( lineEdit_ipAddress, SIGNAL( editingFinished()), this, SLOT( checkIp() ) ); + connect( lineEdit_ipAddress, SIGNAL( textChanged(QString)), this, SLOT( connectButtonTest() ) ); connect( pushButton_connect, SIGNAL( clicked() ), this, SLOT( startClient() ) ); connect( pushButton_save, SIGNAL( clicked() ), this, SLOT( saveServerProfile() ) ); @@ -55,7 +55,8 @@ joinNetworkGameDialogImpl::joinNetworkGameDialogImpl(QWidget *parent, ConfigFile } -void joinNetworkGameDialogImpl::exec() { +void joinNetworkGameDialogImpl::exec() +{ bool toIntTrue; @@ -63,35 +64,35 @@ void joinNetworkGameDialogImpl::exec() { //Profile Name darf nicht mit einer Zahl beginnen --> XML konform QRegExp rx("[A-Z|a-z]+[A-Z|a-z|\\d]*"); - QValidator *validator = new QRegExpValidator(rx, this); - lineEdit_profileName->setValidator(validator); + QValidator *validator = new QRegExpValidator(rx, this); + lineEdit_profileName->setValidator(validator); pushButton_delete->setDisabled(TRUE); lineEdit_ipAddress->setFocus(); - if (myConfig->readConfigInt("CLA_NoWriteAccess") == 0 ) { - //if discwrite-access + if (myConfig->readConfigInt("CLA_NoWriteAccess") == 0 ) { + //if discwrite-access myServerProfilesFile = myConfig->readConfigString("UserDataDir")+"serverprofiles.xml"; - + //Anlegen wenn noch nicht existiert! QFile serverProfilesfile(QString::fromUtf8(myServerProfilesFile.c_str())); - + if(!serverProfilesfile.exists()) { - - TiXmlDocument doc; - TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", ""); - doc.LinkEndChild( decl ); - - TiXmlElement * root = new TiXmlElement( "PokerTH" ); - doc.LinkEndChild( root ); - - TiXmlElement * profiles = new TiXmlElement( "ServerProfiles" ); - root->LinkEndChild( profiles ); - + + TiXmlDocument doc; + TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", ""); + doc.LinkEndChild( decl ); + + TiXmlElement * root = new TiXmlElement( "PokerTH" ); + doc.LinkEndChild( root ); + + TiXmlElement * profiles = new TiXmlElement( "ServerProfiles" ); + root->LinkEndChild( profiles ); + doc.SaveFile(QString::fromUtf8(myServerProfilesFile.c_str()).toStdString()); } - + //Liste Füllen fillServerProfileList(); } @@ -99,74 +100,82 @@ void joinNetworkGameDialogImpl::exec() { checkBox_ipv6->setEnabled(socket_has_ipv6()); checkBox_sctp->setEnabled(socket_has_sctp()); - connectButtonTest(); + connectButtonTest(); QDialog::exec(); - + } -void joinNetworkGameDialogImpl::startClient() { +void joinNetworkGameDialogImpl::startClient() +{ // TODO: Check input values! } -void joinNetworkGameDialogImpl::fillServerProfileList() { +void joinNetworkGameDialogImpl::fillServerProfileList() +{ + - treeWidget->clear(); - TiXmlDocument doc(QString::fromUtf8(myServerProfilesFile.c_str()).toStdString()); - if(!doc.LoadFile()) { + TiXmlDocument doc(QString::fromUtf8(myServerProfilesFile.c_str()).toStdString()); + if(!doc.LoadFile()) { QMessageBox::warning(this, tr("Load Server-Profile-File Error"), - tr("Could not load server-profiles-file:\n"+QString::fromUtf8(myServerProfilesFile.c_str()).toAscii()), - QMessageBox::Close); + tr("Could not load server-profiles-file:\n"+QString::fromUtf8(myServerProfilesFile.c_str()).toAscii()), + QMessageBox::Close); } - TiXmlHandle docHandle( &doc ); + TiXmlHandle docHandle( &doc ); TiXmlElement* profile = docHandle.FirstChild( "PokerTH" ).FirstChild( "ServerProfiles" ).FirstChild().ToElement(); if ( profile ) { for( ; profile; profile = profile->NextSiblingElement()) { - + QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget,0); item->setData(0, 0, QString::fromUtf8(profile->Attribute("Name"))); item->setData(1, 0, QString::fromUtf8(profile->Attribute("Address"))); item->setData(2, 0, profile->Attribute("Port")); - + string isIpv6 = "no"; int tempInt = 0; profile->QueryIntAttribute("IsIpv6", &tempInt ); - if( tempInt == 1 ) { isIpv6 = "yes"; } + if( tempInt == 1 ) { + isIpv6 = "yes"; + } item->setData(3, 0, QString::fromUtf8(isIpv6.c_str())); - + string isSctp = "no"; int tempInt1 = 0; profile->QueryIntAttribute("IsSctp", &tempInt1 ); - if( tempInt1 == 1 ) { isSctp = "yes"; } + if( tempInt1 == 1 ) { + isSctp = "yes"; + } item->setData(4, 0, QString::fromUtf8(isSctp.c_str())); treeWidget->addTopLevelItem(item); } - } - else { cout << "No Profiles Found \n"; } + } else { + cout << "No Profiles Found \n"; + } - treeWidget->resizeColumnToContents ( 0 ); + treeWidget->resizeColumnToContents ( 0 ); treeWidget->resizeColumnToContents ( 1 ); treeWidget->resizeColumnToContents ( 2 ); treeWidget->resizeColumnToContents ( 3 ); } -void joinNetworkGameDialogImpl::itemFillForm (QTreeWidgetItem* item, int /*column*/) { +void joinNetworkGameDialogImpl::itemFillForm (QTreeWidgetItem* item, int /*column*/) +{ bool toIntTrue; - TiXmlDocument doc(QString::fromUtf8(myServerProfilesFile.c_str()).toStdString()); - if(!doc.LoadFile()) { + TiXmlDocument doc(QString::fromUtf8(myServerProfilesFile.c_str()).toStdString()); + if(!doc.LoadFile()) { QMessageBox::warning(this, tr("Load Server-Profile-File Error"), - tr("Could not load server-profiles-file:\n"+QString::fromUtf8(myServerProfilesFile.c_str()).toAscii()), - QMessageBox::Close); + tr("Could not load server-profiles-file:\n"+QString::fromUtf8(myServerProfilesFile.c_str()).toAscii()), + QMessageBox::Close); } - TiXmlHandle docHandle( &doc ); + TiXmlHandle docHandle( &doc ); TiXmlElement* profile = docHandle.FirstChild( "PokerTH" ).FirstChild( "ServerProfiles" ).FirstChild( item->data(0,0).toString().toStdString() ).ToElement(); if ( profile ) { @@ -182,53 +191,53 @@ void joinNetworkGameDialogImpl::itemFillForm (QTreeWidgetItem* item, int /*colum pushButton_delete->setEnabled(TRUE); } -void joinNetworkGameDialogImpl::saveServerProfile() { +void joinNetworkGameDialogImpl::saveServerProfile() +{ // bool toIntTrue; - TiXmlDocument doc(QString::fromUtf8(myServerProfilesFile.c_str()).toStdString()); - if(!doc.LoadFile()) { + TiXmlDocument doc(QString::fromUtf8(myServerProfilesFile.c_str()).toStdString()); + if(!doc.LoadFile()) { QMessageBox::warning(this, tr("Load Server-Profile-File Error"), - tr("Could not load server-profiles-file:\n"+QString::fromUtf8(myServerProfilesFile.c_str()).toAscii()), - QMessageBox::Close); + tr("Could not load server-profiles-file:\n"+QString::fromUtf8(myServerProfilesFile.c_str()).toAscii()), + QMessageBox::Close); } - TiXmlHandle docHandle( &doc ); + TiXmlHandle docHandle( &doc ); TiXmlElement* profiles = docHandle.FirstChild( "PokerTH" ).FirstChild( "ServerProfiles" ).ToElement(); if ( profiles ) { - TiXmlElement * testProfile = docHandle.FirstChild( "PokerTH" ).FirstChild( "ServerProfiles" ).FirstChild( lineEdit_profileName->text().toStdString() ).ToElement(); - + TiXmlElement * testProfile = docHandle.FirstChild( "PokerTH" ).FirstChild( "ServerProfiles" ).FirstChild( lineEdit_profileName->text().toStdString() ).ToElement(); + if( testProfile ) { // Wenn der Name schon existiert --> Überschreiben? QMessageBox msgBox(QMessageBox::Warning, tr("Save Server Profile Error"), - QString(tr("A profile with the name: %1 already exists.\nWould you like to overwrite ?")).arg(lineEdit_profileName->text()), QMessageBox::Yes | QMessageBox::No, this); + QString(tr("A profile with the name: %1 already exists.\nWould you like to overwrite ?")).arg(lineEdit_profileName->text()), QMessageBox::Yes | QMessageBox::No, this); switch (msgBox.exec()) { - case QMessageBox::Yes: { - // yes was clicked - // remove the old - testProfile->Parent()->RemoveChild(testProfile); - // write the new - TiXmlElement * profile1 = new TiXmlElement( lineEdit_profileName->text().toUtf8().constData() ); - profiles->LinkEndChild( profile1 ); - profile1->SetAttribute("Name", lineEdit_profileName->text().toUtf8().constData()); - profile1->SetAttribute("Address", lineEdit_ipAddress->text().toUtf8().constData()); - profile1->SetAttribute("Port", spinBox_port->value()); - profile1->SetAttribute("IsIpv6", checkBox_ipv6->isChecked()); - profile1->SetAttribute("IsSctp", checkBox_sctp->isChecked()); - } - break; - case QMessageBox::No: + case QMessageBox::Yes: { + // yes was clicked + // remove the old + testProfile->Parent()->RemoveChild(testProfile); + // write the new + TiXmlElement * profile1 = new TiXmlElement( lineEdit_profileName->text().toUtf8().constData() ); + profiles->LinkEndChild( profile1 ); + profile1->SetAttribute("Name", lineEdit_profileName->text().toUtf8().constData()); + profile1->SetAttribute("Address", lineEdit_ipAddress->text().toUtf8().constData()); + profile1->SetAttribute("Port", spinBox_port->value()); + profile1->SetAttribute("IsIpv6", checkBox_ipv6->isChecked()); + profile1->SetAttribute("IsSctp", checkBox_sctp->isChecked()); + } + break; + case QMessageBox::No: // no was clicked break; - default: + default: // should never be reached break; } - - } - else { + + } else { // Wenn der Name nicht existiert --> speichern TiXmlElement * profile2 = new TiXmlElement( lineEdit_profileName->text().toStdString() ); profiles->LinkEndChild( profile2 ); @@ -237,65 +246,76 @@ void joinNetworkGameDialogImpl::saveServerProfile() { profile2->SetAttribute("Port", spinBox_port->value()); profile2->SetAttribute("IsIpv6", checkBox_ipv6->isChecked()); profile2->SetAttribute("IsSctp", checkBox_sctp->isChecked()); - - } - } - else { QMessageBox::warning(this, tr("Read Server-Profile List Error"), - tr("Could not read server-profiles list"), - QMessageBox::Close); } - if(!doc.SaveFile()) { QMessageBox::warning(this, tr("Save Server-Profile-File Error"), - tr("Could not save server-profiles-file:\n"+QString::fromUtf8(myServerProfilesFile.c_str()).toAscii()), - QMessageBox::Close); } + } + } else { + QMessageBox::warning(this, tr("Read Server-Profile List Error"), + tr("Could not read server-profiles list"), + QMessageBox::Close); + } + + if(!doc.SaveFile()) { + QMessageBox::warning(this, tr("Save Server-Profile-File Error"), + tr("Could not save server-profiles-file:\n"+QString::fromUtf8(myServerProfilesFile.c_str()).toAscii()), + QMessageBox::Close); + } fillServerProfileList(); } -void joinNetworkGameDialogImpl::deleteServerProfile() { +void joinNetworkGameDialogImpl::deleteServerProfile() +{ - TiXmlDocument doc(QString::fromUtf8(myServerProfilesFile.c_str()).toStdString()); - if(!doc.LoadFile()) { + TiXmlDocument doc(QString::fromUtf8(myServerProfilesFile.c_str()).toStdString()); + if(!doc.LoadFile()) { QMessageBox::warning(this, tr("Load Server-Profile-File Error"), - tr("Could not load server-profiles-file:\n"+QString::fromUtf8(myServerProfilesFile.c_str()).toAscii()), - QMessageBox::Close); - } - else { - TiXmlHandle docHandle( &doc ); - + tr("Could not load server-profiles-file:\n"+QString::fromUtf8(myServerProfilesFile.c_str()).toAscii()), + QMessageBox::Close); + } else { + TiXmlHandle docHandle( &doc ); + TiXmlElement* profile = docHandle.FirstChild( "PokerTH" ).FirstChild( "ServerProfiles" ).FirstChild( treeWidget->currentItem()->data(0,0).toString().toUtf8().constData() ).ToElement(); - - if ( profile ) { profile->Parent()->RemoveChild(profile); } - - if(!doc.SaveFile()) { QMessageBox::warning(this, tr("Save Server-Profile-File Error"), - tr("Could not save server-profiles-file:\n"+QString::fromUtf8(myServerProfilesFile.c_str()).toAscii()), - QMessageBox::Close); } + + if ( profile ) { + profile->Parent()->RemoveChild(profile); + } + + if(!doc.SaveFile()) { + QMessageBox::warning(this, tr("Save Server-Profile-File Error"), + tr("Could not save server-profiles-file:\n"+QString::fromUtf8(myServerProfilesFile.c_str()).toAscii()), + QMessageBox::Close); + } //Liste Füllen fillServerProfileList(); } - + pushButton_delete->setDisabled(TRUE); } -void joinNetworkGameDialogImpl::keyPressEvent ( QKeyEvent * event ) { +void joinNetworkGameDialogImpl::keyPressEvent ( QKeyEvent * event ) +{ // std::cout << "key" << event->key(); - if (event->key() == 16777220) { pushButton_connect->click(); } //ENTER + if (event->key() == 16777220) { + pushButton_connect->click(); //ENTER + } } -void joinNetworkGameDialogImpl::checkIp() { - +void joinNetworkGameDialogImpl::checkIp() +{ + //remove whitespaces QString tmp = lineEdit_ipAddress->text(); lineEdit_ipAddress->setText(tmp.remove(" ")); } -void joinNetworkGameDialogImpl::connectButtonTest() { +void joinNetworkGameDialogImpl::connectButtonTest() +{ - if(lineEdit_ipAddress->text().isEmpty()) { - pushButton_connect->setDisabled(TRUE); - } - else { - pushButton_connect->setDisabled(FALSE); - } + if(lineEdit_ipAddress->text().isEmpty()) { + pushButton_connect->setDisabled(TRUE); + } else { + pushButton_connect->setDisabled(FALSE); + } } diff --git a/src/gui/qt/joinnetworkgamedialog/joinnetworkgamedialogimpl.h b/src/gui/qt/joinnetworkgamedialog/joinnetworkgamedialogimpl.h index 251f116a..11491960 100644 --- a/src/gui/qt/joinnetworkgamedialog/joinnetworkgamedialogimpl.h +++ b/src/gui/qt/joinnetworkgamedialog/joinnetworkgamedialogimpl.h @@ -30,10 +30,11 @@ class Session; class ConfigFile; -class joinNetworkGameDialogImpl: public QDialog, public Ui::joinNetworkGameDialog { -Q_OBJECT +class joinNetworkGameDialogImpl: public QDialog, public Ui::joinNetworkGameDialog +{ + Q_OBJECT public: - joinNetworkGameDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); + joinNetworkGameDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); ConfigFile *myConfig; std::string myServerProfilesFile; @@ -49,7 +50,7 @@ public slots: void deleteServerProfile(); void keyPressEvent ( QKeyEvent * event ); void checkIp(); - void connectButtonTest(); + void connectButtonTest(); }; #endif diff --git a/src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp b/src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp index 74ec1a01..bd48dbce 100644 --- a/src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp +++ b/src/gui/qt/mymessagedialog/mymessagedialogimpl.cpp @@ -30,114 +30,114 @@ using namespace std; myMessageDialogImpl::myMessageDialogImpl(ConfigFile *c, QWidget *parent) - : QDialog(parent), myConfig(c), currentMsgId(0) + : QDialog(parent), myConfig(c), currentMsgId(0) { #ifdef __APPLE__ - setWindowModality(Qt::ApplicationModal); - setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); -#endif - setupUi(this); + setWindowModality(Qt::ApplicationModal); + setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); +#endif + setupUi(this); } int myMessageDialogImpl::exec(int messageId, QString msg, QString title, QPixmap pix, QDialogButtonBox::StandardButtons buttons, bool showCheckBox) { - if(showCheckBox) checkBox->show(); - else checkBox->hide(); + if(showCheckBox) checkBox->show(); + else checkBox->hide(); - bool show = false; - bool found = false; + bool show = false; + bool found = false; - currentMsgId = messageId; + currentMsgId = messageId; - currentMsgShowList = myConfig->readConfigStringList("IfInfoMessageShowList"); - list::iterator it1; + currentMsgShowList = myConfig->readConfigStringList("IfInfoMessageShowList"); + list::iterator it1; for(it1= currentMsgShowList.begin(); it1 != currentMsgShowList.end(); ++it1) { - QString tmpString = QString::fromUtf8(it1->c_str()); - if(QString("%1").arg(messageId) == tmpString.split(",").at(1)) { + QString tmpString = QString::fromUtf8(it1->c_str()); + if(QString("%1").arg(messageId) == tmpString.split(",").at(1)) { - found = true; - show = tmpString.split(",").at(0).toInt(); + found = true; + show = tmpString.split(",").at(0).toInt(); - break; - } - } + break; + } + } - if(!found) { - currentMsgShowList.push_back(QString("1,%1").arg(messageId).toUtf8().constData()); - myConfig->writeConfigStringList("IfInfoMessageShowList", currentMsgShowList); - myConfig->writeBuffer(); - } + if(!found) { + currentMsgShowList.push_back(QString("1,%1").arg(messageId).toUtf8().constData()); + myConfig->writeConfigStringList("IfInfoMessageShowList", currentMsgShowList); + myConfig->writeBuffer(); + } - if(!found || show) { + if(!found || show) { - setWindowTitle(title); - label_icon->setPixmap(pix.scaled(50,50,Qt::KeepAspectRatio,Qt::SmoothTransformation)); - label->setText(msg); - buttonBox->setStandardButtons(buttons); + setWindowTitle(title); + label_icon->setPixmap(pix.scaled(50,50,Qt::KeepAspectRatio,Qt::SmoothTransformation)); + label->setText(msg); + buttonBox->setStandardButtons(buttons); - return QDialog::exec(); - } + return QDialog::exec(); + } - return -1; + return -1; } void myMessageDialogImpl::accept() { - writeConfig(); - QDialog::accept(); + writeConfig(); + QDialog::accept(); } void myMessageDialogImpl::reject() { - writeConfig(); - QDialog::reject(); + writeConfig(); + QDialog::reject(); } void myMessageDialogImpl::writeConfig() { - if(checkBox->isChecked()) { + if(checkBox->isChecked()) { - list::iterator it1; + list::iterator it1; for(it1= currentMsgShowList.begin(); it1 != currentMsgShowList.end(); ++it1) { - QString tmpString = QString::fromUtf8(it1->c_str()); - if(QString("%1").arg(currentMsgId) == tmpString.split(",").at(1)) { + QString tmpString = QString::fromUtf8(it1->c_str()); + if(QString("%1").arg(currentMsgId) == tmpString.split(",").at(1)) { - (*it1) = QString("0,%1").arg(currentMsgId).toUtf8().constData(); - break; - } - } + (*it1) = QString("0,%1").arg(currentMsgId).toUtf8().constData(); + break; + } + } - myConfig->writeConfigStringList("IfInfoMessageShowList", currentMsgShowList); - myConfig->writeBuffer(); - } + myConfig->writeConfigStringList("IfInfoMessageShowList", currentMsgShowList); + myConfig->writeBuffer(); + } } bool myMessageDialogImpl::checkIfMesssageWillBeDisplayed(int id) { - bool found = false; - bool show = true; + bool found = false; + bool show = true; - currentMsgShowList = myConfig->readConfigStringList("IfInfoMessageShowList"); - list::iterator it1; + currentMsgShowList = myConfig->readConfigStringList("IfInfoMessageShowList"); + list::iterator it1; for(it1= currentMsgShowList.begin(); it1 != currentMsgShowList.end(); ++it1) { - QString tmpString = QString::fromUtf8(it1->c_str()); - if(QString("%1").arg(id) == tmpString.split(",").at(1)) { + QString tmpString = QString::fromUtf8(it1->c_str()); + if(QString("%1").arg(id) == tmpString.split(",").at(1)) { - found = true; - show = tmpString.split(",").at(0).toInt(); + found = true; + show = tmpString.split(",").at(0).toInt(); - break; - } - } + break; + } + } - if(!found) { - currentMsgShowList.push_back(QString("1,%1").arg(id).toUtf8().constData()); - myConfig->writeConfigStringList("IfInfoMessageShowList", currentMsgShowList); - myConfig->writeBuffer(); - } + if(!found) { + currentMsgShowList.push_back(QString("1,%1").arg(id).toUtf8().constData()); + myConfig->writeConfigStringList("IfInfoMessageShowList", currentMsgShowList); + myConfig->writeBuffer(); + } - return show; + return show; } diff --git a/src/gui/qt/mymessagedialog/mymessagedialogimpl.h b/src/gui/qt/mymessagedialog/mymessagedialogimpl.h index 85f6cccb..696267d2 100644 --- a/src/gui/qt/mymessagedialog/mymessagedialogimpl.h +++ b/src/gui/qt/mymessagedialog/mymessagedialogimpl.h @@ -24,25 +24,26 @@ class ConfigFile; -class myMessageDialogImpl: public QDialog, public Ui::myMessageDialog { -Q_OBJECT +class myMessageDialogImpl: public QDialog, public Ui::myMessageDialog +{ + Q_OBJECT public: - myMessageDialogImpl(ConfigFile *, QWidget *parent = 0); + myMessageDialogImpl(ConfigFile *, QWidget *parent = 0); public slots: - bool checkIfMesssageWillBeDisplayed(int id); - int exec(int messageId, QString msg, QString title, QPixmap pix, QDialogButtonBox::StandardButtons buttons, bool showCheckBox = false); - void accept(); - void reject(); - void writeConfig(); + bool checkIfMesssageWillBeDisplayed(int id); + int exec(int messageId, QString msg, QString title, QPixmap pix, QDialogButtonBox::StandardButtons buttons, bool showCheckBox = false); + void accept(); + void reject(); + void writeConfig(); private: - ConfigFile *myConfig; - int currentMsgId; - std::list currentMsgShowList; + ConfigFile *myConfig; + int currentMsgId; + std::list currentMsgShowList; }; diff --git a/src/gui/qt/newlocalgamedialog/newgamedialogimpl.cpp b/src/gui/qt/newlocalgamedialog/newgamedialogimpl.cpp index 2faa5f68..3ce66259 100755 --- a/src/gui/qt/newlocalgamedialog/newgamedialogimpl.cpp +++ b/src/gui/qt/newlocalgamedialog/newgamedialogimpl.cpp @@ -22,21 +22,22 @@ #include "configfile.h" newGameDialogImpl::newGameDialogImpl(QMainWindow *parent, ConfigFile *c) - : QDialog(parent), myConfig(c) + : QDialog(parent), myConfig(c) { #ifdef __APPLE__ setWindowModality(Qt::ApplicationModal); setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); -#endif - setupUi(this); - +#endif + setupUi(this); + myChangeCompleteBlindsDialog = new changeCompleteBlindsDialogImpl; connect( radioButton_changeBlindsSettings, SIGNAL( clicked(bool) ), this, SLOT( callChangeBlindsDialog(bool) ) ); - + } -void newGameDialogImpl::exec() { +void newGameDialogImpl::exec() +{ spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NumberOfPlayers")); spinBox_startCash->setValue(myConfig->readConfigInt("StartCash")); @@ -56,22 +57,23 @@ void newGameDialogImpl::exec() { std::list myBlindsList = myConfig->readConfigIntList("ManualBlindsList"); std::list::iterator it1; - + for(it1= myBlindsList.begin(); it1 != myBlindsList.end(); ++it1) { myChangeCompleteBlindsDialog->listWidget_blinds->addItem(QString::number(*it1,10)); } myChangeCompleteBlindsDialog->sortBlindsList(); - + myChangeCompleteBlindsDialog->radioButton_afterThisAlwaysDoubleBlinds->setChecked(myConfig->readConfigInt("AfterMBAlwaysDoubleBlinds")); myChangeCompleteBlindsDialog->radioButton_afterThisAlwaysRaiseAbout->setChecked(myConfig->readConfigInt("AfterMBAlwaysRaiseAbout")); myChangeCompleteBlindsDialog->spinBox_afterThisAlwaysRaiseValue->setValue(myConfig->readConfigInt("AfterMBAlwaysRaiseValue")); myChangeCompleteBlindsDialog->radioButton_afterThisStayAtLastBlind->setChecked(myConfig->readConfigInt("AfterMBStayAtLastBlind")); QDialog::exec(); - + } -void newGameDialogImpl::callChangeBlindsDialog(bool show) { +void newGameDialogImpl::callChangeBlindsDialog(bool show) +{ if(show) { myChangeCompleteBlindsDialog->exec(); diff --git a/src/gui/qt/newlocalgamedialog/newgamedialogimpl.h b/src/gui/qt/newlocalgamedialog/newgamedialogimpl.h index 3e97ac08..188817e8 100755 --- a/src/gui/qt/newlocalgamedialog/newgamedialogimpl.h +++ b/src/gui/qt/newlocalgamedialog/newgamedialogimpl.h @@ -29,21 +29,24 @@ class ConfigFile; class changeCompleteBlindsDialogImpl; -class newGameDialogImpl: public QDialog, public Ui::newGameDialog { -Q_OBJECT +class newGameDialogImpl: public QDialog, public Ui::newGameDialog +{ + Q_OBJECT public: - newGameDialogImpl(QMainWindow *parent = 0, ConfigFile* = 0); + newGameDialogImpl(QMainWindow *parent = 0, ConfigFile* = 0); void exec(); - changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() { return myChangeCompleteBlindsDialog; } + changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() { + return myChangeCompleteBlindsDialog; + } public slots: void callChangeBlindsDialog(bool); private: - - ConfigFile *myConfig; + + ConfigFile *myConfig; changeCompleteBlindsDialogImpl *myChangeCompleteBlindsDialog; }; diff --git a/src/gui/qt/qttools/nonqttoolswrapper.cpp b/src/gui/qt/qttools/nonqttoolswrapper.cpp index 3679b2bb..830705af 100644 --- a/src/gui/qt/qttools/nonqttoolswrapper.cpp +++ b/src/gui/qt/qttools/nonqttoolswrapper.cpp @@ -44,8 +44,20 @@ NonQtToolsWrapper::~NonQtToolsWrapper() myQtHelper = 0; } -std::string NonQtToolsWrapper::stringToUtf8(const std::string &myString) { return myQtHelper->stringToUtf8(myString); } -std::string NonQtToolsWrapper::stringFromUtf8(const std::string &myString) { return myQtHelper->stringFromUtf8(myString); } -std::string NonQtToolsWrapper::getDefaultLanguage() { return myQtHelper->getDefaultLanguage(); } -std::string NonQtToolsWrapper::getDataPathStdString(const char * argv0) { return myQtHelper->getDataPathStdString(argv0); } +std::string NonQtToolsWrapper::stringToUtf8(const std::string &myString) +{ + return myQtHelper->stringToUtf8(myString); +} +std::string NonQtToolsWrapper::stringFromUtf8(const std::string &myString) +{ + return myQtHelper->stringFromUtf8(myString); +} +std::string NonQtToolsWrapper::getDefaultLanguage() +{ + return myQtHelper->getDefaultLanguage(); +} +std::string NonQtToolsWrapper::getDataPathStdString(const char * argv0) +{ + return myQtHelper->getDataPathStdString(argv0); +} diff --git a/src/gui/qt/qttools/nonqttoolswrapper.h b/src/gui/qt/qttools/nonqttoolswrapper.h index cd9d6068..2ac943ad 100644 --- a/src/gui/qt/qttools/nonqttoolswrapper.h +++ b/src/gui/qt/qttools/nonqttoolswrapper.h @@ -37,10 +37,10 @@ public: std::string getDefaultLanguage(); std::string getDataPathStdString(const char *argv0); -private: - +private: + NonQtHelper *myQtHelper; - + }; #endif diff --git a/src/gui/qt/qttools/qthelper/qthelper.cpp b/src/gui/qt/qttools/qthelper/qthelper.cpp index be21ebc8..f5a54c3f 100644 --- a/src/gui/qt/qttools/qthelper/qthelper.cpp +++ b/src/gui/qt/qttools/qthelper/qthelper.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: qthelper // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -23,35 +23,42 @@ QtHelper::~QtHelper() { } -std::string QtHelper::stringToUtf8(const std::string &myString) { +std::string QtHelper::stringToUtf8(const std::string &myString) +{ QString tmpString = QString::fromLocal8Bit(myString.c_str()); std::string myUtf8String = tmpString.toUtf8().constData(); - + return myUtf8String; } -std::string QtHelper::stringFromUtf8(const std::string &myString) { +std::string QtHelper::stringFromUtf8(const std::string &myString) +{ QString tmpString = QString::fromUtf8(myString.c_str()); - + return tmpString.toLocal8Bit().constData(); } -std::string QtHelper::getDefaultLanguage() { return QLocale::system().name().toStdString(); } +std::string QtHelper::getDefaultLanguage() +{ + return QLocale::system().name().toStdString(); +} std::string QtHelper::getDataPathStdString(const char * /*argv0*/) { QString path(QCoreApplication::instance()->applicationDirPath()); - -#ifdef _WIN32 + +#ifdef _WIN32 path += "/data/"; #else - #ifdef __APPLE__ +#ifdef __APPLE__ if (QRegExp("Contents/MacOS/?$").indexIn(path) != -1) { // pointing into an macosx application bundle path += "/../Resources/data/"; - } else { path += "/data/"; } - #else //Unix + } else { + path += "/data/"; + } +#else //Unix if (QRegExp("pokerth/?$").indexIn(path) != -1) { // there is an own application directory path += "/data/"; @@ -64,9 +71,11 @@ std::string QtHelper::getDataPathStdString(const char * /*argv0*/) } else if (QRegExp("bin/?$").indexIn(path) != -1) { // we are in a bin directory. e.g. /usr/bin path += "/../share/pokerth/data/"; - - } else { path += "/data/"; } - #endif + + } else { + path += "/data/"; + } +#endif #endif return (QDir::cleanPath(path) + "/").toStdString(); } diff --git a/src/gui/qt/qttools/qthelper/qthelper.h b/src/gui/qt/qttools/qthelper/qthelper.h index 8a14483b..018eb6c2 100644 --- a/src/gui/qt/qttools/qthelper/qthelper.h +++ b/src/gui/qt/qttools/qthelper/qthelper.h @@ -1,7 +1,7 @@ // // C++ Interface: qthelper // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 diff --git a/src/gui/qt/qttools/qttoolswrapper.cpp b/src/gui/qt/qttools/qttoolswrapper.cpp index 3dd5dd21..1f5996b3 100644 --- a/src/gui/qt/qttools/qttoolswrapper.cpp +++ b/src/gui/qt/qttools/qttoolswrapper.cpp @@ -44,8 +44,20 @@ QtToolsWrapper::~QtToolsWrapper() myQtHelper = 0; } -std::string QtToolsWrapper::stringToUtf8(const std::string &myString) { return myQtHelper->stringToUtf8(myString); } -std::string QtToolsWrapper::stringFromUtf8(const std::string &myString) { return myQtHelper->stringFromUtf8(myString); } -std::string QtToolsWrapper::getDefaultLanguage() { return myQtHelper->getDefaultLanguage(); } -std::string QtToolsWrapper::getDataPathStdString(const char * argv0) { return myQtHelper->getDataPathStdString(argv0); } +std::string QtToolsWrapper::stringToUtf8(const std::string &myString) +{ + return myQtHelper->stringToUtf8(myString); +} +std::string QtToolsWrapper::stringFromUtf8(const std::string &myString) +{ + return myQtHelper->stringFromUtf8(myString); +} +std::string QtToolsWrapper::getDefaultLanguage() +{ + return myQtHelper->getDefaultLanguage(); +} +std::string QtToolsWrapper::getDataPathStdString(const char * argv0) +{ + return myQtHelper->getDataPathStdString(argv0); +} diff --git a/src/gui/qt/qttools/qttoolswrapper.h b/src/gui/qt/qttools/qttoolswrapper.h index 5fb5bce5..083ace02 100644 --- a/src/gui/qt/qttools/qttoolswrapper.h +++ b/src/gui/qt/qttools/qttoolswrapper.h @@ -29,19 +29,19 @@ class QtHelper; class QtToolsWrapper : public QtToolsInterface { public: - QtToolsWrapper(); + QtToolsWrapper(); - ~QtToolsWrapper(); + ~QtToolsWrapper(); std::string stringToUtf8(const std::string &myString); std::string stringFromUtf8(const std::string &myString); std::string getDefaultLanguage(); std::string getDataPathStdString(const char *argv0); -private: - +private: + QtHelper *myQtHelper; - + }; #endif diff --git a/src/gui/qt/serverlistdialog/serverlistdialogimpl.cpp b/src/gui/qt/serverlistdialog/serverlistdialogimpl.cpp index 61cf2162..d51e4fcd 100644 --- a/src/gui/qt/serverlistdialog/serverlistdialogimpl.cpp +++ b/src/gui/qt/serverlistdialog/serverlistdialogimpl.cpp @@ -25,23 +25,24 @@ #include "session.h" serverListDialogImpl::serverListDialogImpl(startWindowImpl *sw, QMainWindow *parent, ConfigFile *c) - : QDialog(parent), myConfig(c), mySw(sw) + : QDialog(parent), myConfig(c), mySw(sw) { #ifdef __APPLE__ setWindowModality(Qt::ApplicationModal); setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); -#endif - setupUi(this); - +#endif + setupUi(this); + connect( treeWidget_serverList, SIGNAL( itemDoubleClicked ( QTreeWidgetItem*, int) ), this, SLOT( connectToServer() )); connect( buttonBox, SIGNAL( accepted() ), this, SLOT( connectToServer() )); connect( buttonBox, SIGNAL( rejected() ), this, SLOT( closeNetworkClient() )); connect( this, SIGNAL( rejected() ), this, SLOT( closeNetworkClient() )); } -void serverListDialogImpl::exec() { +void serverListDialogImpl::exec() +{ - QDialog::exec(); + QDialog::exec(); } void serverListDialogImpl::clearList() @@ -70,7 +71,8 @@ void serverListDialogImpl::connectToServer() this->hide(); } -void serverListDialogImpl::closeNetworkClient() { +void serverListDialogImpl::closeNetworkClient() +{ mySw->getSession()->terminateNetworkClient(); mySw->getMyConnectToServerDialog()->reject(); diff --git a/src/gui/qt/serverlistdialog/serverlistdialogimpl.h b/src/gui/qt/serverlistdialog/serverlistdialogimpl.h index 88f9a46c..0c852a27 100644 --- a/src/gui/qt/serverlistdialog/serverlistdialogimpl.h +++ b/src/gui/qt/serverlistdialog/serverlistdialogimpl.h @@ -29,10 +29,11 @@ class ConfigFile; class startWindowImpl; -class serverListDialogImpl: public QDialog, public Ui::ServerListDialog { -Q_OBJECT +class serverListDialogImpl: public QDialog, public Ui::ServerListDialog +{ + Q_OBJECT public: - serverListDialogImpl(startWindowImpl *sw, QMainWindow *parent = 0, ConfigFile* = 0 ); + serverListDialogImpl(startWindowImpl *sw, QMainWindow *parent = 0, ConfigFile* = 0 ); public slots: @@ -43,8 +44,8 @@ public slots: void closeNetworkClient(); private: - - ConfigFile *myConfig; + + ConfigFile *myConfig; startWindowImpl *mySw; }; diff --git a/src/gui/qt/settingsdialog/manualblindsorderdialog/manualblindsorderdialogimpl.cpp b/src/gui/qt/settingsdialog/manualblindsorderdialog/manualblindsorderdialogimpl.cpp index 3e4e857c..70ce679b 100644 --- a/src/gui/qt/settingsdialog/manualblindsorderdialog/manualblindsorderdialogimpl.cpp +++ b/src/gui/qt/settingsdialog/manualblindsorderdialog/manualblindsorderdialogimpl.cpp @@ -23,64 +23,68 @@ manualBlindsOrderDialogImpl::manualBlindsOrderDialogImpl(QWidget *parent, ConfigFile *c) - : QDialog(parent), myConfig(c), settingsCorrect(TRUE) + : QDialog(parent), myConfig(c), settingsCorrect(TRUE) { #ifdef __APPLE__ setWindowModality(Qt::ApplicationModal); setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); -#endif +#endif setupUi(this); connect( pushButton_add, SIGNAL( clicked() ), this, SLOT( addBlindValueToList() ) ); connect( pushButton_delete, SIGNAL( clicked() ), this, SLOT( removeBlindFromList() ) ); - + } -void manualBlindsOrderDialogImpl::exec() { +void manualBlindsOrderDialogImpl::exec() +{ QDialog::exec(); } -void manualBlindsOrderDialogImpl::addBlindValueToList() { +void manualBlindsOrderDialogImpl::addBlindValueToList() +{ - if(listWidget_blinds->count() == 30) { + if(listWidget_blinds->count() == 30) { QMessageBox::warning(this, tr("Manual Blinds Order"), - tr("You cannot set more than 30 manual blinds."), - QMessageBox::Close); } - else { + tr("You cannot set more than 30 manual blinds."), + QMessageBox::Close); + } else { listWidget_blinds->addItem(QString::number(spinBox_input->value(),10)); sortBlindsList(); } } -void manualBlindsOrderDialogImpl::removeBlindFromList() { +void manualBlindsOrderDialogImpl::removeBlindFromList() +{ listWidget_blinds->takeItem(listWidget_blinds->currentRow()); sortBlindsList(); } -void manualBlindsOrderDialogImpl::sortBlindsList() { +void manualBlindsOrderDialogImpl::sortBlindsList() +{ int i; QList tempIntList; QStringList tempStringList; bool ok = TRUE; - + for(i=0; icount(); i++) { // std::cout << listWidget_blinds->item(i)->text().toInt(&ok,10) << "\n"; - tempIntList << listWidget_blinds->item(i)->text().toInt(&ok,10); + tempIntList << listWidget_blinds->item(i)->text().toInt(&ok,10); } qStableSort(tempIntList.begin(), tempIntList.end()); -// +// for(i=0; iclear(); listWidget_blinds->addItems(tempStringList); } diff --git a/src/gui/qt/settingsdialog/manualblindsorderdialog/manualblindsorderdialogimpl.h b/src/gui/qt/settingsdialog/manualblindsorderdialog/manualblindsorderdialogimpl.h index b5e397a8..4c899bf1 100644 --- a/src/gui/qt/settingsdialog/manualblindsorderdialog/manualblindsorderdialogimpl.h +++ b/src/gui/qt/settingsdialog/manualblindsorderdialog/manualblindsorderdialogimpl.h @@ -27,23 +27,26 @@ class ConfigFile; -class manualBlindsOrderDialogImpl: public QDialog, public Ui::manualBlindsOrderDialog { -Q_OBJECT +class manualBlindsOrderDialogImpl: public QDialog, public Ui::manualBlindsOrderDialog +{ + Q_OBJECT public: - manualBlindsOrderDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); - + manualBlindsOrderDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); + void exec(); - + public slots: - bool getSettingsCorrect() const { return settingsCorrect;} - + bool getSettingsCorrect() const { + return settingsCorrect; + } + void addBlindValueToList(); void removeBlindFromList(); void sortBlindsList(); private: - + ConfigFile* myConfig; bool settingsCorrect; diff --git a/src/gui/qt/settingsdialog/myavatarbutton.cpp b/src/gui/qt/settingsdialog/myavatarbutton.cpp index 1c0ec17e..02dae622 100644 --- a/src/gui/qt/settingsdialog/myavatarbutton.cpp +++ b/src/gui/qt/settingsdialog/myavatarbutton.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -15,7 +15,7 @@ using namespace std; MyAvatarButton::MyAvatarButton(QGroupBox* parent) - : QPushButton(parent) + : QPushButton(parent) { } diff --git a/src/gui/qt/settingsdialog/myavatarbutton.h b/src/gui/qt/settingsdialog/myavatarbutton.h index 236ba7f3..76b85c24 100644 --- a/src/gui/qt/settingsdialog/myavatarbutton.h +++ b/src/gui/qt/settingsdialog/myavatarbutton.h @@ -1,7 +1,7 @@ // // C++ Interface: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -18,13 +18,17 @@ class MyAvatarButton : public QPushButton { public: - MyAvatarButton(QGroupBox*); + MyAvatarButton(QGroupBox*); - ~MyAvatarButton(); + ~MyAvatarButton(); + + void setMyLink(QString theValue) { + myLink = theValue; + } + QString getMyLink() const { + return myLink; + } - void setMyLink(QString theValue){ myLink = theValue;} - QString getMyLink() const{ return myLink;} - private: diff --git a/src/gui/qt/settingsdialog/myhpavatarbutton.cpp b/src/gui/qt/settingsdialog/myhpavatarbutton.cpp index f4d69514..3ab48b38 100644 --- a/src/gui/qt/settingsdialog/myhpavatarbutton.cpp +++ b/src/gui/qt/settingsdialog/myhpavatarbutton.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -15,7 +15,7 @@ using namespace std; MyHPAvatarButton::MyHPAvatarButton(QWidget* parent) - : QPushButton(parent) + : QPushButton(parent) { } diff --git a/src/gui/qt/settingsdialog/myhpavatarbutton.h b/src/gui/qt/settingsdialog/myhpavatarbutton.h index f76b044f..43f73519 100644 --- a/src/gui/qt/settingsdialog/myhpavatarbutton.h +++ b/src/gui/qt/settingsdialog/myhpavatarbutton.h @@ -1,7 +1,7 @@ // // C++ Interface: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -18,13 +18,17 @@ class MyHPAvatarButton : public QPushButton { public: - MyHPAvatarButton(QWidget*); + MyHPAvatarButton(QWidget*); - ~MyHPAvatarButton(); + ~MyHPAvatarButton(); + + void setMyLink(QString theValue) { + myLink = theValue; + } + QString getMyLink() const { + return myLink; + } - void setMyLink(QString theValue){ myLink = theValue;} - QString getMyLink() const{ return myLink;} - private: diff --git a/src/gui/qt/settingsdialog/mystylelistitem.cpp b/src/gui/qt/settingsdialog/mystylelistitem.cpp index a3fa8ef3..e2260871 100644 --- a/src/gui/qt/settingsdialog/mystylelistitem.cpp +++ b/src/gui/qt/settingsdialog/mystylelistitem.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -12,16 +12,16 @@ #include "mystylelistitem.h" MyStyleListItem::MyStyleListItem(QStringList s, QTreeWidget *w) - : QTreeWidgetItem(w, s, QTreeWidgetItem::UserType) + : QTreeWidgetItem(w, s, QTreeWidgetItem::UserType) { } -MyStyleListItem::~MyStyleListItem() +MyStyleListItem::~MyStyleListItem() { } bool MyStyleListItem::operator<( const QTreeWidgetItem &other ) const { - return text(0).toLower() < other.text(0).toLower(); + return text(0).toLower() < other.text(0).toLower(); } diff --git a/src/gui/qt/settingsdialog/mystylelistitem.h b/src/gui/qt/settingsdialog/mystylelistitem.h index 76a56093..c5756be4 100644 --- a/src/gui/qt/settingsdialog/mystylelistitem.h +++ b/src/gui/qt/settingsdialog/mystylelistitem.h @@ -10,12 +10,13 @@ #include #include -class MyStyleListItem : public QTreeWidgetItem { +class MyStyleListItem : public QTreeWidgetItem +{ public: - MyStyleListItem(QStringList, QTreeWidget *); - ~MyStyleListItem(); - - virtual bool operator<( const QTreeWidgetItem &) const; + MyStyleListItem(QStringList, QTreeWidget *); + ~MyStyleListItem(); + + virtual bool operator<( const QTreeWidgetItem &) const; }; #endif // MYSTYLELISTITEM_H diff --git a/src/gui/qt/settingsdialog/selectavatardialog/myavatarlistitem.cpp b/src/gui/qt/settingsdialog/selectavatardialog/myavatarlistitem.cpp index c6c021e4..feb4d013 100644 --- a/src/gui/qt/settingsdialog/selectavatardialog/myavatarlistitem.cpp +++ b/src/gui/qt/settingsdialog/selectavatardialog/myavatarlistitem.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -14,7 +14,7 @@ using namespace std; MyAvatarListItem::MyAvatarListItem(QListWidget* parent) - : QListWidgetItem(parent, QListWidgetItem::UserType) + : QListWidgetItem(parent, QListWidgetItem::UserType) { } diff --git a/src/gui/qt/settingsdialog/selectavatardialog/myavatarlistitem.h b/src/gui/qt/settingsdialog/selectavatardialog/myavatarlistitem.h index 78be5ba4..4c97839b 100644 --- a/src/gui/qt/settingsdialog/selectavatardialog/myavatarlistitem.h +++ b/src/gui/qt/settingsdialog/selectavatardialog/myavatarlistitem.h @@ -1,7 +1,7 @@ // // C++ Interface: mycardspixmaplabel // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -18,13 +18,17 @@ class MyAvatarListItem : public QListWidgetItem { public: - MyAvatarListItem(QListWidget*); + MyAvatarListItem(QListWidget*); - ~MyAvatarListItem(); + ~MyAvatarListItem(); + + void setMyLink(QString theValue) { + myLink = theValue; + } + QString getMyLink() const { + return myLink; + } - void setMyLink(QString theValue){ myLink = theValue;} - QString getMyLink() const{ return myLink;} - private: diff --git a/src/gui/qt/settingsdialog/selectavatardialog/selectavatardialogimpl.cpp b/src/gui/qt/settingsdialog/selectavatardialog/selectavatardialogimpl.cpp index f855c455..2e2f4a8d 100644 --- a/src/gui/qt/settingsdialog/selectavatardialog/selectavatardialogimpl.cpp +++ b/src/gui/qt/settingsdialog/selectavatardialog/selectavatardialogimpl.cpp @@ -24,14 +24,14 @@ selectAvatarDialogImpl::selectAvatarDialogImpl(QWidget *parent, ConfigFile *c) - : QDialog(parent), myConfig(c), settingsCorrect(TRUE), avatarDir("") + : QDialog(parent), myConfig(c), settingsCorrect(TRUE), avatarDir("") { #ifdef __APPLE__ setWindowModality(Qt::ApplicationModal); setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); -#endif +#endif setupUi(this); - + myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); pushButton_OpenAvatarFile->setIcon(QIcon(QPixmap(myAppDataPath+"gfx/gui/misc/fileopen16.png"))); @@ -39,7 +39,7 @@ selectAvatarDialogImpl::selectAvatarDialogImpl(QWidget *parent, ConfigFile *c) // listWidget->setViewMode(QListView::IconMode); // listWidget->setIconSize(QSize(50,50)); // listWidget->setLayoutDirection(Qt::LeftToRight); - listWidget->setViewMode(QListView::IconMode); + listWidget->setViewMode(QListView::IconMode); listWidget->setIconSize(QSize(50, 50)); // listWidget->setFlow(QListView::TopToBottom); // listWidget->setWrapping(true); @@ -47,7 +47,7 @@ selectAvatarDialogImpl::selectAvatarDialogImpl(QWidget *parent, ConfigFile *c) listWidget->setDragEnabled(FALSE); listWidget->setResizeMode(QListView::Adjust); - + // int i; // for (i=0; i<30; i++) { // MyAvatarListItem *myItem = new MyAvatarListItem(listWidget); @@ -60,7 +60,7 @@ selectAvatarDialogImpl::selectAvatarDialogImpl(QWidget *parent, ConfigFile *c) peopleAvatarList << myAppDataPath +"gfx/avatars/default/people/95df673e5ee4d02f0f95d5c7ff091cfb.png"; peopleAvatarList << myAppDataPath +"gfx/avatars/default/people/490ed3a748f6f4d6c261436198f2368f.png"; peopleAvatarList << myAppDataPath +"gfx/avatars/default/people/e3e1ae15f7d808fce16c26c049e2cbe9.png"; - peopleAvatarList << myAppDataPath +"gfx/avatars/default/people/237c518f2bb6ac99f6eb1012e18460b9.png"; + peopleAvatarList << myAppDataPath +"gfx/avatars/default/people/237c518f2bb6ac99f6eb1012e18460b9.png"; peopleAvatarList << myAppDataPath +"gfx/avatars/default/people/9f49fc3d6062ddc08dc6bbd9ef9b399d.png"; peopleAvatarList << myAppDataPath +"gfx/avatars/default/people/bed234c6672d512bdb4c2768f0b3f90c.png"; peopleAvatarList << myAppDataPath +"gfx/avatars/default/people/d6f8a45e9243b7e7e4e2c8e41df1c9f5.png"; @@ -76,7 +76,7 @@ selectAvatarDialogImpl::selectAvatarDialogImpl(QWidget *parent, ConfigFile *c) peopleAvatarList << myAppDataPath +"gfx/avatars/default/people/6ecea83d9fac6b4cae97e2fccd09a5f6.png"; peopleAvatarList << myAppDataPath +"gfx/avatars/default/people/74672ebfa2ab02968386c4e441a08668.png"; peopleAvatarList << myAppDataPath +"gfx/avatars/default/people/e54e67ebd5265cf549362a2cda5a999c.png"; - peopleAvatarList << myAppDataPath +"gfx/avatars/default/people/da34195981d255656f39c05481de3b6a.png"; + peopleAvatarList << myAppDataPath +"gfx/avatars/default/people/da34195981d255656f39c05481de3b6a.png"; peopleAvatarList << myAppDataPath +"gfx/avatars/default/people/6ad16e2c3e4b8e4e6da47032d4372f4b.png"; peopleAvatarList << myAppDataPath +"gfx/avatars/default/people/c018b15b8164a303b9395b1e89c51004.png"; peopleAvatarList << myAppDataPath +"gfx/avatars/default/people/0c24b06358f7b308d6b47c59ebace73d.png"; @@ -147,8 +147,8 @@ selectAvatarDialogImpl::selectAvatarDialogImpl(QWidget *parent, ConfigFile *c) miscAvatarList << myAppDataPath +"gfx/avatars/default/misc/eb7612a2b515bd826babec8f649b44cf.png"; miscAvatarList << myAppDataPath +"gfx/avatars/default/misc/08ced517579b3d258c947aec6c0a0dd4.png"; - - + + // peopleAvatarList << myAppDataPath +"gfx/avatars/default/misc/ connect(groupBox, SIGNAL(toggled(bool)), this, SLOT(toggleGroupBox1(bool))); @@ -158,11 +158,12 @@ selectAvatarDialogImpl::selectAvatarDialogImpl(QWidget *parent, ConfigFile *c) connect( pushButton_OpenAvatarFile, SIGNAL( clicked() ), this, SLOT( setExternalAvatar() ) ); connect( listWidget, SIGNAL( doubleClicked(QModelIndex) ), this, SLOT( isAccepted() ) ); connect( comboBox_avatarViewCategorie, SIGNAL( currentIndexChanged(int) ), this, SLOT( refreshAvatarView() ) ); - + } -void selectAvatarDialogImpl::exec() { +void selectAvatarDialogImpl::exec() +{ //clear lineEdit->setText(""); @@ -171,24 +172,29 @@ void selectAvatarDialogImpl::exec() { QDialog::exec(); } -void selectAvatarDialogImpl::refreshAvatarView() { +void selectAvatarDialogImpl::refreshAvatarView() +{ listWidget->clear(); int i; QStringList currentViewList; - + switch(comboBox_avatarViewCategorie->currentIndex()) { - case 0: { currentViewList = peopleAvatarList; } + case 0: { + currentViewList = peopleAvatarList; + } break; - - case 1: { currentViewList = miscAvatarList; } + + case 1: { + currentViewList = miscAvatarList; + } break; } for (i=0; isetIcon(QIcon(QPixmap(currentViewList.at(i)).scaled(50,50,Qt::IgnoreAspectRatio,Qt::SmoothTransformation))); myItem->setMyLink(currentViewList.at(i)); @@ -197,82 +203,94 @@ void selectAvatarDialogImpl::refreshAvatarView() { } } -void selectAvatarDialogImpl::toggleGroupBox1(bool /*toggleState*/) { if(groupBox->isChecked()) groupBox_2->setChecked(FALSE); } +void selectAvatarDialogImpl::toggleGroupBox1(bool /*toggleState*/) +{ + if(groupBox->isChecked()) groupBox_2->setChecked(FALSE); +} -void selectAvatarDialogImpl::toggleGroupBox2(bool /*toggleState*/) { if(groupBox_2->isChecked()) groupBox->setChecked(FALSE); } +void selectAvatarDialogImpl::toggleGroupBox2(bool /*toggleState*/) +{ + if(groupBox_2->isChecked()) groupBox->setChecked(FALSE); +} -QString selectAvatarDialogImpl::getAvatarLink() { +QString selectAvatarDialogImpl::getAvatarLink() +{ QList myItemList = listWidget->selectedItems(); if(groupBox->isChecked()) { if(myItemList.size() == 1) { return static_cast(listWidget->currentItem())->getMyLink(); - } - else return QString(""); + } else return QString(""); } - + QFile lineEditFile(lineEdit->text()); if(groupBox_2->isChecked() && lineEditFile.exists() ) return externalAvatar; else return QString(""); } -void selectAvatarDialogImpl::isAccepted() { +void selectAvatarDialogImpl::isAccepted() +{ QList myItemList = listWidget->selectedItems(); - settingsCorrect = TRUE; + settingsCorrect = TRUE; - if(groupBox->isChecked()) { + if(groupBox->isChecked()) { if(myItemList.size() == 0) { QMessageBox::warning(this, tr("Avatar File Error"), - tr("Please select an avatar from the list!"), - QMessageBox::Ok); - settingsCorrect = FALSE; - } - else settingsCorrect = TRUE;; + tr("Please select an avatar from the list!"), + QMessageBox::Ok); + settingsCorrect = FALSE; + } else settingsCorrect = TRUE;; } - + if(groupBox_2->isChecked()) { QFile lineEditFile(lineEdit->text()); - if(lineEditFile.exists()) { + if(lineEditFile.exists()) { if(lineEditFile.size() <= 30720 ) { externalAvatar = lineEdit->text(); settingsCorrect = TRUE; - } - else { QMessageBox::warning(this, tr("Avatar File Error"), - tr("The file size of the chosen picture is too big. (max. 30KB)\n" - "Please choose a smaller picture!"), - QMessageBox::Ok); - settingsCorrect = FALSE; + } else { + QMessageBox::warning(this, tr("Avatar File Error"), + tr("The file size of the chosen picture is too big. (max. 30KB)\n" + "Please choose a smaller picture!"), + QMessageBox::Ok); + settingsCorrect = FALSE; externalAvatar = ""; - } - } - else { QMessageBox::warning(this, tr("Avatar File Error"), - tr("The entered avatar picture doesn't exist.\n" - "Please enter an valid picture!"), - QMessageBox::Ok); - settingsCorrect = FALSE; + } + } else { + QMessageBox::warning(this, tr("Avatar File Error"), + tr("The entered avatar picture doesn't exist.\n" + "Please enter an valid picture!"), + QMessageBox::Ok); + settingsCorrect = FALSE; externalAvatar = ""; } } //Wenn alles richtig eingegeben wurde --> Dialog schließen - if(settingsCorrect) { this->hide(); } + if(settingsCorrect) { + this->hide(); + } } -void selectAvatarDialogImpl::isRejected() { settingsCorrect = FALSE; } +void selectAvatarDialogImpl::isRejected() +{ + settingsCorrect = FALSE; +} + +void selectAvatarDialogImpl::setExternalAvatar() +{ -void selectAvatarDialogImpl::setExternalAvatar() { - if (avatarDir == "") avatarDir = QDir::homePath(); QString fileName = QFileDialog::getOpenFileName(this, tr("Select external avatar picture"), avatarDir, tr("Images (*.png *.jpg *.gif)")); - if (!fileName.isEmpty()) { - lineEdit->setText(fileName); + if (!fileName.isEmpty()) { + lineEdit->setText(fileName); avatarDir = fileName; } } diff --git a/src/gui/qt/settingsdialog/selectavatardialog/selectavatardialogimpl.h b/src/gui/qt/settingsdialog/selectavatardialog/selectavatardialogimpl.h index a0527f03..3c7dea89 100644 --- a/src/gui/qt/settingsdialog/selectavatardialog/selectavatardialogimpl.h +++ b/src/gui/qt/settingsdialog/selectavatardialog/selectavatardialogimpl.h @@ -28,30 +28,33 @@ class ConfigFile; class selectAvatarDialogImpl; -class selectAvatarDialogImpl: public QDialog, public Ui::selectAvatarDialog { -Q_OBJECT +class selectAvatarDialogImpl: public QDialog, public Ui::selectAvatarDialog +{ + Q_OBJECT public: - selectAvatarDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); - + selectAvatarDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); + void exec(); - + public slots: void toggleGroupBox1(bool); void toggleGroupBox2(bool); void isAccepted(); void isRejected(); - + QString getAvatarLink(); void setExternalAvatar(); - bool getSettingsCorrect() const { return settingsCorrect;} + bool getSettingsCorrect() const { + return settingsCorrect; + } void refreshAvatarView(); - + private: - + ConfigFile* myConfig; bool settingsCorrect; diff --git a/src/gui/qt/settingsdialog/settingsdialogimpl.cpp b/src/gui/qt/settingsdialog/settingsdialogimpl.cpp index e8fd3534..491b5861 100644 --- a/src/gui/qt/settingsdialog/settingsdialogimpl.cpp +++ b/src/gui/qt/settingsdialog/settingsdialogimpl.cpp @@ -31,109 +31,111 @@ enum StyleType { POKERTH_DISTRIBUTED_STYLE, ADDITIONAL_STYLE }; using namespace std; settingsDialogImpl::settingsDialogImpl(QWidget *parent, ConfigFile *c, selectAvatarDialogImpl *s) - : QDialog(parent), myConfig(c), mySelectAvatarDialogImpl(s) + : QDialog(parent), myConfig(c), mySelectAvatarDialogImpl(s) { #ifdef __APPLE__ - setWindowModality(Qt::ApplicationModal); - setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); -#endif - setupUi(this); + setWindowModality(Qt::ApplicationModal); + setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); +#endif + setupUi(this); - if(!SQLITE_LOG) {//temporarely remove sql log features - pushButton_deleteLog->hide(); - pushButton_saveLogAs->hide(); - pushButton_exportLogTxt->hide(); - pushButton_exportLogHtml->hide(); - treeWidget_logFiles->hide(); - } + if(!SQLITE_LOG) {//temporarely remove sql log features + pushButton_deleteLog->hide(); + pushButton_saveLogAs->hide(); + pushButton_exportLogTxt->hide(); + pushButton_exportLogHtml->hide(); + treeWidget_logFiles->hide(); + } - myManualBlindsOrderDialog = new manualBlindsOrderDialogImpl; + myManualBlindsOrderDialog = new manualBlindsOrderDialogImpl; - myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); + myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); - pushButton_openFlipsidePicture->setIcon(QIcon(QPixmap(myAppDataPath+"gfx/gui/misc/fileopen16.png"))); - pushButton_openLogDir->setIcon(QIcon(QPixmap(myAppDataPath+"gfx/gui/misc/fileopen16.png"))); + pushButton_openFlipsidePicture->setIcon(QIcon(QPixmap(myAppDataPath+"gfx/gui/misc/fileopen16.png"))); + pushButton_openLogDir->setIcon(QIcon(QPixmap(myAppDataPath+"gfx/gui/misc/fileopen16.png"))); - if (myConfig->readConfigInt("CLA_NoWriteAccess")) { groupBox_logOnOff->setDisabled(TRUE); } + if (myConfig->readConfigInt("CLA_NoWriteAccess")) { + groupBox_logOnOff->setDisabled(TRUE); + } - comboBox_switchLanguage->addItem(QString(tr("Afrikaans")+" "+QString::fromUtf8("(Afrikaans)")),"af"); - comboBox_switchLanguage->addItem(QString(tr("Bulgarian")+" "+QString::fromUtf8("(Български)")),"bg"); - comboBox_switchLanguage->addItem(QString(tr("Catalan")+" "+QString::fromUtf8("(Català)")),"ca"); - comboBox_switchLanguage->addItem(QString(tr("Chinese")+" "+QString::fromUtf8("(简体中文)")),"zhcn"); - comboBox_switchLanguage->addItem(QString(tr("Czech")+" "+QString::fromUtf8("(čeština)")),"cz"); - comboBox_switchLanguage->addItem(QString(tr("Danish")+" "+QString::fromUtf8("(Dansk)")),"dk"); - comboBox_switchLanguage->addItem(QString(tr("Dutch")+" "+QString::fromUtf8("(Nederlands)")),"nl"); - comboBox_switchLanguage->addItem(QString(tr("English")+" "+QString::fromUtf8("(English)")),"en"); - comboBox_switchLanguage->addItem(QString(tr("Finnish")+" "+QString::fromUtf8("(suomi)")),"fi"); - comboBox_switchLanguage->addItem(QString(tr("French")+" "+QString::fromUtf8("(français)")),"fr"); - comboBox_switchLanguage->addItem(QString(tr("German")+" "+QString::fromUtf8("(Deutsch)")),"de"); - comboBox_switchLanguage->addItem(QString(tr("Greek")+" "+QString::fromUtf8("(Ελληνικά)")),"gr"); - comboBox_switchLanguage->addItem(QString(tr("Hungarian")+" "+QString::fromUtf8("(Magyar)")),"hu"); - comboBox_switchLanguage->addItem(QString(tr("Italian")+" "+QString::fromUtf8("(italiano)")),"it"); - comboBox_switchLanguage->addItem(QString(tr("Lithuania")+" "+QString::fromUtf8("(Lietuviškai)")),"lt"); - comboBox_switchLanguage->addItem(QString(tr("Norwegian")+" "+QString::fromUtf8("(Norsk)")),"no"); - comboBox_switchLanguage->addItem(QString(tr("Polish")+" "+QString::fromUtf8("(polski)")),"pl"); - comboBox_switchLanguage->addItem(QString(tr("Portuguese-Brazilian")+" "+QString::fromUtf8("(português brasileiro)")),"ptbr"); - comboBox_switchLanguage->addItem(QString(tr("Portuguese-Portuguese")+" "+QString::fromUtf8("(português português)")),"ptpt"); - comboBox_switchLanguage->addItem(QString(tr("Russian")+" "+QString::fromUtf8("(Pyccĸий)")),"ru"); - comboBox_switchLanguage->addItem(QString(tr("Slovak")+" "+QString::fromUtf8("(Slovenčina)")),"sk"); - comboBox_switchLanguage->addItem(QString(tr("Spanish")+" "+QString::fromUtf8("(Español)")),"es"); - comboBox_switchLanguage->addItem(QString(tr("Swedish")+" "+QString::fromUtf8("(svenska)")),"sv"); - comboBox_switchLanguage->addItem(QString(tr("Tamil")+" "+QString::fromUtf8("(தமிழ்)")),"ta"); - comboBox_switchLanguage->addItem(QString(tr("Turkish")+" "+QString::fromUtf8("(Tϋrkçe)")),"tr"); + comboBox_switchLanguage->addItem(QString(tr("Afrikaans")+" "+QString::fromUtf8("(Afrikaans)")),"af"); + comboBox_switchLanguage->addItem(QString(tr("Bulgarian")+" "+QString::fromUtf8("(Български)")),"bg"); + comboBox_switchLanguage->addItem(QString(tr("Catalan")+" "+QString::fromUtf8("(Català)")),"ca"); + comboBox_switchLanguage->addItem(QString(tr("Chinese")+" "+QString::fromUtf8("(简体中文)")),"zhcn"); + comboBox_switchLanguage->addItem(QString(tr("Czech")+" "+QString::fromUtf8("(čeština)")),"cz"); + comboBox_switchLanguage->addItem(QString(tr("Danish")+" "+QString::fromUtf8("(Dansk)")),"dk"); + comboBox_switchLanguage->addItem(QString(tr("Dutch")+" "+QString::fromUtf8("(Nederlands)")),"nl"); + comboBox_switchLanguage->addItem(QString(tr("English")+" "+QString::fromUtf8("(English)")),"en"); + comboBox_switchLanguage->addItem(QString(tr("Finnish")+" "+QString::fromUtf8("(suomi)")),"fi"); + comboBox_switchLanguage->addItem(QString(tr("French")+" "+QString::fromUtf8("(français)")),"fr"); + comboBox_switchLanguage->addItem(QString(tr("German")+" "+QString::fromUtf8("(Deutsch)")),"de"); + comboBox_switchLanguage->addItem(QString(tr("Greek")+" "+QString::fromUtf8("(Ελληνικά)")),"gr"); + comboBox_switchLanguage->addItem(QString(tr("Hungarian")+" "+QString::fromUtf8("(Magyar)")),"hu"); + comboBox_switchLanguage->addItem(QString(tr("Italian")+" "+QString::fromUtf8("(italiano)")),"it"); + comboBox_switchLanguage->addItem(QString(tr("Lithuania")+" "+QString::fromUtf8("(Lietuviškai)")),"lt"); + comboBox_switchLanguage->addItem(QString(tr("Norwegian")+" "+QString::fromUtf8("(Norsk)")),"no"); + comboBox_switchLanguage->addItem(QString(tr("Polish")+" "+QString::fromUtf8("(polski)")),"pl"); + comboBox_switchLanguage->addItem(QString(tr("Portuguese-Brazilian")+" "+QString::fromUtf8("(português brasileiro)")),"ptbr"); + comboBox_switchLanguage->addItem(QString(tr("Portuguese-Portuguese")+" "+QString::fromUtf8("(português português)")),"ptpt"); + comboBox_switchLanguage->addItem(QString(tr("Russian")+" "+QString::fromUtf8("(Pyccĸий)")),"ru"); + comboBox_switchLanguage->addItem(QString(tr("Slovak")+" "+QString::fromUtf8("(Slovenčina)")),"sk"); + comboBox_switchLanguage->addItem(QString(tr("Spanish")+" "+QString::fromUtf8("(Español)")),"es"); + comboBox_switchLanguage->addItem(QString(tr("Swedish")+" "+QString::fromUtf8("(svenska)")),"sv"); + comboBox_switchLanguage->addItem(QString(tr("Tamil")+" "+QString::fromUtf8("(தமிழ்)")),"ta"); + comboBox_switchLanguage->addItem(QString(tr("Turkish")+" "+QString::fromUtf8("(Tϋrkçe)")),"tr"); - connect( buttonBox, SIGNAL( accepted() ), this, SLOT( isAccepted() ) ); - connect( lineEdit_HumanPlayerName, SIGNAL( textChanged( const QString &) ), this, SLOT( playerNickChanged() ) ); - connect( lineEdit_Opponent1Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); - connect( lineEdit_Opponent2Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); - connect( lineEdit_Opponent3Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); - connect( lineEdit_Opponent4Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); - connect( lineEdit_Opponent5Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); - connect( lineEdit_Opponent6Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); - connect( lineEdit_Opponent7Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); - connect( lineEdit_Opponent8Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); - connect( lineEdit_Opponent9Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); - connect( pushButton_openFlipsidePicture, SIGNAL( clicked() ), this, SLOT( setFlipsidePicFileName()) ); - connect( pushButton_openLogDir, SIGNAL( clicked() ), this, SLOT( setLogDir()) ); - connect( pushButton_HumanPlayerAvatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile0()) ); - connect( pushButton_Opponent1Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile1()) ); - connect( pushButton_Opponent2Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile2()) ); - connect( pushButton_Opponent3Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile3()) ); - connect( pushButton_Opponent4Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile4()) ); - connect( pushButton_Opponent5Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile5()) ); - connect( pushButton_Opponent6Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile6()) ); - connect( pushButton_Opponent7Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile7()) ); - connect( pushButton_Opponent8Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile8()) ); - connect( pushButton_Opponent9Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile9()) ); - connect( pushButton_editManualBlindsOrder, SIGNAL( clicked() ), this, SLOT( callManualBlindsOrderDialog()) ); - connect( pushButton_netEditManualBlindsOrder, SIGNAL( clicked() ), this, SLOT( callNetManualBlindsOrderDialog()) ); + connect( buttonBox, SIGNAL( accepted() ), this, SLOT( isAccepted() ) ); + connect( lineEdit_HumanPlayerName, SIGNAL( textChanged( const QString &) ), this, SLOT( playerNickChanged() ) ); + connect( lineEdit_Opponent1Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); + connect( lineEdit_Opponent2Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); + connect( lineEdit_Opponent3Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); + connect( lineEdit_Opponent4Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); + connect( lineEdit_Opponent5Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); + connect( lineEdit_Opponent6Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); + connect( lineEdit_Opponent7Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); + connect( lineEdit_Opponent8Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); + connect( lineEdit_Opponent9Name, SIGNAL( textChanged(const QString &) ), this, SLOT( playerNickChanged() ) ); + connect( pushButton_openFlipsidePicture, SIGNAL( clicked() ), this, SLOT( setFlipsidePicFileName()) ); + connect( pushButton_openLogDir, SIGNAL( clicked() ), this, SLOT( setLogDir()) ); + connect( pushButton_HumanPlayerAvatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile0()) ); + connect( pushButton_Opponent1Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile1()) ); + connect( pushButton_Opponent2Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile2()) ); + connect( pushButton_Opponent3Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile3()) ); + connect( pushButton_Opponent4Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile4()) ); + connect( pushButton_Opponent5Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile5()) ); + connect( pushButton_Opponent6Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile6()) ); + connect( pushButton_Opponent7Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile7()) ); + connect( pushButton_Opponent8Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile8()) ); + connect( pushButton_Opponent9Avatar, SIGNAL( clicked() ), this, SLOT( setAvatarFile9()) ); + connect( pushButton_editManualBlindsOrder, SIGNAL( clicked() ), this, SLOT( callManualBlindsOrderDialog()) ); + connect( pushButton_netEditManualBlindsOrder, SIGNAL( clicked() ), this, SLOT( callNetManualBlindsOrderDialog()) ); - connect( checkBox_UseInternetGamePassword, SIGNAL( toggled(bool) ), this, SLOT( clearInternetGamePassword(bool)) ); + connect( checkBox_UseInternetGamePassword, SIGNAL( toggled(bool) ), this, SLOT( clearInternetGamePassword(bool)) ); - // connect( spinBox_netFirstSmallBlind, SIGNAL( valueChanged(int) ), this, SLOT ( checkProperNetFirstSmallBlind(int))); - // connect( spinBox_firstSmallBlind, SIGNAL( valueChanged(int) ), this, SLOT ( checkProperFirstSmallBlind(int))); + // connect( spinBox_netFirstSmallBlind, SIGNAL( valueChanged(int) ), this, SLOT ( checkProperNetFirstSmallBlind(int))); + // connect( spinBox_firstSmallBlind, SIGNAL( valueChanged(int) ), this, SLOT ( checkProperFirstSmallBlind(int))); - connect( radioButton_netManualBlindsOrder, SIGNAL( toggled(bool) ), this, SLOT( setFirstSmallBlindMargin() )); - connect( radioButton_manualBlindsOrder, SIGNAL( toggled(bool) ), this, SLOT( setFirstSmallBlindMargin() )); + connect( radioButton_netManualBlindsOrder, SIGNAL( toggled(bool) ), this, SLOT( setFirstSmallBlindMargin() )); + connect( radioButton_manualBlindsOrder, SIGNAL( toggled(bool) ), this, SLOT( setFirstSmallBlindMargin() )); - connect( comboBox_switchLanguage, SIGNAL( currentIndexChanged (int) ), this, SLOT ( setLanguageChanged(int) )); + connect( comboBox_switchLanguage, SIGNAL( currentIndexChanged (int) ), this, SLOT ( setLanguageChanged(int) )); - connect(groupBox_automaticServerConfig, SIGNAL(toggled(bool)), this, SLOT(toggleGroupBoxAutomaticServerConfig(bool))); - connect(groupBox_manualServerConfig, SIGNAL(toggled(bool)), this, SLOT(toggleGroupBoxManualServerConfig(bool))); + connect(groupBox_automaticServerConfig, SIGNAL(toggled(bool)), this, SLOT(toggleGroupBoxAutomaticServerConfig(bool))); + connect(groupBox_manualServerConfig, SIGNAL(toggled(bool)), this, SLOT(toggleGroupBoxManualServerConfig(bool))); - connect( treeWidget_gameTableStyles, SIGNAL( currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT ( showCurrentGameTableStylePreview() )); - connect( pushButton_addGameTableStyle, SIGNAL( clicked() ), this, SLOT( addGameTableStyle()) ); - connect( pushButton_removeGameTableStyle, SIGNAL( clicked() ), this, SLOT( removeGameTableStyle()) ); + connect( treeWidget_gameTableStyles, SIGNAL( currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT ( showCurrentGameTableStylePreview() )); + connect( pushButton_addGameTableStyle, SIGNAL( clicked() ), this, SLOT( addGameTableStyle()) ); + connect( pushButton_removeGameTableStyle, SIGNAL( clicked() ), this, SLOT( removeGameTableStyle()) ); - connect( treeWidget_cardDeckStyles, SIGNAL( currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT ( showCurrentCardDeckStylePreview() )); - connect( pushButton_addCardDeckStyle, SIGNAL( clicked() ), this, SLOT( addCardDeckStyle()) ); - connect( pushButton_removeCardDeckStyle, SIGNAL( clicked() ), this, SLOT( removeCardDeckStyle()) ); - connect( pushButton_internetGameRemoveIgnoredPlayer, SIGNAL( clicked()), this, SLOT( removePlayerFromIgnoredPlayersList())); + connect( treeWidget_cardDeckStyles, SIGNAL( currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*) ), this, SLOT ( showCurrentCardDeckStylePreview() )); + connect( pushButton_addCardDeckStyle, SIGNAL( clicked() ), this, SLOT( addCardDeckStyle()) ); + connect( pushButton_removeCardDeckStyle, SIGNAL( clicked() ), this, SLOT( removeCardDeckStyle()) ); + connect( pushButton_internetGameRemoveIgnoredPlayer, SIGNAL( clicked()), this, SLOT( removePlayerFromIgnoredPlayersList())); - connect( pushButton_deleteLog, SIGNAL(clicked()), this, SLOT (deleteLogFile())); - connect( pushButton_exportLogHtml, SIGNAL(clicked()), this, SLOT (exportLogToHtml())); - connect( pushButton_exportLogTxt, SIGNAL(clicked()), this, SLOT (exportLogToTxt())); - connect( pushButton_saveLogAs, SIGNAL(clicked()), this, SLOT (saveLogFileAs())); + connect( pushButton_deleteLog, SIGNAL(clicked()), this, SLOT (deleteLogFile())); + connect( pushButton_exportLogHtml, SIGNAL(clicked()), this, SLOT (exportLogToHtml())); + connect( pushButton_exportLogTxt, SIGNAL(clicked()), this, SLOT (exportLogToTxt())); + connect( pushButton_saveLogAs, SIGNAL(clicked()), this, SLOT (saveLogFileAs())); } @@ -143,1147 +145,1165 @@ settingsDialogImpl::~settingsDialogImpl() void settingsDialogImpl::prepareDialog() { - playerNickIsChanged = FALSE; + playerNickIsChanged = FALSE; - //Player Nicks - lineEdit_HumanPlayerName->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); - pushButton_HumanPlayerAvatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("MyAvatar").c_str())); - lineEdit_Opponent1Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent1Name").c_str())); - pushButton_Opponent1Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent1Avatar").c_str())); - lineEdit_Opponent2Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent2Name").c_str())); - pushButton_Opponent2Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent2Avatar").c_str())); - lineEdit_Opponent3Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent3Name").c_str())); - pushButton_Opponent3Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent3Avatar").c_str())); - lineEdit_Opponent4Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent4Name").c_str())); - pushButton_Opponent4Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent4Avatar").c_str())); - lineEdit_Opponent5Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent5Name").c_str())); - pushButton_Opponent5Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent5Avatar").c_str())); - lineEdit_Opponent6Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent6Name").c_str())); - pushButton_Opponent6Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent6Avatar").c_str())); - lineEdit_Opponent7Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent7Name").c_str())); - pushButton_Opponent7Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent7Avatar").c_str())); - lineEdit_Opponent8Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent8Name").c_str())); - pushButton_Opponent8Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent8Avatar").c_str())); - lineEdit_Opponent9Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent9Name").c_str())); - pushButton_Opponent9Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent9Avatar").c_str())); + //Player Nicks + lineEdit_HumanPlayerName->setText(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); + pushButton_HumanPlayerAvatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("MyAvatar").c_str())); + lineEdit_Opponent1Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent1Name").c_str())); + pushButton_Opponent1Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent1Avatar").c_str())); + lineEdit_Opponent2Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent2Name").c_str())); + pushButton_Opponent2Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent2Avatar").c_str())); + lineEdit_Opponent3Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent3Name").c_str())); + pushButton_Opponent3Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent3Avatar").c_str())); + lineEdit_Opponent4Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent4Name").c_str())); + pushButton_Opponent4Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent4Avatar").c_str())); + lineEdit_Opponent5Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent5Name").c_str())); + pushButton_Opponent5Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent5Avatar").c_str())); + lineEdit_Opponent6Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent6Name").c_str())); + pushButton_Opponent6Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent6Avatar").c_str())); + lineEdit_Opponent7Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent7Name").c_str())); + pushButton_Opponent7Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent7Avatar").c_str())); + lineEdit_Opponent8Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent8Name").c_str())); + pushButton_Opponent8Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent8Avatar").c_str())); + lineEdit_Opponent9Name->setText(QString::fromUtf8(myConfig->readConfigString("Opponent9Name").c_str())); + pushButton_Opponent9Avatar->setMyLink(QString::fromUtf8(myConfig->readConfigString("Opponent9Avatar").c_str())); - //refresh AvatarIcons - pushButton_HumanPlayerAvatar->setIcon(QIcon(pushButton_HumanPlayerAvatar->getMyLink())); - pushButton_Opponent1Avatar->setIcon(QIcon(pushButton_Opponent1Avatar->getMyLink())); - pushButton_Opponent2Avatar->setIcon(QIcon(pushButton_Opponent2Avatar->getMyLink())); - pushButton_Opponent3Avatar->setIcon(QIcon(pushButton_Opponent3Avatar->getMyLink())); - pushButton_Opponent4Avatar->setIcon(QIcon(pushButton_Opponent4Avatar->getMyLink())); - pushButton_Opponent5Avatar->setIcon(QIcon(pushButton_Opponent5Avatar->getMyLink())); - pushButton_Opponent6Avatar->setIcon(QIcon(pushButton_Opponent6Avatar->getMyLink())); - pushButton_Opponent7Avatar->setIcon(QIcon(pushButton_Opponent7Avatar->getMyLink())); - pushButton_Opponent8Avatar->setIcon(QIcon(pushButton_Opponent8Avatar->getMyLink())); - pushButton_Opponent9Avatar->setIcon(QIcon(pushButton_Opponent9Avatar->getMyLink())); + //refresh AvatarIcons + pushButton_HumanPlayerAvatar->setIcon(QIcon(pushButton_HumanPlayerAvatar->getMyLink())); + pushButton_Opponent1Avatar->setIcon(QIcon(pushButton_Opponent1Avatar->getMyLink())); + pushButton_Opponent2Avatar->setIcon(QIcon(pushButton_Opponent2Avatar->getMyLink())); + pushButton_Opponent3Avatar->setIcon(QIcon(pushButton_Opponent3Avatar->getMyLink())); + pushButton_Opponent4Avatar->setIcon(QIcon(pushButton_Opponent4Avatar->getMyLink())); + pushButton_Opponent5Avatar->setIcon(QIcon(pushButton_Opponent5Avatar->getMyLink())); + pushButton_Opponent6Avatar->setIcon(QIcon(pushButton_Opponent6Avatar->getMyLink())); + pushButton_Opponent7Avatar->setIcon(QIcon(pushButton_Opponent7Avatar->getMyLink())); + pushButton_Opponent8Avatar->setIcon(QIcon(pushButton_Opponent8Avatar->getMyLink())); + pushButton_Opponent9Avatar->setIcon(QIcon(pushButton_Opponent9Avatar->getMyLink())); - //Local Game Settings - spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NumberOfPlayers")); - spinBox_startCash->setValue(myConfig->readConfigInt("StartCash")); - spinBox_firstSmallBlind->setValue(myConfig->readConfigInt("FirstSmallBlind")); - radioButton_raiseBlindsAtHands->setChecked(myConfig->readConfigInt("RaiseBlindsAtHands")); - radioButton_raiseBlindsAtMinutes->setChecked(myConfig->readConfigInt("RaiseBlindsAtMinutes")); - spinBox_raiseSmallBlindEveryHands->setValue(myConfig->readConfigInt("RaiseSmallBlindEveryHands")); - spinBox_raiseSmallBlindEveryMinutes->setValue(myConfig->readConfigInt("RaiseSmallBlindEveryMinutes")); - radioButton_alwaysDoubleBlinds->setChecked(myConfig->readConfigInt("AlwaysDoubleBlinds")); - radioButton_manualBlindsOrder->setChecked(myConfig->readConfigInt("ManualBlindsOrder")); - spinBox_gameSpeed->setValue(myConfig->readConfigInt("GameSpeed")); - checkBox_pauseBetweenHands->setChecked(myConfig->readConfigInt("PauseBetweenHands")); - checkBox_showGameSettingsDialogOnNewGame->setChecked(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame")); + //Local Game Settings + spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NumberOfPlayers")); + spinBox_startCash->setValue(myConfig->readConfigInt("StartCash")); + spinBox_firstSmallBlind->setValue(myConfig->readConfigInt("FirstSmallBlind")); + radioButton_raiseBlindsAtHands->setChecked(myConfig->readConfigInt("RaiseBlindsAtHands")); + radioButton_raiseBlindsAtMinutes->setChecked(myConfig->readConfigInt("RaiseBlindsAtMinutes")); + spinBox_raiseSmallBlindEveryHands->setValue(myConfig->readConfigInt("RaiseSmallBlindEveryHands")); + spinBox_raiseSmallBlindEveryMinutes->setValue(myConfig->readConfigInt("RaiseSmallBlindEveryMinutes")); + radioButton_alwaysDoubleBlinds->setChecked(myConfig->readConfigInt("AlwaysDoubleBlinds")); + radioButton_manualBlindsOrder->setChecked(myConfig->readConfigInt("ManualBlindsOrder")); + spinBox_gameSpeed->setValue(myConfig->readConfigInt("GameSpeed")); + checkBox_pauseBetweenHands->setChecked(myConfig->readConfigInt("PauseBetweenHands")); + checkBox_showGameSettingsDialogOnNewGame->setChecked(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame")); - //Network Game Settings - spinBox_netQuantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers")); - spinBox_netStartCash->setValue(myConfig->readConfigInt("NetStartCash")); - spinBox_netFirstSmallBlind->setValue(myConfig->readConfigInt("NetFirstSmallBlind")); - radioButton_netRaiseBlindsAtHands->setChecked(myConfig->readConfigInt("NetRaiseBlindsAtHands")); - radioButton_netRaiseBlindsAtMinutes->setChecked(myConfig->readConfigInt("NetRaiseBlindsAtMinutes")); - spinBox_netRaiseSmallBlindEveryHands->setValue(myConfig->readConfigInt("NetRaiseSmallBlindEveryHands")); - spinBox_netRaiseSmallBlindEveryMinutes->setValue(myConfig->readConfigInt("NetRaiseSmallBlindEveryMinutes")); - radioButton_netAlwaysDoubleBlinds->setChecked(myConfig->readConfigInt("NetAlwaysDoubleBlinds")); - radioButton_netManualBlindsOrder->setChecked(myConfig->readConfigInt("NetManualBlindsOrder")); - spinBox_netDelayBetweenHands->setValue(myConfig->readConfigInt("NetDelayBetweenHands")); - spinBox_netTimeOutPlayerAction->setValue(myConfig->readConfigInt("NetTimeOutPlayerAction")); - spinBox_serverPort->setValue(myConfig->readConfigInt("ServerPort")); - checkBox_useIpv6->setChecked(myConfig->readConfigInt("ServerUseIpv6")); - checkBox_useSctp->setChecked(myConfig->readConfigInt("ServerUseSctp")); + //Network Game Settings + spinBox_netQuantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers")); + spinBox_netStartCash->setValue(myConfig->readConfigInt("NetStartCash")); + spinBox_netFirstSmallBlind->setValue(myConfig->readConfigInt("NetFirstSmallBlind")); + radioButton_netRaiseBlindsAtHands->setChecked(myConfig->readConfigInt("NetRaiseBlindsAtHands")); + radioButton_netRaiseBlindsAtMinutes->setChecked(myConfig->readConfigInt("NetRaiseBlindsAtMinutes")); + spinBox_netRaiseSmallBlindEveryHands->setValue(myConfig->readConfigInt("NetRaiseSmallBlindEveryHands")); + spinBox_netRaiseSmallBlindEveryMinutes->setValue(myConfig->readConfigInt("NetRaiseSmallBlindEveryMinutes")); + radioButton_netAlwaysDoubleBlinds->setChecked(myConfig->readConfigInt("NetAlwaysDoubleBlinds")); + radioButton_netManualBlindsOrder->setChecked(myConfig->readConfigInt("NetManualBlindsOrder")); + spinBox_netDelayBetweenHands->setValue(myConfig->readConfigInt("NetDelayBetweenHands")); + spinBox_netTimeOutPlayerAction->setValue(myConfig->readConfigInt("NetTimeOutPlayerAction")); + spinBox_serverPort->setValue(myConfig->readConfigInt("ServerPort")); + checkBox_useIpv6->setChecked(myConfig->readConfigInt("ServerUseIpv6")); + checkBox_useSctp->setChecked(myConfig->readConfigInt("ServerUseSctp")); - //Internet Game Settings - if(myConfig->readConfigInt("InternetServerConfigMode")) { groupBox_manualServerConfig->setChecked(TRUE); } - else { groupBox_automaticServerConfig->setChecked(TRUE); } - lineEdit_InternetServerListAddress->setText(QString::fromUtf8(myConfig->readConfigString("InternetServerListAddress").c_str())); - lineEdit_InternetServerAddress->setText(QString::fromUtf8(myConfig->readConfigString("InternetServerAddress").c_str())); - spinBox_InternetServerPort->setValue(myConfig->readConfigInt("InternetServerPort")); - checkBox_InternetServerUseIpv6->setChecked(myConfig->readConfigInt("InternetServerUseIpv6")); - checkBox_InternetServerUseSctp->setChecked(myConfig->readConfigInt("InternetServerUseSctp")); - if(myConfig->readConfigInt("UseAvatarServer")) { - lineEdit_avatarServerAddress->setText(QString::fromUtf8(myConfig->readConfigString("AvatarServerAddress").c_str())); - checkBox_useAvatarServer->setCheckState(Qt::Checked); - lineEdit_avatarServerAddress->setEnabled(TRUE); - } - else { - checkBox_useAvatarServer->setCheckState(Qt::Unchecked); - lineEdit_avatarServerAddress->setEnabled(FALSE); - } - checkBox_UseInternetGamePassword->setChecked(myConfig->readConfigInt("UseInternetGamePassword")); - if(myConfig->readConfigInt("UseInternetGamePassword")) { - lineEdit_InternetGamePassword->setText(QString::fromUtf8(myConfig->readConfigString("InternetGamePassword").c_str())); - } - checkBox_UseLobbyChat->setChecked(myConfig->readConfigInt("UseLobbyChat")); - comboBox_internetGameType->setCurrentIndex(myConfig->readConfigInt("InternetGameType")); - lineEdit_internetGameName->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str())); + //Internet Game Settings + if(myConfig->readConfigInt("InternetServerConfigMode")) { + groupBox_manualServerConfig->setChecked(TRUE); + } else { + groupBox_automaticServerConfig->setChecked(TRUE); + } + lineEdit_InternetServerListAddress->setText(QString::fromUtf8(myConfig->readConfigString("InternetServerListAddress").c_str())); + lineEdit_InternetServerAddress->setText(QString::fromUtf8(myConfig->readConfigString("InternetServerAddress").c_str())); + spinBox_InternetServerPort->setValue(myConfig->readConfigInt("InternetServerPort")); + checkBox_InternetServerUseIpv6->setChecked(myConfig->readConfigInt("InternetServerUseIpv6")); + checkBox_InternetServerUseSctp->setChecked(myConfig->readConfigInt("InternetServerUseSctp")); + if(myConfig->readConfigInt("UseAvatarServer")) { + lineEdit_avatarServerAddress->setText(QString::fromUtf8(myConfig->readConfigString("AvatarServerAddress").c_str())); + checkBox_useAvatarServer->setCheckState(Qt::Checked); + lineEdit_avatarServerAddress->setEnabled(TRUE); + } else { + checkBox_useAvatarServer->setCheckState(Qt::Unchecked); + lineEdit_avatarServerAddress->setEnabled(FALSE); + } + checkBox_UseInternetGamePassword->setChecked(myConfig->readConfigInt("UseInternetGamePassword")); + if(myConfig->readConfigInt("UseInternetGamePassword")) { + lineEdit_InternetGamePassword->setText(QString::fromUtf8(myConfig->readConfigString("InternetGamePassword").c_str())); + } + checkBox_UseLobbyChat->setChecked(myConfig->readConfigInt("UseLobbyChat")); + comboBox_internetGameType->setCurrentIndex(myConfig->readConfigInt("InternetGameType")); + lineEdit_internetGameName->setText(QString::fromUtf8(myConfig->readConfigString("InternetGameName").c_str())); - std::list playerIgnoreList = myConfig->readConfigStringList("PlayerIgnoreList"); - std::list::iterator it5; - treeWidget_internetGameIgnoredPlayers->clear(); + std::list playerIgnoreList = myConfig->readConfigStringList("PlayerIgnoreList"); + std::list::iterator it5; + treeWidget_internetGameIgnoredPlayers->clear(); for(it5= playerIgnoreList.begin(); it5 != playerIgnoreList.end(); ++it5) { - QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_internetGameIgnoredPlayers); - item->setText(0, QString::fromUtf8(it5->c_str())); - } + QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_internetGameIgnoredPlayers); + item->setText(0, QString::fromUtf8(it5->c_str())); + } - //Interface - comboBox_switchLanguage->setCurrentIndex(comboBox_switchLanguage->findData(QString::fromUtf8(myConfig->readConfigString("Language").c_str()).section('_', 0, 0))); - checkBox_showLeftToolbox->setChecked(myConfig->readConfigInt("ShowLeftToolBox")); - checkBox_showRightToolbox->setChecked(myConfig->readConfigInt("ShowRightToolBox")); - checkBox_showFadeOutCardsAnimation->setChecked(myConfig->readConfigInt("ShowFadeOutCardsAnimation")); - checkBox_showFlipCardsAnimation->setChecked(myConfig->readConfigInt("ShowFlipCardsAnimation")); - checkBox_showBlindButtons->setChecked(myConfig->readConfigInt("ShowBlindButtons")); - checkBox_showCountryFlagInAvatar->setChecked(myConfig->readConfigInt("ShowCountryFlagInAvatar")); - checkBox_antiPeekMode->setChecked(myConfig->readConfigInt("AntiPeekMode")); - checkBox_alternateFKeysUserActionMode->setChecked(myConfig->readConfigInt("AlternateFKeysUserActionMode")); - checkBox_enableBetInputFocusSwitch->setChecked(myConfig->readConfigInt("EnableBetInputFocusSwitch")); - checkBox_cardsChanceMonitor->setChecked(myConfig->readConfigInt("ShowCardsChanceMonitor")); - checkBox_dontTranslatePokerStrings->setChecked(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle")); - checkBox_disableSplashscreen->setChecked(myConfig->readConfigInt("DisableSplashScreenOnStartup")); + //Interface + comboBox_switchLanguage->setCurrentIndex(comboBox_switchLanguage->findData(QString::fromUtf8(myConfig->readConfigString("Language").c_str()).section('_', 0, 0))); + checkBox_showLeftToolbox->setChecked(myConfig->readConfigInt("ShowLeftToolBox")); + checkBox_showRightToolbox->setChecked(myConfig->readConfigInt("ShowRightToolBox")); + checkBox_showFadeOutCardsAnimation->setChecked(myConfig->readConfigInt("ShowFadeOutCardsAnimation")); + checkBox_showFlipCardsAnimation->setChecked(myConfig->readConfigInt("ShowFlipCardsAnimation")); + checkBox_showBlindButtons->setChecked(myConfig->readConfigInt("ShowBlindButtons")); + checkBox_showCountryFlagInAvatar->setChecked(myConfig->readConfigInt("ShowCountryFlagInAvatar")); + checkBox_antiPeekMode->setChecked(myConfig->readConfigInt("AntiPeekMode")); + checkBox_alternateFKeysUserActionMode->setChecked(myConfig->readConfigInt("AlternateFKeysUserActionMode")); + checkBox_enableBetInputFocusSwitch->setChecked(myConfig->readConfigInt("EnableBetInputFocusSwitch")); + checkBox_cardsChanceMonitor->setChecked(myConfig->readConfigInt("ShowCardsChanceMonitor")); + checkBox_dontTranslatePokerStrings->setChecked(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle")); + checkBox_disableSplashscreen->setChecked(myConfig->readConfigInt("DisableSplashScreenOnStartup")); - //S t y l e - //TABLE - // define PokerTH default GameTableStyle - treeWidget_gameTableStyles->clear(); + //S t y l e + //TABLE + // define PokerTH default GameTableStyle + treeWidget_gameTableStyles->clear(); - GameTableStyleReader defaultTableStyle(myConfig, this); - defaultTableStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/default/defaulttablestyle.xml"); - if(defaultTableStyle.getLoadedSuccessfull()) { - QStringList tempStringList1; - tempStringList1 << defaultTableStyle.getStyleDescription() << defaultTableStyle.getStyleMaintainerName(); - MyStyleListItem *defaultTableItem = new MyStyleListItem(tempStringList1, treeWidget_gameTableStyles); - defaultTableItem->setData(0, 15, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/default/defaulttablestyle.xml"); - defaultTableItem->setData(0, 16, POKERTH_DISTRIBUTED_STYLE); - defaultTableItem->setData(0, Qt::ToolTipRole, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/default/defaulttablestyle.xml"); - defaultTableItem->setData(2, Qt::ToolTipRole, defaultTableStyle.getMyStateToolTipInfo()); - if(defaultTableStyle.getState()) defaultTableItem->setIcon(2, QIcon(":/gfx/emblem-important.png")); - else defaultTableItem->setIcon(2, QIcon(":/gfx/dialog_ok_apply.png")); - } - //add danuxi table - GameTableStyleReader danuxi1TableStyle(myConfig, this); - danuxi1TableStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/danuxi1/danuxi1tablestyle.xml"); - if(danuxi1TableStyle.getLoadedSuccessfull()) { - QStringList tempStringList2; - tempStringList2 << danuxi1TableStyle.getStyleDescription() << danuxi1TableStyle.getStyleMaintainerName(); - MyStyleListItem *danuxi1TableItem = new MyStyleListItem(tempStringList2, treeWidget_gameTableStyles); - danuxi1TableItem->setData(0, 15, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/danuxi1/danuxi1tablestyle.xml"); - danuxi1TableItem->setData(0, 16, POKERTH_DISTRIBUTED_STYLE); - danuxi1TableItem->setData(0, Qt::ToolTipRole, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/danuxi1/danuxi1tablestyle.xml"); - danuxi1TableItem->setData(2, Qt::ToolTipRole, danuxi1TableStyle.getMyStateToolTipInfo()); - if(danuxi1TableStyle.getState()) danuxi1TableItem->setIcon(2, QIcon(":/gfx/emblem-important.png")); - else danuxi1TableItem->setIcon(2, QIcon(":/gfx/dialog_ok_apply.png")); - } + GameTableStyleReader defaultTableStyle(myConfig, this); + defaultTableStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/default/defaulttablestyle.xml"); + if(defaultTableStyle.getLoadedSuccessfull()) { + QStringList tempStringList1; + tempStringList1 << defaultTableStyle.getStyleDescription() << defaultTableStyle.getStyleMaintainerName(); + MyStyleListItem *defaultTableItem = new MyStyleListItem(tempStringList1, treeWidget_gameTableStyles); + defaultTableItem->setData(0, 15, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/default/defaulttablestyle.xml"); + defaultTableItem->setData(0, 16, POKERTH_DISTRIBUTED_STYLE); + defaultTableItem->setData(0, Qt::ToolTipRole, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/default/defaulttablestyle.xml"); + defaultTableItem->setData(2, Qt::ToolTipRole, defaultTableStyle.getMyStateToolTipInfo()); + if(defaultTableStyle.getState()) defaultTableItem->setIcon(2, QIcon(":/gfx/emblem-important.png")); + else defaultTableItem->setIcon(2, QIcon(":/gfx/dialog_ok_apply.png")); + } + //add danuxi table + GameTableStyleReader danuxi1TableStyle(myConfig, this); + danuxi1TableStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/danuxi1/danuxi1tablestyle.xml"); + if(danuxi1TableStyle.getLoadedSuccessfull()) { + QStringList tempStringList2; + tempStringList2 << danuxi1TableStyle.getStyleDescription() << danuxi1TableStyle.getStyleMaintainerName(); + MyStyleListItem *danuxi1TableItem = new MyStyleListItem(tempStringList2, treeWidget_gameTableStyles); + danuxi1TableItem->setData(0, 15, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/danuxi1/danuxi1tablestyle.xml"); + danuxi1TableItem->setData(0, 16, POKERTH_DISTRIBUTED_STYLE); + danuxi1TableItem->setData(0, Qt::ToolTipRole, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/danuxi1/danuxi1tablestyle.xml"); + danuxi1TableItem->setData(2, Qt::ToolTipRole, danuxi1TableStyle.getMyStateToolTipInfo()); + if(danuxi1TableStyle.getState()) danuxi1TableItem->setIcon(2, QIcon(":/gfx/emblem-important.png")); + else danuxi1TableItem->setIcon(2, QIcon(":/gfx/dialog_ok_apply.png")); + } - //load secondary styles into list (if fallback no entry) - myGameTableStylesList = myConfig->readConfigStringList("GameTableStylesList"); - list::iterator it1; + //load secondary styles into list (if fallback no entry) + myGameTableStylesList = myConfig->readConfigStringList("GameTableStylesList"); + list::iterator it1; for(it1= myGameTableStylesList.begin(); it1 != myGameTableStylesList.end(); ++it1) { - GameTableStyleReader nextStyle(myConfig, this); - nextStyle.readStyleFile(QString::fromUtf8(it1->c_str())); - if(!nextStyle.getFallBack() && nextStyle.getLoadedSuccessfull()) { - QStringList tempStringList1; - tempStringList1 << nextStyle.getStyleDescription() << nextStyle.getStyleMaintainerName(); - MyStyleListItem *nextItem = new MyStyleListItem(tempStringList1, treeWidget_gameTableStyles); - nextItem->setData(0, 15,QString::fromUtf8(it1->c_str())); - nextItem->setData(0, 16, ADDITIONAL_STYLE); - nextItem->setData(0, Qt::ToolTipRole,QString::fromUtf8(it1->c_str())); - nextItem->setData(2, Qt::ToolTipRole, nextStyle.getMyStateToolTipInfo()); - if(nextStyle.getState()) nextItem->setIcon(2, QIcon(":/gfx/emblem-important.png")); - else nextItem->setIcon(2, QIcon(":/gfx/dialog_ok_apply.png")); - treeWidget_gameTableStyles->addTopLevelItem(nextItem); - } - } - treeWidget_gameTableStyles->sortItems(0, Qt::AscendingOrder); + GameTableStyleReader nextStyle(myConfig, this); + nextStyle.readStyleFile(QString::fromUtf8(it1->c_str())); + if(!nextStyle.getFallBack() && nextStyle.getLoadedSuccessfull()) { + QStringList tempStringList1; + tempStringList1 << nextStyle.getStyleDescription() << nextStyle.getStyleMaintainerName(); + MyStyleListItem *nextItem = new MyStyleListItem(tempStringList1, treeWidget_gameTableStyles); + nextItem->setData(0, 15,QString::fromUtf8(it1->c_str())); + nextItem->setData(0, 16, ADDITIONAL_STYLE); + nextItem->setData(0, Qt::ToolTipRole,QString::fromUtf8(it1->c_str())); + nextItem->setData(2, Qt::ToolTipRole, nextStyle.getMyStateToolTipInfo()); + if(nextStyle.getState()) nextItem->setIcon(2, QIcon(":/gfx/emblem-important.png")); + else nextItem->setIcon(2, QIcon(":/gfx/dialog_ok_apply.png")); + treeWidget_gameTableStyles->addTopLevelItem(nextItem); + } + } + treeWidget_gameTableStyles->sortItems(0, Qt::AscendingOrder); - //set current Game Table Style from config file or fallback to first entry - GameTableStyleReader currentGameTableStyle(myConfig, this); - currentGameTableStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentGameTableStyle").c_str())); - if(currentGameTableStyle.getLoadedSuccessfull()) { - int i; - bool currentGameTableFound(FALSE); - for(i=0; i < treeWidget_gameTableStyles->topLevelItemCount(); i++) { - QTreeWidgetItem *item = treeWidget_gameTableStyles->topLevelItem(i); - if(item->data(0, 15) == currentGameTableStyle.getCurrentFileName()) { - item->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); - treeWidget_gameTableStyles->setCurrentItem(item); - currentGameTableFound=TRUE; - } - else item->setIcon(0, QIcon()); - } - if(!currentGameTableFound) { - qDebug() << "Config ERROR: current game table style file not found in List. Try to mark default as selected."; - QTreeWidgetItem *item = treeWidget_gameTableStyles->topLevelItem(0); - if(item) { - item->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); - treeWidget_gameTableStyles->setCurrentItem(item); - } - } - } - else { - qDebug() << "Config ERROR: current game table style file could not be loaded. Try to mark default as selected."; - QTreeWidgetItem *item = treeWidget_gameTableStyles->topLevelItem(0); - if(item) { - item->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); - treeWidget_gameTableStyles->setCurrentItem(item); - } - } + //set current Game Table Style from config file or fallback to first entry + GameTableStyleReader currentGameTableStyle(myConfig, this); + currentGameTableStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentGameTableStyle").c_str())); + if(currentGameTableStyle.getLoadedSuccessfull()) { + int i; + bool currentGameTableFound(FALSE); + for(i=0; i < treeWidget_gameTableStyles->topLevelItemCount(); i++) { + QTreeWidgetItem *item = treeWidget_gameTableStyles->topLevelItem(i); + if(item->data(0, 15) == currentGameTableStyle.getCurrentFileName()) { + item->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); + treeWidget_gameTableStyles->setCurrentItem(item); + currentGameTableFound=TRUE; + } else item->setIcon(0, QIcon()); + } + if(!currentGameTableFound) { + qDebug() << "Config ERROR: current game table style file not found in List. Try to mark default as selected."; + QTreeWidgetItem *item = treeWidget_gameTableStyles->topLevelItem(0); + if(item) { + item->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); + treeWidget_gameTableStyles->setCurrentItem(item); + } + } + } else { + qDebug() << "Config ERROR: current game table style file could not be loaded. Try to mark default as selected."; + QTreeWidgetItem *item = treeWidget_gameTableStyles->topLevelItem(0); + if(item) { + item->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); + treeWidget_gameTableStyles->setCurrentItem(item); + } + } - //refresh Game Table Style Preview - showCurrentGameTableStylePreview(); + //refresh Game Table Style Preview + showCurrentGameTableStylePreview(); - //CARDS - //define PokerTH default CardDeck - treeWidget_cardDeckStyles->clear(); - CardDeckStyleReader defaultCardStyle(myConfig, this); - defaultCardStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default/defaultdeckstyle.xml"); - if(defaultCardStyle.getLoadedSuccessfull()) { - QStringList tempStringList1; - tempStringList1 << defaultCardStyle.getStyleDescription() << defaultCardStyle.getStyleMaintainerName(); - MyStyleListItem *defaultCardItem = new MyStyleListItem(tempStringList1, treeWidget_cardDeckStyles); - defaultCardItem->setData(0, 15, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default/defaultdeckstyle.xml"); - defaultCardItem->setData(0, 16, POKERTH_DISTRIBUTED_STYLE); - defaultCardItem->setData(0, Qt::ToolTipRole, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default/defaultdeckstyle.xml"); - } - //define PokerTH default CardDeck4c - CardDeckStyleReader default4cCardStyle(myConfig, this); - default4cCardStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default4c/default4cdeckstyle.xml"); - if(default4cCardStyle.getLoadedSuccessfull()) { - QStringList tempStringList1; - tempStringList1 << default4cCardStyle.getStyleDescription() << default4cCardStyle.getStyleMaintainerName(); - MyStyleListItem *default4cCardItem = new MyStyleListItem(tempStringList1, treeWidget_cardDeckStyles); - default4cCardItem->setData(0, 15, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default4c/default4cdeckstyle.xml"); - default4cCardItem->setData(0, 16, POKERTH_DISTRIBUTED_STYLE); - default4cCardItem->setData(0, Qt::ToolTipRole, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default4c/default4cdeckstyle.xml"); - } + //CARDS + //define PokerTH default CardDeck + treeWidget_cardDeckStyles->clear(); + CardDeckStyleReader defaultCardStyle(myConfig, this); + defaultCardStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default/defaultdeckstyle.xml"); + if(defaultCardStyle.getLoadedSuccessfull()) { + QStringList tempStringList1; + tempStringList1 << defaultCardStyle.getStyleDescription() << defaultCardStyle.getStyleMaintainerName(); + MyStyleListItem *defaultCardItem = new MyStyleListItem(tempStringList1, treeWidget_cardDeckStyles); + defaultCardItem->setData(0, 15, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default/defaultdeckstyle.xml"); + defaultCardItem->setData(0, 16, POKERTH_DISTRIBUTED_STYLE); + defaultCardItem->setData(0, Qt::ToolTipRole, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default/defaultdeckstyle.xml"); + } + //define PokerTH default CardDeck4c + CardDeckStyleReader default4cCardStyle(myConfig, this); + default4cCardStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default4c/default4cdeckstyle.xml"); + if(default4cCardStyle.getLoadedSuccessfull()) { + QStringList tempStringList1; + tempStringList1 << default4cCardStyle.getStyleDescription() << default4cCardStyle.getStyleMaintainerName(); + MyStyleListItem *default4cCardItem = new MyStyleListItem(tempStringList1, treeWidget_cardDeckStyles); + default4cCardItem->setData(0, 15, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default4c/default4cdeckstyle.xml"); + default4cCardItem->setData(0, 16, POKERTH_DISTRIBUTED_STYLE); + default4cCardItem->setData(0, Qt::ToolTipRole, QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default4c/default4cdeckstyle.xml"); + } - //load secondary card styles into list (if fallback no entry) - myCardDeckStylesList = myConfig->readConfigStringList("CardDeckStylesList"); - list::iterator it2; + //load secondary card styles into list (if fallback no entry) + myCardDeckStylesList = myConfig->readConfigStringList("CardDeckStylesList"); + list::iterator it2; for(it2= myCardDeckStylesList.begin(); it2 != myCardDeckStylesList.end(); ++it2) { - CardDeckStyleReader nextStyle(myConfig, this); - nextStyle.readStyleFile(QString::fromUtf8(it2->c_str())); - if(!nextStyle.getFallBack() && nextStyle.getLoadedSuccessfull()) { - QStringList tempStringList1; - tempStringList1 << nextStyle.getStyleDescription() << nextStyle.getStyleMaintainerName(); - MyStyleListItem *nextItem = new MyStyleListItem(tempStringList1, treeWidget_cardDeckStyles); - nextItem->setData(0, 15,QString::fromUtf8(it2->c_str())); - nextItem->setData(0, 16, ADDITIONAL_STYLE); - nextItem->setData(0, Qt::ToolTipRole,QString::fromUtf8(it2->c_str())); - treeWidget_cardDeckStyles->addTopLevelItem(nextItem); - } - } - treeWidget_cardDeckStyles->sortItems(0, Qt::AscendingOrder); + CardDeckStyleReader nextStyle(myConfig, this); + nextStyle.readStyleFile(QString::fromUtf8(it2->c_str())); + if(!nextStyle.getFallBack() && nextStyle.getLoadedSuccessfull()) { + QStringList tempStringList1; + tempStringList1 << nextStyle.getStyleDescription() << nextStyle.getStyleMaintainerName(); + MyStyleListItem *nextItem = new MyStyleListItem(tempStringList1, treeWidget_cardDeckStyles); + nextItem->setData(0, 15,QString::fromUtf8(it2->c_str())); + nextItem->setData(0, 16, ADDITIONAL_STYLE); + nextItem->setData(0, Qt::ToolTipRole,QString::fromUtf8(it2->c_str())); + treeWidget_cardDeckStyles->addTopLevelItem(nextItem); + } + } + treeWidget_cardDeckStyles->sortItems(0, Qt::AscendingOrder); - //set current card deck style from config file - CardDeckStyleReader currentCardDeckStyle(myConfig, this); - currentCardDeckStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentCardDeckStyle").c_str())); - if(currentCardDeckStyle.getLoadedSuccessfull()) { - int j; - bool currentCardDeckFound(FALSE); - for(j=0; j < treeWidget_cardDeckStyles->topLevelItemCount(); j++) { - QTreeWidgetItem *item = treeWidget_cardDeckStyles->topLevelItem(j); - if(item->data(0, 15) == currentCardDeckStyle.getCurrentFileName()) { - item->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); - treeWidget_cardDeckStyles->setCurrentItem(item); - currentCardDeckFound=TRUE; - } - else item->setIcon(0, QIcon()); - } - if(!currentCardDeckFound) { - qDebug() << "Config ERROR: current card deck style file not found in List. Try to mark default as selected."; - QTreeWidgetItem *item = treeWidget_cardDeckStyles->topLevelItem(0); - if(item) { - item->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); - treeWidget_cardDeckStyles->setCurrentItem(item); - } - } - } - else { - qDebug() << "Config ERROR: current card deck style file could not be loaded. Try to mark default as selected."; - QTreeWidgetItem *item = treeWidget_cardDeckStyles->topLevelItem(0); - if(item) { - item->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); - treeWidget_cardDeckStyles->setCurrentItem(item); - } - } + //set current card deck style from config file + CardDeckStyleReader currentCardDeckStyle(myConfig, this); + currentCardDeckStyle.readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentCardDeckStyle").c_str())); + if(currentCardDeckStyle.getLoadedSuccessfull()) { + int j; + bool currentCardDeckFound(FALSE); + for(j=0; j < treeWidget_cardDeckStyles->topLevelItemCount(); j++) { + QTreeWidgetItem *item = treeWidget_cardDeckStyles->topLevelItem(j); + if(item->data(0, 15) == currentCardDeckStyle.getCurrentFileName()) { + item->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); + treeWidget_cardDeckStyles->setCurrentItem(item); + currentCardDeckFound=TRUE; + } else item->setIcon(0, QIcon()); + } + if(!currentCardDeckFound) { + qDebug() << "Config ERROR: current card deck style file not found in List. Try to mark default as selected."; + QTreeWidgetItem *item = treeWidget_cardDeckStyles->topLevelItem(0); + if(item) { + item->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); + treeWidget_cardDeckStyles->setCurrentItem(item); + } + } + } else { + qDebug() << "Config ERROR: current card deck style file could not be loaded. Try to mark default as selected."; + QTreeWidgetItem *item = treeWidget_cardDeckStyles->topLevelItem(0); + if(item) { + item->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); + treeWidget_cardDeckStyles->setCurrentItem(item); + } + } - // refresh Card Deck Style Preview - showCurrentCardDeckStylePreview(); + // refresh Card Deck Style Preview + showCurrentCardDeckStylePreview(); - //adjust column sizes for styles treeWidgets - treeWidget_gameTableStyles->resizeColumnToContents(0); - treeWidget_gameTableStyles->resizeColumnToContents(1); - treeWidget_gameTableStyles->resizeColumnToContents(2); - treeWidget_cardDeckStyles->resizeColumnToContents(0); - treeWidget_cardDeckStyles->resizeColumnToContents(1); - treeWidget_cardDeckStyles->resizeColumnToContents(2); + //adjust column sizes for styles treeWidgets + treeWidget_gameTableStyles->resizeColumnToContents(0); + treeWidget_gameTableStyles->resizeColumnToContents(1); + treeWidget_gameTableStyles->resizeColumnToContents(2); + treeWidget_cardDeckStyles->resizeColumnToContents(0); + treeWidget_cardDeckStyles->resizeColumnToContents(1); + treeWidget_cardDeckStyles->resizeColumnToContents(2); - radioButton_flipsideTux->setChecked(myConfig->readConfigInt("FlipsideTux")); - radioButton_flipsideOwn->setChecked(myConfig->readConfigInt("FlipsideOwn")); - if(radioButton_flipsideOwn->isChecked()) { - lineEdit_OwnFlipsideFilename->setEnabled(TRUE); - pushButton_openFlipsidePicture->setEnabled(TRUE); - } - lineEdit_OwnFlipsideFilename->setText(QString::fromUtf8(myConfig->readConfigString("FlipsideOwnFile").c_str())); + radioButton_flipsideTux->setChecked(myConfig->readConfigInt("FlipsideTux")); + radioButton_flipsideOwn->setChecked(myConfig->readConfigInt("FlipsideOwn")); + if(radioButton_flipsideOwn->isChecked()) { + lineEdit_OwnFlipsideFilename->setEnabled(TRUE); + pushButton_openFlipsidePicture->setEnabled(TRUE); + } + lineEdit_OwnFlipsideFilename->setText(QString::fromUtf8(myConfig->readConfigString("FlipsideOwnFile").c_str())); - //Sound - groupBox_playSoundEffects->setChecked(myConfig->readConfigInt("PlaySoundEffects")); - horizontalSlider_soundVolume->setValue(myConfig->readConfigInt("SoundVolume")); - checkBox_playGameActions->setChecked(myConfig->readConfigInt("PlayGameActions")); - checkBox_playLobbyChatNotification->setChecked(myConfig->readConfigInt("PlayLobbyChatNotification")); - checkBox_playNetworkGameNotification->setChecked(myConfig->readConfigInt("PlayNetworkGameNotification")); + //Sound + groupBox_playSoundEffects->setChecked(myConfig->readConfigInt("PlaySoundEffects")); + horizontalSlider_soundVolume->setValue(myConfig->readConfigInt("SoundVolume")); + checkBox_playGameActions->setChecked(myConfig->readConfigInt("PlayGameActions")); + checkBox_playLobbyChatNotification->setChecked(myConfig->readConfigInt("PlayLobbyChatNotification")); + checkBox_playNetworkGameNotification->setChecked(myConfig->readConfigInt("PlayNetworkGameNotification")); - //Log - groupBox_logOnOff->setChecked(myConfig->readConfigInt("LogOnOff")); - lineEdit_logDir->setText(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str())); - spinBox_logStoreDuration->setValue(myConfig->readConfigInt("LogStoreDuration")); - comboBox_logInterval->setCurrentIndex(myConfig->readConfigInt("LogInterval")); + //Log + groupBox_logOnOff->setChecked(myConfig->readConfigInt("LogOnOff")); + lineEdit_logDir->setText(QString::fromUtf8(myConfig->readConfigString("LogDir").c_str())); + spinBox_logStoreDuration->setValue(myConfig->readConfigInt("LogStoreDuration")); + comboBox_logInterval->setCurrentIndex(myConfig->readConfigInt("LogInterval")); - refreshLogFileList(); + refreshLogFileList(); - bool tmpHasIpv6 = socket_has_ipv6(); - bool tmpHasSctp = socket_has_sctp(); - checkBox_useIpv6->setEnabled(tmpHasIpv6); - checkBox_useSctp->setEnabled(tmpHasSctp); - checkBox_InternetServerUseIpv6->setEnabled(tmpHasIpv6); - checkBox_InternetServerUseSctp->setEnabled(tmpHasSctp); + bool tmpHasIpv6 = socket_has_ipv6(); + bool tmpHasSctp = socket_has_sctp(); + checkBox_useIpv6->setEnabled(tmpHasIpv6); + checkBox_useSctp->setEnabled(tmpHasSctp); + checkBox_InternetServerUseIpv6->setEnabled(tmpHasIpv6); + checkBox_InternetServerUseSctp->setEnabled(tmpHasSctp); - //Manual Blinds Order Dialog (local) - myManualBlindsList = myConfig->readConfigIntList("ManualBlindsList"); - myAfterMBAlwaysDoubleBlinds = myConfig->readConfigInt("AfterMBAlwaysDoubleBlinds"); - myAfterMBAlwaysRaiseAbout = myConfig->readConfigInt("AfterMBAlwaysRaiseAbout"); - myAfterMBAlwaysRaiseValue = myConfig->readConfigInt("AfterMBAlwaysRaiseValue"); - myAfterMBStayAtLastBlind = myConfig->readConfigInt("AfterMBStayAtLastBlind"); + //Manual Blinds Order Dialog (local) + myManualBlindsList = myConfig->readConfigIntList("ManualBlindsList"); + myAfterMBAlwaysDoubleBlinds = myConfig->readConfigInt("AfterMBAlwaysDoubleBlinds"); + myAfterMBAlwaysRaiseAbout = myConfig->readConfigInt("AfterMBAlwaysRaiseAbout"); + myAfterMBAlwaysRaiseValue = myConfig->readConfigInt("AfterMBAlwaysRaiseValue"); + myAfterMBStayAtLastBlind = myConfig->readConfigInt("AfterMBStayAtLastBlind"); - //Manual Blinds Order Dialog (network) - myNetManualBlindsList = myConfig->readConfigIntList("NetManualBlindsList"); - myNetAfterMBAlwaysDoubleBlinds = myConfig->readConfigInt("NetAfterMBAlwaysDoubleBlinds"); - myNetAfterMBAlwaysRaiseAbout = myConfig->readConfigInt("NetAfterMBAlwaysRaiseAbout"); - myNetAfterMBAlwaysRaiseValue = myConfig->readConfigInt("NetAfterMBAlwaysRaiseValue"); - myNetAfterMBStayAtLastBlind = myConfig->readConfigInt("NetAfterMBStayAtLastBlind"); + //Manual Blinds Order Dialog (network) + myNetManualBlindsList = myConfig->readConfigIntList("NetManualBlindsList"); + myNetAfterMBAlwaysDoubleBlinds = myConfig->readConfigInt("NetAfterMBAlwaysDoubleBlinds"); + myNetAfterMBAlwaysRaiseAbout = myConfig->readConfigInt("NetAfterMBAlwaysRaiseAbout"); + myNetAfterMBAlwaysRaiseValue = myConfig->readConfigInt("NetAfterMBAlwaysRaiseValue"); + myNetAfterMBStayAtLastBlind = myConfig->readConfigInt("NetAfterMBStayAtLastBlind"); - setFirstSmallBlindMargin(); + setFirstSmallBlindMargin(); - //set this AFTER switch combobox like config-settings. This IS a currentIndexChanged() ;-) - languageIsChanged = FALSE; + //set this AFTER switch combobox like config-settings. This IS a currentIndexChanged() ;-) + languageIsChanged = FALSE; } -void settingsDialogImpl::exec() { +void settingsDialogImpl::exec() +{ - prepareDialog(); - QDialog::exec(); + prepareDialog(); + QDialog::exec(); } -void settingsDialogImpl::isAccepted() { +void settingsDialogImpl::isAccepted() +{ - settingsCorrect = TRUE; + settingsCorrect = TRUE; - // Player Nicks - myConfig->writeConfigString("MyName", lineEdit_HumanPlayerName->text().trimmed().toUtf8().constData()); - myConfig->writeConfigString("MyAvatar", pushButton_HumanPlayerAvatar->getMyLink().toUtf8().constData()); + // Player Nicks + myConfig->writeConfigString("MyName", lineEdit_HumanPlayerName->text().trimmed().toUtf8().constData()); + myConfig->writeConfigString("MyAvatar", pushButton_HumanPlayerAvatar->getMyLink().toUtf8().constData()); - myConfig->writeConfigString("Opponent1Name", lineEdit_Opponent1Name->text().toUtf8().constData()); - myConfig->writeConfigString("Opponent1Avatar", pushButton_Opponent1Avatar->getMyLink().toUtf8().constData()); + myConfig->writeConfigString("Opponent1Name", lineEdit_Opponent1Name->text().toUtf8().constData()); + myConfig->writeConfigString("Opponent1Avatar", pushButton_Opponent1Avatar->getMyLink().toUtf8().constData()); - myConfig->writeConfigString("Opponent2Name", lineEdit_Opponent2Name->text().toUtf8().constData()); - myConfig->writeConfigString("Opponent2Avatar", pushButton_Opponent2Avatar->getMyLink().toUtf8().constData()); + myConfig->writeConfigString("Opponent2Name", lineEdit_Opponent2Name->text().toUtf8().constData()); + myConfig->writeConfigString("Opponent2Avatar", pushButton_Opponent2Avatar->getMyLink().toUtf8().constData()); - myConfig->writeConfigString("Opponent3Name", lineEdit_Opponent3Name->text().toUtf8().constData()); - myConfig->writeConfigString("Opponent3Avatar", pushButton_Opponent3Avatar->getMyLink().toUtf8().constData()); + myConfig->writeConfigString("Opponent3Name", lineEdit_Opponent3Name->text().toUtf8().constData()); + myConfig->writeConfigString("Opponent3Avatar", pushButton_Opponent3Avatar->getMyLink().toUtf8().constData()); - myConfig->writeConfigString("Opponent4Name", lineEdit_Opponent4Name->text().toUtf8().constData()); - myConfig->writeConfigString("Opponent4Avatar", pushButton_Opponent4Avatar->getMyLink().toUtf8().constData()); + myConfig->writeConfigString("Opponent4Name", lineEdit_Opponent4Name->text().toUtf8().constData()); + myConfig->writeConfigString("Opponent4Avatar", pushButton_Opponent4Avatar->getMyLink().toUtf8().constData()); - myConfig->writeConfigString("Opponent5Name", lineEdit_Opponent5Name->text().toUtf8().constData()); - myConfig->writeConfigString("Opponent5Avatar", pushButton_Opponent5Avatar->getMyLink().toUtf8().constData()); + myConfig->writeConfigString("Opponent5Name", lineEdit_Opponent5Name->text().toUtf8().constData()); + myConfig->writeConfigString("Opponent5Avatar", pushButton_Opponent5Avatar->getMyLink().toUtf8().constData()); - myConfig->writeConfigString("Opponent6Name", lineEdit_Opponent6Name->text().toUtf8().constData()); - myConfig->writeConfigString("Opponent6Avatar", pushButton_Opponent6Avatar->getMyLink().toUtf8().constData()); + myConfig->writeConfigString("Opponent6Name", lineEdit_Opponent6Name->text().toUtf8().constData()); + myConfig->writeConfigString("Opponent6Avatar", pushButton_Opponent6Avatar->getMyLink().toUtf8().constData()); - myConfig->writeConfigString("Opponent7Name", lineEdit_Opponent7Name->text().toUtf8().constData()); - myConfig->writeConfigString("Opponent7Avatar", pushButton_Opponent7Avatar->getMyLink().toUtf8().constData()); + myConfig->writeConfigString("Opponent7Name", lineEdit_Opponent7Name->text().toUtf8().constData()); + myConfig->writeConfigString("Opponent7Avatar", pushButton_Opponent7Avatar->getMyLink().toUtf8().constData()); - myConfig->writeConfigString("Opponent8Name", lineEdit_Opponent8Name->text().toUtf8().constData()); - myConfig->writeConfigString("Opponent8Avatar", pushButton_Opponent8Avatar->getMyLink().toUtf8().constData()); + myConfig->writeConfigString("Opponent8Name", lineEdit_Opponent8Name->text().toUtf8().constData()); + myConfig->writeConfigString("Opponent8Avatar", pushButton_Opponent8Avatar->getMyLink().toUtf8().constData()); - myConfig->writeConfigString("Opponent9Name", lineEdit_Opponent9Name->text().toUtf8().constData()); - myConfig->writeConfigString("Opponent9Avatar", pushButton_Opponent9Avatar->getMyLink().toUtf8().constData()); + myConfig->writeConfigString("Opponent9Name", lineEdit_Opponent9Name->text().toUtf8().constData()); + myConfig->writeConfigString("Opponent9Avatar", pushButton_Opponent9Avatar->getMyLink().toUtf8().constData()); - // Local Game Settings - myConfig->writeConfigInt("NumberOfPlayers", spinBox_quantityPlayers->value()); - myConfig->writeConfigInt("StartCash", spinBox_startCash->value()); - myConfig->writeConfigInt("FirstSmallBlind", spinBox_firstSmallBlind->value()); - myConfig->writeConfigInt("RaiseBlindsAtHands", radioButton_raiseBlindsAtHands->isChecked()); - myConfig->writeConfigInt("RaiseBlindsAtMinutes", radioButton_raiseBlindsAtMinutes->isChecked()); - myConfig->writeConfigInt("RaiseSmallBlindEveryHands", spinBox_raiseSmallBlindEveryHands->value()); - myConfig->writeConfigInt("RaiseSmallBlindEveryMinutes", spinBox_raiseSmallBlindEveryMinutes->value()); - myConfig->writeConfigInt("AlwaysDoubleBlinds", radioButton_alwaysDoubleBlinds->isChecked()); - myConfig->writeConfigInt("ManualBlindsOrder", radioButton_manualBlindsOrder->isChecked()); - myConfig->writeConfigInt("GameSpeed", spinBox_gameSpeed->value()); - myConfig->writeConfigInt("PauseBetweenHands", checkBox_pauseBetweenHands->isChecked()); - myConfig->writeConfigInt("ShowGameSettingsDialogOnNewGame", checkBox_showGameSettingsDialogOnNewGame->isChecked()); + // Local Game Settings + myConfig->writeConfigInt("NumberOfPlayers", spinBox_quantityPlayers->value()); + myConfig->writeConfigInt("StartCash", spinBox_startCash->value()); + myConfig->writeConfigInt("FirstSmallBlind", spinBox_firstSmallBlind->value()); + myConfig->writeConfigInt("RaiseBlindsAtHands", radioButton_raiseBlindsAtHands->isChecked()); + myConfig->writeConfigInt("RaiseBlindsAtMinutes", radioButton_raiseBlindsAtMinutes->isChecked()); + myConfig->writeConfigInt("RaiseSmallBlindEveryHands", spinBox_raiseSmallBlindEveryHands->value()); + myConfig->writeConfigInt("RaiseSmallBlindEveryMinutes", spinBox_raiseSmallBlindEveryMinutes->value()); + myConfig->writeConfigInt("AlwaysDoubleBlinds", radioButton_alwaysDoubleBlinds->isChecked()); + myConfig->writeConfigInt("ManualBlindsOrder", radioButton_manualBlindsOrder->isChecked()); + myConfig->writeConfigInt("GameSpeed", spinBox_gameSpeed->value()); + myConfig->writeConfigInt("PauseBetweenHands", checkBox_pauseBetweenHands->isChecked()); + myConfig->writeConfigInt("ShowGameSettingsDialogOnNewGame", checkBox_showGameSettingsDialogOnNewGame->isChecked()); - //Network Game Settings - myConfig->writeConfigInt("NetNumberOfPlayers", spinBox_netQuantityPlayers->value()); - myConfig->writeConfigInt("NetStartCash", spinBox_netStartCash->value()); - myConfig->writeConfigInt("NetFirstSmallBlind", spinBox_netFirstSmallBlind->value()); - myConfig->writeConfigInt("NetRaiseBlindsAtHands", radioButton_netRaiseBlindsAtHands->isChecked()); - myConfig->writeConfigInt("NetRaiseBlindsAtMinutes", radioButton_netRaiseBlindsAtMinutes->isChecked()); - myConfig->writeConfigInt("NetRaiseSmallBlindEveryHands", spinBox_netRaiseSmallBlindEveryHands->value()); - myConfig->writeConfigInt("NetRaiseSmallBlindEveryMinutes", spinBox_netRaiseSmallBlindEveryMinutes->value()); - myConfig->writeConfigInt("NetAlwaysDoubleBlinds", radioButton_netAlwaysDoubleBlinds->isChecked()); - myConfig->writeConfigInt("NetManualBlindsOrder", radioButton_netManualBlindsOrder->isChecked()); - myConfig->writeConfigInt("NetDelayBetweenHands", spinBox_netDelayBetweenHands->value()); - myConfig->writeConfigInt("NetTimeOutPlayerAction", spinBox_netTimeOutPlayerAction->value()); - myConfig->writeConfigInt("ServerPort", spinBox_serverPort->value()); - myConfig->writeConfigInt("ServerUseIpv6", checkBox_useIpv6->isChecked()); - myConfig->writeConfigInt("ServerUseSctp", checkBox_useSctp->isChecked()); + //Network Game Settings + myConfig->writeConfigInt("NetNumberOfPlayers", spinBox_netQuantityPlayers->value()); + myConfig->writeConfigInt("NetStartCash", spinBox_netStartCash->value()); + myConfig->writeConfigInt("NetFirstSmallBlind", spinBox_netFirstSmallBlind->value()); + myConfig->writeConfigInt("NetRaiseBlindsAtHands", radioButton_netRaiseBlindsAtHands->isChecked()); + myConfig->writeConfigInt("NetRaiseBlindsAtMinutes", radioButton_netRaiseBlindsAtMinutes->isChecked()); + myConfig->writeConfigInt("NetRaiseSmallBlindEveryHands", spinBox_netRaiseSmallBlindEveryHands->value()); + myConfig->writeConfigInt("NetRaiseSmallBlindEveryMinutes", spinBox_netRaiseSmallBlindEveryMinutes->value()); + myConfig->writeConfigInt("NetAlwaysDoubleBlinds", radioButton_netAlwaysDoubleBlinds->isChecked()); + myConfig->writeConfigInt("NetManualBlindsOrder", radioButton_netManualBlindsOrder->isChecked()); + myConfig->writeConfigInt("NetDelayBetweenHands", spinBox_netDelayBetweenHands->value()); + myConfig->writeConfigInt("NetTimeOutPlayerAction", spinBox_netTimeOutPlayerAction->value()); + myConfig->writeConfigInt("ServerPort", spinBox_serverPort->value()); + myConfig->writeConfigInt("ServerUseIpv6", checkBox_useIpv6->isChecked()); + myConfig->writeConfigInt("ServerUseSctp", checkBox_useSctp->isChecked()); - //Internet Game Settings - if(groupBox_automaticServerConfig->isChecked()) { + //Internet Game Settings + if(groupBox_automaticServerConfig->isChecked()) { - myConfig->writeConfigInt("InternetServerConfigMode", 0); + myConfig->writeConfigInt("InternetServerConfigMode", 0); - // QUrl serverList; - // serverList.setUrl(lineEdit_InternetServerListAddress->text(),QUrl::StrictMode); - // QRegExp rx("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?"); - // if(lineEdit_InternetServerListAddress->text().contains(rx)) { - if(lineEdit_InternetServerListAddress->text().contains("/") && lineEdit_InternetServerListAddress->text().contains(".") ) { + // QUrl serverList; + // serverList.setUrl(lineEdit_InternetServerListAddress->text(),QUrl::StrictMode); + // QRegExp rx("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?"); + // if(lineEdit_InternetServerListAddress->text().contains(rx)) { + if(lineEdit_InternetServerListAddress->text().contains("/") && lineEdit_InternetServerListAddress->text().contains(".") ) { - myConfig->writeConfigString("InternetServerListAddress", lineEdit_InternetServerListAddress->text().toUtf8().constData()); - } - else { - QMessageBox::warning(this, tr("Settings Error"), - tr("The entered server list address is not a valid URL.\n" - "Please enter a valid server list address!"), - QMessageBox::Ok); - settingsCorrect = FALSE; - } - } - if(groupBox_manualServerConfig->isChecked()) { + myConfig->writeConfigString("InternetServerListAddress", lineEdit_InternetServerListAddress->text().toUtf8().constData()); + } else { + QMessageBox::warning(this, tr("Settings Error"), + tr("The entered server list address is not a valid URL.\n" + "Please enter a valid server list address!"), + QMessageBox::Ok); + settingsCorrect = FALSE; + } + } + if(groupBox_manualServerConfig->isChecked()) { - myConfig->writeConfigInt("InternetServerConfigMode", 1); - myConfig->writeConfigString("InternetServerAddress", lineEdit_InternetServerAddress->text().toUtf8().constData()); - myConfig->writeConfigInt("InternetServerPort", spinBox_InternetServerPort->value()); - } - if(checkBox_useAvatarServer->isChecked()) { - myConfig->writeConfigInt("UseAvatarServer", 1); - myConfig->writeConfigString("AvatarServerAddress", lineEdit_avatarServerAddress->text().toUtf8().constData()); - } - else { - myConfig->writeConfigInt("UseAvatarServer", 0); - } + myConfig->writeConfigInt("InternetServerConfigMode", 1); + myConfig->writeConfigString("InternetServerAddress", lineEdit_InternetServerAddress->text().toUtf8().constData()); + myConfig->writeConfigInt("InternetServerPort", spinBox_InternetServerPort->value()); + } + if(checkBox_useAvatarServer->isChecked()) { + myConfig->writeConfigInt("UseAvatarServer", 1); + myConfig->writeConfigString("AvatarServerAddress", lineEdit_avatarServerAddress->text().toUtf8().constData()); + } else { + myConfig->writeConfigInt("UseAvatarServer", 0); + } - myConfig->writeConfigInt("InternetServerUseIpv6", checkBox_InternetServerUseIpv6->isChecked()); - myConfig->writeConfigInt("InternetServerUseSctp", checkBox_InternetServerUseSctp->isChecked()); - myConfig->writeConfigInt("UseInternetGamePassword", checkBox_UseInternetGamePassword->isChecked()); - myConfig->writeConfigString("InternetGamePassword", lineEdit_InternetGamePassword->text().toUtf8().constData()); - myConfig->writeConfigInt("UseLobbyChat", checkBox_UseLobbyChat->isChecked()); - myConfig->writeConfigInt("InternetGameType", comboBox_internetGameType->currentIndex()); - myConfig->writeConfigString("InternetGameName", lineEdit_internetGameName->text().toUtf8().constData()); + myConfig->writeConfigInt("InternetServerUseIpv6", checkBox_InternetServerUseIpv6->isChecked()); + myConfig->writeConfigInt("InternetServerUseSctp", checkBox_InternetServerUseSctp->isChecked()); + myConfig->writeConfigInt("UseInternetGamePassword", checkBox_UseInternetGamePassword->isChecked()); + myConfig->writeConfigString("InternetGamePassword", lineEdit_InternetGamePassword->text().toUtf8().constData()); + myConfig->writeConfigInt("UseLobbyChat", checkBox_UseLobbyChat->isChecked()); + myConfig->writeConfigInt("InternetGameType", comboBox_internetGameType->currentIndex()); + myConfig->writeConfigString("InternetGameName", lineEdit_internetGameName->text().toUtf8().constData()); - int k; - std::list playerIgnoreList; - for(k=0; ktopLevelItemCount(); k++) { - playerIgnoreList.push_back(QString("%1").arg(treeWidget_internetGameIgnoredPlayers->topLevelItem(k)->text(0)).toUtf8().constData()); - } - myConfig->writeConfigStringList("PlayerIgnoreList", playerIgnoreList); + int k; + std::list playerIgnoreList; + for(k=0; ktopLevelItemCount(); k++) { + playerIgnoreList.push_back(QString("%1").arg(treeWidget_internetGameIgnoredPlayers->topLevelItem(k)->text(0)).toUtf8().constData()); + } + myConfig->writeConfigStringList("PlayerIgnoreList", playerIgnoreList); - // Interface - myConfig->writeConfigString("Language", comboBox_switchLanguage->itemData(comboBox_switchLanguage->currentIndex()).toString().toUtf8().constData()); - myConfig->writeConfigInt("ShowLeftToolBox", checkBox_showLeftToolbox->isChecked()); - myConfig->writeConfigInt("ShowRightToolBox", checkBox_showRightToolbox->isChecked()); - myConfig->writeConfigInt("ShowFadeOutCardsAnimation", checkBox_showFadeOutCardsAnimation->isChecked()); - myConfig->writeConfigInt("ShowFlipCardsAnimation", checkBox_showFlipCardsAnimation->isChecked()); - myConfig->writeConfigInt("ShowBlindButtons", checkBox_showBlindButtons->isChecked()); - myConfig->writeConfigInt("ShowCardsChanceMonitor", checkBox_cardsChanceMonitor->isChecked()); - myConfig->writeConfigInt("AntiPeekMode", checkBox_antiPeekMode->isChecked()); - myConfig->writeConfigInt("ShowCountryFlagInAvatar", checkBox_showCountryFlagInAvatar->isChecked()); - myConfig->writeConfigInt("AlternateFKeysUserActionMode", checkBox_alternateFKeysUserActionMode->isChecked()); - myConfig->writeConfigInt("DontTranslateInternationalPokerStringsFromStyle", checkBox_dontTranslatePokerStrings->isChecked()); - myConfig->writeConfigInt("DisableSplashScreenOnStartup", checkBox_disableSplashscreen->isChecked()); - myConfig->writeConfigInt("EnableBetInputFocusSwitch", checkBox_enableBetInputFocusSwitch->isChecked()); - myConfig->writeConfigInt("FlipsideTux", radioButton_flipsideTux->isChecked()); - myConfig->writeConfigInt("FlipsideOwn", radioButton_flipsideOwn->isChecked()); + // Interface + myConfig->writeConfigString("Language", comboBox_switchLanguage->itemData(comboBox_switchLanguage->currentIndex()).toString().toUtf8().constData()); + myConfig->writeConfigInt("ShowLeftToolBox", checkBox_showLeftToolbox->isChecked()); + myConfig->writeConfigInt("ShowRightToolBox", checkBox_showRightToolbox->isChecked()); + myConfig->writeConfigInt("ShowFadeOutCardsAnimation", checkBox_showFadeOutCardsAnimation->isChecked()); + myConfig->writeConfigInt("ShowFlipCardsAnimation", checkBox_showFlipCardsAnimation->isChecked()); + myConfig->writeConfigInt("ShowBlindButtons", checkBox_showBlindButtons->isChecked()); + myConfig->writeConfigInt("ShowCardsChanceMonitor", checkBox_cardsChanceMonitor->isChecked()); + myConfig->writeConfigInt("AntiPeekMode", checkBox_antiPeekMode->isChecked()); + myConfig->writeConfigInt("ShowCountryFlagInAvatar", checkBox_showCountryFlagInAvatar->isChecked()); + myConfig->writeConfigInt("AlternateFKeysUserActionMode", checkBox_alternateFKeysUserActionMode->isChecked()); + myConfig->writeConfigInt("DontTranslateInternationalPokerStringsFromStyle", checkBox_dontTranslatePokerStrings->isChecked()); + myConfig->writeConfigInt("DisableSplashScreenOnStartup", checkBox_disableSplashscreen->isChecked()); + myConfig->writeConfigInt("EnableBetInputFocusSwitch", checkBox_enableBetInputFocusSwitch->isChecked()); + myConfig->writeConfigInt("FlipsideTux", radioButton_flipsideTux->isChecked()); + myConfig->writeConfigInt("FlipsideOwn", radioButton_flipsideOwn->isChecked()); - if(radioButton_flipsideOwn->isChecked()) { - QFile ownFlipsideFilename(lineEdit_OwnFlipsideFilename->text()); - if(ownFlipsideFilename.exists() && lineEdit_OwnFlipsideFilename->text() != "") {myConfig->writeConfigString("FlipsideOwnFile", lineEdit_OwnFlipsideFilename->text().toUtf8().constData()); } - else { QMessageBox::warning(this, tr("Settings Error"), - tr("The entered flipside picture doesn't exist.\n" - "Please enter an valid picture!"), - QMessageBox::Ok); - settingsCorrect = FALSE; - } - } + if(radioButton_flipsideOwn->isChecked()) { + QFile ownFlipsideFilename(lineEdit_OwnFlipsideFilename->text()); + if(ownFlipsideFilename.exists() && lineEdit_OwnFlipsideFilename->text() != "") { + myConfig->writeConfigString("FlipsideOwnFile", lineEdit_OwnFlipsideFilename->text().toUtf8().constData()); + } else { + QMessageBox::warning(this, tr("Settings Error"), + tr("The entered flipside picture doesn't exist.\n" + "Please enter an valid picture!"), + QMessageBox::Ok); + settingsCorrect = FALSE; + } + } - //S T Y L E - // TABLE - //save game table styles list - myGameTableStylesList.clear(); - int i; - for(i=0; i < treeWidget_gameTableStyles->topLevelItemCount(); i++) { - QTreeWidgetItem *item = treeWidget_gameTableStyles->topLevelItem(i); - if(item->data(0, 16).toInt() == ADDITIONAL_STYLE) { - myGameTableStylesList.push_back(item->data(0, 15).toString().toUtf8().constData()); - } - } - myConfig->writeConfigStringList("GameTableStylesList", myGameTableStylesList); - //save current game table style - for(i=0; i < treeWidget_gameTableStyles->topLevelItemCount(); i++) { - QTreeWidgetItem *item = treeWidget_gameTableStyles->topLevelItem(i); - if(!item->icon(0).isNull()) - myConfig->writeConfigString("CurrentGameTableStyle", item->data(0, 15).toString().toUtf8().constData()); - } - // CARDS - //save card deck styles list - myCardDeckStylesList.clear(); - int j; - for(j=0; j < treeWidget_cardDeckStyles->topLevelItemCount(); j++) { - QTreeWidgetItem *item = treeWidget_cardDeckStyles->topLevelItem(j); - if(item->data(0, 16).toInt() == ADDITIONAL_STYLE) { - myCardDeckStylesList.push_back(item->data(0, 15).toString().toUtf8().constData()); - } - } - myConfig->writeConfigStringList("CardDeckStylesList", myCardDeckStylesList); - //save current card deck style - for(j=0; j < treeWidget_cardDeckStyles->topLevelItemCount(); j++) { - QTreeWidgetItem *item = treeWidget_cardDeckStyles->topLevelItem(j); - if(!item->icon(0).isNull()) - myConfig->writeConfigString("CurrentCardDeckStyle", item->data(0, 15).toString().toUtf8().constData()); - } + //S T Y L E + // TABLE + //save game table styles list + myGameTableStylesList.clear(); + int i; + for(i=0; i < treeWidget_gameTableStyles->topLevelItemCount(); i++) { + QTreeWidgetItem *item = treeWidget_gameTableStyles->topLevelItem(i); + if(item->data(0, 16).toInt() == ADDITIONAL_STYLE) { + myGameTableStylesList.push_back(item->data(0, 15).toString().toUtf8().constData()); + } + } + myConfig->writeConfigStringList("GameTableStylesList", myGameTableStylesList); + //save current game table style + for(i=0; i < treeWidget_gameTableStyles->topLevelItemCount(); i++) { + QTreeWidgetItem *item = treeWidget_gameTableStyles->topLevelItem(i); + if(!item->icon(0).isNull()) + myConfig->writeConfigString("CurrentGameTableStyle", item->data(0, 15).toString().toUtf8().constData()); + } + // CARDS + //save card deck styles list + myCardDeckStylesList.clear(); + int j; + for(j=0; j < treeWidget_cardDeckStyles->topLevelItemCount(); j++) { + QTreeWidgetItem *item = treeWidget_cardDeckStyles->topLevelItem(j); + if(item->data(0, 16).toInt() == ADDITIONAL_STYLE) { + myCardDeckStylesList.push_back(item->data(0, 15).toString().toUtf8().constData()); + } + } + myConfig->writeConfigStringList("CardDeckStylesList", myCardDeckStylesList); + //save current card deck style + for(j=0; j < treeWidget_cardDeckStyles->topLevelItemCount(); j++) { + QTreeWidgetItem *item = treeWidget_cardDeckStyles->topLevelItem(j); + if(!item->icon(0).isNull()) + myConfig->writeConfigString("CurrentCardDeckStyle", item->data(0, 15).toString().toUtf8().constData()); + } - //Sound - myConfig->writeConfigInt("PlaySoundEffects", groupBox_playSoundEffects->isChecked()); - myConfig->writeConfigInt("SoundVolume", horizontalSlider_soundVolume->value()); - myConfig->writeConfigInt("PlayGameActions", checkBox_playGameActions->isChecked()); - myConfig->writeConfigInt("PlayLobbyChatNotification", checkBox_playLobbyChatNotification->isChecked()); - myConfig->writeConfigInt("PlayNetworkGameNotification", checkBox_playNetworkGameNotification->isChecked()); + //Sound + myConfig->writeConfigInt("PlaySoundEffects", groupBox_playSoundEffects->isChecked()); + myConfig->writeConfigInt("SoundVolume", horizontalSlider_soundVolume->value()); + myConfig->writeConfigInt("PlayGameActions", checkBox_playGameActions->isChecked()); + myConfig->writeConfigInt("PlayLobbyChatNotification", checkBox_playLobbyChatNotification->isChecked()); + myConfig->writeConfigInt("PlayNetworkGameNotification", checkBox_playNetworkGameNotification->isChecked()); - // Log - myConfig->writeConfigInt("LogOnOff", groupBox_logOnOff->isChecked()); - if (myConfig->readConfigInt("LogOnOff")) { - // if log On - QDir logDir(lineEdit_logDir->text()); - if(logDir.exists() && lineEdit_logDir->text() != "") { myConfig->writeConfigString("LogDir", lineEdit_logDir->text().toUtf8().constData()); } - else { - QMessageBox::warning(this, tr("Settings Error"), - tr("The log file directory doesn't exist.\n" - "Please select an valid directory!"), - QMessageBox::Ok); - settingsCorrect = FALSE; - } - - myConfig->writeConfigInt("LogStoreDuration", spinBox_logStoreDuration->value()); - myConfig->writeConfigInt("LogInterval", comboBox_logInterval->currentIndex()); - } + // Log + myConfig->writeConfigInt("LogOnOff", groupBox_logOnOff->isChecked()); + if (myConfig->readConfigInt("LogOnOff")) { + // if log On + QDir logDir(lineEdit_logDir->text()); + if(logDir.exists() && lineEdit_logDir->text() != "") { + myConfig->writeConfigString("LogDir", lineEdit_logDir->text().toUtf8().constData()); + } else { + QMessageBox::warning(this, tr("Settings Error"), + tr("The log file directory doesn't exist.\n" + "Please select an valid directory!"), + QMessageBox::Ok); + settingsCorrect = FALSE; + } - //Manual Blinds Order Dialog (local) - myConfig->writeConfigIntList("ManualBlindsList",myManualBlindsList); - myConfig->writeConfigInt("AfterMBAlwaysDoubleBlinds",myAfterMBAlwaysDoubleBlinds); - myConfig->writeConfigInt("AfterMBAlwaysRaiseAbout",myAfterMBAlwaysRaiseAbout); - myConfig->writeConfigInt("AfterMBAlwaysRaiseValue",myAfterMBAlwaysRaiseValue); - myConfig->writeConfigInt("AfterMBStayAtLastBlind",myAfterMBStayAtLastBlind); + myConfig->writeConfigInt("LogStoreDuration", spinBox_logStoreDuration->value()); + myConfig->writeConfigInt("LogInterval", comboBox_logInterval->currentIndex()); + } - //Manual Blinds Order Dialog (network) - myConfig->writeConfigIntList("NetManualBlindsList",myNetManualBlindsList); - myConfig->writeConfigInt("NetAfterMBAlwaysDoubleBlinds",myNetAfterMBAlwaysDoubleBlinds); - myConfig->writeConfigInt("NetAfterMBAlwaysRaiseAbout",myNetAfterMBAlwaysRaiseAbout); - myConfig->writeConfigInt("NetAfterMBAlwaysRaiseValue",myNetAfterMBAlwaysRaiseValue); - myConfig->writeConfigInt("NetAfterMBStayAtLastBlind",myNetAfterMBStayAtLastBlind); + //Manual Blinds Order Dialog (local) + myConfig->writeConfigIntList("ManualBlindsList",myManualBlindsList); + myConfig->writeConfigInt("AfterMBAlwaysDoubleBlinds",myAfterMBAlwaysDoubleBlinds); + myConfig->writeConfigInt("AfterMBAlwaysRaiseAbout",myAfterMBAlwaysRaiseAbout); + myConfig->writeConfigInt("AfterMBAlwaysRaiseValue",myAfterMBAlwaysRaiseValue); + myConfig->writeConfigInt("AfterMBStayAtLastBlind",myAfterMBStayAtLastBlind); + + //Manual Blinds Order Dialog (network) + myConfig->writeConfigIntList("NetManualBlindsList",myNetManualBlindsList); + myConfig->writeConfigInt("NetAfterMBAlwaysDoubleBlinds",myNetAfterMBAlwaysDoubleBlinds); + myConfig->writeConfigInt("NetAfterMBAlwaysRaiseAbout",myNetAfterMBAlwaysRaiseAbout); + myConfig->writeConfigInt("NetAfterMBAlwaysRaiseValue",myNetAfterMBAlwaysRaiseValue); + myConfig->writeConfigInt("NetAfterMBStayAtLastBlind",myNetAfterMBStayAtLastBlind); - //write buffer to disc - myConfig->writeBuffer(); + //write buffer to disc + myConfig->writeBuffer(); - if(languageIsChanged) { - QMessageBox::information(this, tr("Language Changed"), - tr("You have changed application language to %1.\nPlease restart PokerTH to load new language!").arg(comboBox_switchLanguage->itemText(changedLanguageIndex)), - QMessageBox::Ok); - } + if(languageIsChanged) { + QMessageBox::information(this, tr("Language Changed"), + tr("You have changed application language to %1.\nPlease restart PokerTH to load new language!").arg(comboBox_switchLanguage->itemText(changedLanguageIndex)), + QMessageBox::Ok); + } - //Wenn alles richtig eingegeben wurde --> Dialog schließen - if(settingsCorrect) { this->accept(); } + //Wenn alles richtig eingegeben wurde --> Dialog schließen + if(settingsCorrect) { + this->accept(); + } } void settingsDialogImpl::setFlipsidePicFileName() { - QDir flipSideDir(QDir::homePath()); - QFile flipSideFile(QString::fromUtf8(myConfig->readConfigString("FlipsideOwnFile").c_str())); - if(flipSideFile.exists()) { - flipSideDir = QDir(QString::fromUtf8(myConfig->readConfigString("FlipsideOwnFile").c_str())); - } + QDir flipSideDir(QDir::homePath()); + QFile flipSideFile(QString::fromUtf8(myConfig->readConfigString("FlipsideOwnFile").c_str())); + if(flipSideFile.exists()) { + flipSideDir = QDir(QString::fromUtf8(myConfig->readConfigString("FlipsideOwnFile").c_str())); + } - QString fileName = QFileDialog::getOpenFileName(this, tr("Select your flipside picture"), - flipSideDir.absolutePath(), - tr("Images (*.png *.jpg *.gif)")); + QString fileName = QFileDialog::getOpenFileName(this, tr("Select your flipside picture"), + flipSideDir.absolutePath(), + tr("Images (*.png *.jpg *.gif)")); - if (!fileName.isEmpty()) - lineEdit_OwnFlipsideFilename->setText(fileName); + if (!fileName.isEmpty()) + lineEdit_OwnFlipsideFilename->setText(fileName); } -void settingsDialogImpl::setAvatarFile0() { +void settingsDialogImpl::setAvatarFile0() +{ - callSelectAvatarDialog(); - if(mySelectAvatarDialogImpl->getSettingsCorrect()) { - pushButton_HumanPlayerAvatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); - pushButton_HumanPlayerAvatar->setIcon(QIcon(pushButton_HumanPlayerAvatar->getMyLink())); - } + callSelectAvatarDialog(); + if(mySelectAvatarDialogImpl->getSettingsCorrect()) { + pushButton_HumanPlayerAvatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); + pushButton_HumanPlayerAvatar->setIcon(QIcon(pushButton_HumanPlayerAvatar->getMyLink())); + } } -void settingsDialogImpl::setAvatarFile1() { +void settingsDialogImpl::setAvatarFile1() +{ - callSelectAvatarDialog(); - if(mySelectAvatarDialogImpl->getSettingsCorrect()) { - pushButton_Opponent1Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); - pushButton_Opponent1Avatar->setIcon(QIcon(pushButton_Opponent1Avatar->getMyLink())); - } + callSelectAvatarDialog(); + if(mySelectAvatarDialogImpl->getSettingsCorrect()) { + pushButton_Opponent1Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); + pushButton_Opponent1Avatar->setIcon(QIcon(pushButton_Opponent1Avatar->getMyLink())); + } } -void settingsDialogImpl::setAvatarFile2() { +void settingsDialogImpl::setAvatarFile2() +{ - callSelectAvatarDialog(); + callSelectAvatarDialog(); - if(mySelectAvatarDialogImpl->getSettingsCorrect()) { - pushButton_Opponent2Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); - pushButton_Opponent2Avatar->setIcon(QIcon(pushButton_Opponent2Avatar->getMyLink())); - } + if(mySelectAvatarDialogImpl->getSettingsCorrect()) { + pushButton_Opponent2Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); + pushButton_Opponent2Avatar->setIcon(QIcon(pushButton_Opponent2Avatar->getMyLink())); + } } -void settingsDialogImpl::setAvatarFile3() { +void settingsDialogImpl::setAvatarFile3() +{ - callSelectAvatarDialog(); - if(mySelectAvatarDialogImpl->getSettingsCorrect()) { - pushButton_Opponent3Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); - pushButton_Opponent3Avatar->setIcon(QIcon(pushButton_Opponent3Avatar->getMyLink())); - } + callSelectAvatarDialog(); + if(mySelectAvatarDialogImpl->getSettingsCorrect()) { + pushButton_Opponent3Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); + pushButton_Opponent3Avatar->setIcon(QIcon(pushButton_Opponent3Avatar->getMyLink())); + } } -void settingsDialogImpl::setAvatarFile4() { +void settingsDialogImpl::setAvatarFile4() +{ - callSelectAvatarDialog(); - if(mySelectAvatarDialogImpl->getSettingsCorrect()) { - pushButton_Opponent4Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); - pushButton_Opponent4Avatar->setIcon(QIcon(pushButton_Opponent4Avatar->getMyLink())); - } + callSelectAvatarDialog(); + if(mySelectAvatarDialogImpl->getSettingsCorrect()) { + pushButton_Opponent4Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); + pushButton_Opponent4Avatar->setIcon(QIcon(pushButton_Opponent4Avatar->getMyLink())); + } } -void settingsDialogImpl::setAvatarFile5() { +void settingsDialogImpl::setAvatarFile5() +{ - callSelectAvatarDialog(); - if(mySelectAvatarDialogImpl->getSettingsCorrect()) { - pushButton_Opponent5Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); - pushButton_Opponent5Avatar->setIcon(QIcon(pushButton_Opponent5Avatar->getMyLink())); - } + callSelectAvatarDialog(); + if(mySelectAvatarDialogImpl->getSettingsCorrect()) { + pushButton_Opponent5Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); + pushButton_Opponent5Avatar->setIcon(QIcon(pushButton_Opponent5Avatar->getMyLink())); + } } -void settingsDialogImpl::setAvatarFile6() { +void settingsDialogImpl::setAvatarFile6() +{ - callSelectAvatarDialog(); - if(mySelectAvatarDialogImpl->getSettingsCorrect()) { - pushButton_Opponent6Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); - pushButton_Opponent6Avatar->setIcon(QIcon(pushButton_Opponent6Avatar->getMyLink())); - } + callSelectAvatarDialog(); + if(mySelectAvatarDialogImpl->getSettingsCorrect()) { + pushButton_Opponent6Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); + pushButton_Opponent6Avatar->setIcon(QIcon(pushButton_Opponent6Avatar->getMyLink())); + } } -void settingsDialogImpl::setAvatarFile7() { +void settingsDialogImpl::setAvatarFile7() +{ - callSelectAvatarDialog(); - if(mySelectAvatarDialogImpl->getSettingsCorrect()) { - pushButton_Opponent7Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); - pushButton_Opponent7Avatar->setIcon(QIcon(pushButton_Opponent7Avatar->getMyLink())); - } + callSelectAvatarDialog(); + if(mySelectAvatarDialogImpl->getSettingsCorrect()) { + pushButton_Opponent7Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); + pushButton_Opponent7Avatar->setIcon(QIcon(pushButton_Opponent7Avatar->getMyLink())); + } } -void settingsDialogImpl::setAvatarFile8() { +void settingsDialogImpl::setAvatarFile8() +{ - callSelectAvatarDialog(); - if(mySelectAvatarDialogImpl->getSettingsCorrect()) { - pushButton_Opponent8Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); - pushButton_Opponent8Avatar->setIcon(QIcon(pushButton_Opponent8Avatar->getMyLink())); - } + callSelectAvatarDialog(); + if(mySelectAvatarDialogImpl->getSettingsCorrect()) { + pushButton_Opponent8Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); + pushButton_Opponent8Avatar->setIcon(QIcon(pushButton_Opponent8Avatar->getMyLink())); + } } -void settingsDialogImpl::setAvatarFile9() { +void settingsDialogImpl::setAvatarFile9() +{ - callSelectAvatarDialog(); - if(mySelectAvatarDialogImpl->getSettingsCorrect()) { - pushButton_Opponent9Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); - pushButton_Opponent9Avatar->setIcon(QIcon(pushButton_Opponent9Avatar->getMyLink())); - } + callSelectAvatarDialog(); + if(mySelectAvatarDialogImpl->getSettingsCorrect()) { + pushButton_Opponent9Avatar->setMyLink(mySelectAvatarDialogImpl->getAvatarLink()); + pushButton_Opponent9Avatar->setIcon(QIcon(pushButton_Opponent9Avatar->getMyLink())); + } } void settingsDialogImpl::setLogDir() { - QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), - QDir::homePath(), - QFileDialog::ShowDirsOnly - | QFileDialog::DontResolveSymlinks); + QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), + QDir::homePath(), + QFileDialog::ShowDirsOnly + | QFileDialog::DontResolveSymlinks); - if (!dir.isEmpty()) { + if (!dir.isEmpty()) { - QDir logDir(dir); - if(logDir.exists()) { - lineEdit_logDir->setText(dir); - refreshLogFileList(); - } - else { - QMessageBox::warning(this, tr("Settings Error"), - tr("The log file directory doesn't exist.\n" - "Please select an valid directory!"), - QMessageBox::Ok); - } - } + QDir logDir(dir); + if(logDir.exists()) { + lineEdit_logDir->setText(dir); + refreshLogFileList(); + } else { + QMessageBox::warning(this, tr("Settings Error"), + tr("The log file directory doesn't exist.\n" + "Please select an valid directory!"), + QMessageBox::Ok); + } + } } -void settingsDialogImpl::clearInternetGamePassword(bool clear) { +void settingsDialogImpl::clearInternetGamePassword(bool clear) +{ - if(!clear) { lineEdit_InternetGamePassword->clear(); } + if(!clear) { + lineEdit_InternetGamePassword->clear(); + } } -void settingsDialogImpl::callManualBlindsOrderDialog() { +void settingsDialogImpl::callManualBlindsOrderDialog() +{ - myManualBlindsOrderDialog->listWidget_blinds->clear(); - myManualBlindsOrderDialog->spinBox_input->setMinimum(spinBox_firstSmallBlind->value()); + myManualBlindsOrderDialog->listWidget_blinds->clear(); + myManualBlindsOrderDialog->spinBox_input->setMinimum(spinBox_firstSmallBlind->value()); - list::iterator it1; + list::iterator it1; for(it1= myManualBlindsList.begin(); it1 != myManualBlindsList.end(); ++it1) { - myManualBlindsOrderDialog->listWidget_blinds->addItem(QString::number(*it1,10)); - } - myManualBlindsOrderDialog->sortBlindsList(); + myManualBlindsOrderDialog->listWidget_blinds->addItem(QString::number(*it1,10)); + } + myManualBlindsOrderDialog->sortBlindsList(); - myManualBlindsOrderDialog->radioButton_alwaysDoubleBlinds->setChecked(myAfterMBAlwaysDoubleBlinds); - myManualBlindsOrderDialog->radioButton_alwaysRaiseAbout->setChecked(myAfterMBAlwaysRaiseAbout); - myManualBlindsOrderDialog->spinBox_alwaysRaiseValue->setValue(myAfterMBAlwaysRaiseValue); - myManualBlindsOrderDialog->radioButton_stayAtLastBlind->setChecked(myAfterMBStayAtLastBlind); + myManualBlindsOrderDialog->radioButton_alwaysDoubleBlinds->setChecked(myAfterMBAlwaysDoubleBlinds); + myManualBlindsOrderDialog->radioButton_alwaysRaiseAbout->setChecked(myAfterMBAlwaysRaiseAbout); + myManualBlindsOrderDialog->spinBox_alwaysRaiseValue->setValue(myAfterMBAlwaysRaiseValue); + myManualBlindsOrderDialog->radioButton_stayAtLastBlind->setChecked(myAfterMBStayAtLastBlind); - myManualBlindsOrderDialog->exec(); - if(myManualBlindsOrderDialog->result() == QDialog::Accepted) { + myManualBlindsOrderDialog->exec(); + if(myManualBlindsOrderDialog->result() == QDialog::Accepted) { - bool ok = TRUE; - int i; - myManualBlindsList.clear(); - for(i=0; ilistWidget_blinds->count(); i++) { - myManualBlindsList.push_back(myManualBlindsOrderDialog->listWidget_blinds->item(i)->text().toInt(&ok,10)); - } + bool ok = TRUE; + int i; + myManualBlindsList.clear(); + for(i=0; ilistWidget_blinds->count(); i++) { + myManualBlindsList.push_back(myManualBlindsOrderDialog->listWidget_blinds->item(i)->text().toInt(&ok,10)); + } - myAfterMBAlwaysDoubleBlinds = myManualBlindsOrderDialog->radioButton_alwaysDoubleBlinds->isChecked(); - myAfterMBAlwaysRaiseAbout = myManualBlindsOrderDialog->radioButton_alwaysRaiseAbout->isChecked(); - myAfterMBAlwaysRaiseValue = myManualBlindsOrderDialog->spinBox_alwaysRaiseValue->value(); - myAfterMBStayAtLastBlind = myManualBlindsOrderDialog->radioButton_stayAtLastBlind->isChecked(); + myAfterMBAlwaysDoubleBlinds = myManualBlindsOrderDialog->radioButton_alwaysDoubleBlinds->isChecked(); + myAfterMBAlwaysRaiseAbout = myManualBlindsOrderDialog->radioButton_alwaysRaiseAbout->isChecked(); + myAfterMBAlwaysRaiseValue = myManualBlindsOrderDialog->spinBox_alwaysRaiseValue->value(); + myAfterMBStayAtLastBlind = myManualBlindsOrderDialog->radioButton_stayAtLastBlind->isChecked(); - setFirstSmallBlindMargin(); - } + setFirstSmallBlindMargin(); + } } -void settingsDialogImpl::callNetManualBlindsOrderDialog() { +void settingsDialogImpl::callNetManualBlindsOrderDialog() +{ - myManualBlindsOrderDialog->listWidget_blinds->clear(); - myManualBlindsOrderDialog->spinBox_input->setMinimum(spinBox_netFirstSmallBlind->value()); + myManualBlindsOrderDialog->listWidget_blinds->clear(); + myManualBlindsOrderDialog->spinBox_input->setMinimum(spinBox_netFirstSmallBlind->value()); - list::iterator it1; + list::iterator it1; for(it1= myNetManualBlindsList.begin(); it1 != myNetManualBlindsList.end(); ++it1) { - myManualBlindsOrderDialog->listWidget_blinds->addItem(QString::number(*it1,10)); - } - myManualBlindsOrderDialog->sortBlindsList(); + myManualBlindsOrderDialog->listWidget_blinds->addItem(QString::number(*it1,10)); + } + myManualBlindsOrderDialog->sortBlindsList(); - myManualBlindsOrderDialog->radioButton_alwaysDoubleBlinds->setChecked(myNetAfterMBAlwaysDoubleBlinds); - myManualBlindsOrderDialog->radioButton_alwaysRaiseAbout->setChecked(myNetAfterMBAlwaysRaiseAbout); - myManualBlindsOrderDialog->spinBox_alwaysRaiseValue->setValue(myNetAfterMBAlwaysRaiseValue); - myManualBlindsOrderDialog->radioButton_stayAtLastBlind->setChecked(myNetAfterMBStayAtLastBlind); + myManualBlindsOrderDialog->radioButton_alwaysDoubleBlinds->setChecked(myNetAfterMBAlwaysDoubleBlinds); + myManualBlindsOrderDialog->radioButton_alwaysRaiseAbout->setChecked(myNetAfterMBAlwaysRaiseAbout); + myManualBlindsOrderDialog->spinBox_alwaysRaiseValue->setValue(myNetAfterMBAlwaysRaiseValue); + myManualBlindsOrderDialog->radioButton_stayAtLastBlind->setChecked(myNetAfterMBStayAtLastBlind); - myManualBlindsOrderDialog->exec(); - if(myManualBlindsOrderDialog->result() == QDialog::Accepted) { + myManualBlindsOrderDialog->exec(); + if(myManualBlindsOrderDialog->result() == QDialog::Accepted) { - bool ok = TRUE; - int i; - myNetManualBlindsList.clear(); - for(i=0; ilistWidget_blinds->count(); i++) { - myNetManualBlindsList.push_back(myManualBlindsOrderDialog->listWidget_blinds->item(i)->text().toInt(&ok,10)); - } + bool ok = TRUE; + int i; + myNetManualBlindsList.clear(); + for(i=0; ilistWidget_blinds->count(); i++) { + myNetManualBlindsList.push_back(myManualBlindsOrderDialog->listWidget_blinds->item(i)->text().toInt(&ok,10)); + } - myNetAfterMBAlwaysDoubleBlinds = myManualBlindsOrderDialog->radioButton_alwaysDoubleBlinds->isChecked(); - myNetAfterMBAlwaysRaiseAbout = myManualBlindsOrderDialog->radioButton_alwaysRaiseAbout->isChecked(); - myNetAfterMBAlwaysRaiseValue = myManualBlindsOrderDialog->spinBox_alwaysRaiseValue->value(); - myNetAfterMBStayAtLastBlind = myManualBlindsOrderDialog->radioButton_stayAtLastBlind->isChecked(); + myNetAfterMBAlwaysDoubleBlinds = myManualBlindsOrderDialog->radioButton_alwaysDoubleBlinds->isChecked(); + myNetAfterMBAlwaysRaiseAbout = myManualBlindsOrderDialog->radioButton_alwaysRaiseAbout->isChecked(); + myNetAfterMBAlwaysRaiseValue = myManualBlindsOrderDialog->spinBox_alwaysRaiseValue->value(); + myNetAfterMBStayAtLastBlind = myManualBlindsOrderDialog->radioButton_stayAtLastBlind->isChecked(); - setFirstSmallBlindMargin(); - } + setFirstSmallBlindMargin(); + } } // void settingsDialogImpl::checkProperNetFirstSmallBlind(int currentSB) { -// +// // } -// -// +// +// // void settingsDialogImpl::checkProperFirstSmallBlind(int currentSB) { -// +// // } -void settingsDialogImpl::setFirstSmallBlindMargin() { +void settingsDialogImpl::setFirstSmallBlindMargin() +{ - if(radioButton_manualBlindsOrder->isChecked() && !myManualBlindsList.empty()) { - if(spinBox_firstSmallBlind->value() > myManualBlindsList.front()) { - QMessageBox::warning(this, tr("Blinds Error"), - tr("The first element in your manual-blinds-list \nis smaller than current first-small-blind!\nThis first-small-blind-value will be set to maximum allowed value."), - QMessageBox::Close); - } - spinBox_firstSmallBlind->setMaximum(myManualBlindsList.front()); - } - else { - spinBox_firstSmallBlind->setMaximum(9999); - } - if(radioButton_netManualBlindsOrder->isChecked() && !myNetManualBlindsList.empty()) { - if(spinBox_netFirstSmallBlind->value() > myNetManualBlindsList.front()) { - QMessageBox::warning(this, tr("Blinds Error"), - tr("The first element in your manual-blinds-list \nis smaller than current first-small-blind!\nThis first-small-blind-value will be set to maximum allowed value."), - QMessageBox::Close); - } - spinBox_netFirstSmallBlind->setMaximum(myNetManualBlindsList.front()); - } - else { - spinBox_netFirstSmallBlind->setMaximum(9999); - } + if(radioButton_manualBlindsOrder->isChecked() && !myManualBlindsList.empty()) { + if(spinBox_firstSmallBlind->value() > myManualBlindsList.front()) { + QMessageBox::warning(this, tr("Blinds Error"), + tr("The first element in your manual-blinds-list \nis smaller than current first-small-blind!\nThis first-small-blind-value will be set to maximum allowed value."), + QMessageBox::Close); + } + spinBox_firstSmallBlind->setMaximum(myManualBlindsList.front()); + } else { + spinBox_firstSmallBlind->setMaximum(9999); + } + if(radioButton_netManualBlindsOrder->isChecked() && !myNetManualBlindsList.empty()) { + if(spinBox_netFirstSmallBlind->value() > myNetManualBlindsList.front()) { + QMessageBox::warning(this, tr("Blinds Error"), + tr("The first element in your manual-blinds-list \nis smaller than current first-small-blind!\nThis first-small-blind-value will be set to maximum allowed value."), + QMessageBox::Close); + } + spinBox_netFirstSmallBlind->setMaximum(myNetManualBlindsList.front()); + } else { + spinBox_netFirstSmallBlind->setMaximum(9999); + } } -void settingsDialogImpl::setLanguageChanged(int index) { +void settingsDialogImpl::setLanguageChanged(int index) +{ - languageIsChanged = TRUE; - changedLanguageIndex = index; + languageIsChanged = TRUE; + changedLanguageIndex = index; } -void settingsDialogImpl::toggleGroupBoxAutomaticServerConfig(bool toggleState) { - if(toggleState) groupBox_manualServerConfig->setChecked(FALSE); - else groupBox_manualServerConfig->setChecked(TRUE); +void settingsDialogImpl::toggleGroupBoxAutomaticServerConfig(bool toggleState) +{ + if(toggleState) groupBox_manualServerConfig->setChecked(FALSE); + else groupBox_manualServerConfig->setChecked(TRUE); } -void settingsDialogImpl::toggleGroupBoxManualServerConfig(bool toggleState) { - if(toggleState) groupBox_automaticServerConfig->setChecked(FALSE); - else groupBox_automaticServerConfig->setChecked(TRUE); +void settingsDialogImpl::toggleGroupBoxManualServerConfig(bool toggleState) +{ + if(toggleState) groupBox_automaticServerConfig->setChecked(FALSE); + else groupBox_automaticServerConfig->setChecked(TRUE); } void settingsDialogImpl::showCurrentGameTableStylePreview() { - QTreeWidgetItem* item = treeWidget_gameTableStyles->currentItem(); - if(item) { - GameTableStyleReader style(myConfig, this); - style.readStyleFile(item->data(0, 15).toString()); - QPixmap preview(style.getPreview()); - if(preview.height() > 160 || preview.width() > 120) label_gameTableStylePreview->setPixmap(preview.scaled(160,120,Qt::KeepAspectRatio,Qt::SmoothTransformation)); - else label_gameTableStylePreview->setPixmap(preview); + QTreeWidgetItem* item = treeWidget_gameTableStyles->currentItem(); + if(item) { + GameTableStyleReader style(myConfig, this); + style.readStyleFile(item->data(0, 15).toString()); + QPixmap preview(style.getPreview()); + if(preview.height() > 160 || preview.width() > 120) label_gameTableStylePreview->setPixmap(preview.scaled(160,120,Qt::KeepAspectRatio,Qt::SmoothTransformation)); + else label_gameTableStylePreview->setPixmap(preview); - QString MaintainerName = tr("Maintainer Name"); - QString MaintainerEMail = tr("Maintainer EMail"); - QString CreateDate = tr("Create Date"); - QString WindowBehaviour = tr("Windows Behaviour"); - QString scaleable = tr("scaleable"); - QString fixed = tr("fixed"); - QString MinimumSize = tr("Minimum Size"); - QString MaximumSize = tr("Maximum Size"); - QString FixedSize = tr("Fixed Size"); - QString State = tr("State"); + QString MaintainerName = tr("Maintainer Name"); + QString MaintainerEMail = tr("Maintainer EMail"); + QString CreateDate = tr("Create Date"); + QString WindowBehaviour = tr("Windows Behaviour"); + QString scaleable = tr("scaleable"); + QString fixed = tr("fixed"); + QString MinimumSize = tr("Minimum Size"); + QString MaximumSize = tr("Maximum Size"); + QString FixedSize = tr("Fixed Size"); + QString State = tr("State"); - QString windowsSubString; - if(style.getIfFixedWindowSize().toInt()) { - windowsSubString = ""+WindowBehaviour+": "+fixed+"
"+FixedSize+": "+style.getFixedWindowWidth()+"x"+style.getFixedWindowHeight(); - } - else { - windowsSubString = ""+WindowBehaviour+": "+scaleable+"
"+MinimumSize+": "+style.getMinimumWindowWidth()+"x"+style.getMinimumWindowHeight()+"
"+MaximumSize+": "+style.getMaximumWindowWidth()+"x"+style.getMaximumWindowHeight(); - } + QString windowsSubString; + if(style.getIfFixedWindowSize().toInt()) { + windowsSubString = ""+WindowBehaviour+": "+fixed+"
"+FixedSize+": "+style.getFixedWindowWidth()+"x"+style.getFixedWindowHeight(); + } else { + windowsSubString = ""+WindowBehaviour+": "+scaleable+"
"+MinimumSize+": "+style.getMinimumWindowWidth()+"x"+style.getMinimumWindowHeight()+"
"+MaximumSize+": "+style.getMaximumWindowWidth()+"x"+style.getMaximumWindowHeight(); + } - QString maintainerEMailString; - if(style.getStyleMaintainerEMail() != "NULL" && style.getStyleMaintainerEMail() != "") { - maintainerEMailString = ""+MaintainerEMail+": "+style.getStyleMaintainerEMail()+"
"; - } + QString maintainerEMailString; + if(style.getStyleMaintainerEMail() != "NULL" && style.getStyleMaintainerEMail() != "") { + maintainerEMailString = ""+MaintainerEMail+": "+style.getStyleMaintainerEMail()+"
"; + } - label_gameTableStyleInfo->setWordWrap(TRUE); - label_gameTableStyleInfo->setText(""+MaintainerName+": "+style.getStyleMaintainerName()+"
"+maintainerEMailString+""+CreateDate+": "+style.getStyleCreateDate()+"
"+windowsSubString+"
"+State+": "+style.getMyStateToolTipInfo()); + label_gameTableStyleInfo->setWordWrap(TRUE); + label_gameTableStyleInfo->setText(""+MaintainerName+": "+style.getStyleMaintainerName()+"
"+maintainerEMailString+""+CreateDate+": "+style.getStyleCreateDate()+"
"+windowsSubString+"
"+State+": "+style.getMyStateToolTipInfo()); - //active the current selected item directly - setSelectedGameTableStyleActivated(); + //active the current selected item directly + setSelectedGameTableStyleActivated(); - //disable remove button for distributed styles - if(item->data(0, 16).toInt() == POKERTH_DISTRIBUTED_STYLE) { pushButton_removeGameTableStyle->setDisabled(TRUE); } - else { pushButton_removeGameTableStyle->setDisabled(FALSE); } - - } + //disable remove button for distributed styles + if(item->data(0, 16).toInt() == POKERTH_DISTRIBUTED_STYLE) { + pushButton_removeGameTableStyle->setDisabled(TRUE); + } else { + pushButton_removeGameTableStyle->setDisabled(FALSE); + } + + } } void settingsDialogImpl::setSelectedGameTableStyleActivated() { - QTreeWidgetItem* selectedItem = treeWidget_gameTableStyles->currentItem(); - if(selectedItem) { - int i; - for(i=0; i < treeWidget_gameTableStyles->topLevelItemCount(); i++) { - QTreeWidgetItem *item = treeWidget_gameTableStyles->topLevelItem(i); - if(item == selectedItem) { - item->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); - } - else item->setIcon(0, QIcon()); - } - } + QTreeWidgetItem* selectedItem = treeWidget_gameTableStyles->currentItem(); + if(selectedItem) { + int i; + for(i=0; i < treeWidget_gameTableStyles->topLevelItemCount(); i++) { + QTreeWidgetItem *item = treeWidget_gameTableStyles->topLevelItem(i); + if(item == selectedItem) { + item->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); + } else item->setIcon(0, QIcon()); + } + } } void settingsDialogImpl::addGameTableStyle() { - QDir dir(QString::fromUtf8(myConfig->readConfigString("LastGameTableStyleDir").c_str())); - QString dirString; + QDir dir(QString::fromUtf8(myConfig->readConfigString("LastGameTableStyleDir").c_str())); + QString dirString; - if(dir.exists()) dirString = dir.absolutePath(); - else dirString = QDir::home().absolutePath(); + if(dir.exists()) dirString = dir.absolutePath(); + else dirString = QDir::home().absolutePath(); - QString fileName = QFileDialog::getOpenFileName(this, tr("Please select your game table style"), - dirString, - tr("PokerTH game table styles (*.xml)")); + QString fileName = QFileDialog::getOpenFileName(this, tr("Please select your game table style"), + dirString, + tr("PokerTH game table styles (*.xml)")); - if (!fileName.isEmpty()) { - - int i; - bool fileNameAlreadyFound(FALSE); - for(i=0; i < treeWidget_gameTableStyles->topLevelItemCount(); i++) { - QTreeWidgetItem *item = treeWidget_gameTableStyles->topLevelItem(i); - if(item->data(0, 15).toString() == fileName) - fileNameAlreadyFound = TRUE; - } - - if(fileNameAlreadyFound) { - QMessageBox::warning(this, tr("Game Table Style Error"), - tr("Selected game table style file is already in the list. \nPlease select another one to add!"), - QMessageBox::Ok); - } - else { - GameTableStyleReader newStyle(myConfig, this); - newStyle.readStyleFile(fileName); - if(!newStyle.getFallBack() && newStyle.getLoadedSuccessfull()) { - QStringList tempStringList1; - tempStringList1 << newStyle.getStyleDescription() << newStyle.getStyleMaintainerName(); - MyStyleListItem *newItem = new MyStyleListItem(tempStringList1, treeWidget_gameTableStyles); - newItem->setData(0, 15,fileName); - newItem->setData(0, 16, ADDITIONAL_STYLE); - newItem->setData(0, Qt::ToolTipRole,fileName); - newItem->setData(2, Qt::ToolTipRole, newStyle.getMyStateToolTipInfo()); - if(newStyle.getState() != GT_STYLE_OK) newItem->setIcon(2, QIcon(":/gfx/emblem-important.png")); - else newItem->setIcon(2, QIcon(":/gfx/dialog-ok-apply.png")); - treeWidget_gameTableStyles->addTopLevelItem(newItem); - treeWidget_gameTableStyles->setCurrentItem(newItem); - treeWidget_gameTableStyles->sortItems(0, Qt::AscendingOrder); + if (!fileName.isEmpty()) { - qDebug() << "settings: " << newStyle.getStyleDescription() << newStyle.getState(); - if(newStyle.getState() != GT_STYLE_OK) newStyle.showErrorMessage(); - } - else { - QMessageBox::warning(this, tr("Game Table Style File Error"), - tr("Could not load game table style file correctly. \nStyle will not be placed into list!"), - QMessageBox::Ok); - } - } - //save current filepath - myConfig->writeConfigString("LastGameTableStyleDir",QFileInfo(fileName).absolutePath().toUtf8().constData()); + int i; + bool fileNameAlreadyFound(FALSE); + for(i=0; i < treeWidget_gameTableStyles->topLevelItemCount(); i++) { + QTreeWidgetItem *item = treeWidget_gameTableStyles->topLevelItem(i); + if(item->data(0, 15).toString() == fileName) + fileNameAlreadyFound = TRUE; + } - //adjust column sizes for styles treeWidgets - treeWidget_gameTableStyles->resizeColumnToContents(0); - treeWidget_gameTableStyles->resizeColumnToContents(1); - treeWidget_gameTableStyles->resizeColumnToContents(2); - } + if(fileNameAlreadyFound) { + QMessageBox::warning(this, tr("Game Table Style Error"), + tr("Selected game table style file is already in the list. \nPlease select another one to add!"), + QMessageBox::Ok); + } else { + GameTableStyleReader newStyle(myConfig, this); + newStyle.readStyleFile(fileName); + if(!newStyle.getFallBack() && newStyle.getLoadedSuccessfull()) { + QStringList tempStringList1; + tempStringList1 << newStyle.getStyleDescription() << newStyle.getStyleMaintainerName(); + MyStyleListItem *newItem = new MyStyleListItem(tempStringList1, treeWidget_gameTableStyles); + newItem->setData(0, 15,fileName); + newItem->setData(0, 16, ADDITIONAL_STYLE); + newItem->setData(0, Qt::ToolTipRole,fileName); + newItem->setData(2, Qt::ToolTipRole, newStyle.getMyStateToolTipInfo()); + if(newStyle.getState() != GT_STYLE_OK) newItem->setIcon(2, QIcon(":/gfx/emblem-important.png")); + else newItem->setIcon(2, QIcon(":/gfx/dialog-ok-apply.png")); + treeWidget_gameTableStyles->addTopLevelItem(newItem); + treeWidget_gameTableStyles->setCurrentItem(newItem); + treeWidget_gameTableStyles->sortItems(0, Qt::AscendingOrder); + + qDebug() << "settings: " << newStyle.getStyleDescription() << newStyle.getState(); + if(newStyle.getState() != GT_STYLE_OK) newStyle.showErrorMessage(); + } else { + QMessageBox::warning(this, tr("Game Table Style File Error"), + tr("Could not load game table style file correctly. \nStyle will not be placed into list!"), + QMessageBox::Ok); + } + } + //save current filepath + myConfig->writeConfigString("LastGameTableStyleDir",QFileInfo(fileName).absolutePath().toUtf8().constData()); + + //adjust column sizes for styles treeWidgets + treeWidget_gameTableStyles->resizeColumnToContents(0); + treeWidget_gameTableStyles->resizeColumnToContents(1); + treeWidget_gameTableStyles->resizeColumnToContents(2); + } } void settingsDialogImpl::removeGameTableStyle() { - QTreeWidgetItem* selectedItem = treeWidget_gameTableStyles->currentItem(); - //never delete PokerTH defaullt Styles - if(selectedItem && selectedItem->data(0, 16).toInt() == ADDITIONAL_STYLE) { - // if selected is activated --> swith activation to first default - if(!selectedItem->icon(0).isNull()) { - QTreeWidgetItem* firstItem = treeWidget_gameTableStyles->topLevelItem(0); - firstItem->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); - } - //remove from List - treeWidget_gameTableStyles->takeTopLevelItem(treeWidget_gameTableStyles->currentIndex().row()); + QTreeWidgetItem* selectedItem = treeWidget_gameTableStyles->currentItem(); + //never delete PokerTH defaullt Styles + if(selectedItem && selectedItem->data(0, 16).toInt() == ADDITIONAL_STYLE) { + // if selected is activated --> swith activation to first default + if(!selectedItem->icon(0).isNull()) { + QTreeWidgetItem* firstItem = treeWidget_gameTableStyles->topLevelItem(0); + firstItem->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); + } + //remove from List + treeWidget_gameTableStyles->takeTopLevelItem(treeWidget_gameTableStyles->currentIndex().row()); - } + } } void settingsDialogImpl::showCurrentCardDeckStylePreview() { - QTreeWidgetItem* item = treeWidget_cardDeckStyles->currentItem(); - if(item) { - CardDeckStyleReader style(myConfig, this); - style.readStyleFile(item->data(0, 15).toString()); - QPixmap preview(style.getPreview()); - if(preview.height() > 160 || preview.width() > 120) label_cardDeckStylePreview->setPixmap(preview.scaled(160,120,Qt::KeepAspectRatio,Qt::SmoothTransformation)); - else label_cardDeckStylePreview->setPixmap(preview); + QTreeWidgetItem* item = treeWidget_cardDeckStyles->currentItem(); + if(item) { + CardDeckStyleReader style(myConfig, this); + style.readStyleFile(item->data(0, 15).toString()); + QPixmap preview(style.getPreview()); + if(preview.height() > 160 || preview.width() > 120) label_cardDeckStylePreview->setPixmap(preview.scaled(160,120,Qt::KeepAspectRatio,Qt::SmoothTransformation)); + else label_cardDeckStylePreview->setPixmap(preview); - QString MaintainerName = tr("Maintainer Name"); - QString MaintainerEMail = tr("Maintainer EMail"); - QString CreateDate = tr("Create Date"); + QString MaintainerName = tr("Maintainer Name"); + QString MaintainerEMail = tr("Maintainer EMail"); + QString CreateDate = tr("Create Date"); - QString maintainerEMailString; - if(style.getStyleMaintainerEMail() != "NULL" && style.getStyleMaintainerEMail() != "") { - maintainerEMailString = ""+MaintainerEMail+": "+style.getStyleMaintainerEMail()+"
"; - } + QString maintainerEMailString; + if(style.getStyleMaintainerEMail() != "NULL" && style.getStyleMaintainerEMail() != "") { + maintainerEMailString = ""+MaintainerEMail+": "+style.getStyleMaintainerEMail()+"
"; + } - label_cardDeckStyleInfo->setText(""+MaintainerName+": "+style.getStyleMaintainerName()+"
"+maintainerEMailString+""+CreateDate+": "+style.getStyleCreateDate()+""); - //active the current selected item directly - setSelectedCardDeckStyleActivated(); + label_cardDeckStyleInfo->setText(""+MaintainerName+": "+style.getStyleMaintainerName()+"
"+maintainerEMailString+""+CreateDate+": "+style.getStyleCreateDate()+""); + //active the current selected item directly + setSelectedCardDeckStyleActivated(); - //disable remove button for distributed styles - if(item->data(0, 16).toInt() == POKERTH_DISTRIBUTED_STYLE) { pushButton_removeCardDeckStyle->setDisabled(TRUE); } - else { pushButton_removeCardDeckStyle->setDisabled(FALSE); } - } + //disable remove button for distributed styles + if(item->data(0, 16).toInt() == POKERTH_DISTRIBUTED_STYLE) { + pushButton_removeCardDeckStyle->setDisabled(TRUE); + } else { + pushButton_removeCardDeckStyle->setDisabled(FALSE); + } + } } void settingsDialogImpl::setSelectedCardDeckStyleActivated() { - QTreeWidgetItem* selectedItem = treeWidget_cardDeckStyles->currentItem(); - if(selectedItem) { - int i; - for(i=0; i < treeWidget_cardDeckStyles->topLevelItemCount(); i++) { - QTreeWidgetItem *item = treeWidget_cardDeckStyles->topLevelItem(i); - if(item == selectedItem) { - item->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); - } - else item->setIcon(0, QIcon()); - } - } + QTreeWidgetItem* selectedItem = treeWidget_cardDeckStyles->currentItem(); + if(selectedItem) { + int i; + for(i=0; i < treeWidget_cardDeckStyles->topLevelItemCount(); i++) { + QTreeWidgetItem *item = treeWidget_cardDeckStyles->topLevelItem(i); + if(item == selectedItem) { + item->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); + } else item->setIcon(0, QIcon()); + } + } } void settingsDialogImpl::addCardDeckStyle() { - QDir dir(QString::fromUtf8(myConfig->readConfigString("LastCardDeckStyleDir").c_str())); - QString dirString; + QDir dir(QString::fromUtf8(myConfig->readConfigString("LastCardDeckStyleDir").c_str())); + QString dirString; - if(dir.exists()) dirString = dir.absolutePath(); - else dirString = QDir::home().absolutePath(); + if(dir.exists()) dirString = dir.absolutePath(); + else dirString = QDir::home().absolutePath(); - QString fileName = QFileDialog::getOpenFileName(this, tr("Please select your card deck style"), - dirString, - tr("PokerTH card deck styles (*.xml)")); + QString fileName = QFileDialog::getOpenFileName(this, tr("Please select your card deck style"), + dirString, + tr("PokerTH card deck styles (*.xml)")); - if (!fileName.isEmpty()) { + if (!fileName.isEmpty()) { - int i; - bool fileNameAlreadyFound(FALSE); - for(i=0; i < treeWidget_cardDeckStyles->topLevelItemCount(); i++) { - QTreeWidgetItem *item = treeWidget_cardDeckStyles->topLevelItem(i); - if(item->data(0, 15).toString() == fileName) - fileNameAlreadyFound = TRUE; - } + int i; + bool fileNameAlreadyFound(FALSE); + for(i=0; i < treeWidget_cardDeckStyles->topLevelItemCount(); i++) { + QTreeWidgetItem *item = treeWidget_cardDeckStyles->topLevelItem(i); + if(item->data(0, 15).toString() == fileName) + fileNameAlreadyFound = TRUE; + } - if(fileNameAlreadyFound) { - QMessageBox::warning(this, tr("Card Deck Style Error"), - tr("Selected card deck style file is already in the list. \nPlease select another one to add!"), - QMessageBox::Ok); - } - else { - CardDeckStyleReader newStyle(myConfig, this); - newStyle.readStyleFile(fileName); - if(!newStyle.getFallBack() && newStyle.getLoadedSuccessfull()) { - QStringList tempStringList1; - tempStringList1 << newStyle.getStyleDescription() << newStyle.getStyleMaintainerName(); - MyStyleListItem *newItem = new MyStyleListItem(tempStringList1, treeWidget_cardDeckStyles); - newItem->setData(0, 15,fileName); - newItem->setData(0, 16, ADDITIONAL_STYLE); - newItem->setData(0, Qt::ToolTipRole,fileName); - treeWidget_cardDeckStyles->addTopLevelItem(newItem); - treeWidget_cardDeckStyles->setCurrentItem(newItem); - treeWidget_cardDeckStyles->sortItems(0, Qt::AscendingOrder); - } - else { - QMessageBox::warning(this, tr("Card Deck Style File Error"), - tr("Could not load card deck style file correctly. \nStyle will not be placed into list!"), - QMessageBox::Ok); - } - } - //save current filepath - myConfig->writeConfigString("LastCardDeckStyleDir",QFileInfo(fileName).absolutePath().toUtf8().constData()); + if(fileNameAlreadyFound) { + QMessageBox::warning(this, tr("Card Deck Style Error"), + tr("Selected card deck style file is already in the list. \nPlease select another one to add!"), + QMessageBox::Ok); + } else { + CardDeckStyleReader newStyle(myConfig, this); + newStyle.readStyleFile(fileName); + if(!newStyle.getFallBack() && newStyle.getLoadedSuccessfull()) { + QStringList tempStringList1; + tempStringList1 << newStyle.getStyleDescription() << newStyle.getStyleMaintainerName(); + MyStyleListItem *newItem = new MyStyleListItem(tempStringList1, treeWidget_cardDeckStyles); + newItem->setData(0, 15,fileName); + newItem->setData(0, 16, ADDITIONAL_STYLE); + newItem->setData(0, Qt::ToolTipRole,fileName); + treeWidget_cardDeckStyles->addTopLevelItem(newItem); + treeWidget_cardDeckStyles->setCurrentItem(newItem); + treeWidget_cardDeckStyles->sortItems(0, Qt::AscendingOrder); + } else { + QMessageBox::warning(this, tr("Card Deck Style File Error"), + tr("Could not load card deck style file correctly. \nStyle will not be placed into list!"), + QMessageBox::Ok); + } + } + //save current filepath + myConfig->writeConfigString("LastCardDeckStyleDir",QFileInfo(fileName).absolutePath().toUtf8().constData()); - treeWidget_cardDeckStyles->resizeColumnToContents(0); - treeWidget_cardDeckStyles->resizeColumnToContents(1); - treeWidget_cardDeckStyles->resizeColumnToContents(2); - } + treeWidget_cardDeckStyles->resizeColumnToContents(0); + treeWidget_cardDeckStyles->resizeColumnToContents(1); + treeWidget_cardDeckStyles->resizeColumnToContents(2); + } } void settingsDialogImpl::removeCardDeckStyle() { - QTreeWidgetItem* selectedItem = treeWidget_cardDeckStyles->currentItem(); - //never delete PokerTH defaullt Styles - if(selectedItem && selectedItem->data(0, 16).toInt() == ADDITIONAL_STYLE) { - // if selected is activated --> swith activation to first default - if(!selectedItem->icon(0).isNull()) { - QTreeWidgetItem* firstItem = treeWidget_cardDeckStyles->topLevelItem(0); - firstItem->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); - } - //remove from List - treeWidget_cardDeckStyles->takeTopLevelItem(treeWidget_cardDeckStyles->currentIndex().row()); - } + QTreeWidgetItem* selectedItem = treeWidget_cardDeckStyles->currentItem(); + //never delete PokerTH defaullt Styles + if(selectedItem && selectedItem->data(0, 16).toInt() == ADDITIONAL_STYLE) { + // if selected is activated --> swith activation to first default + if(!selectedItem->icon(0).isNull()) { + QTreeWidgetItem* firstItem = treeWidget_cardDeckStyles->topLevelItem(0); + firstItem->setIcon(0, QIcon(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"/gfx/gui/misc/rating.png")); + } + //remove from List + treeWidget_cardDeckStyles->takeTopLevelItem(treeWidget_cardDeckStyles->currentIndex().row()); + } } void settingsDialogImpl::removePlayerFromIgnoredPlayersList() { - if(treeWidget_internetGameIgnoredPlayers->selectedItems().count()) { - treeWidget_internetGameIgnoredPlayers->takeTopLevelItem(treeWidget_internetGameIgnoredPlayers->currentIndex().row()); - } + if(treeWidget_internetGameIgnoredPlayers->selectedItems().count()) { + treeWidget_internetGameIgnoredPlayers->takeTopLevelItem(treeWidget_internetGameIgnoredPlayers->currentIndex().row()); + } } void settingsDialogImpl::refreshLogFileList() { - QDir logFileDir; - logFileDir.setPath(lineEdit_logDir->text()); - QStringList filters; - filters << "*.pdb"; - QFileInfoList dbFilesList = logFileDir.entryInfoList(filters, QDir::Files, QDir::Time); + QDir logFileDir; + logFileDir.setPath(lineEdit_logDir->text()); + QStringList filters; + filters << "*.pdb"; + QFileInfoList dbFilesList = logFileDir.entryInfoList(filters, QDir::Files, QDir::Time); - treeWidget_logFiles->clear(); - int i; - for (i=0; i < dbFilesList.size(); i++) { + treeWidget_logFiles->clear(); + int i; + for (i=0; i < dbFilesList.size(); i++) { - QTreeWidgetItem *item = new QTreeWidgetItem; - item->setText(0, dbFilesList.at(i).fileName()); - item->setData(0, Qt::UserRole, dbFilesList.at(i).absoluteFilePath()); - treeWidget_logFiles->addTopLevelItem(item); - } + QTreeWidgetItem *item = new QTreeWidgetItem; + item->setText(0, dbFilesList.at(i).fileName()); + item->setData(0, Qt::UserRole, dbFilesList.at(i).absoluteFilePath()); + treeWidget_logFiles->addTopLevelItem(item); + } } void settingsDialogImpl::deleteLogFile() { - QTreeWidgetItem* selectedItem = treeWidget_logFiles->currentItem(); + QTreeWidgetItem* selectedItem = treeWidget_logFiles->currentItem(); - if(selectedItem) { - int ret = QMessageBox::warning(this, tr("PokerTH - Log file"), - tr("Do you really want to delete the selected log file?"), - QMessageBox::Yes | QMessageBox::No); + if(selectedItem) { + int ret = QMessageBox::warning(this, tr("PokerTH - Log file"), + tr("Do you really want to delete the selected log file?"), + QMessageBox::Yes | QMessageBox::No); - if(ret == QMessageBox::Yes) { + if(ret == QMessageBox::Yes) { - QFile fileToDelete (selectedItem->data(0, Qt::UserRole).toString()); - if(!fileToDelete.remove()) { - QMessageBox::warning(this, "Remove log file", "PokerTH cannot remove this log file, please check if you have write access to this file!", QMessageBox::Close ); - } - refreshLogFileList(); - } - } + QFile fileToDelete (selectedItem->data(0, Qt::UserRole).toString()); + if(!fileToDelete.remove()) { + QMessageBox::warning(this, "Remove log file", "PokerTH cannot remove this log file, please check if you have write access to this file!", QMessageBox::Close ); + } + refreshLogFileList(); + } + } } void settingsDialogImpl::exportLogToHtml() @@ -1298,15 +1318,15 @@ void settingsDialogImpl::exportLogToTxt() void settingsDialogImpl::saveLogFileAs() { - QTreeWidgetItem* selectedItem = treeWidget_logFiles->currentItem(); + QTreeWidgetItem* selectedItem = treeWidget_logFiles->currentItem(); - if(selectedItem) { - QString fileName = QFileDialog::getSaveFileName(this, tr("Save PokerTH log file"), - QDir::homePath()+"/"+selectedItem->text(0), - tr("PokerTH SQL log (*.pdb)")); + if(selectedItem) { + QString fileName = QFileDialog::getSaveFileName(this, tr("Save PokerTH log file"), + QDir::homePath()+"/"+selectedItem->text(0), + tr("PokerTH SQL log (*.pdb)")); - if(!fileName.isEmpty()) { - QFile::copy(selectedItem->data(0, Qt::UserRole).toString(), fileName); - } - } + if(!fileName.isEmpty()) { + QFile::copy(selectedItem->data(0, Qt::UserRole).toString(), fileName); + } + } } diff --git a/src/gui/qt/settingsdialog/settingsdialogimpl.h b/src/gui/qt/settingsdialog/settingsdialogimpl.h index fbf7988c..30b7318c 100644 --- a/src/gui/qt/settingsdialog/settingsdialogimpl.h +++ b/src/gui/qt/settingsdialog/settingsdialogimpl.h @@ -36,25 +36,34 @@ class selectAvatarDialogImpl; class manualBlindsOrderDialogImpl; class MyStyleListItem; -class settingsDialogImpl: public QDialog, public Ui::settingsDialog { -Q_OBJECT +class settingsDialogImpl: public QDialog, public Ui::settingsDialog +{ + Q_OBJECT public: - settingsDialogImpl(QWidget *parent = 0, ConfigFile *c = 0, selectAvatarDialogImpl *s = 0); + settingsDialogImpl(QWidget *parent = 0, ConfigFile *c = 0, selectAvatarDialogImpl *s = 0); - ~settingsDialogImpl(); + ~settingsDialogImpl(); - void prepareDialog(); + void prepareDialog(); void exec(); - void setPlayerNickIsChanged(bool theValue){ playerNickIsChanged = theValue;} - bool getPlayerNickIsChanged() const{ return playerNickIsChanged;} + void setPlayerNickIsChanged(bool theValue) { + playerNickIsChanged = theValue; + } + bool getPlayerNickIsChanged() const { + return playerNickIsChanged; + } - bool getSettingsCorrect() const{ return settingsCorrect;} + bool getSettingsCorrect() const { + return settingsCorrect; + } public slots: void isAccepted(); - void playerNickChanged() { setPlayerNickIsChanged(TRUE); }; + void playerNickChanged() { + setPlayerNickIsChanged(TRUE); + }; void setFlipsidePicFileName(); void setLogDir(); void setAvatarFile0(); @@ -71,10 +80,12 @@ public slots: void callManualBlindsOrderDialog(); void callNetManualBlindsOrderDialog(); - void callSelectAvatarDialog() { mySelectAvatarDialogImpl->exec(); } + void callSelectAvatarDialog() { + mySelectAvatarDialogImpl->exec(); + } void clearInternetGamePassword(bool); - + // void checkProperNetFirstSmallBlind(int); // void checkProperFirstSmallBlind(int); void setFirstSmallBlindMargin() ; @@ -93,15 +104,15 @@ public slots: void showCurrentCardDeckStylePreview(); void addCardDeckStyle(); void removeCardDeckStyle(); - void removePlayerFromIgnoredPlayersList(); - void refreshLogFileList(); - void deleteLogFile(); - void exportLogToHtml(); - void exportLogToTxt(); - void saveLogFileAs(); + void removePlayerFromIgnoredPlayersList(); + void refreshLogFileList(); + void deleteLogFile(); + void exportLogToHtml(); + void exportLogToTxt(); + void saveLogFileAs(); private: - + bool playerNickIsChanged; bool settingsCorrect; @@ -117,10 +128,10 @@ private: std::list myNetManualBlindsList; std::list myGameTableStylesList; std::list myCardDeckStylesList; - + ConfigFile* myConfig; - selectAvatarDialogImpl *mySelectAvatarDialogImpl; - manualBlindsOrderDialogImpl *myManualBlindsOrderDialog; + selectAvatarDialogImpl *mySelectAvatarDialogImpl; + manualBlindsOrderDialogImpl *myManualBlindsOrderDialog; QString myAppDataPath; diff --git a/src/gui/qt/sound/sdlplayer.cpp b/src/gui/qt/sound/sdlplayer.cpp index 8af1d934..534ef9c5 100644 --- a/src/gui/qt/sound/sdlplayer.cpp +++ b/src/gui/qt/sound/sdlplayer.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: sdlplayer // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -12,18 +12,18 @@ #include "sdlplayer.h" #if (defined __APPLE__) - #include +#include #else - #include +#include #endif using namespace std; SDLPlayer::SDLPlayer(ConfigFile *c) -: soundData(NULL), currentChannel(0) , audioEnabled(0), myConfig(c) + : soundData(NULL), currentChannel(0) , audioEnabled(0), myConfig(c) { - SDL_Init(SDL_INIT_AUDIO); - initAudio(); + SDL_Init(SDL_INIT_AUDIO); + initAudio(); myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); } @@ -35,10 +35,10 @@ SDLPlayer::~SDLPlayer() SDL_Quit(); } -void SDLPlayer::initAudio() { +void SDLPlayer::initAudio() +{ - if (!audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) - { + if (!audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) { int audio_rate = 44100; Uint16 audio_format = AUDIO_S16; /* 16-bit stereo */ int audio_channels = 2; @@ -52,68 +52,94 @@ void SDLPlayer::initAudio() { } } -void SDLPlayer::playSound(string audioString, int playerID) { +void SDLPlayer::playSound(string audioString, int playerID) +{ if(audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) { - + QFile myFile(myAppDataPath + "sounds/default/" + QString::fromStdString(audioString)+".wav"); - + if(myFile.open(QIODevice::ReadOnly)) { - + //set 3d position for player int position = 0; int distance = 0; - + switch (playerID) { - case 0: { position = 180; distance = 10; } + case 0: { + position = 180; + distance = 10; + } break; - case 1: { position = 281; distance = 50; } + case 1: { + position = 281; + distance = 50; + } break; - case 2: { position = 315; distance = 120; } + case 2: { + position = 315; + distance = 120; + } break; - case 3: { position = 338; distance = 160; } + case 3: { + position = 338; + distance = 160; + } break; - case 4: { position = 23; distance = 160; } + case 4: { + position = 23; + distance = 160; + } break; - case 5: { position = 45; distance = 120; } + case 5: { + position = 45; + distance = 120; + } break; - case 6: { position = 79; distance = 50; } + case 6: { + position = 79; + distance = 50; + } break; - default: { position = 0; distance = 0; } + default: { + position = 0; + distance = 0; + } break; } audioDone(); - + QDataStream in(&myFile); soundData = new Uint8[(int)myFile.size()]; in.readRawData( (char*)soundData, (int)myFile.size() ); - - sound = Mix_QuickLoad_WAV(soundData); - - - // set channel 0 to settings volume + + sound = Mix_QuickLoad_WAV(soundData); + + + // set channel 0 to settings volume Mix_Volume(0,myConfig->readConfigInt("SoundVolume")*10); // set 3d effect if(!Mix_SetPosition(0, position, distance)) { - printf("Mix_SetPosition: %s\n", Mix_GetError()); - // no position effect, is it ok? + printf("Mix_SetPosition: %s\n", Mix_GetError()); + // no position effect, is it ok? } currentChannel = Mix_PlayChannel(-1, sound,0); } - // else cout << "could not load " << audioString << ".wav" << endl; - + // else cout << "could not load " << audioString << ".wav" << endl; + //test - // audioDone(); - // sound = Mix_LoadWAV( QString(QString::fromStdString(audioString)+QString(".wav")).toStdString().c_str() ); - // currentChannel = Mix_PlayChannel(-1, sound,0); + // audioDone(); + // sound = Mix_LoadWAV( QString(QString::fromStdString(audioString)+QString(".wav")).toStdString().c_str() ); + // currentChannel = Mix_PlayChannel(-1, sound,0); } } -void SDLPlayer::audioDone() { +void SDLPlayer::audioDone() +{ if(audioEnabled) { Mix_HaltChannel(currentChannel); @@ -124,8 +150,9 @@ void SDLPlayer::audioDone() { } } -void SDLPlayer::closeAudio() { - +void SDLPlayer::closeAudio() +{ + if(audioEnabled) { audioDone(); Mix_CloseAudio(); diff --git a/src/gui/qt/sound/sdlplayer.h b/src/gui/qt/sound/sdlplayer.h index c35739ee..bdf7dfe2 100644 --- a/src/gui/qt/sound/sdlplayer.h +++ b/src/gui/qt/sound/sdlplayer.h @@ -1,7 +1,7 @@ // // C++ Interface: sdlplayer // -// Description: +// Description: // // // Author: FThauer FHammer , (C) 2007 @@ -17,9 +17,9 @@ #include "configfile.h" #if (defined __APPLE__) - #include +#include #else - #include +#include #endif #include @@ -30,8 +30,9 @@ /** @author FThauer FHammer */ -class SDLPlayer : public QObject{ -Q_OBJECT +class SDLPlayer : public QObject +{ + Q_OBJECT public: SDLPlayer(ConfigFile*); diff --git a/src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.cpp b/src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.cpp index 1c61973c..62348fab 100644 --- a/src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.cpp +++ b/src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.cpp @@ -25,15 +25,15 @@ #include startNetworkGameDialogImpl::startNetworkGameDialogImpl(startWindowImpl *parent, ConfigFile *config) - : QDialog(parent), myW(NULL), myStartWindow(parent), keyUpDownChatCounter(0), myPlayerId(0), isAdmin(false), myConfig(config), myChat(NULL) + : QDialog(parent), myW(NULL), myStartWindow(parent), keyUpDownChatCounter(0), myPlayerId(0), isAdmin(false), myConfig(config), myChat(NULL) { #ifdef __APPLE__ setWindowModality(Qt::ApplicationModal); setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); -#endif +#endif setupUi(this); - myChat = new ChatTools(lineEdit_ChatInput, myConfig, LAN_LOBBY_CHAT, textBrowser_ChatDisplay); + myChat = new ChatTools(lineEdit_ChatInput, myConfig, LAN_LOBBY_CHAT, textBrowser_ChatDisplay); lineEdit_ChatInput->installEventFilter(this); @@ -48,36 +48,41 @@ startNetworkGameDialogImpl::startNetworkGameDialogImpl(startWindowImpl *parent, clearDialog(); } -void startNetworkGameDialogImpl::exec() { +void startNetworkGameDialogImpl::exec() +{ QDialog::exec(); } -void startNetworkGameDialogImpl::startGame() { +void startNetworkGameDialogImpl::startGame() +{ assert(mySession); mySession->sendStartEvent(checkBox_fillUpWithComputerOpponents->isChecked()); } -void startNetworkGameDialogImpl::cancel() { - +void startNetworkGameDialogImpl::cancel() +{ + } -void startNetworkGameDialogImpl::refresh(int actionID) { +void startNetworkGameDialogImpl::refresh(int actionID) +{ - if (actionID == MSG_NET_GAME_CLIENT_START) - { + if (actionID == MSG_NET_GAME_CLIENT_START) { QTimer::singleShot(500, this, SLOT(accept())); } } -void startNetworkGameDialogImpl::joinedNetworkGame(unsigned playerId, QString playerName, bool admin) { +void startNetworkGameDialogImpl::joinedNetworkGame(unsigned playerId, QString playerName, bool admin) +{ myPlayerId = playerId; - isAdmin = admin; - addConnectedPlayer(playerId, playerName, admin); + isAdmin = admin; + addConnectedPlayer(playerId, playerName, admin); } -void startNetworkGameDialogImpl::addConnectedPlayer(unsigned playerId, QString playerName, bool) { +void startNetworkGameDialogImpl::addConnectedPlayer(unsigned playerId, QString playerName, bool) +{ // TODO mark admin QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget, 0); @@ -89,8 +94,7 @@ void startNetworkGameDialogImpl::addConnectedPlayer(unsigned playerId, QString p if(this->isVisible() && myConfig->readConfigInt("PlayNetworkGameNotification")) { if(treeWidget->topLevelItemCount() < info.data.maxNumberOfPlayers) { myW->getMySDLPlayer()->playSound("playerconnected", 0); - } - else { + } else { myW->getMySDLPlayer()->playSound("onlinegameready", 0); } } @@ -102,8 +106,7 @@ void startNetworkGameDialogImpl::updatePlayer(unsigned playerId, QString newPlay { QTreeWidgetItemIterator it(treeWidget); while (*it) { - if ((*it)->data(0, Qt::UserRole) == playerId) - { + if ((*it)->data(0, Qt::UserRole) == playerId) { (*it)->setData(0, Qt::DisplayRole, newPlayerName); break; } @@ -111,12 +114,12 @@ void startNetworkGameDialogImpl::updatePlayer(unsigned playerId, QString newPlay } } -void startNetworkGameDialogImpl::removePlayer(unsigned playerId, QString) { +void startNetworkGameDialogImpl::removePlayer(unsigned playerId, QString) +{ QTreeWidgetItemIterator it(treeWidget); while (*it) { - if ((*it)->data(0, Qt::UserRole) == playerId) - { + if ((*it)->data(0, Qt::UserRole) == playerId) { treeWidget->takeTopLevelItem(treeWidget->indexOfTopLevelItem(*it)); break; } @@ -128,8 +131,7 @@ void startNetworkGameDialogImpl::removePlayer(unsigned playerId, QString) { void startNetworkGameDialogImpl::newGameAdmin(unsigned playerId, QString) { - if (myPlayerId == playerId) - { + if (myPlayerId == playerId) { isAdmin = true; checkPlayerQuantity(); } @@ -141,25 +143,27 @@ void startNetworkGameDialogImpl::gameCreated(unsigned /*gameId*/) label_maxPlayerNumber->setText(QString::number(info.data.maxNumberOfPlayers)); } -void startNetworkGameDialogImpl::playerSelected(QTreeWidgetItem* item, QTreeWidgetItem*) { +void startNetworkGameDialogImpl::playerSelected(QTreeWidgetItem* item, QTreeWidgetItem*) +{ if (item) pushButton_Kick->setEnabled(isAdmin); } -void startNetworkGameDialogImpl::kickPlayer() { +void startNetworkGameDialogImpl::kickPlayer() +{ + - QTreeWidgetItem *item = treeWidget->currentItem(); - if (item) - { + if (item) { QString playerName = item->text(0); if(playerName == QString::fromUtf8(myConfig->readConfigString("MyName").c_str())) { - { QMessageBox::warning(this, tr("Server Error"), - tr("You should not kick yourself from this game!"), - QMessageBox::Close); } - } - else { + { + QMessageBox::warning(this, tr("Server Error"), + tr("You should not kick yourself from this game!"), + QMessageBox::Close); + } + } else { assert(mySession); mySession->kickPlayer(item->data(0, Qt::UserRole).toUInt()); } @@ -167,17 +171,17 @@ void startNetworkGameDialogImpl::kickPlayer() { pushButton_Kick->setEnabled(false); } -void startNetworkGameDialogImpl::checkPlayerQuantity() { +void startNetworkGameDialogImpl::checkPlayerQuantity() +{ - if(isAdmin){ + if(isAdmin) { pushButton_Kick->show(); pushButton_startGame->show(); checkBox_fillUpWithComputerOpponents->show(); - + if (treeWidget->topLevelItemCount() >= 2) { pushButton_startGame->setEnabled(true); - } - else { + } else { pushButton_startGame->setEnabled(false); } } @@ -203,27 +207,31 @@ void startNetworkGameDialogImpl::setSession(boost::shared_ptr session) myChat->setSession(mySession); } -void startNetworkGameDialogImpl::keyPressEvent ( QKeyEvent * event ) { +void startNetworkGameDialogImpl::keyPressEvent ( QKeyEvent * event ) +{ - if (event->key() == Qt::Key_Up && lineEdit_ChatInput->hasFocus()) { - if((keyUpDownChatCounter + 1) <= myChat->getChatLinesHistorySize()) { keyUpDownChatCounter++; } + if (event->key() == Qt::Key_Up && lineEdit_ChatInput->hasFocus()) { + if((keyUpDownChatCounter + 1) <= myChat->getChatLinesHistorySize()) { + keyUpDownChatCounter++; + } // std::cout << "Up keyUpDownChatCounter: " << keyUpDownChatCounter << "\n"; - myChat->showChatHistoryIndex(keyUpDownChatCounter); - } - else if(event->key() == Qt::Key_Down && lineEdit_ChatInput->hasFocus()) { - if((keyUpDownChatCounter - 1) >= 0) { keyUpDownChatCounter--; } + myChat->showChatHistoryIndex(keyUpDownChatCounter); + } else if(event->key() == Qt::Key_Down && lineEdit_ChatInput->hasFocus()) { + if((keyUpDownChatCounter - 1) >= 0) { + keyUpDownChatCounter--; + } // std::cout << "Down keyUpDownChatCounter: " << keyUpDownChatCounter << "\n"; - myChat->showChatHistoryIndex(keyUpDownChatCounter); + myChat->showChatHistoryIndex(keyUpDownChatCounter); + } else { + keyUpDownChatCounter = 0; } - else { keyUpDownChatCounter = 0; } } bool startNetworkGameDialogImpl::eventFilter(QObject *obj, QEvent *event) { QKeyEvent *keyEvent = static_cast(event); - if (obj == lineEdit_ChatInput && lineEdit_ChatInput->text() != "" && event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Tab) - { + if (obj == lineEdit_ChatInput && lineEdit_ChatInput->text() != "" && event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Tab) { myChat->nickAutoCompletition(); return true; } else { diff --git a/src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.h b/src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.h index 51180744..060585cc 100644 --- a/src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.h +++ b/src/gui/qt/startnetworkgamedialog/startnetworkgamedialogimpl.h @@ -32,8 +32,9 @@ class ConfigFile; class ChatTools; class startWindowImpl; -class startNetworkGameDialogImpl: public QDialog, public Ui::startNetworkGameDialog { -Q_OBJECT +class startNetworkGameDialogImpl: public QDialog, public Ui::startNetworkGameDialog +{ + Q_OBJECT public: startNetworkGameDialogImpl(startWindowImpl *parent = 0, ConfigFile *config = 0); @@ -41,16 +42,20 @@ public: public slots: - void setMyW ( gameTableImpl* theValue ) { myW = theValue; } - ChatTools *getMyChat() { return myChat; } + void setMyW ( gameTableImpl* theValue ) { + myW = theValue; + } + ChatTools *getMyChat() { + return myChat; + } void startGame(); void cancel(); void refresh(int actionID); void accept(); void reject(); - void joinedNetworkGame(unsigned playerId, QString playerName, bool admin); - void addConnectedPlayer(unsigned playerId, QString playerName, bool admin); + void joinedNetworkGame(unsigned playerId, QString playerName, bool admin); + void addConnectedPlayer(unsigned playerId, QString playerName, bool admin); void updatePlayer(unsigned playerId, QString newPlayerName); void removePlayer(unsigned playerId, QString playerName); void newGameAdmin(unsigned playerId, QString playerName); @@ -65,23 +70,28 @@ public slots: void keyPressEvent ( QKeyEvent*); bool eventFilter(QObject *obj, QEvent *event); - void setMaxPlayerNumber ( int theValue ) { maxPlayerNumber = theValue; label_maxPlayerNumber->setText(QString::number(theValue,10)); } - int getMaxPlayerNumber() const { return maxPlayerNumber; } + void setMaxPlayerNumber ( int theValue ) { + maxPlayerNumber = theValue; + label_maxPlayerNumber->setText(QString::number(theValue,10)); + } + int getMaxPlayerNumber() const { + return maxPlayerNumber; + } void exec(); -private: +private: gameTableImpl* myW; startWindowImpl* myStartWindow; int maxPlayerNumber; int keyUpDownChatCounter; unsigned myPlayerId; - bool isAdmin; + bool isAdmin; ConfigFile *myConfig; boost::shared_ptr mySession; ChatTools *myChat; - + }; #endif diff --git a/src/gui/qt/startwindow/startwindowimpl.cpp b/src/gui/qt/startwindow/startwindowimpl.cpp index 14c0f7aa..67e5a1ae 100644 --- a/src/gui/qt/startwindow/startwindowimpl.cpp +++ b/src/gui/qt/startwindow/startwindowimpl.cpp @@ -52,125 +52,125 @@ using namespace std; startWindowImpl::startWindowImpl(ConfigFile *c) - : myConfig(c), msgBoxOutdatedVersionActive(false) + : myConfig(c), msgBoxOutdatedVersionActive(false) { - myGuiInterface.reset(new GuiWrapper(myConfig, this)); - { - mySession.reset(new Session(myGuiInterface.get(), myConfig)); - mySession->init(); // TODO handle error - // myGuiInterface->setSession(session); - } + myGuiInterface.reset(new GuiWrapper(myConfig, this)); + { + mySession.reset(new Session(myGuiInterface.get(), myConfig)); + mySession->init(); // TODO handle error + // myGuiInterface->setSession(session); + } - // #ifdef __APPLE__ - // setWindowModality(Qt::ApplicationModal); - // setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); - // #endif - setupUi(this); - this->setWindowTitle(QString(tr("PokerTH %1").arg(POKERTH_BETA_RELEASE_STRING))); - this->installEventFilter(this); + // #ifdef __APPLE__ + // setWindowModality(Qt::ApplicationModal); + // setWindowFlags(Qt::WindowSystemMenuHint | Qt::CustomizeWindowHint | Qt::Dialog); + // #endif + setupUi(this); + this->setWindowTitle(QString(tr("PokerTH %1").arg(POKERTH_BETA_RELEASE_STRING))); + this->installEventFilter(this); - //Widgets Grafiken per Stylesheets setzen - QString myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); - this->setWindowIcon(QIcon(myAppDataPath+"gfx/gui/misc/windowicon.png")); + //Widgets Grafiken per Stylesheets setzen + QString myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); + this->setWindowIcon(QIcon(myAppDataPath+"gfx/gui/misc/windowicon.png")); - this->setStatusBar(0); + this->setStatusBar(0); - centralwidget->setStyleSheet(".QWidget { background-image: url(\""+myAppDataPath+"gfx/gui/misc/startwindowbg.png\"); background-position: bottom center; background-origin: content; background-repeat: no-repeat;}"); + centralwidget->setStyleSheet(".QWidget { background-image: url(\""+myAppDataPath+"gfx/gui/misc/startwindowbg.png\"); background-position: bottom center; background-origin: content; background-repeat: no-repeat;}"); - // Dialogs - myNewGameDialog = new newGameDialogImpl(this, myConfig); - mySelectAvatarDialog = new selectAvatarDialogImpl(this, myConfig); - mySettingsDialog = new settingsDialogImpl(this, myConfig, mySelectAvatarDialog); - myJoinNetworkGameDialog = new joinNetworkGameDialogImpl(this, myConfig); - myConnectToServerDialog = new connectToServerDialogImpl(this); - myStartNetworkGameDialog = new startNetworkGameDialogImpl(this, myConfig); - myCreateNetworkGameDialog = new createNetworkGameDialogImpl(this, myConfig); - myAboutPokerthDialog = new aboutPokerthImpl(this, myConfig); - myGameLobbyDialog = new gameLobbyDialogImpl(this, myConfig); + // Dialogs + myNewGameDialog = new newGameDialogImpl(this, myConfig); + mySelectAvatarDialog = new selectAvatarDialogImpl(this, myConfig); + mySettingsDialog = new settingsDialogImpl(this, myConfig, mySelectAvatarDialog); + myJoinNetworkGameDialog = new joinNetworkGameDialogImpl(this, myConfig); + myConnectToServerDialog = new connectToServerDialogImpl(this); + myStartNetworkGameDialog = new startNetworkGameDialogImpl(this, myConfig); + myCreateNetworkGameDialog = new createNetworkGameDialogImpl(this, myConfig); + myAboutPokerthDialog = new aboutPokerthImpl(this, myConfig); + myGameLobbyDialog = new gameLobbyDialogImpl(this, myConfig); - myStartNetworkGameDialog->setMyW(myGuiInterface->getMyW()); - myGameLobbyDialog->setMyW(myGuiInterface->getMyW()); + myStartNetworkGameDialog->setMyW(myGuiInterface->getMyW()); + myGameLobbyDialog->setMyW(myGuiInterface->getMyW()); - myTimeoutDialog = new timeoutMsgBoxImpl(this); - myServerListDialog = new serverListDialogImpl(this, this, myConfig); - myInternetGameLoginDialog = new internetGameLoginDialogImpl(this, myConfig); + myTimeoutDialog = new timeoutMsgBoxImpl(this); + myServerListDialog = new serverListDialogImpl(this, this, myConfig); + myInternetGameLoginDialog = new internetGameLoginDialogImpl(this, myConfig); - connect( actionStart_Local_Game, SIGNAL( triggered() ), this, SLOT( callNewGameDialog() ) ); - connect( pushButtonStart_Local_Game, SIGNAL( clicked() ), this, SLOT( callNewGameDialog() ) ); - connect( actionInternet_Game, SIGNAL( triggered() ), this, SLOT( joinGameLobby() ) ); - connect( pushButtonInternet_Game, SIGNAL( clicked() ), this, SLOT( joinGameLobby() ) ); - connect( actionCreate_Network_Game, SIGNAL( triggered() ), this, SLOT( callCreateNetworkGameDialog() ) ); - connect( pushButton_Create_Network_Game, SIGNAL( clicked() ), this, SLOT( callCreateNetworkGameDialog() ) ); - connect( actionJoin_Network_Game, SIGNAL( triggered() ), this, SLOT( callJoinNetworkGameDialog() ) ); - connect( pushButton_Join_Network_Game, SIGNAL( clicked() ), this, SLOT( callJoinNetworkGameDialog() ) ); + connect( actionStart_Local_Game, SIGNAL( triggered() ), this, SLOT( callNewGameDialog() ) ); + connect( pushButtonStart_Local_Game, SIGNAL( clicked() ), this, SLOT( callNewGameDialog() ) ); + connect( actionInternet_Game, SIGNAL( triggered() ), this, SLOT( joinGameLobby() ) ); + connect( pushButtonInternet_Game, SIGNAL( clicked() ), this, SLOT( joinGameLobby() ) ); + connect( actionCreate_Network_Game, SIGNAL( triggered() ), this, SLOT( callCreateNetworkGameDialog() ) ); + connect( pushButton_Create_Network_Game, SIGNAL( clicked() ), this, SLOT( callCreateNetworkGameDialog() ) ); + connect( actionJoin_Network_Game, SIGNAL( triggered() ), this, SLOT( callJoinNetworkGameDialog() ) ); + connect( pushButton_Join_Network_Game, SIGNAL( clicked() ), this, SLOT( callJoinNetworkGameDialog() ) ); - connect( actionAbout_PokerTH, SIGNAL( triggered() ), this, SLOT( callAboutPokerthDialog() ) ); - connect( actionConfigure_PokerTH, SIGNAL( triggered() ), this, SLOT( callSettingsDialog() ) ); + connect( actionAbout_PokerTH, SIGNAL( triggered() ), this, SLOT( callAboutPokerthDialog() ) ); + connect( actionConfigure_PokerTH, SIGNAL( triggered() ), this, SLOT( callSettingsDialog() ) ); - connect(this, SIGNAL(signalShowClientDialog()), this, SLOT(showClientDialog())); + connect(this, SIGNAL(signalShowClientDialog()), this, SLOT(showClientDialog())); - connect(this, SIGNAL(signalNetClientConnect(int)), myConnectToServerDialog, SLOT(refresh(int))); - connect(this, SIGNAL(signalNetClientGameInfo(int)), myStartNetworkGameDialog, SLOT(refresh(int))); - connect(this, SIGNAL(signalNetClientGameInfo(int)), myGameLobbyDialog, SLOT(refresh(int))); + connect(this, SIGNAL(signalNetClientConnect(int)), myConnectToServerDialog, SLOT(refresh(int))); + connect(this, SIGNAL(signalNetClientGameInfo(int)), myStartNetworkGameDialog, SLOT(refresh(int))); + connect(this, SIGNAL(signalNetClientGameInfo(int)), myGameLobbyDialog, SLOT(refresh(int))); - connect(this, SIGNAL(signalNetClientServerListShow()), myServerListDialog, SLOT(exec())); - connect(this, SIGNAL(signalNetClientServerListClear()), myServerListDialog, SLOT(clearList())); - connect(this, SIGNAL(signalNetClientServerListAdd(unsigned)), myServerListDialog, SLOT(addServerItem(unsigned))); + connect(this, SIGNAL(signalNetClientServerListShow()), myServerListDialog, SLOT(exec())); + connect(this, SIGNAL(signalNetClientServerListClear()), myServerListDialog, SLOT(clearList())); + connect(this, SIGNAL(signalNetClientServerListAdd(unsigned)), myServerListDialog, SLOT(addServerItem(unsigned))); - connect(this, SIGNAL(signalNetClientLoginShow()), this, SLOT(callInternetGameLoginDialog())); + connect(this, SIGNAL(signalNetClientLoginShow()), this, SLOT(callInternetGameLoginDialog())); - connect(this, SIGNAL(signalNetClientSelfJoined(unsigned, QString, bool)), myStartNetworkGameDialog, SLOT(joinedNetworkGame(unsigned, QString, bool))); - connect(this, SIGNAL(signalNetClientPlayerJoined(unsigned, QString, bool)), myStartNetworkGameDialog, SLOT(addConnectedPlayer(unsigned, QString, bool))); - connect(this, SIGNAL(signalNetClientPlayerChanged(unsigned, QString)), myStartNetworkGameDialog, SLOT(updatePlayer(unsigned, QString))); - connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned, QString)), myStartNetworkGameDialog, SLOT(removePlayer(unsigned, QString))); - connect(this, SIGNAL(signalNetClientNewGameAdmin(unsigned, QString)), myStartNetworkGameDialog, SLOT(newGameAdmin(unsigned, QString))); - connect(this, SIGNAL(signalNetClientGameListNew(unsigned)), myStartNetworkGameDialog, SLOT(gameCreated(unsigned))); + connect(this, SIGNAL(signalNetClientSelfJoined(unsigned, QString, bool)), myStartNetworkGameDialog, SLOT(joinedNetworkGame(unsigned, QString, bool))); + connect(this, SIGNAL(signalNetClientPlayerJoined(unsigned, QString, bool)), myStartNetworkGameDialog, SLOT(addConnectedPlayer(unsigned, QString, bool))); + connect(this, SIGNAL(signalNetClientPlayerChanged(unsigned, QString)), myStartNetworkGameDialog, SLOT(updatePlayer(unsigned, QString))); + connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned, QString)), myStartNetworkGameDialog, SLOT(removePlayer(unsigned, QString))); + connect(this, SIGNAL(signalNetClientNewGameAdmin(unsigned, QString)), myStartNetworkGameDialog, SLOT(newGameAdmin(unsigned, QString))); + connect(this, SIGNAL(signalNetClientGameListNew(unsigned)), myStartNetworkGameDialog, SLOT(gameCreated(unsigned))); - connect(this, SIGNAL(signalNetClientSelfJoined(unsigned, QString, bool)), myGameLobbyDialog, SLOT(joinedNetworkGame(unsigned, QString, bool))); - connect(this, SIGNAL(signalNetClientPlayerJoined(unsigned, QString, bool)), myGameLobbyDialog, SLOT(addConnectedPlayer(unsigned, QString, bool))); - connect(this, SIGNAL(signalNetClientPlayerChanged(unsigned, QString)), myGameLobbyDialog, SLOT(updatePlayer(unsigned, QString))); - connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned, QString)), myGameLobbyDialog, SLOT(removePlayer(unsigned, QString))); - connect(this, SIGNAL(signalNetClientNewGameAdmin(unsigned, QString)), myGameLobbyDialog, SLOT(newGameAdmin(unsigned, QString))); + connect(this, SIGNAL(signalNetClientSelfJoined(unsigned, QString, bool)), myGameLobbyDialog, SLOT(joinedNetworkGame(unsigned, QString, bool))); + connect(this, SIGNAL(signalNetClientPlayerJoined(unsigned, QString, bool)), myGameLobbyDialog, SLOT(addConnectedPlayer(unsigned, QString, bool))); + connect(this, SIGNAL(signalNetClientPlayerChanged(unsigned, QString)), myGameLobbyDialog, SLOT(updatePlayer(unsigned, QString))); + connect(this, SIGNAL(signalNetClientPlayerLeft(unsigned, QString)), myGameLobbyDialog, SLOT(removePlayer(unsigned, QString))); + connect(this, SIGNAL(signalNetClientNewGameAdmin(unsigned, QString)), myGameLobbyDialog, SLOT(newGameAdmin(unsigned, QString))); - connect(this, SIGNAL(signalNetClientGameListNew(unsigned)), myGameLobbyDialog, SLOT(addGame(unsigned))); - connect(this, SIGNAL(signalNetClientGameListRemove(unsigned)), myGameLobbyDialog, SLOT(removeGame(unsigned))); - connect(this, SIGNAL(signalNetClientGameListUpdateMode(unsigned, int)), myGameLobbyDialog, SLOT(updateGameMode(unsigned, int))); - connect(this, SIGNAL(signalNetClientGameListUpdateAdmin(unsigned, unsigned)), myGameLobbyDialog, SLOT(updateGameAdmin(unsigned, unsigned))); - connect(this, SIGNAL(signalNetClientGameListPlayerJoined(unsigned, unsigned)), myGameLobbyDialog, SLOT(gameAddPlayer(unsigned, unsigned))); - connect(this, SIGNAL(signalNetClientGameListPlayerLeft(unsigned, unsigned)), myGameLobbyDialog, SLOT(gameRemovePlayer(unsigned, unsigned))); - connect(this, SIGNAL(signalNetClientRemovedFromGame(int)), myGameLobbyDialog, SLOT(removedFromGame(int))); - connect(this, SIGNAL(signalNetClientStatsUpdate(ServerStats)), myGameLobbyDialog, SLOT(updateStats(ServerStats))); + connect(this, SIGNAL(signalNetClientGameListNew(unsigned)), myGameLobbyDialog, SLOT(addGame(unsigned))); + connect(this, SIGNAL(signalNetClientGameListRemove(unsigned)), myGameLobbyDialog, SLOT(removeGame(unsigned))); + connect(this, SIGNAL(signalNetClientGameListUpdateMode(unsigned, int)), myGameLobbyDialog, SLOT(updateGameMode(unsigned, int))); + connect(this, SIGNAL(signalNetClientGameListUpdateAdmin(unsigned, unsigned)), myGameLobbyDialog, SLOT(updateGameAdmin(unsigned, unsigned))); + connect(this, SIGNAL(signalNetClientGameListPlayerJoined(unsigned, unsigned)), myGameLobbyDialog, SLOT(gameAddPlayer(unsigned, unsigned))); + connect(this, SIGNAL(signalNetClientGameListPlayerLeft(unsigned, unsigned)), myGameLobbyDialog, SLOT(gameRemovePlayer(unsigned, unsigned))); + connect(this, SIGNAL(signalNetClientRemovedFromGame(int)), myGameLobbyDialog, SLOT(removedFromGame(int))); + connect(this, SIGNAL(signalNetClientStatsUpdate(ServerStats)), myGameLobbyDialog, SLOT(updateStats(ServerStats))); - connect(this, SIGNAL(signalNetClientGameChatMsg(QString, QString)), myGuiInterface->getMyW()->getMyChat(), SLOT(receiveMessage(QString, QString))); - connect(this, SIGNAL(signalNetClientLobbyChatMsg(QString, QString)), myStartNetworkGameDialog->getMyChat(), SLOT(receiveMessage(QString, QString))); - connect(this, SIGNAL(signalNetClientLobbyChatMsg(QString, QString)), myGameLobbyDialog->getMyChat(), SLOT(receiveMessage(QString, QString))); - connect(this, SIGNAL(signalNetClientMsgBox(QString)), this, SLOT(networkMessage(QString))); - connect(this, SIGNAL(signalNetClientMsgBox(unsigned)), this, SLOT(networkMessage(unsigned))); - connect(this, SIGNAL(signalNetClientShowTimeoutDialog(int, unsigned)), this, SLOT(showTimeoutDialog(int, unsigned))); + connect(this, SIGNAL(signalNetClientGameChatMsg(QString, QString)), myGuiInterface->getMyW()->getMyChat(), SLOT(receiveMessage(QString, QString))); + connect(this, SIGNAL(signalNetClientLobbyChatMsg(QString, QString)), myStartNetworkGameDialog->getMyChat(), SLOT(receiveMessage(QString, QString))); + connect(this, SIGNAL(signalNetClientLobbyChatMsg(QString, QString)), myGameLobbyDialog->getMyChat(), SLOT(receiveMessage(QString, QString))); + connect(this, SIGNAL(signalNetClientMsgBox(QString)), this, SLOT(networkMessage(QString))); + connect(this, SIGNAL(signalNetClientMsgBox(unsigned)), this, SLOT(networkMessage(unsigned))); + connect(this, SIGNAL(signalNetClientShowTimeoutDialog(int, unsigned)), this, SLOT(showTimeoutDialog(int, unsigned))); - connect(this, SIGNAL(signalLobbyPlayerJoined(unsigned, QString)), myGameLobbyDialog, SLOT(playerJoinedLobby(unsigned, QString))); - connect(this, SIGNAL(signalLobbyPlayerLeft(unsigned)), myGameLobbyDialog, SLOT(playerLeftLobby(unsigned))); + connect(this, SIGNAL(signalLobbyPlayerJoined(unsigned, QString)), myGameLobbyDialog, SLOT(playerJoinedLobby(unsigned, QString))); + connect(this, SIGNAL(signalLobbyPlayerLeft(unsigned)), myGameLobbyDialog, SLOT(playerLeftLobby(unsigned))); - // Errors are handled globally, not within one dialog. - connect(this, SIGNAL(signalNetClientError(int, int)), this, SLOT(networkError(int, int))); - connect(this, SIGNAL(signalNetClientNotification(int)), this, SLOT(networkNotification(int))); - connect(this, SIGNAL(signalNetServerError(int, int)), this, SLOT(networkError(int, int))); - connect(this, SIGNAL(signalNetClientRemovedFromGame(int)), this, SLOT(networkNotification(int))); - connect(this, SIGNAL(signalNetClientGameStart(boost::shared_ptr)), this, SLOT(networkStart(boost::shared_ptr))); + // Errors are handled globally, not within one dialog. + connect(this, SIGNAL(signalNetClientError(int, int)), this, SLOT(networkError(int, int))); + connect(this, SIGNAL(signalNetClientNotification(int)), this, SLOT(networkNotification(int))); + connect(this, SIGNAL(signalNetServerError(int, int)), this, SLOT(networkError(int, int))); + connect(this, SIGNAL(signalNetClientRemovedFromGame(int)), this, SLOT(networkNotification(int))); + connect(this, SIGNAL(signalNetClientGameStart(boost::shared_ptr)), this, SLOT(networkStart(boost::shared_ptr))); - connect(this, SIGNAL(signalSelfGameInvitation(unsigned, unsigned)), myGameLobbyDialog, SLOT(showInvitationDialog(unsigned, unsigned))); - connect(this, SIGNAL(signalPlayerGameInvitation(unsigned, unsigned, unsigned)), myGameLobbyDialog, SLOT(chatInfoPlayerInvitation(unsigned, unsigned, unsigned))); - connect(this, SIGNAL(signalRejectedGameInvitation(unsigned, unsigned, DenyGameInvitationReason)), myGameLobbyDialog, SLOT(chatInfoPlayerRejectedInvitation(unsigned, unsigned, DenyGameInvitationReason))); + connect(this, SIGNAL(signalSelfGameInvitation(unsigned, unsigned)), myGameLobbyDialog, SLOT(showInvitationDialog(unsigned, unsigned))); + connect(this, SIGNAL(signalPlayerGameInvitation(unsigned, unsigned, unsigned)), myGameLobbyDialog, SLOT(chatInfoPlayerInvitation(unsigned, unsigned, unsigned))); + connect(this, SIGNAL(signalRejectedGameInvitation(unsigned, unsigned, DenyGameInvitationReason)), myGameLobbyDialog, SLOT(chatInfoPlayerRejectedInvitation(unsigned, unsigned, DenyGameInvitationReason))); - this->show(); + this->show(); - //update HACKS - if(!checkForFirstStartAfterUpdated().isEmpty()) { - qDebug() << checkForFirstStartAfterUpdated(); - } + //update HACKS + if(!checkForFirstStartAfterUpdated().isEmpty()) { + qDebug() << checkForFirstStartAfterUpdated(); + } } @@ -178,848 +178,918 @@ startWindowImpl::~startWindowImpl() { } -void startWindowImpl::callNewGameDialog() { +void startWindowImpl::callNewGameDialog() +{ - //wenn Dialogfenster gezeigt werden soll - if(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame")){ + //wenn Dialogfenster gezeigt werden soll + if(myConfig->readConfigInt("ShowGameSettingsDialogOnNewGame")) { - myNewGameDialog->exec(); - if (myNewGameDialog->result() == QDialog::Accepted ) { startNewLocalGame(myNewGameDialog); } - } - // sonst mit gespeicherten Werten starten - else { startNewLocalGame(); } + myNewGameDialog->exec(); + if (myNewGameDialog->result() == QDialog::Accepted ) { + startNewLocalGame(myNewGameDialog); + } + } + // sonst mit gespeicherten Werten starten + else { + startNewLocalGame(); + } } -void startWindowImpl::startNewLocalGame(newGameDialogImpl *v) { +void startWindowImpl::startNewLocalGame(newGameDialogImpl *v) +{ - this->hide(); - myGuiInterface->getMyW()->show(); + this->hide(); + myGuiInterface->getMyW()->show(); - // Start new local game - terminate existing network game. - mySession->terminateNetworkClient(); - if (myServerGuiInterface.get()) - myServerGuiInterface->getSession()->terminateNetworkServer(); + // Start new local game - terminate existing network game. + mySession->terminateNetworkClient(); + if (myServerGuiInterface.get()) + myServerGuiInterface->getSession()->terminateNetworkServer(); - //get values from local game dialog - GameData gameData; - if(v) { - // Set Game Data - gameData.maxNumberOfPlayers = v->spinBox_quantityPlayers->value(); - gameData.startMoney = v->spinBox_startCash->value(); - gameData.firstSmallBlind = v->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value(); + //get values from local game dialog + GameData gameData; + if(v) { + // Set Game Data + gameData.maxNumberOfPlayers = v->spinBox_quantityPlayers->value(); + gameData.startMoney = v->spinBox_startCash->value(); + gameData.firstSmallBlind = v->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value(); - if(v->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) { - gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER; - gameData.raiseSmallBlindEveryHandsValue = v->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value(); - } - else { - gameData.raiseIntervalMode = RAISE_ON_MINUTES; - gameData.raiseSmallBlindEveryMinutesValue = v->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value(); - } + if(v->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) { + gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER; + gameData.raiseSmallBlindEveryHandsValue = v->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value(); + } else { + gameData.raiseIntervalMode = RAISE_ON_MINUTES; + gameData.raiseSmallBlindEveryMinutesValue = v->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value(); + } - if(v->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) { - gameData.raiseMode = DOUBLE_BLINDS; - } - else { - gameData.raiseMode = MANUAL_BLINDS_ORDER; - list tempBlindList; - int i; - bool ok = TRUE; - for(i=0; igetChangeCompleteBlindsDialog()->listWidget_blinds->count(); i++) { - tempBlindList.push_back(v->getChangeCompleteBlindsDialog()->listWidget_blinds->item(i)->text().toInt(&ok,10)); - } - gameData.manualBlindsList = tempBlindList; + if(v->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) { + gameData.raiseMode = DOUBLE_BLINDS; + } else { + gameData.raiseMode = MANUAL_BLINDS_ORDER; + list tempBlindList; + int i; + bool ok = TRUE; + for(i=0; igetChangeCompleteBlindsDialog()->listWidget_blinds->count(); i++) { + tempBlindList.push_back(v->getChangeCompleteBlindsDialog()->listWidget_blinds->item(i)->text().toInt(&ok,10)); + } + gameData.manualBlindsList = tempBlindList; - if(v->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; } - else { - if(v->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysRaiseAbout->isChecked()) { - gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT; - gameData.afterMBAlwaysRaiseValue = v->getChangeCompleteBlindsDialog()->spinBox_afterThisAlwaysRaiseValue->value(); - } - else { gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; } - } - } + if(v->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) { + gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; + } else { + if(v->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysRaiseAbout->isChecked()) { + gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT; + gameData.afterMBAlwaysRaiseValue = v->getChangeCompleteBlindsDialog()->spinBox_afterThisAlwaysRaiseValue->value(); + } else { + gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; + } + } + } - //Speeds - gameData.guiSpeed = v->spinBox_gameSpeed->value(); - } - // start with default values - else { - // Set Game Data - gameData.maxNumberOfPlayers = myConfig->readConfigInt("NumberOfPlayers"); - gameData.startMoney = myConfig->readConfigInt("StartCash"); - gameData.firstSmallBlind = myConfig->readConfigInt("FirstSmallBlind"); - - if(myConfig->readConfigInt("RaiseBlindsAtHands")) { - gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER; - gameData.raiseSmallBlindEveryHandsValue = myConfig->readConfigInt("RaiseSmallBlindEveryHands"); - } - else { - gameData.raiseIntervalMode = RAISE_ON_MINUTES; - gameData.raiseSmallBlindEveryMinutesValue = myConfig->readConfigInt("RaiseSmallBlindEveryMinutes"); - } + //Speeds + gameData.guiSpeed = v->spinBox_gameSpeed->value(); + } + // start with default values + else { + // Set Game Data + gameData.maxNumberOfPlayers = myConfig->readConfigInt("NumberOfPlayers"); + gameData.startMoney = myConfig->readConfigInt("StartCash"); + gameData.firstSmallBlind = myConfig->readConfigInt("FirstSmallBlind"); - if(myConfig->readConfigInt("AlwaysDoubleBlinds")) { - gameData.raiseMode = DOUBLE_BLINDS; - } - else { - gameData.raiseMode = MANUAL_BLINDS_ORDER; - gameData.manualBlindsList = myConfig->readConfigIntList("ManualBlindsList"); + if(myConfig->readConfigInt("RaiseBlindsAtHands")) { + gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER; + gameData.raiseSmallBlindEveryHandsValue = myConfig->readConfigInt("RaiseSmallBlindEveryHands"); + } else { + gameData.raiseIntervalMode = RAISE_ON_MINUTES; + gameData.raiseSmallBlindEveryMinutesValue = myConfig->readConfigInt("RaiseSmallBlindEveryMinutes"); + } - if(myConfig->readConfigInt("AfterMBAlwaysDoubleBlinds")) { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; } - else { - if(myConfig->readConfigInt("AfterMBAlwaysRaiseAbout")) { - gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT; - gameData.afterMBAlwaysRaiseValue = myConfig->readConfigInt("AfterMBAlwaysRaiseValue"); - } - else { gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; } - } - } - //Speeds - gameData.guiSpeed = myConfig->readConfigInt("GameSpeed"); - } - // Set dealer pos. - StartData startData; - int tmpDealerPos = 0; - startData.numberOfPlayers = gameData.maxNumberOfPlayers; - Tools::getRandNumber(0, startData.numberOfPlayers-1, 1, &tmpDealerPos, 0); - //if(DEBUG_MODE) { - // tmpDealerPos = 4; - //} - startData.startDealerPlayerId = static_cast(tmpDealerPos); + if(myConfig->readConfigInt("AlwaysDoubleBlinds")) { + gameData.raiseMode = DOUBLE_BLINDS; + } else { + gameData.raiseMode = MANUAL_BLINDS_ORDER; + gameData.manualBlindsList = myConfig->readConfigIntList("ManualBlindsList"); - //some gui modifications - myGuiInterface->getMyW()->localGameModification(); + if(myConfig->readConfigInt("AfterMBAlwaysDoubleBlinds")) { + gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; + } else { + if(myConfig->readConfigInt("AfterMBAlwaysRaiseAbout")) { + gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT; + gameData.afterMBAlwaysRaiseValue = myConfig->readConfigInt("AfterMBAlwaysRaiseValue"); + } else { + gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; + } + } + } + //Speeds + gameData.guiSpeed = myConfig->readConfigInt("GameSpeed"); + } + // Set dealer pos. + StartData startData; + int tmpDealerPos = 0; + startData.numberOfPlayers = gameData.maxNumberOfPlayers; + Tools::getRandNumber(0, startData.numberOfPlayers-1, 1, &tmpDealerPos, 0); + //if(DEBUG_MODE) { + // tmpDealerPos = 4; + //} + startData.startDealerPlayerId = static_cast(tmpDealerPos); - //Start Game!!! - mySession->startLocalGame(gameData, startData); + //some gui modifications + myGuiInterface->getMyW()->localGameModification(); + + //Start Game!!! + mySession->startLocalGame(gameData, startData); } -void startWindowImpl::callGameLobbyDialog() { +void startWindowImpl::callGameLobbyDialog() +{ - //Avoid join Lobby with "Human Player" nick - if(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()) == QString("Human Player")) { - changeContentDialogImpl dialog(this, myConfig, CHANGE_HUMAN_PLAYER_NAME); - dialog.exec(); - if(dialog.result() == QDialog::Accepted) { - joinGameLobby(); - } - } - else { - joinGameLobby(); - } + //Avoid join Lobby with "Human Player" nick + if(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()) == QString("Human Player")) { + changeContentDialogImpl dialog(this, myConfig, CHANGE_HUMAN_PLAYER_NAME); + dialog.exec(); + if(dialog.result() == QDialog::Accepted) { + joinGameLobby(); + } + } else { + joinGameLobby(); + } } -void startWindowImpl::joinGameLobby() { +void startWindowImpl::joinGameLobby() +{ - // Stop local game. - myGuiInterface->getMyW()->stopTimer(); + // Stop local game. + myGuiInterface->getMyW()->stopTimer(); - mySession->terminateNetworkClient(); - if (myServerGuiInterface) - myServerGuiInterface->getSession()->terminateNetworkServer(); + mySession->terminateNetworkClient(); + if (myServerGuiInterface) + myServerGuiInterface->getSession()->terminateNetworkServer(); - myGameLobbyDialog->setSession(getSession()); - myStartNetworkGameDialog->setSession(getSession()); + myGameLobbyDialog->setSession(getSession()); + myStartNetworkGameDialog->setSession(getSession()); - // Clear Lobby dialog. - myGameLobbyDialog->clearDialog(); + // Clear Lobby dialog. + myGameLobbyDialog->clearDialog(); - //start internet client with config values for user and pw TODO - mySession->startInternetClient(); + //start internet client with config values for user and pw TODO + mySession->startInternetClient(); - //Dialog mit Statusbalken - myConnectToServerDialog->exec(); - if (myConnectToServerDialog->result() == QDialog::Accepted ) { - showLobbyDialog(); - } - else { - mySession->terminateNetworkClient(); - } + //Dialog mit Statusbalken + myConnectToServerDialog->exec(); + if (myConnectToServerDialog->result() == QDialog::Accepted ) { + showLobbyDialog(); + } else { + mySession->terminateNetworkClient(); + } } -void startWindowImpl::callInternetGameLoginDialog() { +void startWindowImpl::callInternetGameLoginDialog() +{ - //login + //login - //HACK if Outdated Version info is available show it here! - if(msgBoxOutdatedVersionActive) { - msgBoxOutdatedVersionActive = false; - msgBoxOutdatedVersion.exec(); - msgBoxOutdatedVersion.raise(); - msgBoxOutdatedVersion.activateWindow(); - } + //HACK if Outdated Version info is available show it here! + if(msgBoxOutdatedVersionActive) { + msgBoxOutdatedVersionActive = false; + msgBoxOutdatedVersion.exec(); + msgBoxOutdatedVersion.raise(); + msgBoxOutdatedVersion.activateWindow(); + } - myInternetGameLoginDialog->exec(); + myInternetGameLoginDialog->exec(); - if(myInternetGameLoginDialog->result() == QDialog::Accepted) { - //send login infos - mySession->setLogin( - myConfig->readConfigString("MyName"), - myInternetGameLoginDialog->lineEdit_password->text().toUtf8().constData(), - myInternetGameLoginDialog->checkBox_guest->isChecked()); - } - else { - myConnectToServerDialog->reject(); - mySession->terminateNetworkClient(); - } + if(myInternetGameLoginDialog->result() == QDialog::Accepted) { + //send login infos + mySession->setLogin( + myConfig->readConfigString("MyName"), + myInternetGameLoginDialog->lineEdit_password->text().toUtf8().constData(), + myInternetGameLoginDialog->checkBox_guest->isChecked()); + } else { + myConnectToServerDialog->reject(); + mySession->terminateNetworkClient(); + } } -void startWindowImpl::callCreateNetworkGameDialog() { +void startWindowImpl::callCreateNetworkGameDialog() +{ - myCreateNetworkGameDialog->exec(); - // - if (myCreateNetworkGameDialog->result() == QDialog::Accepted ) { + myCreateNetworkGameDialog->exec(); + // + if (myCreateNetworkGameDialog->result() == QDialog::Accepted ) { - // Stop local game. - myGuiInterface->getMyW()->stopTimer(); + // Stop local game. + myGuiInterface->getMyW()->stopTimer(); - if (!myServerGuiInterface) - { - // Create pseudo Gui Wrapper for the server. - myServerGuiInterface.reset(new ServerGuiWrapper(myConfig, mySession->getGui(), mySession->getGui(), mySession->getGui())); - { - boost::shared_ptr session(new Session(myServerGuiInterface.get(), myConfig)); - session->init(mySession->getAvatarManager()); - myServerGuiInterface->setSession(session); - } - } + if (!myServerGuiInterface) { + // Create pseudo Gui Wrapper for the server. + myServerGuiInterface.reset(new ServerGuiWrapper(myConfig, mySession->getGui(), mySession->getGui(), mySession->getGui())); + { + boost::shared_ptr session(new Session(myServerGuiInterface.get(), myConfig)); + session->init(mySession->getAvatarManager()); + myServerGuiInterface->setSession(session); + } + } - // Terminate existing network games. - mySession->terminateNetworkClient(); - myServerGuiInterface->getSession()->terminateNetworkServer(); + // Terminate existing network games. + mySession->terminateNetworkClient(); + myServerGuiInterface->getSession()->terminateNetworkServer(); - GameData gameData; - gameData.maxNumberOfPlayers = myCreateNetworkGameDialog->spinBox_quantityPlayers->value(); - gameData.startMoney = myCreateNetworkGameDialog->spinBox_startCash->value(); - gameData.firstSmallBlind = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value(); + GameData gameData; + gameData.maxNumberOfPlayers = myCreateNetworkGameDialog->spinBox_quantityPlayers->value(); + gameData.startMoney = myCreateNetworkGameDialog->spinBox_startCash->value(); + gameData.firstSmallBlind = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_firstSmallBlind->value(); - if(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) { - gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER; - gameData.raiseSmallBlindEveryHandsValue = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value(); - } - else { - gameData.raiseIntervalMode = RAISE_ON_MINUTES; - gameData.raiseSmallBlindEveryMinutesValue = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value(); - } + if(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) { + gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER; + gameData.raiseSmallBlindEveryHandsValue = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value(); + } else { + gameData.raiseIntervalMode = RAISE_ON_MINUTES; + gameData.raiseSmallBlindEveryMinutesValue = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value(); + } - if(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) { - gameData.raiseMode = DOUBLE_BLINDS; - } - else { - gameData.raiseMode = MANUAL_BLINDS_ORDER; - std::list tempBlindList; - int i; - bool ok = TRUE; - for(i=0; igetChangeCompleteBlindsDialog()->listWidget_blinds->count(); i++) { - tempBlindList.push_back(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->listWidget_blinds->item(i)->text().toInt(&ok,10)); - } - gameData.manualBlindsList = tempBlindList; + if(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) { + gameData.raiseMode = DOUBLE_BLINDS; + } else { + gameData.raiseMode = MANUAL_BLINDS_ORDER; + std::list tempBlindList; + int i; + bool ok = TRUE; + for(i=0; igetChangeCompleteBlindsDialog()->listWidget_blinds->count(); i++) { + tempBlindList.push_back(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->listWidget_blinds->item(i)->text().toInt(&ok,10)); + } + gameData.manualBlindsList = tempBlindList; - if(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; } - else { - if(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysRaiseAbout->isChecked()) { - gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT; - gameData.afterMBAlwaysRaiseValue = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_afterThisAlwaysRaiseValue->value(); - } - else { gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; } - } - } + if(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) { + gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; + } else { + if(myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysRaiseAbout->isChecked()) { + gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT; + gameData.afterMBAlwaysRaiseValue = myCreateNetworkGameDialog->getChangeCompleteBlindsDialog()->spinBox_afterThisAlwaysRaiseValue->value(); + } else { + gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; + } + } + } - gameData.guiSpeed = myConfig->readConfigInt("GameSpeed"); - gameData.delayBetweenHandsSec = myCreateNetworkGameDialog->spinBox_netDelayBetweenHands->value(); - gameData.playerActionTimeoutSec = myCreateNetworkGameDialog->spinBox_netTimeOutPlayerAction->value(); + gameData.guiSpeed = myConfig->readConfigInt("GameSpeed"); + gameData.delayBetweenHandsSec = myCreateNetworkGameDialog->spinBox_netDelayBetweenHands->value(); + gameData.playerActionTimeoutSec = myCreateNetworkGameDialog->spinBox_netTimeOutPlayerAction->value(); - myGameLobbyDialog->setSession(getSession()); - myStartNetworkGameDialog->setSession(getSession()); + myGameLobbyDialog->setSession(getSession()); + myStartNetworkGameDialog->setSession(getSession()); - // Clear network game dialog. - myStartNetworkGameDialog->clearDialog(); + // Clear network game dialog. + myStartNetworkGameDialog->clearDialog(); - myServerGuiInterface->getSession()->startNetworkServer(false); - mySession->startNetworkClientForLocalServer(gameData); + myServerGuiInterface->getSession()->startNetworkServer(false); + mySession->startNetworkClientForLocalServer(gameData); - myStartNetworkGameDialog->setMaxPlayerNumber(gameData.maxNumberOfPlayers); + myStartNetworkGameDialog->setMaxPlayerNumber(gameData.maxNumberOfPlayers); - myStartNetworkGameDialog->setWindowTitle("Start Network Game"); + myStartNetworkGameDialog->setWindowTitle("Start Network Game"); - showNetworkStartDialog(); - } + showNetworkStartDialog(); + } } -void startWindowImpl::callJoinNetworkGameDialog() { +void startWindowImpl::callJoinNetworkGameDialog() +{ - myJoinNetworkGameDialog->exec(); + myJoinNetworkGameDialog->exec(); - if (myJoinNetworkGameDialog->result() == QDialog::Accepted ) { + if (myJoinNetworkGameDialog->result() == QDialog::Accepted ) { - // Stop local game. - myGuiInterface->getMyW()->stopTimer(); + // Stop local game. + myGuiInterface->getMyW()->stopTimer(); - mySession->terminateNetworkClient(); - if (myServerGuiInterface) - myServerGuiInterface->getSession()->terminateNetworkServer(); + mySession->terminateNetworkClient(); + if (myServerGuiInterface) + myServerGuiInterface->getSession()->terminateNetworkServer(); - myGameLobbyDialog->setSession(getSession()); - myStartNetworkGameDialog->setSession(getSession()); - // Clear network game dialog - myStartNetworkGameDialog->clearDialog(); - // Maybe use QUrl::toPunycode. - mySession->startNetworkClient( - myJoinNetworkGameDialog->lineEdit_ipAddress->text().toUtf8().constData(), - myJoinNetworkGameDialog->spinBox_port->value(), - myJoinNetworkGameDialog->checkBox_ipv6->isChecked(), - myJoinNetworkGameDialog->checkBox_sctp->isChecked()); + myGameLobbyDialog->setSession(getSession()); + myStartNetworkGameDialog->setSession(getSession()); + // Clear network game dialog + myStartNetworkGameDialog->clearDialog(); + // Maybe use QUrl::toPunycode. + mySession->startNetworkClient( + myJoinNetworkGameDialog->lineEdit_ipAddress->text().toUtf8().constData(), + myJoinNetworkGameDialog->spinBox_port->value(), + myJoinNetworkGameDialog->checkBox_ipv6->isChecked(), + myJoinNetworkGameDialog->checkBox_sctp->isChecked()); - //Dialog mit Statusbalken - myConnectToServerDialog->exec(); + //Dialog mit Statusbalken + myConnectToServerDialog->exec(); - if (myConnectToServerDialog->result() == QDialog::Rejected ) { - mySession->terminateNetworkClient(); - actionJoin_Network_Game->trigger(); // re-trigger - } - else { - //needed for join and ready sounds - TODO - //myStartNetworkGameDialog->setMaxPlayerNumber(gameData.maxNumberOfPlayers); - myStartNetworkGameDialog->setWindowTitle("Start Network Game"); + if (myConnectToServerDialog->result() == QDialog::Rejected ) { + mySession->terminateNetworkClient(); + actionJoin_Network_Game->trigger(); // re-trigger + } else { + //needed for join and ready sounds - TODO + //myStartNetworkGameDialog->setMaxPlayerNumber(gameData.maxNumberOfPlayers); + myStartNetworkGameDialog->setWindowTitle("Start Network Game"); - showNetworkStartDialog(); - } - } + showNetworkStartDialog(); + } + } } void startWindowImpl::showClientDialog() { - if (mySession->getGameType() == Session::GAME_TYPE_NETWORK) - { - if (myGuiInterface->getMyW()->isVisible()) - myGuiInterface->getMyW()->hide(); - if (!this->isVisible()) - this->show(); - if (!myStartNetworkGameDialog->isVisible()) - showNetworkStartDialog(); - } - else if (mySession->getGameType() == Session::GAME_TYPE_INTERNET) - { - if (myGuiInterface->getMyW()->isVisible()) - myGuiInterface->getMyW()->closeMessageBoxes(); - myGuiInterface->getMyW()->hide(); - if (!this->isVisible()) - this->show(); - if (!myGameLobbyDialog->isVisible()) - showLobbyDialog(); - } + if (mySession->getGameType() == Session::GAME_TYPE_NETWORK) { + if (myGuiInterface->getMyW()->isVisible()) + myGuiInterface->getMyW()->hide(); + if (!this->isVisible()) + this->show(); + if (!myStartNetworkGameDialog->isVisible()) + showNetworkStartDialog(); + } else if (mySession->getGameType() == Session::GAME_TYPE_INTERNET) { + if (myGuiInterface->getMyW()->isVisible()) + myGuiInterface->getMyW()->closeMessageBoxes(); + myGuiInterface->getMyW()->hide(); + if (!this->isVisible()) + this->show(); + if (!myGameLobbyDialog->isVisible()) + showLobbyDialog(); + } } void startWindowImpl::showLobbyDialog() { - myGameLobbyDialog->exec(); + myGameLobbyDialog->exec(); - if (myGameLobbyDialog->result() == QDialog::Accepted ) - { - this->hide(); - //some gui modifications - myGuiInterface->getMyW()->networkGameModification(); - } - else - { - myGameLobbyDialog->clearDialog(); - mySession->terminateNetworkClient(); - } + if (myGameLobbyDialog->result() == QDialog::Accepted ) { + this->hide(); + //some gui modifications + myGuiInterface->getMyW()->networkGameModification(); + } else { + myGameLobbyDialog->clearDialog(); + mySession->terminateNetworkClient(); + } } void startWindowImpl::showNetworkStartDialog() { - myStartNetworkGameDialog->exec(); + myStartNetworkGameDialog->exec(); - if (myStartNetworkGameDialog->result() == QDialog::Accepted ) { + if (myStartNetworkGameDialog->result() == QDialog::Accepted ) { - this->hide(); - //some gui modifications - myGuiInterface->getMyW()->networkGameModification(); - } - else { - mySession->terminateNetworkClient(); - if (myServerGuiInterface) - myServerGuiInterface->getSession()->terminateNetworkServer(); - } + this->hide(); + //some gui modifications + myGuiInterface->getMyW()->networkGameModification(); + } else { + mySession->terminateNetworkClient(); + if (myServerGuiInterface) + myServerGuiInterface->getSession()->terminateNetworkServer(); + } } -void startWindowImpl::callAboutPokerthDialog() { myAboutPokerthDialog->exec(); } - -void startWindowImpl::callSettingsDialog() { - - mySettingsDialog->exec(); - - if (mySettingsDialog->result() == QDialog::Accepted && mySettingsDialog->getSettingsCorrect()) { - myGuiInterface->getMyW()->applySettings(mySettingsDialog); - } +void startWindowImpl::callAboutPokerthDialog() +{ + myAboutPokerthDialog->exec(); } -void startWindowImpl::showTimeoutDialog(int msgID, unsigned duration) { +void startWindowImpl::callSettingsDialog() +{ - if(myTimeoutDialog->isHidden()) { - myTimeoutDialog->setMySession(mySession); - myTimeoutDialog->setMsgID((NetTimeoutReason)msgID); - myTimeoutDialog->setTimeoutDuration(duration); - myTimeoutDialog->show(); - myTimeoutDialog->raise(); - myTimeoutDialog->activateWindow(); - myTimeoutDialog->startTimeout(); - } + mySettingsDialog->exec(); + + if (mySettingsDialog->result() == QDialog::Accepted && mySettingsDialog->getSettingsCorrect()) { + myGuiInterface->getMyW()->applySettings(mySettingsDialog); + } } -void startWindowImpl::hideTimeoutDialog() { myTimeoutDialog->hide(); } +void startWindowImpl::showTimeoutDialog(int msgID, unsigned duration) +{ -void startWindowImpl::networkError(int errorID, int /*osErrorID*/) { + if(myTimeoutDialog->isHidden()) { + myTimeoutDialog->setMySession(mySession); + myTimeoutDialog->setMsgID((NetTimeoutReason)msgID); + myTimeoutDialog->setTimeoutDuration(duration); + myTimeoutDialog->show(); + myTimeoutDialog->raise(); + myTimeoutDialog->activateWindow(); + myTimeoutDialog->startTimeout(); + } +} - hideTimeoutDialog(); - switch (errorID) { - case ERR_SOCK_SERVERADDR_NOT_SET: - {QMessageBox::warning(this, tr("Network Error"), - tr("Server address was not set."), - QMessageBox::Close); } - break; - case ERR_SOCK_INVALID_PORT: - { QMessageBox::warning(this, tr("Network Error"), - tr("An invalid port was set (ports 0-1023 are not allowed)."), - QMessageBox::Close); } - break; - case ERR_SOCK_CREATION_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not create a socket for TCP communication."), - QMessageBox::Close); } - break; - case ERR_SOCK_SET_ADDR_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not set the IP address."), - QMessageBox::Close); } - break; - case ERR_SOCK_SET_PORT_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not set the port for this type of address."), - QMessageBox::Close); } - break; - case ERR_SOCK_RESOLVE_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("The server name could not be resolved."), - QMessageBox::Close); } - break; - case ERR_SOCK_BIND_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Bind failed - please choose a different port."), - QMessageBox::Close); } - break; - case ERR_SOCK_LISTEN_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Internal network error: \"listen\" failed."), - QMessageBox::Close); } - break; - case ERR_SOCK_ACCEPT_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Server execution was terminated."), - QMessageBox::Close); } - break; - case ERR_SOCK_CONNECT_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not connect to the server."), - QMessageBox::Close); } - break; - case ERR_SOCK_CONNECT_TIMEOUT: - { QMessageBox::warning(this, tr("Network Error"), - tr("Connection timed out.\nPlease check the server address.\n\nIf the server is behind a NAT-Router, make sure port forwarding has been set up on server side."), - QMessageBox::Close); } - break; - case ERR_SOCK_SELECT_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Internal network error: \"select\" failed."), - QMessageBox::Close); } - break; - case ERR_SOCK_SEND_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Internal network error: \"send\" failed."), - QMessageBox::Close); } - break; - case ERR_SOCK_RECV_FAILED: // Sometimes windows reports recv failed on close. - case ERR_SOCK_CONN_RESET: - { QMessageBox::warning(this, tr("Network Error"), - tr("Connection was closed by the server."), - QMessageBox::Close); } - break; - case ERR_SOCK_CONN_EXISTS: - { QMessageBox::warning(this, tr("Network Error"), - tr("Internal network error: Duplicate TCP connection."), - QMessageBox::Close); } - break; - case ERR_SOCK_INVALID_PACKET: - { QMessageBox::warning(this, tr("Network Error"), - tr("An invalid network packet was received.\nPlease make sure that all players use the same version of PokerTH."), - QMessageBox::Close); } - break; - case ERR_SOCK_INVALID_STATE: - { QMessageBox::warning(this, tr("Network Error"), - tr("Internal state error.\nPlease make sure that all players use the same version of PokerTH."), - QMessageBox::Close); } - break; - case ERR_SOCK_INVALID_SERVERLIST_URL: - case ERR_SOCK_TRANSFER_INVALID_URL: - { QMessageBox::warning(this, tr("Network Error"), - tr("Invalid server list URL.\nPlease correct the address in the settings."), - QMessageBox::Close); } - break; - case ERR_SOCK_OPEN_MD5_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not open the server list MD5 file.\nPlease make sure that the server list URL is correct."), - QMessageBox::Close); } - break; - case ERR_SOCK_INVALID_SERVERLIST_MD5: - { QMessageBox::warning(this, tr("Network Error"), - tr("Synchronization of the PokerTH internet server list has failed.\nPlease make sure that the server list URL is correct."), - QMessageBox::Close); } - break; - case ERR_SOCK_INVALID_SERVERLIST_XML: - { QMessageBox::warning(this, tr("Network Error"), - tr("The PokerTH internet server list contains invalid data.\nIf you use a custom server list, please make sure its format is correct."), - QMessageBox::Close); } - break; - case ERR_SOCK_UNZIP_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not unzip the PokerTH internet server list."), - QMessageBox::Close); } - break; - case ERR_SOCK_TRANSFER_INIT_FAILED: - case ERR_SOCK_TRANSFER_SELECT_FAILED: - case ERR_SOCK_TRANSFER_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not download the PokerTH internet server list.\nPlease make sure you are directly connected to the internet."), - QMessageBox::Close); } - break; - case ERR_SOCK_TRANSFER_OPEN_FAILED: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not open the target file when downloading the server list."), - QMessageBox::Close); } - break; - case ERR_NET_VERSION_NOT_SUPPORTED: - { QMessageBox msgBox(QMessageBox::Warning, tr("Network Error"), - tr("The PokerTH server does not support this version of the game.
Please go to http://www.pokerth.net and download the latest version."), - QMessageBox::Close, this); - msgBox.setTextFormat(Qt::RichText); - msgBox.exec(); - } - break; - case ERR_NET_SERVER_FULL: - { QMessageBox::warning(this, tr("Network Error"), - tr("Sorry, this server is already full."), - QMessageBox::Close); } - break; - case ERR_NET_INVALID_PASSWORD: - { QMessageBox::warning(this, tr("Network Error"), - tr("Invalid login.\nPlease check your username and password."), - QMessageBox::Close); } - break; - case ERR_NET_INVALID_PASSWORD_STR: - { QMessageBox::warning(this, tr("Network Error"), - tr("The password is too long. Please choose another one."), - QMessageBox::Close); } - break; - case ERR_NET_PLAYER_NAME_IN_USE: - { changeContentDialogImpl dialog(this, myConfig, CHANGE_NICK_ALREADY_IN_USE); dialog.exec(); } - break; - case ERR_NET_INVALID_PLAYER_NAME: - { changeContentDialogImpl dialog(this, myConfig, CHANGE_NICK_INVALID); dialog.exec(); } - break; - case ERR_NET_INVALID_GAME_NAME: - { QMessageBox::warning(this, tr("Network Error"), - tr("The game name is either too short or too long. Please choose another one."), - QMessageBox::Close); } - break; - case ERR_NET_UNKNOWN_GAME: - { QMessageBox::warning(this, tr("Network Error"), - tr("The game could not be found."), - QMessageBox::Close); } - break; - case ERR_NET_INVALID_CHAT_TEXT: - { QMessageBox::warning(this, tr("Network Error"), - tr("The chat text is invalid."), - QMessageBox::Close); } - break; - case ERR_NET_UNKNOWN_PLAYER_ID: - { QMessageBox::warning(this, tr("Network Error"), - tr("The server referred to an unknown player. Aborting."), - QMessageBox::Close); } - break; - case ERR_NET_NO_CURRENT_PLAYER: - { QMessageBox::warning(this, tr("Network Error"), - tr("Internal error: The current player could not be found."), - QMessageBox::Close); } - break; - case ERR_NET_PLAYER_NOT_ACTIVE: - { QMessageBox::warning(this, tr("Network Error"), - tr("Internal error: The current player is not active."), - QMessageBox::Close); } - break; - case ERR_NET_PLAYER_KICKED: - { mySession->terminateNetworkClient(); - QMessageBox::warning(this, tr("Network Error"), - tr("You were kicked from the server."), - QMessageBox::Close); } - break; - case ERR_NET_PLAYER_BANNED: - { mySession->terminateNetworkClient(); - QMessageBox::warning(this, tr("Network Error"), - tr("You were temporarily banned from the server."), - QMessageBox::Close); } - break; - case ERR_NET_PLAYER_BLOCKED: - { mySession->terminateNetworkClient(); - QMessageBox::warning(this, tr("Network Error"), - tr("Your account is blocked indefinitely."), - QMessageBox::Close); } - break; - case ERR_NET_SESSION_TIMED_OUT: - { mySession->terminateNetworkClient(); - QMessageBox::warning(this, tr("Network Error"), - tr("Your server connection timed out due to inactivity. You are very welcome to reconnect!"), - QMessageBox::Close); } - break; - case ERR_NET_INVALID_PLAYER_COUNT: - { QMessageBox::warning(this, tr("Network Error"), - tr("The client player count is invalid."), - QMessageBox::Close); } - break; - case ERR_NET_TOO_MANY_MANUAL_BLINDS: - { QMessageBox::warning(this, tr("Network Error"), - tr("Too many manual blinds were set. Please reconfigure the manual blinds."), - QMessageBox::Close); } - break; - case ERR_NET_INVALID_AVATAR_FILE: - case ERR_NET_WRONG_AVATAR_SIZE: - { QMessageBox::warning(this, tr("Network Error"), - tr("An invalid avatar file was configured. Please choose a different avatar."), - QMessageBox::Close); } - break; - case ERR_NET_AVATAR_TOO_LARGE: - { QMessageBox::warning(this, tr("Network Error"), - tr("The selected avatar file is too large. Please choose a different avatar."), - QMessageBox::Close); } - break; - case ERR_NET_INIT_BLOCKED: - { QMessageBox::warning(this, tr("Network Error"), - tr("You cannot login at this time. Please try again in a few seconds."), - QMessageBox::Close); } - break; - case ERR_NET_INVALID_REQUEST_ID: - { QMessageBox::warning(this, tr("Network Error"), - tr("An internal avatar error occured. Please report this to an admin in the lobby chat."), - QMessageBox::Close); } - break; - case ERR_NET_START_TIMEOUT: - { QMessageBox::warning(this, tr("Network Error"), - tr("Could not start game: Synchronization failed."), - QMessageBox::Close); } - break; - case ERR_NET_SERVER_MAINTENANCE: - { QMessageBox::warning(this, tr("Network Error"), - tr("The server is down for maintenance. Please try again later."), - QMessageBox::Close); } - break; - default: { QMessageBox::warning(this, tr("Network Error"), - tr("An internal error occured."), - QMessageBox::Close); } - } - // close dialogs - myGameLobbyDialog->reject(); - myConnectToServerDialog->reject(); - myStartNetworkGameDialog->reject(); - myGuiInterface->getMyW()->close(); +void startWindowImpl::hideTimeoutDialog() +{ + myTimeoutDialog->hide(); +} + +void startWindowImpl::networkError(int errorID, int /*osErrorID*/) +{ + + hideTimeoutDialog(); + switch (errorID) { + case ERR_SOCK_SERVERADDR_NOT_SET: { + QMessageBox::warning(this, tr("Network Error"), + tr("Server address was not set."), + QMessageBox::Close); + } + break; + case ERR_SOCK_INVALID_PORT: { + QMessageBox::warning(this, tr("Network Error"), + tr("An invalid port was set (ports 0-1023 are not allowed)."), + QMessageBox::Close); + } + break; + case ERR_SOCK_CREATION_FAILED: { + QMessageBox::warning(this, tr("Network Error"), + tr("Could not create a socket for TCP communication."), + QMessageBox::Close); + } + break; + case ERR_SOCK_SET_ADDR_FAILED: { + QMessageBox::warning(this, tr("Network Error"), + tr("Could not set the IP address."), + QMessageBox::Close); + } + break; + case ERR_SOCK_SET_PORT_FAILED: { + QMessageBox::warning(this, tr("Network Error"), + tr("Could not set the port for this type of address."), + QMessageBox::Close); + } + break; + case ERR_SOCK_RESOLVE_FAILED: { + QMessageBox::warning(this, tr("Network Error"), + tr("The server name could not be resolved."), + QMessageBox::Close); + } + break; + case ERR_SOCK_BIND_FAILED: { + QMessageBox::warning(this, tr("Network Error"), + tr("Bind failed - please choose a different port."), + QMessageBox::Close); + } + break; + case ERR_SOCK_LISTEN_FAILED: { + QMessageBox::warning(this, tr("Network Error"), + tr("Internal network error: \"listen\" failed."), + QMessageBox::Close); + } + break; + case ERR_SOCK_ACCEPT_FAILED: { + QMessageBox::warning(this, tr("Network Error"), + tr("Server execution was terminated."), + QMessageBox::Close); + } + break; + case ERR_SOCK_CONNECT_FAILED: { + QMessageBox::warning(this, tr("Network Error"), + tr("Could not connect to the server."), + QMessageBox::Close); + } + break; + case ERR_SOCK_CONNECT_TIMEOUT: { + QMessageBox::warning(this, tr("Network Error"), + tr("Connection timed out.\nPlease check the server address.\n\nIf the server is behind a NAT-Router, make sure port forwarding has been set up on server side."), + QMessageBox::Close); + } + break; + case ERR_SOCK_SELECT_FAILED: { + QMessageBox::warning(this, tr("Network Error"), + tr("Internal network error: \"select\" failed."), + QMessageBox::Close); + } + break; + case ERR_SOCK_SEND_FAILED: { + QMessageBox::warning(this, tr("Network Error"), + tr("Internal network error: \"send\" failed."), + QMessageBox::Close); + } + break; + case ERR_SOCK_RECV_FAILED: // Sometimes windows reports recv failed on close. + case ERR_SOCK_CONN_RESET: { + QMessageBox::warning(this, tr("Network Error"), + tr("Connection was closed by the server."), + QMessageBox::Close); + } + break; + case ERR_SOCK_CONN_EXISTS: { + QMessageBox::warning(this, tr("Network Error"), + tr("Internal network error: Duplicate TCP connection."), + QMessageBox::Close); + } + break; + case ERR_SOCK_INVALID_PACKET: { + QMessageBox::warning(this, tr("Network Error"), + tr("An invalid network packet was received.\nPlease make sure that all players use the same version of PokerTH."), + QMessageBox::Close); + } + break; + case ERR_SOCK_INVALID_STATE: { + QMessageBox::warning(this, tr("Network Error"), + tr("Internal state error.\nPlease make sure that all players use the same version of PokerTH."), + QMessageBox::Close); + } + break; + case ERR_SOCK_INVALID_SERVERLIST_URL: + case ERR_SOCK_TRANSFER_INVALID_URL: { + QMessageBox::warning(this, tr("Network Error"), + tr("Invalid server list URL.\nPlease correct the address in the settings."), + QMessageBox::Close); + } + break; + case ERR_SOCK_OPEN_MD5_FAILED: { + QMessageBox::warning(this, tr("Network Error"), + tr("Could not open the server list MD5 file.\nPlease make sure that the server list URL is correct."), + QMessageBox::Close); + } + break; + case ERR_SOCK_INVALID_SERVERLIST_MD5: { + QMessageBox::warning(this, tr("Network Error"), + tr("Synchronization of the PokerTH internet server list has failed.\nPlease make sure that the server list URL is correct."), + QMessageBox::Close); + } + break; + case ERR_SOCK_INVALID_SERVERLIST_XML: { + QMessageBox::warning(this, tr("Network Error"), + tr("The PokerTH internet server list contains invalid data.\nIf you use a custom server list, please make sure its format is correct."), + QMessageBox::Close); + } + break; + case ERR_SOCK_UNZIP_FAILED: { + QMessageBox::warning(this, tr("Network Error"), + tr("Could not unzip the PokerTH internet server list."), + QMessageBox::Close); + } + break; + case ERR_SOCK_TRANSFER_INIT_FAILED: + case ERR_SOCK_TRANSFER_SELECT_FAILED: + case ERR_SOCK_TRANSFER_FAILED: { + QMessageBox::warning(this, tr("Network Error"), + tr("Could not download the PokerTH internet server list.\nPlease make sure you are directly connected to the internet."), + QMessageBox::Close); + } + break; + case ERR_SOCK_TRANSFER_OPEN_FAILED: { + QMessageBox::warning(this, tr("Network Error"), + tr("Could not open the target file when downloading the server list."), + QMessageBox::Close); + } + break; + case ERR_NET_VERSION_NOT_SUPPORTED: { + QMessageBox msgBox(QMessageBox::Warning, tr("Network Error"), + tr("The PokerTH server does not support this version of the game.
Please go to http://www.pokerth.net and download the latest version."), + QMessageBox::Close, this); + msgBox.setTextFormat(Qt::RichText); + msgBox.exec(); + } + break; + case ERR_NET_SERVER_FULL: { + QMessageBox::warning(this, tr("Network Error"), + tr("Sorry, this server is already full."), + QMessageBox::Close); + } + break; + case ERR_NET_INVALID_PASSWORD: { + QMessageBox::warning(this, tr("Network Error"), + tr("Invalid login.\nPlease check your username and password."), + QMessageBox::Close); + } + break; + case ERR_NET_INVALID_PASSWORD_STR: { + QMessageBox::warning(this, tr("Network Error"), + tr("The password is too long. Please choose another one."), + QMessageBox::Close); + } + break; + case ERR_NET_PLAYER_NAME_IN_USE: { + changeContentDialogImpl dialog(this, myConfig, CHANGE_NICK_ALREADY_IN_USE); + dialog.exec(); + } + break; + case ERR_NET_INVALID_PLAYER_NAME: { + changeContentDialogImpl dialog(this, myConfig, CHANGE_NICK_INVALID); + dialog.exec(); + } + break; + case ERR_NET_INVALID_GAME_NAME: { + QMessageBox::warning(this, tr("Network Error"), + tr("The game name is either too short or too long. Please choose another one."), + QMessageBox::Close); + } + break; + case ERR_NET_UNKNOWN_GAME: { + QMessageBox::warning(this, tr("Network Error"), + tr("The game could not be found."), + QMessageBox::Close); + } + break; + case ERR_NET_INVALID_CHAT_TEXT: { + QMessageBox::warning(this, tr("Network Error"), + tr("The chat text is invalid."), + QMessageBox::Close); + } + break; + case ERR_NET_UNKNOWN_PLAYER_ID: { + QMessageBox::warning(this, tr("Network Error"), + tr("The server referred to an unknown player. Aborting."), + QMessageBox::Close); + } + break; + case ERR_NET_NO_CURRENT_PLAYER: { + QMessageBox::warning(this, tr("Network Error"), + tr("Internal error: The current player could not be found."), + QMessageBox::Close); + } + break; + case ERR_NET_PLAYER_NOT_ACTIVE: { + QMessageBox::warning(this, tr("Network Error"), + tr("Internal error: The current player is not active."), + QMessageBox::Close); + } + break; + case ERR_NET_PLAYER_KICKED: { + mySession->terminateNetworkClient(); + QMessageBox::warning(this, tr("Network Error"), + tr("You were kicked from the server."), + QMessageBox::Close); + } + break; + case ERR_NET_PLAYER_BANNED: { + mySession->terminateNetworkClient(); + QMessageBox::warning(this, tr("Network Error"), + tr("You were temporarily banned from the server."), + QMessageBox::Close); + } + break; + case ERR_NET_PLAYER_BLOCKED: { + mySession->terminateNetworkClient(); + QMessageBox::warning(this, tr("Network Error"), + tr("Your account is blocked indefinitely."), + QMessageBox::Close); + } + break; + case ERR_NET_SESSION_TIMED_OUT: { + mySession->terminateNetworkClient(); + QMessageBox::warning(this, tr("Network Error"), + tr("Your server connection timed out due to inactivity. You are very welcome to reconnect!"), + QMessageBox::Close); + } + break; + case ERR_NET_INVALID_PLAYER_COUNT: { + QMessageBox::warning(this, tr("Network Error"), + tr("The client player count is invalid."), + QMessageBox::Close); + } + break; + case ERR_NET_TOO_MANY_MANUAL_BLINDS: { + QMessageBox::warning(this, tr("Network Error"), + tr("Too many manual blinds were set. Please reconfigure the manual blinds."), + QMessageBox::Close); + } + break; + case ERR_NET_INVALID_AVATAR_FILE: + case ERR_NET_WRONG_AVATAR_SIZE: { + QMessageBox::warning(this, tr("Network Error"), + tr("An invalid avatar file was configured. Please choose a different avatar."), + QMessageBox::Close); + } + break; + case ERR_NET_AVATAR_TOO_LARGE: { + QMessageBox::warning(this, tr("Network Error"), + tr("The selected avatar file is too large. Please choose a different avatar."), + QMessageBox::Close); + } + break; + case ERR_NET_INIT_BLOCKED: { + QMessageBox::warning(this, tr("Network Error"), + tr("You cannot login at this time. Please try again in a few seconds."), + QMessageBox::Close); + } + break; + case ERR_NET_INVALID_REQUEST_ID: { + QMessageBox::warning(this, tr("Network Error"), + tr("An internal avatar error occured. Please report this to an admin in the lobby chat."), + QMessageBox::Close); + } + break; + case ERR_NET_START_TIMEOUT: { + QMessageBox::warning(this, tr("Network Error"), + tr("Could not start game: Synchronization failed."), + QMessageBox::Close); + } + break; + case ERR_NET_SERVER_MAINTENANCE: { + QMessageBox::warning(this, tr("Network Error"), + tr("The server is down for maintenance. Please try again later."), + QMessageBox::Close); + } + break; + default: { + QMessageBox::warning(this, tr("Network Error"), + tr("An internal error occured."), + QMessageBox::Close); + } + } + // close dialogs + myGameLobbyDialog->reject(); + myConnectToServerDialog->reject(); + myStartNetworkGameDialog->reject(); + myGuiInterface->getMyW()->close(); } void startWindowImpl::networkNotification(int notificationId) { - hideTimeoutDialog(); - switch (notificationId) - { - case NTF_NET_JOIN_IP_BLOCKED: - { QMessageBox::warning(this, tr("Network Notification"), - tr("You cannot join this game, because another player in that game has your network address."), - QMessageBox::Close); } - break; - case NTF_NET_REMOVED_START_FAILED: - { QMessageBox::warning(this, tr("Network Notification"), - tr("Your connection to the server is very slow, the game had to start without you."), - QMessageBox::Close); } - break; - case NTF_NET_REMOVED_KICKED: - { QMessageBox::warning(this, tr("Network Notification"), - tr("You were kicked from the game."), - QMessageBox::Close); } - break; - case NTF_NET_REMOVED_GAME_FULL: - case NTF_NET_JOIN_GAME_FULL: - { QMessageBox::warning(this, tr("Network Notification"), - tr("Sorry, this game is already full."), - QMessageBox::Close); } - break; - case NTF_NET_REMOVED_ALREADY_RUNNING: - case NTF_NET_JOIN_ALREADY_RUNNING: - { QMessageBox::warning(this, tr("Network Notification"), - tr("Unable to join - the server has already started the game."), - QMessageBox::Close); } - break; - case NTF_NET_JOIN_NOT_INVITED: - { QMessageBox::warning(this, tr("Network Notification"), - tr("This game is of type invite-only. You cannot join this game without being invited."), - QMessageBox::Close); } - break; - case NTF_NET_JOIN_GAME_NAME_IN_USE: - { changeContentDialogImpl dialog(this, myConfig, CHANGE_INET_GAME_NAME_IN_USE); - dialog.exec(); - if(dialog.result() == QDialog::Accepted) { - myGameLobbyDialog->pushButton_CreateGame->click(); - } - } - break; - case NTF_NET_JOIN_GAME_BAD_NAME: - { changeContentDialogImpl dialog(this, myConfig, CHANGE_INET_BAD_GAME_NAME); - dialog.exec(); - if(dialog.result() == QDialog::Accepted) { - myGameLobbyDialog->pushButton_CreateGame->click(); - } - } - break; - case NTF_NET_REMOVED_TIMEOUT: - { QMessageBox::warning(this, tr("Network Notification"), - tr("Your admin state timed out due to inactivity. Feel free to create a new game!"), - QMessageBox::Close); } - break; - case NTF_NET_JOIN_INVALID_PASSWORD: - { QMessageBox::warning(this, tr("Network Notification"), - tr("Invalid password when joining the game.\nPlease reenter the password and try again."), - QMessageBox::Close); } - break; - case NTF_NET_JOIN_GUEST_FORBIDDEN: - { QMessageBox::warning(this, tr("Network Notification"), - tr("You cannot join this type of game as guest."), - QMessageBox::Close); } - break; - case NTF_NET_JOIN_INVALID_SETTINGS: - { QMessageBox::warning(this, tr("Network Notification"), - tr("The settings are invalid for this type of game."), - QMessageBox::Close); } - break; - case NTF_NET_NEW_RELEASE_AVAILABLE: - { - msgBoxOutdatedVersion.setIcon(QMessageBox::Information); - msgBoxOutdatedVersion.setWindowTitle(tr("Network Notification")); - msgBoxOutdatedVersion.setText(tr("A new release of PokerTH is available.
Please go to http://www.pokerth.net and download the latest version.")); - msgBoxOutdatedVersion.setTextFormat(Qt::RichText); - msgBoxOutdatedVersion.setStandardButtons(QMessageBox::Ok); - msgBoxOutdatedVersion.setDefaultButton(QMessageBox::Ok); + hideTimeoutDialog(); + switch (notificationId) { + case NTF_NET_JOIN_IP_BLOCKED: { + QMessageBox::warning(this, tr("Network Notification"), + tr("You cannot join this game, because another player in that game has your network address."), + QMessageBox::Close); + } + break; + case NTF_NET_REMOVED_START_FAILED: { + QMessageBox::warning(this, tr("Network Notification"), + tr("Your connection to the server is very slow, the game had to start without you."), + QMessageBox::Close); + } + break; + case NTF_NET_REMOVED_KICKED: { + QMessageBox::warning(this, tr("Network Notification"), + tr("You were kicked from the game."), + QMessageBox::Close); + } + break; + case NTF_NET_REMOVED_GAME_FULL: + case NTF_NET_JOIN_GAME_FULL: { + QMessageBox::warning(this, tr("Network Notification"), + tr("Sorry, this game is already full."), + QMessageBox::Close); + } + break; + case NTF_NET_REMOVED_ALREADY_RUNNING: + case NTF_NET_JOIN_ALREADY_RUNNING: { + QMessageBox::warning(this, tr("Network Notification"), + tr("Unable to join - the server has already started the game."), + QMessageBox::Close); + } + break; + case NTF_NET_JOIN_NOT_INVITED: { + QMessageBox::warning(this, tr("Network Notification"), + tr("This game is of type invite-only. You cannot join this game without being invited."), + QMessageBox::Close); + } + break; + case NTF_NET_JOIN_GAME_NAME_IN_USE: { + changeContentDialogImpl dialog(this, myConfig, CHANGE_INET_GAME_NAME_IN_USE); + dialog.exec(); + if(dialog.result() == QDialog::Accepted) { + myGameLobbyDialog->pushButton_CreateGame->click(); + } + } + break; + case NTF_NET_JOIN_GAME_BAD_NAME: { + changeContentDialogImpl dialog(this, myConfig, CHANGE_INET_BAD_GAME_NAME); + dialog.exec(); + if(dialog.result() == QDialog::Accepted) { + myGameLobbyDialog->pushButton_CreateGame->click(); + } + } + break; + case NTF_NET_REMOVED_TIMEOUT: { + QMessageBox::warning(this, tr("Network Notification"), + tr("Your admin state timed out due to inactivity. Feel free to create a new game!"), + QMessageBox::Close); + } + break; + case NTF_NET_JOIN_INVALID_PASSWORD: { + QMessageBox::warning(this, tr("Network Notification"), + tr("Invalid password when joining the game.\nPlease reenter the password and try again."), + QMessageBox::Close); + } + break; + case NTF_NET_JOIN_GUEST_FORBIDDEN: { + QMessageBox::warning(this, tr("Network Notification"), + tr("You cannot join this type of game as guest."), + QMessageBox::Close); + } + break; + case NTF_NET_JOIN_INVALID_SETTINGS: { + QMessageBox::warning(this, tr("Network Notification"), + tr("The settings are invalid for this type of game."), + QMessageBox::Close); + } + break; + case NTF_NET_NEW_RELEASE_AVAILABLE: { + msgBoxOutdatedVersion.setIcon(QMessageBox::Information); + msgBoxOutdatedVersion.setWindowTitle(tr("Network Notification")); + msgBoxOutdatedVersion.setText(tr("A new release of PokerTH is available.
Please go to http://www.pokerth.net and download the latest version.")); + msgBoxOutdatedVersion.setTextFormat(Qt::RichText); + msgBoxOutdatedVersion.setStandardButtons(QMessageBox::Ok); + msgBoxOutdatedVersion.setDefaultButton(QMessageBox::Ok); - msgBoxOutdatedVersionActive = true; - } - break; - case NTF_NET_OUTDATED_BETA: - { - msgBoxOutdatedVersion.setIcon(QMessageBox::Information); - msgBoxOutdatedVersion.setWindowTitle(tr("Network Notification")); - msgBoxOutdatedVersion.setText(tr("This beta release of PokerTH is outdated.
Please go to http://www.pokerth.net and download the latest version.")); - msgBoxOutdatedVersion.setTextFormat(Qt::RichText); - msgBoxOutdatedVersion.setStandardButtons(QMessageBox::Ok); - msgBoxOutdatedVersion.setDefaultButton(QMessageBox::Ok); + msgBoxOutdatedVersionActive = true; + } + break; + case NTF_NET_OUTDATED_BETA: { + msgBoxOutdatedVersion.setIcon(QMessageBox::Information); + msgBoxOutdatedVersion.setWindowTitle(tr("Network Notification")); + msgBoxOutdatedVersion.setText(tr("This beta release of PokerTH is outdated.
Please go to http://www.pokerth.net and download the latest version.")); + msgBoxOutdatedVersion.setTextFormat(Qt::RichText); + msgBoxOutdatedVersion.setStandardButtons(QMessageBox::Ok); + msgBoxOutdatedVersion.setDefaultButton(QMessageBox::Ok); - msgBoxOutdatedVersionActive = true; - } - break; - } + msgBoxOutdatedVersionActive = true; + } + break; + } } void startWindowImpl::networkMessage(QString msg) { - QMessageBox msgBox(QMessageBox::Information, tr("Server Message"), - msg, QMessageBox::Close, this); - msgBox.setTextFormat(Qt::RichText); - msgBox.exec(); + QMessageBox msgBox(QMessageBox::Information, tr("Server Message"), + msg, QMessageBox::Close, this); + msgBox.setTextFormat(Qt::RichText); + msgBox.exec(); } void startWindowImpl::networkMessage(unsigned msgId) { - QString msgText; + QString msgText; - switch(msgId) { + switch(msgId) { - case MSG_NET_AVATAR_REPORT_ACCEPTED: - { msgText = tr("The avatar report was accepted by the server. Thank you."); } - break; - case MSG_NET_AVATAR_REPORT_DUP: - { msgText = tr("This avatar was already reported by another player."); } - break; - case MSG_NET_AVATAR_REPORT_REJECTED: - { msgText = tr("An error occurred while reporting the avatar."); } - break; - default:; - break; - } + case MSG_NET_AVATAR_REPORT_ACCEPTED: { + msgText = tr("The avatar report was accepted by the server. Thank you."); + } + break; + case MSG_NET_AVATAR_REPORT_DUP: { + msgText = tr("This avatar was already reported by another player."); + } + break; + case MSG_NET_AVATAR_REPORT_REJECTED: { + msgText = tr("An error occurred while reporting the avatar."); + } + break; + default: + ; + break; + } - QMessageBox msgBox(QMessageBox::Information, tr("Server Message"), - msgText, QMessageBox::Close, this); + QMessageBox msgBox(QMessageBox::Information, tr("Server Message"), + msgText, QMessageBox::Close, this); // msgBox.setTextFormat(Qt::RichText); - msgBox.exec(); + msgBox.exec(); } void startWindowImpl::networkStart(boost::shared_ptr game) { - mySession->startClientGame(game); + mySession->startClientGame(game); - //send playerNicksList to chat for nick-autocompletition - myGuiInterface->getMyW()->getMyChat()->setPlayerNicksList(getPlayerNicksList()); + //send playerNicksList to chat for nick-autocompletition + myGuiInterface->getMyW()->getMyChat()->setPlayerNicksList(getPlayerNicksList()); } -QStringList startWindowImpl::getPlayerNicksList() { +QStringList startWindowImpl::getPlayerNicksList() +{ - QStringList list; - PlayerListConstIterator it_c; - PlayerList seatList = mySession->getCurrentGame()->getSeatsList(); + QStringList list; + PlayerListConstIterator it_c; + PlayerList seatList = mySession->getCurrentGame()->getSeatsList(); for (it_c=seatList->begin(); it_c!=seatList->end(); ++it_c) { - list << QString::fromUtf8((*it_c)->getMyName().c_str()); - } + list << QString::fromUtf8((*it_c)->getMyName().c_str()); + } - return list; + return list; } QString startWindowImpl::checkForFirstStartAfterUpdated() { - if(myConfig->getConfigState() == OLD) { + if(myConfig->getConfigState() == OLD) { - if(POKERTH_VERSION_MAJOR == 0 && POKERTH_VERSION_MINOR == 80) { - //version 0.8 HACK - //to avoid old PokerTH distributed styles pathes in settings which leads to error message like "outdated" prepare settings dialog (fallback will correct this issue) and save settings - mySettingsDialog->prepareDialog(); - mySettingsDialog->isAccepted(); - myGuiInterface->getMyW()->applySettings(mySettingsDialog); - } - return QString("Update old config to version %1").arg(QString::number(POKERTH_VERSION_MAJOR)+"."+QString::number(POKERTH_VERSION_MINOR)); - } + if(POKERTH_VERSION_MAJOR == 0 && POKERTH_VERSION_MINOR == 80) { + //version 0.8 HACK + //to avoid old PokerTH distributed styles pathes in settings which leads to error message like "outdated" prepare settings dialog (fallback will correct this issue) and save settings + mySettingsDialog->prepareDialog(); + mySettingsDialog->isAccepted(); + myGuiInterface->getMyW()->applySettings(mySettingsDialog); + } + return QString("Update old config to version %1").arg(QString::number(POKERTH_VERSION_MAJOR)+"."+QString::number(POKERTH_VERSION_MINOR)); + } - return QString(); + return QString(); } bool startWindowImpl::eventFilter(QObject *obj, QEvent *event) { - if (event->type() == QEvent::Close) { - event->ignore(); + if (event->type() == QEvent::Close) { + event->ignore(); // mySession->getMyLog()->closeLogDbAtExit(); - return QMainWindow::eventFilter(obj, event); - } - else { - // pass the event on to the parent class - return QMainWindow::eventFilter(obj, event); - } + return QMainWindow::eventFilter(obj, event); + } else { + // pass the event on to the parent class + return QMainWindow::eventFilter(obj, event); + } } diff --git a/src/gui/qt/startwindow/startwindowimpl.h b/src/gui/qt/startwindow/startwindowimpl.h index 97d44613..ed4a54b8 100644 --- a/src/gui/qt/startwindow/startwindowimpl.h +++ b/src/gui/qt/startwindow/startwindowimpl.h @@ -47,115 +47,125 @@ class timeoutMsgBoxImpl; class serverListDialogImpl; class internetGameLoginDialogImpl; -class startWindowImpl: public QMainWindow, public Ui::startWindow { - Q_OBJECT +class startWindowImpl: public QMainWindow, public Ui::startWindow +{ + Q_OBJECT public: - startWindowImpl(ConfigFile *c =0); - ~startWindowImpl(); + startWindowImpl(ConfigFile *c =0); + ~startWindowImpl(); - void setSession(boost::shared_ptr session) { mySession = session; } - boost::shared_ptr getSession() { assert(mySession.get()); return mySession; } - boost::shared_ptr< GuiInterface > getMyServerGuiInterface() const { return myServerGuiInterface; } - connectToServerDialogImpl* getMyConnectToServerDialog() const { return myConnectToServerDialog; } + void setSession(boost::shared_ptr session) { + mySession = session; + } + boost::shared_ptr getSession() { + assert(mySession.get()); + return mySession; + } + boost::shared_ptr< GuiInterface > getMyServerGuiInterface() const { + return myServerGuiInterface; + } + connectToServerDialogImpl* getMyConnectToServerDialog() const { + return myConnectToServerDialog; + } - // void keyPressEvent( QKeyEvent *); - bool eventFilter(QObject *obj, QEvent *event); + // void keyPressEvent( QKeyEvent *); + bool eventFilter(QObject *obj, QEvent *event); -signals: - void signalShowClientDialog(); +signals: + void signalShowClientDialog(); - void signalNetClientConnect(int actionID); - void signalNetClientServerListShow(); - void signalNetClientServerListClear(); - void signalNetClientServerListAdd(unsigned serverId); - void signalNetClientLoginShow(); - void signalNetClientGameInfo(int actionID); - void signalNetClientError(int errorID, int osErrorID); - void signalNetClientNotification(int notificationId); - void signalNetClientStatsUpdate(ServerStats stats); - void signalNetClientShowTimeoutDialog(int, unsigned); - void signalNetClientRemovedFromGame(int notificationId); - void signalNetServerError(int errorID, int osErrorID); - void signalNetClientSelfJoined(unsigned playerId, QString playerName, bool isGameAdmin); - void signalNetClientPlayerJoined(unsigned playerId, QString playerName, bool isGameAdmin); - void signalNetClientPlayerChanged(unsigned playerId, QString newPlayerName); - void signalNetClientPlayerLeft(unsigned playerId, QString playerName); - void signalNetClientNewGameAdmin(unsigned playerId, QString playerName); - void signalNetClientGameListNew(unsigned gameId); - void signalNetClientGameListRemove(unsigned gameId); - void signalNetClientGameListUpdateMode(unsigned gameId, int mode); - void signalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId); - void signalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId); - void signalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId); - void signalNetClientGameStart(boost::shared_ptr game); - void signalNetClientGameChatMsg(QString nickName, QString msg); - void signalNetClientLobbyChatMsg(QString nickName, QString msg); - void signalNetClientMsgBox(QString msg); - void signalNetClientMsgBox(unsigned msgId); + void signalNetClientConnect(int actionID); + void signalNetClientServerListShow(); + void signalNetClientServerListClear(); + void signalNetClientServerListAdd(unsigned serverId); + void signalNetClientLoginShow(); + void signalNetClientGameInfo(int actionID); + void signalNetClientError(int errorID, int osErrorID); + void signalNetClientNotification(int notificationId); + void signalNetClientStatsUpdate(ServerStats stats); + void signalNetClientShowTimeoutDialog(int, unsigned); + void signalNetClientRemovedFromGame(int notificationId); + void signalNetServerError(int errorID, int osErrorID); + void signalNetClientSelfJoined(unsigned playerId, QString playerName, bool isGameAdmin); + void signalNetClientPlayerJoined(unsigned playerId, QString playerName, bool isGameAdmin); + void signalNetClientPlayerChanged(unsigned playerId, QString newPlayerName); + void signalNetClientPlayerLeft(unsigned playerId, QString playerName); + void signalNetClientNewGameAdmin(unsigned playerId, QString playerName); + void signalNetClientGameListNew(unsigned gameId); + void signalNetClientGameListRemove(unsigned gameId); + void signalNetClientGameListUpdateMode(unsigned gameId, int mode); + void signalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId); + void signalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId); + void signalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId); + void signalNetClientGameStart(boost::shared_ptr game); + void signalNetClientGameChatMsg(QString nickName, QString msg); + void signalNetClientLobbyChatMsg(QString nickName, QString msg); + void signalNetClientMsgBox(QString msg); + void signalNetClientMsgBox(unsigned msgId); - void signalLobbyPlayerJoined(unsigned playerId, QString nickName); - void signalLobbyPlayerKicked(QString nickName, QString byWhom, QString reason); - void signalLobbyPlayerLeft(unsigned playerId); + void signalLobbyPlayerJoined(unsigned playerId, QString nickName); + void signalLobbyPlayerKicked(QString nickName, QString byWhom, QString reason); + void signalLobbyPlayerLeft(unsigned playerId); - void signalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom); - void signalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); - void signalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); + void signalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom); + void signalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom); + void signalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason); -public slots: +public slots: - void callAboutPokerthDialog(); - void callSettingsDialog(); - void callNewGameDialog(); - void callGameLobbyDialog(); - void callCreateNetworkGameDialog(); - void callJoinNetworkGameDialog(); - void showLobbyDialog(); - void callInternetGameLoginDialog(); - void joinGameLobby(); - void showClientDialog(); - void showNetworkStartDialog(); + void callAboutPokerthDialog(); + void callSettingsDialog(); + void callNewGameDialog(); + void callGameLobbyDialog(); + void callCreateNetworkGameDialog(); + void callJoinNetworkGameDialog(); + void showLobbyDialog(); + void callInternetGameLoginDialog(); + void joinGameLobby(); + void showClientDialog(); + void showNetworkStartDialog(); - void startNewLocalGame(newGameDialogImpl* =0); + void startNewLocalGame(newGameDialogImpl* =0); - void showTimeoutDialog(int msgID, unsigned duration); - void hideTimeoutDialog(); + void showTimeoutDialog(int msgID, unsigned duration); + void hideTimeoutDialog(); - void networkError(int, int); - void networkNotification(int); - void networkMessage(QString); - void networkMessage(unsigned); + void networkError(int, int); + void networkNotification(int); + void networkMessage(QString); + void networkMessage(unsigned); - void networkStart(boost::shared_ptr game); - QStringList getPlayerNicksList(); + void networkStart(boost::shared_ptr game); + QStringList getPlayerNicksList(); - QString checkForFirstStartAfterUpdated(); + QString checkForFirstStartAfterUpdated(); private: - ConfigFile *myConfig; + ConfigFile *myConfig; - boost::shared_ptr myGuiInterface; - boost::shared_ptr mySession; - boost::shared_ptr myServerGuiInterface; + boost::shared_ptr myGuiInterface; + boost::shared_ptr mySession; + boost::shared_ptr myServerGuiInterface; - // Dialogs - aboutPokerthImpl *myAboutPokerthDialog; - newGameDialogImpl *myNewGameDialog; - settingsDialogImpl *mySettingsDialog; - selectAvatarDialogImpl *mySelectAvatarDialog; - joinNetworkGameDialogImpl *myJoinNetworkGameDialog; - connectToServerDialogImpl *myConnectToServerDialog; - startNetworkGameDialogImpl *myStartNetworkGameDialog; - createNetworkGameDialogImpl *myCreateNetworkGameDialog; - gameLobbyDialogImpl *myGameLobbyDialog; - timeoutMsgBoxImpl *myTimeoutDialog; - startWindowImpl *myStartWindow; - serverListDialogImpl *myServerListDialog; - internetGameLoginDialogImpl *myInternetGameLoginDialog; + // Dialogs + aboutPokerthImpl *myAboutPokerthDialog; + newGameDialogImpl *myNewGameDialog; + settingsDialogImpl *mySettingsDialog; + selectAvatarDialogImpl *mySelectAvatarDialog; + joinNetworkGameDialogImpl *myJoinNetworkGameDialog; + connectToServerDialogImpl *myConnectToServerDialog; + startNetworkGameDialogImpl *myStartNetworkGameDialog; + createNetworkGameDialogImpl *myCreateNetworkGameDialog; + gameLobbyDialogImpl *myGameLobbyDialog; + timeoutMsgBoxImpl *myTimeoutDialog; + startWindowImpl *myStartWindow; + serverListDialogImpl *myServerListDialog; + internetGameLoginDialogImpl *myInternetGameLoginDialog; - QMessageBox msgBoxOutdatedVersion; - bool msgBoxOutdatedVersionActive; + QMessageBox msgBoxOutdatedVersion; + bool msgBoxOutdatedVersionActive; - friend class GuiWrapper; + friend class GuiWrapper; }; #endif diff --git a/src/gui/qt/styles/carddeckstylereader.cpp b/src/gui/qt/styles/carddeckstylereader.cpp index 311a3baa..d9eafbe7 100644 --- a/src/gui/qt/styles/carddeckstylereader.cpp +++ b/src/gui/qt/styles/carddeckstylereader.cpp @@ -28,7 +28,7 @@ using namespace std; CardDeckStyleReader::CardDeckStyleReader(ConfigFile *c, QWidget *w) : myConfig(c), myW(w), fallBack(0), loadedSuccessfull(0) { - + } @@ -36,14 +36,14 @@ CardDeckStyleReader::~CardDeckStyleReader() { } -void CardDeckStyleReader::readStyleFile(QString file) { +void CardDeckStyleReader::readStyleFile(QString file) +{ //if style file failed --> default style fallback - if(QFile(file).exists()) { + if(QFile(file).exists()) { currentFileName = file; - } - else { - currentFileName = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default/defaultdeckstyle.xml"; + } else { + currentFileName = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/cards/default/defaultdeckstyle.xml"; fallBack = 1; } @@ -54,106 +54,121 @@ void CardDeckStyleReader::readStyleFile(QString file) { QFileInfo info(currentFileName); currentDir = info.absolutePath()+"/"; - //start reading the file and fill vars + //start reading the file and fill vars string tempString1(""); - TiXmlDocument doc; + TiXmlDocument doc; doc.Parse(fileContent.constData()); if(doc.RootElement()) { - TiXmlHandle docHandle( &doc ); + TiXmlHandle docHandle( &doc ); - TiXmlElement *GameTableElement = docHandle.FirstChild( "PokerTH" ).FirstChild( "TableStyle" ).ToElement(); - if(GameTableElement) { - QMessageBox::warning(myW, tr("Card Deck Style Error"), - tr("A game table style was selected instead of a card deck style.\nPlease select a card deck style and try again!"), - QMessageBox::Ok); - } - else { + TiXmlElement *GameTableElement = docHandle.FirstChild( "PokerTH" ).FirstChild( "TableStyle" ).ToElement(); + if(GameTableElement) { + QMessageBox::warning(myW, tr("Card Deck Style Error"), + tr("A game table style was selected instead of a card deck style.\nPlease select a card deck style and try again!"), + QMessageBox::Ok); + } else { - TiXmlElement* itemsList = docHandle.FirstChild( "PokerTH" ).FirstChild( "CardDeck" ).FirstChild().ToElement(); - for( ; itemsList; itemsList=itemsList->NextSiblingElement()) { - const char *tmpStr1 = itemsList->Attribute("value"); - if (tmpStr1) { - tempString1 = tmpStr1; + TiXmlElement* itemsList = docHandle.FirstChild( "PokerTH" ).FirstChild( "CardDeck" ).FirstChild().ToElement(); + for( ; itemsList; itemsList=itemsList->NextSiblingElement()) { + const char *tmpStr1 = itemsList->Attribute("value"); + if (tmpStr1) { + tempString1 = tmpStr1; - if(itemsList->ValueStr() == "StyleDescription") { StyleDescription = QString::fromUtf8(tempString1.c_str()); } - else if(itemsList->ValueStr() == "StyleMaintainerName") { StyleMaintainerName = QString::fromUtf8(tempString1.c_str()); } - else if(itemsList->ValueStr() == "StyleMaintainerEMail") { StyleMaintainerEMail = QString::fromUtf8(tempString1.c_str()); } - else if(itemsList->ValueStr() == "StyleCreateDate") { StyleCreateDate = QString::fromUtf8(tempString1.c_str()); } - else if(itemsList->ValueStr() == "PokerTHStyleFileVersion") { PokerTHStyleFileVersion = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "Preview") { Preview = currentDir+QString::fromUtf8(tempString1.c_str()); } - } - } - //check if style items are left and show warning - leftItems.clear(); + if(itemsList->ValueStr() == "StyleDescription") { + StyleDescription = QString::fromUtf8(tempString1.c_str()); + } else if(itemsList->ValueStr() == "StyleMaintainerName") { + StyleMaintainerName = QString::fromUtf8(tempString1.c_str()); + } else if(itemsList->ValueStr() == "StyleMaintainerEMail") { + StyleMaintainerEMail = QString::fromUtf8(tempString1.c_str()); + } else if(itemsList->ValueStr() == "StyleCreateDate") { + StyleCreateDate = QString::fromUtf8(tempString1.c_str()); + } else if(itemsList->ValueStr() == "PokerTHStyleFileVersion") { + PokerTHStyleFileVersion = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "Preview") { + Preview = currentDir+QString::fromUtf8(tempString1.c_str()); + } + } + } + //check if style items are left and show warning + leftItems.clear(); - if(StyleDescription == "") { leftItems << "StyleDescription"; } - if(StyleMaintainerName == "") { leftItems << "StyleMaintainerName"; } - if(StyleMaintainerEMail == "") { leftItems << "StyleMaintainerEMail"; } - if(StyleCreateDate == "") { leftItems << "StyleCreateDate"; } - if(PokerTHStyleFileVersion == "") { leftItems << "PokerTHStyleFileVersion"; } + if(StyleDescription == "") { + leftItems << "StyleDescription"; + } + if(StyleMaintainerName == "") { + leftItems << "StyleMaintainerName"; + } + if(StyleMaintainerEMail == "") { + leftItems << "StyleMaintainerEMail"; + } + if(StyleCreateDate == "") { + leftItems << "StyleCreateDate"; + } + if(PokerTHStyleFileVersion == "") { + leftItems << "PokerTHStyleFileVersion"; + } - //check if all files are there - cardsLeft.clear(); - int i; - for(i=0; i<52; i++) { - QString cardString(QString::number(i)+".png"); - if(!QDir(currentDir).exists(cardString)) { - cardsLeft << cardString; - } - } - if(!QDir(currentDir).exists("flipside.png")) { - cardsLeft << "flipside.png"; - } + //check if all files are there + cardsLeft.clear(); + int i; + for(i=0; i<52; i++) { + QString cardString(QString::number(i)+".png"); + if(!QDir(currentDir).exists(cardString)) { + cardsLeft << cardString; + } + } + if(!QDir(currentDir).exists("flipside.png")) { + cardsLeft << "flipside.png"; + } - // set loadedSuccessfull TRUE if everything works - if(leftItems.isEmpty() && cardsLeft.isEmpty() && PokerTHStyleFileVersion != "" && PokerTHStyleFileVersion.toInt() == POKERTH_CD_STYLE_FILE_VERSION) - loadedSuccessfull = 1; - else - loadedSuccessfull = 0; + // set loadedSuccessfull TRUE if everything works + if(leftItems.isEmpty() && cardsLeft.isEmpty() && PokerTHStyleFileVersion != "" && PokerTHStyleFileVersion.toInt() == POKERTH_CD_STYLE_FILE_VERSION) + loadedSuccessfull = 1; + else + loadedSuccessfull = 0; - if(!leftItems.isEmpty() && myW != 0) showLeftItemsErrorMessage(StyleDescription, leftItems, StyleMaintainerEMail); - else { - if(!cardsLeft.isEmpty() && myW != 0) showCardsLeftErrorMessage(StyleDescription, cardsLeft, StyleMaintainerEMail); - //check for style file version - if(PokerTHStyleFileVersion != "" && PokerTHStyleFileVersion.toInt() != POKERTH_CD_STYLE_FILE_VERSION) { - QString EMail; - if(StyleMaintainerEMail != "NULL") EMail = StyleMaintainerEMail; - QMessageBox::warning(myW, tr("Card Deck Style Error"), - tr("Selected card deck style \"%1\" seems to be outdated. \n The current PokerTH card deck style version is \"%2\", but this style has version \"%3\" set. \n\nPlease contact the card deck style builder %4.").arg(StyleDescription).arg(POKERTH_CD_STYLE_FILE_VERSION).arg(PokerTHStyleFileVersion).arg(EMail), - QMessageBox::Ok); - } - } - } - } - else { - loadedSuccessfull = 0; - QMessageBox::warning(myW, tr("Card Deck Style Error"), - tr("Cannot load card deck style file: %1 \n\nPlease check the style file or choose another style!").arg(currentFileName), - QMessageBox::Ok); - } + if(!leftItems.isEmpty() && myW != 0) showLeftItemsErrorMessage(StyleDescription, leftItems, StyleMaintainerEMail); + else { + if(!cardsLeft.isEmpty() && myW != 0) showCardsLeftErrorMessage(StyleDescription, cardsLeft, StyleMaintainerEMail); + //check for style file version + if(PokerTHStyleFileVersion != "" && PokerTHStyleFileVersion.toInt() != POKERTH_CD_STYLE_FILE_VERSION) { + QString EMail; + if(StyleMaintainerEMail != "NULL") EMail = StyleMaintainerEMail; + QMessageBox::warning(myW, tr("Card Deck Style Error"), + tr("Selected card deck style \"%1\" seems to be outdated. \n The current PokerTH card deck style version is \"%2\", but this style has version \"%3\" set. \n\nPlease contact the card deck style builder %4.").arg(StyleDescription).arg(POKERTH_CD_STYLE_FILE_VERSION).arg(PokerTHStyleFileVersion).arg(EMail), + QMessageBox::Ok); + } + } + } + } else { + loadedSuccessfull = 0; + QMessageBox::warning(myW, tr("Card Deck Style Error"), + tr("Cannot load card deck style file: %1 \n\nPlease check the style file or choose another style!").arg(currentFileName), + QMessageBox::Ok); + } } void CardDeckStyleReader::showLeftItemsErrorMessage(QString style, QStringList failedItems, QString email) { QString items = failedItems.join(", "); - QString EMail; - if(email != "NULL") EMail = email; + QString EMail; + if(email != "NULL") EMail = email; QMessageBox::warning(myW, tr("Card Deck Style Error"), - tr("Selected card deck style \"%1\" seems to be incomplete or defective. \n\nThe value(s) of \"%2\" is/are missing. \n\nPlease contact the card deck style builder %3.").arg(style).arg(items).arg(EMail), - QMessageBox::Ok); + tr("Selected card deck style \"%1\" seems to be incomplete or defective. \n\nThe value(s) of \"%2\" is/are missing. \n\nPlease contact the card deck style builder %3.").arg(style).arg(items).arg(EMail), + QMessageBox::Ok); } void CardDeckStyleReader::showCardsLeftErrorMessage(QString style, QStringList failedItems, QString email) { QString items = failedItems.join(", "); - QString EMail; - if(email != "NULL") EMail = email; + QString EMail; + if(email != "NULL") EMail = email; QMessageBox::warning(myW, tr("Card Deck Style Error"), - tr("Selected card deck style \"%1\" seems to be incomplete or defective. \nThe card picture(s) \"%2\" is/are not available. \n\nPlease contact the card deck style builder %3.").arg(style).arg(items).arg(EMail), - QMessageBox::Ok); + tr("Selected card deck style \"%1\" seems to be incomplete or defective. \nThe card picture(s) \"%2\" is/are not available. \n\nPlease contact the card deck style builder %3.").arg(style).arg(items).arg(EMail), + QMessageBox::Ok); } diff --git a/src/gui/qt/styles/carddeckstylereader.h b/src/gui/qt/styles/carddeckstylereader.h index 05fc2670..c705142b 100644 --- a/src/gui/qt/styles/carddeckstylereader.h +++ b/src/gui/qt/styles/carddeckstylereader.h @@ -29,39 +29,58 @@ #define POKERTH_CD_STYLE_FILE_VERSION 1 enum CdStyleState { - CD_STYLE_OK = 0, - CD_STYLE_OUTDATED, - CD_STYLE_FIELDS_EMPTY, - CD_STYLE_PICTURES_MISSING, + CD_STYLE_OK = 0, + CD_STYLE_OUTDATED, + CD_STYLE_FIELDS_EMPTY, + CD_STYLE_PICTURES_MISSING, }; -class CardDeckStyleReader : public QObject { -Q_OBJECT +class CardDeckStyleReader : public QObject +{ + Q_OBJECT public: - CardDeckStyleReader(ConfigFile *c, QWidget *w ); + CardDeckStyleReader(ConfigFile *c, QWidget *w ); ~CardDeckStyleReader(); - + void readStyleFile(QString); - QString getStyleDescription() const { return StyleDescription; } - QString getStyleMaintainerName() const { return StyleMaintainerName; } - QString getStyleMaintainerEMail() const { return StyleMaintainerEMail; } - QString getStyleCreateDate() const { return StyleCreateDate; } + QString getStyleDescription() const { + return StyleDescription; + } + QString getStyleMaintainerName() const { + return StyleMaintainerName; + } + QString getStyleMaintainerEMail() const { + return StyleMaintainerEMail; + } + QString getStyleCreateDate() const { + return StyleCreateDate; + } - QString getCurrentFileName() const { return currentFileName; } - QString getCurrentDir() const { return currentDir; } - - QString getPreview() const { return Preview; } + QString getCurrentFileName() const { + return currentFileName; + } + QString getCurrentDir() const { + return currentDir; + } - bool getFallBack() const { return fallBack; } - bool getLoadedSuccessfull() const { return loadedSuccessfull; } + QString getPreview() const { + return Preview; + } + + bool getFallBack() const { + return fallBack; + } + bool getLoadedSuccessfull() const { + return loadedSuccessfull; + } void showLeftItemsErrorMessage(QString, QStringList, QString); void showCardsLeftErrorMessage(QString, QStringList, QString); private: - QString StyleDescription; + QString StyleDescription; QString StyleMaintainerName; QString StyleMaintainerEMail; QString StyleCreateDate; @@ -76,10 +95,10 @@ private: QStringList leftItems; ConfigFile *myConfig; - QWidget *myW; + QWidget *myW; bool fallBack; - bool loadedSuccessfull; + bool loadedSuccessfull; }; #endif diff --git a/src/gui/qt/styles/gametablestylereader.cpp b/src/gui/qt/styles/gametablestylereader.cpp index 1e0b4ce9..4224f3b0 100644 --- a/src/gui/qt/styles/gametablestylereader.cpp +++ b/src/gui/qt/styles/gametablestylereader.cpp @@ -23,45 +23,45 @@ using namespace std; GameTableStyleReader::GameTableStyleReader(ConfigFile *c, QWidget *w) -: myConfig(c), myW(w), fallBack(0), loadedSuccessfull(0), myState(GT_STYLE_UNDEFINED) + : myConfig(c), myW(w), fallBack(0), loadedSuccessfull(0), myState(GT_STYLE_UNDEFINED) { - //set fonts and font sizes + //set fonts and font sizes #ifdef _WIN32 - font1String = "font-family: \"Arial\";"; - font2String = "font-family: \"Nimbus Sans L\";"; - cashFontSize = "11"; - setLabelFontSize = "11"; - playerNameLabelFontSize = "11"; - smallBoardFontSize = "13"; - bigBoardFontSize = "18"; - humanPlayerButtonFontSize = "13"; - betValueFontSize = "11"; + font1String = "font-family: \"Arial\";"; + font2String = "font-family: \"Nimbus Sans L\";"; + cashFontSize = "11"; + setLabelFontSize = "11"; + playerNameLabelFontSize = "11"; + smallBoardFontSize = "13"; + bigBoardFontSize = "18"; + humanPlayerButtonFontSize = "13"; + betValueFontSize = "11"; - tabBarPaddingTop = "2"; - tabBarPaddingSide = "10"; -#else -#ifdef __APPLE__ - font1String = "font-family: \"Lucida Grande\";"; - font2String = "font-family: \"Lucida Grande\";"; - - tabBarPaddingTop = "1"; - tabBarPaddingSide = "9"; + tabBarPaddingTop = "2"; + tabBarPaddingSide = "10"; #else - font1String = "font-family: \"Nimbus Sans L\";"; - font2String = "font-family: \"Bitstream Vera Sans\";"; +#ifdef __APPLE__ + font1String = "font-family: \"Lucida Grande\";"; + font2String = "font-family: \"Lucida Grande\";"; - tabBarPaddingTop = "0"; - tabBarPaddingSide = "9"; + tabBarPaddingTop = "1"; + tabBarPaddingSide = "9"; +#else + font1String = "font-family: \"Nimbus Sans L\";"; + font2String = "font-family: \"Bitstream Vera Sans\";"; + + tabBarPaddingTop = "0"; + tabBarPaddingSide = "9"; #endif - textBrowserFontsize= "10"; - cashFontSize = "10"; - setLabelFontSize = "10"; - playerNameLabelFontSize = "11"; - smallBoardFontSize = "13"; - bigBoardFontSize = "17"; - humanPlayerButtonFontSize = "12"; - betValueFontSize = "10"; + textBrowserFontsize= "10"; + cashFontSize = "10"; + setLabelFontSize = "10"; + playerNameLabelFontSize = "11"; + smallBoardFontSize = "13"; + bigBoardFontSize = "17"; + humanPlayerButtonFontSize = "12"; + betValueFontSize = "10"; #endif } @@ -71,636 +71,1230 @@ GameTableStyleReader::~GameTableStyleReader() { } -void GameTableStyleReader::readStyleFile(QString file) { +void GameTableStyleReader::readStyleFile(QString file) +{ - //if style file failed --> default style fallback - if(QFile(file).exists()) { - currentFileName = QFile(file).fileName(); - } - else { - currentFileName = QFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/default/defaulttablestyle.xml").fileName(); - fallBack = 1; - } + //if style file failed --> default style fallback + if(QFile(file).exists()) { + currentFileName = QFile(file).fileName(); + } else { + currentFileName = QFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/default/defaulttablestyle.xml").fileName(); + fallBack = 1; + } - QFile myFile(currentFileName); - myFile.open(QIODevice::ReadOnly); - fileContent = myFile.readAll(); + QFile myFile(currentFileName); + myFile.open(QIODevice::ReadOnly); + fileContent = myFile.readAll(); - QFileInfo info(currentFileName); - currentDir = info.absolutePath()+"/"; + QFileInfo info(currentFileName); + currentDir = info.absolutePath()+"/"; - //start reading the file and fill vars - string tempString1(""); - TiXmlDocument doc; - doc.Parse(fileContent.constData()); + //start reading the file and fill vars + string tempString1(""); + TiXmlDocument doc; + doc.Parse(fileContent.constData()); - if(doc.RootElement()) { - TiXmlHandle docHandle( &doc ); + if(doc.RootElement()) { + TiXmlHandle docHandle( &doc ); - TiXmlElement *CardDeckElement = docHandle.FirstChild( "PokerTH" ).FirstChild( "CardDeck" ).ToElement(); - if(CardDeckElement) { - QMessageBox::warning(myW, tr("Game Table Style Error"), - tr("A card deck style was selected instead of a game table style.\nPlease select a game table style and try again!"), - QMessageBox::Ok); - } - else { - //in case of rereading clear old variables: - StyleDescription.clear(); - StyleMaintainerName.clear(); - StyleMaintainerEMail.clear(); - StyleCreateDate.clear(); - PokerTHStyleFileVersion.clear(); - IfFixedWindowSize.clear(); - FixedWindowWidth.clear(); - FixedWindowHeight.clear(); - MinimumWindowWidth.clear(); - MinimumWindowHeight.clear(); - MaximumWindowWidth.clear(); - MaximumWindowHeight.clear(); - Preview.clear(); - ActionAllInI18NPic.clear(); - ActionRaiseI18NPic.clear(); - ActionBetI18NPic.clear(); - ActionCallI18NPic.clear(); - ActionCheckI18NPic.clear(); - ActionFoldI18NPic.clear(); - ActionWinnerI18NPic.clear(); - BigBlindPuck.clear(); - SmallBlindPuck.clear(); - DealerPuck.clear(); - DefaultAvatar.clear(); - CardHolderFlop.clear(); - CardHolderTurn.clear(); - CardHolderRiver.clear(); - FoldButtonDefault.clear(); - FoldButtonHover.clear(); - FoldButtonChecked.clear(); - FoldButtonCheckedHover.clear(); - CheckCallButtonDefault.clear(); - CheckCallButtonHover.clear(); - CheckCallButtonChecked.clear(); - CheckCallButtonCheckedHover.clear(); - BetRaiseButtonDefault.clear(); - BetRaiseButtonHover.clear(); - BetRaiseButtonChecked.clear(); - BetRaiseButtonCheckedHover.clear(); - AllInButtonDefault.clear(); - AllInButtonHover.clear(); - AllInButtonChecked.clear(); - AllInButtonCheckedHover.clear(); - RadioButtonPressed.clear(); - RadioButtonChecked.clear(); - RadioButtonCheckedHover.clear(); - RadioButtonUnchecked.clear(); - RadioButtonUncheckedHover.clear(); - PlayerTopSeatInactive.clear(); - PlayerTopSeatActive.clear(); - PlayerBottomSeatInactive.clear(); - PlayerBottomSeatActive.clear(); - Table.clear(); - HandRanking.clear(); - ToolBoxBackground.clear(); - ShowMyCardsButtonDefault.clear(); - ShowMyCardsButtonHover.clear(); - ActionAllInI18NString.clear(); - ActionRaiseI18NString.clear(); - ActionBetI18NString.clear(); - ActionCallI18NString.clear(); - ActionCheckI18NString.clear(); - ActionFoldI18NString.clear(); - PotI18NString.clear(); - TotalI18NString.clear(); - BetsI18NString.clear(); - GameI18NString.clear(); - HandI18NString.clear(); - PreflopI18NString.clear(); - FlopI18NString.clear(); - TurnI18NString.clear(); - RiverI18NString.clear(); - FKeyIndicatorColor.clear(); - ChanceLabelPossibleColor.clear(); - ChanceLabelImpossibleColor.clear(); - ChatTextNickNotifyColor.clear(); - ChatLogTextColor.clear(); - ChatLogBgColor.clear(); - ChatLogScrollBarBorderColor.clear(); - ChatLogScrollBarBgColor.clear(); - ChatLogScrollBarHandleBorderColor.clear(); - ChatLogScrollBarHandleBgColor.clear(); - ChatLogScrollBarArrowBorderColor.clear(); - ChatLogScrollBarArrowBgColor.clear(); - LogWinnerMainPotColor.clear(); - LogWinnerSidePotColor.clear(); - LogPlayerSitsOutColor.clear(); - LogNewGameAdminColor.clear(); - TabWidgetBorderColor.clear(); - TabWidgetBgColor.clear(); - TabWidgetTextColor.clear(); - MenuBgColor.clear(); - MenuTextColor.clear(); - BreakLobbyButtonBgColor.clear(); - BreakLobbyButtonTextColor.clear(); - BreakLobbyButtonBgDisabledColor.clear(); - BreakLobbyButtonTextDisabledColor.clear(); - BreakLobbyButtonBgBlinkColor.clear(); - BreakLobbyButtonTextBlinkColor.clear(); - PlayerCashTextColor.clear(); - PlayerBetTextColor.clear(); - PlayerNickTextColor.clear(); - BoardBigTextColor.clear(); - BoardSmallTextColor.clear(); - SpeedTextColor.clear(); - VoteButtonBgColor.clear(); - VoteButtonTextColor.clear(); - BetInputTextColor.clear(); - BetInputBgColor.clear(); - BetInputDisabledTextColor.clear(); - BetInputDisabledBgColor.clear(); - FoldButtonTextColor.clear(); - FoldButtonCheckableTextColor.clear(); - CheckCallButtonTextColor.clear(); - CheckCallButtonCheckableTextColor.clear(); - BetRaiseButtonTextColor.clear(); - BetRaiseButtonCheckableTextColor.clear(); - AllInButtonTextColor.clear(); - AllInButtonCheckableTextColor.clear(); - BetSpeedSliderGrooveBgColor.clear(); - BetSpeedSliderGrooveBorderColor.clear(); - BetSpeedSliderHandleBgColor.clear(); - BetSpeedSliderHandleBorderColor.clear(); - ShowMyCardsButtonTextColor.clear(); + TiXmlElement *CardDeckElement = docHandle.FirstChild( "PokerTH" ).FirstChild( "CardDeck" ).ToElement(); + if(CardDeckElement) { + QMessageBox::warning(myW, tr("Game Table Style Error"), + tr("A card deck style was selected instead of a game table style.\nPlease select a game table style and try again!"), + QMessageBox::Ok); + } else { + //in case of rereading clear old variables: + StyleDescription.clear(); + StyleMaintainerName.clear(); + StyleMaintainerEMail.clear(); + StyleCreateDate.clear(); + PokerTHStyleFileVersion.clear(); + IfFixedWindowSize.clear(); + FixedWindowWidth.clear(); + FixedWindowHeight.clear(); + MinimumWindowWidth.clear(); + MinimumWindowHeight.clear(); + MaximumWindowWidth.clear(); + MaximumWindowHeight.clear(); + Preview.clear(); + ActionAllInI18NPic.clear(); + ActionRaiseI18NPic.clear(); + ActionBetI18NPic.clear(); + ActionCallI18NPic.clear(); + ActionCheckI18NPic.clear(); + ActionFoldI18NPic.clear(); + ActionWinnerI18NPic.clear(); + BigBlindPuck.clear(); + SmallBlindPuck.clear(); + DealerPuck.clear(); + DefaultAvatar.clear(); + CardHolderFlop.clear(); + CardHolderTurn.clear(); + CardHolderRiver.clear(); + FoldButtonDefault.clear(); + FoldButtonHover.clear(); + FoldButtonChecked.clear(); + FoldButtonCheckedHover.clear(); + CheckCallButtonDefault.clear(); + CheckCallButtonHover.clear(); + CheckCallButtonChecked.clear(); + CheckCallButtonCheckedHover.clear(); + BetRaiseButtonDefault.clear(); + BetRaiseButtonHover.clear(); + BetRaiseButtonChecked.clear(); + BetRaiseButtonCheckedHover.clear(); + AllInButtonDefault.clear(); + AllInButtonHover.clear(); + AllInButtonChecked.clear(); + AllInButtonCheckedHover.clear(); + RadioButtonPressed.clear(); + RadioButtonChecked.clear(); + RadioButtonCheckedHover.clear(); + RadioButtonUnchecked.clear(); + RadioButtonUncheckedHover.clear(); + PlayerTopSeatInactive.clear(); + PlayerTopSeatActive.clear(); + PlayerBottomSeatInactive.clear(); + PlayerBottomSeatActive.clear(); + Table.clear(); + HandRanking.clear(); + ToolBoxBackground.clear(); + ShowMyCardsButtonDefault.clear(); + ShowMyCardsButtonHover.clear(); + ActionAllInI18NString.clear(); + ActionRaiseI18NString.clear(); + ActionBetI18NString.clear(); + ActionCallI18NString.clear(); + ActionCheckI18NString.clear(); + ActionFoldI18NString.clear(); + PotI18NString.clear(); + TotalI18NString.clear(); + BetsI18NString.clear(); + GameI18NString.clear(); + HandI18NString.clear(); + PreflopI18NString.clear(); + FlopI18NString.clear(); + TurnI18NString.clear(); + RiverI18NString.clear(); + FKeyIndicatorColor.clear(); + ChanceLabelPossibleColor.clear(); + ChanceLabelImpossibleColor.clear(); + ChatTextNickNotifyColor.clear(); + ChatLogTextColor.clear(); + ChatLogBgColor.clear(); + ChatLogScrollBarBorderColor.clear(); + ChatLogScrollBarBgColor.clear(); + ChatLogScrollBarHandleBorderColor.clear(); + ChatLogScrollBarHandleBgColor.clear(); + ChatLogScrollBarArrowBorderColor.clear(); + ChatLogScrollBarArrowBgColor.clear(); + LogWinnerMainPotColor.clear(); + LogWinnerSidePotColor.clear(); + LogPlayerSitsOutColor.clear(); + LogNewGameAdminColor.clear(); + TabWidgetBorderColor.clear(); + TabWidgetBgColor.clear(); + TabWidgetTextColor.clear(); + MenuBgColor.clear(); + MenuTextColor.clear(); + BreakLobbyButtonBgColor.clear(); + BreakLobbyButtonTextColor.clear(); + BreakLobbyButtonBgDisabledColor.clear(); + BreakLobbyButtonTextDisabledColor.clear(); + BreakLobbyButtonBgBlinkColor.clear(); + BreakLobbyButtonTextBlinkColor.clear(); + PlayerCashTextColor.clear(); + PlayerBetTextColor.clear(); + PlayerNickTextColor.clear(); + BoardBigTextColor.clear(); + BoardSmallTextColor.clear(); + SpeedTextColor.clear(); + VoteButtonBgColor.clear(); + VoteButtonTextColor.clear(); + BetInputTextColor.clear(); + BetInputBgColor.clear(); + BetInputDisabledTextColor.clear(); + BetInputDisabledBgColor.clear(); + FoldButtonTextColor.clear(); + FoldButtonCheckableTextColor.clear(); + CheckCallButtonTextColor.clear(); + CheckCallButtonCheckableTextColor.clear(); + BetRaiseButtonTextColor.clear(); + BetRaiseButtonCheckableTextColor.clear(); + AllInButtonTextColor.clear(); + AllInButtonCheckableTextColor.clear(); + BetSpeedSliderGrooveBgColor.clear(); + BetSpeedSliderGrooveBorderColor.clear(); + BetSpeedSliderHandleBgColor.clear(); + BetSpeedSliderHandleBorderColor.clear(); + ShowMyCardsButtonTextColor.clear(); RatingStarsColor.clear(); PlayerInfoHintTextColor.clear(); - ChatLogTextSize.clear(); + ChatLogTextSize.clear(); - //now reading! - TiXmlElement* itemsList = docHandle.FirstChild( "PokerTH" ).FirstChild( "TableStyle" ).FirstChild().ToElement(); - for( ; itemsList; itemsList=itemsList->NextSiblingElement()) { - const char *tmpStr1 = itemsList->Attribute("value"); - if (tmpStr1) { - tempString1 = tmpStr1; + //now reading! + TiXmlElement* itemsList = docHandle.FirstChild( "PokerTH" ).FirstChild( "TableStyle" ).FirstChild().ToElement(); + for( ; itemsList; itemsList=itemsList->NextSiblingElement()) { + const char *tmpStr1 = itemsList->Attribute("value"); + if (tmpStr1) { + tempString1 = tmpStr1; - // INFOS - if(itemsList->ValueStr() == "StyleDescription") { StyleDescription = QString::fromUtf8(tempString1.c_str()); } - else if(itemsList->ValueStr() == "StyleMaintainerName") { StyleMaintainerName = QString::fromUtf8(tempString1.c_str()); } - else if(itemsList->ValueStr() == "StyleMaintainerEMail") { StyleMaintainerEMail = QString::fromUtf8(tempString1.c_str()); } - else if(itemsList->ValueStr() == "StyleCreateDate") { StyleCreateDate = QString::fromUtf8(tempString1.c_str()); } - else if(itemsList->ValueStr() == "PokerTHStyleFileVersion") { PokerTHStyleFileVersion = QString::fromUtf8(tempString1.c_str()); } - // WINDOWS SETTINGS - else if (itemsList->ValueStr() == "IfFixedWindowSize") { IfFixedWindowSize = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "FixedWindowWidth") { FixedWindowWidth = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "FixedWindowHeight") { FixedWindowHeight = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "MinimumWindowWidth") { MinimumWindowWidth = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "MinimumWindowHeight") { MinimumWindowHeight = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "MaximumWindowWidth") { MaximumWindowWidth = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "MaximumWindowHeight") { MaximumWindowHeight = QString::fromUtf8(tempString1.c_str()); } - // PICS - else if (itemsList->ValueStr() == "Preview") { Preview = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ActionAllInI18NPic") { ActionAllInI18NPic = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ActionRaiseI18NPic") { ActionRaiseI18NPic = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ActionBetI18NPic") { ActionBetI18NPic = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ActionCallI18NPic") { ActionCallI18NPic = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ActionCheckI18NPic") { ActionCheckI18NPic = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ActionFoldI18NPic") { ActionFoldI18NPic = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ActionWinnerI18NPic") { ActionWinnerI18NPic = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BigBlindPuck") { BigBlindPuck = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "SmallBlindPuck") { SmallBlindPuck = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "DealerPuck") { DealerPuck = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "DefaultAvatar") { DefaultAvatar = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "CardHolderFlop") { CardHolderFlop = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "CardHolderTurn") { CardHolderTurn = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "CardHolderRiver") { CardHolderRiver = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "FoldButtonDefault") { FoldButtonDefault = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "FoldButtonHover") { FoldButtonHover = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "FoldButtonChecked") { FoldButtonChecked = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "FoldButtonCheckedHover") { FoldButtonCheckedHover = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "CheckCallButtonDefault") { CheckCallButtonDefault = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "CheckCallButtonHover") { CheckCallButtonHover = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "CheckCallButtonChecked") { CheckCallButtonChecked = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "CheckCallButtonCheckedHover") { CheckCallButtonCheckedHover = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BetRaiseButtonDefault") { BetRaiseButtonDefault = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BetRaiseButtonHover") { BetRaiseButtonHover = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BetRaiseButtonChecked") { BetRaiseButtonChecked = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BetRaiseButtonCheckedHover") { BetRaiseButtonCheckedHover = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "AllInButtonDefault") { AllInButtonDefault = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "AllInButtonHover") { AllInButtonHover = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "AllInButtonChecked") { AllInButtonChecked = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "AllInButtonCheckedHover") { AllInButtonCheckedHover = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "RadioButtonPressed") { RadioButtonPressed = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "RadioButtonChecked") { RadioButtonChecked = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "RadioButtonCheckedHover") { RadioButtonCheckedHover = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "RadioButtonUnchecked") { RadioButtonUnchecked = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "RadioButtonUncheckedHover") { RadioButtonUncheckedHover = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "PlayerTopSeatInactive") { PlayerTopSeatInactive = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "PlayerTopSeatActive") { PlayerTopSeatActive = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "PlayerBottomSeatInactive") { PlayerBottomSeatInactive = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "PlayerBottomSeatActive") { PlayerBottomSeatActive = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "Table") { Table = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "HandRanking") { HandRanking = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ToolBoxBackground") { ToolBoxBackground = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ShowMyCardsButtonDefault") { ShowMyCardsButtonDefault = currentDir+QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ShowMyCardsButtonHover") { ShowMyCardsButtonHover = currentDir+QString::fromUtf8(tempString1.c_str()); } + // INFOS + if(itemsList->ValueStr() == "StyleDescription") { + StyleDescription = QString::fromUtf8(tempString1.c_str()); + } else if(itemsList->ValueStr() == "StyleMaintainerName") { + StyleMaintainerName = QString::fromUtf8(tempString1.c_str()); + } else if(itemsList->ValueStr() == "StyleMaintainerEMail") { + StyleMaintainerEMail = QString::fromUtf8(tempString1.c_str()); + } else if(itemsList->ValueStr() == "StyleCreateDate") { + StyleCreateDate = QString::fromUtf8(tempString1.c_str()); + } else if(itemsList->ValueStr() == "PokerTHStyleFileVersion") { + PokerTHStyleFileVersion = QString::fromUtf8(tempString1.c_str()); + } + // WINDOWS SETTINGS + else if (itemsList->ValueStr() == "IfFixedWindowSize") { + IfFixedWindowSize = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "FixedWindowWidth") { + FixedWindowWidth = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "FixedWindowHeight") { + FixedWindowHeight = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "MinimumWindowWidth") { + MinimumWindowWidth = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "MinimumWindowHeight") { + MinimumWindowHeight = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "MaximumWindowWidth") { + MaximumWindowWidth = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "MaximumWindowHeight") { + MaximumWindowHeight = QString::fromUtf8(tempString1.c_str()); + } + // PICS + else if (itemsList->ValueStr() == "Preview") { + Preview = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ActionAllInI18NPic") { + ActionAllInI18NPic = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ActionRaiseI18NPic") { + ActionRaiseI18NPic = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ActionBetI18NPic") { + ActionBetI18NPic = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ActionCallI18NPic") { + ActionCallI18NPic = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ActionCheckI18NPic") { + ActionCheckI18NPic = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ActionFoldI18NPic") { + ActionFoldI18NPic = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ActionWinnerI18NPic") { + ActionWinnerI18NPic = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BigBlindPuck") { + BigBlindPuck = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "SmallBlindPuck") { + SmallBlindPuck = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "DealerPuck") { + DealerPuck = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "DefaultAvatar") { + DefaultAvatar = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "CardHolderFlop") { + CardHolderFlop = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "CardHolderTurn") { + CardHolderTurn = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "CardHolderRiver") { + CardHolderRiver = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "FoldButtonDefault") { + FoldButtonDefault = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "FoldButtonHover") { + FoldButtonHover = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "FoldButtonChecked") { + FoldButtonChecked = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "FoldButtonCheckedHover") { + FoldButtonCheckedHover = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "CheckCallButtonDefault") { + CheckCallButtonDefault = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "CheckCallButtonHover") { + CheckCallButtonHover = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "CheckCallButtonChecked") { + CheckCallButtonChecked = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "CheckCallButtonCheckedHover") { + CheckCallButtonCheckedHover = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BetRaiseButtonDefault") { + BetRaiseButtonDefault = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BetRaiseButtonHover") { + BetRaiseButtonHover = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BetRaiseButtonChecked") { + BetRaiseButtonChecked = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BetRaiseButtonCheckedHover") { + BetRaiseButtonCheckedHover = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "AllInButtonDefault") { + AllInButtonDefault = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "AllInButtonHover") { + AllInButtonHover = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "AllInButtonChecked") { + AllInButtonChecked = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "AllInButtonCheckedHover") { + AllInButtonCheckedHover = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "RadioButtonPressed") { + RadioButtonPressed = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "RadioButtonChecked") { + RadioButtonChecked = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "RadioButtonCheckedHover") { + RadioButtonCheckedHover = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "RadioButtonUnchecked") { + RadioButtonUnchecked = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "RadioButtonUncheckedHover") { + RadioButtonUncheckedHover = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "PlayerTopSeatInactive") { + PlayerTopSeatInactive = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "PlayerTopSeatActive") { + PlayerTopSeatActive = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "PlayerBottomSeatInactive") { + PlayerBottomSeatInactive = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "PlayerBottomSeatActive") { + PlayerBottomSeatActive = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "Table") { + Table = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "HandRanking") { + HandRanking = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ToolBoxBackground") { + ToolBoxBackground = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ShowMyCardsButtonDefault") { + ShowMyCardsButtonDefault = currentDir+QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ShowMyCardsButtonHover") { + ShowMyCardsButtonHover = currentDir+QString::fromUtf8(tempString1.c_str()); + } - //I18N ACTION STRINGS - else if (itemsList->ValueStr() == "ActionAllInI18NString") { ActionAllInI18NString = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ActionRaiseI18NString") { ActionRaiseI18NString = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ActionBetI18NString") { ActionBetI18NString = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ActionCallI18NString") { ActionCallI18NString = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ActionCheckI18NString") { ActionCheckI18NString = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ActionFoldI18NString") { ActionFoldI18NString = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "PotI18NString") { PotI18NString = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "TotalI18NString") { TotalI18NString = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BetsI18NString") { BetsI18NString = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "GameI18NString") { GameI18NString = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "HandI18NString") { HandI18NString = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "PreflopI18NString") { PreflopI18NString = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "FlopI18NString") { FlopI18NString = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "TurnI18NString") { TurnI18NString = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "RiverI18NString") { RiverI18NString = QString::fromUtf8(tempString1.c_str()); } + //I18N ACTION STRINGS + else if (itemsList->ValueStr() == "ActionAllInI18NString") { + ActionAllInI18NString = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ActionRaiseI18NString") { + ActionRaiseI18NString = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ActionBetI18NString") { + ActionBetI18NString = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ActionCallI18NString") { + ActionCallI18NString = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ActionCheckI18NString") { + ActionCheckI18NString = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ActionFoldI18NString") { + ActionFoldI18NString = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "PotI18NString") { + PotI18NString = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "TotalI18NString") { + TotalI18NString = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BetsI18NString") { + BetsI18NString = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "GameI18NString") { + GameI18NString = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "HandI18NString") { + HandI18NString = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "PreflopI18NString") { + PreflopI18NString = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "FlopI18NString") { + FlopI18NString = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "TurnI18NString") { + TurnI18NString = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "RiverI18NString") { + RiverI18NString = QString::fromUtf8(tempString1.c_str()); + } - // COLORS - if (itemsList->ValueStr() == "FKeyIndicatorColor") { FKeyIndicatorColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ChanceLabelPossibleColor") { ChanceLabelPossibleColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ChanceLabelImpossibleColor") { ChanceLabelImpossibleColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ChatTextNickNotifyColor") { ChatTextNickNotifyColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ChatLogTextColor") { ChatLogTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ChatLogBgColor") { ChatLogBgColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ChatLogScrollBarBorderColor") { ChatLogScrollBarBorderColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ChatLogScrollBarBgColor") { ChatLogScrollBarBgColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ChatLogScrollBarHandleBorderColor") { ChatLogScrollBarHandleBorderColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ChatLogScrollBarHandleBgColor") { ChatLogScrollBarHandleBgColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ChatLogScrollBarArrowBorderColor") { ChatLogScrollBarArrowBorderColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ChatLogScrollBarArrowBgColor") { ChatLogScrollBarArrowBgColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "LogWinnerMainPotColor") { LogWinnerMainPotColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "LogWinnerSidePotColor") { LogWinnerSidePotColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "LogPlayerSitsOutColor") { LogPlayerSitsOutColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "LogNewGameAdminColor") { LogNewGameAdminColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "TabWidgetBorderColor") { TabWidgetBorderColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "TabWidgetBgColor") { TabWidgetBgColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "TabWidgetTextColor") { TabWidgetTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "MenuBgColor") { MenuBgColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "MenuTextColor") { MenuTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BreakLobbyButtonBgColor") { BreakLobbyButtonBgColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BreakLobbyButtonTextColor") { BreakLobbyButtonTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BreakLobbyButtonBgDisabledColor") { BreakLobbyButtonBgDisabledColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BreakLobbyButtonTextDisabledColor") { BreakLobbyButtonTextDisabledColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BreakLobbyButtonBgBlinkColor") { BreakLobbyButtonBgBlinkColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BreakLobbyButtonTextBlinkColor") { BreakLobbyButtonTextBlinkColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "PlayerCashTextColor") { PlayerCashTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "PlayerBetTextColor") { PlayerBetTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "PlayerNickTextColor") { PlayerNickTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BoardBigTextColor") { BoardBigTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BoardSmallTextColor") { BoardSmallTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "SpeedTextColor") { SpeedTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "VoteButtonBgColor") { VoteButtonBgColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "VoteButtonTextColor") { VoteButtonTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BetInputTextColor") { BetInputTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BetInputBgColor") { BetInputBgColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BetInputDisabledTextColor") { BetInputDisabledTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BetInputDisabledBgColor") { BetInputDisabledBgColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "FoldButtonTextColor") { FoldButtonTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "FoldButtonCheckableTextColor") { FoldButtonCheckableTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "CheckCallButtonTextColor") { CheckCallButtonTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "CheckCallButtonCheckableTextColor") { CheckCallButtonCheckableTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BetRaiseButtonTextColor") { BetRaiseButtonTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BetRaiseButtonCheckableTextColor") { BetRaiseButtonCheckableTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "AllInButtonTextColor") { AllInButtonTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "AllInButtonCheckableTextColor") { AllInButtonCheckableTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BetSpeedSliderGrooveBgColor") { BetSpeedSliderGrooveBgColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BetSpeedSliderGrooveBorderColor") { BetSpeedSliderGrooveBorderColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BetSpeedSliderHandleBgColor") { BetSpeedSliderHandleBgColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "BetSpeedSliderHandleBorderColor") { BetSpeedSliderHandleBorderColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "ShowMyCardsButtonTextColor") { ShowMyCardsButtonTextColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "RatingStarsColor") { RatingStarsColor = QString::fromUtf8(tempString1.c_str()); } - else if (itemsList->ValueStr() == "PlayerInfoHintTextColor") { PlayerInfoHintTextColor = QString::fromUtf8(tempString1.c_str()); } - // SIZES - else if (itemsList->ValueStr() == "ChatLogTextSize") { ChatLogTextSize = QString::fromUtf8(tempString1.c_str()); } - } - } + // COLORS + if (itemsList->ValueStr() == "FKeyIndicatorColor") { + FKeyIndicatorColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ChanceLabelPossibleColor") { + ChanceLabelPossibleColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ChanceLabelImpossibleColor") { + ChanceLabelImpossibleColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ChatTextNickNotifyColor") { + ChatTextNickNotifyColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ChatLogTextColor") { + ChatLogTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ChatLogBgColor") { + ChatLogBgColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ChatLogScrollBarBorderColor") { + ChatLogScrollBarBorderColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ChatLogScrollBarBgColor") { + ChatLogScrollBarBgColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ChatLogScrollBarHandleBorderColor") { + ChatLogScrollBarHandleBorderColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ChatLogScrollBarHandleBgColor") { + ChatLogScrollBarHandleBgColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ChatLogScrollBarArrowBorderColor") { + ChatLogScrollBarArrowBorderColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ChatLogScrollBarArrowBgColor") { + ChatLogScrollBarArrowBgColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "LogWinnerMainPotColor") { + LogWinnerMainPotColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "LogWinnerSidePotColor") { + LogWinnerSidePotColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "LogPlayerSitsOutColor") { + LogPlayerSitsOutColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "LogNewGameAdminColor") { + LogNewGameAdminColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "TabWidgetBorderColor") { + TabWidgetBorderColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "TabWidgetBgColor") { + TabWidgetBgColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "TabWidgetTextColor") { + TabWidgetTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "MenuBgColor") { + MenuBgColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "MenuTextColor") { + MenuTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BreakLobbyButtonBgColor") { + BreakLobbyButtonBgColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BreakLobbyButtonTextColor") { + BreakLobbyButtonTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BreakLobbyButtonBgDisabledColor") { + BreakLobbyButtonBgDisabledColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BreakLobbyButtonTextDisabledColor") { + BreakLobbyButtonTextDisabledColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BreakLobbyButtonBgBlinkColor") { + BreakLobbyButtonBgBlinkColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BreakLobbyButtonTextBlinkColor") { + BreakLobbyButtonTextBlinkColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "PlayerCashTextColor") { + PlayerCashTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "PlayerBetTextColor") { + PlayerBetTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "PlayerNickTextColor") { + PlayerNickTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BoardBigTextColor") { + BoardBigTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BoardSmallTextColor") { + BoardSmallTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "SpeedTextColor") { + SpeedTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "VoteButtonBgColor") { + VoteButtonBgColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "VoteButtonTextColor") { + VoteButtonTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BetInputTextColor") { + BetInputTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BetInputBgColor") { + BetInputBgColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BetInputDisabledTextColor") { + BetInputDisabledTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BetInputDisabledBgColor") { + BetInputDisabledBgColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "FoldButtonTextColor") { + FoldButtonTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "FoldButtonCheckableTextColor") { + FoldButtonCheckableTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "CheckCallButtonTextColor") { + CheckCallButtonTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "CheckCallButtonCheckableTextColor") { + CheckCallButtonCheckableTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BetRaiseButtonTextColor") { + BetRaiseButtonTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BetRaiseButtonCheckableTextColor") { + BetRaiseButtonCheckableTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "AllInButtonTextColor") { + AllInButtonTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "AllInButtonCheckableTextColor") { + AllInButtonCheckableTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BetSpeedSliderGrooveBgColor") { + BetSpeedSliderGrooveBgColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BetSpeedSliderGrooveBorderColor") { + BetSpeedSliderGrooveBorderColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BetSpeedSliderHandleBgColor") { + BetSpeedSliderHandleBgColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "BetSpeedSliderHandleBorderColor") { + BetSpeedSliderHandleBorderColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "ShowMyCardsButtonTextColor") { + ShowMyCardsButtonTextColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "RatingStarsColor") { + RatingStarsColor = QString::fromUtf8(tempString1.c_str()); + } else if (itemsList->ValueStr() == "PlayerInfoHintTextColor") { + PlayerInfoHintTextColor = QString::fromUtf8(tempString1.c_str()); + } + // SIZES + else if (itemsList->ValueStr() == "ChatLogTextSize") { + ChatLogTextSize = QString::fromUtf8(tempString1.c_str()); + } + } + } - //check if style items are left and if pictures where not found - leftItems.clear(); - itemPicsLeft.clear(); + //check if style items are left and if pictures where not found + leftItems.clear(); + itemPicsLeft.clear(); - // INFOS - if(StyleDescription == "") { leftItems << "StyleDescription"; } - if(StyleMaintainerName == "") { leftItems << "StyleMaintainerName"; } - if(StyleMaintainerEMail == "") { leftItems << "StyleMaintainerEMail"; } - if(StyleCreateDate == "") { leftItems << "StyleCreateDate"; } - if(PokerTHStyleFileVersion == "") { leftItems << "PokerTHStyleFileVersion"; } - // WINDOWS SETTINGS - if(IfFixedWindowSize == "") { IfFixedWindowSize = getFallBackFieldContent("IfFixedWindowSize", 0); leftItems << "IfFixedWindowSize"; } - if(FixedWindowWidth == "") { FixedWindowWidth = getFallBackFieldContent("FixedWindowWidth", 0); leftItems << "FixedWindowWidth"; } - if(FixedWindowHeight == "") { FixedWindowHeight = getFallBackFieldContent("FixedWindowHeight", 0); leftItems << "FixedWindowHeight"; } - if(MinimumWindowWidth == "") { MinimumWindowWidth = getFallBackFieldContent("MinimumWindowWidth", 0); leftItems << "MinimumWindowWidth"; } - if(MinimumWindowHeight == "") { MinimumWindowHeight = getFallBackFieldContent("MinimumWindowHeight", 0); leftItems << "MinimumWindowHeight"; } - if(MaximumWindowWidth == "") { MaximumWindowWidth = getFallBackFieldContent("MaximumWindowWidth", 0); leftItems << "MaximumWindowWidth"; } - if(MaximumWindowHeight == "") { MaximumWindowHeight = getFallBackFieldContent("MaximumWindowHeight", 0); leftItems << "MaximumWindowHeight"; } - // P I C S + // INFOS + if(StyleDescription == "") { + leftItems << "StyleDescription"; + } + if(StyleMaintainerName == "") { + leftItems << "StyleMaintainerName"; + } + if(StyleMaintainerEMail == "") { + leftItems << "StyleMaintainerEMail"; + } + if(StyleCreateDate == "") { + leftItems << "StyleCreateDate"; + } + if(PokerTHStyleFileVersion == "") { + leftItems << "PokerTHStyleFileVersion"; + } + // WINDOWS SETTINGS + if(IfFixedWindowSize == "") { + IfFixedWindowSize = getFallBackFieldContent("IfFixedWindowSize", 0); + leftItems << "IfFixedWindowSize"; + } + if(FixedWindowWidth == "") { + FixedWindowWidth = getFallBackFieldContent("FixedWindowWidth", 0); + leftItems << "FixedWindowWidth"; + } + if(FixedWindowHeight == "") { + FixedWindowHeight = getFallBackFieldContent("FixedWindowHeight", 0); + leftItems << "FixedWindowHeight"; + } + if(MinimumWindowWidth == "") { + MinimumWindowWidth = getFallBackFieldContent("MinimumWindowWidth", 0); + leftItems << "MinimumWindowWidth"; + } + if(MinimumWindowHeight == "") { + MinimumWindowHeight = getFallBackFieldContent("MinimumWindowHeight", 0); + leftItems << "MinimumWindowHeight"; + } + if(MaximumWindowWidth == "") { + MaximumWindowWidth = getFallBackFieldContent("MaximumWindowWidth", 0); + leftItems << "MaximumWindowWidth"; + } + if(MaximumWindowHeight == "") { + MaximumWindowHeight = getFallBackFieldContent("MaximumWindowHeight", 0); + leftItems << "MaximumWindowHeight"; + } + // P I C S - // I18N Pics - if(ActionAllInI18NPic == "") { ActionAllInI18NPic = getFallBackFieldContent("ActionAllInI18NPic", 1); leftItems << "ActionAllInI18NPic"; } - else if(ActionAllInI18NPic != QString(currentDir+"NULL") && !QFile(ActionAllInI18NPic).exists()) { itemPicsLeft << "ActionAllInI18NPic = "+ActionAllInI18NPic; ActionAllInI18NPic = getFallBackFieldContent("ActionAllInI18NPic", 1); } + // I18N Pics + if(ActionAllInI18NPic == "") { + ActionAllInI18NPic = getFallBackFieldContent("ActionAllInI18NPic", 1); + leftItems << "ActionAllInI18NPic"; + } else if(ActionAllInI18NPic != QString(currentDir+"NULL") && !QFile(ActionAllInI18NPic).exists()) { + itemPicsLeft << "ActionAllInI18NPic = "+ActionAllInI18NPic; + ActionAllInI18NPic = getFallBackFieldContent("ActionAllInI18NPic", 1); + } - if(ActionRaiseI18NPic == "") { ActionRaiseI18NPic = getFallBackFieldContent("ActionRaiseI18NPic", 1); leftItems << "ActionRaiseI18NPic"; } - else if(ActionRaiseI18NPic != QString(currentDir+"NULL") && !QFile(ActionRaiseI18NPic).exists()) { itemPicsLeft << "ActionRaiseI18NPic = "+ActionRaiseI18NPic; ActionRaiseI18NPic = getFallBackFieldContent("ActionRaiseI18NPic", 1); } + if(ActionRaiseI18NPic == "") { + ActionRaiseI18NPic = getFallBackFieldContent("ActionRaiseI18NPic", 1); + leftItems << "ActionRaiseI18NPic"; + } else if(ActionRaiseI18NPic != QString(currentDir+"NULL") && !QFile(ActionRaiseI18NPic).exists()) { + itemPicsLeft << "ActionRaiseI18NPic = "+ActionRaiseI18NPic; + ActionRaiseI18NPic = getFallBackFieldContent("ActionRaiseI18NPic", 1); + } - if(ActionBetI18NPic == "") { ActionBetI18NPic = getFallBackFieldContent("ActionBetI18NPic", 1); leftItems << "ActionBetI18NPic"; } - else if(ActionBetI18NPic != QString(currentDir+"NULL") && !QFile(ActionBetI18NPic).exists()) { itemPicsLeft << "ActionBetI18NPic = "+ActionBetI18NPic; ActionBetI18NPic = getFallBackFieldContent("ActionBetI18NPic", 1); } + if(ActionBetI18NPic == "") { + ActionBetI18NPic = getFallBackFieldContent("ActionBetI18NPic", 1); + leftItems << "ActionBetI18NPic"; + } else if(ActionBetI18NPic != QString(currentDir+"NULL") && !QFile(ActionBetI18NPic).exists()) { + itemPicsLeft << "ActionBetI18NPic = "+ActionBetI18NPic; + ActionBetI18NPic = getFallBackFieldContent("ActionBetI18NPic", 1); + } - if(ActionCallI18NPic == "") { ActionCallI18NPic = getFallBackFieldContent("ActionCallI18NPic", 1); leftItems << "ActionCallI18NPic"; } - else if(ActionCallI18NPic != QString(currentDir+"NULL") && !QFile(ActionCallI18NPic).exists()) { itemPicsLeft << "ActionCallI18NPic = "+ActionCallI18NPic; ActionCallI18NPic = getFallBackFieldContent("ActionCallI18NPic", 1); } + if(ActionCallI18NPic == "") { + ActionCallI18NPic = getFallBackFieldContent("ActionCallI18NPic", 1); + leftItems << "ActionCallI18NPic"; + } else if(ActionCallI18NPic != QString(currentDir+"NULL") && !QFile(ActionCallI18NPic).exists()) { + itemPicsLeft << "ActionCallI18NPic = "+ActionCallI18NPic; + ActionCallI18NPic = getFallBackFieldContent("ActionCallI18NPic", 1); + } - if(ActionCheckI18NPic == "") { ActionCheckI18NPic = getFallBackFieldContent("ActionCheckI18NPic", 1); leftItems << "ActionCheckI18NPic"; } - else if(ActionCheckI18NPic != QString(currentDir+"NULL") && !QFile(ActionCheckI18NPic).exists()) { itemPicsLeft << "ActionCheckI18NPic = "+ActionCheckI18NPic; ActionCheckI18NPic = getFallBackFieldContent("ActionCheckI18NPic", 1); } + if(ActionCheckI18NPic == "") { + ActionCheckI18NPic = getFallBackFieldContent("ActionCheckI18NPic", 1); + leftItems << "ActionCheckI18NPic"; + } else if(ActionCheckI18NPic != QString(currentDir+"NULL") && !QFile(ActionCheckI18NPic).exists()) { + itemPicsLeft << "ActionCheckI18NPic = "+ActionCheckI18NPic; + ActionCheckI18NPic = getFallBackFieldContent("ActionCheckI18NPic", 1); + } - if(ActionFoldI18NPic == "") { ActionFoldI18NPic = getFallBackFieldContent("ActionFoldI18NPic", 1); leftItems << "ActionFoldI18NPic"; } - else if(ActionFoldI18NPic != QString(currentDir+"NULL") && !QFile(ActionFoldI18NPic).exists()) { itemPicsLeft << "ActionFoldI18NPic = "+ActionFoldI18NPic; ActionFoldI18NPic = getFallBackFieldContent("ActionFoldI18NPic", 1); } + if(ActionFoldI18NPic == "") { + ActionFoldI18NPic = getFallBackFieldContent("ActionFoldI18NPic", 1); + leftItems << "ActionFoldI18NPic"; + } else if(ActionFoldI18NPic != QString(currentDir+"NULL") && !QFile(ActionFoldI18NPic).exists()) { + itemPicsLeft << "ActionFoldI18NPic = "+ActionFoldI18NPic; + ActionFoldI18NPic = getFallBackFieldContent("ActionFoldI18NPic", 1); + } - if(ActionWinnerI18NPic == "") { ActionWinnerI18NPic = getFallBackFieldContent(" ActionWinnerI18NPic", 1); leftItems << "ActionWinnerI18NPic"; } - else if(ActionWinnerI18NPic != QString(currentDir+"NULL") && !QFile(ActionWinnerI18NPic).exists()) { itemPicsLeft << "ActionWinnerI18NPic = "+ActionWinnerI18NPic; ActionWinnerI18NPic = getFallBackFieldContent(" ActionWinnerI18NPic", 1); } + if(ActionWinnerI18NPic == "") { + ActionWinnerI18NPic = getFallBackFieldContent(" ActionWinnerI18NPic", 1); + leftItems << "ActionWinnerI18NPic"; + } else if(ActionWinnerI18NPic != QString(currentDir+"NULL") && !QFile(ActionWinnerI18NPic).exists()) { + itemPicsLeft << "ActionWinnerI18NPic = "+ActionWinnerI18NPic; + ActionWinnerI18NPic = getFallBackFieldContent(" ActionWinnerI18NPic", 1); + } - // Other Pics - if(BigBlindPuck == "") { BigBlindPuck = getFallBackFieldContent("BigBlindPuck", 1); leftItems << "BigBlindPuck"; } - else if(BigBlindPuck != QString(currentDir+"NULL") && !QFile(BigBlindPuck).exists()) { itemPicsLeft << "BigBlindPuck = "+BigBlindPuck; BigBlindPuck = getFallBackFieldContent("BigBlindPuck", 1); } + // Other Pics + if(BigBlindPuck == "") { + BigBlindPuck = getFallBackFieldContent("BigBlindPuck", 1); + leftItems << "BigBlindPuck"; + } else if(BigBlindPuck != QString(currentDir+"NULL") && !QFile(BigBlindPuck).exists()) { + itemPicsLeft << "BigBlindPuck = "+BigBlindPuck; + BigBlindPuck = getFallBackFieldContent("BigBlindPuck", 1); + } - if(SmallBlindPuck == "") { SmallBlindPuck = getFallBackFieldContent("SmallBlindPuck", 1); leftItems << "SmallBlindPuck"; } - else if(SmallBlindPuck != QString(currentDir+"NULL") && !QFile(SmallBlindPuck).exists()) { itemPicsLeft << "SmallBlindPuck = "+SmallBlindPuck; SmallBlindPuck = getFallBackFieldContent("SmallBlindPuck", 1); } + if(SmallBlindPuck == "") { + SmallBlindPuck = getFallBackFieldContent("SmallBlindPuck", 1); + leftItems << "SmallBlindPuck"; + } else if(SmallBlindPuck != QString(currentDir+"NULL") && !QFile(SmallBlindPuck).exists()) { + itemPicsLeft << "SmallBlindPuck = "+SmallBlindPuck; + SmallBlindPuck = getFallBackFieldContent("SmallBlindPuck", 1); + } - if(DealerPuck == "") { DealerPuck = getFallBackFieldContent("DealerPuck", 1); leftItems << "DealerPuck"; } - else if(DealerPuck != QString(currentDir+"NULL") && !QFile(DealerPuck).exists()) { itemPicsLeft << "DealerPuck = "+DealerPuck; DealerPuck = getFallBackFieldContent("DealerPuck", 1); } + if(DealerPuck == "") { + DealerPuck = getFallBackFieldContent("DealerPuck", 1); + leftItems << "DealerPuck"; + } else if(DealerPuck != QString(currentDir+"NULL") && !QFile(DealerPuck).exists()) { + itemPicsLeft << "DealerPuck = "+DealerPuck; + DealerPuck = getFallBackFieldContent("DealerPuck", 1); + } - if(DefaultAvatar == "") { DefaultAvatar = getFallBackFieldContent("DefaultAvatar", 1); leftItems << "DefaultAvatar"; } - else if(DefaultAvatar != QString(currentDir+"NULL") && !QFile(DefaultAvatar).exists()) { itemPicsLeft << "DefaultAvatar = "+DefaultAvatar; DefaultAvatar = getFallBackFieldContent("DefaultAvatar", 1); } + if(DefaultAvatar == "") { + DefaultAvatar = getFallBackFieldContent("DefaultAvatar", 1); + leftItems << "DefaultAvatar"; + } else if(DefaultAvatar != QString(currentDir+"NULL") && !QFile(DefaultAvatar).exists()) { + itemPicsLeft << "DefaultAvatar = "+DefaultAvatar; + DefaultAvatar = getFallBackFieldContent("DefaultAvatar", 1); + } - if(CardHolderFlop == "") { CardHolderFlop = getFallBackFieldContent("CardHolderFlop", 1); leftItems << "CardHolderFlop"; } - else if(CardHolderFlop != QString(currentDir+"NULL") && !QFile(CardHolderFlop).exists()) { itemPicsLeft << "CardHolderFlop = "+CardHolderFlop; CardHolderFlop = getFallBackFieldContent("CardHolderFlop", 1); } + if(CardHolderFlop == "") { + CardHolderFlop = getFallBackFieldContent("CardHolderFlop", 1); + leftItems << "CardHolderFlop"; + } else if(CardHolderFlop != QString(currentDir+"NULL") && !QFile(CardHolderFlop).exists()) { + itemPicsLeft << "CardHolderFlop = "+CardHolderFlop; + CardHolderFlop = getFallBackFieldContent("CardHolderFlop", 1); + } - if(CardHolderTurn == "") { CardHolderTurn = getFallBackFieldContent("CardHolderTurn", 1); leftItems << "CardHolderTurn"; } - else if(CardHolderTurn != QString(currentDir+"NULL") && !QFile(CardHolderTurn).exists()) { itemPicsLeft << "CardHolderTurn = "+CardHolderTurn; CardHolderTurn = getFallBackFieldContent("CardHolderTurn", 1); } + if(CardHolderTurn == "") { + CardHolderTurn = getFallBackFieldContent("CardHolderTurn", 1); + leftItems << "CardHolderTurn"; + } else if(CardHolderTurn != QString(currentDir+"NULL") && !QFile(CardHolderTurn).exists()) { + itemPicsLeft << "CardHolderTurn = "+CardHolderTurn; + CardHolderTurn = getFallBackFieldContent("CardHolderTurn", 1); + } - if(CardHolderRiver == "") { CardHolderRiver = getFallBackFieldContent("CardHolderRiver", 1); leftItems << "CardHolderRiver"; } - else if(CardHolderRiver != QString(currentDir+"NULL") && !QFile(CardHolderRiver).exists()) { itemPicsLeft << "CardHolderRiver = "+CardHolderRiver; CardHolderRiver = getFallBackFieldContent("CardHolderRiver", 1); } + if(CardHolderRiver == "") { + CardHolderRiver = getFallBackFieldContent("CardHolderRiver", 1); + leftItems << "CardHolderRiver"; + } else if(CardHolderRiver != QString(currentDir+"NULL") && !QFile(CardHolderRiver).exists()) { + itemPicsLeft << "CardHolderRiver = "+CardHolderRiver; + CardHolderRiver = getFallBackFieldContent("CardHolderRiver", 1); + } - if(FoldButtonDefault == "") { FoldButtonDefault = getFallBackFieldContent("FoldButtonDefault", 1); leftItems << "FoldButtonDefault"; } - else if(FoldButtonDefault != QString(currentDir+"NULL") && !QFile(FoldButtonDefault).exists()) { itemPicsLeft << "FoldButtonDefault = "+FoldButtonDefault; FoldButtonDefault = getFallBackFieldContent("FoldButtonDefault", 1); } + if(FoldButtonDefault == "") { + FoldButtonDefault = getFallBackFieldContent("FoldButtonDefault", 1); + leftItems << "FoldButtonDefault"; + } else if(FoldButtonDefault != QString(currentDir+"NULL") && !QFile(FoldButtonDefault).exists()) { + itemPicsLeft << "FoldButtonDefault = "+FoldButtonDefault; + FoldButtonDefault = getFallBackFieldContent("FoldButtonDefault", 1); + } - if(FoldButtonHover == "") { FoldButtonHover = getFallBackFieldContent("FoldButtonHover", 1); leftItems << "FoldButtonHover"; } - else if(FoldButtonHover != QString(currentDir+"NULL") && !QFile(FoldButtonHover).exists()) { itemPicsLeft << "FoldButtonHover = "+FoldButtonHover; FoldButtonHover = getFallBackFieldContent("FoldButtonHover", 1); } + if(FoldButtonHover == "") { + FoldButtonHover = getFallBackFieldContent("FoldButtonHover", 1); + leftItems << "FoldButtonHover"; + } else if(FoldButtonHover != QString(currentDir+"NULL") && !QFile(FoldButtonHover).exists()) { + itemPicsLeft << "FoldButtonHover = "+FoldButtonHover; + FoldButtonHover = getFallBackFieldContent("FoldButtonHover", 1); + } - if(FoldButtonChecked == "") { FoldButtonChecked = getFallBackFieldContent("FoldButtonChecked", 1); leftItems << "FoldButtonChecked"; } - else if(FoldButtonChecked != QString(currentDir+"NULL") && !QFile(FoldButtonChecked).exists()) { itemPicsLeft << "FoldButtonChecked = "+FoldButtonChecked; FoldButtonChecked = getFallBackFieldContent("FoldButtonChecked", 1); } + if(FoldButtonChecked == "") { + FoldButtonChecked = getFallBackFieldContent("FoldButtonChecked", 1); + leftItems << "FoldButtonChecked"; + } else if(FoldButtonChecked != QString(currentDir+"NULL") && !QFile(FoldButtonChecked).exists()) { + itemPicsLeft << "FoldButtonChecked = "+FoldButtonChecked; + FoldButtonChecked = getFallBackFieldContent("FoldButtonChecked", 1); + } - if(FoldButtonCheckedHover == "") { FoldButtonCheckedHover = getFallBackFieldContent("FoldButtonCheckedHover", 1); leftItems << "FoldButtonCheckedHover"; } - else if(FoldButtonCheckedHover != QString(currentDir+"NULL") && !QFile(FoldButtonCheckedHover).exists()) { itemPicsLeft << "FoldButtonCheckedHover = "+FoldButtonCheckedHover; FoldButtonCheckedHover = getFallBackFieldContent("FoldButtonCheckedHover", 1); } + if(FoldButtonCheckedHover == "") { + FoldButtonCheckedHover = getFallBackFieldContent("FoldButtonCheckedHover", 1); + leftItems << "FoldButtonCheckedHover"; + } else if(FoldButtonCheckedHover != QString(currentDir+"NULL") && !QFile(FoldButtonCheckedHover).exists()) { + itemPicsLeft << "FoldButtonCheckedHover = "+FoldButtonCheckedHover; + FoldButtonCheckedHover = getFallBackFieldContent("FoldButtonCheckedHover", 1); + } - if(CheckCallButtonDefault == "") { CheckCallButtonDefault = getFallBackFieldContent("CheckCallButtonDefault", 1); leftItems << "CheckCallButtonDefault"; } - else if(CheckCallButtonDefault != QString(currentDir+"NULL") && !QFile(CheckCallButtonDefault).exists()) { itemPicsLeft << "CheckCallButtonDefault = "+CheckCallButtonDefault; CheckCallButtonDefault = getFallBackFieldContent("CheckCallButtonDefault", 1); } + if(CheckCallButtonDefault == "") { + CheckCallButtonDefault = getFallBackFieldContent("CheckCallButtonDefault", 1); + leftItems << "CheckCallButtonDefault"; + } else if(CheckCallButtonDefault != QString(currentDir+"NULL") && !QFile(CheckCallButtonDefault).exists()) { + itemPicsLeft << "CheckCallButtonDefault = "+CheckCallButtonDefault; + CheckCallButtonDefault = getFallBackFieldContent("CheckCallButtonDefault", 1); + } - if(CheckCallButtonHover == "") { CheckCallButtonHover = getFallBackFieldContent("CheckCallButtonHover", 1); leftItems << "CheckCallButtonHover"; } - else if(CheckCallButtonHover != QString(currentDir+"NULL") && !QFile(CheckCallButtonHover).exists()) { itemPicsLeft << "CheckCallButtonHover = "+CheckCallButtonHover; CheckCallButtonHover = getFallBackFieldContent("CheckCallButtonHover", 1); } + if(CheckCallButtonHover == "") { + CheckCallButtonHover = getFallBackFieldContent("CheckCallButtonHover", 1); + leftItems << "CheckCallButtonHover"; + } else if(CheckCallButtonHover != QString(currentDir+"NULL") && !QFile(CheckCallButtonHover).exists()) { + itemPicsLeft << "CheckCallButtonHover = "+CheckCallButtonHover; + CheckCallButtonHover = getFallBackFieldContent("CheckCallButtonHover", 1); + } - if(CheckCallButtonChecked == "") { CheckCallButtonChecked = getFallBackFieldContent("CheckCallButtonChecked", 1); leftItems << "CheckCallButtonChecked"; } - else if(CheckCallButtonChecked != QString(currentDir+"NULL") && !QFile(CheckCallButtonChecked).exists()) { itemPicsLeft << "CheckCallButtonChecked = "+CheckCallButtonChecked; CheckCallButtonChecked = getFallBackFieldContent("CheckCallButtonChecked", 1); } + if(CheckCallButtonChecked == "") { + CheckCallButtonChecked = getFallBackFieldContent("CheckCallButtonChecked", 1); + leftItems << "CheckCallButtonChecked"; + } else if(CheckCallButtonChecked != QString(currentDir+"NULL") && !QFile(CheckCallButtonChecked).exists()) { + itemPicsLeft << "CheckCallButtonChecked = "+CheckCallButtonChecked; + CheckCallButtonChecked = getFallBackFieldContent("CheckCallButtonChecked", 1); + } - if(CheckCallButtonCheckedHover == "") { CheckCallButtonCheckedHover = getFallBackFieldContent("CheckCallButtonCheckedHover", 1); leftItems << "CheckCallButtonCheckedHover"; } - else if(CheckCallButtonCheckedHover != QString(currentDir+"NULL") && !QFile(CheckCallButtonCheckedHover).exists()) { itemPicsLeft << "CheckCallButtonCheckedHover = "+CheckCallButtonCheckedHover; CheckCallButtonCheckedHover = getFallBackFieldContent("CheckCallButtonCheckedHover", 1); } + if(CheckCallButtonCheckedHover == "") { + CheckCallButtonCheckedHover = getFallBackFieldContent("CheckCallButtonCheckedHover", 1); + leftItems << "CheckCallButtonCheckedHover"; + } else if(CheckCallButtonCheckedHover != QString(currentDir+"NULL") && !QFile(CheckCallButtonCheckedHover).exists()) { + itemPicsLeft << "CheckCallButtonCheckedHover = "+CheckCallButtonCheckedHover; + CheckCallButtonCheckedHover = getFallBackFieldContent("CheckCallButtonCheckedHover", 1); + } - if(BetRaiseButtonDefault == "") { BetRaiseButtonDefault = getFallBackFieldContent("BetRaiseButtonDefault", 1); leftItems << "BetRaiseButtonDefault"; } - else if(BetRaiseButtonDefault != QString(currentDir+"NULL") && !QFile(BetRaiseButtonDefault).exists()) { itemPicsLeft << "BetRaiseButtonDefault = "+BetRaiseButtonDefault; BetRaiseButtonDefault = getFallBackFieldContent("BetRaiseButtonDefault", 1); } + if(BetRaiseButtonDefault == "") { + BetRaiseButtonDefault = getFallBackFieldContent("BetRaiseButtonDefault", 1); + leftItems << "BetRaiseButtonDefault"; + } else if(BetRaiseButtonDefault != QString(currentDir+"NULL") && !QFile(BetRaiseButtonDefault).exists()) { + itemPicsLeft << "BetRaiseButtonDefault = "+BetRaiseButtonDefault; + BetRaiseButtonDefault = getFallBackFieldContent("BetRaiseButtonDefault", 1); + } - if(BetRaiseButtonHover == "") { BetRaiseButtonHover = getFallBackFieldContent("BetRaiseButtonHover", 1); leftItems << "BetRaiseButtonHover"; } - else if(BetRaiseButtonHover != QString(currentDir+"NULL") && !QFile(BetRaiseButtonHover).exists()) { itemPicsLeft << "BetRaiseButtonHover = "+BetRaiseButtonHover; BetRaiseButtonHover = getFallBackFieldContent("BetRaiseButtonHover", 1); } + if(BetRaiseButtonHover == "") { + BetRaiseButtonHover = getFallBackFieldContent("BetRaiseButtonHover", 1); + leftItems << "BetRaiseButtonHover"; + } else if(BetRaiseButtonHover != QString(currentDir+"NULL") && !QFile(BetRaiseButtonHover).exists()) { + itemPicsLeft << "BetRaiseButtonHover = "+BetRaiseButtonHover; + BetRaiseButtonHover = getFallBackFieldContent("BetRaiseButtonHover", 1); + } - if(BetRaiseButtonChecked == "") { BetRaiseButtonChecked = getFallBackFieldContent("BetRaiseButtonChecked", 1); leftItems << "BetRaiseButtonChecked"; } - else if(BetRaiseButtonChecked != QString(currentDir+"NULL") && !QFile(BetRaiseButtonChecked).exists()) { itemPicsLeft << "BetRaiseButtonChecked = "+BetRaiseButtonChecked; BetRaiseButtonChecked = getFallBackFieldContent("BetRaiseButtonChecked", 1); } + if(BetRaiseButtonChecked == "") { + BetRaiseButtonChecked = getFallBackFieldContent("BetRaiseButtonChecked", 1); + leftItems << "BetRaiseButtonChecked"; + } else if(BetRaiseButtonChecked != QString(currentDir+"NULL") && !QFile(BetRaiseButtonChecked).exists()) { + itemPicsLeft << "BetRaiseButtonChecked = "+BetRaiseButtonChecked; + BetRaiseButtonChecked = getFallBackFieldContent("BetRaiseButtonChecked", 1); + } - if(BetRaiseButtonCheckedHover == "") { BetRaiseButtonCheckedHover = getFallBackFieldContent("BetRaiseButtonCheckedHover", 1); leftItems << "BetRaiseButtonCheckedHover"; } - else if(BetRaiseButtonCheckedHover != QString(currentDir+"NULL") && !QFile(BetRaiseButtonCheckedHover).exists()) { itemPicsLeft << "BetRaiseButtonCheckedHover = "+BetRaiseButtonCheckedHover; BetRaiseButtonCheckedHover = getFallBackFieldContent("BetRaiseButtonCheckedHover", 1); } + if(BetRaiseButtonCheckedHover == "") { + BetRaiseButtonCheckedHover = getFallBackFieldContent("BetRaiseButtonCheckedHover", 1); + leftItems << "BetRaiseButtonCheckedHover"; + } else if(BetRaiseButtonCheckedHover != QString(currentDir+"NULL") && !QFile(BetRaiseButtonCheckedHover).exists()) { + itemPicsLeft << "BetRaiseButtonCheckedHover = "+BetRaiseButtonCheckedHover; + BetRaiseButtonCheckedHover = getFallBackFieldContent("BetRaiseButtonCheckedHover", 1); + } - if(AllInButtonDefault == "") { AllInButtonDefault = getFallBackFieldContent("AllInButtonDefault", 1); leftItems << "AllInButtonDefault"; } - else if(AllInButtonDefault != QString(currentDir+"NULL") && !QFile(AllInButtonDefault).exists()) { itemPicsLeft << "AllInButtonDefault = "+AllInButtonDefault; AllInButtonDefault = getFallBackFieldContent("AllInButtonDefault", 1); } + if(AllInButtonDefault == "") { + AllInButtonDefault = getFallBackFieldContent("AllInButtonDefault", 1); + leftItems << "AllInButtonDefault"; + } else if(AllInButtonDefault != QString(currentDir+"NULL") && !QFile(AllInButtonDefault).exists()) { + itemPicsLeft << "AllInButtonDefault = "+AllInButtonDefault; + AllInButtonDefault = getFallBackFieldContent("AllInButtonDefault", 1); + } - if(AllInButtonHover == "") { AllInButtonHover = getFallBackFieldContent("AllInButtonHover", 1); leftItems << "AllInButtonHover"; } - else if(AllInButtonHover != QString(currentDir+"NULL") && !QFile(AllInButtonHover).exists()) { itemPicsLeft << "AllInButtonHover = "+AllInButtonHover; AllInButtonHover = getFallBackFieldContent("AllInButtonHover", 1); } + if(AllInButtonHover == "") { + AllInButtonHover = getFallBackFieldContent("AllInButtonHover", 1); + leftItems << "AllInButtonHover"; + } else if(AllInButtonHover != QString(currentDir+"NULL") && !QFile(AllInButtonHover).exists()) { + itemPicsLeft << "AllInButtonHover = "+AllInButtonHover; + AllInButtonHover = getFallBackFieldContent("AllInButtonHover", 1); + } - if(AllInButtonChecked == "") { AllInButtonChecked = getFallBackFieldContent("AllInButtonChecked", 1); leftItems << "AllInButtonChecked"; } - else if(AllInButtonChecked != QString(currentDir+"NULL") && !QFile(AllInButtonChecked).exists()) { itemPicsLeft << "AllInButtonChecked = "+AllInButtonChecked; AllInButtonChecked = getFallBackFieldContent("AllInButtonChecked", 1); } + if(AllInButtonChecked == "") { + AllInButtonChecked = getFallBackFieldContent("AllInButtonChecked", 1); + leftItems << "AllInButtonChecked"; + } else if(AllInButtonChecked != QString(currentDir+"NULL") && !QFile(AllInButtonChecked).exists()) { + itemPicsLeft << "AllInButtonChecked = "+AllInButtonChecked; + AllInButtonChecked = getFallBackFieldContent("AllInButtonChecked", 1); + } - if(AllInButtonCheckedHover == "") { AllInButtonCheckedHover = getFallBackFieldContent("AllInButtonCheckedHover", 1); leftItems << "AllInButtonCheckedHover"; } - else if(AllInButtonCheckedHover != QString(currentDir+"NULL") && !QFile(AllInButtonCheckedHover).exists()) { itemPicsLeft << "AllInButtonCheckedHover = "+AllInButtonCheckedHover; AllInButtonCheckedHover = getFallBackFieldContent("AllInButtonCheckedHover", 1); } + if(AllInButtonCheckedHover == "") { + AllInButtonCheckedHover = getFallBackFieldContent("AllInButtonCheckedHover", 1); + leftItems << "AllInButtonCheckedHover"; + } else if(AllInButtonCheckedHover != QString(currentDir+"NULL") && !QFile(AllInButtonCheckedHover).exists()) { + itemPicsLeft << "AllInButtonCheckedHover = "+AllInButtonCheckedHover; + AllInButtonCheckedHover = getFallBackFieldContent("AllInButtonCheckedHover", 1); + } - if(RadioButtonPressed == "") { RadioButtonPressed = getFallBackFieldContent("RadioButtonPressed", 1); leftItems << "RadioButtonPressed"; } - else if(RadioButtonPressed != QString(currentDir+"NULL") && !QFile(RadioButtonPressed).exists()) { itemPicsLeft << "RadioButtonPressed = "+RadioButtonPressed; RadioButtonPressed = getFallBackFieldContent("RadioButtonPressed", 1); } + if(RadioButtonPressed == "") { + RadioButtonPressed = getFallBackFieldContent("RadioButtonPressed", 1); + leftItems << "RadioButtonPressed"; + } else if(RadioButtonPressed != QString(currentDir+"NULL") && !QFile(RadioButtonPressed).exists()) { + itemPicsLeft << "RadioButtonPressed = "+RadioButtonPressed; + RadioButtonPressed = getFallBackFieldContent("RadioButtonPressed", 1); + } - if(RadioButtonChecked == "") { RadioButtonChecked = getFallBackFieldContent("RadioButtonChecked", 1); leftItems << "RadioButtonChecked"; } - else if(RadioButtonChecked != QString(currentDir+"NULL") && !QFile(RadioButtonChecked).exists()) { itemPicsLeft << "RadioButtonChecked = "+RadioButtonChecked; RadioButtonChecked = getFallBackFieldContent("RadioButtonChecked", 1); } + if(RadioButtonChecked == "") { + RadioButtonChecked = getFallBackFieldContent("RadioButtonChecked", 1); + leftItems << "RadioButtonChecked"; + } else if(RadioButtonChecked != QString(currentDir+"NULL") && !QFile(RadioButtonChecked).exists()) { + itemPicsLeft << "RadioButtonChecked = "+RadioButtonChecked; + RadioButtonChecked = getFallBackFieldContent("RadioButtonChecked", 1); + } - if(RadioButtonCheckedHover == "") { RadioButtonCheckedHover = getFallBackFieldContent("RadioButtonCheckedHover", 1); leftItems << "RadioButtonCheckedHover"; } - else if(RadioButtonCheckedHover != QString(currentDir+"NULL") && !QFile(RadioButtonCheckedHover).exists()) { itemPicsLeft << "RadioButtonCheckedHover = "+RadioButtonCheckedHover; RadioButtonCheckedHover = getFallBackFieldContent("RadioButtonCheckedHover", 1); } + if(RadioButtonCheckedHover == "") { + RadioButtonCheckedHover = getFallBackFieldContent("RadioButtonCheckedHover", 1); + leftItems << "RadioButtonCheckedHover"; + } else if(RadioButtonCheckedHover != QString(currentDir+"NULL") && !QFile(RadioButtonCheckedHover).exists()) { + itemPicsLeft << "RadioButtonCheckedHover = "+RadioButtonCheckedHover; + RadioButtonCheckedHover = getFallBackFieldContent("RadioButtonCheckedHover", 1); + } - if(RadioButtonUnchecked == "") { RadioButtonUnchecked = getFallBackFieldContent("RadioButtonUnchecked", 1); leftItems << "RadioButtonUnchecked"; } - else if(RadioButtonUnchecked != QString(currentDir+"NULL") && !QFile(RadioButtonUnchecked).exists()) { itemPicsLeft << "RadioButtonUnchecked = "+RadioButtonUnchecked; RadioButtonUnchecked = getFallBackFieldContent("RadioButtonUnchecked", 1); } + if(RadioButtonUnchecked == "") { + RadioButtonUnchecked = getFallBackFieldContent("RadioButtonUnchecked", 1); + leftItems << "RadioButtonUnchecked"; + } else if(RadioButtonUnchecked != QString(currentDir+"NULL") && !QFile(RadioButtonUnchecked).exists()) { + itemPicsLeft << "RadioButtonUnchecked = "+RadioButtonUnchecked; + RadioButtonUnchecked = getFallBackFieldContent("RadioButtonUnchecked", 1); + } - if(RadioButtonUncheckedHover == "") { RadioButtonUncheckedHover = getFallBackFieldContent("RadioButtonUncheckedHover", 1); leftItems << "RadioButtonUncheckedHover"; } - else if(RadioButtonUncheckedHover != QString(currentDir+"NULL") && !QFile(RadioButtonUncheckedHover).exists()) { itemPicsLeft << "RadioButtonUncheckedHover = "+RadioButtonUncheckedHover; RadioButtonUncheckedHover = getFallBackFieldContent("RadioButtonUncheckedHover", 1); } + if(RadioButtonUncheckedHover == "") { + RadioButtonUncheckedHover = getFallBackFieldContent("RadioButtonUncheckedHover", 1); + leftItems << "RadioButtonUncheckedHover"; + } else if(RadioButtonUncheckedHover != QString(currentDir+"NULL") && !QFile(RadioButtonUncheckedHover).exists()) { + itemPicsLeft << "RadioButtonUncheckedHover = "+RadioButtonUncheckedHover; + RadioButtonUncheckedHover = getFallBackFieldContent("RadioButtonUncheckedHover", 1); + } - if(PlayerTopSeatActive == "") { PlayerTopSeatActive = getFallBackFieldContent("PlayerTopSeatActive", 1); leftItems << "PlayerTopSeatActive"; } - else if(PlayerTopSeatActive != QString(currentDir+"NULL") && !QFile(PlayerTopSeatActive).exists()) { itemPicsLeft << "PlayerTopSeatActive = "+PlayerTopSeatActive; PlayerTopSeatActive = getFallBackFieldContent("PlayerTopSeatActive", 1); } + if(PlayerTopSeatActive == "") { + PlayerTopSeatActive = getFallBackFieldContent("PlayerTopSeatActive", 1); + leftItems << "PlayerTopSeatActive"; + } else if(PlayerTopSeatActive != QString(currentDir+"NULL") && !QFile(PlayerTopSeatActive).exists()) { + itemPicsLeft << "PlayerTopSeatActive = "+PlayerTopSeatActive; + PlayerTopSeatActive = getFallBackFieldContent("PlayerTopSeatActive", 1); + } - if(PlayerTopSeatInactive == "") { PlayerTopSeatInactive = getFallBackFieldContent("PlayerTopSeatInactive", 1); leftItems << "PlayerTopSeatInactive"; } - else if(PlayerTopSeatInactive != QString(currentDir+"NULL") && !QFile(PlayerTopSeatInactive).exists()) { itemPicsLeft << "PlayerTopSeatInactive = "+PlayerTopSeatInactive; PlayerTopSeatInactive = getFallBackFieldContent("PlayerTopSeatInactive", 1); } + if(PlayerTopSeatInactive == "") { + PlayerTopSeatInactive = getFallBackFieldContent("PlayerTopSeatInactive", 1); + leftItems << "PlayerTopSeatInactive"; + } else if(PlayerTopSeatInactive != QString(currentDir+"NULL") && !QFile(PlayerTopSeatInactive).exists()) { + itemPicsLeft << "PlayerTopSeatInactive = "+PlayerTopSeatInactive; + PlayerTopSeatInactive = getFallBackFieldContent("PlayerTopSeatInactive", 1); + } - if(PlayerBottomSeatActive == "") { PlayerBottomSeatActive = getFallBackFieldContent("PlayerBottomSeatActive", 1); leftItems << "PlayerBottomSeatActive"; } - else if(PlayerBottomSeatActive != QString(currentDir+"NULL") && !QFile(PlayerBottomSeatActive).exists()) { itemPicsLeft << "PlayerBottomSeatActive = "+PlayerBottomSeatActive; PlayerBottomSeatActive = getFallBackFieldContent("PlayerBottomSeatActive", 1); } + if(PlayerBottomSeatActive == "") { + PlayerBottomSeatActive = getFallBackFieldContent("PlayerBottomSeatActive", 1); + leftItems << "PlayerBottomSeatActive"; + } else if(PlayerBottomSeatActive != QString(currentDir+"NULL") && !QFile(PlayerBottomSeatActive).exists()) { + itemPicsLeft << "PlayerBottomSeatActive = "+PlayerBottomSeatActive; + PlayerBottomSeatActive = getFallBackFieldContent("PlayerBottomSeatActive", 1); + } - if(PlayerBottomSeatInactive == "") { PlayerBottomSeatInactive = getFallBackFieldContent("PlayerBottomSeatInactive", 1); leftItems << "PlayerBottomSeatInactive"; } - else if(PlayerBottomSeatInactive != QString(currentDir+"NULL") && !QFile(PlayerBottomSeatInactive).exists()) { itemPicsLeft << "PlayerBottomSeatInactive = "+PlayerBottomSeatInactive; PlayerBottomSeatInactive = getFallBackFieldContent("PlayerBottomSeatInactive", 1); } + if(PlayerBottomSeatInactive == "") { + PlayerBottomSeatInactive = getFallBackFieldContent("PlayerBottomSeatInactive", 1); + leftItems << "PlayerBottomSeatInactive"; + } else if(PlayerBottomSeatInactive != QString(currentDir+"NULL") && !QFile(PlayerBottomSeatInactive).exists()) { + itemPicsLeft << "PlayerBottomSeatInactive = "+PlayerBottomSeatInactive; + PlayerBottomSeatInactive = getFallBackFieldContent("PlayerBottomSeatInactive", 1); + } - if(Table == "") { Table = getFallBackFieldContent("Table", 1); leftItems << "Table"; } - else if(Table != QString(currentDir+"NULL") && !QFile(Table).exists()) { itemPicsLeft << "Table = "+Table; Table = getFallBackFieldContent("Table", 1); } + if(Table == "") { + Table = getFallBackFieldContent("Table", 1); + leftItems << "Table"; + } else if(Table != QString(currentDir+"NULL") && !QFile(Table).exists()) { + itemPicsLeft << "Table = "+Table; + Table = getFallBackFieldContent("Table", 1); + } - if(HandRanking == "") { HandRanking = getFallBackFieldContent("HandRanking", 1); leftItems << "HandRanking"; } - else if(HandRanking != QString(currentDir+"NULL") && !QFile(HandRanking).exists()) { itemPicsLeft << "HandRanking = "+HandRanking; HandRanking = getFallBackFieldContent("HandRanking", 1); } + if(HandRanking == "") { + HandRanking = getFallBackFieldContent("HandRanking", 1); + leftItems << "HandRanking"; + } else if(HandRanking != QString(currentDir+"NULL") && !QFile(HandRanking).exists()) { + itemPicsLeft << "HandRanking = "+HandRanking; + HandRanking = getFallBackFieldContent("HandRanking", 1); + } - if(ToolBoxBackground == "") { ToolBoxBackground = getFallBackFieldContent("ToolBoxBackground", 1); leftItems << "ToolBoxBackground"; } - else if(ToolBoxBackground != QString(currentDir+"NULL") && !QFile(ToolBoxBackground).exists()) { itemPicsLeft << "ToolBoxBackground = "+ToolBoxBackground; ToolBoxBackground = getFallBackFieldContent("ToolBoxBackground", 1); } + if(ToolBoxBackground == "") { + ToolBoxBackground = getFallBackFieldContent("ToolBoxBackground", 1); + leftItems << "ToolBoxBackground"; + } else if(ToolBoxBackground != QString(currentDir+"NULL") && !QFile(ToolBoxBackground).exists()) { + itemPicsLeft << "ToolBoxBackground = "+ToolBoxBackground; + ToolBoxBackground = getFallBackFieldContent("ToolBoxBackground", 1); + } - if(ShowMyCardsButtonDefault == "") { ShowMyCardsButtonDefault = getFallBackFieldContent("ShowMyCardsButtonDefault", 1); leftItems << "ShowMyCardsButtonDefault"; } - else if(ShowMyCardsButtonDefault != QString(currentDir+"NULL") && !QFile(ShowMyCardsButtonDefault).exists()) { itemPicsLeft << "ShowMyCardsButtonDefault = "+ShowMyCardsButtonDefault; ShowMyCardsButtonDefault = getFallBackFieldContent("ShowMyCardsButtonDefault", 1); } + if(ShowMyCardsButtonDefault == "") { + ShowMyCardsButtonDefault = getFallBackFieldContent("ShowMyCardsButtonDefault", 1); + leftItems << "ShowMyCardsButtonDefault"; + } else if(ShowMyCardsButtonDefault != QString(currentDir+"NULL") && !QFile(ShowMyCardsButtonDefault).exists()) { + itemPicsLeft << "ShowMyCardsButtonDefault = "+ShowMyCardsButtonDefault; + ShowMyCardsButtonDefault = getFallBackFieldContent("ShowMyCardsButtonDefault", 1); + } - if(ShowMyCardsButtonHover == "") { ShowMyCardsButtonHover = getFallBackFieldContent("ShowMyCardsButtonHover", 1); leftItems << "ShowMyCardsButtonHover"; } - else if(ShowMyCardsButtonHover != QString(currentDir+"NULL") && !QFile(ShowMyCardsButtonHover).exists()) { itemPicsLeft << "ShowMyCardsButtonHover = "+ShowMyCardsButtonHover; ShowMyCardsButtonHover = getFallBackFieldContent("ShowMyCardsButtonHover", 1); } + if(ShowMyCardsButtonHover == "") { + ShowMyCardsButtonHover = getFallBackFieldContent("ShowMyCardsButtonHover", 1); + leftItems << "ShowMyCardsButtonHover"; + } else if(ShowMyCardsButtonHover != QString(currentDir+"NULL") && !QFile(ShowMyCardsButtonHover).exists()) { + itemPicsLeft << "ShowMyCardsButtonHover = "+ShowMyCardsButtonHover; + ShowMyCardsButtonHover = getFallBackFieldContent("ShowMyCardsButtonHover", 1); + } - //I18N ACTION STRINGS - if(ActionAllInI18NString == "") { ActionAllInI18NString = "NULL"; leftItems << "ActionAllInI18NString"; } - if(ActionRaiseI18NString == "") { ActionRaiseI18NString = "NULL"; leftItems << "ActionRaiseI18NString"; } - if(ActionBetI18NString == "") { ActionBetI18NString = "NULL"; leftItems << "ActionBetI18NString"; } - if(ActionCallI18NString == "") { ActionCallI18NString = "NULL"; leftItems << "ActionCallI18NString"; } - if(ActionCheckI18NString == "") { ActionCheckI18NString = "NULL"; leftItems << "ActionCheckI18NString"; } - if(ActionFoldI18NString == "") { ActionFoldI18NString = "NULL"; leftItems << "ActionFoldI18NString"; } - if(PotI18NString == "") { PotI18NString = "NULL"; leftItems << "PotI18NString"; } - if(TotalI18NString == "") { TotalI18NString = "NULL"; leftItems << "TotalI18NString"; } - if(BetsI18NString == "") { BetsI18NString = "NULL"; leftItems << "BetsI18NString"; } - if(GameI18NString == "") { GameI18NString = "NULL"; leftItems << "GameI18NString"; } - if(HandI18NString == "") { HandI18NString = "NULL"; leftItems << "HandI18NString"; } - if(PreflopI18NString == "") { PreflopI18NString = "NULL"; leftItems << "PreflopI18NString"; } - if(FlopI18NString == "") { FlopI18NString = "NULL"; leftItems << "FlopI18NString"; } - if(TurnI18NString == "") { TurnI18NString = "NULL"; leftItems << "TurnI18NString"; } - if(RiverI18NString == "") { RiverI18NString = "NULL"; leftItems << "RiverI18NString"; } + //I18N ACTION STRINGS + if(ActionAllInI18NString == "") { + ActionAllInI18NString = "NULL"; + leftItems << "ActionAllInI18NString"; + } + if(ActionRaiseI18NString == "") { + ActionRaiseI18NString = "NULL"; + leftItems << "ActionRaiseI18NString"; + } + if(ActionBetI18NString == "") { + ActionBetI18NString = "NULL"; + leftItems << "ActionBetI18NString"; + } + if(ActionCallI18NString == "") { + ActionCallI18NString = "NULL"; + leftItems << "ActionCallI18NString"; + } + if(ActionCheckI18NString == "") { + ActionCheckI18NString = "NULL"; + leftItems << "ActionCheckI18NString"; + } + if(ActionFoldI18NString == "") { + ActionFoldI18NString = "NULL"; + leftItems << "ActionFoldI18NString"; + } + if(PotI18NString == "") { + PotI18NString = "NULL"; + leftItems << "PotI18NString"; + } + if(TotalI18NString == "") { + TotalI18NString = "NULL"; + leftItems << "TotalI18NString"; + } + if(BetsI18NString == "") { + BetsI18NString = "NULL"; + leftItems << "BetsI18NString"; + } + if(GameI18NString == "") { + GameI18NString = "NULL"; + leftItems << "GameI18NString"; + } + if(HandI18NString == "") { + HandI18NString = "NULL"; + leftItems << "HandI18NString"; + } + if(PreflopI18NString == "") { + PreflopI18NString = "NULL"; + leftItems << "PreflopI18NString"; + } + if(FlopI18NString == "") { + FlopI18NString = "NULL"; + leftItems << "FlopI18NString"; + } + if(TurnI18NString == "") { + TurnI18NString = "NULL"; + leftItems << "TurnI18NString"; + } + if(RiverI18NString == "") { + RiverI18NString = "NULL"; + leftItems << "RiverI18NString"; + } - // COLORS - if(FKeyIndicatorColor == "") { FKeyIndicatorColor = getFallBackFieldContent("FKeyIndicatorColor", 0); leftItems << "FKeyIndicatorColor"; } - if(ChanceLabelPossibleColor == "") { ChanceLabelPossibleColor = getFallBackFieldContent("ChanceLabelPossibleColor", 0); leftItems << "ChanceLabelPossibleColor"; } - if(ChanceLabelImpossibleColor == "") { ChanceLabelImpossibleColor = getFallBackFieldContent("ChanceLabelImpossibleColor", 0); leftItems << "ChanceLabelImpossibleColor"; } - if(ChatLogTextColor == "") { ChatLogTextColor = getFallBackFieldContent("ChatLogTextColor", 0); leftItems << "ChatLogTextColor"; } - if(ChatTextNickNotifyColor == "") { ChatTextNickNotifyColor = getFallBackFieldContent("ChatTextNickNotifyColor", 0); leftItems << "ChatTextNickNotifyColor"; } - if(ChatLogBgColor == "") { ChatLogBgColor = getFallBackFieldContent("ChatLogBgColor", 0); leftItems << "ChatLogBgColor"; } - if(ChatLogScrollBarBorderColor == "") { ChatLogScrollBarBorderColor = getFallBackFieldContent("ChatLogScrollBarBorderColor", 0); leftItems << "ChatLogScrollBarBorderColor"; } - if(ChatLogScrollBarBgColor == "") { ChatLogScrollBarBgColor = getFallBackFieldContent("ChatLogScrollBarBgColor", 0); leftItems << "ChatLogScrollBarBgColor"; } - if(ChatLogScrollBarHandleBorderColor == "") { ChatLogScrollBarHandleBorderColor = getFallBackFieldContent("ChatLogScrollBarHandleBorderColor", 0); leftItems << "ChatLogScrollBarHandleBorderColor"; } - if(ChatLogScrollBarHandleBgColor == "") { ChatLogScrollBarHandleBgColor = getFallBackFieldContent("ChatLogScrollBarHandleBgColor", 0); leftItems << "ChatLogScrollBarHandleBgColor"; } - if(ChatLogScrollBarArrowBorderColor == "") { ChatLogScrollBarArrowBorderColor = getFallBackFieldContent("ChatLogScrollBarArrowBorderColor", 0); leftItems << "ChatLogScrollBarArrowBorderColor"; } - if(ChatLogScrollBarArrowBgColor == "") { ChatLogScrollBarArrowBgColor = getFallBackFieldContent("ChatLogScrollBarArrowBgColor", 0); leftItems << "ChatLogScrollBarArrowBgColor"; } - if(LogWinnerMainPotColor == "") { LogWinnerMainPotColor = getFallBackFieldContent("LogWinnerMainPotColor", 0); leftItems << "LogWinnerMainPotColor"; } - if(LogWinnerSidePotColor == "") { LogWinnerSidePotColor = getFallBackFieldContent("LogWinnerSidePotColor", 0); leftItems << "LogWinnerSidePotColor"; } - if(LogPlayerSitsOutColor == "") { LogPlayerSitsOutColor = getFallBackFieldContent("LogPlayerSitsOutColor", 0); leftItems << "LogPlayerSitsOutColor"; } - if(LogNewGameAdminColor == "") { LogNewGameAdminColor = getFallBackFieldContent("LogNewGameAdminColor", 0); leftItems << "LogNewGameAdminColor"; } - if(TabWidgetBorderColor == "") { TabWidgetBorderColor = getFallBackFieldContent("TabWidgetBorderColor", 0); leftItems << "TabWidgetBorderColor"; } - if(TabWidgetBgColor == "") { TabWidgetBgColor = getFallBackFieldContent("TabWidgetBgColor", 0); leftItems << "TabWidgetBgColor"; } - if(TabWidgetTextColor == "") { TabWidgetTextColor = getFallBackFieldContent("TabWidgetTextColor", 0); leftItems << "TabWidgetTextColor"; } - if(MenuBgColor == "") { MenuBgColor = getFallBackFieldContent("MenuBgColor", 0); leftItems << "MenuBgColor"; } - if(MenuTextColor == "") { MenuTextColor = getFallBackFieldContent("MenuTextColor", 0); leftItems << "MenuTextColor"; } - if(BreakLobbyButtonBgColor == "") { BreakLobbyButtonBgColor = getFallBackFieldContent("BreakLobbyButtonBgColor", 0); leftItems << "BreakLobbyButtonBgColor"; } - if(BreakLobbyButtonTextColor == "") { BreakLobbyButtonTextColor = getFallBackFieldContent("BreakLobbyButtonTextColor", 0); leftItems << "BreakLobbyButtonTextColor"; } - if(BreakLobbyButtonBgDisabledColor == "") { BreakLobbyButtonBgDisabledColor = getFallBackFieldContent("BreakLobbyButtonBgDisabledColor", 0); leftItems << "BreakLobbyButtonBgDisabledColor"; } - if(BreakLobbyButtonTextDisabledColor == "") { BreakLobbyButtonTextDisabledColor = getFallBackFieldContent("BreakLobbyButtonTextDisabledColor", 0); leftItems << "BreakLobbyButtonTextDisabledColor"; } - if(BreakLobbyButtonBgBlinkColor == "") { BreakLobbyButtonBgBlinkColor = getFallBackFieldContent("BreakLobbyButtonBgBlinkColor", 0); leftItems << "BreakLobbyButtonBgBlinkColor"; } - if(BreakLobbyButtonTextBlinkColor == "") { BreakLobbyButtonTextBlinkColor = getFallBackFieldContent("BreakLobbyButtonTextBlinkColor", 0); leftItems << "BreakLobbyButtonTextBlinkColor"; } - if(PlayerCashTextColor == "") { PlayerCashTextColor = getFallBackFieldContent("PlayerCashTextColor", 0); leftItems << "PlayerCashTextColor"; } - if(PlayerBetTextColor == "") { PlayerBetTextColor = getFallBackFieldContent("PlayerBetTextColor", 0); leftItems << "PlayerBetTextColor"; } - if(PlayerNickTextColor == "") { PlayerNickTextColor = getFallBackFieldContent("PlayerNickTextColor", 0); leftItems << "PlayerNickTextColor"; } - if(BoardBigTextColor == "") { BoardBigTextColor = getFallBackFieldContent("BoardBigTextColor", 0); leftItems << "BoardBigTextColor"; } - if(BoardSmallTextColor == "") { BoardSmallTextColor = getFallBackFieldContent("BoardSmallTextColor", 0); leftItems << "BoardSmallTextColor"; } - if(SpeedTextColor == "") { SpeedTextColor = getFallBackFieldContent("SpeedTextColor", 0); leftItems << "SpeedTextColor"; } - if(VoteButtonBgColor == "") { VoteButtonBgColor = getFallBackFieldContent("VoteButtonBgColor", 0); leftItems << "VoteButtonBgColor"; } - if(VoteButtonTextColor == "") { VoteButtonTextColor = getFallBackFieldContent("VoteButtonTextColor", 0); leftItems << "VoteButtonTextColor"; } - if(BetInputTextColor == "") { BetInputTextColor = getFallBackFieldContent("BetInputTextColor", 0); leftItems << "BetInputTextColor"; } - if(BetInputBgColor == "") { BetInputBgColor = getFallBackFieldContent("BetInputBgColor", 0); leftItems << "BetInputBgColor"; } - if(BetInputDisabledTextColor == "") { BetInputDisabledTextColor = getFallBackFieldContent("BetInputDisabledTextColor", 0); leftItems << "BetInputDisabledTextColor"; } - if(BetInputDisabledBgColor == "") { BetInputDisabledBgColor = getFallBackFieldContent("BetInputDisabledBgColor", 0); leftItems << "BetInputDisabledBgColor"; } - if(FoldButtonTextColor == "") { FoldButtonTextColor = getFallBackFieldContent("FoldButtonTextColor", 0); leftItems << "FoldButtonTextColor"; } - if(FoldButtonCheckableTextColor == "") { FoldButtonCheckableTextColor = getFallBackFieldContent("FoldButtonCheckableTextColor", 0); leftItems << "FoldButtonCheckableTextColor"; } - if(CheckCallButtonTextColor == "") { CheckCallButtonTextColor = getFallBackFieldContent("CheckCallButtonTextColor", 0); leftItems << "CheckCallButtonTextColor"; } - if(CheckCallButtonCheckableTextColor == "") { CheckCallButtonCheckableTextColor = getFallBackFieldContent("CheckCallButtonCheckableTextColor", 0); leftItems << "CheckCallButtonCheckableTextColor"; } - if(BetRaiseButtonTextColor == "") { BetRaiseButtonTextColor = getFallBackFieldContent("BetRaiseButtonTextColor", 0); leftItems << "BetRaiseButtonTextColor"; } - if(BetRaiseButtonCheckableTextColor == "") { BetRaiseButtonCheckableTextColor = getFallBackFieldContent("BetRaiseButtonCheckableTextColor", 0); leftItems << "BetRaiseButtonCheckableTextColor"; } - if(AllInButtonTextColor == "") { AllInButtonTextColor = getFallBackFieldContent("AllInButtonTextColor", 0); leftItems << "AllInButtonTextColor"; } - if(AllInButtonCheckableTextColor == "") { AllInButtonCheckableTextColor = getFallBackFieldContent("AllInButtonCheckableTextColor", 0); leftItems << "AllInButtonCheckableTextColor"; } - if(BetSpeedSliderGrooveBgColor == "") { BetSpeedSliderGrooveBgColor = getFallBackFieldContent("BetSpeedSliderGrooveBgColor", 0); leftItems << "BetSpeedSliderGrooveBgColor"; } - if(BetSpeedSliderGrooveBorderColor == "") { BetSpeedSliderGrooveBorderColor = getFallBackFieldContent("BetSpeedSliderGrooveBorderColor", 0); leftItems << "BetSpeedSliderGrooveBorderColor"; } - if(BetSpeedSliderHandleBgColor == "") { BetSpeedSliderHandleBgColor = getFallBackFieldContent("BetSpeedSliderHandleBgColor", 0); leftItems << "BetSpeedSliderHandleBgColor"; } - if(BetSpeedSliderHandleBorderColor == "") { BetSpeedSliderHandleBorderColor = getFallBackFieldContent("BetSpeedSliderHandleBorderColor", 0); leftItems << "BetSpeedSliderHandleBorderColor"; } - if(ShowMyCardsButtonTextColor == "") { ShowMyCardsButtonTextColor = getFallBackFieldContent("ShowMyCardsButtonTextColor", 0); leftItems << "ShowMyCardsButtonTextColor"; } - if(RatingStarsColor == "") { RatingStarsColor = getFallBackFieldContent("RatingStarsColor", 0); leftItems << "RatingStarsColor"; } - if(PlayerInfoHintTextColor == "") { PlayerInfoHintTextColor = getFallBackFieldContent("PlayerInfoHintTextColor", 0); leftItems << "PlayerInfoHintTextColor"; } + // COLORS + if(FKeyIndicatorColor == "") { + FKeyIndicatorColor = getFallBackFieldContent("FKeyIndicatorColor", 0); + leftItems << "FKeyIndicatorColor"; + } + if(ChanceLabelPossibleColor == "") { + ChanceLabelPossibleColor = getFallBackFieldContent("ChanceLabelPossibleColor", 0); + leftItems << "ChanceLabelPossibleColor"; + } + if(ChanceLabelImpossibleColor == "") { + ChanceLabelImpossibleColor = getFallBackFieldContent("ChanceLabelImpossibleColor", 0); + leftItems << "ChanceLabelImpossibleColor"; + } + if(ChatLogTextColor == "") { + ChatLogTextColor = getFallBackFieldContent("ChatLogTextColor", 0); + leftItems << "ChatLogTextColor"; + } + if(ChatTextNickNotifyColor == "") { + ChatTextNickNotifyColor = getFallBackFieldContent("ChatTextNickNotifyColor", 0); + leftItems << "ChatTextNickNotifyColor"; + } + if(ChatLogBgColor == "") { + ChatLogBgColor = getFallBackFieldContent("ChatLogBgColor", 0); + leftItems << "ChatLogBgColor"; + } + if(ChatLogScrollBarBorderColor == "") { + ChatLogScrollBarBorderColor = getFallBackFieldContent("ChatLogScrollBarBorderColor", 0); + leftItems << "ChatLogScrollBarBorderColor"; + } + if(ChatLogScrollBarBgColor == "") { + ChatLogScrollBarBgColor = getFallBackFieldContent("ChatLogScrollBarBgColor", 0); + leftItems << "ChatLogScrollBarBgColor"; + } + if(ChatLogScrollBarHandleBorderColor == "") { + ChatLogScrollBarHandleBorderColor = getFallBackFieldContent("ChatLogScrollBarHandleBorderColor", 0); + leftItems << "ChatLogScrollBarHandleBorderColor"; + } + if(ChatLogScrollBarHandleBgColor == "") { + ChatLogScrollBarHandleBgColor = getFallBackFieldContent("ChatLogScrollBarHandleBgColor", 0); + leftItems << "ChatLogScrollBarHandleBgColor"; + } + if(ChatLogScrollBarArrowBorderColor == "") { + ChatLogScrollBarArrowBorderColor = getFallBackFieldContent("ChatLogScrollBarArrowBorderColor", 0); + leftItems << "ChatLogScrollBarArrowBorderColor"; + } + if(ChatLogScrollBarArrowBgColor == "") { + ChatLogScrollBarArrowBgColor = getFallBackFieldContent("ChatLogScrollBarArrowBgColor", 0); + leftItems << "ChatLogScrollBarArrowBgColor"; + } + if(LogWinnerMainPotColor == "") { + LogWinnerMainPotColor = getFallBackFieldContent("LogWinnerMainPotColor", 0); + leftItems << "LogWinnerMainPotColor"; + } + if(LogWinnerSidePotColor == "") { + LogWinnerSidePotColor = getFallBackFieldContent("LogWinnerSidePotColor", 0); + leftItems << "LogWinnerSidePotColor"; + } + if(LogPlayerSitsOutColor == "") { + LogPlayerSitsOutColor = getFallBackFieldContent("LogPlayerSitsOutColor", 0); + leftItems << "LogPlayerSitsOutColor"; + } + if(LogNewGameAdminColor == "") { + LogNewGameAdminColor = getFallBackFieldContent("LogNewGameAdminColor", 0); + leftItems << "LogNewGameAdminColor"; + } + if(TabWidgetBorderColor == "") { + TabWidgetBorderColor = getFallBackFieldContent("TabWidgetBorderColor", 0); + leftItems << "TabWidgetBorderColor"; + } + if(TabWidgetBgColor == "") { + TabWidgetBgColor = getFallBackFieldContent("TabWidgetBgColor", 0); + leftItems << "TabWidgetBgColor"; + } + if(TabWidgetTextColor == "") { + TabWidgetTextColor = getFallBackFieldContent("TabWidgetTextColor", 0); + leftItems << "TabWidgetTextColor"; + } + if(MenuBgColor == "") { + MenuBgColor = getFallBackFieldContent("MenuBgColor", 0); + leftItems << "MenuBgColor"; + } + if(MenuTextColor == "") { + MenuTextColor = getFallBackFieldContent("MenuTextColor", 0); + leftItems << "MenuTextColor"; + } + if(BreakLobbyButtonBgColor == "") { + BreakLobbyButtonBgColor = getFallBackFieldContent("BreakLobbyButtonBgColor", 0); + leftItems << "BreakLobbyButtonBgColor"; + } + if(BreakLobbyButtonTextColor == "") { + BreakLobbyButtonTextColor = getFallBackFieldContent("BreakLobbyButtonTextColor", 0); + leftItems << "BreakLobbyButtonTextColor"; + } + if(BreakLobbyButtonBgDisabledColor == "") { + BreakLobbyButtonBgDisabledColor = getFallBackFieldContent("BreakLobbyButtonBgDisabledColor", 0); + leftItems << "BreakLobbyButtonBgDisabledColor"; + } + if(BreakLobbyButtonTextDisabledColor == "") { + BreakLobbyButtonTextDisabledColor = getFallBackFieldContent("BreakLobbyButtonTextDisabledColor", 0); + leftItems << "BreakLobbyButtonTextDisabledColor"; + } + if(BreakLobbyButtonBgBlinkColor == "") { + BreakLobbyButtonBgBlinkColor = getFallBackFieldContent("BreakLobbyButtonBgBlinkColor", 0); + leftItems << "BreakLobbyButtonBgBlinkColor"; + } + if(BreakLobbyButtonTextBlinkColor == "") { + BreakLobbyButtonTextBlinkColor = getFallBackFieldContent("BreakLobbyButtonTextBlinkColor", 0); + leftItems << "BreakLobbyButtonTextBlinkColor"; + } + if(PlayerCashTextColor == "") { + PlayerCashTextColor = getFallBackFieldContent("PlayerCashTextColor", 0); + leftItems << "PlayerCashTextColor"; + } + if(PlayerBetTextColor == "") { + PlayerBetTextColor = getFallBackFieldContent("PlayerBetTextColor", 0); + leftItems << "PlayerBetTextColor"; + } + if(PlayerNickTextColor == "") { + PlayerNickTextColor = getFallBackFieldContent("PlayerNickTextColor", 0); + leftItems << "PlayerNickTextColor"; + } + if(BoardBigTextColor == "") { + BoardBigTextColor = getFallBackFieldContent("BoardBigTextColor", 0); + leftItems << "BoardBigTextColor"; + } + if(BoardSmallTextColor == "") { + BoardSmallTextColor = getFallBackFieldContent("BoardSmallTextColor", 0); + leftItems << "BoardSmallTextColor"; + } + if(SpeedTextColor == "") { + SpeedTextColor = getFallBackFieldContent("SpeedTextColor", 0); + leftItems << "SpeedTextColor"; + } + if(VoteButtonBgColor == "") { + VoteButtonBgColor = getFallBackFieldContent("VoteButtonBgColor", 0); + leftItems << "VoteButtonBgColor"; + } + if(VoteButtonTextColor == "") { + VoteButtonTextColor = getFallBackFieldContent("VoteButtonTextColor", 0); + leftItems << "VoteButtonTextColor"; + } + if(BetInputTextColor == "") { + BetInputTextColor = getFallBackFieldContent("BetInputTextColor", 0); + leftItems << "BetInputTextColor"; + } + if(BetInputBgColor == "") { + BetInputBgColor = getFallBackFieldContent("BetInputBgColor", 0); + leftItems << "BetInputBgColor"; + } + if(BetInputDisabledTextColor == "") { + BetInputDisabledTextColor = getFallBackFieldContent("BetInputDisabledTextColor", 0); + leftItems << "BetInputDisabledTextColor"; + } + if(BetInputDisabledBgColor == "") { + BetInputDisabledBgColor = getFallBackFieldContent("BetInputDisabledBgColor", 0); + leftItems << "BetInputDisabledBgColor"; + } + if(FoldButtonTextColor == "") { + FoldButtonTextColor = getFallBackFieldContent("FoldButtonTextColor", 0); + leftItems << "FoldButtonTextColor"; + } + if(FoldButtonCheckableTextColor == "") { + FoldButtonCheckableTextColor = getFallBackFieldContent("FoldButtonCheckableTextColor", 0); + leftItems << "FoldButtonCheckableTextColor"; + } + if(CheckCallButtonTextColor == "") { + CheckCallButtonTextColor = getFallBackFieldContent("CheckCallButtonTextColor", 0); + leftItems << "CheckCallButtonTextColor"; + } + if(CheckCallButtonCheckableTextColor == "") { + CheckCallButtonCheckableTextColor = getFallBackFieldContent("CheckCallButtonCheckableTextColor", 0); + leftItems << "CheckCallButtonCheckableTextColor"; + } + if(BetRaiseButtonTextColor == "") { + BetRaiseButtonTextColor = getFallBackFieldContent("BetRaiseButtonTextColor", 0); + leftItems << "BetRaiseButtonTextColor"; + } + if(BetRaiseButtonCheckableTextColor == "") { + BetRaiseButtonCheckableTextColor = getFallBackFieldContent("BetRaiseButtonCheckableTextColor", 0); + leftItems << "BetRaiseButtonCheckableTextColor"; + } + if(AllInButtonTextColor == "") { + AllInButtonTextColor = getFallBackFieldContent("AllInButtonTextColor", 0); + leftItems << "AllInButtonTextColor"; + } + if(AllInButtonCheckableTextColor == "") { + AllInButtonCheckableTextColor = getFallBackFieldContent("AllInButtonCheckableTextColor", 0); + leftItems << "AllInButtonCheckableTextColor"; + } + if(BetSpeedSliderGrooveBgColor == "") { + BetSpeedSliderGrooveBgColor = getFallBackFieldContent("BetSpeedSliderGrooveBgColor", 0); + leftItems << "BetSpeedSliderGrooveBgColor"; + } + if(BetSpeedSliderGrooveBorderColor == "") { + BetSpeedSliderGrooveBorderColor = getFallBackFieldContent("BetSpeedSliderGrooveBorderColor", 0); + leftItems << "BetSpeedSliderGrooveBorderColor"; + } + if(BetSpeedSliderHandleBgColor == "") { + BetSpeedSliderHandleBgColor = getFallBackFieldContent("BetSpeedSliderHandleBgColor", 0); + leftItems << "BetSpeedSliderHandleBgColor"; + } + if(BetSpeedSliderHandleBorderColor == "") { + BetSpeedSliderHandleBorderColor = getFallBackFieldContent("BetSpeedSliderHandleBorderColor", 0); + leftItems << "BetSpeedSliderHandleBorderColor"; + } + if(ShowMyCardsButtonTextColor == "") { + ShowMyCardsButtonTextColor = getFallBackFieldContent("ShowMyCardsButtonTextColor", 0); + leftItems << "ShowMyCardsButtonTextColor"; + } + if(RatingStarsColor == "") { + RatingStarsColor = getFallBackFieldContent("RatingStarsColor", 0); + leftItems << "RatingStarsColor"; + } + if(PlayerInfoHintTextColor == "") { + PlayerInfoHintTextColor = getFallBackFieldContent("PlayerInfoHintTextColor", 0); + leftItems << "PlayerInfoHintTextColor"; + } - // SIZE - if(ChatLogTextSize == "") { ChatLogTextSize = getFallBackFieldContent("ChatLogTextSize", 0); leftItems << "ChatLogTextSize"; } + // SIZE + if(ChatLogTextSize == "") { + ChatLogTextSize = getFallBackFieldContent("ChatLogTextSize", 0); + leftItems << "ChatLogTextSize"; + } - //set loadedSuccessfull TRUE if everything works + //set loadedSuccessfull TRUE if everything works // qDebug() << "leftitem is empty: " << leftItems.isEmpty() << "pics left is empty: " << itemPicsLeft.isEmpty() << "stylefileversion is: " << PokerTHStyleFileVersion; - if(leftItems.isEmpty() && itemPicsLeft.isEmpty() && PokerTHStyleFileVersion != "" && PokerTHStyleFileVersion.toInt() == POKERTH_GT_STYLE_FILE_VERSION) { - myState = GT_STYLE_OK; + if(leftItems.isEmpty() && itemPicsLeft.isEmpty() && PokerTHStyleFileVersion != "" && PokerTHStyleFileVersion.toInt() == POKERTH_GT_STYLE_FILE_VERSION) { + myState = GT_STYLE_OK; // qDebug() << "myState of: " << StyleDescription << "is now: " << myState; - } - else { - //check for style file version - if(PokerTHStyleFileVersion != "" && PokerTHStyleFileVersion.toInt() != POKERTH_GT_STYLE_FILE_VERSION) { - myState = GT_STYLE_OUTDATED; - } - else { - //if one or more items are left - if(!leftItems.isEmpty() && myW != 0) myState = GT_STYLE_FIELDS_EMPTY; + } else { + //check for style file version + if(PokerTHStyleFileVersion != "" && PokerTHStyleFileVersion.toInt() != POKERTH_GT_STYLE_FILE_VERSION) { + myState = GT_STYLE_OUTDATED; + } else { + //if one or more items are left + if(!leftItems.isEmpty() && myW != 0) myState = GT_STYLE_FIELDS_EMPTY; - //if one or more pictures where not found - if(!itemPicsLeft.isEmpty() && myW != 0) myState = GT_STYLE_PICTURES_MISSING; - } + //if one or more pictures where not found + if(!itemPicsLeft.isEmpty() && myW != 0) myState = GT_STYLE_PICTURES_MISSING; + } // qDebug() << "myState of: " << StyleDescription << "is now: " << myState; - } - loadedSuccessfull = 1; - } - } - else { - loadedSuccessfull = 0; - QMessageBox::warning(myW, tr("Game Table Style Error"), - tr("Cannot load game table style file: %1 \n\nPlease check the style file or choose another style!").arg(currentFileName), - QMessageBox::Ok); - } + } + loadedSuccessfull = 1; + } + } else { + loadedSuccessfull = 0; + QMessageBox::warning(myW, tr("Game Table Style Error"), + tr("Cannot load game table style file: %1 \n\nPlease check the style file or choose another style!").arg(currentFileName), + QMessageBox::Ok); + } } void GameTableStyleReader::showErrorMessage() { - switch (myState) { - case GT_STYLE_PICTURES_MISSING: showItemPicsLeftErrorMessage(); - break; - case GT_STYLE_FIELDS_EMPTY: showLeftItemsErrorMessage(); - break; - case GT_STYLE_OUTDATED: showOutdatedErrorMessage(); - break; - default:; - } + switch (myState) { + case GT_STYLE_PICTURES_MISSING: + showItemPicsLeftErrorMessage(); + break; + case GT_STYLE_FIELDS_EMPTY: + showLeftItemsErrorMessage(); + break; + case GT_STYLE_OUTDATED: + showOutdatedErrorMessage(); + break; + default: + ; + } } void GameTableStyleReader::showLeftItemsErrorMessage() { - QString items = leftItems.join("\n"); - QString EMail; - if(StyleMaintainerEMail != "NULL") EMail = StyleMaintainerEMail; + QString items = leftItems.join("\n"); + QString EMail; + if(StyleMaintainerEMail != "NULL") EMail = StyleMaintainerEMail; - myMessageDialogImpl dialog(myConfig, myW); + myMessageDialogImpl dialog(myConfig, myW); - if(dialog.checkIfMesssageWillBeDisplayed(5)) { - dialog.exec(5, tr("Selected game table style \"%1\" seems to be incomplete or defective. \n\nThe value(s) of: \n%2 \nis/are missing. \n\nAnyway you can play with this style, because the missing content will be filled up by PokerTH default style. \n\nPlease contact the game table style builder via \"%3\".").arg(StyleDescription).arg(items).arg(EMail), tr("Game Table Style Error - Fields content missing"), QPixmap(":/gfx/emblem-important-64.png"), QDialogButtonBox::Ok, true); - } + if(dialog.checkIfMesssageWillBeDisplayed(5)) { + dialog.exec(5, tr("Selected game table style \"%1\" seems to be incomplete or defective. \n\nThe value(s) of: \n%2 \nis/are missing. \n\nAnyway you can play with this style, because the missing content will be filled up by PokerTH default style. \n\nPlease contact the game table style builder via \"%3\".").arg(StyleDescription).arg(items).arg(EMail), tr("Game Table Style Error - Fields content missing"), QPixmap(":/gfx/emblem-important-64.png"), QDialogButtonBox::Ok, true); + } } void GameTableStyleReader::showItemPicsLeftErrorMessage() { - QString pics = itemPicsLeft.join("\n"); - QString EMail; - if(StyleMaintainerEMail != "NULL") EMail = StyleMaintainerEMail; + QString pics = itemPicsLeft.join("\n"); + QString EMail; + if(StyleMaintainerEMail != "NULL") EMail = StyleMaintainerEMail; - myMessageDialogImpl dialog(myConfig, myW); + myMessageDialogImpl dialog(myConfig, myW); - if(dialog.checkIfMesssageWillBeDisplayed(6)) { - dialog.exec(6, tr("One or more pictures from current game table style \"%1\" were not found: \n\n%2 \n\nAnyway you can play with this style, because the missing content will be filled up by PokerTH default style. \n\nPlease contact the game table style builder via \"%3\".").arg(StyleDescription).arg(pics).arg(EMail), tr("Game Table Style Error - Pictures missing"), QPixmap(":/gfx/emblem-important-64.png"), QDialogButtonBox::Ok, true); - } + if(dialog.checkIfMesssageWillBeDisplayed(6)) { + dialog.exec(6, tr("One or more pictures from current game table style \"%1\" were not found: \n\n%2 \n\nAnyway you can play with this style, because the missing content will be filled up by PokerTH default style. \n\nPlease contact the game table style builder via \"%3\".").arg(StyleDescription).arg(pics).arg(EMail), tr("Game Table Style Error - Pictures missing"), QPixmap(":/gfx/emblem-important-64.png"), QDialogButtonBox::Ok, true); + } } void GameTableStyleReader::showOutdatedErrorMessage() { - QString EMail; - if(StyleMaintainerEMail != "NULL") EMail = StyleMaintainerEMail; + QString EMail; + if(StyleMaintainerEMail != "NULL") EMail = StyleMaintainerEMail; - myMessageDialogImpl dialog(myConfig, myW); + myMessageDialogImpl dialog(myConfig, myW); - if(dialog.checkIfMesssageWillBeDisplayed(7)) { - dialog.exec(7, tr("Selected game table style \"%1\" seems to be outdated. \nThe current PokerTH game table style version is \"%2\", but this style has version \"%3\" set. \n\nAnyway you can play with this style, because the missing content will be filled up by PokerTH default style. \n\nPlease contact the game table style builder via \"%4\".").arg(StyleDescription).arg(POKERTH_GT_STYLE_FILE_VERSION).arg(PokerTHStyleFileVersion).arg(EMail), tr("Game Table Style Error - Outdated"), QPixmap(":/gfx/emblem-important-64.png"), QDialogButtonBox::Ok, true); - } + if(dialog.checkIfMesssageWillBeDisplayed(7)) { + dialog.exec(7, tr("Selected game table style \"%1\" seems to be outdated. \nThe current PokerTH game table style version is \"%2\", but this style has version \"%3\" set. \n\nAnyway you can play with this style, because the missing content will be filled up by PokerTH default style. \n\nPlease contact the game table style builder via \"%4\".").arg(StyleDescription).arg(POKERTH_GT_STYLE_FILE_VERSION).arg(PokerTHStyleFileVersion).arg(EMail), tr("Game Table Style Error - Outdated"), QPixmap(":/gfx/emblem-important-64.png"), QDialogButtonBox::Ok, true); + } } void GameTableStyleReader::setTableBackground(gameTableImpl *gt) { - gt->setStyleSheet("QMainWindow { background-image: url(\""+Table+"\"); background-position: bottom center; background-origin: content; background-repeat: no-repeat;}"); + gt->setStyleSheet("QMainWindow { background-image: url(\""+Table+"\"); background-position: bottom center; background-origin: content; background-repeat: no-repeat;}"); } void GameTableStyleReader::setChatLogStyle(QTextBrowser *tb) { - tb->setStyleSheet("QTextBrowser { "+ font1String +" font-size: "+ChatLogTextSize+"px; color: #"+ChatLogTextColor+"; background-color: #"+ChatLogBgColor+"; border:none; } QScrollBar:vertical { border: 1px solid #"+ChatLogScrollBarBorderColor+"; background: #"+ChatLogScrollBarBgColor+"; width: 15px; margin: 17px -1px 17px 0px; } QScrollBar::handle:vertical { border-radius: 1px; border: 1px solid #"+ChatLogScrollBarHandleBorderColor+"; background: #"+ChatLogScrollBarHandleBgColor+"; min-height: 20px; } QScrollBar::add-line:vertical { margin-right: 0px; margin-left: 1px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 1px; border-top-left-radius: 1px; border: 1px solid #"+ChatLogScrollBarHandleBorderColor+"; background: #"+ChatLogScrollBarHandleBgColor+"; height: 15px; subcontrol-position: bottom; subcontrol-origin: margin; } QScrollBar::sub-line:vertical { margin-right: 0px; margin-left: 1px; border-bottom-right-radius: 1px; border-bottom-left-radius: 1px; border-top-right-radius: 2px; border-top-left-radius: 2px; border: 1px solid #"+ChatLogScrollBarHandleBorderColor+"; background: #"+ChatLogScrollBarHandleBgColor+"; height: 15px; subcontrol-position: top; subcontrol-origin: margin; } QScrollBar:up-arrow:vertical, QScrollBar::down-arrow:vertical { border: 1px solid #"+ChatLogScrollBarArrowBorderColor+"; height: 3px; width: 3px; background: #"+ChatLogScrollBarArrowBgColor+"; } QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { background: none; }"); + tb->setStyleSheet("QTextBrowser { "+ font1String +" font-size: "+ChatLogTextSize+"px; color: #"+ChatLogTextColor+"; background-color: #"+ChatLogBgColor+"; border:none; } QScrollBar:vertical { border: 1px solid #"+ChatLogScrollBarBorderColor+"; background: #"+ChatLogScrollBarBgColor+"; width: 15px; margin: 17px -1px 17px 0px; } QScrollBar::handle:vertical { border-radius: 1px; border: 1px solid #"+ChatLogScrollBarHandleBorderColor+"; background: #"+ChatLogScrollBarHandleBgColor+"; min-height: 20px; } QScrollBar::add-line:vertical { margin-right: 0px; margin-left: 1px; border-bottom-right-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 1px; border-top-left-radius: 1px; border: 1px solid #"+ChatLogScrollBarHandleBorderColor+"; background: #"+ChatLogScrollBarHandleBgColor+"; height: 15px; subcontrol-position: bottom; subcontrol-origin: margin; } QScrollBar::sub-line:vertical { margin-right: 0px; margin-left: 1px; border-bottom-right-radius: 1px; border-bottom-left-radius: 1px; border-top-right-radius: 2px; border-top-left-radius: 2px; border: 1px solid #"+ChatLogScrollBarHandleBorderColor+"; background: #"+ChatLogScrollBarHandleBgColor+"; height: 15px; subcontrol-position: top; subcontrol-origin: margin; } QScrollBar:up-arrow:vertical, QScrollBar::down-arrow:vertical { border: 1px solid #"+ChatLogScrollBarArrowBorderColor+"; height: 3px; width: 3px; background: #"+ChatLogScrollBarArrowBgColor+"; } QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { background: none; }"); } @@ -713,346 +1307,350 @@ void GameTableStyleReader::setChatLogStyle(QPlainTextEdit* pte) void GameTableStyleReader::setChatInputStyle(QLineEdit *ci) { - ci->setStyleSheet("QLineEdit { "+ font1String +" font-size: "+ChatLogTextSize+"px; color: #"+ChatLogTextColor+"; background-color: #"+ChatLogBgColor+"; border-top: 2px solid #"+TabWidgetBorderColor+"; }"); + ci->setStyleSheet("QLineEdit { "+ font1String +" font-size: "+ChatLogTextSize+"px; color: #"+ChatLogTextColor+"; background-color: #"+ChatLogBgColor+"; border-top: 2px solid #"+TabWidgetBorderColor+"; }"); } void GameTableStyleReader::setCashLabelStyle(QLabel *cl) { - cl->setStyleSheet("QLabel { "+ font2String +" font-size: "+cashFontSize+"px; font-weight: bold; color: #"+PlayerCashTextColor+"; }"); + cl->setStyleSheet("QLabel { "+ font2String +" font-size: "+cashFontSize+"px; font-weight: bold; color: #"+PlayerCashTextColor+"; }"); } void GameTableStyleReader::setSetLabelStyle(QLabel *sl) { - sl->setStyleSheet("QLabel { "+ font2String +" font-size: "+setLabelFontSize+"px; font-weight: bold; color: #"+PlayerBetTextColor+"; }"); + sl->setStyleSheet("QLabel { "+ font2String +" font-size: "+setLabelFontSize+"px; font-weight: bold; color: #"+PlayerBetTextColor+"; }"); } void GameTableStyleReader::setPlayerNameLabelStyle(QLabel *pnl) { - pnl->setStyleSheet("QLabel { "+ font2String +" font-size: "+playerNameLabelFontSize+"px; font-weight: bold; color: #"+PlayerNickTextColor+"; }"); + pnl->setStyleSheet("QLabel { "+ font2String +" font-size: "+playerNameLabelFontSize+"px; font-weight: bold; color: #"+PlayerNickTextColor+"; }"); } void GameTableStyleReader::setSmallFontBoardStyle(QLabel *l) { - l->setStyleSheet("QLabel { "+ font2String +" font-size: "+smallBoardFontSize+"px; font-weight: bold; color: #"+BoardSmallTextColor+"; }"); + l->setStyleSheet("QLabel { "+ font2String +" font-size: "+smallBoardFontSize+"px; font-weight: bold; color: #"+BoardSmallTextColor+"; }"); } void GameTableStyleReader::setBigFontBoardStyle(QLabel *l) { - l->setStyleSheet("QLabel { "+ font2String +" font-size: "+bigBoardFontSize+"px; font-weight: bold; color: #"+BoardBigTextColor+"; }"); + l->setStyleSheet("QLabel { "+ font2String +" font-size: "+bigBoardFontSize+"px; font-weight: bold; color: #"+BoardBigTextColor+"; }"); } void GameTableStyleReader::setCardHolderStyle(QLabel *l, int bero) { - switch(bero) { - case 0: l->setPixmap(CardHolderFlop); - break; - case 1: l->setPixmap(CardHolderTurn); - break; - case 2: l->setPixmap(CardHolderRiver); - break; - } + switch(bero) { + case 0: + l->setPixmap(CardHolderFlop); + break; + case 1: + l->setPixmap(CardHolderTurn); + break; + case 2: + l->setPixmap(CardHolderRiver); + break; + } } void GameTableStyleReader::setMenuBarStyle(QMenuBar *mb) { - mb->setStyleSheet("QMenuBar { background-color: #"+MenuBgColor+"; font-size:12px; border-width: 0px;} QMenuBar::item { color: #"+MenuTextColor+"; }"); + mb->setStyleSheet("QMenuBar { background-color: #"+MenuBgColor+"; font-size:12px; border-width: 0px;} QMenuBar::item { color: #"+MenuTextColor+"; }"); } void GameTableStyleReader::setBreakButtonStyle(QPushButton *bb, int state) { - switch(state) { - // default - case 0: bb->setStyleSheet("QPushButton:enabled { background-color: #"+BreakLobbyButtonBgColor+"; color: #"+BreakLobbyButtonTextColor+";} QPushButton:disabled { background-color: #"+BreakLobbyButtonBgDisabledColor+"; color: #"+BreakLobbyButtonTextDisabledColor+"; font-weight: 900;}"); - break; - // blink - case 1: bb->setStyleSheet("QPushButton { background-color: #"+BreakLobbyButtonBgBlinkColor+"; color: "+BreakLobbyButtonTextBlinkColor+";}"); + switch(state) { + // default + case 0: + bb->setStyleSheet("QPushButton:enabled { background-color: #"+BreakLobbyButtonBgColor+"; color: #"+BreakLobbyButtonTextColor+";} QPushButton:disabled { background-color: #"+BreakLobbyButtonBgDisabledColor+"; color: #"+BreakLobbyButtonTextDisabledColor+"; font-weight: 900;}"); + break; + // blink + case 1: + bb->setStyleSheet("QPushButton { background-color: #"+BreakLobbyButtonBgBlinkColor+"; color: "+BreakLobbyButtonTextBlinkColor+";}"); - break; - } + break; + } } void GameTableStyleReader::setSpeedStringStyle(QLabel *l) { - l->setStyleSheet("QLabel { color: #"+SpeedTextColor+";}"); + l->setStyleSheet("QLabel { color: #"+SpeedTextColor+";}"); } void GameTableStyleReader::setVoteButtonStyle(QPushButton *b) { - b->setStyleSheet("QPushButton:enabled { background-color: #"+VoteButtonBgColor+"; color: #"+VoteButtonTextColor+";} "); + b->setStyleSheet("QPushButton:enabled { background-color: #"+VoteButtonBgColor+"; color: #"+VoteButtonTextColor+";} "); } void GameTableStyleReader::setVoteStringsStyle(QLabel *l) { - l->setStyleSheet("QLabel { color: #"+TabWidgetTextColor+"; font-size: 11px;}"); + l->setStyleSheet("QLabel { color: #"+TabWidgetTextColor+"; font-size: 11px;}"); } void GameTableStyleReader::setPlayerSeatInactiveStyle(QGroupBox *ps) { - // check if seat is on top or bottom line - if(ps->objectName() == "groupBox2" || ps->objectName() == "groupBox1" || ps->objectName() == "groupBox0" || ps->objectName() == "groupBox9" || ps->objectName() == "groupBox8") { - ps->setStyleSheet("QGroupBox { border:none; background-image: url(\""+PlayerBottomSeatInactive+"\") }"); - } - else { - ps->setStyleSheet("QGroupBox { border:none; background-image: url(\""+PlayerTopSeatInactive+"\") }"); - } + // check if seat is on top or bottom line + if(ps->objectName() == "groupBox2" || ps->objectName() == "groupBox1" || ps->objectName() == "groupBox0" || ps->objectName() == "groupBox9" || ps->objectName() == "groupBox8") { + ps->setStyleSheet("QGroupBox { border:none; background-image: url(\""+PlayerBottomSeatInactive+"\") }"); + } else { + ps->setStyleSheet("QGroupBox { border:none; background-image: url(\""+PlayerTopSeatInactive+"\") }"); + } } void GameTableStyleReader::setPlayerSeatActiveStyle(QGroupBox *ps) { - // check if seat is on top or bottom line - if(ps->objectName() == "groupBox2" || ps->objectName() == "groupBox1" || ps->objectName() == "groupBox0" || ps->objectName() == "groupBox9" || ps->objectName() == "groupBox8") { - ps->setStyleSheet("QGroupBox { border:none; background-image: url(\""+PlayerBottomSeatActive+"\") }"); - } - else { - ps->setStyleSheet("QGroupBox { border:none; background-image: url(\""+PlayerTopSeatActive+"\") }"); - } + // check if seat is on top or bottom line + if(ps->objectName() == "groupBox2" || ps->objectName() == "groupBox1" || ps->objectName() == "groupBox0" || ps->objectName() == "groupBox9" || ps->objectName() == "groupBox8") { + ps->setStyleSheet("QGroupBox { border:none; background-image: url(\""+PlayerBottomSeatActive+"\") }"); + } else { + ps->setStyleSheet("QGroupBox { border:none; background-image: url(\""+PlayerTopSeatActive+"\") }"); + } } void GameTableStyleReader::setBetValueInputStyle(QSpinBox *bv) { - bv->setStyleSheet("QSpinBox { "+ font2String +" font-size: "+betValueFontSize+"px; font-weight: bold; background-color: #"+BetInputBgColor+"; color: #"+BetInputTextColor+"; } QSpinBox:disabled { background-color: #"+BetInputDisabledBgColor+"; color: #"+BetInputDisabledTextColor+" }"); + bv->setStyleSheet("QSpinBox { "+ font2String +" font-size: "+betValueFontSize+"px; font-weight: bold; background-color: #"+BetInputBgColor+"; color: #"+BetInputTextColor+"; } QSpinBox:disabled { background-color: #"+BetInputDisabledBgColor+"; color: #"+BetInputDisabledTextColor+" }"); } void GameTableStyleReader::setAwayRadioButtonsStyle(QRadioButton *rb) { - rb->setStyleSheet("QRadioButton { color: #"+TabWidgetTextColor+"; } QRadioButton::indicator { width: 13px; height: 13px;} QRadioButton::indicator::checked { image: url(\""+RadioButtonChecked+"\");} QRadioButton::indicator::unchecked { image: url(\""+RadioButtonUnchecked+"\");} QRadioButton::indicator:unchecked:hover { image: url(\""+RadioButtonUncheckedHover+"\");} QRadioButton::indicator:unchecked:pressed { image: url(\""+RadioButtonPressed+"\");} QRadioButton::indicator::checked { image: url(\""+RadioButtonChecked+"\");} QRadioButton::indicator:checked:hover { image: url(\""+RadioButtonCheckedHover+"\");} QRadioButton::indicator:checked:pressed { image: url(\""+RadioButtonPressed+"\");}"); + rb->setStyleSheet("QRadioButton { color: #"+TabWidgetTextColor+"; } QRadioButton::indicator { width: 13px; height: 13px;} QRadioButton::indicator::checked { image: url(\""+RadioButtonChecked+"\");} QRadioButton::indicator::unchecked { image: url(\""+RadioButtonUnchecked+"\");} QRadioButton::indicator:unchecked:hover { image: url(\""+RadioButtonUncheckedHover+"\");} QRadioButton::indicator:unchecked:pressed { image: url(\""+RadioButtonPressed+"\");} QRadioButton::indicator::checked { image: url(\""+RadioButtonChecked+"\");} QRadioButton::indicator:checked:hover { image: url(\""+RadioButtonCheckedHover+"\");} QRadioButton::indicator:checked:pressed { image: url(\""+RadioButtonPressed+"\");}"); } QString GameTableStyleReader::getActionPic(int action) { - QString myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); + QString myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); - // 1 = fold, 2 = check, 3 = call, 4 = bet, 5 = raise, 6 = allin, 7 = winner - switch(action) { - case 1: { - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || ActionFoldI18NPic.endsWith("NULL")) - return myAppDataPath+"gfx/gui/misc/actionpics/action_fold.png"; - else - return ActionFoldI18NPic; - } - break; - case 2: { - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || ActionCheckI18NPic.endsWith("NULL")) - return myAppDataPath+"gfx/gui/misc/actionpics/action_check.png"; - else - return ActionCheckI18NPic; - } - break; - case 3: { - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || ActionCallI18NPic.endsWith("NULL")) - return myAppDataPath+"gfx/gui/misc/actionpics/action_call.png"; - else - return ActionCallI18NPic; - } - break; - case 4: { - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || ActionBetI18NPic.endsWith("NULL")) - return myAppDataPath+"gfx/gui/misc/actionpics/action_bet.png"; - else - return ActionBetI18NPic; - } - break; - case 5: { - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || ActionRaiseI18NPic.endsWith("NULL")) - return myAppDataPath+"gfx/gui/misc/actionpics/action_raise.png"; - else - return ActionRaiseI18NPic; - } - break; - case 6: { - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || ActionAllInI18NPic.endsWith("NULL")) - return myAppDataPath+"gfx/gui/misc/actionpics/action_allin.png"; - else - return ActionAllInI18NPic; - } - break; - case 7: { - if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || ActionWinnerI18NPic.endsWith("NULL")) - return myAppDataPath+"gfx/gui/misc/actionpics/action_winner.png"; - else - return ActionWinnerI18NPic; - } - break; - } + // 1 = fold, 2 = check, 3 = call, 4 = bet, 5 = raise, 6 = allin, 7 = winner + switch(action) { + case 1: { + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || ActionFoldI18NPic.endsWith("NULL")) + return myAppDataPath+"gfx/gui/misc/actionpics/action_fold.png"; + else + return ActionFoldI18NPic; + } + break; + case 2: { + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || ActionCheckI18NPic.endsWith("NULL")) + return myAppDataPath+"gfx/gui/misc/actionpics/action_check.png"; + else + return ActionCheckI18NPic; + } + break; + case 3: { + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || ActionCallI18NPic.endsWith("NULL")) + return myAppDataPath+"gfx/gui/misc/actionpics/action_call.png"; + else + return ActionCallI18NPic; + } + break; + case 4: { + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || ActionBetI18NPic.endsWith("NULL")) + return myAppDataPath+"gfx/gui/misc/actionpics/action_bet.png"; + else + return ActionBetI18NPic; + } + break; + case 5: { + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || ActionRaiseI18NPic.endsWith("NULL")) + return myAppDataPath+"gfx/gui/misc/actionpics/action_raise.png"; + else + return ActionRaiseI18NPic; + } + break; + case 6: { + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || ActionAllInI18NPic.endsWith("NULL")) + return myAppDataPath+"gfx/gui/misc/actionpics/action_allin.png"; + else + return ActionAllInI18NPic; + } + break; + case 7: { + if(myConfig->readConfigInt("DontTranslateInternationalPokerStringsFromStyle") || ActionWinnerI18NPic.endsWith("NULL")) + return myAppDataPath+"gfx/gui/misc/actionpics/action_winner.png"; + else + return ActionWinnerI18NPic; + } + break; + } return QString(""); } void GameTableStyleReader::setButtonsStyle(MyActionButton *br, MyActionButton *cc, MyActionButton *f, MyActionButton *a, int state) { - br->setMyStyle(this); - cc->setMyStyle(this); - f->setMyStyle(this); - a->setMyStyle(this); + br->setMyStyle(this); + cc->setMyStyle(this); + f->setMyStyle(this); + a->setMyStyle(this); - switch(state) { - //default - case 0: { - br->setStyleSheet("QPushButton { border:none; background-image: url(\""+BetRaiseButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+BetRaiseButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+BetRaiseButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+BetRaiseButtonChecked+"\");} QPushButton:hover { background-image: url(\""+BetRaiseButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+BetRaiseButtonCheckedHover+"\");}"); + switch(state) { + //default + case 0: { + br->setStyleSheet("QPushButton { border:none; background-image: url(\""+BetRaiseButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+BetRaiseButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+BetRaiseButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+BetRaiseButtonChecked+"\");} QPushButton:hover { background-image: url(\""+BetRaiseButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+BetRaiseButtonCheckedHover+"\");}"); - cc->setStyleSheet("QPushButton { border:none; background-image: url(\""+CheckCallButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+CheckCallButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+CheckCallButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+CheckCallButtonChecked+"\");} QPushButton:hover { background-image: url(\""+CheckCallButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+CheckCallButtonCheckedHover+"\");}"); + cc->setStyleSheet("QPushButton { border:none; background-image: url(\""+CheckCallButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+CheckCallButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+CheckCallButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+CheckCallButtonChecked+"\");} QPushButton:hover { background-image: url(\""+CheckCallButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+CheckCallButtonCheckedHover+"\");}"); - f->setStyleSheet("QPushButton { border:none; background-image: url(\""+FoldButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+FoldButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+FoldButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+FoldButtonChecked+"\");} QPushButton:hover { background-image: url(\""+FoldButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+FoldButtonCheckedHover+"\");}"); + f->setStyleSheet("QPushButton { border:none; background-image: url(\""+FoldButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+FoldButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+FoldButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+FoldButtonChecked+"\");} QPushButton:hover { background-image: url(\""+FoldButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+FoldButtonCheckedHover+"\");}"); - a->setStyleSheet("QPushButton { border:none; background-image: url(\""+AllInButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+AllInButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+AllInButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+AllInButtonChecked+"\");} QPushButton:hover { background-image: url(\""+AllInButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+AllInButtonCheckedHover+"\");}"); - } - break; - //no hover - case 1: { - br->setStyleSheet("QPushButton { border:none; background-image: url(\""+BetRaiseButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+BetRaiseButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+BetRaiseButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+BetRaiseButtonChecked+"\");} QPushButton:hover { background-image: url(\""+BetRaiseButtonDefault+"\"); } QPushButton:checked:hover { background-image: url(\""+BetRaiseButtonChecked+"\");}"); + a->setStyleSheet("QPushButton { border:none; background-image: url(\""+AllInButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+AllInButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+AllInButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+AllInButtonChecked+"\");} QPushButton:hover { background-image: url(\""+AllInButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+AllInButtonCheckedHover+"\");}"); + } + break; + //no hover + case 1: { + br->setStyleSheet("QPushButton { border:none; background-image: url(\""+BetRaiseButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+BetRaiseButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+BetRaiseButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+BetRaiseButtonChecked+"\");} QPushButton:hover { background-image: url(\""+BetRaiseButtonDefault+"\"); } QPushButton:checked:hover { background-image: url(\""+BetRaiseButtonChecked+"\");}"); - cc->setStyleSheet("QPushButton { border:none; background-image: url(\""+CheckCallButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+CheckCallButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+CheckCallButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+CheckCallButtonChecked+"\");} QPushButton:hover { background-image: url(\""+CheckCallButtonDefault+"\"); } QPushButton:checked:hover { background-image: url(\""+CheckCallButtonChecked+"\");}"); + cc->setStyleSheet("QPushButton { border:none; background-image: url(\""+CheckCallButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+CheckCallButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+CheckCallButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+CheckCallButtonChecked+"\");} QPushButton:hover { background-image: url(\""+CheckCallButtonDefault+"\"); } QPushButton:checked:hover { background-image: url(\""+CheckCallButtonChecked+"\");}"); - f->setStyleSheet("QPushButton { border:none; background-image: url(\""+FoldButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+FoldButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+FoldButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+FoldButtonChecked+"\");} QPushButton:hover { background-image: url(\""+FoldButtonDefault+"\"); } QPushButton:checked:hover { background-image: url(\""+FoldButtonChecked+"\");}"); + f->setStyleSheet("QPushButton { border:none; background-image: url(\""+FoldButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+FoldButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+FoldButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+FoldButtonChecked+"\");} QPushButton:hover { background-image: url(\""+FoldButtonDefault+"\"); } QPushButton:checked:hover { background-image: url(\""+FoldButtonChecked+"\");}"); - a->setStyleSheet("QPushButton { border:none; background-image: url(\""+AllInButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+AllInButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+AllInButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+AllInButtonChecked+"\");} QPushButton:hover { background-image: url(\""+AllInButtonDefault+"\"); } QPushButton:checked:hover { background-image: url(\""+AllInButtonChecked+"\");}"); - } - break; - //checkable - case 2: { - br->setStyleSheet("QPushButton { border:none; background-image: url(\""+BetRaiseButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+BetRaiseButtonCheckableTextColor+";} QPushButton:unchecked { background-image: url(\""+BetRaiseButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+BetRaiseButtonChecked+"\");} QPushButton:hover { background-image: url(\""+BetRaiseButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+BetRaiseButtonCheckedHover+"\");}"); + a->setStyleSheet("QPushButton { border:none; background-image: url(\""+AllInButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+AllInButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+AllInButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+AllInButtonChecked+"\");} QPushButton:hover { background-image: url(\""+AllInButtonDefault+"\"); } QPushButton:checked:hover { background-image: url(\""+AllInButtonChecked+"\");}"); + } + break; + //checkable + case 2: { + br->setStyleSheet("QPushButton { border:none; background-image: url(\""+BetRaiseButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+BetRaiseButtonCheckableTextColor+";} QPushButton:unchecked { background-image: url(\""+BetRaiseButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+BetRaiseButtonChecked+"\");} QPushButton:hover { background-image: url(\""+BetRaiseButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+BetRaiseButtonCheckedHover+"\");}"); - cc->setStyleSheet("QPushButton { border:none; background-image: url(\""+CheckCallButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+CheckCallButtonCheckableTextColor+";} QPushButton:unchecked { background-image: url(\""+CheckCallButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+CheckCallButtonChecked+"\");} QPushButton:hover { background-image: url(\""+CheckCallButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+CheckCallButtonCheckedHover+"\");}"); + cc->setStyleSheet("QPushButton { border:none; background-image: url(\""+CheckCallButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+CheckCallButtonCheckableTextColor+";} QPushButton:unchecked { background-image: url(\""+CheckCallButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+CheckCallButtonChecked+"\");} QPushButton:hover { background-image: url(\""+CheckCallButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+CheckCallButtonCheckedHover+"\");}"); - f->setStyleSheet("QPushButton { border:none; background-image: url(\""+FoldButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+FoldButtonCheckableTextColor+";} QPushButton:unchecked { background-image: url(\""+FoldButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+FoldButtonChecked+"\");} QPushButton:hover { background-image: url(\""+FoldButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+FoldButtonCheckedHover+"\");}"); + f->setStyleSheet("QPushButton { border:none; background-image: url(\""+FoldButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+FoldButtonCheckableTextColor+";} QPushButton:unchecked { background-image: url(\""+FoldButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+FoldButtonChecked+"\");} QPushButton:hover { background-image: url(\""+FoldButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+FoldButtonCheckedHover+"\");}"); - a->setStyleSheet("QPushButton { border:none; background-image: url(\""+AllInButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+AllInButtonCheckableTextColor+";} QPushButton:unchecked { background-image: url(\""+AllInButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+AllInButtonChecked+"\");} QPushButton:hover { background-image: url(\""+AllInButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+AllInButtonCheckedHover+"\");}"); - } - break; - } + a->setStyleSheet("QPushButton { border:none; background-image: url(\""+AllInButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+AllInButtonCheckableTextColor+";} QPushButton:unchecked { background-image: url(\""+AllInButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+AllInButtonChecked+"\");} QPushButton:hover { background-image: url(\""+AllInButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+AllInButtonCheckedHover+"\");}"); + } + break; + } } void GameTableStyleReader::setShowMyCardsButtonStyle( MyActionButton *sc) { - sc->setMyStyle(this); + sc->setMyStyle(this); - //Show My Cards Button has same look and feel all the time - sc->setStyleSheet("QPushButton { border:none; background-image: url(\""+ShowMyCardsButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+ShowMyCardsButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+ShowMyCardsButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+BetRaiseButtonDefault+"\");} QPushButton:hover { background-image: url(\""+ShowMyCardsButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+ShowMyCardsButtonHover+"\");}"); + //Show My Cards Button has same look and feel all the time + sc->setStyleSheet("QPushButton { border:none; background-image: url(\""+ShowMyCardsButtonDefault+"\"); "+ font2String +" font-size: "+humanPlayerButtonFontSize+"px; font-weight: bold; color: #"+ShowMyCardsButtonTextColor+";} QPushButton:unchecked { background-image: url(\""+ShowMyCardsButtonDefault+"\"); } QPushButton:checked { background-image: url(\""+BetRaiseButtonDefault+"\");} QPushButton:hover { background-image: url(\""+ShowMyCardsButtonHover+"\"); } QPushButton:checked:hover { background-image: url(\""+ShowMyCardsButtonHover+"\");}"); } void GameTableStyleReader::setToolBoxBackground(QGroupBox* gb) { - gb->setStyleSheet("QGroupBox { border:none; background-image: url(\""+ToolBoxBackground+"\") }"); + gb->setStyleSheet("QGroupBox { border:none; background-image: url(\""+ToolBoxBackground+"\") }"); } void GameTableStyleReader::setTabWidgetStyle(QTabWidget *tw, QTabBar *tb) { - tw->setStyleSheet("QTabWidget::pane { border: 2px solid #"+TabWidgetBorderColor+"; border-radius: 2px; background-color: #"+TabWidgetBgColor+"; } QTabWidget::tab-bar { left: 5px; } "); + tw->setStyleSheet("QTabWidget::pane { border: 2px solid #"+TabWidgetBorderColor+"; border-radius: 2px; background-color: #"+TabWidgetBgColor+"; } QTabWidget::tab-bar { left: 5px; } "); - QString bottomPadding(""); + QString bottomPadding(""); #ifdef _WIN32 - bottomPadding = " padding-bottom: 3px;"; + bottomPadding = " padding-bottom: 3px;"; #endif - tb->setStyleSheet("QTabBar::tab{ "+ font1String +" font-size: 11px; color: #"+TabWidgetTextColor+"; background-color: #"+TabWidgetBgColor+"; border: 2px solid #"+TabWidgetBorderColor+"; border-bottom-color: #"+TabWidgetBorderColor+"; border-top-left-radius: 4px; border-top-right-radius: 4px; padding-top: "+tabBarPaddingTop+"px;"+bottomPadding+" padding-left:"+tabBarPaddingSide+"px; padding-right:"+tabBarPaddingSide+"px;} QTabBar::tab:selected, QTabBar::tab:hover { background-color: #"+TabWidgetBgColor+"; padding-top: "+tabBarPaddingTop+"px; padding-left:"+tabBarPaddingSide+"px; padding-right:"+tabBarPaddingSide+"px;} QTabBar::tab:selected { border-color: #"+TabWidgetBorderColor+"; border-bottom-color: #"+TabWidgetBgColor+"; padding-top: "+tabBarPaddingTop+"px; padding-left:"+tabBarPaddingSide+"px; padding-right:"+tabBarPaddingSide+"px;} QTabBar::tab:!selected { margin-top: 2px; padding-top: "+tabBarPaddingTop+"px; padding-left:"+tabBarPaddingSide+"px; padding-right:"+tabBarPaddingSide+"px;} QTabBar::tab:selected { margin-left: -4px; margin-right: -4px; padding-top: "+tabBarPaddingTop+"px; padding-left:"+tabBarPaddingSide+"px; padding-right:"+tabBarPaddingSide+"px;} QTabBar::tab:first:selected { margin-left: 0; padding-top: "+tabBarPaddingTop+"px; padding-left:"+tabBarPaddingSide+"px; padding-right:"+tabBarPaddingSide+"px;} QTabBar::tab:last:selected { margin-right: 0; padding-top: "+tabBarPaddingTop+"px; padding-left:"+tabBarPaddingSide+"px; padding-right:"+tabBarPaddingSide+"px;} QTabBar::tab:only-one { margin: 0; } "); + tb->setStyleSheet("QTabBar::tab{ "+ font1String +" font-size: 11px; color: #"+TabWidgetTextColor+"; background-color: #"+TabWidgetBgColor+"; border: 2px solid #"+TabWidgetBorderColor+"; border-bottom-color: #"+TabWidgetBorderColor+"; border-top-left-radius: 4px; border-top-right-radius: 4px; padding-top: "+tabBarPaddingTop+"px;"+bottomPadding+" padding-left:"+tabBarPaddingSide+"px; padding-right:"+tabBarPaddingSide+"px;} QTabBar::tab:selected, QTabBar::tab:hover { background-color: #"+TabWidgetBgColor+"; padding-top: "+tabBarPaddingTop+"px; padding-left:"+tabBarPaddingSide+"px; padding-right:"+tabBarPaddingSide+"px;} QTabBar::tab:selected { border-color: #"+TabWidgetBorderColor+"; border-bottom-color: #"+TabWidgetBgColor+"; padding-top: "+tabBarPaddingTop+"px; padding-left:"+tabBarPaddingSide+"px; padding-right:"+tabBarPaddingSide+"px;} QTabBar::tab:!selected { margin-top: 2px; padding-top: "+tabBarPaddingTop+"px; padding-left:"+tabBarPaddingSide+"px; padding-right:"+tabBarPaddingSide+"px;} QTabBar::tab:selected { margin-left: -4px; margin-right: -4px; padding-top: "+tabBarPaddingTop+"px; padding-left:"+tabBarPaddingSide+"px; padding-right:"+tabBarPaddingSide+"px;} QTabBar::tab:first:selected { margin-left: 0; padding-top: "+tabBarPaddingTop+"px; padding-left:"+tabBarPaddingSide+"px; padding-right:"+tabBarPaddingSide+"px;} QTabBar::tab:last:selected { margin-right: 0; padding-top: "+tabBarPaddingTop+"px; padding-left:"+tabBarPaddingSide+"px; padding-right:"+tabBarPaddingSide+"px;} QTabBar::tab:only-one { margin: 0; } "); } void GameTableStyleReader::setWindowsGeometry(gameTableImpl *gt) { - if(IfFixedWindowSize.toInt()) { - gt->setMinimumSize(FixedWindowWidth.toInt(), FixedWindowHeight.toInt()); - gt->setMaximumSize(FixedWindowWidth.toInt(), FixedWindowHeight.toInt()); - gt->resize(FixedWindowWidth.toInt(), FixedWindowHeight.toInt()); + if(IfFixedWindowSize.toInt()) { + gt->setMinimumSize(FixedWindowWidth.toInt(), FixedWindowHeight.toInt()); + gt->setMaximumSize(FixedWindowWidth.toInt(), FixedWindowHeight.toInt()); + gt->resize(FixedWindowWidth.toInt(), FixedWindowHeight.toInt()); - QDesktopWidget dw; - int availableWidth = dw.screenGeometry().width(); - int availableHeight = dw.screenGeometry().height(); - if(availableWidth == FixedWindowWidth.toInt() && availableHeight == FixedWindowHeight.toInt()) { - gt->actionFullScreen->setEnabled(TRUE); - } - else { - gt->actionFullScreen->setDisabled(TRUE); - if(gt->isFullScreen()) { - gt->showNormal(); - gt->move(50,50); - } - } - } - else { - gt->setMinimumSize(MinimumWindowWidth.toInt(), MinimumWindowHeight.toInt()); - gt->setMaximumSize(MaximumWindowWidth.toInt(), MaximumWindowHeight.toInt()); - gt->resize(MinimumWindowWidth.toInt(), MinimumWindowHeight.toInt()); + QDesktopWidget dw; + int availableWidth = dw.screenGeometry().width(); + int availableHeight = dw.screenGeometry().height(); + if(availableWidth == FixedWindowWidth.toInt() && availableHeight == FixedWindowHeight.toInt()) { + gt->actionFullScreen->setEnabled(TRUE); + } else { + gt->actionFullScreen->setDisabled(TRUE); + if(gt->isFullScreen()) { + gt->showNormal(); + gt->move(50,50); + } + } + } else { + gt->setMinimumSize(MinimumWindowWidth.toInt(), MinimumWindowHeight.toInt()); + gt->setMaximumSize(MaximumWindowWidth.toInt(), MaximumWindowHeight.toInt()); + gt->resize(MinimumWindowWidth.toInt(), MinimumWindowHeight.toInt()); - QDesktopWidget dw; - int availableWidth = dw.screenGeometry().width(); - int availableHeight = dw.screenGeometry().height(); - if(availableWidth <= MaximumWindowWidth.toInt() && availableHeight <= MaximumWindowHeight.toInt()) { - gt->actionFullScreen->setEnabled(TRUE); - } - else { - gt->actionFullScreen->setDisabled(TRUE); - if(gt->isFullScreen()) { - gt->showNormal(); - gt->move(50,50); - } - } - } + QDesktopWidget dw; + int availableWidth = dw.screenGeometry().width(); + int availableHeight = dw.screenGeometry().height(); + if(availableWidth <= MaximumWindowWidth.toInt() && availableHeight <= MaximumWindowHeight.toInt()) { + gt->actionFullScreen->setEnabled(TRUE); + } else { + gt->actionFullScreen->setDisabled(TRUE); + if(gt->isFullScreen()) { + gt->showNormal(); + gt->move(50,50); + } + } + } } void GameTableStyleReader::setSliderStyle(QSlider *s) { #if QT_VERSION >= 0x040700 - s->setStyleSheet("QSlider::groove:horizontal { border: 1px solid #"+BetSpeedSliderGrooveBorderColor+"; height: 3px; background: #"+BetSpeedSliderGrooveBgColor+"; margin: 4px 0; border-radius: 2px; } QSlider::handle:horizontal { background: #"+BetSpeedSliderHandleBgColor+"; border: 1px solid #"+BetSpeedSliderHandleBorderColor+"; width: 12px; margin: -7px 0; border-radius: 4px;}"); + s->setStyleSheet("QSlider::groove:horizontal { border: 1px solid #"+BetSpeedSliderGrooveBorderColor+"; height: 3px; background: #"+BetSpeedSliderGrooveBgColor+"; margin: 4px 0; border-radius: 2px; } QSlider::handle:horizontal { background: #"+BetSpeedSliderHandleBgColor+"; border: 1px solid #"+BetSpeedSliderHandleBorderColor+"; width: 12px; margin: -7px 0; border-radius: 4px;}"); #else - s->setStyleSheet("QSlider::groove:horizontal { border: 1px solid #"+BetSpeedSliderGrooveBorderColor+"; height: 3px; background: #"+BetSpeedSliderGrooveBgColor+"; margin: 4px 0; border-radius: 2px; } QSlider::handle:horizontal { background: #"+BetSpeedSliderHandleBgColor+"; border: 1px solid #"+BetSpeedSliderHandleBorderColor+"; width: 12px; margin: -2px 0; border-radius: 4px;}"); + s->setStyleSheet("QSlider::groove:horizontal { border: 1px solid #"+BetSpeedSliderGrooveBorderColor+"; height: 3px; background: #"+BetSpeedSliderGrooveBgColor+"; margin: 4px 0; border-radius: 2px; } QSlider::handle:horizontal { background: #"+BetSpeedSliderHandleBgColor+"; border: 1px solid #"+BetSpeedSliderHandleBorderColor+"; width: 12px; margin: -2px 0; border-radius: 4px;}"); #endif } QString GameTableStyleReader::getFallBackFieldContent(QString field, int type) { - QFile myFile(QFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/default/defaulttablestyle.xml").fileName()); - myFile.open(QIODevice::ReadOnly); - QByteArray thisContent = myFile.readAll(); + QFile myFile(QFile(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/default/defaulttablestyle.xml").fileName()); + myFile.open(QIODevice::ReadOnly); + QByteArray thisContent = myFile.readAll(); - //start reading the file and fill vars - string tempString1(""); - TiXmlDocument doc; - doc.Parse(thisContent.constData()); + //start reading the file and fill vars + string tempString1(""); + TiXmlDocument doc; + doc.Parse(thisContent.constData()); - if(doc.RootElement()) { - TiXmlHandle docHandle( &doc ); + if(doc.RootElement()) { + TiXmlHandle docHandle( &doc ); - TiXmlElement *CardDeckElement = docHandle.FirstChild( "PokerTH" ).FirstChild( "CardDeck" ).ToElement(); - if(CardDeckElement) { - QMessageBox::warning(myW, tr("Game Table Style Error"), - tr("A card deck style was selected instead of a game table style.\nPlease select a game table style and try again!"), - QMessageBox::Ok); - } - else { - TiXmlElement* itemsList = docHandle.FirstChild( "PokerTH" ).FirstChild( "TableStyle" ).FirstChild().ToElement(); - for( ; itemsList; itemsList=itemsList->NextSiblingElement()) { - const char *tmpStr1 = itemsList->Attribute("value"); - if (tmpStr1) { - tempString1 = tmpStr1; - if(itemsList->ValueStr() == field.toStdString()) { - if(type == 1) return QString(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/default/"+QString::fromUtf8(tempString1.c_str())); - else return QString::fromUtf8(tempString1.c_str()); - } - } - } - } - } + TiXmlElement *CardDeckElement = docHandle.FirstChild( "PokerTH" ).FirstChild( "CardDeck" ).ToElement(); + if(CardDeckElement) { + QMessageBox::warning(myW, tr("Game Table Style Error"), + tr("A card deck style was selected instead of a game table style.\nPlease select a game table style and try again!"), + QMessageBox::Ok); + } else { + TiXmlElement* itemsList = docHandle.FirstChild( "PokerTH" ).FirstChild( "TableStyle" ).FirstChild().ToElement(); + for( ; itemsList; itemsList=itemsList->NextSiblingElement()) { + const char *tmpStr1 = itemsList->Attribute("value"); + if (tmpStr1) { + tempString1 = tmpStr1; + if(itemsList->ValueStr() == field.toStdString()) { + if(type == 1) return QString(QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str())+"gfx/gui/table/default/"+QString::fromUtf8(tempString1.c_str())); + else return QString::fromUtf8(tempString1.c_str()); + } + } + } + } + } - return QString(""); + return QString(""); } QString GameTableStyleReader::getMyStateToolTipInfo() { - switch (myState) { - case GT_STYLE_OK: return QString(tr("Everything OK!")); - break; - case GT_STYLE_PICTURES_MISSING: return QString(tr("Some pictures are missing, please contact style maintainer for this issue.")); - break; - case GT_STYLE_FIELDS_EMPTY: return QString(tr("Some style fields are missing, please contact style maintainer for this issue.")); - break; - case GT_STYLE_OUTDATED: return QString(tr("This style is outdated, please contact style maintainer for this issue.")); - break; - default: return QString(""); - } + switch (myState) { + case GT_STYLE_OK: + return QString(tr("Everything OK!")); + break; + case GT_STYLE_PICTURES_MISSING: + return QString(tr("Some pictures are missing, please contact style maintainer for this issue.")); + break; + case GT_STYLE_FIELDS_EMPTY: + return QString(tr("Some style fields are missing, please contact style maintainer for this issue.")); + break; + case GT_STYLE_OUTDATED: + return QString(tr("This style is outdated, please contact style maintainer for this issue.")); + break; + default: + return QString(""); + } } diff --git a/src/gui/qt/styles/gametablestylereader.h b/src/gui/qt/styles/gametablestylereader.h index f677124a..70cf7431 100644 --- a/src/gui/qt/styles/gametablestylereader.h +++ b/src/gui/qt/styles/gametablestylereader.h @@ -32,290 +32,393 @@ #define POKERTH_GT_STYLE_FILE_VERSION 3 enum GtStyleState { - GT_STYLE_OK = 0, - GT_STYLE_OUTDATED, - GT_STYLE_FIELDS_EMPTY, - GT_STYLE_PICTURES_MISSING, + GT_STYLE_OK = 0, + GT_STYLE_OUTDATED, + GT_STYLE_FIELDS_EMPTY, + GT_STYLE_PICTURES_MISSING, GT_STYLE_UNDEFINED }; class gameTableImpl; -class GameTableStyleReader : public QObject { - Q_OBJECT +class GameTableStyleReader : public QObject +{ + Q_OBJECT public: - GameTableStyleReader(ConfigFile *c, QWidget *w); - ~GameTableStyleReader(); + GameTableStyleReader(ConfigFile *c, QWidget *w); + ~GameTableStyleReader(); - void readStyleFile(QString); + void readStyleFile(QString); - void showErrorMessage(); - void showLeftItemsErrorMessage(); - void showItemPicsLeftErrorMessage(); - void showOutdatedErrorMessage(); + void showErrorMessage(); + void showLeftItemsErrorMessage(); + void showItemPicsLeftErrorMessage(); + void showOutdatedErrorMessage(); - QString getStyleDescription() const { return StyleDescription; } - QString getStyleMaintainerName() const { return StyleMaintainerName; } - QString getStyleMaintainerEMail() const { return StyleMaintainerEMail; } - QString getStyleCreateDate() const { return StyleCreateDate; } + QString getStyleDescription() const { + return StyleDescription; + } + QString getStyleMaintainerName() const { + return StyleMaintainerName; + } + QString getStyleMaintainerEMail() const { + return StyleMaintainerEMail; + } + QString getStyleCreateDate() const { + return StyleCreateDate; + } - QString getCurrentFileName() const { return currentFileName; } - QString getPreview() const { return Preview; } - QString getDefaultAvatar() const { return DefaultAvatar; } - QString getDealerPuck() const { return DealerPuck; } - QString getSmallBlindPuck() const { return SmallBlindPuck; } - QString getBigBlindPuck() const { return BigBlindPuck; } - QString getHandRanking() const { return HandRanking; } - QString getActionPic(int); + QString getCurrentFileName() const { + return currentFileName; + } + QString getPreview() const { + return Preview; + } + QString getDefaultAvatar() const { + return DefaultAvatar; + } + QString getDealerPuck() const { + return DealerPuck; + } + QString getSmallBlindPuck() const { + return SmallBlindPuck; + } + QString getBigBlindPuck() const { + return BigBlindPuck; + } + QString getHandRanking() const { + return HandRanking; + } + QString getActionPic(int); - QString getFKeyIndicatorColor() const { return FKeyIndicatorColor; } - QString getChanceLabelImpossibleColor() const { return ChanceLabelImpossibleColor; } - QString getChanceLabelPossibleColor() const { return ChanceLabelPossibleColor; } - QString getChatLogTextColor() const { return ChatLogTextColor; } - QString getChatTextNickNotifyColor() const { return ChatTextNickNotifyColor; } - QString getLogWinnerMainPotColor() const { return LogWinnerMainPotColor; } - QString getLogWinnerSidePotColor() const { return LogWinnerSidePotColor; } - QString getLogPlayerSitsOutColor() const { return LogPlayerSitsOutColor; } - QString getLogNewGameAdminColor() const { return LogNewGameAdminColor; } - QString getBreakLobbyButtonBgColor() const { return BreakLobbyButtonBgColor; } - QString getRatingStarsColor() const { return RatingStarsColor; } - QString getPlayerInfoHintTextColor() const { return PlayerInfoHintTextColor; } + QString getFKeyIndicatorColor() const { + return FKeyIndicatorColor; + } + QString getChanceLabelImpossibleColor() const { + return ChanceLabelImpossibleColor; + } + QString getChanceLabelPossibleColor() const { + return ChanceLabelPossibleColor; + } + QString getChatLogTextColor() const { + return ChatLogTextColor; + } + QString getChatTextNickNotifyColor() const { + return ChatTextNickNotifyColor; + } + QString getLogWinnerMainPotColor() const { + return LogWinnerMainPotColor; + } + QString getLogWinnerSidePotColor() const { + return LogWinnerSidePotColor; + } + QString getLogPlayerSitsOutColor() const { + return LogPlayerSitsOutColor; + } + QString getLogNewGameAdminColor() const { + return LogNewGameAdminColor; + } + QString getBreakLobbyButtonBgColor() const { + return BreakLobbyButtonBgColor; + } + QString getRatingStarsColor() const { + return RatingStarsColor; + } + QString getPlayerInfoHintTextColor() const { + return PlayerInfoHintTextColor; + } - QString getPlayerNickTextColor() const { return PlayerNickTextColor; } - QString getPlayerNameLabelFontSize() const { return playerNameLabelFontSize; } - QString getFont2String() const { return font2String; } + QString getPlayerNickTextColor() const { + return PlayerNickTextColor; + } + QString getPlayerNameLabelFontSize() const { + return playerNameLabelFontSize; + } + QString getFont2String() const { + return font2String; + } - QString getMinimumWindowWidth() const { return MinimumWindowWidth; } - QString getMinimumWindowHeight() const { return MinimumWindowHeight; } - QString getMaximumWindowWidth() const { return MaximumWindowWidth; } - QString getMaximumWindowHeight() const { return MaximumWindowHeight; } - QString getFixedWindowWidth() const { return FixedWindowWidth; } - QString getFixedWindowHeight() const { return FixedWindowHeight; } - QString getIfFixedWindowSize() const { return IfFixedWindowSize; } + QString getMinimumWindowWidth() const { + return MinimumWindowWidth; + } + QString getMinimumWindowHeight() const { + return MinimumWindowHeight; + } + QString getMaximumWindowWidth() const { + return MaximumWindowWidth; + } + QString getMaximumWindowHeight() const { + return MaximumWindowHeight; + } + QString getFixedWindowWidth() const { + return FixedWindowWidth; + } + QString getFixedWindowHeight() const { + return FixedWindowHeight; + } + QString getIfFixedWindowSize() const { + return IfFixedWindowSize; + } - bool getFallBack() const { return fallBack; } - bool getLoadedSuccessfull() const { return loadedSuccessfull; } - GtStyleState getState() const { return myState; } + bool getFallBack() const { + return fallBack; + } + bool getLoadedSuccessfull() const { + return loadedSuccessfull; + } + GtStyleState getState() const { + return myState; + } - //set pictures - void setTableBackground(gameTableImpl*); - void setCardHolderStyle(QLabel*, int /*bero*/); - void setPlayerSeatActiveStyle(QGroupBox*); - void setPlayerSeatInactiveStyle(QGroupBox*); - void setToolBoxBackground(QGroupBox*); + //set pictures + void setTableBackground(gameTableImpl*); + void setCardHolderStyle(QLabel*, int /*bero*/); + void setPlayerSeatActiveStyle(QGroupBox*); + void setPlayerSeatInactiveStyle(QGroupBox*); + void setToolBoxBackground(QGroupBox*); - //set fonts + colors - void setChatLogStyle(QTextBrowser*); + //set fonts + colors + void setChatLogStyle(QTextBrowser*); void setChatLogStyle(QPlainTextEdit*); - void setChatInputStyle(QLineEdit*); - void setCashLabelStyle(QLabel*); - void setSetLabelStyle(QLabel*); - void setPlayerNameLabelStyle(QLabel*); - void setSmallFontBoardStyle(QLabel*); - void setBigFontBoardStyle(QLabel*); - void setMenuBarStyle(QMenuBar*); - void setBreakButtonStyle(QPushButton*, int); - void setSpeedStringStyle(QLabel*); - void setVoteButtonStyle(QPushButton*); - void setVoteStringsStyle(QLabel*); - void setBetValueInputStyle(QSpinBox*); - void setSliderStyle(QSlider*); + void setChatInputStyle(QLineEdit*); + void setCashLabelStyle(QLabel*); + void setSetLabelStyle(QLabel*); + void setPlayerNameLabelStyle(QLabel*); + void setSmallFontBoardStyle(QLabel*); + void setBigFontBoardStyle(QLabel*); + void setMenuBarStyle(QMenuBar*); + void setBreakButtonStyle(QPushButton*, int); + void setSpeedStringStyle(QLabel*); + void setVoteButtonStyle(QPushButton*); + void setVoteStringsStyle(QLabel*); + void setBetValueInputStyle(QSpinBox*); + void setSliderStyle(QSlider*); - void setTabWidgetStyle(QTabWidget*, QTabBar*); + void setTabWidgetStyle(QTabWidget*, QTabBar*); - void setWindowsGeometry(gameTableImpl*); + void setWindowsGeometry(gameTableImpl*); - //set pics and fonts and colors - void setButtonsStyle(MyActionButton*, MyActionButton*, MyActionButton*, MyActionButton*, int); - void setShowMyCardsButtonStyle( MyActionButton *sc); - void setAwayRadioButtonsStyle(QRadioButton*); + //set pics and fonts and colors + void setButtonsStyle(MyActionButton*, MyActionButton*, MyActionButton*, MyActionButton*, int); + void setShowMyCardsButtonStyle( MyActionButton *sc); + void setAwayRadioButtonsStyle(QRadioButton*); - QString getActionAllInI18NString() const { return ActionAllInI18NString; } - QString getActionRaiseI18NString() const { return ActionRaiseI18NString; } - QString getActionBetI18NString() const { return ActionBetI18NString; } - QString getActionCallI18NString() const { return ActionCallI18NString; } - QString getActionCheckI18NString() const { return ActionCheckI18NString; } - QString getActionFoldI18NString() const { return ActionFoldI18NString; } - QString getRiverI18NString() const { return RiverI18NString; } - QString getTurnI18NString() const { return TurnI18NString; } - QString getFlopI18NString() const { return FlopI18NString; } - QString getPreflopI18NString() const { return PreflopI18NString; } - QString getHandI18NString() const { return HandI18NString; } - QString getGameI18NString() const { return GameI18NString; } - QString getBetsI18NString() const { return BetsI18NString; } - QString getTotalI18NString() const { return TotalI18NString; } - QString getPotI18NString() const { return PotI18NString; } + QString getActionAllInI18NString() const { + return ActionAllInI18NString; + } + QString getActionRaiseI18NString() const { + return ActionRaiseI18NString; + } + QString getActionBetI18NString() const { + return ActionBetI18NString; + } + QString getActionCallI18NString() const { + return ActionCallI18NString; + } + QString getActionCheckI18NString() const { + return ActionCheckI18NString; + } + QString getActionFoldI18NString() const { + return ActionFoldI18NString; + } + QString getRiverI18NString() const { + return RiverI18NString; + } + QString getTurnI18NString() const { + return TurnI18NString; + } + QString getFlopI18NString() const { + return FlopI18NString; + } + QString getPreflopI18NString() const { + return PreflopI18NString; + } + QString getHandI18NString() const { + return HandI18NString; + } + QString getGameI18NString() const { + return GameI18NString; + } + QString getBetsI18NString() const { + return BetsI18NString; + } + QString getTotalI18NString() const { + return TotalI18NString; + } + QString getPotI18NString() const { + return PotI18NString; + } - QString getFallBackFieldContent(QString field, int type); // type: 0 = string, 1= picture - QString getMyStateToolTipInfo(); + QString getFallBackFieldContent(QString field, int type); // type: 0 = string, 1= picture + QString getMyStateToolTipInfo(); private: - //style values - // INFOS - QString StyleDescription; - QString StyleMaintainerName; - QString StyleMaintainerEMail; - QString StyleCreateDate; - QString PokerTHStyleFileVersion; - // WINDOWS SETTINGS - QString IfFixedWindowSize; - QString FixedWindowWidth; - QString FixedWindowHeight; - QString MinimumWindowWidth; - QString MinimumWindowHeight; - QString MaximumWindowWidth; - QString MaximumWindowHeight; - // PICS - QString Preview; - QString ActionAllInI18NPic; - QString ActionRaiseI18NPic; - QString ActionBetI18NPic; - QString ActionCallI18NPic; - QString ActionCheckI18NPic; - QString ActionFoldI18NPic; - QString ActionWinnerI18NPic; - QString BigBlindPuck; - QString SmallBlindPuck; - QString DealerPuck; - QString DefaultAvatar; - QString CardHolderFlop; - QString CardHolderTurn; - QString CardHolderRiver; - QString FoldButtonDefault; - QString FoldButtonHover; - QString FoldButtonChecked; - QString FoldButtonCheckedHover; - QString CheckCallButtonDefault; - QString CheckCallButtonHover; - QString CheckCallButtonChecked; - QString CheckCallButtonCheckedHover; - QString BetRaiseButtonDefault; - QString BetRaiseButtonHover; - QString BetRaiseButtonChecked; - QString BetRaiseButtonCheckedHover; - QString AllInButtonDefault; - QString AllInButtonHover; - QString AllInButtonChecked; - QString AllInButtonCheckedHover; - QString RadioButtonPressed; - QString RadioButtonChecked; - QString RadioButtonCheckedHover; - QString RadioButtonUnchecked; - QString RadioButtonUncheckedHover; - QString PlayerTopSeatInactive; - QString PlayerTopSeatActive; - QString PlayerBottomSeatInactive; - QString PlayerBottomSeatActive; - QString Table; - QString HandRanking; - QString ToolBoxBackground; - QString ShowMyCardsButtonDefault; - QString ShowMyCardsButtonHover; + //style values + // INFOS + QString StyleDescription; + QString StyleMaintainerName; + QString StyleMaintainerEMail; + QString StyleCreateDate; + QString PokerTHStyleFileVersion; + // WINDOWS SETTINGS + QString IfFixedWindowSize; + QString FixedWindowWidth; + QString FixedWindowHeight; + QString MinimumWindowWidth; + QString MinimumWindowHeight; + QString MaximumWindowWidth; + QString MaximumWindowHeight; + // PICS + QString Preview; + QString ActionAllInI18NPic; + QString ActionRaiseI18NPic; + QString ActionBetI18NPic; + QString ActionCallI18NPic; + QString ActionCheckI18NPic; + QString ActionFoldI18NPic; + QString ActionWinnerI18NPic; + QString BigBlindPuck; + QString SmallBlindPuck; + QString DealerPuck; + QString DefaultAvatar; + QString CardHolderFlop; + QString CardHolderTurn; + QString CardHolderRiver; + QString FoldButtonDefault; + QString FoldButtonHover; + QString FoldButtonChecked; + QString FoldButtonCheckedHover; + QString CheckCallButtonDefault; + QString CheckCallButtonHover; + QString CheckCallButtonChecked; + QString CheckCallButtonCheckedHover; + QString BetRaiseButtonDefault; + QString BetRaiseButtonHover; + QString BetRaiseButtonChecked; + QString BetRaiseButtonCheckedHover; + QString AllInButtonDefault; + QString AllInButtonHover; + QString AllInButtonChecked; + QString AllInButtonCheckedHover; + QString RadioButtonPressed; + QString RadioButtonChecked; + QString RadioButtonCheckedHover; + QString RadioButtonUnchecked; + QString RadioButtonUncheckedHover; + QString PlayerTopSeatInactive; + QString PlayerTopSeatActive; + QString PlayerBottomSeatInactive; + QString PlayerBottomSeatActive; + QString Table; + QString HandRanking; + QString ToolBoxBackground; + QString ShowMyCardsButtonDefault; + QString ShowMyCardsButtonHover; - // I18N ACTION STRINGS - QString ActionAllInI18NString; - QString ActionRaiseI18NString; - QString ActionBetI18NString; - QString ActionCallI18NString; - QString ActionCheckI18NString; - QString ActionFoldI18NString; - QString PotI18NString; - QString TotalI18NString; - QString BetsI18NString; - QString GameI18NString; - QString HandI18NString; - QString PreflopI18NString; - QString FlopI18NString; - QString TurnI18NString; - QString RiverI18NString; + // I18N ACTION STRINGS + QString ActionAllInI18NString; + QString ActionRaiseI18NString; + QString ActionBetI18NString; + QString ActionCallI18NString; + QString ActionCheckI18NString; + QString ActionFoldI18NString; + QString PotI18NString; + QString TotalI18NString; + QString BetsI18NString; + QString GameI18NString; + QString HandI18NString; + QString PreflopI18NString; + QString FlopI18NString; + QString TurnI18NString; + QString RiverI18NString; - // COLORS - QString FKeyIndicatorColor; - QString ChanceLabelPossibleColor; - QString ChanceLabelImpossibleColor; - QString ChatTextNickNotifyColor; - QString ChatLogTextColor; - QString ChatLogBgColor; - QString ChatLogScrollBarBorderColor; - QString ChatLogScrollBarBgColor; - QString ChatLogScrollBarHandleBorderColor; - QString ChatLogScrollBarHandleBgColor; - QString ChatLogScrollBarArrowBorderColor; - QString ChatLogScrollBarArrowBgColor; - QString LogWinnerMainPotColor; - QString LogWinnerSidePotColor; - QString LogPlayerSitsOutColor; - QString LogNewGameAdminColor; - QString TabWidgetBorderColor; - QString TabWidgetBgColor; - QString TabWidgetTextColor; - QString MenuBgColor; - QString MenuTextColor; - QString BreakLobbyButtonBgColor; - QString BreakLobbyButtonTextColor; - QString BreakLobbyButtonBgDisabledColor; - QString BreakLobbyButtonTextDisabledColor; - QString BreakLobbyButtonBgBlinkColor; - QString BreakLobbyButtonTextBlinkColor; - QString PlayerCashTextColor; - QString PlayerBetTextColor; - QString PlayerNickTextColor; - QString BoardBigTextColor; - QString BoardSmallTextColor; - QString SpeedTextColor; - QString VoteButtonBgColor; - QString VoteButtonTextColor; - QString BetInputTextColor; - QString BetInputBgColor; - QString BetInputDisabledTextColor; - QString BetInputDisabledBgColor; - QString FoldButtonTextColor; - QString FoldButtonCheckableTextColor; - QString CheckCallButtonTextColor; - QString CheckCallButtonCheckableTextColor; - QString BetRaiseButtonTextColor; - QString BetRaiseButtonCheckableTextColor; - QString AllInButtonTextColor; - QString AllInButtonCheckableTextColor; - QString BetSpeedSliderGrooveBgColor; - QString BetSpeedSliderGrooveBorderColor; - QString BetSpeedSliderHandleBgColor; - QString BetSpeedSliderHandleBorderColor; - QString ShowMyCardsButtonTextColor; + // COLORS + QString FKeyIndicatorColor; + QString ChanceLabelPossibleColor; + QString ChanceLabelImpossibleColor; + QString ChatTextNickNotifyColor; + QString ChatLogTextColor; + QString ChatLogBgColor; + QString ChatLogScrollBarBorderColor; + QString ChatLogScrollBarBgColor; + QString ChatLogScrollBarHandleBorderColor; + QString ChatLogScrollBarHandleBgColor; + QString ChatLogScrollBarArrowBorderColor; + QString ChatLogScrollBarArrowBgColor; + QString LogWinnerMainPotColor; + QString LogWinnerSidePotColor; + QString LogPlayerSitsOutColor; + QString LogNewGameAdminColor; + QString TabWidgetBorderColor; + QString TabWidgetBgColor; + QString TabWidgetTextColor; + QString MenuBgColor; + QString MenuTextColor; + QString BreakLobbyButtonBgColor; + QString BreakLobbyButtonTextColor; + QString BreakLobbyButtonBgDisabledColor; + QString BreakLobbyButtonTextDisabledColor; + QString BreakLobbyButtonBgBlinkColor; + QString BreakLobbyButtonTextBlinkColor; + QString PlayerCashTextColor; + QString PlayerBetTextColor; + QString PlayerNickTextColor; + QString BoardBigTextColor; + QString BoardSmallTextColor; + QString SpeedTextColor; + QString VoteButtonBgColor; + QString VoteButtonTextColor; + QString BetInputTextColor; + QString BetInputBgColor; + QString BetInputDisabledTextColor; + QString BetInputDisabledBgColor; + QString FoldButtonTextColor; + QString FoldButtonCheckableTextColor; + QString CheckCallButtonTextColor; + QString CheckCallButtonCheckableTextColor; + QString BetRaiseButtonTextColor; + QString BetRaiseButtonCheckableTextColor; + QString AllInButtonTextColor; + QString AllInButtonCheckableTextColor; + QString BetSpeedSliderGrooveBgColor; + QString BetSpeedSliderGrooveBorderColor; + QString BetSpeedSliderHandleBgColor; + QString BetSpeedSliderHandleBorderColor; + QString ShowMyCardsButtonTextColor; QString RatingStarsColor; QString PlayerInfoHintTextColor; - // SIZES - QString ChatLogTextSize; + // SIZES + QString ChatLogTextSize; - //internal - QString font2String; - QString font1String; - QString textBrowserFontsize; - QString cashFontSize; - QString setLabelFontSize; - QString playerNameLabelFontSize; - QString smallBoardFontSize; - QString bigBoardFontSize; - QString humanPlayerButtonFontSize; - QString betValueFontSize; + //internal + QString font2String; + QString font1String; + QString textBrowserFontsize; + QString cashFontSize; + QString setLabelFontSize; + QString playerNameLabelFontSize; + QString smallBoardFontSize; + QString bigBoardFontSize; + QString humanPlayerButtonFontSize; + QString betValueFontSize; - QString tabBarPaddingTop; - QString tabBarPaddingSide; + QString tabBarPaddingTop; + QString tabBarPaddingSide; - QByteArray fileContent; - QString currentFileName; - QString currentDir; + QByteArray fileContent; + QString currentFileName; + QString currentDir; - QStringList leftItems; - QStringList itemPicsLeft; + QStringList leftItems; + QStringList itemPicsLeft; - ConfigFile *myConfig; - QWidget *myW; + ConfigFile *myConfig; + QWidget *myW; - bool fallBack; - bool loadedSuccessfull; - GtStyleState myState; + bool fallBack; + bool loadedSuccessfull; + GtStyleState myState; }; diff --git a/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.cpp b/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.cpp index 259a855a..3c5bbf18 100644 --- a/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.cpp +++ b/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.cpp @@ -1,7 +1,7 @@ // // C++ Implementation: opengametimeoutmsgboximpl // -// Description: +// Description: // // // Author: Felix Hammer , (C) 2008 @@ -13,14 +13,14 @@ #include "session.h" timeoutMsgBoxImpl::timeoutMsgBoxImpl(QMainWindow *parent) - : QMessageBox(parent), msgID(NETWORK_TIMEOUT_GENERIC) + : QMessageBox(parent), msgID(NETWORK_TIMEOUT_GENERIC) { okButton = this->addButton(QMessageBox::Ok); this->setWindowTitle(tr("Timeout Warning")); this->setIcon(QMessageBox::Warning); this->setInformativeText(tr("Please click \"OK\" to stop the countdown!")); - + timeOutTimer = new QTimer; connect(timeOutTimer, SIGNAL(timeout()), this, SLOT(timerRefresh())); @@ -32,7 +32,8 @@ timeoutMsgBoxImpl::~timeoutMsgBoxImpl() { } -void timeoutMsgBoxImpl::startTimeout() { +void timeoutMsgBoxImpl::startTimeout() +{ //start the real timer realTimer.reset(); realTimer.start(); @@ -40,23 +41,25 @@ void timeoutMsgBoxImpl::startTimeout() { timeOutTimer->start(1000); } -void timeoutMsgBoxImpl::timerRefresh() { - +void timeoutMsgBoxImpl::timerRefresh() +{ + int sec = timeoutDuration; unsigned int realTimerValue = realTimer.elapsed().total_milliseconds(); sec -= realTimerValue/1000; if (sec < 0) sec = 0; switch (msgID) { - case NETWORK_TIMEOUT_GAME_ADMIN_IDLE: - this->setText(tr("You are game-admin of an open game which will time out in %1 seconds.").arg(sec,0,10)); - break; - default: - this->setText(tr("Your connection is about to time out due to inactivity in %1 seconds.").arg(sec,0,10)); - break; + case NETWORK_TIMEOUT_GAME_ADMIN_IDLE: + this->setText(tr("You are game-admin of an open game which will time out in %1 seconds.").arg(sec,0,10)); + break; + default: + this->setText(tr("Your connection is about to time out due to inactivity in %1 seconds.").arg(sec,0,10)); + break; } } -void timeoutMsgBoxImpl::stopTimeout() { +void timeoutMsgBoxImpl::stopTimeout() +{ - mySession->resetNetworkTimeout(); + mySession->resetNetworkTimeout(); } diff --git a/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.h b/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.h index c8edf850..0a91f4ba 100644 --- a/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.h +++ b/src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.h @@ -1,7 +1,7 @@ // // C++ Interface: opengametimeoutmsgboximpl // -// Description: +// Description: // // // Author: Felix Hammer , (C) 2008 @@ -25,11 +25,11 @@ class Session; class timeoutMsgBoxImpl : public QMessageBox { -Q_OBJECT + Q_OBJECT public: - timeoutMsgBoxImpl(QMainWindow*); + timeoutMsgBoxImpl(QMainWindow*); - ~timeoutMsgBoxImpl(); + ~timeoutMsgBoxImpl(); public slots: @@ -37,11 +37,17 @@ public slots: void timerRefresh(); void stopTimeout(); - void setMySession ( boost::shared_ptr theValue ) { mySession = theValue; } - void setMsgID ( NetTimeoutReason theValue ) { msgID = theValue; } - void setTimeoutDuration ( int theValue ) { timeoutDuration = theValue; } - -private: + void setMySession ( boost::shared_ptr theValue ) { + mySession = theValue; + } + void setMsgID ( NetTimeoutReason theValue ) { + msgID = theValue; + } + void setTimeoutDuration ( int theValue ) { + timeoutDuration = theValue; + } + +private: QTimer *timeOutTimer; QPushButton *okButton; diff --git a/src/gui/qttoolsinterface.h b/src/gui/qttoolsinterface.h index 1d3c3296..1523bdcf 100644 --- a/src/gui/qttoolsinterface.h +++ b/src/gui/qttoolsinterface.h @@ -22,7 +22,8 @@ #include -class QtToolsInterface { +class QtToolsInterface +{ public: virtual ~QtToolsInterface(); @@ -31,7 +32,7 @@ public: virtual std::string stringFromUtf8(const std::string &) =0; virtual std::string getDefaultLanguage() =0; virtual std::string getDataPathStdString(const char *argv0) =0; - + }; diff --git a/src/net/clientcontext.h b/src/net/clientcontext.h index ea0784c1..fc002b66 100644 --- a/src/net/clientcontext.h +++ b/src/net/clientcontext.h @@ -38,61 +38,88 @@ public: void SetSessionData(boost::shared_ptr sessionData); boost::shared_ptr GetResolver() const; void SetResolver(boost::shared_ptr resolver); - bool GetSctp() const - {return m_sctp;} - void SetSctp(bool sctp) - {m_sctp = sctp;} - int GetAddrFamily() const - {return m_addrFamily;} - void SetAddrFamily(int addrFamily) - {m_addrFamily = addrFamily;} - const std::string &GetServerAddr() const - {return m_serverAddr;} - void SetServerAddr(const std::string &serverAddr) - {m_serverAddr = serverAddr;} - const std::string &GetServerListUrl() const - {return m_serverListUrl;} - void SetServerListUrl(const std::string &serverListUrl) - {m_serverListUrl = serverListUrl;} - bool GetUseServerList() const - {return m_useServerList;} - void SetUseServerList(bool use) - {m_useServerList = use;} - unsigned GetServerPort() const - {return m_serverPort;} - void SetServerPort(unsigned serverPort) - {m_serverPort = serverPort;} - const std::string &GetAvatarServerAddr() const - {return m_avatarServerAddr;} - void SetAvatarServerAddr(const std::string &avatarServerAddr) - {m_avatarServerAddr = avatarServerAddr;} - const std::string &GetPassword() const - {return m_password;} - void SetPassword(const std::string &password) - {m_password = password;} - const std::string &GetPlayerName() const - {return m_playerName;} - void SetPlayerName(const std::string &playerName) - {m_playerName = playerName;} - PlayerRights GetPlayerRights() const - {return m_playerRights;} - void SetPlayerRights(PlayerRights rights) - {m_playerRights = rights;} - const std::string &GetAvatarFile() const - {return m_avatarFile;} - void SetAvatarFile(const std::string &avatarFile) - {m_avatarFile = avatarFile;} - const std::string &GetCacheDir() const - {return m_cacheDir;} - void SetCacheDir(const std::string &cacheDir) - {m_cacheDir = cacheDir;} - bool GetSubscribeLobbyMsg() const - {return m_hasSubscribedLobbyMsg;} - void SetSubscribeLobbyMsg(bool setSubscribe) - {m_hasSubscribedLobbyMsg = setSubscribe;} + bool GetSctp() const { + return m_sctp; + } + void SetSctp(bool sctp) { + m_sctp = sctp; + } + int GetAddrFamily() const { + return m_addrFamily; + } + void SetAddrFamily(int addrFamily) { + m_addrFamily = addrFamily; + } + const std::string &GetServerAddr() const { + return m_serverAddr; + } + void SetServerAddr(const std::string &serverAddr) { + m_serverAddr = serverAddr; + } + const std::string &GetServerListUrl() const { + return m_serverListUrl; + } + void SetServerListUrl(const std::string &serverListUrl) { + m_serverListUrl = serverListUrl; + } + bool GetUseServerList() const { + return m_useServerList; + } + void SetUseServerList(bool use) { + m_useServerList = use; + } + unsigned GetServerPort() const { + return m_serverPort; + } + void SetServerPort(unsigned serverPort) { + m_serverPort = serverPort; + } + const std::string &GetAvatarServerAddr() const { + return m_avatarServerAddr; + } + void SetAvatarServerAddr(const std::string &avatarServerAddr) { + m_avatarServerAddr = avatarServerAddr; + } + const std::string &GetPassword() const { + return m_password; + } + void SetPassword(const std::string &password) { + m_password = password; + } + const std::string &GetPlayerName() const { + return m_playerName; + } + void SetPlayerName(const std::string &playerName) { + m_playerName = playerName; + } + PlayerRights GetPlayerRights() const { + return m_playerRights; + } + void SetPlayerRights(PlayerRights rights) { + m_playerRights = rights; + } + const std::string &GetAvatarFile() const { + return m_avatarFile; + } + void SetAvatarFile(const std::string &avatarFile) { + m_avatarFile = avatarFile; + } + const std::string &GetCacheDir() const { + return m_cacheDir; + } + void SetCacheDir(const std::string &cacheDir) { + m_cacheDir = cacheDir; + } + bool GetSubscribeLobbyMsg() const { + return m_hasSubscribedLobbyMsg; + } + void SetSubscribeLobbyMsg(bool setSubscribe) { + m_hasSubscribedLobbyMsg = setSubscribe; + } - ReceiveBuffer &GetReceiveBuffer() - {return m_receiveBuffer;} + ReceiveBuffer &GetReceiveBuffer() { + return m_receiveBuffer; + } private: boost::shared_ptr m_sessionData; diff --git a/src/net/clientstate.h b/src/net/clientstate.h index 663ed755..b8849ca7 100644 --- a/src/net/clientstate.h +++ b/src/net/clientstate.h @@ -85,8 +85,8 @@ protected: ClientStateStartResolve(); void HandleResolve( - const boost::system::error_code& ec, boost::asio::ip::tcp::resolver::iterator endpoint_iterator, - boost::shared_ptr client); + const boost::system::error_code& ec, boost::asio::ip::tcp::resolver::iterator endpoint_iterator, + boost::shared_ptr client); }; // State: Start download of the server list. diff --git a/src/net/clientthread.h b/src/net/clientthread.h index 93a20516..4e163b57 100644 --- a/src/net/clientthread.h +++ b/src/net/clientthread.h @@ -112,8 +112,7 @@ protected: typedef std::map PlayerInfoMap; typedef std::map > AvatarFileMap; typedef std::map ServerInfoMap; - struct LoginData - { + struct LoginData { LoginData() : isGuest(false) {} std::string userName; std::string password; @@ -276,30 +275,30 @@ private: boost::asio::deadline_timer m_stateTimer; boost::asio::deadline_timer m_avatarTimer; -friend class AbstractClientStateReceiving; -friend class ClientStateInit; -friend class ClientStateStartResolve; -friend class ClientStateResolving; -friend class ClientStateStartServerListDownload; -friend class ClientStateSynchronizingServerList; -friend class ClientStateDownloadingServerList; -friend class ClientStateReadingServerList; -friend class ClientStateWaitChooseServer; -friend class ClientStateStartConnect; -friend class ClientStateConnecting; -friend class ClientStateStartSession; -friend class ClientStateWaitEnterLogin; -friend class ClientStateWaitAuthChallenge; -friend class ClientStateWaitAuthVerify; -friend class ClientStateWaitSession; -friend class ClientStateWaitJoin; -friend class ClientStateWaitGame; -friend class ClientStateSynchronizeStart; -friend class ClientStateWaitStart; -friend class ClientStateWaitHand; -friend class ClientStateRunHand; -friend class ClientStateFinal; -friend class ClientSenderCallback; + friend class AbstractClientStateReceiving; + friend class ClientStateInit; + friend class ClientStateStartResolve; + friend class ClientStateResolving; + friend class ClientStateStartServerListDownload; + friend class ClientStateSynchronizingServerList; + friend class ClientStateDownloadingServerList; + friend class ClientStateReadingServerList; + friend class ClientStateWaitChooseServer; + friend class ClientStateStartConnect; + friend class ClientStateConnecting; + friend class ClientStateStartSession; + friend class ClientStateWaitEnterLogin; + friend class ClientStateWaitAuthChallenge; + friend class ClientStateWaitAuthVerify; + friend class ClientStateWaitSession; + friend class ClientStateWaitJoin; + friend class ClientStateWaitGame; + friend class ClientStateSynchronizeStart; + friend class ClientStateWaitStart; + friend class ClientStateWaitHand; + friend class ClientStateRunHand; + friend class ClientStateFinal; + friend class ClientSenderCallback; }; #endif diff --git a/src/net/common/chatcleanermanager.cpp b/src/net/common/chatcleanermanager.cpp index 2dc8e397..9b6eda67 100644 --- a/src/net/common/chatcleanermanager.cpp +++ b/src/net/common/chatcleanermanager.cpp @@ -30,8 +30,8 @@ using boost::asio::ip::tcp; ChatCleanerManager::ChatCleanerManager(ChatCleanerCallback &cb, boost::shared_ptr ioService) -: m_callback(cb), m_ioService(ioService), m_connected(false), m_curRequestId(0), m_serverPort(0), m_useIpv6(false), - m_recvBufUsed(0) + : m_callback(cb), m_ioService(ioService), m_connected(false), m_curRequestId(0), m_serverPort(0), m_useIpv6(false), + m_recvBufUsed(0) { m_recvBuf[0] = 0; m_resolver.reset( @@ -69,9 +69,9 @@ ChatCleanerManager::ReInit() m_resolver->async_resolve( q, boost::bind(&ChatCleanerManager::HandleResolve, - shared_from_this(), - boost::asio::placeholders::error, - boost::asio::placeholders::iterator)); + shared_from_this(), + boost::asio::placeholders::error, + boost::asio::placeholders::iterator)); } void @@ -83,19 +83,15 @@ ChatCleanerManager::HandleLobbyChatText(unsigned playerId, const std::string &na void ChatCleanerManager::HandleGameChatText(unsigned gameId, unsigned playerId, const std::string &name, const std::string &text) { - if (m_connected) - { + if (m_connected) { InternalChatCleanerPacket tmpChat; tmpChat.GetMsg()->present = ChatCleanerMessage_PR_cleanerChatRequestMessage; CleanerChatRequestMessage_t *netRequest = &tmpChat.GetMsg()->choice.cleanerChatRequestMessage; netRequest->requestId = GetNextRequestId(); - if (gameId) - { + if (gameId) { netRequest->cleanerChatType.present = CleanerChatType_PR_cleanerChatTypeGame; netRequest->cleanerChatType.choice.cleanerChatTypeGame.gameId = gameId; - } - else - { + } else { netRequest->cleanerChatType.present = CleanerChatType_PR_cleanerChatTypeLobby; } netRequest->playerId = playerId; @@ -113,18 +109,15 @@ void ChatCleanerManager::HandleResolve(const boost::system::error_code& ec, boost::asio::ip::tcp::resolver::iterator endpoint_iterator) { - if (!ec) - { + if (!ec) { boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator; m_socket->async_connect( endpoint, boost::bind(&ChatCleanerManager::HandleConnect, - shared_from_this(), - boost::asio::placeholders::error, - ++endpoint_iterator)); - } - else if (ec != boost::asio::error::operation_aborted) - { + shared_from_this(), + boost::asio::placeholders::error, + ++endpoint_iterator)); + } else if (ec != boost::asio::error::operation_aborted) { LOG_ERROR("Could not resolve chat cleaner server."); } } @@ -133,8 +126,7 @@ void ChatCleanerManager::HandleConnect(const boost::system::error_code& ec, boost::asio::ip::tcp::resolver::iterator endpoint_iterator) { - if (!ec) - { + if (!ec) { InternalChatCleanerPacket tmpInit; tmpInit.GetMsg()->present = ChatCleanerMessage_PR_cleanerInitMessage; CleanerInitMessage_t *netInit = &tmpInit.GetMsg()->choice.cleanerInitMessage; @@ -150,11 +142,8 @@ ChatCleanerManager::HandleConnect(const boost::system::error_code& ec, shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); - } - else if (ec != boost::asio::error::operation_aborted) - { - if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) - { + } else if (ec != boost::asio::error::operation_aborted) { + if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) { // Try next resolve entry. boost::system::error_code ec; m_socket->close(ec); @@ -162,11 +151,10 @@ ChatCleanerManager::HandleConnect(const boost::system::error_code& ec, m_socket->async_connect( endpoint, boost::bind(&ChatCleanerManager::HandleConnect, - shared_from_this(), - boost::asio::placeholders::error, - ++endpoint_iterator)); - } - else + shared_from_this(), + boost::asio::placeholders::error, + ++endpoint_iterator)); + } else LOG_ERROR("Could not connect to chat cleaner server."); } } @@ -175,8 +163,7 @@ void ChatCleanerManager::HandleWrite(const boost::system::error_code &ec, boost::shared_ptr /*tmpPacket*/) { - if (ec && ec != boost::asio::error::operation_aborted) - { + if (ec && ec != boost::asio::error::operation_aborted) { LOG_ERROR("Error sending message to chat cleaner."); boost::system::error_code ec; m_socket->close(ec); @@ -187,25 +174,20 @@ ChatCleanerManager::HandleWrite(const boost::system::error_code &ec, void ChatCleanerManager::HandleRead(const boost::system::error_code &ec, size_t bytesRead) { - if (!ec) - { + if (!ec) { bool error = false; m_recvBufUsed += bytesRead; asn_dec_rval_t retVal; - do - { + do { InternalChatCleanerPacket recvMsg; retVal = ber_decode(0, &asn_DEF_ChatCleanerMessage, (void **)recvMsg.GetMsgPtr(), m_recvBuf, m_recvBufUsed); - if(retVal.code == RC_OK) - { + if(retVal.code == RC_OK) { // Consume the bytes. - if (retVal.consumed < m_recvBufUsed) - { + if (retVal.consumed < m_recvBufUsed) { m_recvBufUsed -= retVal.consumed; memmove(m_recvBuf, m_recvBuf + retVal.consumed, m_recvBufUsed); - } - else + } else m_recvBufUsed = 0; if (asn_check_constraints(&asn_DEF_ChatCleanerMessage, recvMsg.GetMsg(), NULL, NULL) == 0) @@ -215,8 +197,7 @@ ChatCleanerManager::HandleRead(const boost::system::error_code &ec, size_t bytes } } while (!error && retVal.code == RC_OK); - if (!error) - { + if (!error) { m_socket->async_read_some( boost::asio::buffer(m_recvBuf + m_recvBufUsed, sizeof(m_recvBuf) - m_recvBufUsed), boost::bind( @@ -224,16 +205,12 @@ ChatCleanerManager::HandleRead(const boost::system::error_code &ec, size_t bytes shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); - } - else - { + } else { boost::system::error_code ec; m_socket->close(ec); m_connected = false; } - } - else if (ec != boost::asio::error::operation_aborted) - { + } else if (ec != boost::asio::error::operation_aborted) { LOG_ERROR("Error receiving data from chat cleaner."); bool wasConnected = m_connected; boost::system::error_code ec; @@ -248,14 +225,11 @@ bool ChatCleanerManager::HandleMessage(InternalChatCleanerPacket &msg) { bool error = true; - if (msg.GetMsg()->present == ChatCleanerMessage_PR_cleanerInitAckMessage) - { + if (msg.GetMsg()->present == ChatCleanerMessage_PR_cleanerInitAckMessage) { CleanerInitAckMessage_t *netAck = &msg.GetMsg()->choice.cleanerInitAckMessage; - if (netAck->serverVersion == CLEANER_PROTOCOL_VERSION) - { + if (netAck->serverVersion == CLEANER_PROTOCOL_VERSION) { string tmpSecret((const char *)netAck->serverSecret.buf, netAck->serverSecret.size); - if (m_serverSecret == tmpSecret) - { + if (m_serverSecret == tmpSecret) { m_connected = true; error = false; LOG_MSG("Successfully connected to chat cleaner."); @@ -263,18 +237,12 @@ ChatCleanerManager::HandleMessage(InternalChatCleanerPacket &msg) } if (!m_connected) LOG_ERROR("Chat cleaner handshake failed."); - } - else if (msg.GetMsg()->present == ChatCleanerMessage_PR_cleanerChatReplyMessage) - { + } else if (msg.GetMsg()->present == ChatCleanerMessage_PR_cleanerChatReplyMessage) { CleanerChatReplyMessage_t *netReply = &msg.GetMsg()->choice.cleanerChatReplyMessage; - if (netReply->cleanerText) - { - if (netReply->cleanerChatType.present == CleanerChatType_PR_cleanerChatTypeLobby) - { + if (netReply->cleanerText) { + if (netReply->cleanerChatType.present == CleanerChatType_PR_cleanerChatTypeLobby) { m_callback.SignalChatBotMessage(string((const char *)netReply->cleanerText->buf, netReply->cleanerText->size)); - } - else if (netReply->cleanerChatType.present == CleanerChatType_PR_cleanerChatTypeGame) - { + } else if (netReply->cleanerChatType.present == CleanerChatType_PR_cleanerChatTypeGame) { m_callback.SignalChatBotMessage(netReply->cleanerChatType.choice.cleanerChatTypeGame.gameId, string((const char *)netReply->cleanerText->buf, netReply->cleanerText->size)); } } @@ -295,8 +263,7 @@ ChatCleanerManager::SendMessageToServer(InternalChatCleanerPacket &msg) if (e.encoded == -1) LOG_ERROR("Failed to encode chat cleaner packet: " << msg.GetMsg()->present); - else - { + else { boost::shared_ptr tmpPacket(new EncodedPacket(buf, e.encoded)); // Actually, this should not be done (parallel async_write calls might break data). // But we do not want to create additional buffers here. @@ -304,9 +271,9 @@ ChatCleanerManager::SendMessageToServer(InternalChatCleanerPacket &msg) *m_socket, boost::asio::buffer(tmpPacket->GetData(), tmpPacket->GetSize()), boost::bind(&ChatCleanerManager::HandleWrite, - shared_from_this(), - boost::asio::placeholders::error, - tmpPacket)); + shared_from_this(), + boost::asio::placeholders::error, + tmpPacket)); } } diff --git a/src/net/common/clientcontext.cpp b/src/net/common/clientcontext.cpp index e84ae55d..949286f7 100644 --- a/src/net/common/clientcontext.cpp +++ b/src/net/common/clientcontext.cpp @@ -22,8 +22,8 @@ ClientContext::ClientContext() -: m_sctp(false), m_addrFamily(AF_INET), m_useServerList(false), m_serverPort(0), - m_playerRights(PLAYER_RIGHTS_NORMAL), m_hasSubscribedLobbyMsg(true) + : m_sctp(false), m_addrFamily(AF_INET), m_useServerList(false), m_serverPort(0), + m_playerRights(PLAYER_RIGHTS_NORMAL), m_hasSubscribedLobbyMsg(true) { } diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index 8bc60bc4..09a478c4 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -128,10 +128,10 @@ ClientStateStartResolve::Enter(boost::shared_ptr client) context.GetResolver()->async_resolve( q, boost::bind(&ClientStateStartResolve::HandleResolve, - this, - boost::asio::placeholders::error, - boost::asio::placeholders::iterator, - client)); + this, + boost::asio::placeholders::error, + boost::asio::placeholders::iterator, + client)); } void @@ -144,15 +144,12 @@ void ClientStateStartResolve::HandleResolve(const boost::system::error_code& ec, boost::asio::ip::tcp::resolver::iterator endpoint_iterator, boost::shared_ptr client) { - if (!ec && &client->GetState() == this) - { + if (!ec && &client->GetState() == this) { client->GetCallback().SignalNetClientConnect(MSG_SOCK_RESOLVE_DONE); // Use the first resolver result. ClientStateStartConnect::Instance().SetRemoteEndpoint(endpoint_iterator); client->SetState(ClientStateStartConnect::Instance()); - } - else - { + } else { if (ec != boost::asio::error::operation_aborted) throw ClientException(__FILE__, __LINE__, ERR_SOCK_RESOLVE_FAILED, 0); } @@ -183,22 +180,18 @@ ClientStateStartServerListDownload::Enter(boost::shared_ptr client string serverListUrl(context.GetServerListUrl()); // Retrieve the file name from the URL. size_t pos = serverListUrl.find_last_of('/'); - if (serverListUrl.empty() || pos == string::npos || ++pos >= serverListUrl.length()) - { + if (serverListUrl.empty() || pos == string::npos || ++pos >= serverListUrl.length()) { throw ClientException(__FILE__, __LINE__, ERR_SOCK_INVALID_SERVERLIST_URL, 0); } tmpServerListPath /= serverListUrl.substr(pos); - if (exists(tmpServerListPath)) - { + if (exists(tmpServerListPath)) { // Download and compare md5. tmpServerListPath = change_extension(tmpServerListPath, extension(tmpServerListPath) + ".md5"); boost::shared_ptr downloader(new DownloadHelper); downloader->Init(serverListUrl + ".md5", tmpServerListPath.directory_string()); ClientStateSynchronizingServerList::Instance().SetDownloadHelper(downloader); client->SetState(ClientStateSynchronizingServerList::Instance()); - } - else - { + } else { // Download server list. boost::shared_ptr downloader(new DownloadHelper); downloader->Init(serverListUrl, tmpServerListPath.directory_string()); @@ -255,10 +248,8 @@ ClientStateSynchronizingServerList::SetDownloadHelper(boost::shared_ptr client) { - if (!ec && &client->GetState() == this) - { - if (m_downloadHelper->Process()) - { + if (!ec && &client->GetState() == this) { + if (m_downloadHelper->Process()) { m_downloadHelper.reset(); ClientContext &context = client->GetContext(); path md5ServerListPath(context.GetCacheDir()); @@ -280,27 +271,20 @@ ClientStateSynchronizingServerList::TimerLoop(const boost::system::error_code& e MD5Buf currentMd5; if (!CryptHelper::MD5Sum(serverListPath.directory_string(), currentMd5)) throw ClientException(__FILE__, __LINE__, ERR_SOCK_INVALID_SERVERLIST_MD5, 0); - if (downloadedMd5 == currentMd5) - { + if (downloadedMd5 == currentMd5) { // Server list is still current. client->SetState(ClientStateReadingServerList::Instance()); - } - else - { + } else { // Download new server list. // Paranoia check before removing the file, we do not want to delete wrong files. path tmpPath(serverListPath); - if (path(context.GetCacheDir()) == tmpPath.remove_leaf()) - { + if (path(context.GetCacheDir()) == tmpPath.remove_leaf()) { remove(serverListPath); client->SetState(ClientStateStartServerListDownload::Instance()); - } - else + } else throw ClientException(__FILE__, __LINE__, ERR_SOCK_INVALID_SERVERLIST_URL, 0); } - } - else - { + } else { // Download still in process. Delay. client->GetStateTimer().expires_from_now( boost::posix_time::milliseconds(CLIENT_WAIT_TIMEOUT_MSEC)); @@ -353,15 +337,11 @@ ClientStateDownloadingServerList::SetDownloadHelper(boost::shared_ptr client) { - if (!ec && &client->GetState() == this) - { - if (m_downloadHelper->Process()) - { + if (!ec && &client->GetState() == this) { + if (m_downloadHelper->Process()) { m_downloadHelper.reset(); client->SetState(ClientStateReadingServerList::Instance()); - } - else - { + } else { client->GetStateTimer().expires_from_now( boost::posix_time::milliseconds(CLIENT_WAIT_TIMEOUT_MSEC)); client->GetStateTimer().async_wait( @@ -395,8 +375,7 @@ ClientStateReadingServerList::Enter(boost::shared_ptr client) path zippedServerListPath(context.GetCacheDir()); zippedServerListPath /= context.GetServerListUrl().substr(context.GetServerListUrl().find_last_of('/') + 1); path xmlServerListPath; - if (extension(zippedServerListPath) == ".z") - { + if (extension(zippedServerListPath) == ".z") { xmlServerListPath = change_extension(zippedServerListPath, ""); // Unzip the file using zlib. @@ -407,26 +386,22 @@ ClientStateReadingServerList::Enter(boost::shared_ptr client) in.push(boost::iostreams::zlib_decompressor()); in.push(inFile); boost::iostreams::copy(in, outFile); - } catch (...) - { + } catch (...) { throw ClientException(__FILE__, __LINE__, ERR_SOCK_UNZIP_FAILED, 0); } - } - else + } else xmlServerListPath = zippedServerListPath; // Parse the server address. TiXmlDocument doc(xmlServerListPath.directory_string()); - if (doc.LoadFile()) - { + if (doc.LoadFile()) { client->ClearServerInfoMap(); int serverCount = 0; unsigned lastServerInfoId = 0; TiXmlHandle docHandle(&doc); const TiXmlElement *nextServer = docHandle.FirstChild("ServerList" ).FirstChild("Server").ToElement(); - while (nextServer) - { + while (nextServer) { ServerInfo serverInfo; { int tmpId; @@ -445,7 +420,7 @@ ClientStateReadingServerList::Enter(boost::shared_ptr client) const TiXmlNode *avatarNode = nextServer->FirstChild("AvatarServerAddress"); if (!nameNode || !nameNode->ToElement() || !addr4Node || !addr4Node->ToElement() - || !addr6Node || !addr6Node->ToElement() || !portNode || !portNode->ToElement()) + || !addr6Node || !addr6Node->ToElement() || !portNode || !portNode->ToElement()) throw ClientException(__FILE__, __LINE__, ERR_SOCK_INVALID_SERVERLIST_XML, 0); serverInfo.name = nameNode->ToElement()->Attribute("value"); @@ -458,8 +433,7 @@ ClientStateReadingServerList::Enter(boost::shared_ptr client) serverInfo.sponsor = sponsorNode->ToElement()->Attribute("value"); if (countryNode && countryNode->ToElement()) serverInfo.country = countryNode->ToElement()->Attribute("value"); - if (sctpNode && sctpNode->ToElement()) - { + if (sctpNode && sctpNode->ToElement()) { int tmpSctp; sctpNode->ToElement()->QueryIntAttribute("value", &tmpSctp); serverInfo.supportsSctp = tmpSctp == 1 ? true : false; @@ -473,21 +447,16 @@ ClientStateReadingServerList::Enter(boost::shared_ptr client) serverCount++; } - if (serverCount == 1) - { + if (serverCount == 1) { client->UseServer(lastServerInfoId); client->GetCallback().SignalNetClientConnect(MSG_SOCK_SERVER_LIST_DONE); client->SetState(ClientStateStartResolve::Instance()); - } - else if (serverCount > 1) - { + } else if (serverCount > 1) { client->GetCallback().SignalNetClientServerListShow(); client->SetState(ClientStateWaitChooseServer::Instance()); - } - else + } else throw ClientException(__FILE__, __LINE__, ERR_SOCK_INVALID_SERVERLIST_XML, 0); - } - else + } else throw ClientException(__FILE__, __LINE__, ERR_SOCK_INVALID_SERVERLIST_XML, 0); } @@ -533,17 +502,13 @@ ClientStateWaitChooseServer::Exit(boost::shared_ptr client) void ClientStateWaitChooseServer::TimerLoop(const boost::system::error_code& ec, boost::shared_ptr client) { - if (!ec && &client->GetState() == this) - { + if (!ec && &client->GetState() == this) { unsigned serverId; - if (client->GetSelectedServer(serverId)) - { + if (client->GetSelectedServer(serverId)) { client->UseServer(serverId); client->GetCallback().SignalNetClientConnect(MSG_SOCK_SERVER_LIST_DONE); client->SetState(ClientStateStartResolve::Instance()); - } - else - { + } else { client->GetStateTimer().expires_from_now( boost::posix_time::milliseconds(CLIENT_WAIT_TIMEOUT_MSEC)); client->GetStateTimer().async_wait( @@ -583,10 +548,10 @@ ClientStateStartConnect::Enter(boost::shared_ptr client) client->GetContext().GetSessionData()->GetAsioSocket()->async_connect( endpoint, boost::bind(&ClientStateStartConnect::HandleConnect, - this, - boost::asio::placeholders::error, - ++m_remoteEndpointIterator, - client)); + this, + boost::asio::placeholders::error, + ++m_remoteEndpointIterator, + client)); } void @@ -605,15 +570,11 @@ void ClientStateStartConnect::HandleConnect(const boost::system::error_code& ec, boost::asio::ip::tcp::resolver::iterator endpoint_iterator, boost::shared_ptr client) { - if (&client->GetState() == this) - { - if (!ec) - { + if (&client->GetState() == this) { + if (!ec) { client->GetCallback().SignalNetClientConnect(MSG_SOCK_CONNECT_DONE); client->SetState(ClientStateStartSession::Instance()); - } - else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) - { + } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) { // Try next resolve entry. ClientContext &context = client->GetContext(); boost::system::error_code ec; @@ -622,13 +583,11 @@ ClientStateStartConnect::HandleConnect(const boost::system::error_code& ec, boos context.GetSessionData()->GetAsioSocket()->async_connect( endpoint, boost::bind(&ClientStateStartConnect::HandleConnect, - this, - boost::asio::placeholders::error, - ++m_remoteEndpointIterator, - client)); - } - else - { + this, + boost::asio::placeholders::error, + ++m_remoteEndpointIterator, + client)); + } else { if (ec != boost::asio::error::operation_aborted) throw ClientException(__FILE__, __LINE__, ERR_SOCK_CONNECT_FAILED, ec.value()); } @@ -638,8 +597,7 @@ ClientStateStartConnect::HandleConnect(const boost::system::error_code& ec, boos void ClientStateStartConnect::TimerTimeout(const boost::system::error_code& ec, boost::shared_ptr client) { - if (!ec && &client->GetState() == this) - { + if (!ec && &client->GetState() == this) { boost::system::error_code ec; client->GetContext().GetSessionData()->GetAsioSocket()->close(ec); throw ClientException(__FILE__, __LINE__, ERR_SOCK_CONNECT_TIMEOUT, 0); @@ -659,22 +617,18 @@ AbstractClientStateReceiving::~AbstractClientStateReceiving() void AbstractClientStateReceiving::HandlePacket(boost::shared_ptr client, boost::shared_ptr tmpPacket) { - if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_playerInfoReplyMessage) - { + if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_playerInfoReplyMessage) { unsigned playerId = tmpPacket->GetMsg()->choice.playerInfoReplyMessage.playerId; - if (tmpPacket->GetMsg()->choice.playerInfoReplyMessage.playerInfoResult.present == playerInfoResult_PR_playerInfoData) - { + if (tmpPacket->GetMsg()->choice.playerInfoReplyMessage.playerInfoResult.present == playerInfoResult_PR_playerInfoData) { PlayerInfo tmpInfo; PlayerInfoData_t *netInfo = &tmpPacket->GetMsg()->choice.playerInfoReplyMessage.playerInfoResult.choice.playerInfoData; tmpInfo.playerName = STL_STRING_FROM_OCTET_STRING(netInfo->playerName); tmpInfo.ptype = netInfo->isHuman ? PLAYER_TYPE_HUMAN : PLAYER_TYPE_COMPUTER; tmpInfo.isGuest = netInfo->playerRights == PlayerInfoRights_playerRightsGuest; - if (netInfo->countryCode) - { + if (netInfo->countryCode) { tmpInfo.countryCode = STL_STRING_FROM_OCTET_STRING(*netInfo->countryCode); } - if (netInfo->avatarData) - { + if (netInfo->avatarData) { tmpInfo.hasAvatar = true; memcpy(tmpInfo.avatar.GetData(), netInfo->avatarData->avatar.buf, MD5_DATA_SIZE); tmpInfo.avatarType = (AvatarFileType)netInfo->avatarData->avatarType; @@ -682,18 +636,13 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr clien client->SetPlayerInfo( playerId, tmpInfo); - } - else - { + } else { client->SetUnknownPlayer(playerId); } - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_gamePlayerMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_gamePlayerMessage) { GamePlayerMessage_t *netGamePlayer = &tmpPacket->GetMsg()->choice.gamePlayerMessage; // unsigned gameId = netGamePlayer->gameId; - if (netGamePlayer->gamePlayerNotification.present == gamePlayerNotification_PR_removedFromGame) - { + if (netGamePlayer->gamePlayerNotification.present == gamePlayerNotification_PR_removedFromGame) { RemovedFromGame_t *netRemoved = &netGamePlayer->gamePlayerNotification.choice.removedFromGame; client->ClearPlayerDataList(); @@ -702,105 +651,81 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr clien // Show Lobby. client->GetCallback().SignalNetClientWaitDialog(); int removeReason; - switch (netRemoved->removedFromGameReason) - { - case removedFromGameReason_kickedFromGame : - removeReason = NTF_NET_REMOVED_KICKED; - break; - case removedFromGameReason_gameIsFull : - removeReason = NTF_NET_REMOVED_GAME_FULL; - break; - case removedFromGameReason_gameIsRunning : - removeReason = NTF_NET_REMOVED_ALREADY_RUNNING; - break; - case removedFromGameReason_gameTimeout : - removeReason = NTF_NET_REMOVED_TIMEOUT; - break; - case removedFromGameReason_removedStartFailed : - removeReason = NTF_NET_REMOVED_START_FAILED; - break; - default : - removeReason = NTF_NET_REMOVED_ON_REQUEST; - break; + switch (netRemoved->removedFromGameReason) { + case removedFromGameReason_kickedFromGame : + removeReason = NTF_NET_REMOVED_KICKED; + break; + case removedFromGameReason_gameIsFull : + removeReason = NTF_NET_REMOVED_GAME_FULL; + break; + case removedFromGameReason_gameIsRunning : + removeReason = NTF_NET_REMOVED_ALREADY_RUNNING; + break; + case removedFromGameReason_gameTimeout : + removeReason = NTF_NET_REMOVED_TIMEOUT; + break; + case removedFromGameReason_removedStartFailed : + removeReason = NTF_NET_REMOVED_START_FAILED; + break; + default : + removeReason = NTF_NET_REMOVED_ON_REQUEST; + break; } client->GetCallback().SignalNetClientRemovedFromGame(removeReason); client->SetState(ClientStateWaitJoin::Instance()); - } - else if (netGamePlayer->gamePlayerNotification.present == gamePlayerNotification_PR_gamePlayerLeft) - { + } else if (netGamePlayer->gamePlayerNotification.present == gamePlayerNotification_PR_gamePlayerLeft) { // A player left the game. GamePlayerLeft_t *netLeft = &netGamePlayer->gamePlayerNotification.choice.gamePlayerLeft; // Signal to GUI and remove from data list. client->RemovePlayerData(netLeft->playerId, netLeft->gamePlayerLeftReason); - } - else if (netGamePlayer->gamePlayerNotification.present == gamePlayerNotification_PR_gameAdminChanged) - { + } else if (netGamePlayer->gamePlayerNotification.present == gamePlayerNotification_PR_gameAdminChanged) { // New admin for the game. GameAdminChanged_t *netChanged = &netGamePlayer->gamePlayerNotification.choice.gameAdminChanged; // Set new game admin and signal to GUI. client->SetNewGameAdmin(netChanged->newAdminPlayerId); } - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_timeoutWarningMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_timeoutWarningMessage) { TimeoutWarningMessage_t *tmpTimeout = &tmpPacket->GetMsg()->choice.timeoutWarningMessage; client->GetCallback().SignalNetClientShowTimeoutDialog((NetTimeoutReason)tmpTimeout->timeoutReason, tmpTimeout->remainingSeconds); - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_afkWarningMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_afkWarningMessage) { AfkWarningMessage_t *tmpAfk = &tmpPacket->GetMsg()->choice.afkWarningMessage; client->GetCallback().SignalNetClientWarningAutoFoldInRankingGame(tmpAfk->remainingTimeouts); - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_chatMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_chatMessage) { // Chat message - display it in the GUI. ChatMessage_t *netMessage = &tmpPacket->GetMsg()->choice.chatMessage; string playerName; - if (netMessage->chatType.present == chatType_PR_chatTypeBroadcast) - { + if (netMessage->chatType.present == chatType_PR_chatTypeBroadcast) { client->GetCallback().SignalNetClientGameChatMsg("(global notice)", STL_STRING_FROM_OCTET_STRING(netMessage->chatText)); client->GetCallback().SignalNetClientLobbyChatMsg("(global notice)", STL_STRING_FROM_OCTET_STRING(netMessage->chatText)); - } - else if (netMessage->chatType.present == chatType_PR_chatTypeBot) - { + } else if (netMessage->chatType.present == chatType_PR_chatTypeBot) { client->GetCallback().SignalNetClientGameChatMsg("(chat bot)", STL_STRING_FROM_OCTET_STRING(netMessage->chatText)); client->GetCallback().SignalNetClientLobbyChatMsg("(chat bot)", STL_STRING_FROM_OCTET_STRING(netMessage->chatText)); - } - else if (netMessage->chatType.present == chatType_PR_chatTypeGame) - { + } else if (netMessage->chatType.present == chatType_PR_chatTypeGame) { unsigned playerId = netMessage->chatType.choice.chatTypeGame.playerId; boost::shared_ptr tmpPlayer = client->GetPlayerDataByUniqueId(playerId); if (tmpPlayer.get()) playerName = tmpPlayer->GetName(); if (!playerName.empty()) client->GetCallback().SignalNetClientGameChatMsg(playerName, STL_STRING_FROM_OCTET_STRING(netMessage->chatText)); - } - else if (netMessage->chatType.present == chatType_PR_chatTypeLobby) - { + } else if (netMessage->chatType.present == chatType_PR_chatTypeLobby) { unsigned playerId = netMessage->chatType.choice.chatTypeLobby.playerId; PlayerInfo info; if (client->GetCachedPlayerInfo(playerId, info)) client->GetCallback().SignalNetClientLobbyChatMsg(info.playerName, STL_STRING_FROM_OCTET_STRING(netMessage->chatText)); } - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_dialogMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_dialogMessage) { // Message box - display it in the GUI. DialogMessage_t *netDialog = &tmpPacket->GetMsg()->choice.dialogMessage; client->GetCallback().SignalNetClientMsgBox(STL_STRING_FROM_OCTET_STRING(netDialog->notificationText)); - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_playerListMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_playerListMessage) { PlayerListMessage_t *netPlayerList = &tmpPacket->GetMsg()->choice.playerListMessage; - if (netPlayerList->playerListNotification == playerListNotification_playerListNew) - { + if (netPlayerList->playerListNotification == playerListNotification_playerListNew) { PlayerInfo info; - if (!client->GetCachedPlayerInfo(netPlayerList->playerId, info)) - { + if (!client->GetCachedPlayerInfo(netPlayerList->playerId, info)) { // Request player info. ostringstream name; name << "#" << netPlayerList->playerId; @@ -808,19 +733,14 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr clien client->RequestPlayerInfo(netPlayerList->playerId); } client->GetCallback().SignalLobbyPlayerJoined(netPlayerList->playerId, info.playerName); - } - else if (netPlayerList->playerListNotification == playerListNotification_playerListLeft) - { + } else if (netPlayerList->playerListNotification == playerListNotification_playerListLeft) { client->GetCallback().SignalLobbyPlayerLeft(netPlayerList->playerId); } - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_gameListMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_gameListMessage) { GameListMessage_t *netGameList = &tmpPacket->GetMsg()->choice.gameListMessage; unsigned gameId = netGameList->gameId; - if (netGameList->gameListNotification.present == gameListNotification_PR_gameListNew) - { + if (netGameList->gameListNotification.present == gameListNotification_PR_gameListNew) { // A new game was created on the server. GameListNew_t *netListNew = &netGameList->gameListNotification.choice.gameListNew; @@ -828,12 +748,10 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr clien unsigned numPlayers = netListNew->playerIds.list.count; // Request player info for players if needed. GameInfo tmpInfo; - for (unsigned i = 0; i < numPlayers; i++) - { + for (unsigned i = 0; i < numPlayers; i++) { PlayerInfo info; unsigned playerId = *playerIds[i]; - if (!client->GetCachedPlayerInfo(playerId, info)) - { + if (!client->GetCachedPlayerInfo(playerId, info)) { // Request player info. client->RequestPlayerInfo(playerId); } @@ -846,121 +764,88 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr clien NetPacket::GetGameData(&netListNew->gameInfo, tmpInfo.data); client->AddGameInfo(gameId, tmpInfo); - } - else if (netGameList->gameListNotification.present == gameListNotification_PR_gameListUpdate) - { + } else if (netGameList->gameListNotification.present == gameListNotification_PR_gameListUpdate) { // An existing game was updated on the server. GameListUpdate_t *netListUpdate = &netGameList->gameListNotification.choice.gameListUpdate; if (netListUpdate->gameMode == NetGameMode_gameClosed) client->RemoveGameInfo(gameId); else client->UpdateGameInfoMode(gameId, static_cast(netListUpdate->gameMode)); - } - else if (netGameList->gameListNotification.present == gameListNotification_PR_gameListPlayerJoined) - { + } else if (netGameList->gameListNotification.present == gameListNotification_PR_gameListPlayerJoined) { GameListPlayerJoined_t *netListJoined = &netGameList->gameListNotification.choice.gameListPlayerJoined; client->ModifyGameInfoAddPlayer(gameId, netListJoined->playerId); // Request player info if needed. PlayerInfo info; - if (!client->GetCachedPlayerInfo(netListJoined->playerId, info)) - { + if (!client->GetCachedPlayerInfo(netListJoined->playerId, info)) { client->RequestPlayerInfo(netListJoined->playerId); } - } - else if (netGameList->gameListNotification.present == gameListNotification_PR_gameListPlayerLeft) - { + } else if (netGameList->gameListNotification.present == gameListNotification_PR_gameListPlayerLeft) { GameListPlayerLeft_t *netListLeft = &netGameList->gameListNotification.choice.gameListPlayerLeft; client->ModifyGameInfoRemovePlayer(gameId, netListLeft->playerId); - } - else if (netGameList->gameListNotification.present == gameListNotification_PR_gameListAdminChanged) - { + } else if (netGameList->gameListNotification.present == gameListNotification_PR_gameListAdminChanged) { GameListAdminChanged_t *netListAdmin = &netGameList->gameListNotification.choice.gameListAdminChanged; client->UpdateGameInfoAdmin(gameId, netListAdmin->newAdminPlayerId); } - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_startKickPetitionMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_startKickPetitionMessage) { StartKickPetitionMessage_t *netStartPetition = &tmpPacket->GetMsg()->choice.startKickPetitionMessage; client->StartPetition(netStartPetition->petitionId, netStartPetition->proposingPlayerId, - netStartPetition->kickPlayerId, netStartPetition->kickTimeoutSec, netStartPetition->numVotesNeededToKick); - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_kickPetitionUpdateMessage) - { + netStartPetition->kickPlayerId, netStartPetition->kickTimeoutSec, netStartPetition->numVotesNeededToKick); + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_kickPetitionUpdateMessage) { KickPetitionUpdateMessage_t *netPetitionUpdate = &tmpPacket->GetMsg()->choice.kickPetitionUpdateMessage; client->UpdatePetition(netPetitionUpdate->petitionId, netPetitionUpdate->numVotesAgainstKicking, - netPetitionUpdate->numVotesInFavourOfKicking, netPetitionUpdate->numVotesNeededToKick); - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_endKickPetitionMessage) - { + netPetitionUpdate->numVotesInFavourOfKicking, netPetitionUpdate->numVotesNeededToKick); + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_endKickPetitionMessage) { EndKickPetitionMessage_t *netEndPetition = &tmpPacket->GetMsg()->choice.endKickPetitionMessage; client->EndPetition(netEndPetition->petitionId); - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_avatarReplyMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_avatarReplyMessage) { AvatarReplyMessage_t *netAvatarReply = &tmpPacket->GetMsg()->choice.avatarReplyMessage; unsigned requestId = netAvatarReply->requestId; - if (netAvatarReply->avatarResult.present == avatarResult_PR_avatarHeader) - { + if (netAvatarReply->avatarResult.present == avatarResult_PR_avatarHeader) { AvatarHeader_t *netAvatarHeader = &netAvatarReply->avatarResult.choice.avatarHeader; client->AddTempAvatarFile(requestId, netAvatarHeader->avatarSize, static_cast(netAvatarHeader->avatarType)); - } - else if (netAvatarReply->avatarResult.present == avatarResult_PR_avatarData) - { + } else if (netAvatarReply->avatarResult.present == avatarResult_PR_avatarData) { AvatarData_t *netAvatarData = &netAvatarReply->avatarResult.choice.avatarData; vector fileData(netAvatarData->avatarBlock.size); memcpy(&fileData[0], netAvatarData->avatarBlock.buf, netAvatarData->avatarBlock.size); client->StoreInTempAvatarFile(requestId, fileData); - } - else if (netAvatarReply->avatarResult.present == avatarResult_PR_avatarEnd) - { + } else if (netAvatarReply->avatarResult.present == avatarResult_PR_avatarEnd) { client->CompleteTempAvatarFile(requestId); - } - else if (netAvatarReply->avatarResult.present == avatarResult_PR_unknownAvatar) - { + } else if (netAvatarReply->avatarResult.present == avatarResult_PR_unknownAvatar) { client->SetUnknownAvatar(requestId); } - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_reportAvatarAckMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_reportAvatarAckMessage) { ReportAvatarAckMessage_t *netReportAck = &tmpPacket->GetMsg()->choice.reportAvatarAckMessage; unsigned msgCode; - switch (netReportAck->reportResult) - { - case reportResult_avatarReportAccepted: - msgCode = MSG_NET_AVATAR_REPORT_ACCEPTED; - break; - case reportResult_avatarReportDuplicate: - msgCode = MSG_NET_AVATAR_REPORT_DUP; - break; - default: - msgCode = MSG_NET_AVATAR_REPORT_REJECTED; - break; + switch (netReportAck->reportResult) { + case reportResult_avatarReportAccepted: + msgCode = MSG_NET_AVATAR_REPORT_ACCEPTED; + break; + case reportResult_avatarReportDuplicate: + msgCode = MSG_NET_AVATAR_REPORT_DUP; + break; + default: + msgCode = MSG_NET_AVATAR_REPORT_REJECTED; + break; } client->GetCallback().SignalNetClientMsgBox(msgCode); - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_statisticsMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_statisticsMessage) { StatisticsMessage_t *netStatistics = &tmpPacket->GetMsg()->choice.statisticsMessage; StatisticsData **statData = netStatistics->statisticsData.list.array; unsigned numStats = netStatistics->statisticsData.list.count; // Request player info for players if needed. - if (numStats && statData && *statData) - { + if (numStats && statData && *statData) { ServerStats tmpStats; - for (unsigned i = 0; i < numStats; i++) - { + for (unsigned i = 0; i < numStats; i++) { if (statData[i]->statisticsType == statisticsType_statNumberOfPlayers) tmpStats.numberOfPlayersOnServer = statData[i]->statisticsValue; } client->UpdateStatData(tmpStats); } - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_errorMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_errorMessage) { // Server reported an error. ErrorMessage_t *netError = &tmpPacket->GetMsg()->choice.errorMessage; // Show the error. @@ -1002,32 +887,26 @@ ClientStateStartSession::Exit(boost::shared_ptr /*client*/) void ClientStateStartSession::InternalHandlePacket(boost::shared_ptr client, boost::shared_ptr tmpPacket) { - if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_announceMessage) - { + if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_announceMessage) { // Server has send announcement - check data. AnnounceMessage_t *netAnnounce = &tmpPacket->GetMsg()->choice.announceMessage; // Check current game version. if (netAnnounce->latestGameVersion.major != POKERTH_VERSION_MAJOR - || netAnnounce->latestGameVersion.minor != POKERTH_VERSION_MINOR) - { + || netAnnounce->latestGameVersion.minor != POKERTH_VERSION_MINOR) { client->GetCallback().SignalNetClientNotification(NTF_NET_NEW_RELEASE_AVAILABLE); - } - else if (POKERTH_BETA_REVISION && netAnnounce->latestBetaRevision != POKERTH_BETA_REVISION) - { + } else if (POKERTH_BETA_REVISION && netAnnounce->latestBetaRevision != POKERTH_BETA_REVISION) { client->GetCallback().SignalNetClientNotification(NTF_NET_OUTDATED_BETA); } ClientContext &context = client->GetContext(); // CASE 1: Authenticated login (username, challenge/response for password). - if (netAnnounce->serverType == serverType_serverTypeInternetAuth) - { + if (netAnnounce->serverType == serverType_serverTypeInternetAuth) { client->GetCallback().SignalNetClientLoginShow(); client->SetState(ClientStateWaitEnterLogin::Instance()); } // CASE 2: Unauthenticated login (network game or dedicated server without auth backend). else if (netAnnounce->serverType == serverType_serverTypeInternetNoAuth - || netAnnounce->serverType == serverType_serverTypeLAN) - { + || netAnnounce->serverType == serverType_serverTypeLAN) { boost::shared_ptr init(new NetPacket(NetPacket::Alloc)); init->GetMsg()->present = PokerTHMessage_PR_initMessage; InitMessage_t *netInit = &init->GetMsg()->choice.initMessage; @@ -1039,17 +918,15 @@ ClientStateStartSession::InternalHandlePacket(boost::shared_ptr cl context.GetPlayerName().c_str(), context.GetPlayerName().length()); string avatarFile = client->GetQtToolsInterface().stringFromUtf8(context.GetAvatarFile()); - if (!avatarFile.empty()) - { + if (!avatarFile.empty()) { MD5Buf tmpMD5; - if (client->GetAvatarManager().GetHashForAvatar(avatarFile, tmpMD5)) - { + if (client->GetAvatarManager().GetHashForAvatar(avatarFile, tmpMD5)) { // TODO: use sha1. noauthLogin->avatar = - OCTET_STRING_new_fromBuf( - &asn_DEF_OCTET_STRING, - (const char *)tmpMD5.GetData(), - MD5_DATA_SIZE); + OCTET_STRING_new_fromBuf( + &asn_DEF_OCTET_STRING, + (const char *)tmpMD5.GetData(), + MD5_DATA_SIZE); } } client->GetSender().Send(context.GetSessionData(), init); @@ -1094,11 +971,9 @@ ClientStateWaitEnterLogin::Exit(boost::shared_ptr client) void ClientStateWaitEnterLogin::TimerLoop(const boost::system::error_code& ec, boost::shared_ptr client) { - if (!ec && &client->GetState() == this) - { + if (!ec && &client->GetState() == this) { ClientThread::LoginData loginData; - if (client->GetLoginData(loginData)) - { + if (client->GetLoginData(loginData)) { ClientContext &context = client->GetContext(); boost::shared_ptr init(new NetPacket(NetPacket::Alloc)); init->GetMsg()->present = PokerTHMessage_PR_initMessage; @@ -1109,8 +984,7 @@ ClientStateWaitEnterLogin::TimerLoop(const boost::system::error_code& ec, boost: context.SetPlayerName(loginData.userName); // Handle guest login first. - if (loginData.isGuest) - { + if (loginData.isGuest) { context.SetPassword(""); context.SetPlayerRights(PLAYER_RIGHTS_GUEST); netInit->login.present = login_PR_guestLogin; @@ -1123,8 +997,7 @@ ClientStateWaitEnterLogin::TimerLoop(const boost::system::error_code& ec, boost: client->SetState(ClientStateWaitSession::Instance()); } // If the player is not a guest, authenticate. - else - { + else { context.SetPassword(loginData.password); netInit->login.present = login_PR_authenticatedLogin; AuthenticatedLogin_t *authLogin = &netInit->login.choice.authenticatedLogin; @@ -1138,25 +1011,21 @@ ClientStateWaitEnterLogin::TimerLoop(const boost::system::error_code& ec, boost: outUserData.c_str(), outUserData.length()); string avatarFile = client->GetQtToolsInterface().stringFromUtf8(context.GetAvatarFile()); - if (!avatarFile.empty()) - { + if (!avatarFile.empty()) { MD5Buf tmpMD5; - if (client->GetAvatarManager().GetHashForAvatar(avatarFile, tmpMD5)) - { + if (client->GetAvatarManager().GetHashForAvatar(avatarFile, tmpMD5)) { // TODO: use sha1. authLogin->avatar = - OCTET_STRING_new_fromBuf( - &asn_DEF_OCTET_STRING, - (const char *)tmpMD5.GetData(), - MD5_DATA_SIZE); + OCTET_STRING_new_fromBuf( + &asn_DEF_OCTET_STRING, + (const char *)tmpMD5.GetData(), + MD5_DATA_SIZE); } } client->GetSender().Send(context.GetSessionData(), init); client->SetState(ClientStateWaitAuthChallenge::Instance()); } - } - else - { + } else { client->GetStateTimer().expires_from_now( boost::posix_time::milliseconds(CLIENT_WAIT_TIMEOUT_MSEC)); client->GetStateTimer().async_wait( @@ -1196,12 +1065,10 @@ ClientStateWaitAuthChallenge::Exit(boost::shared_ptr /*client*/) void ClientStateWaitAuthChallenge::InternalHandlePacket(boost::shared_ptr client, boost::shared_ptr tmpPacket) { - if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_authMessage) - { + if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_authMessage) { // Check subtype. AuthMessage_t *netAuth = &tmpPacket->GetMsg()->choice.authMessage; - if (netAuth->present == AuthMessage_PR_authServerChallenge) - { + if (netAuth->present == AuthMessage_PR_authServerChallenge) { AuthServerChallenge_t *netChallenge = &netAuth->choice.authServerChallenge; string challengeStr = STL_STRING_FROM_OCTET_STRING(netChallenge->serverChallenge); boost::shared_ptr tmpSession = client->GetContext().GetSessionData(); @@ -1221,8 +1088,7 @@ ClientStateWaitAuthChallenge::InternalHandlePacket(boost::shared_ptrGetSender().Send(tmpSession, packet); client->SetState(ClientStateWaitAuthVerify::Instance()); - } - else + } else throw ClientException(__FILE__, __LINE__, ERR_NET_INVALID_PASSWORD, 0); } } @@ -1257,12 +1123,10 @@ ClientStateWaitAuthVerify::Exit(boost::shared_ptr /*client*/) void ClientStateWaitAuthVerify::InternalHandlePacket(boost::shared_ptr client, boost::shared_ptr tmpPacket) { - if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_authMessage) - { + if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_authMessage) { // Check subtype. AuthMessage_t *netAuth = &tmpPacket->GetMsg()->choice.authMessage; - if (netAuth->present == AuthMessage_PR_authServerVerification) - { + if (netAuth->present == AuthMessage_PR_authServerVerification) { AuthServerVerification_t *netVerification = &netAuth->choice.authServerVerification; string verificationStr = STL_STRING_FROM_OCTET_STRING(netVerification->serverVerification); boost::shared_ptr tmpSession = client->GetContext().GetSessionData(); @@ -1270,8 +1134,7 @@ ClientStateWaitAuthVerify::InternalHandlePacket(boost::shared_ptr throw ClientException(__FILE__, __LINE__, ERR_NET_INVALID_PASSWORD, 0); client->SetState(ClientStateWaitSession::Instance()); - } - else + } else throw ClientException(__FILE__, __LINE__, ERR_NET_INVALID_PASSWORD, 0); } } @@ -1306,8 +1169,7 @@ ClientStateWaitSession::Exit(boost::shared_ptr /*client*/) void ClientStateWaitSession::InternalHandlePacket(boost::shared_ptr client, boost::shared_ptr tmpPacket) { - if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_initAckMessage) - { + if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_initAckMessage) { // Everything is fine - we are in the lobby. InitAckMessage_t *netInitAck = &tmpPacket->GetMsg()->choice.initAckMessage; client->SetGuiPlayerId(netInitAck->yourPlayerId); @@ -1315,18 +1177,16 @@ ClientStateWaitSession::InternalHandlePacket(boost::shared_ptr cli client->SetSessionEstablished(true); client->GetCallback().SignalNetClientConnect(MSG_SOCK_SESSION_DONE); client->SetState(ClientStateWaitJoin::Instance()); - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_avatarRequestMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_avatarRequestMessage) { // Before letting us join the lobby, the server requests our avatar. AvatarRequestMessage_t *netAvatarRequest = &tmpPacket->GetMsg()->choice.avatarRequestMessage; // TODO compare SHA1. NetPacketList tmpList; int avatarError = client->GetAvatarManager().AvatarFileToNetPackets( - client->GetQtToolsInterface().stringFromUtf8(client->GetContext().GetAvatarFile()), - netAvatarRequest->requestId, - tmpList); + client->GetQtToolsInterface().stringFromUtf8(client->GetContext().GetAvatarFile()), + netAvatarRequest->requestId, + tmpList); if (!avatarError) client->GetSender().Send(client->GetContext().GetSessionData(), tmpList); @@ -1367,12 +1227,10 @@ ClientStateWaitJoin::InternalHandlePacket(boost::shared_ptr client { ClientContext &context = client->GetContext(); - if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_joinGameReplyMessage) - { + if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_joinGameReplyMessage) { JoinGameReplyMessage_t *netJoinReply = &tmpPacket->GetMsg()->choice.joinGameReplyMessage; unsigned gameId = netJoinReply->gameId; - if (netJoinReply->joinGameResult.present == joinGameResult_PR_joinGameAck) - { + if (netJoinReply->joinGameResult.present == joinGameResult_PR_joinGameAck) { // Successfully joined a game. JoinGameAck_t *netJoinAck = &netJoinReply->joinGameResult.choice.joinGameAck; client->SetGameId(gameId); @@ -1383,65 +1241,59 @@ ClientStateWaitJoin::InternalHandlePacket(boost::shared_ptr client // Player number is 0 on init. Will be set when the game starts. boost::shared_ptr playerData( new PlayerData(client->GetGuiPlayerId(), 0, PLAYER_TYPE_HUMAN, - context.GetPlayerRights(), netJoinAck->areYouGameAdmin)); + context.GetPlayerRights(), netJoinAck->areYouGameAdmin)); playerData->SetName(context.GetPlayerName()); playerData->SetAvatarFile(context.GetAvatarFile()); client->AddPlayerData(playerData); client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_JOIN); client->SetState(ClientStateWaitGame::Instance()); - } - else if (netJoinReply->joinGameResult.present == joinGameResult_PR_joinGameFailed) - { + } else if (netJoinReply->joinGameResult.present == joinGameResult_PR_joinGameFailed) { // Failed to join a game. JoinGameFailed_t *netJoinFailed = &netJoinReply->joinGameResult.choice.joinGameFailed; int failureCode; - switch (netJoinFailed->joinGameFailureReason) - { - case joinGameFailureReason_invalidGame : - failureCode = NTF_NET_JOIN_GAME_INVALID; - break; - case joinGameFailureReason_gameIsFull : - failureCode = NTF_NET_JOIN_GAME_FULL; - break; - case joinGameFailureReason_gameIsRunning : - failureCode = NTF_NET_JOIN_ALREADY_RUNNING; - break; - case joinGameFailureReason_invalidPassword : - failureCode = NTF_NET_JOIN_INVALID_PASSWORD; - break; - case joinGameFailureReason_notAllowedAsGuest : - failureCode = NTF_NET_JOIN_GUEST_FORBIDDEN; - break; - case joinGameFailureReason_notInvited : - failureCode = NTF_NET_JOIN_NOT_INVITED; - break; - case joinGameFailureReason_gameNameInUse : - failureCode = NTF_NET_JOIN_GAME_NAME_IN_USE; - break; - case joinGameFailureReason_badGameName : - failureCode = NTF_NET_JOIN_GAME_BAD_NAME; - break; - case joinGameFailureReason_invalidSettings : - failureCode = NTF_NET_JOIN_INVALID_SETTINGS; - break; - case joinGameFailureReason_ipAddressBlocked : - failureCode = NTF_NET_JOIN_IP_BLOCKED; - break; - default : - failureCode = NTF_NET_INTERNAL; - break; + switch (netJoinFailed->joinGameFailureReason) { + case joinGameFailureReason_invalidGame : + failureCode = NTF_NET_JOIN_GAME_INVALID; + break; + case joinGameFailureReason_gameIsFull : + failureCode = NTF_NET_JOIN_GAME_FULL; + break; + case joinGameFailureReason_gameIsRunning : + failureCode = NTF_NET_JOIN_ALREADY_RUNNING; + break; + case joinGameFailureReason_invalidPassword : + failureCode = NTF_NET_JOIN_INVALID_PASSWORD; + break; + case joinGameFailureReason_notAllowedAsGuest : + failureCode = NTF_NET_JOIN_GUEST_FORBIDDEN; + break; + case joinGameFailureReason_notInvited : + failureCode = NTF_NET_JOIN_NOT_INVITED; + break; + case joinGameFailureReason_gameNameInUse : + failureCode = NTF_NET_JOIN_GAME_NAME_IN_USE; + break; + case joinGameFailureReason_badGameName : + failureCode = NTF_NET_JOIN_GAME_BAD_NAME; + break; + case joinGameFailureReason_invalidSettings : + failureCode = NTF_NET_JOIN_INVALID_SETTINGS; + break; + case joinGameFailureReason_ipAddressBlocked : + failureCode = NTF_NET_JOIN_IP_BLOCKED; + break; + default : + failureCode = NTF_NET_INTERNAL; + break; } client->GetCallback().SignalNetClientNotification(failureCode); } - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_inviteNotifyMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_inviteNotifyMessage) { InviteNotifyMessage_t *netInvNotify = &tmpPacket->GetMsg()->choice.inviteNotifyMessage; - if (netInvNotify->playerIdWho == client->GetGuiPlayerId()) - { + if (netInvNotify->playerIdWho == client->GetGuiPlayerId()) { client->GetCallback().SignalSelfGameInvitation(netInvNotify->gameId, netInvNotify->playerIdByWhom); } } @@ -1477,39 +1329,31 @@ ClientStateWaitGame::Exit(boost::shared_ptr /*client*/) void ClientStateWaitGame::InternalHandlePacket(boost::shared_ptr client, boost::shared_ptr tmpPacket) { - if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_startEventMessage) - { + if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_startEventMessage) { client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_SYNCSTART); client->SetState(ClientStateSynchronizeStart::Instance()); - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_gamePlayerMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_gamePlayerMessage) { GamePlayerMessage_t *netGamePlayer = &tmpPacket->GetMsg()->choice.gamePlayerMessage; // unsigned gameId = netGamePlayer->gameId; - if (netGamePlayer->gamePlayerNotification.present == gamePlayerNotification_PR_gamePlayerJoined) - { + if (netGamePlayer->gamePlayerNotification.present == gamePlayerNotification_PR_gamePlayerJoined) { // Another player joined the network game. GamePlayerJoined_t *netPlayerJoined = &netGamePlayer->gamePlayerNotification.choice.gamePlayerJoined; boost::shared_ptr playerData; PlayerInfo info; - if (client->GetCachedPlayerInfo(netPlayerJoined->playerId, info)) - { + if (client->GetCachedPlayerInfo(netPlayerJoined->playerId, info)) { playerData.reset( new PlayerData(netPlayerJoined->playerId, 0, info.ptype, - info.isGuest ? PLAYER_RIGHTS_GUEST : PLAYER_RIGHTS_NORMAL, netPlayerJoined->isGameAdmin)); + info.isGuest ? PLAYER_RIGHTS_GUEST : PLAYER_RIGHTS_NORMAL, netPlayerJoined->isGameAdmin)); playerData->SetName(info.playerName); - if (info.hasAvatar) - { + if (info.hasAvatar) { string avatarFile; if (client->GetAvatarManager().GetAvatarFileName(info.avatar, avatarFile)) playerData->SetAvatarFile(client->GetQtToolsInterface().stringToUtf8(avatarFile)); else client->RetrieveAvatarIfNeeded(netPlayerJoined->playerId, info); } - } - else - { + } else { ostringstream name; name << "#" << netPlayerJoined->playerId; @@ -1522,17 +1366,13 @@ ClientStateWaitGame::InternalHandlePacket(boost::shared_ptr client } client->AddPlayerData(playerData); } - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_inviteNotifyMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_inviteNotifyMessage) { InviteNotifyMessage_t *netInvNotify = &tmpPacket->GetMsg()->choice.inviteNotifyMessage; client->GetCallback().SignalPlayerGameInvitation( netInvNotify->gameId, netInvNotify->playerIdWho, netInvNotify->playerIdByWhom); - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_rejectInvNotifyMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_rejectInvNotifyMessage) { RejectInvNotifyMessage_t *netRejNotify = &tmpPacket->GetMsg()->choice.rejectInvNotifyMessage; client->GetCallback().SignalRejectedGameInvitation( netRejNotify->gameId, @@ -1577,10 +1417,8 @@ ClientStateSynchronizeStart::Exit(boost::shared_ptr client) void ClientStateSynchronizeStart::TimerLoop(const boost::system::error_code& ec, boost::shared_ptr client) { - if (!ec && &client->GetState() == this) - { - if (client->IsSynchronized()) - { + if (!ec && &client->GetState() == this) { + if (client->IsSynchronized()) { // Acknowledge start. boost::shared_ptr startAck(new NetPacket(NetPacket::Alloc)); startAck->GetMsg()->present = PokerTHMessage_PR_startEventAckMessage; @@ -1592,9 +1430,7 @@ ClientStateSynchronizeStart::TimerLoop(const boost::system::error_code& ec, boos client->UnsubscribeLobbyMsg(); client->SetState(ClientStateWaitStart::Instance()); - } - else - { + } else { client->GetStateTimer().expires_from_now( boost::posix_time::milliseconds(CLIENT_WAIT_TIMEOUT_MSEC)); client->GetStateTimer().async_wait( @@ -1641,8 +1477,7 @@ ClientStateWaitStart::Exit(boost::shared_ptr /*client*/) void ClientStateWaitStart::InternalHandlePacket(boost::shared_ptr client, boost::shared_ptr tmpPacket) { - if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_gameStartMessage) - { + if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_gameStartMessage) { // Start the network game as client. GameStartMessage_t *netGameStart = &tmpPacket->GetMsg()->choice.gameStartMessage; @@ -1655,18 +1490,15 @@ ClientStateWaitStart::InternalHandlePacket(boost::shared_ptr clien NonZeroId_t **playerIds = netGameStart->playerSeats.list.array; unsigned numPlayers = netGameStart->playerSeats.list.count; // Request player info for players if needed. - if (numPlayers && playerIds && *playerIds) - { - for (unsigned i = 0; i < numPlayers; i++) - { + if (numPlayers && playerIds && *playerIds) { + for (unsigned i = 0; i < numPlayers; i++) { unsigned playerId = *playerIds[i]; boost::shared_ptr tmpPlayer = client->GetPlayerDataByUniqueId(playerId); if (!tmpPlayer.get()) throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0); tmpPlayer->SetNumber(i); } - } - else + } else throw ClientException(__FILE__, __LINE__, ERR_NET_INVALID_PLAYER_COUNT, 0); client->InitGame(); @@ -1705,8 +1537,7 @@ ClientStateWaitHand::Exit(boost::shared_ptr /*client*/) void ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr client, boost::shared_ptr tmpPacket) { - if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_handStartMessage) - { + if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_handStartMessage) { // Remove all players which left the server. client->RemoveDisconnectedPlayers(); @@ -1716,23 +1547,19 @@ ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr client int myCards[2]; string userPassword(client->GetContext().GetPassword()); if (netHandStart->yourCards.present == yourCards_PR_plainCards - && userPassword.empty()) - { + && userPassword.empty()) { PlainCards_t *plainCards = &netHandStart->yourCards.choice.plainCards; myCards[0] = (int)plainCards->plainCard1; myCards[1] = (int)plainCards->plainCard2; - } - else if (netHandStart->yourCards.present == yourCards_PR_encryptedCards - && !userPassword.empty()) - { + } else if (netHandStart->yourCards.present == yourCards_PR_encryptedCards + && !userPassword.empty()) { EncryptedCards_t *encryptedCards = &netHandStart->yourCards.choice.encryptedCards; string plainCards; if (!CryptHelper::AES128Decrypt((const unsigned char *)userPassword.c_str(), (unsigned)userPassword.size(), encryptedCards->cardData.buf, encryptedCards->cardData.size, - plainCards)) - { + plainCards)) { throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0); } istringstream cardDataStream(plainCards); @@ -1742,9 +1569,8 @@ ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr client cardDataStream >> tmpGameId; cardDataStream >> tmpHandNum; if (tmpPlayerId != client->GetGuiPlayerId() - || tmpGameId != client->GetGameId() - || tmpHandNum != client->GetGame()->getCurrentHandID() + 1) - { + || tmpGameId != client->GetGameId() + || tmpHandNum != client->GetGame()->getCurrentHandID() + 1) { throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0); } cardDataStream >> myCards[0]; @@ -1765,12 +1591,9 @@ ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr client client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_HAND_START); client->SetState(ClientStateRunHand::Instance()); - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_endOfGameMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_endOfGameMessage) { boost::shared_ptr curGame = client->GetGame(); - if (curGame.get()) - { + if (curGame.get()) { EndOfGameMessage_t *netEndOfGame = &tmpPacket->GetMsg()->choice.endOfGameMessage; boost::shared_ptr tmpPlayer = curGame->getPlayerByUniqueId(netEndOfGame->winnerPlayerId); @@ -1784,9 +1607,7 @@ ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr client client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_END); client->SetState(ClientStateWaitGame::Instance()); } - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_afterHandShowCardsMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_afterHandShowCardsMessage) { AfterHandShowCardsMessage_t *showCards = &tmpPacket->GetMsg()->choice.afterHandShowCardsMessage; PlayerResult_t *r = &showCards->playerResult; @@ -1841,8 +1662,7 @@ void ClientStateRunHand::InternalHandlePacket(boost::shared_ptr client, boost::shared_ptr tmpPacket) { boost::shared_ptr curGame = client->GetGame(); - if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_playersActionDoneMessage) - { + if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_playersActionDoneMessage) { PlayersActionDoneMessage_t *netActionDone = &tmpPacket->GetMsg()->choice.playersActionDoneMessage; boost::shared_ptr tmpPlayer = curGame->getPlayerByUniqueId(netActionDone->playerId); @@ -1851,25 +1671,19 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr client, bool isBigBlind = false; - if (netActionDone->gameState == NetGameState_statePreflopSmallBlind) - { + if (netActionDone->gameState == NetGameState_statePreflopSmallBlind) { curGame->getCurrentHand()->getCurrentBeRo()->setSmallBlindPositionId(tmpPlayer->getMyUniqueID()); tmpPlayer->setMyButton(BUTTON_SMALL_BLIND); - } - else if (netActionDone->gameState == NetGameState_statePreflopBigBlind) - { + } else if (netActionDone->gameState == NetGameState_statePreflopBigBlind) { curGame->getCurrentHand()->getCurrentBeRo()->setBigBlindPositionId(tmpPlayer->getMyUniqueID()); tmpPlayer->setMyButton(BUTTON_BIG_BLIND); isBigBlind = true; - } - else // no blind -> log - { - if (netActionDone->playerAction) - { + } else { // no blind -> log + if (netActionDone->playerAction) { assert(netActionDone->totalPlayerBet >= (long)tmpPlayer->getMySet()); client->GetGui().logPlayerActionMsg( tmpPlayer->getMyName(), - tmpPlayer->getMyID(), + tmpPlayer->getMyID(), netActionDone->playerAction, netActionDone->totalPlayerBet - tmpPlayer->getMySet()); } @@ -1910,9 +1724,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr client, client->GetGui().refreshCash(); client->GetGui().refreshButton(); client->GetGui().updateMyButtonsState(); - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_playersTurnMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_playersTurnMessage) { PlayersTurnMessage_t *netPlayersTurn = &tmpPacket->GetMsg()->choice.playersTurnMessage; boost::shared_ptr tmpPlayer = curGame->getPlayerByUniqueId(netPlayersTurn->playerId); @@ -1920,8 +1732,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr client, throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0); // Set round. - if (curGame->getCurrentHand()->getCurrentRound() != netPlayersTurn->gameState) - { + if (curGame->getCurrentHand()->getCurrentRound() != netPlayersTurn->gameState) { ResetPlayerActions(*curGame); curGame->getCurrentHand()->setCurrentRound(netPlayersTurn->gameState); // Refresh actions. @@ -1946,9 +1757,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr client, if (tmpPlayer->getMyID() == 0) // Is this the GUI player? client->GetGui().meInAction(); - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_dealFlopCardsMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_dealFlopCardsMessage) { DealFlopCardsMessage_t *netDealFlop = &tmpPacket->GetMsg()->choice.dealFlopCardsMessage; int tmpCards[5]; @@ -1965,9 +1774,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr client, client->GetGui().refreshPot(); client->GetGui().refreshSet(); client->GetGui().dealBeRoCards(1); - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_dealTurnCardMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_dealTurnCardMessage) { DealTurnCardMessage_t *netDealTurn = &tmpPacket->GetMsg()->choice.dealTurnCardMessage; int tmpCards[5]; @@ -1982,9 +1789,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr client, client->GetGui().refreshPot(); client->GetGui().refreshSet(); client->GetGui().dealBeRoCards(2); - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_dealRiverCardMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_dealRiverCardMessage) { DealRiverCardMessage_t *netDealRiver = &tmpPacket->GetMsg()->choice.dealRiverCardMessage; int tmpCards[5]; @@ -1999,9 +1804,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr client, client->GetGui().refreshPot(); client->GetGui().refreshSet(); client->GetGui().dealBeRoCards(3); - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_allInShowCardsMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_allInShowCardsMessage) { AllInShowCardsMessage_t *netAllInShow = &tmpPacket->GetMsg()->choice.allInShowCardsMessage; curGame->getCurrentHand()->setAllInCondition(true); @@ -2010,8 +1813,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr client, PlayerAllIn_t **allInPlayers = netAllInShow->playersAllIn.list.array; unsigned numPlayers = netAllInShow->playersAllIn.list.count; // Request player info for players if needed. - for (unsigned i = 0; i < numPlayers; i++) - { + for (unsigned i = 0; i < numPlayers; i++) { PlayerAllIn_t *p = allInPlayers[i]; boost::shared_ptr tmpPlayer = curGame->getPlayerByUniqueId(p->playerId); @@ -2024,13 +1826,10 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr client, tmpPlayer->setMyCards(tmpCards); } client->GetGui().flipHolecardsAllIn(); - } - else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_endOfHandMessage) - { + } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_endOfHandMessage) { EndOfHandMessage_t *netEndHand = &tmpPacket->GetMsg()->choice.endOfHandMessage; - if (netEndHand->endOfHandType.present == endOfHandType_PR_endOfHandHideCards) - { + if (netEndHand->endOfHandType.present == endOfHandType_PR_endOfHandHideCards) { EndOfHandHideCards_t *hideCards = &netEndHand->endOfHandType.choice.endOfHandHideCards; curGame->getCurrentHand()->getBoard()->collectPot(); // Reset player sets @@ -2058,9 +1857,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr client, // Wait for next Hand. client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_SERVER_HAND_END); client->SetState(ClientStateWaitHand::Instance()); - } - else if (netEndHand->endOfHandType.present == endOfHandType_PR_endOfHandShowCards) - { + } else if (netEndHand->endOfHandType.present == endOfHandType_PR_endOfHandShowCards) { EndOfHandShowCards_t *showCards = &netEndHand->endOfHandType.choice.endOfHandShowCards; curGame->getCurrentHand()->getBoard()->collectPot(); @@ -2078,8 +1875,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr client, PlayerResult_t **playerResults = showCards->playerResults.list.array; unsigned numResults = showCards->playerResults.list.count; // Request player info for players if needed. - for (unsigned i = 0; i < numResults; i++) - { + for (unsigned i = 0; i < numResults; i++) { PlayerResult_t *r = playerResults[i]; boost::shared_ptr tmpPlayer = curGame->getPlayerByUniqueId(r->playerId); @@ -2103,7 +1899,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr client, winnerList.push_back(r->playerId); showList.push_back(r->playerId); } - + curGame->getCurrentHand()->setCurrentRound(GAME_STATE_POST_RIVER); curGame->getCurrentHand()->getCurrentBeRo()->setHighestCardsValue(highestValueOfCards); curGame->getCurrentHand()->getBoard()->setPot(0); @@ -2128,8 +1924,7 @@ ClientStateRunHand::ResetPlayerActions(Game &curGame) PlayerListIterator i = curGame.getSeatsList()->begin(); PlayerListIterator end = curGame.getSeatsList()->end(); - while (i != end) - { + while (i != end) { int action = (*i)->getMyAction(); if (action != 1 && action != 6) (*i)->setMyAction(0); @@ -2143,8 +1938,7 @@ ClientStateRunHand::ResetPlayerSets(Game &curGame) { PlayerListIterator i = curGame.getSeatsList()->begin(); PlayerListIterator end = curGame.getSeatsList()->end(); - while (i != end) - { + while (i != end) { (*i)->setMySetNull(); ++i; } diff --git a/src/net/common/clientthread.cpp b/src/net/common/clientthread.cpp index 9779768f..bd5cda80 100644 --- a/src/net/common/clientthread.cpp +++ b/src/net/common/clientthread.cpp @@ -55,22 +55,20 @@ public: ClientSenderCallback() {} virtual ~ClientSenderCallback() {} - virtual void SignalNetError(SessionId /*session*/, int /*errorID*/, int /*osErrorID*/) - { + virtual void SignalNetError(SessionId /*session*/, int /*errorID*/, int /*osErrorID*/) { } - virtual void SignalSessionTerminated(unsigned /*session*/) - { + virtual void SignalSessionTerminated(unsigned /*session*/) { } private: }; ClientThread::ClientThread(GuiInterface &gui, AvatarManager &avatarManager) -: m_ioService(new boost::asio::io_service), m_curState(NULL), m_gui(gui), - m_avatarManager(avatarManager), m_isServerSelected(false), - m_curGameId(0), m_curGameNum(1), m_guiPlayerId(0), m_sessionEstablished(false), - m_stateTimer(*m_ioService), m_avatarTimer(*m_ioService) + : m_ioService(new boost::asio::io_service), m_curState(NULL), m_gui(gui), + m_avatarManager(avatarManager), m_isServerSelected(false), + m_curGameId(0), m_curGameNum(1), m_guiPlayerId(0), m_sessionEstablished(false), + m_stateTimer(*m_ioService), m_avatarTimer(*m_ioService) { m_clientLog.reset(new Log("", 0)); m_context.reset(new ClientContext); @@ -91,8 +89,7 @@ ClientThread::Init( const string &avatarServerAddress, const string &playerName, const string &avatarFile, const string &cacheDir) { - if (IsRunning()) - { + if (IsRunning()) { assert(false); return; } @@ -239,12 +236,11 @@ ClientThread::SendJoinFirstGame(const std::string &password, bool autoLeave) packet->GetMsg()->present = PokerTHMessage_PR_joinGameRequestMessage; JoinGameRequestMessage_t *netJoinGame = &packet->GetMsg()->choice.joinGameRequestMessage; netJoinGame->autoLeave = autoLeave; - if (!password.empty()) - { + if (!password.empty()) { netJoinGame->password = OCTET_STRING_new_fromBuf( - &asn_DEF_UTF8String, - password.c_str(), - password.length()); + &asn_DEF_UTF8String, + password.c_str(), + password.length()); } netJoinGame->joinGameAction.present = joinGameAction_PR_joinExistingGame; @@ -262,12 +258,11 @@ ClientThread::SendJoinGame(unsigned gameId, const std::string &password, bool au packet->GetMsg()->present = PokerTHMessage_PR_joinGameRequestMessage; JoinGameRequestMessage_t *netJoinGame = &packet->GetMsg()->choice.joinGameRequestMessage; netJoinGame->autoLeave = autoLeave; - if (!password.empty()) - { + if (!password.empty()) { netJoinGame->password = OCTET_STRING_new_fromBuf( - &asn_DEF_UTF8String, - password.c_str(), - password.length()); + &asn_DEF_UTF8String, + password.c_str(), + password.length()); } netJoinGame->joinGameAction.present = joinGameAction_PR_joinExistingGame; @@ -285,12 +280,11 @@ ClientThread::SendCreateGame(const GameData &gameData, const std::string &name, packet->GetMsg()->present = PokerTHMessage_PR_joinGameRequestMessage; JoinGameRequestMessage_t *netJoinGame = &packet->GetMsg()->choice.joinGameRequestMessage; netJoinGame->autoLeave = autoLeave; - if (!password.empty()) - { + if (!password.empty()) { netJoinGame->password = OCTET_STRING_new_fromBuf( - &asn_DEF_UTF8String, - password.c_str(), - password.length()); + &asn_DEF_UTF8String, + password.c_str(), + password.length()); } netJoinGame->joinGameAction.present = joinGameAction_PR_joinNewGame; @@ -374,8 +368,7 @@ ClientThread::SendReportAvatar(unsigned reportedPlayerId, const std::string &ava ReportAvatarMessage_t *netReport = &packet->GetMsg()->choice.reportAvatarMessage; netReport->reportedPlayerId = reportedPlayerId; MD5Buf tmpMD5; - if (tmpMD5.FromString(avatarHash) && !tmpMD5.IsZero()) - { + if (tmpMD5.FromString(avatarHash) && !tmpMD5.IsZero()) { OCTET_STRING_fromBuf( &netReport->reportedAvatar, (const char *)tmpMD5.GetData(), @@ -401,23 +394,19 @@ ClientThread::StartAsyncRead() void ClientThread::HandleRead(const boost::system::error_code& ec, size_t bytesRead) { - if (!ec) - { + if (!ec) { ReceiveBuffer &buf = GetContext().GetSessionData()->GetReceiveBuffer(); buf.recvBufUsed += bytesRead; GetReceiver().ScanPackets(buf); - while (!buf.receivedPackets.empty()) - { + while (!buf.receivedPackets.empty()) { boost::shared_ptr packet = buf.receivedPackets.front(); buf.receivedPackets.pop_front(); if (packet) GetState().HandlePacket(shared_from_this(), packet); } StartAsyncRead(); - } - else - { + } else { if (ec != boost::asio::error::operation_aborted) throw NetException(__FILE__, __LINE__, ERR_SOCK_CONN_RESET, 0); } @@ -446,8 +435,7 @@ ClientThread::GetServerInfo(unsigned serverId) const ServerInfo tmpInfo; boost::mutex::scoped_lock lock(m_serverInfoMapMutex); ServerInfoMap::const_iterator pos = m_serverInfoMap.find(serverId); - if (pos != m_serverInfoMap.end()) - { + if (pos != m_serverInfoMap.end()) { tmpInfo = pos->second; } return tmpInfo; @@ -459,8 +447,7 @@ ClientThread::GetGameInfo(unsigned gameId) const GameInfo tmpInfo; boost::mutex::scoped_lock lock(m_gameInfoMapMutex); GameInfoMap::const_iterator pos = m_gameInfoMap.find(gameId); - if (pos != m_gameInfoMap.end()) - { + if (pos != m_gameInfoMap.end()) { tmpInfo = pos->second; } return tmpInfo; @@ -470,8 +457,7 @@ PlayerInfo ClientThread::GetPlayerInfo(unsigned playerId) const { PlayerInfo info; - if (!GetCachedPlayerInfo(playerId, info)) - { + if (!GetCachedPlayerInfo(playerId, info)) { ostringstream name; name << "#" << playerId; @@ -489,10 +475,8 @@ ClientThread::GetPlayerIdFromName(const string &playerName, unsigned &playerId) PlayerInfoMap::const_reverse_iterator i = m_playerInfoMap.rbegin(); PlayerInfoMap::const_reverse_iterator end = m_playerInfoMap.rend(); - while (i != end) - { - if (i->second.playerName == playerName) - { + while (i != end) { + if (i->second.playerName == playerName) { playerId = i->first; retVal = true; break; @@ -511,14 +495,11 @@ ClientThread::GetGameIdOfPlayer(unsigned playerId) const boost::mutex::scoped_lock lock(m_gameInfoMapMutex); GameInfoMap::const_iterator i = m_gameInfoMap.begin(); GameInfoMap::const_iterator i_end = m_gameInfoMap.end(); - while (i != i_end) - { + while (i != i_end) { PlayerIdList::const_iterator j = (*i).second.players.begin(); PlayerIdList::const_iterator j_end = (*i).second.players.end(); - while (j != j_end) - { - if (playerId == *j) - { + while (j != j_end) { + if (playerId == *j) { gameId = (*i).first; break; } @@ -554,8 +535,7 @@ ClientThread::Main() { // Main loop. boost::asio::io_service::work ioWork(*m_ioService); - try - { + try { InitAuthContext(); // Start sub-threads. m_avatarDownloader.reset(new DownloaderThread); @@ -566,8 +546,7 @@ ClientThread::Main() boost::asio::io_service::work ioWork(*m_ioService); m_ioService->run(); // Will only be aborted asynchronously. - } catch (const PokerTHException &e) - { + } catch (const PokerTHException &e) { GetCallback().SignalNetClientError(e.GetErrorId(), e.GetOsErrorCode()); } // Close the socket. @@ -608,8 +587,7 @@ ClientThread::InitAuthContext() if (res != GSASL_OK) throw ClientException(__FILE__, __LINE__, ERR_NET_GSASL_INIT_FAILED, 0); - if (!gsasl_server_support_p(m_authContext, "SCRAM-SHA-1")) - { + if (!gsasl_server_support_p(m_authContext, "SCRAM-SHA-1")) { gsasl_done(m_authContext); throw ClientException(__FILE__, __LINE__, ERR_NET_GSASL_NO_SCRAM, 0); } @@ -655,13 +633,11 @@ ClientThread::SendSessionPacket(boost::shared_ptr packet) void ClientThread::SendQueuedPackets() { - if (!m_outPacketList.empty()) - { + if (!m_outPacketList.empty()) { NetPacketList::iterator i = m_outPacketList.begin(); NetPacketList::iterator end = m_outPacketList.end(); - while (i != end) - { + while (i != end) { GetSender().Send(GetContext().GetSessionData(), *i); ++i; } @@ -676,8 +652,7 @@ ClientThread::GetCachedPlayerInfo(unsigned id, PlayerInfo &info) const boost::mutex::scoped_lock lock(m_playerInfoMapMutex); PlayerInfoMap::const_iterator pos = m_playerInfoMap.find(id); - if (pos != m_playerInfoMap.end()) - { + if (pos != m_playerInfoMap.end()) { info = pos->second; retVal = true; } @@ -687,8 +662,7 @@ ClientThread::GetCachedPlayerInfo(unsigned id, PlayerInfo &info) const void ClientThread::RequestPlayerInfo(unsigned id, bool requestAvatar) { - if (find(m_playerInfoRequestList.begin(), m_playerInfoRequestList.end(), id) == m_playerInfoRequestList.end()) - { + if (find(m_playerInfoRequestList.begin(), m_playerInfoRequestList.end(), id) == m_playerInfoRequestList.end()) { boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); packet->GetMsg()->present = PokerTHMessage_PR_playerInfoRequestMessage; PlayerInfoRequestMessage_t *netPlayerInfo = &packet->GetMsg()->choice.playerInfoRequestMessage; @@ -699,8 +673,7 @@ ClientThread::RequestPlayerInfo(unsigned id, bool requestAvatar) } // Remember that we have to request an avatar. - if (requestAvatar) - { + if (requestAvatar) { m_avatarShouldRequestList.push_back(id); } } @@ -715,14 +688,11 @@ ClientThread::SetPlayerInfo(unsigned id, const PlayerInfo &info) // This can only be one entry, since every time a duplicate // name is added one is removed. // Only erase non computer player entries. - if (info.playerName.substr(0, sizeof(SERVER_COMPUTER_PLAYER_NAME) - 1) != SERVER_COMPUTER_PLAYER_NAME) - { + if (info.playerName.substr(0, sizeof(SERVER_COMPUTER_PLAYER_NAME) - 1) != SERVER_COMPUTER_PLAYER_NAME) { PlayerInfoMap::iterator i = m_playerInfoMap.begin(); PlayerInfoMap::iterator end = m_playerInfoMap.end(); - while (i != end) - { - if (i->first != id && i->second.playerName == info.playerName) - { + while (i != end) { + if (i->first != id && i->second.playerName == info.playerName) { m_playerInfoMap.erase(i); break; } @@ -734,22 +704,18 @@ ClientThread::SetPlayerInfo(unsigned id, const PlayerInfo &info) // Update player data for current game. boost::shared_ptr playerData = GetPlayerDataByUniqueId(id); - if (playerData.get()) - { + if (playerData.get()) { playerData->SetName(info.playerName); playerData->SetType(info.ptype); - if (info.hasAvatar) - { + if (info.hasAvatar) { string avatarFile; - if (GetAvatarManager().GetAvatarFileName(info.avatar, avatarFile)) - { + if (GetAvatarManager().GetAvatarFileName(info.avatar, avatarFile)) { playerData->SetAvatarFile(GetQtToolsInterface().stringToUtf8(avatarFile)); } } } - if (find(m_avatarShouldRequestList.begin(), m_avatarShouldRequestList.end(), id) != m_avatarShouldRequestList.end()) - { + if (find(m_avatarShouldRequestList.begin(), m_avatarShouldRequestList.end(), id) != m_avatarShouldRequestList.end()) { m_avatarShouldRequestList.remove(id); // Retrieve avatar if needed. RetrieveAvatarIfNeeded(id, info); @@ -777,8 +743,7 @@ ClientThread::SetNewGameAdmin(unsigned id) { // Update player data for current game. boost::shared_ptr playerData = GetPlayerDataByUniqueId(id); - if (playerData.get()) - { + if (playerData.get()) { playerData->SetGameAdmin(true); GetCallback().SignalNetClientNewGameAdmin(id, playerData->GetName()); } @@ -787,22 +752,17 @@ ClientThread::SetNewGameAdmin(unsigned id) void ClientThread::RetrieveAvatarIfNeeded(unsigned id, const PlayerInfo &info) { - if (find(m_avatarHasRequestedList.begin(), m_avatarHasRequestedList.end(), id) == m_avatarHasRequestedList.end()) - { - if (info.hasAvatar && !info.avatar.IsZero() && !GetAvatarManager().HasAvatar(info.avatar)) - { + if (find(m_avatarHasRequestedList.begin(), m_avatarHasRequestedList.end(), id) == m_avatarHasRequestedList.end()) { + if (info.hasAvatar && !info.avatar.IsZero() && !GetAvatarManager().HasAvatar(info.avatar)) { m_avatarHasRequestedList.push_back(id); // Never remove from this list. Only request once. // Download from avatar server if applicable. string avatarServerAddress(GetContext().GetAvatarServerAddr()); - if (!avatarServerAddress.empty() && m_avatarDownloader) - { + if (!avatarServerAddress.empty() && m_avatarDownloader) { string serverFileName(info.avatar.ToString() + AvatarManager::GetAvatarFileExtension(info.avatarType)); m_avatarDownloader->QueueDownload( id, avatarServerAddress + serverFileName, GetContext().GetCacheDir() + TEMP_AVATAR_FILENAME); - } - else - { + } else { boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); packet->GetMsg()->present = PokerTHMessage_PR_avatarRequestMessage; AvatarRequestMessage_t *netAvatar = &packet->GetMsg()->choice.avatarRequestMessage; @@ -860,8 +820,7 @@ ClientThread::PassAvatarFileToManager(unsigned playerId, boost::shared_ptrfileType == AVATAR_FILE_TYPE_UNKNOWN) AvatarFile->fileType = tmpPlayerInfo.avatarType; if (!GetAvatarManager().StoreAvatarInCache(tmpPlayerInfo.avatar, AvatarFile->fileType, &AvatarFile->fileData[0], AvatarFile->reportedSize, false)) @@ -871,8 +830,7 @@ ClientThread::PassAvatarFileToManager(unsigned playerId, boost::shared_ptrHasDownloadResult()) - { + if (!ec) { + if (m_avatarDownloader && m_avatarDownloader->HasDownloadResult()) { unsigned playerId; boost::shared_ptr tmpAvatar(new AvatarFile); m_avatarDownloader->GetDownloadResult(playerId, tmpAvatar->fileData); @@ -910,8 +866,7 @@ ClientThread::TimerCheckAvatarDownloads(const boost::system::error_code& ec) void ClientThread::UnsubscribeLobbyMsg() { - if (GetContext().GetSubscribeLobbyMsg()) - { + if (GetContext().GetSubscribeLobbyMsg()) { // Send unsubscribe request. boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); packet->GetMsg()->present = PokerTHMessage_PR_subscriptionRequestMessage; @@ -925,8 +880,7 @@ ClientThread::UnsubscribeLobbyMsg() void ClientThread::ResubscribeLobbyMsg() { - if (!GetContext().GetSubscribeLobbyMsg()) - { + if (!GetContext().GetSubscribeLobbyMsg()) { // Clear game info map as it is outdated. ClearGameInfoMap(); // Send resubscribe request. @@ -970,14 +924,13 @@ ClientThread::CreateContextSession() newSock->set_option(boost::asio::socket_base::keep_alive(true)); GetContext().SetSessionData(boost::shared_ptr(new SessionData( - newSock, - SESSION_ID_GENERIC, - *m_senderCallback))); + newSock, + SESSION_ID_GENERIC, + *m_senderCallback))); GetContext().SetResolver(boost::shared_ptr( - new boost::asio::ip::tcp::resolver(*m_ioService))); + new boost::asio::ip::tcp::resolver(*m_ioService))); validSocket = true; - } catch (...) - { + } catch (...) { } if (!validSocket) throw ClientException(__FILE__, __LINE__, ERR_SOCK_CREATION_FAILED, 0); @@ -1094,8 +1047,7 @@ ClientThread::GetQtToolsInterface() void ClientThread::AddPlayerData(boost::shared_ptr playerData) { - if (playerData.get() && !playerData->GetName().empty()) - { + if (playerData.get() && !playerData->GetName().empty()) { m_playerDataList.push_back(playerData); if (playerData->GetUniqueId() == GetGuiPlayerId()) GetCallback().SignalNetClientSelfJoined(playerData->GetUniqueId(), playerData->GetName(), playerData->IsGameAdmin()); @@ -1111,10 +1063,8 @@ ClientThread::RemovePlayerData(unsigned playerId, int removeReason) PlayerDataList::iterator i = m_playerDataList.begin(); PlayerDataList::iterator end = m_playerDataList.end(); - while (i != end) - { - if ((*i)->GetUniqueId() == playerId) - { + while (i != end) { + if ((*i)->GetUniqueId() == playerId) { tmpData = *i; m_playerDataList.erase(i); break; @@ -1122,8 +1072,7 @@ ClientThread::RemovePlayerData(unsigned playerId, int removeReason) ++i; } - if (tmpData.get()) - { + if (tmpData.get()) { // Remove player from gui. GetCallback().SignalNetClientPlayerLeft(tmpData->GetUniqueId(), tmpData->GetName(), removeReason); } @@ -1151,8 +1100,7 @@ ClientThread::MapPlayerDataList() PlayerDataList::const_iterator end = m_playerDataList.end(); int numPlayers = GetStartData().numberOfPlayers; - while (i != end) - { + while (i != end) { boost::shared_ptr tmpData(new PlayerData(*(*i))); int numberDiff = tmpData->GetNumber() - guiPlayerNum; if (numberDiff >= 0) @@ -1183,10 +1131,8 @@ ClientThread::GetPlayerDataByUniqueId(unsigned id) PlayerDataList::const_iterator i = m_playerDataList.begin(); PlayerDataList::const_iterator end = m_playerDataList.end(); - while (i != end) - { - if ((*i)->GetUniqueId() == id) - { + while (i != end) { + if ((*i)->GetUniqueId() == id) { tmpPlayer = *i; break; } @@ -1200,15 +1146,12 @@ ClientThread::GetPlayerDataByName(const std::string &name) { boost::shared_ptr tmpPlayer; - if (!name.empty()) - { + if (!name.empty()) { PlayerDataList::const_iterator i = m_playerDataList.begin(); PlayerDataList::const_iterator end = m_playerDataList.end(); - while (i != end) - { - if ((*i)->GetName() == name) - { + while (i != end) { + if ((*i)->GetName() == name) { tmpPlayer = *i; break; } @@ -1222,19 +1165,15 @@ void ClientThread::RemoveDisconnectedPlayers() { // This should only be called between hands. - if (m_game) - { + if (m_game) { PlayerList tmpList(m_game->getSeatsList()); PlayerListIterator i = tmpList->begin(); PlayerListIterator end = tmpList->end(); - while (i != end) - { + while (i != end) { boost::shared_ptr tmpPlayer = *i; - if (tmpPlayer->getMyActiveStatus()) - { + if (tmpPlayer->getMyActiveStatus()) { // If a player is not in the player data list, it was disconnected. - if (!GetPlayerDataByUniqueId(tmpPlayer->getMyUniqueID()).get()) - { + if (!GetPlayerDataByUniqueId(tmpPlayer->getMyUniqueID()).get()) { tmpPlayer->setMyCash(0); tmpPlayer->setMyActiveStatus(false); } @@ -1269,8 +1208,7 @@ ClientThread::GetSelectedServer(unsigned &serverId) const { bool retVal = false; boost::mutex::scoped_lock lock(m_selectServerMutex); - if (m_isServerSelected) - { + if (m_isServerSelected) { retVal = true; serverId = m_selectedServerId; } @@ -1297,8 +1235,7 @@ ClientThread::GetLoginData(LoginData &loginData) const { bool retVal = false; boost::mutex::scoped_lock lock(m_loginDataMutex); - if (!m_loginData.userName.empty()) - { + if (!m_loginData.userName.empty()) { loginData = m_loginData; retVal = true; } @@ -1312,8 +1249,7 @@ ClientThread::GetGameIdByName(const std::string &name) const boost::mutex::scoped_lock lock(m_gameInfoMapMutex); GameInfoMap::const_iterator i = m_gameInfoMap.begin(); GameInfoMap::const_iterator end = m_gameInfoMap.end(); - while (i != end) - { + while (i != end) { if (i->second.name == name) break; ++i; @@ -1341,8 +1277,7 @@ ClientThread::UpdateGameInfoMode(unsigned gameId, GameMode mode) { boost::mutex::scoped_lock lock(m_gameInfoMapMutex); GameInfoMap::iterator pos = m_gameInfoMap.find(gameId); - if (pos != m_gameInfoMap.end()) - { + if (pos != m_gameInfoMap.end()) { found = true; (*pos).second.mode = mode; } @@ -1358,8 +1293,7 @@ ClientThread::UpdateGameInfoAdmin(unsigned gameId, unsigned adminPlayerId) { boost::mutex::scoped_lock lock(m_gameInfoMapMutex); GameInfoMap::iterator pos = m_gameInfoMap.find(gameId); - if (pos != m_gameInfoMap.end()) - { + if (pos != m_gameInfoMap.end()) { found = true; (*pos).second.adminPlayerId = adminPlayerId; } @@ -1375,8 +1309,7 @@ ClientThread::RemoveGameInfo(unsigned gameId) { boost::mutex::scoped_lock lock(m_gameInfoMapMutex); GameInfoMap::iterator pos = m_gameInfoMap.find(gameId); - if (pos != m_gameInfoMap.end()) - { + if (pos != m_gameInfoMap.end()) { found = true; m_gameInfoMap.erase(pos); } @@ -1392,8 +1325,7 @@ ClientThread::ModifyGameInfoAddPlayer(unsigned gameId, unsigned playerId) { boost::mutex::scoped_lock lock(m_gameInfoMapMutex); GameInfoMap::iterator pos = m_gameInfoMap.find(gameId); - if (pos != m_gameInfoMap.end()) - { + if (pos != m_gameInfoMap.end()) { pos->second.players.push_back(playerId); playerAdded = true; } @@ -1409,8 +1341,7 @@ ClientThread::ModifyGameInfoRemovePlayer(unsigned gameId, unsigned playerId) { boost::mutex::scoped_lock lock(m_gameInfoMapMutex); GameInfoMap::iterator pos = m_gameInfoMap.find(gameId); - if (pos != m_gameInfoMap.end()) - { + if (pos != m_gameInfoMap.end()) { pos->second.players.remove(playerId); playerRemoved = true; } @@ -1435,8 +1366,7 @@ ClientThread::StartPetition(unsigned petitionId, unsigned proposingPlayerId, uns } GetGui().startVoteOnKick(kickPlayerId, proposingPlayerId, timeoutSec, numVotesToKick); if (GetGuiPlayerId() != kickPlayerId - && GetGuiPlayerId() != proposingPlayerId) - { + && GetGuiPlayerId() != proposingPlayerId) { GetGui().changeVoteOnKickButtonsState(true); } } @@ -1449,8 +1379,7 @@ ClientThread::UpdatePetition(unsigned petitionId, int /*numVotesAgainstKicking*/ boost::mutex::scoped_lock lock(m_curPetitionIdMutex); isCurPetition = m_curPetitionId == petitionId; } - if (isCurPetition) - { + if (isCurPetition) { GetGui().refreshVotesMonitor(numVotesInFavourOfKicking, numVotesToKick); } } @@ -1499,8 +1428,7 @@ ClientThread::IsSessionEstablished() const void ClientThread::SetSessionEstablished(bool flag) { - if (m_sessionEstablished != flag) - { + if (m_sessionEstablished != flag) { m_sessionEstablished = flag; if (flag) SendQueuedPackets(); diff --git a/src/net/common/downloaderthread.cpp b/src/net/common/downloaderthread.cpp index 34261d0f..945bd7b8 100644 --- a/src/net/common/downloaderthread.cpp +++ b/src/net/common/downloaderthread.cpp @@ -33,7 +33,7 @@ using namespace boost::filesystem; DownloaderThread::DownloaderThread() -: m_downloadInProgress(false) + : m_downloadInProgress(false) { m_downloadHelper.reset(new DownloadHelper()); } @@ -61,8 +61,7 @@ DownloaderThread::GetDownloadResult(unsigned &downloadId, std::vectorProcess(); } - if (!m_downloadInProgress) - { + if (!m_downloadInProgress) { // Previous download was finished. - if (m_curDownloadData) - { + if (m_curDownloadData) { path filepath(m_curDownloadData->filename); ifstream instream(filepath.file_string().c_str(), ios_base::in | ios_base::binary); // Find out file size. @@ -119,22 +113,18 @@ DownloaderThread::Main() // Start next download. { boost::mutex::scoped_lock lock(m_downloadQueueMutex); - if (!m_downloadQueue.empty()) - { + if (!m_downloadQueue.empty()) { m_curDownloadData.reset(new DownloadData(m_downloadQueue.front())); m_downloadQueue.pop(); } } - if (m_curDownloadData && !m_curDownloadData->filename.empty()) - { + if (m_curDownloadData && !m_curDownloadData->filename.empty()) { path filepath(m_curDownloadData->filename); m_downloadHelper->Init(m_curDownloadData->address, filepath.file_string()); m_downloadInProgress = true; } } - } - catch (const NetException &e) - { + } catch (const NetException &e) { LOG_ERROR("Download failed: " << e.what()); m_downloadInProgress = false; m_curDownloadData.reset(); diff --git a/src/net/common/encodedpacket.cpp b/src/net/common/encodedpacket.cpp index 34f1c65e..bc9827fc 100644 --- a/src/net/common/encodedpacket.cpp +++ b/src/net/common/encodedpacket.cpp @@ -23,7 +23,7 @@ using namespace std; EncodedPacket::EncodedPacket(const unsigned char *data, unsigned size) -: m_size(size) + : m_size(size) { m_data = new unsigned char[size]; memcpy(m_data, data, size); diff --git a/src/net/common/ircthread.cpp b/src/net/common/ircthread.cpp index baed8e3c..926beccc 100644 --- a/src/net/common/ircthread.cpp +++ b/src/net/common/ircthread.cpp @@ -39,8 +39,7 @@ using namespace std; #define IRC_MAX_NICK_LEN 16 -struct IrcContext -{ +struct IrcContext { IrcContext(IrcThread &t) : ircThread(t), session(NULL), serverPort(0), useIPv6(false), renameTries(0), sendingBlocked(false), sendCounter(0) {} IrcThread &ircThread; irc_session_t *session; @@ -60,34 +59,27 @@ void irc_auto_rename_nick(irc_session_t *session) { IrcContext *context = (IrcContext *) irc_get_ctx(session); - if (context->renameTries <= IRC_MAX_RENAME_TRIES) // Limit number of rename tries. - { + if (context->renameTries <= IRC_MAX_RENAME_TRIES) { // Limit number of rename tries. // Automatically rename the nick on collision. // First: Try to append the string "Lobby". - if (context->nick.find(IRC_RENAME_ATTACH) == string::npos) - { + if (context->nick.find(IRC_RENAME_ATTACH) == string::npos) { if (context->nick.length() + (sizeof(IRC_RENAME_ATTACH)) > IRC_MAX_NICK_LEN) context->nick = context->nick.substr(0, IRC_MAX_NICK_LEN - (sizeof(IRC_RENAME_ATTACH))); context->nick = context->nick + IRC_RENAME_ATTACH; - } - else - { + } else { // This didn't work out. Append a number or increment it. string::reverse_iterator end = context->nick.rbegin(); - if (!context->nick.empty() && isdigit(*end)) - { + if (!context->nick.empty() && isdigit(*end)) { if (*end != '9') *end = (*end) + 1; else context->nick = context->nick + "0"; - } - else + } else context->nick = context->nick + "1"; } irc_cmd_nick(session, context->nick.c_str()); context->renameTries++; - } - else + } else irc_cmd_quit(session, NULL); } @@ -98,8 +90,7 @@ void irc_notify_player_list(irc_session_t *session, const char *players) istringstream input(players); string name; input >> name; - while (!input.fail() && !input.eof()) - { + while (!input.fail() && !input.eof()) { context->ircThread.GetCallback().SignalIrcPlayerJoined(name); input >> name; } @@ -139,8 +130,7 @@ irc_event_nick(irc_session_t *session, const char * /*irc_event*/, const char *o // someone changed his/her nick IrcContext *context = (IrcContext *) irc_get_ctx(session); - if (count && context->nick != params[0]) // only act if this was not an auto-rename - { + if (count && context->nick != params[0]) { // only act if this was not an auto-rename if (context->nick == origin) context->nick = params[0]; context->ircThread.GetCallback().SignalIrcPlayerChanged(origin, params[0]); @@ -179,8 +169,7 @@ irc_event_channel(irc_session_t *session, const char * /*irc_event*/, const char { IrcContext *context = (IrcContext *) irc_get_ctx(session); - if (count >= 2 && boost::algorithm::iequals(context->channel, params[0])) // check whether this message is for our channel - { + if (count >= 2 && boost::algorithm::iequals(context->channel, params[0])) { // check whether this message is for our channel // Signal the message (if any) to GUI. if (*params[1] != 0) context->ircThread.GetCallback().SignalIrcChatMsg(origin, params[1]); @@ -192,8 +181,7 @@ irc_event_unknown(irc_session_t *session, const char * irc_event, const char * / { IrcContext *context = (IrcContext *) irc_get_ctx(session); - if (boost::algorithm::iequals(irc_event, "PONG")) - { + if (boost::algorithm::iequals(irc_event, "PONG")) { context->sendingBlocked = false; context->ircThread.FlushQueue(); } @@ -202,77 +190,76 @@ irc_event_unknown(irc_session_t *session, const char * irc_event, const char * / void irc_event_numeric(irc_session_t * session, unsigned irc_event, const char * /*origin*/, const char **params, unsigned count) { - switch (irc_event) - { - case LIBIRC_RFC_ERR_NICKNAMEINUSE : - case LIBIRC_RFC_ERR_NICKCOLLISION : - irc_auto_rename_nick(session); - break; - case LIBIRC_RFC_RPL_TOPIC : - break; - case LIBIRC_RFC_RPL_NAMREPLY : - if (count >= 4) - irc_notify_player_list(session, params[3]); - break; - case LIBIRC_RFC_ERR_NOSUCHNICK : - case LIBIRC_RFC_ERR_NOSUCHCHANNEL : - case LIBIRC_RFC_ERR_CANNOTSENDTOCHAN : - case LIBIRC_RFC_ERR_TOOMANYCHANNELS : - case LIBIRC_RFC_ERR_WASNOSUCHNICK : - case LIBIRC_RFC_ERR_TOOMANYTARGETS : - case LIBIRC_RFC_ERR_NOSUCHSERVICE : - case LIBIRC_RFC_ERR_NOORIGIN : - case LIBIRC_RFC_ERR_NORECIPIENT : - case LIBIRC_RFC_ERR_NOTEXTTOSEND : - case LIBIRC_RFC_ERR_NOTOPLEVEL : - case LIBIRC_RFC_ERR_WILDTOPLEVEL : - case LIBIRC_RFC_ERR_BADMASK : - case LIBIRC_RFC_ERR_UNKNOWNCOMMAND : - case LIBIRC_RFC_ERR_NOMOTD : - case LIBIRC_RFC_ERR_NOADMININFO : - case LIBIRC_RFC_ERR_FILEERROR : - case LIBIRC_RFC_ERR_NONICKNAMEGIVEN : - case LIBIRC_RFC_ERR_ERRONEUSNICKNAME : - case LIBIRC_RFC_ERR_UNAVAILRESOURCE : - case LIBIRC_RFC_ERR_USERNOTINCHANNEL : - case LIBIRC_RFC_ERR_NOTONCHANNEL : - case LIBIRC_RFC_ERR_USERONCHANNEL : - case LIBIRC_RFC_ERR_NOLOGIN : - case LIBIRC_RFC_ERR_SUMMONDISABLED : - case LIBIRC_RFC_ERR_USERSDISABLED : - case LIBIRC_RFC_ERR_NOTREGISTERED : - case LIBIRC_RFC_ERR_NEEDMOREPARAMS : - case LIBIRC_RFC_ERR_ALREADYREGISTRED : - case LIBIRC_RFC_ERR_NOPERMFORHOST : - case LIBIRC_RFC_ERR_PASSWDMISMATCH : - case LIBIRC_RFC_ERR_YOUREBANNEDCREEP : - case LIBIRC_RFC_ERR_YOUWILLBEBANNED : - case LIBIRC_RFC_ERR_KEYSET : - case LIBIRC_RFC_ERR_CHANNELISFULL : - case LIBIRC_RFC_ERR_UNKNOWNMODE : - case LIBIRC_RFC_ERR_INVITEONLYCHAN : - case LIBIRC_RFC_ERR_BANNEDFROMCHAN : - case LIBIRC_RFC_ERR_BADCHANNELKEY : - case LIBIRC_RFC_ERR_BADCHANMASK : - case LIBIRC_RFC_ERR_NOCHANMODES : - case LIBIRC_RFC_ERR_BANLISTFULL : - case LIBIRC_RFC_ERR_NOPRIVILEGES : - case LIBIRC_RFC_ERR_CHANOPRIVSNEEDED : - case LIBIRC_RFC_ERR_CANTKILLSERVER : - case LIBIRC_RFC_ERR_RESTRICTED : - case LIBIRC_RFC_ERR_UNIQOPPRIVSNEEDED : - case LIBIRC_RFC_ERR_NOOPERHOST : - case LIBIRC_RFC_ERR_UMODEUNKNOWNFLAG : - case LIBIRC_RFC_ERR_USERSDONTMATCH : - irc_handle_server_error(session, irc_event); - break; + switch (irc_event) { + case LIBIRC_RFC_ERR_NICKNAMEINUSE : + case LIBIRC_RFC_ERR_NICKCOLLISION : + irc_auto_rename_nick(session); + break; + case LIBIRC_RFC_RPL_TOPIC : + break; + case LIBIRC_RFC_RPL_NAMREPLY : + if (count >= 4) + irc_notify_player_list(session, params[3]); + break; + case LIBIRC_RFC_ERR_NOSUCHNICK : + case LIBIRC_RFC_ERR_NOSUCHCHANNEL : + case LIBIRC_RFC_ERR_CANNOTSENDTOCHAN : + case LIBIRC_RFC_ERR_TOOMANYCHANNELS : + case LIBIRC_RFC_ERR_WASNOSUCHNICK : + case LIBIRC_RFC_ERR_TOOMANYTARGETS : + case LIBIRC_RFC_ERR_NOSUCHSERVICE : + case LIBIRC_RFC_ERR_NOORIGIN : + case LIBIRC_RFC_ERR_NORECIPIENT : + case LIBIRC_RFC_ERR_NOTEXTTOSEND : + case LIBIRC_RFC_ERR_NOTOPLEVEL : + case LIBIRC_RFC_ERR_WILDTOPLEVEL : + case LIBIRC_RFC_ERR_BADMASK : + case LIBIRC_RFC_ERR_UNKNOWNCOMMAND : + case LIBIRC_RFC_ERR_NOMOTD : + case LIBIRC_RFC_ERR_NOADMININFO : + case LIBIRC_RFC_ERR_FILEERROR : + case LIBIRC_RFC_ERR_NONICKNAMEGIVEN : + case LIBIRC_RFC_ERR_ERRONEUSNICKNAME : + case LIBIRC_RFC_ERR_UNAVAILRESOURCE : + case LIBIRC_RFC_ERR_USERNOTINCHANNEL : + case LIBIRC_RFC_ERR_NOTONCHANNEL : + case LIBIRC_RFC_ERR_USERONCHANNEL : + case LIBIRC_RFC_ERR_NOLOGIN : + case LIBIRC_RFC_ERR_SUMMONDISABLED : + case LIBIRC_RFC_ERR_USERSDISABLED : + case LIBIRC_RFC_ERR_NOTREGISTERED : + case LIBIRC_RFC_ERR_NEEDMOREPARAMS : + case LIBIRC_RFC_ERR_ALREADYREGISTRED : + case LIBIRC_RFC_ERR_NOPERMFORHOST : + case LIBIRC_RFC_ERR_PASSWDMISMATCH : + case LIBIRC_RFC_ERR_YOUREBANNEDCREEP : + case LIBIRC_RFC_ERR_YOUWILLBEBANNED : + case LIBIRC_RFC_ERR_KEYSET : + case LIBIRC_RFC_ERR_CHANNELISFULL : + case LIBIRC_RFC_ERR_UNKNOWNMODE : + case LIBIRC_RFC_ERR_INVITEONLYCHAN : + case LIBIRC_RFC_ERR_BANNEDFROMCHAN : + case LIBIRC_RFC_ERR_BADCHANNELKEY : + case LIBIRC_RFC_ERR_BADCHANMASK : + case LIBIRC_RFC_ERR_NOCHANMODES : + case LIBIRC_RFC_ERR_BANLISTFULL : + case LIBIRC_RFC_ERR_NOPRIVILEGES : + case LIBIRC_RFC_ERR_CHANOPRIVSNEEDED : + case LIBIRC_RFC_ERR_CANTKILLSERVER : + case LIBIRC_RFC_ERR_RESTRICTED : + case LIBIRC_RFC_ERR_UNIQOPPRIVSNEEDED : + case LIBIRC_RFC_ERR_NOOPERHOST : + case LIBIRC_RFC_ERR_UMODEUNKNOWNFLAG : + case LIBIRC_RFC_ERR_USERSDONTMATCH : + irc_handle_server_error(session, irc_event); + break; } } IrcThread::IrcThread(const IrcThread &other) -: Thread(), - m_terminationTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::microsec_timer::manual_start), - m_lastConnectTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::microsec_timer::manual_start) + : Thread(), + m_terminationTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::microsec_timer::manual_start), + m_lastConnectTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::microsec_timer::manual_start) { m_callback = other.m_callback; m_context.reset(new IrcContext(*this)); @@ -289,9 +276,9 @@ IrcThread::IrcThread(const IrcThread &other) } IrcThread::IrcThread(IrcCallback *callback) -: m_callback(callback), - m_terminationTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::microsec_timer::manual_start), - m_lastConnectTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::microsec_timer::manual_start) + : m_callback(callback), + m_terminationTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::microsec_timer::manual_start), + m_lastConnectTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::microsec_timer::manual_start) { assert(callback); m_context.reset(new IrcContext(*this)); @@ -324,19 +311,16 @@ void IrcThread::SendChatMessage(const std::string &msg) { IrcContext &context = GetContext(); - if (!context.sendingBlocked) - { + if (!context.sendingBlocked) { irc_cmd_msg(context.session, context.channel.c_str(), msg.c_str()); context.sendCounter += msg.size(); - if (context.sendCounter >= IRC_SEND_LIMIT_BYTES) - { + if (context.sendCounter >= IRC_SEND_LIMIT_BYTES) { context.sendingBlocked = true; context.sendCounter = 0; SendPing(); } - } - else + } else context.sendQueue.push(msg); } @@ -357,8 +341,7 @@ IrcThread::SignalTermination() void IrcThread::Main() { - do - { + do { if (IrcInit()) IrcMain(); // Will loop until terminated. } while (!ShouldTerminate() && GetContext().session && !irc_is_connected(GetContext().session) && m_lastConnectTimer.elapsed().total_seconds() > IRC_MIN_RECONNECT_INTERVAL_SEC); @@ -370,8 +353,7 @@ IrcThread::IrcInit() bool retVal = false; IrcContext &context = GetContext(); - if (context.session) - { + if (context.session) { irc_destroy_session(context.session); context.session = NULL; } @@ -402,8 +384,7 @@ IrcThread::IrcInit() context.session = irc_create_session(&callbacks); - if (context.session) - { + if (context.session) { irc_set_ctx(context.session, &context); // We want nicknames only, strip them from nick!host. irc_option_set(context.session, LIBIRC_OPTION_STRIPNICKS); @@ -428,23 +409,18 @@ IrcThread::IrcMain() if (!connected) HandleIrcError(irc_errno(s)); - else - { + else { // Main loop. - while (irc_is_connected(s)) - { + while (irc_is_connected(s)) { // Handle thread termination - gracefully. - if (!m_terminationTimer.is_running()) - { + if (!m_terminationTimer.is_running()) { if (ShouldTerminate()) m_terminationTimer.start(); - } - else - { + } else { if (m_terminationTimer.elapsed().total_milliseconds() > IRC_WAIT_TERMINATION_MSEC) break; } - + struct timeval timeout; fd_set readSet, writeSet; int maxfd = 0; @@ -458,17 +434,14 @@ IrcThread::IrcMain() irc_add_select_descriptors(s, &readSet, &writeSet, &maxfd); int selectResult = select(maxfd + 1, &readSet, &writeSet, 0, &timeout); - if (selectResult == -1) - { + if (selectResult == -1) { GetCallback().SignalIrcError(ERR_IRC_SELECT_FAILED); break; } - if (irc_process_select_descriptors(s, &readSet, &writeSet) != 0) - { + if (irc_process_select_descriptors(s, &readSet, &writeSet) != 0) { int errorCode = irc_errno(s); - if (errorCode) - { + if (errorCode) { HandleIrcError(errorCode); break; } @@ -483,8 +456,7 @@ IrcThread::FlushQueue() { IrcContext &context = GetContext(); - while (!context.sendingBlocked && !context.sendQueue.empty()) - { + while (!context.sendingBlocked && !context.sendQueue.empty()) { string msg(context.sendQueue.front()); context.sendQueue.pop(); SendChatMessage(msg); @@ -495,30 +467,29 @@ void IrcThread::HandleIrcError(int errorCode) { int internalErrorCode = ERR_IRC_INTERNAL; - switch(errorCode) - { - case LIBIRC_ERR_RESOLV: - case LIBIRC_ERR_SOCKET: - case LIBIRC_ERR_CONNECT: - internalErrorCode = ERR_IRC_CONNECT_FAILED; - break; - case LIBIRC_ERR_INVAL: - case LIBIRC_ERR_STATE: - internalErrorCode = ERR_IRC_INVALID_PARAM; - break; - case LIBIRC_ERR_CLOSED: - case LIBIRC_ERR_TERMINATED: - internalErrorCode = ERR_IRC_TERMINATED; - break; - case LIBIRC_ERR_READ: - internalErrorCode = ERR_IRC_RECV_FAILED; - break; - case LIBIRC_ERR_WRITE: - internalErrorCode = ERR_IRC_SEND_FAILED; - break; - case LIBIRC_ERR_TIMEOUT: - internalErrorCode = ERR_IRC_TIMEOUT; - break; + switch(errorCode) { + case LIBIRC_ERR_RESOLV: + case LIBIRC_ERR_SOCKET: + case LIBIRC_ERR_CONNECT: + internalErrorCode = ERR_IRC_CONNECT_FAILED; + break; + case LIBIRC_ERR_INVAL: + case LIBIRC_ERR_STATE: + internalErrorCode = ERR_IRC_INVALID_PARAM; + break; + case LIBIRC_ERR_CLOSED: + case LIBIRC_ERR_TERMINATED: + internalErrorCode = ERR_IRC_TERMINATED; + break; + case LIBIRC_ERR_READ: + internalErrorCode = ERR_IRC_RECV_FAILED; + break; + case LIBIRC_ERR_WRITE: + internalErrorCode = ERR_IRC_SEND_FAILED; + break; + case LIBIRC_ERR_TIMEOUT: + internalErrorCode = ERR_IRC_TIMEOUT; + break; } GetCallback().SignalIrcError(internalErrorCode); } diff --git a/src/net/common/netpacket.cpp b/src/net/common/netpacket.cpp index d45ba8dd..33a06234 100644 --- a/src/net/common/netpacket.cpp +++ b/src/net/common/netpacket.cpp @@ -23,7 +23,7 @@ using namespace std; NetPacket::NetPacket(MemAllocType alloc) -: m_msg(NULL) + : m_msg(NULL) { if (alloc != NoAlloc) m_msg = (PokerTHMessage_t *)calloc(1, sizeof(PokerTHMessage_t)); @@ -40,26 +40,20 @@ NetPacket::Create(char *data, unsigned &dataSize) boost::shared_ptr tmpPacket; // Check minimum requirements. - if (data && dataSize > 0) - { + if (data && dataSize > 0) { PokerTHMessage_t *msg = NULL; asn_dec_rval_t retVal = ber_decode(0, &asn_DEF_PokerTHMessage, (void **)&msg, data, dataSize); - if(retVal.code == RC_OK) - { + if(retVal.code == RC_OK) { // ASN.1 BER decoding was successful. tmpPacket.reset(new NetPacket(NoAlloc)); tmpPacket->m_msg = msg; // Consume the bytes. - if (retVal.consumed < dataSize) - { + if (retVal.consumed < dataSize) { dataSize -= retVal.consumed; memmove(data, data + retVal.consumed, dataSize); - } - else + } else dataSize = 0; - } - else - { + } else { // Free the partially decoded message (if applicable). ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg); } @@ -72,15 +66,14 @@ NetPacket::IsClientActivity() const { bool retVal = false; if (m_msg && - (m_msg->present == PokerTHMessage_PR_initMessage - || m_msg->present == PokerTHMessage_PR_joinGameRequestMessage - || m_msg->present == PokerTHMessage_PR_kickPlayerRequestMessage - || m_msg->present == PokerTHMessage_PR_leaveGameRequestMessage - || m_msg->present == PokerTHMessage_PR_startEventMessage - || m_msg->present == PokerTHMessage_PR_myActionRequestMessage - || m_msg->present == PokerTHMessage_PR_resetTimeoutMessage - || m_msg->present == PokerTHMessage_PR_chatRequestMessage)) - { + (m_msg->present == PokerTHMessage_PR_initMessage + || m_msg->present == PokerTHMessage_PR_joinGameRequestMessage + || m_msg->present == PokerTHMessage_PR_kickPlayerRequestMessage + || m_msg->present == PokerTHMessage_PR_leaveGameRequestMessage + || m_msg->present == PokerTHMessage_PR_startEventMessage + || m_msg->present == PokerTHMessage_PR_myActionRequestMessage + || m_msg->present == PokerTHMessage_PR_resetTimeoutMessage + || m_msg->present == PokerTHMessage_PR_chatRequestMessage)) { retVal = true; } return retVal; @@ -112,13 +105,10 @@ NetPacket::SetGameData(const GameData &inData, NetGameInfo_t *outData) outData->netGameType = inData.gameType; outData->maxNumPlayers = inData.maxNumberOfPlayers; outData->raiseIntervalMode.present = static_cast(inData.raiseIntervalMode); - if (inData.raiseIntervalMode == RAISE_ON_HANDNUMBER) - { + if (inData.raiseIntervalMode == RAISE_ON_HANDNUMBER) { outData->raiseIntervalMode.present = raiseIntervalMode_PR_raiseEveryHands; outData->raiseIntervalMode.choice.raiseEveryHands = inData.raiseSmallBlindEveryHandsValue; - } - else - { + } else { outData->raiseIntervalMode.present = raiseIntervalMode_PR_raiseEveryMinutes; outData->raiseIntervalMode.choice.raiseEveryMinutes = inData.raiseSmallBlindEveryMinutesValue; } @@ -130,12 +120,10 @@ NetPacket::SetGameData(const GameData &inData, NetGameInfo_t *outData) outData->firstSmallBlind = inData.firstSmallBlind; outData->startMoney = inData.startMoney; - if (numManualBlinds) - { + if (numManualBlinds) { list::const_iterator i = inData.manualBlindsList.begin(); list::const_iterator end = inData.manualBlindsList.end(); - while (i != end) - { + while (i != end) { long *manualBlind = (long *)calloc(1, sizeof(long)); *manualBlind = *i; ASN_SEQUENCE_ADD(&outData->manualBlinds.list, manualBlind); @@ -168,12 +156,10 @@ NetPacket::GetGameData(const NetGameInfo_t *inData, GameData &outData) outData.afterMBAlwaysRaiseValue = inData->endRaiseSmallBlindValue; outData.startMoney = inData->startMoney; - if (numManualBlinds) - { + if (numManualBlinds) { long **manualBlindsPtr = inData->manualBlinds.list.array; int counter = 0; - for (int i = 0; i < numManualBlinds; i++) - { + for (int i = 0; i < numManualBlinds; i++) { outData.manualBlindsList.push_back((int)*manualBlindsPtr[i]); counter++; } @@ -184,53 +170,52 @@ int NetPacket::NetErrorToGameError(long netErrorReason) { int retVal; - switch(netErrorReason) - { - case errorReason_errorInitVersionNotSupported : - retVal = ERR_NET_VERSION_NOT_SUPPORTED; - break; - case errorReason_errorInitServerFull : - retVal = ERR_NET_SERVER_FULL; - break; - case errorReason_errorInitAuthFailure : - retVal = ERR_NET_INVALID_PASSWORD; - break; - case errorReason_errorInitPlayerNameInUse : - retVal = ERR_NET_PLAYER_NAME_IN_USE; - break; - case errorReason_errorInitInvalidPlayerName : - retVal = ERR_NET_INVALID_PLAYER_NAME; - break; - case errorReason_errorInitServerMaintenance : - retVal = ERR_NET_SERVER_MAINTENANCE; - break; - case errorReason_errorInitBlocked : - retVal = ERR_NET_INIT_BLOCKED; - break; - case errorReason_errorAvatarTooLarge : - retVal = ERR_NET_AVATAR_TOO_LARGE; - break; - case errorReason_errorInvalidPacket : - retVal = ERR_SOCK_INVALID_PACKET; - break; - case errorReason_errorInvalidState : - retVal = ERR_SOCK_INVALID_STATE; - break; - case errorReason_errorKickedFromServer : - retVal = ERR_NET_PLAYER_KICKED; - break; - case errorReason_errorBannedFromServer : - retVal = ERR_NET_PLAYER_BANNED; - break; - case errorReason_errorBlockedByServer : - retVal = ERR_NET_PLAYER_BLOCKED; - break; - case errorReason_errorSessionTimeout : - retVal = ERR_NET_SESSION_TIMED_OUT; - break; - default : - retVal = ERR_SOCK_INTERNAL; - break; + switch(netErrorReason) { + case errorReason_errorInitVersionNotSupported : + retVal = ERR_NET_VERSION_NOT_SUPPORTED; + break; + case errorReason_errorInitServerFull : + retVal = ERR_NET_SERVER_FULL; + break; + case errorReason_errorInitAuthFailure : + retVal = ERR_NET_INVALID_PASSWORD; + break; + case errorReason_errorInitPlayerNameInUse : + retVal = ERR_NET_PLAYER_NAME_IN_USE; + break; + case errorReason_errorInitInvalidPlayerName : + retVal = ERR_NET_INVALID_PLAYER_NAME; + break; + case errorReason_errorInitServerMaintenance : + retVal = ERR_NET_SERVER_MAINTENANCE; + break; + case errorReason_errorInitBlocked : + retVal = ERR_NET_INIT_BLOCKED; + break; + case errorReason_errorAvatarTooLarge : + retVal = ERR_NET_AVATAR_TOO_LARGE; + break; + case errorReason_errorInvalidPacket : + retVal = ERR_SOCK_INVALID_PACKET; + break; + case errorReason_errorInvalidState : + retVal = ERR_SOCK_INVALID_STATE; + break; + case errorReason_errorKickedFromServer : + retVal = ERR_NET_PLAYER_KICKED; + break; + case errorReason_errorBannedFromServer : + retVal = ERR_NET_PLAYER_BANNED; + break; + case errorReason_errorBlockedByServer : + retVal = ERR_NET_PLAYER_BLOCKED; + break; + case errorReason_errorSessionTimeout : + retVal = ERR_NET_SESSION_TIMED_OUT; + break; + default : + retVal = ERR_SOCK_INTERNAL; + break; } return retVal; } @@ -239,53 +224,52 @@ long NetPacket::GameErrorToNetError(int gameErrorReason) { int retVal; - switch(gameErrorReason) - { - case ERR_NET_VERSION_NOT_SUPPORTED : - retVal = errorReason_errorInitVersionNotSupported; - break; - case ERR_NET_SERVER_FULL : - retVal = errorReason_errorInitServerFull; - break; - case ERR_NET_INVALID_PASSWORD : - retVal = errorReason_errorInitAuthFailure; - break; - case ERR_NET_PLAYER_NAME_IN_USE : - retVal = errorReason_errorInitPlayerNameInUse; - break; - case ERR_NET_INVALID_PLAYER_NAME : - retVal = errorReason_errorInitInvalidPlayerName; - break; - case ERR_NET_SERVER_MAINTENANCE : - retVal = errorReason_errorInitServerMaintenance; - break; - case ERR_NET_INIT_BLOCKED : - retVal = errorReason_errorInitBlocked; - break; - case ERR_NET_AVATAR_TOO_LARGE : - retVal = errorReason_errorAvatarTooLarge; - break; - case ERR_SOCK_INVALID_PACKET : - retVal = errorReason_errorInvalidPacket; - break; - case ERR_SOCK_INVALID_STATE : - retVal = errorReason_errorInvalidState; - break; - case ERR_NET_PLAYER_KICKED : - retVal = errorReason_errorKickedFromServer; - break; - case ERR_NET_PLAYER_BLOCKED : - retVal = errorReason_errorBlockedByServer; - break; - case ERR_NET_PLAYER_BANNED : - retVal = errorReason_errorBannedFromServer; - break; - case ERR_NET_SESSION_TIMED_OUT : - retVal = errorReason_errorSessionTimeout; - break; - default : - retVal = errorReason_errorReserved; - break; + switch(gameErrorReason) { + case ERR_NET_VERSION_NOT_SUPPORTED : + retVal = errorReason_errorInitVersionNotSupported; + break; + case ERR_NET_SERVER_FULL : + retVal = errorReason_errorInitServerFull; + break; + case ERR_NET_INVALID_PASSWORD : + retVal = errorReason_errorInitAuthFailure; + break; + case ERR_NET_PLAYER_NAME_IN_USE : + retVal = errorReason_errorInitPlayerNameInUse; + break; + case ERR_NET_INVALID_PLAYER_NAME : + retVal = errorReason_errorInitInvalidPlayerName; + break; + case ERR_NET_SERVER_MAINTENANCE : + retVal = errorReason_errorInitServerMaintenance; + break; + case ERR_NET_INIT_BLOCKED : + retVal = errorReason_errorInitBlocked; + break; + case ERR_NET_AVATAR_TOO_LARGE : + retVal = errorReason_errorAvatarTooLarge; + break; + case ERR_SOCK_INVALID_PACKET : + retVal = errorReason_errorInvalidPacket; + break; + case ERR_SOCK_INVALID_STATE : + retVal = errorReason_errorInvalidState; + break; + case ERR_NET_PLAYER_KICKED : + retVal = errorReason_errorKickedFromServer; + break; + case ERR_NET_PLAYER_BLOCKED : + retVal = errorReason_errorBlockedByServer; + break; + case ERR_NET_PLAYER_BANNED : + retVal = errorReason_errorBannedFromServer; + break; + case ERR_NET_SESSION_TIMED_OUT : + retVal = errorReason_errorSessionTimeout; + break; + default : + retVal = errorReason_errorReserved; + break; } return retVal; } diff --git a/src/net/common/receiverhelper.cpp b/src/net/common/receiverhelper.cpp index 6c5141a0..962c0daa 100644 --- a/src/net/common/receiverhelper.cpp +++ b/src/net/common/receiverhelper.cpp @@ -18,7 +18,7 @@ ***************************************************************************/ #ifdef _WIN32 - #define FD_SETSIZE 512 +#define FD_SETSIZE 512 #endif #include @@ -41,35 +41,29 @@ void ReceiverHelper::ScanPackets(ReceiveBuffer &buf) { bool dataAvailable = true; - do - { + do { boost::shared_ptr tmpPacket; // This is necessary, because we use TCP. // Packets may be received in multiple chunks or // several packets may be received at once. - if (buf.recvBufUsed) - { - try - { + if (buf.recvBufUsed) { + try { // This call will also handle the memmove stuff, i.e. // buffering for partial packets. tmpPacket = NetPacket::Create(buf.recvBuf, buf.recvBufUsed); - } catch (const exception &e) - { + } catch (const exception &e) { // Reset buffer on error. buf.recvBufUsed = 0; LOG_ERROR(e.what()); } } - if (tmpPacket) - { + if (tmpPacket) { //cerr << "IN:" << endl << tmpPacket->ToString() << endl; if (asn_check_constraints(&asn_DEF_PokerTHMessage, tmpPacket->GetMsg(), NULL, NULL) == 0) buf.receivedPackets.push_back(tmpPacket); else LOG_ERROR("Invalid packet: " << endl << tmpPacket->ToString()); - } - else + } else dataAvailable = false; } while(dataAvailable); } diff --git a/src/net/common/resolverthread.cpp b/src/net/common/resolverthread.cpp index b8975d74..13699997 100644 --- a/src/net/common/resolverthread.cpp +++ b/src/net/common/resolverthread.cpp @@ -29,7 +29,7 @@ using namespace std; ResolverThread::ResolverThread() -: m_retVal(false) + : m_retVal(false) { m_context.reset(new ClientContext); } @@ -72,13 +72,13 @@ ResolverThread::Main() // Start the name resolution. m_retVal = socket_resolve( - context.GetServerAddr().c_str(), - tmpStr.str().c_str(), - context.GetAddrFamily(), - SOCK_STREAM, - context.GetProtocol(), - (struct sockaddr *)context.GetClientSockaddr(), - context.GetClientSockaddrSize()); + context.GetServerAddr().c_str(), + tmpStr.str().c_str(), + context.GetAddrFamily(), + SOCK_STREAM, + context.GetProtocol(), + (struct sockaddr *)context.GetClientSockaddr(), + context.GetClientSockaddrSize()); } const ClientContext & diff --git a/src/net/common/senderhelper.cpp b/src/net/common/senderhelper.cpp index 21b91163..18382080 100644 --- a/src/net/common/senderhelper.cpp +++ b/src/net/common/senderhelper.cpp @@ -44,25 +44,23 @@ typedef std::list > SendDataList; class SendDataManager : public boost::enable_shared_from_this { - public: - SendDataManager() - : sendBuf(NULL), writeInProgress(false) - { - } +public: + SendDataManager() + : sendBuf(NULL), writeInProgress(false) { + } - ~SendDataManager() - { - delete[] sendBuf; - } + ~SendDataManager() { + delete[] sendBuf; + } - void HandleWrite(boost::shared_ptr socket, const boost::system::error_code &error); + void HandleWrite(boost::shared_ptr socket, const boost::system::error_code &error); - void AsyncSendNextPacket(boost::shared_ptr socket, bool handlerMode = false); + void AsyncSendNextPacket(boost::shared_ptr socket, bool handlerMode = false); - mutable boost::mutex dataMutex; - SendDataList list; - char *sendBuf; - bool writeInProgress; + mutable boost::mutex dataMutex; + SendDataList list; + char *sendBuf; + bool writeInProgress; }; @@ -77,8 +75,7 @@ void SendDataManager::AsyncSendNextPacket(boost::shared_ptr socket, bool handlerMode) { boost::mutex::scoped_lock lock(dataMutex); - if (!writeInProgress || handlerMode) - { + if (!writeInProgress || handlerMode) { delete[] sendBuf; sendBuf = NULL; @@ -87,18 +84,15 @@ SendDataManager::AsyncSendNextPacket(boost::shared_ptrGetSize(); ++i; } - if (bufSize) - { + if (bufSize) { sendBuf = new char[bufSize]; i = list.begin(); end = list.end(); - while (i != end) - { + while (i != end) { memcpy(sendBuf + bufPos, (*i)->GetData(), (*i)->GetSize()); bufPos += (*i)->GetSize(); ++i; @@ -108,18 +102,17 @@ SendDataManager::AsyncSendNextPacket(boost::shared_ptr ioService) -: m_callback(cb), m_ioService(ioService) + : m_callback(cb), m_ioService(ioService) { } @@ -130,8 +123,7 @@ SenderHelper::~SenderHelper() void SenderHelper::Send(boost::shared_ptr session, boost::shared_ptr packet) { - if (packet && session) - { + if (packet && session) { boost::shared_ptr tmpManager; { // First: lock map of all queues. Locate/insert queue. @@ -144,8 +136,7 @@ SenderHelper::Send(boost::shared_ptr session, boost::shared_ptrdataMutex); - if (tmpManager->list.size() < SEND_QUEUE_SIZE) - { + if (tmpManager->list.size() < SEND_QUEUE_SIZE) { InternalStorePacket(*tmpManager, packet); } } @@ -159,8 +150,7 @@ SenderHelper::Send(boost::shared_ptr session, boost::shared_ptr session, const NetPacketList &packetList) { - if (!packetList.empty() && session) - { + if (!packetList.empty() && session) { boost::shared_ptr tmpManager; { // First: lock map of all queues. Locate/insert queue. @@ -173,12 +163,10 @@ SenderHelper::Send(boost::shared_ptr session, const NetPacketList & { // Second: Add packets to specific queue. boost::mutex::scoped_lock lock(tmpManager->dataMutex); - if (tmpManager->list.size() + packetList.size() <= SEND_QUEUE_SIZE) - { + if (tmpManager->list.size() + packetList.size() <= SEND_QUEUE_SIZE) { NetPacketList::const_iterator i = packetList.begin(); NetPacketList::const_iterator end = packetList.end(); - while (i != end) - { + while (i != end) { if (*i) InternalStorePacket(*tmpManager, *i); ++i; diff --git a/src/net/common/serveraccepthelper.cpp b/src/net/common/serveraccepthelper.cpp index 410b079e..2f484eb0 100644 --- a/src/net/common/serveraccepthelper.cpp +++ b/src/net/common/serveraccepthelper.cpp @@ -28,7 +28,7 @@ using namespace std; using boost::asio::ip::tcp; ServerAcceptHelper::ServerAcceptHelper(ServerCallback &serverCallback, boost::shared_ptr ioService) -: m_ioService(ioService), m_serverCallback(serverCallback) + : m_ioService(ioService), m_serverCallback(serverCallback) { m_acceptor.reset(new tcp::acceptor(*m_ioService)); } @@ -42,17 +42,12 @@ ServerAcceptHelper::Listen(unsigned serverPort, bool ipv6, bool sctp, const stri { m_lobbyThread = lobbyThread; - try - { + try { InternalListen(serverPort, ipv6, sctp); - } - catch (const PokerTHException &e) - { + } catch (const PokerTHException &e) { LOG_ERROR(e.what()); GetCallback().SignalNetServerError(e.GetErrorId(), e.GetOsErrorCode()); - } - catch (...) - { + } catch (...) { // This is probably an asio exception. Assume that bind failed, // which is the most frequent case. LOG_ERROR("Cannot bind/listen on TCP port."); @@ -88,16 +83,15 @@ ServerAcceptHelper::InternalListen(unsigned serverPort, bool ipv6, bool /*sctp*/ m_acceptor->async_accept( *newSocket, boost::bind(&ServerAcceptHelper::HandleAccept, this, newSocket, - boost::asio::placeholders::error) - ); + boost::asio::placeholders::error) + ); } void ServerAcceptHelper::HandleAccept(boost::shared_ptr acceptedSocket, const boost::system::error_code &error) { - if (!error) - { + if (!error) { boost::asio::socket_base::non_blocking_io command(true); acceptedSocket->io_control(command); acceptedSocket->set_option(tcp::no_delay(true)); @@ -108,11 +102,9 @@ ServerAcceptHelper::HandleAccept(boost::shared_ptr m_acceptor->async_accept( *newSocket, boost::bind(&ServerAcceptHelper::HandleAccept, this, newSocket, - boost::asio::placeholders::error) - ); - } - else - { + boost::asio::placeholders::error) + ); + } else { // Accept failed. This is a fatal error. LOG_ERROR("In boost::asio handler: Accept failed."); GetCallback().SignalNetServerError(ERR_SOCK_ACCEPT_FAILED, 0); diff --git a/src/net/common/serveradminbot.cpp b/src/net/common/serveradminbot.cpp index 60568fa8..f66e422c 100644 --- a/src/net/common/serveradminbot.cpp +++ b/src/net/common/serveradminbot.cpp @@ -34,9 +34,9 @@ using namespace std; ServerAdminBot::ServerAdminBot() -: m_notifyTimeoutMinutes(0), m_notifyIntervalMinutes(0), m_notifyCounter(0), - m_ircRestartTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::second_timer::auto_start), - m_notifyTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::second_timer::manual_start) + : m_notifyTimeoutMinutes(0), m_notifyIntervalMinutes(0), m_notifyCounter(0), + m_ircRestartTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::second_timer::auto_start), + m_notifyTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::second_timer::manual_start) { } @@ -67,62 +67,47 @@ ServerAdminBot::SignalIrcSelfJoined(const std::string &nickName, const std::stri void ServerAdminBot::SignalIrcChatMsg(const std::string &nickName, const std::string &msg) { - if (m_ircAdminThread) - { - try - { + if (m_ircAdminThread) { + try { istringstream msgStream(msg); string target; msgStream >> target; - if (boost::algorithm::iequals(target, m_ircNick + ":")) - { + if (boost::algorithm::iequals(target, m_ircNick + ":")) { string command; msgStream >> command; - if (command == "kick") - { + if (command == "kick") { while (msgStream.peek() == ' ') msgStream.get(); string playerName(msgStream.str().substr(msgStream.tellg())); - if (!playerName.empty()) - { + if (!playerName.empty()) { if (GetLobbyThread().KickPlayerByName(playerName)) m_ircAdminThread->SendChatMessage(nickName + ": Successfully kicked player \"" + playerName + "\" from the server."); else m_ircAdminThread->SendChatMessage(nickName + ": Player \"" + playerName + "\" was not found on the server."); } - } - else if (command == "cleaner-reconnect") - { + } else if (command == "cleaner-reconnect") { GetLobbyThread().ReconnectChatBot(); m_ircAdminThread->SendChatMessage(nickName + ": Cleaner bot reconnect initiated."); - } - else if (command == "showip") - { + } else if (command == "showip") { while (msgStream.peek() == ' ') msgStream.get(); string playerName(msgStream.str().substr(msgStream.tellg())); - if (!playerName.empty()) - { + if (!playerName.empty()) { string ipAddress(GetLobbyThread().GetPlayerIPAddress(playerName)); if (!ipAddress.empty()) m_ircAdminThread->SendChatMessage(nickName + ": The IP address of player \"" + playerName + "\" is: \"" + ipAddress + "\""); else m_ircAdminThread->SendChatMessage(nickName + ": The IP address of player \"" + playerName + "\" is unknown."); } - } - else if (command == "bannick") - { + } else if (command == "bannick") { while (msgStream.peek() == ' ') msgStream.get(); string playerRegex(msgStream.str().substr(msgStream.tellg())); - if (!playerRegex.empty()) - { + if (!playerRegex.empty()) { GetLobbyThread().GetBanManager().BanPlayerRegex(playerRegex); m_ircAdminThread->SendChatMessage(nickName + ": The regex \"" + playerRegex + "\" was added to the player ban list."); } - } - else if (command == "banip") - { + } else if (command == "banip") { while (msgStream.peek() == ' ') msgStream.get(); string ipAddress; @@ -132,115 +117,94 @@ ServerAdminBot::SignalIrcChatMsg(const std::string &nickName, const std::string msgStream.get(); if (!msgStream.eof()) msgStream >> durationHours; - if (!ipAddress.empty()) - { + if (!ipAddress.empty()) { ostringstream durationStr; durationStr << durationHours; GetLobbyThread().GetBanManager().BanIPAddress(ipAddress, durationHours); m_ircAdminThread->SendChatMessage(nickName + ": The IP address \"" + ipAddress + "\" was added to the IP address ban list for " + durationStr.str() + (durationHours == 1 ? " hour." : " hours.")); } - } - else if (command == "listban") - { + } else if (command == "listban") { list banList; GetLobbyThread().GetBanManager().GetBanList(banList); list::const_iterator i = banList.begin(); list::const_iterator end = banList.end(); - while (i != end) - { + while (i != end) { m_ircAdminThread->SendChatMessage(*i); ++i; } ostringstream banListStream; banListStream - << nickName << ": Total count of bans: " << banList.size(); + << nickName << ": Total count of bans: " << banList.size(); m_ircAdminThread->SendChatMessage(banListStream.str()); - } - else if (command == "removeban") - { + } else if (command == "removeban") { unsigned banId = 0; msgStream >> banId; if (GetLobbyThread().GetBanManager().UnBan(banId)) m_ircAdminThread->SendChatMessage(nickName + ": The ban was successfully removed."); else m_ircAdminThread->SendChatMessage(nickName + ": This ban does not exist."); - } - else if (command == "clearban") - { + } else if (command == "clearban") { GetLobbyThread().GetBanManager().ClearBanList(); m_ircAdminThread->SendChatMessage(nickName + ": All ban lists were cleared."); - } - else if (command == "stat") - { + } else if (command == "stat") { ServerStats tmpStats = GetLobbyThread().GetStats(); { boost::posix_time::time_duration timeDiff(boost::posix_time::second_clock::local_time() - GetLobbyThread().GetStartTime()); ostringstream statStream; statStream - << "Server uptime................ " << timeDiff.hours() / 24 << " days " << timeDiff.hours() % 24 << " hours " << timeDiff.minutes() << " minutes " << timeDiff.seconds() << " seconds"; + << "Server uptime................ " << timeDiff.hours() / 24 << " days " << timeDiff.hours() % 24 << " hours " << timeDiff.minutes() << " minutes " << timeDiff.seconds() << " seconds"; m_ircAdminThread->SendChatMessage(statStream.str()); } { ostringstream statStream; statStream - << "Players currently on Server.. " << tmpStats.numberOfPlayersOnServer; + << "Players currently on Server.. " << tmpStats.numberOfPlayersOnServer; m_ircAdminThread->SendChatMessage(statStream.str()); } { ostringstream statStream; statStream - << "Games currently open......... " << tmpStats.numberOfGamesOpen; + << "Games currently open......... " << tmpStats.numberOfGamesOpen; m_ircAdminThread->SendChatMessage(statStream.str()); } { ostringstream statStream; statStream - << "Total players ever logged in. " << tmpStats.totalPlayersEverLoggedIn - << " (Max at a time: " << tmpStats.maxPlayersLoggedIn << ")"; + << "Total players ever logged in. " << tmpStats.totalPlayersEverLoggedIn + << " (Max at a time: " << tmpStats.maxPlayersLoggedIn << ")"; m_ircAdminThread->SendChatMessage(statStream.str()); } { ostringstream statStream; statStream - << "Total games ever open........ " << tmpStats.totalGamesEverCreated - << " (Max at a time: " << tmpStats.maxGamesOpen << ")"; + << "Total games ever open........ " << tmpStats.totalGamesEverCreated + << " (Max at a time: " << tmpStats.maxGamesOpen << ")"; m_ircAdminThread->SendChatMessage(statStream.str()); } - } - else if (command == "chat") - { + } else if (command == "chat") { while (msgStream.peek() == ' ') msgStream.get(); string chat(msgStream.str().substr(msgStream.tellg())); - if (!chat.empty() && chat.size() < MAX_CHAT_TEXT_SIZE) - { + if (!chat.empty() && chat.size() < MAX_CHAT_TEXT_SIZE) { GetLobbyThread().SendGlobalChat(chat); m_ircAdminThread->SendChatMessage(nickName + ": Global chat message sent."); - } - else + } else m_ircAdminThread->SendChatMessage(nickName + ": Invalid message."); - } - else if (command == "msg") - { + } else if (command == "msg") { while (msgStream.peek() == ' ') msgStream.get(); string message(msgStream.str().substr(msgStream.tellg())); - if (!message.empty() && message.size() < MAX_CHAT_TEXT_SIZE) - { + if (!message.empty() && message.size() < MAX_CHAT_TEXT_SIZE) { GetLobbyThread().SendGlobalMsgBox(message); m_ircAdminThread->SendChatMessage(nickName + ": Global message box sent."); - } - else + } else m_ircAdminThread->SendChatMessage(nickName + ": Invalid message."); - } - else if (command == "notify-restart") - { + } else if (command == "notify-restart") { int timeoutMinutes = 0; int intervalMinutes = 0; msgStream >> timeoutMinutes; msgStream >> intervalMinutes; - if (timeoutMinutes && intervalMinutes) - { + if (timeoutMinutes && intervalMinutes) { ostringstream ack; ack << nickName << ": Restart planned in " << timeoutMinutes << " minutes, notifying every " << intervalMinutes << " minutes."; m_ircAdminThread->SendChatMessage(ack.str()); @@ -250,18 +214,14 @@ ServerAdminBot::SignalIrcChatMsg(const std::string &nickName, const std::string m_notifyCounter = 0; m_notifyTimer.reset(); m_notifyTimer.start(); - } - else - { + } else { m_ircAdminThread->SendChatMessage(nickName + ": Invalid parameters."); } - } - else + } else m_ircAdminThread->SendChatMessage(nickName + ": Invalid command \"" + command + "\"."); } - } catch (...) - { + } catch (...) { m_ircAdminThread->SendChatMessage(nickName + ": Syntax error. Please check the command."); } } @@ -289,13 +249,10 @@ ServerAdminBot::Run() void ServerAdminBot::Process() { - if (m_ircRestartTimer.elapsed().total_seconds() > SERVER_RESTART_IRC_BOT_INTERVAL_SEC) - { - if (m_ircAdminThread) - { + if (m_ircRestartTimer.elapsed().total_seconds() > SERVER_RESTART_IRC_BOT_INTERVAL_SEC) { + if (m_ircAdminThread) { m_ircAdminThread->SignalTermination(); - if (m_ircAdminThread->Join(NET_ADMIN_IRC_TERMINATE_TIMEOUT_MSEC)) - { + if (m_ircAdminThread->Join(NET_ADMIN_IRC_TERMINATE_TIMEOUT_MSEC)) { boost::shared_ptr tmpIrcThread(new IrcThread(*m_ircAdminThread)); tmpIrcThread->Run(); m_ircAdminThread = tmpIrcThread; @@ -307,12 +264,10 @@ ServerAdminBot::Process() { boost::mutex::scoped_lock lock(m_notifyMutex); - if (m_notifyTimeoutMinutes && m_notifyTimer.elapsed().total_seconds() >= m_notifyCounter * m_notifyIntervalMinutes * 60) - { + if (m_notifyTimeoutMinutes && m_notifyTimer.elapsed().total_seconds() >= m_notifyCounter * m_notifyIntervalMinutes * 60) { int remainingMinutes = m_notifyTimeoutMinutes - m_notifyCounter * m_notifyIntervalMinutes; ++m_notifyCounter; - if (remainingMinutes > 1) - { + if (remainingMinutes > 1) { ostringstream notifyStream; notifyStream << "The server will be restarted in " << remainingMinutes << " minutes."; GetLobbyThread().SendGlobalChat(notifyStream.str()); @@ -328,9 +283,7 @@ ServerAdminBot::Process() notifyStream.str(""); notifyStream << "El servidor se reiniciará en " << remainingMinutes << " minutos."; GetLobbyThread().SendGlobalChat(notifyStream.str()); - } - else if (remainingMinutes == 1) - { + } else if (remainingMinutes == 1) { ostringstream notifyStream; notifyStream << "The server will be restarted in " << remainingMinutes << " minute."; GetLobbyThread().SendGlobalChat(notifyStream.str()); @@ -346,9 +299,7 @@ ServerAdminBot::Process() notifyStream.str(""); notifyStream << "El servidor se reiniciará en " << remainingMinutes << " minuto."; GetLobbyThread().SendGlobalChat(notifyStream.str()); - } - else - { + } else { GetLobbyThread().SendGlobalChat("The server will be restarted NOW."); GetLobbyThread().SendGlobalMsgBox("The server will be restarted NOW."); m_notifyTimeoutMinutes = m_notifyCounter = m_notifyIntervalMinutes = 0; diff --git a/src/net/common/serverbanmanager.cpp b/src/net/common/serverbanmanager.cpp index 05493185..6e7eef7b 100644 --- a/src/net/common/serverbanmanager.cpp +++ b/src/net/common/serverbanmanager.cpp @@ -23,7 +23,7 @@ using namespace std; ServerBanManager::ServerBanManager(boost::shared_ptr ioService) -: m_ioService(ioService), m_curBanId(0) + : m_ioService(ioService), m_curBanId(0) { } @@ -73,18 +73,14 @@ ServerBanManager::UnBan(unsigned banId) bool retVal = false; boost::mutex::scoped_lock lock(m_banMutex); RegexMap::iterator posNick = m_banPlayerNameMap.find(banId); - if (posNick != m_banPlayerNameMap.end()) - { + if (posNick != m_banPlayerNameMap.end()) { if (posNick->second.timer) posNick->second.timer->cancel(); m_banPlayerNameMap.erase(posNick); retVal = true; - } - else - { + } else { IPAddressMap::iterator posIP = m_banIPAddressMap.find(banId); - if (posIP != m_banIPAddressMap.end()) - { + if (posIP != m_banIPAddressMap.end()) { if (posIP->second.timer) posIP->second.timer->cancel(); m_banIPAddressMap.erase(posIP); @@ -100,8 +96,7 @@ ServerBanManager::GetBanList(list &list) const boost::mutex::scoped_lock lock(m_banMutex); RegexMap::const_iterator i_nick = m_banPlayerNameMap.begin(); RegexMap::const_iterator end_nick = m_banPlayerNameMap.end(); - while (i_nick != end_nick) - { + while (i_nick != end_nick) { ostringstream banText; if ((*i_nick).second.nameStr.empty()) banText << (*i_nick).first << ": (nickRegex) - " << (*i_nick).second.nameRegex.str(); @@ -115,8 +110,7 @@ ServerBanManager::GetBanList(list &list) const } IPAddressMap::const_iterator i_ip = m_banIPAddressMap.begin(); IPAddressMap::const_iterator end_ip = m_banIPAddressMap.end(); - while (i_ip != end_ip) - { + while (i_ip != end_ip) { ostringstream banText; banText << (*i_ip).first << ": (IP) - " << (*i_ip).second.ipAddress; if ((*i_ip).second.timer) @@ -141,21 +135,15 @@ ServerBanManager::IsPlayerBanned(const std::string &name) const boost::mutex::scoped_lock lock(m_banMutex); RegexMap::const_iterator i = m_banPlayerNameMap.begin(); RegexMap::const_iterator end = m_banPlayerNameMap.end(); - while (i != end) - { + while (i != end) { // Use regex only if name not set. - if ((*i).second.nameStr.empty()) - { - if (regex_match(name, (*i).second.nameRegex)) - { + if ((*i).second.nameStr.empty()) { + if (regex_match(name, (*i).second.nameRegex)) { retVal = true; break; } - } - else - { - if (name == (*i).second.nameStr) - { + } else { + if (name == (*i).second.nameStr) { retVal = true; break; } @@ -173,10 +161,8 @@ ServerBanManager::IsIPAddressBanned(const std::string &ipAddress) const boost::mutex::scoped_lock lock(m_banMutex); IPAddressMap::const_iterator i = m_banIPAddressMap.begin(); IPAddressMap::const_iterator end = m_banIPAddressMap.end(); - while (i != end) - { - if (ipAddress == (*i).second.ipAddress) - { + while (i != end) { + if (ipAddress == (*i).second.ipAddress) { retVal = true; break; } @@ -191,8 +177,7 @@ ServerBanManager::InitGameNameBadWordList(const std::list &badWordList) { list::const_iterator i = badWordList.begin(); list::const_iterator end = badWordList.end(); - while (i != end) - { + while (i != end) { m_gameNameBadWordFilter.push_back(boost::regex(*i, boost::regex::extended | boost::regex::icase)); ++i; } @@ -204,10 +189,8 @@ ServerBanManager::IsBadGameName(const std::string &name) const bool retVal = false; RegexList::const_iterator i = m_gameNameBadWordFilter.begin(); RegexList::const_iterator end = m_gameNameBadWordFilter.end(); - while (i != end) - { - if (regex_match(name, *i)) - { + while (i != end) { + if (regex_match(name, *i)) { retVal = true; break; } @@ -220,8 +203,7 @@ boost::shared_ptr ServerBanManager::InternalRegisterTimedBan(unsigned timerId, unsigned durationHours) { boost::shared_ptr tmpTimer; - if (durationHours) - { + if (durationHours) { tmpTimer.reset(new boost::asio::deadline_timer(*m_ioService)); tmpTimer->expires_from_now( boost::posix_time::hours(durationHours)); diff --git a/src/net/common/servergame.cpp b/src/net/common/servergame.cpp index e041a534..e9547ee0 100644 --- a/src/net/common/servergame.cpp +++ b/src/net/common/servergame.cpp @@ -50,11 +50,11 @@ static bool LessThanPlayerHandStartMoney(const boost::shared_ptr lobbyThread, u_int32_t id, const string &name, const string &pwd, const GameData &gameData, unsigned adminPlayerId, GuiInterface &gui, ConfigFile &playerConfig, Log &serverLog) -: m_adminPlayerId(adminPlayerId), m_lobbyThread(lobbyThread), m_gui(gui), - m_gameData(gameData), m_curState(NULL), m_id(id), m_dbId(DB_ID_INVALID), m_name(name), - m_password(pwd), m_playerConfig(playerConfig), m_serverLog(serverLog), m_gameNum(1), - m_curPetitionId(1), m_doNotAutoKickSmallDelaySec(10), m_voteKickTimer(lobbyThread->GetIOService()), - m_stateTimer1(lobbyThread->GetIOService()), m_stateTimer2(lobbyThread->GetIOService()) + : m_adminPlayerId(adminPlayerId), m_lobbyThread(lobbyThread), m_gui(gui), + m_gameData(gameData), m_curState(NULL), m_id(id), m_dbId(DB_ID_INVALID), m_name(name), + m_password(pwd), m_playerConfig(playerConfig), m_serverLog(serverLog), m_gameNum(1), + m_curPetitionId(1), m_doNotAutoKickSmallDelaySec(10), m_voteKickTimer(lobbyThread->GetIOService()), + m_stateTimer1(lobbyThread->GetIOService()), m_stateTimer2(lobbyThread->GetIOService()) { LOG_VERBOSE("Game object " << GetId() << " created."); @@ -157,12 +157,10 @@ ServerGame::RemoveAllSessions() void ServerGame::TimerVoteKick(const boost::system::error_code &ec) { - if (!ec && m_curState != &ServerGameStateFinal::Instance()) - { + if (!ec && m_curState != &ServerGameStateFinal::Instance()) { // Check whether someone should be kicked, or whether a vote kick should be aborted. // Only one vote kick can be active at a time. - if (m_voteKickData) - { + if (m_voteKickData) { // Prepare some values. const PlayerIdList playerIds(GetPlayerIdList()); int votesRequiredToKick = m_voteKickData->numVotesToKick - m_voteKickData->numVotesInFavourOfKicking; @@ -170,8 +168,7 @@ ServerGame::TimerVoteKick(const boost::system::error_code &ec) // We need to count the number of players which are still allowed to vote. PlayerIdList::const_iterator player_i = playerIds.begin(); PlayerIdList::const_iterator player_end = playerIds.end(); - while (player_i != player_end) - { + while (player_i != player_end) { if (find(m_voteKickData->votedPlayerIds.begin(), m_voteKickData->votedPlayerIds.end(), *player_i) == m_voteKickData->votedPlayerIds.end()) playersAllowedToVote++; ++player_i; @@ -181,32 +178,27 @@ ServerGame::TimerVoteKick(const boost::system::error_code &ec) EndPetitionReason reason; // 1. Enough votes to kick the player. - if (m_voteKickData->numVotesInFavourOfKicking >= m_voteKickData->numVotesToKick) - { + if (m_voteKickData->numVotesInFavourOfKicking >= m_voteKickData->numVotesToKick) { reason = PETITION_END_ENOUGH_VOTES; abortPetition = true; doKick = true; } // 2. Several players left the game, so a kick is no longer possible. - else if (votesRequiredToKick > playersAllowedToVote) - { + else if (votesRequiredToKick > playersAllowedToVote) { reason = PETITION_END_NOT_ENOUGH_PLAYERS; abortPetition = true; } // 3. The kick has become invalid because the player to be kicked left. - else if (!IsValidPlayer(m_voteKickData->kickPlayerId)) - { + else if (!IsValidPlayer(m_voteKickData->kickPlayerId)) { reason = PETITION_END_PLAYER_LEFT; abortPetition = true; } // 4. A kick request timed out (because not everyone voted). - else if (m_voteKickData->voteTimer.elapsed().total_seconds() >= m_voteKickData->timeLimitSec) - { + else if (m_voteKickData->voteTimer.elapsed().total_seconds() >= m_voteKickData->timeLimitSec) { reason = PETITION_END_TIMEOUT; abortPetition = true; } - if (abortPetition) - { + if (abortPetition) { boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); packet->GetMsg()->present = PokerTHMessage_PR_endKickPetitionMessage; EndKickPetitionMessage_t *netEndPetition = &packet->GetMsg()->choice.endKickPetitionMessage; @@ -239,8 +231,7 @@ ServerGame::InternalStartGame() // Initialize the game. PlayerDataList playerData(GetFullPlayerDataList()); - if (playerData.size() >= 2) - { + if (playerData.size() >= 2) { // Set DB Backend. if (GetGameData().gameType == GAME_TYPE_RANKING) m_database = GetLobbyThread().GetDatabase(); @@ -273,8 +264,7 @@ ServerGame::InternalStartGame() PlayerDataList::const_iterator player_end = playerData.end(); int tmpPos = 0; - while (player_i != player_end) - { + while (player_i != player_end) { startData.startDealerPlayerId = static_cast((*player_i)->GetUniqueId()); if (tmpPos == tmpDealerPos) break; @@ -300,8 +290,7 @@ ServerGame::InitRankingMap(const PlayerDataList &playerDataList) { PlayerDataList::const_iterator i = playerDataList.begin(); PlayerDataList::const_iterator end = playerDataList.end(); - while (i != end) - { + while (i != end) { boost::shared_ptr tmpPlayer(*i); RankingData tmpData(tmpPlayer->GetDBId()); m_rankingMap[tmpPlayer->GetUniqueId()] = tmpData; @@ -318,32 +307,27 @@ ServerGame::UpdateRankingMap() PlayerListIterator active_i = activePlayers.begin(); PlayerListIterator active_end = activePlayers.end(); PlayerListIterator next_active_i = active_i; - while(active_i != active_end) - { + while(active_i != active_end) { ++next_active_i; - if ((*active_i)->getMyCash() < 1) - { + if ((*active_i)->getMyCash() < 1) { tmpRemovedPlayers.push_back(*active_i); activePlayers.erase(active_i); } active_i = next_active_i; } - if (!tmpRemovedPlayers.empty()) - { + if (!tmpRemovedPlayers.empty()) { tmpRemovedPlayers.sort(LessThanPlayerHandStartMoney); PlayerListConstIterator removed_i = tmpRemovedPlayers.begin(); PlayerListConstIterator removed_end = tmpRemovedPlayers.end(); PlayerListConstIterator next_removed_i = removed_i; int currentRankCounter = 0; - while (removed_i != removed_end) - { + while (removed_i != removed_end) { ++next_removed_i; SetPlayerPlace((*removed_i)->getMyUniqueID(), currentRank); ++currentRankCounter; - if (next_removed_i != removed_end && (*removed_i)->getMyRoundStartCash() < (*next_removed_i)->getMyRoundStartCash()) - { + if (next_removed_i != removed_end && (*removed_i)->getMyRoundStartCash() < (*next_removed_i)->getMyRoundStartCash()) { currentRank -= currentRankCounter; currentRankCounter = 0; } @@ -352,8 +336,7 @@ ServerGame::UpdateRankingMap() } } // Last player is winner. - if (activePlayers.size() == 1) - { + if (activePlayers.size() == 1) { SetPlayerPlace((*(activePlayers.begin()))->getMyUniqueID(), 1); } } @@ -362,8 +345,7 @@ void ServerGame::SetPlayerPlace(unsigned playerId, int place) { RankingMap::iterator pos = m_rankingMap.find(playerId); - if (pos != m_rankingMap.end()) - { + if (pos != m_rankingMap.end()) { (*pos).second.place = place; } } @@ -372,14 +354,11 @@ void ServerGame::StoreAndResetRanking() { // Store players in database. - if (GetDBId() != DB_ID_INVALID) - { + if (GetDBId() != DB_ID_INVALID) { RankingMap::const_iterator i = m_rankingMap.begin(); RankingMap::const_iterator end = m_rankingMap.end(); - while (i != end) - { - if ((*i).second.dbid != DB_ID_INVALID) - { + while (i != end) { + if ((*i).second.dbid != DB_ID_INVALID) { GetDatabase().SetGamePlayerPlace(GetDBId(), (*i).second.dbid, (*i).second.place); } ++i; @@ -395,8 +374,7 @@ ServerGame::RemoveAutoLeavePlayers() boost::mutex::scoped_lock lock(m_autoLeavePlayerListMutex); PlayerIdList::const_iterator i = m_autoLeavePlayerList.begin(); PlayerIdList::const_iterator end = m_autoLeavePlayerList.end(); - while (i != end) - { + while (i != end) { SessionWrapper tmpSession = GetSessionManager().GetSessionByUniquePlayerId(*i); // Only remove if the player was found. if (tmpSession.sessionData.get()) @@ -433,18 +411,14 @@ ServerGame::InternalKickPlayer(unsigned playerId) void ServerGame::InternalAskVoteKick(SessionWrapper byWhom, unsigned playerIdWho, unsigned timeoutSec) { - if (IsRunning() && byWhom.playerData) - { + if (IsRunning() && byWhom.playerData) { // Retrieve only the number of human players. size_t numPlayers = GetSessionManager().GetPlayerIdList(SessionData::Game).size(); - if (numPlayers > 2) - { + if (numPlayers > 2) { // Check whether the player to be kicked exists. - if (IsValidPlayer(playerIdWho)) - { + if (IsValidPlayer(playerIdWho)) { // Lock the vote kick data. - if (!m_voteKickData) - { + if (!m_voteKickData) { // Initiate a vote kick. unsigned playerIdByWhom = byWhom.playerData->GetUniqueId(); m_voteKickData.reset(new VoteKickData); @@ -473,17 +447,13 @@ ServerGame::InternalAskVoteKick(SessionWrapper byWhom, unsigned playerIdWho, uns boost::bind( &ServerGame::TimerVoteKick, shared_from_this(), boost::asio::placeholders::error)); - } - else + } else InternalDenyAskVoteKick(byWhom, playerIdWho, KICK_DENIED_OTHER_IN_PROGRESS); - } - else + } else InternalDenyAskVoteKick(byWhom, playerIdWho, KICK_DENIED_INVALID_PLAYER_ID); - } - else + } else InternalDenyAskVoteKick(byWhom, playerIdWho, KICK_DENIED_TOO_FEW_PLAYERS); - } - else + } else InternalDenyAskVoteKick(byWhom, playerIdWho, KICK_DENIED_INVALID_STATE); } @@ -502,15 +472,12 @@ ServerGame::InternalDenyAskVoteKick(SessionWrapper byWhom, unsigned playerIdWho, void ServerGame::InternalVoteKick(SessionWrapper byWhom, unsigned petitionId, KickVote vote) { - if (IsRunning() && byWhom.playerData) - { + if (IsRunning() && byWhom.playerData) { // Check whether this is the valid petition id. - if (m_voteKickData && m_voteKickData->petitionId == petitionId) - { + if (m_voteKickData && m_voteKickData->petitionId == petitionId) { // Check whether the player already voted. unsigned playerId = byWhom.playerData->GetUniqueId(); - if (find(m_voteKickData->votedPlayerIds.begin(), m_voteKickData->votedPlayerIds.end(), playerId) == m_voteKickData->votedPlayerIds.end()) - { + if (find(m_voteKickData->votedPlayerIds.begin(), m_voteKickData->votedPlayerIds.end(), playerId) == m_voteKickData->votedPlayerIds.end()) { m_voteKickData->votedPlayerIds.push_back(playerId); if (vote == KICK_VOTE_IN_FAVOUR) m_voteKickData->numVotesInFavourOfKicking++; @@ -526,14 +493,11 @@ ServerGame::InternalVoteKick(SessionWrapper byWhom, unsigned petitionId, KickVot netKickUpdate->numVotesInFavourOfKicking = m_voteKickData->numVotesInFavourOfKicking; netKickUpdate->numVotesNeededToKick = m_voteKickData->numVotesToKick; SendToAllPlayers(packet, SessionData::Game); - } - else + } else InternalDenyVoteKick(byWhom, petitionId, VOTE_DENIED_ALREADY_VOTED); - } - else + } else InternalDenyVoteKick(byWhom, petitionId, VOTE_DENIED_INVALID_PETITION); - } - else + } else InternalDenyVoteKick(byWhom, petitionId, VOTE_DENIED_INVALID_PETITION); } @@ -567,19 +531,14 @@ ServerGame::GetPlayerDataByUniqueId(unsigned playerId) const { boost::shared_ptr tmpPlayer; SessionWrapper session = GetSessionManager().GetSessionByUniquePlayerId(playerId); - if (session.playerData.get()) - { + if (session.playerData.get()) { tmpPlayer = session.playerData; - } - else - { + } else { boost::mutex::scoped_lock lock(m_computerPlayerListMutex); PlayerDataList::const_iterator i = m_computerPlayerList.begin(); PlayerDataList::const_iterator end = m_computerPlayerList.end(); - while (i != end) - { - if ((*i)->GetUniqueId() == playerId) - { + while (i != end) { + if ((*i)->GetUniqueId() == playerId) { tmpPlayer = *i; break; } @@ -596,8 +555,7 @@ ServerGame::GetPlayerIdList() const boost::mutex::scoped_lock lock(m_computerPlayerListMutex); PlayerDataList::const_iterator i = m_computerPlayerList.begin(); PlayerDataList::const_iterator end = m_computerPlayerList.end(); - while (i != end) - { + while (i != end) { idList.push_back((*i)->GetUniqueId()); ++i; } @@ -693,10 +651,8 @@ ServerGame::RemoveComputerPlayer(unsigned playerId) boost::mutex::scoped_lock lock(m_computerPlayerListMutex); PlayerDataList::iterator i = m_computerPlayerList.begin(); PlayerDataList::iterator end = m_computerPlayerList.end(); - while (i != end) - { - if ((*i)->GetUniqueId() == playerId) - { + while (i != end) { + if ((*i)->GetUniqueId() == playerId) { tmpPlayer = *i; m_computerPlayerList.erase(i); break; @@ -715,8 +671,7 @@ ServerGame::IsComputerPlayerActive(unsigned playerId) const boost::mutex::scoped_lock lock(m_computerPlayerListMutex); PlayerDataList::const_iterator i = m_computerPlayerList.begin(); PlayerDataList::const_iterator end = m_computerPlayerList.end(); - while (i != end) - { + while (i != end) { if ((*i)->GetUniqueId() == playerId) retVal = true; ++i; @@ -732,8 +687,7 @@ ServerGame::ResetComputerPlayerList() PlayerDataList::iterator i = m_computerPlayerList.begin(); PlayerDataList::iterator end = m_computerPlayerList.end(); - while (i != end) - { + while (i != end) { GetLobbyThread().RemoveComputerPlayer(*i); RemovePlayerData(*i, NTF_NET_REMOVED_ON_REQUEST); ++i; @@ -748,11 +702,9 @@ ServerGame::GracefulRemoveSession(SessionWrapper session, int reason) if (!session.sessionData) throw ServerException(__FILE__, __LINE__, ERR_NET_INVALID_SESSION, 0); - if (GetSessionManager().RemoveSession(session.sessionData->GetId())) - { + if (GetSessionManager().RemoveSession(session.sessionData->GetId())) { boost::shared_ptr tmpPlayerData = session.playerData; - if (tmpPlayerData && !tmpPlayerData->GetName().empty()) - { + if (tmpPlayerData && !tmpPlayerData->GetName().empty()) { RemovePlayerData(tmpPlayerData, reason); } } @@ -761,12 +713,10 @@ ServerGame::GracefulRemoveSession(SessionWrapper session, int reason) void ServerGame::RemovePlayerData(boost::shared_ptr player, int reason) { - if (player->IsGameAdmin()) - { + if (player->IsGameAdmin()) { // Find new admin for the game PlayerDataList playerList(GetSessionManager().GetPlayerDataList()); - if (!playerList.empty()) - { + if (!playerList.empty()) { boost::shared_ptr newAdmin = playerList.front(); SetAdminPlayerId(newAdmin->GetUniqueId()); newAdmin->SetGameAdmin(true); @@ -798,17 +748,16 @@ ServerGame::RemovePlayerData(boost::shared_ptr player, int reason) netPlayerLeft->gamePlayerNotification.present = gamePlayerNotification_PR_gamePlayerLeft; GamePlayerLeft_t *gamePlayer = &netPlayerLeft->gamePlayerNotification.choice.gamePlayerLeft; gamePlayer->playerId = player->GetUniqueId(); - switch (reason) - { - case NTF_NET_REMOVED_ON_REQUEST : - gamePlayer->gamePlayerLeftReason = gamePlayerLeftReason_leftOnRequest; - break; - case NTF_NET_REMOVED_KICKED : - gamePlayer->gamePlayerLeftReason = gamePlayerLeftReason_leftKicked; - break; - default : - gamePlayer->gamePlayerLeftReason = gamePlayerLeftReason_leftError; - break; + switch (reason) { + case NTF_NET_REMOVED_ON_REQUEST : + gamePlayer->gamePlayerLeftReason = gamePlayerLeftReason_leftOnRequest; + break; + case NTF_NET_REMOVED_KICKED : + gamePlayer->gamePlayerLeftReason = gamePlayerLeftReason_leftKicked; + break; + default : + gamePlayer->gamePlayerLeftReason = gamePlayerLeftReason_leftError; + break; } GetSessionManager().SendToAllSessions(GetLobbyThread().GetSender(), thisPlayerLeft, SessionData::Game); @@ -845,17 +794,14 @@ void ServerGame::RemoveDisconnectedPlayers() { // This should only be called between hands. - if (m_game) - { + if (m_game) { PlayerList tmpList(m_game->getSeatsList()); PlayerListIterator i = tmpList->begin(); PlayerListIterator end = tmpList->end(); - while (i != end) - { + while (i != end) { boost::shared_ptr tmpPlayer = *i; if ((tmpPlayer->getMyType() == PLAYER_TYPE_HUMAN && !GetSessionManager().IsPlayerConnected(tmpPlayer->getMyUniqueID())) - || (tmpPlayer->getMyType() == PLAYER_TYPE_COMPUTER && !IsComputerPlayerActive(tmpPlayer->getMyUniqueID()))) - { + || (tmpPlayer->getMyType() == PLAYER_TYPE_COMPUTER && !IsComputerPlayerActive(tmpPlayer->getMyUniqueID()))) { // Setting player cash to 0 will deactivate the player. tmpPlayer->setMyCash(0); tmpPlayer->setNetSessionData(boost::shared_ptr()); @@ -879,8 +825,7 @@ ServerGame::AssignPlayerNumbers(PlayerDataList &playerList) PlayerDataList::iterator player_i = playerList.begin(); PlayerDataList::iterator player_end = playerList.end(); - while (player_i != player_end) - { + while (player_i != player_end) { (*player_i)->SetNumber(playerNumber); ++playerNumber; ++player_i; @@ -1034,23 +979,19 @@ bool ServerGame::CheckSettings(const GameData &data, const string &password, ServerMode mode) { bool retVal = true; - if (mode != SERVER_MODE_LAN) - { - if (data.playerActionTimeoutSec < 5) - { + if (mode != SERVER_MODE_LAN) { + if (data.playerActionTimeoutSec < 5) { retVal = false; } } - if (data.gameType == GAME_TYPE_RANKING) - { + if (data.gameType == GAME_TYPE_RANKING) { if ((data.startMoney != RANKING_GAME_START_CASH) - || (data.maxNumberOfPlayers != RANKING_GAME_NUMBER_OF_PLAYERS) - || (data.firstSmallBlind != RANKING_GAME_START_SBLIND) - || (data.raiseIntervalMode != RAISE_ON_HANDNUMBER) - || (data.raiseMode != DOUBLE_BLINDS) - || (data.raiseSmallBlindEveryHandsValue != RANKING_GAME_RAISE_EVERY_HAND) - || (!password.empty())) - { + || (data.maxNumberOfPlayers != RANKING_GAME_NUMBER_OF_PLAYERS) + || (data.firstSmallBlind != RANKING_GAME_START_SBLIND) + || (data.raiseIntervalMode != RAISE_ON_HANDNUMBER) + || (data.raiseMode != DOUBLE_BLINDS) + || (data.raiseSmallBlindEveryHandsValue != RANKING_GAME_RAISE_EVERY_HAND) + || (!password.empty())) { retVal = false; } } diff --git a/src/net/common/servergamestate.cpp b/src/net/common/servergamestate.cpp index 06878401..89ccc6e3 100644 --- a/src/net/common/servergamestate.cpp +++ b/src/net/common/servergamestate.cpp @@ -44,23 +44,23 @@ using namespace std; //#define POKERTH_SERVER_TEST #ifdef POKERTH_SERVER_TEST - #define SERVER_DELAY_NEXT_GAME_SEC 0 - #define SERVER_DEAL_FLOP_CARDS_DELAY_SEC 0 - #define SERVER_DEAL_TURN_CARD_DELAY_SEC 0 - #define SERVER_DEAL_RIVER_CARD_DELAY_SEC 0 - #define SERVER_DEAL_ADD_ALL_IN_DELAY_SEC 0 - #define SERVER_SHOW_CARDS_DELAY_SEC 0 - #define SERVER_COMPUTER_ACTION_DELAY_SEC 0 - #define SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC 1 +#define SERVER_DELAY_NEXT_GAME_SEC 0 +#define SERVER_DEAL_FLOP_CARDS_DELAY_SEC 0 +#define SERVER_DEAL_TURN_CARD_DELAY_SEC 0 +#define SERVER_DEAL_RIVER_CARD_DELAY_SEC 0 +#define SERVER_DEAL_ADD_ALL_IN_DELAY_SEC 0 +#define SERVER_SHOW_CARDS_DELAY_SEC 0 +#define SERVER_COMPUTER_ACTION_DELAY_SEC 0 +#define SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC 1 #else - #define SERVER_DELAY_NEXT_GAME_SEC 10 - #define SERVER_DEAL_FLOP_CARDS_DELAY_SEC 5 - #define SERVER_DEAL_TURN_CARD_DELAY_SEC 2 - #define SERVER_DEAL_RIVER_CARD_DELAY_SEC 2 - #define SERVER_DEAL_ADD_ALL_IN_DELAY_SEC 2 - #define SERVER_SHOW_CARDS_DELAY_SEC 2 - #define SERVER_COMPUTER_ACTION_DELAY_SEC 2 - #define SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC 2 +#define SERVER_DELAY_NEXT_GAME_SEC 10 +#define SERVER_DEAL_FLOP_CARDS_DELAY_SEC 5 +#define SERVER_DEAL_TURN_CARD_DELAY_SEC 2 +#define SERVER_DEAL_RIVER_CARD_DELAY_SEC 2 +#define SERVER_DEAL_ADD_ALL_IN_DELAY_SEC 2 +#define SERVER_SHOW_CARDS_DELAY_SEC 2 +#define SERVER_COMPUTER_ACTION_DELAY_SEC 2 +#define SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC 2 #endif #define SERVER_START_GAME_TIMEOUT_SEC 10 @@ -100,41 +100,44 @@ static void SendNewRoundCards(ServerGame &server, Game &curGame, int state) int cards[5]; curGame.getCurrentHand()->getBoard()->getMyCards(cards); switch(state) { - case GAME_STATE_PREFLOP: { - // nothing to do - } break; - case GAME_STATE_FLOP: { - // deal flop cards - boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); - packet->GetMsg()->present = PokerTHMessage_PR_dealFlopCardsMessage; - DealFlopCardsMessage_t *netDealFlop = &packet->GetMsg()->choice.dealFlopCardsMessage; - netDealFlop->gameId = server.GetId(); - netDealFlop->flopCard1 = cards[0]; - netDealFlop->flopCard2 = cards[1]; - netDealFlop->flopCard3 = cards[2]; - server.SendToAllPlayers(packet, SessionData::Game); - } break; - case GAME_STATE_TURN: { - // deal turn card - boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); - packet->GetMsg()->present = PokerTHMessage_PR_dealTurnCardMessage; - DealTurnCardMessage_t *netDealTurn = &packet->GetMsg()->choice.dealTurnCardMessage; - netDealTurn->gameId = server.GetId(); - netDealTurn->turnCard = cards[3]; - server.SendToAllPlayers(packet, SessionData::Game); - } break; - case GAME_STATE_RIVER: { - // deal river card - boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); - packet->GetMsg()->present = PokerTHMessage_PR_dealRiverCardMessage; - DealRiverCardMessage_t *netDealRiver = &packet->GetMsg()->choice.dealRiverCardMessage; - netDealRiver->gameId = server.GetId(); - netDealRiver->riverCard = cards[4]; - server.SendToAllPlayers(packet, SessionData::Game); - } break; - default: { - // - } + case GAME_STATE_PREFLOP: { + // nothing to do + } break; + case GAME_STATE_FLOP: { + // deal flop cards + boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); + packet->GetMsg()->present = PokerTHMessage_PR_dealFlopCardsMessage; + DealFlopCardsMessage_t *netDealFlop = &packet->GetMsg()->choice.dealFlopCardsMessage; + netDealFlop->gameId = server.GetId(); + netDealFlop->flopCard1 = cards[0]; + netDealFlop->flopCard2 = cards[1]; + netDealFlop->flopCard3 = cards[2]; + server.SendToAllPlayers(packet, SessionData::Game); + } + break; + case GAME_STATE_TURN: { + // deal turn card + boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); + packet->GetMsg()->present = PokerTHMessage_PR_dealTurnCardMessage; + DealTurnCardMessage_t *netDealTurn = &packet->GetMsg()->choice.dealTurnCardMessage; + netDealTurn->gameId = server.GetId(); + netDealTurn->turnCard = cards[3]; + server.SendToAllPlayers(packet, SessionData::Game); + } + break; + case GAME_STATE_RIVER: { + // deal river card + boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); + packet->GetMsg()->present = PokerTHMessage_PR_dealRiverCardMessage; + DealRiverCardMessage_t *netDealRiver = &packet->GetMsg()->choice.dealRiverCardMessage; + netDealRiver->gameId = server.GetId(); + netDealRiver->riverCard = cards[4]; + server.SendToAllPlayers(packet, SessionData::Game); + } + break; + default: { + // + } } } @@ -145,31 +148,33 @@ static void PerformPlayerAction(ServerGame &server, boost::shared_ptrsetMyAction(action); // Only change the player bet if action is not fold/check - if (action != PLAYER_ACTION_FOLD && action != PLAYER_ACTION_CHECK) - { + if (action != PLAYER_ACTION_FOLD && action != PLAYER_ACTION_CHECK) { player->setMySet(bet); // update minimumRaise and lastActionPlayer switch(action) { - case PLAYER_ACTION_BET: { - curGame.getCurrentHand()->getCurrentBeRo()->setMinimumRaise(bet); - curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID()); - } break; - case PLAYER_ACTION_RAISE: { + case PLAYER_ACTION_BET: { + curGame.getCurrentHand()->getCurrentBeRo()->setMinimumRaise(bet); + curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID()); + } + break; + case PLAYER_ACTION_RAISE: { + curGame.getCurrentHand()->getCurrentBeRo()->setMinimumRaise(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet()); + curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID()); + } + break; + case PLAYER_ACTION_ALLIN: { + if(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet() > curGame.getCurrentHand()->getCurrentBeRo()->getMinimumRaise()) { curGame.getCurrentHand()->getCurrentBeRo()->setMinimumRaise(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet()); - curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID()); - } break; - case PLAYER_ACTION_ALLIN: { - if(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet() > curGame.getCurrentHand()->getCurrentBeRo()->getMinimumRaise()) { - curGame.getCurrentHand()->getCurrentBeRo()->setMinimumRaise(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet()); - } - if(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet() > 0) { - curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID()); - } - } break; - default: { } + if(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet() > 0) { + curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID()); + } + } + break; + default: { + } } // update highestSet @@ -193,8 +198,7 @@ SetPlayerResult(PlayerResult_t &playerResult, boost::shared_ptr playerResult.resultCard1 = tmpCards[0]; playerResult.resultCard2 = tmpCards[1]; tmpPlayer->getMyBestHandPosition(bestHandPos); - for (int num = 0; num < 5; num++) - { + for (int num = 0; num < 5; num++) { long *handPos = (long *)calloc(1, sizeof(long)); *handPos = bestHandPos[num]; ASN_SEQUENCE_ADD(&playerResult.bestHandPosition.list, handPos); @@ -222,64 +226,45 @@ AbstractServerGameStateReceiving::ProcessPacket(boost::shared_ptr se { if (packet->IsClientActivity()) session.sessionData->ResetActivityTimer(); - if (packet->GetMsg()->present == PokerTHMessage_PR_playerInfoRequestMessage) - { + if (packet->GetMsg()->present == PokerTHMessage_PR_playerInfoRequestMessage) { // Delegate to Lobby. server->GetLobbyThread().HandleGameRetrievePlayerInfo(session, packet->GetMsg()->choice.playerInfoRequestMessage); - } - else if (packet->GetMsg()->present == PokerTHMessage_PR_avatarRequestMessage) - { + } else if (packet->GetMsg()->present == PokerTHMessage_PR_avatarRequestMessage) { // Delegate to Lobby. server->GetLobbyThread().HandleGameRetrieveAvatar(session, packet->GetMsg()->choice.avatarRequestMessage); - } - else if (packet->GetMsg()->present == PokerTHMessage_PR_leaveGameRequestMessage) - { + } else if (packet->GetMsg()->present == PokerTHMessage_PR_leaveGameRequestMessage) { server->MoveSessionToLobby(session, NTF_NET_REMOVED_ON_REQUEST); - } - else if (packet->GetMsg()->present == PokerTHMessage_PR_kickPlayerRequestMessage) - { + } else if (packet->GetMsg()->present == PokerTHMessage_PR_kickPlayerRequestMessage) { // Only admins are allowed to kick, and only in the lobby. // After leaving the lobby, a vote needs to be initiated to kick. KickPlayerRequestMessage_t *netKickRequest = &packet->GetMsg()->choice.kickPlayerRequestMessage; if (session.playerData->IsGameAdmin() && !server->IsRunning() - && netKickRequest->gameId == server->GetId() && server->GetGameData().gameType != GAME_TYPE_RANKING) - { + && netKickRequest->gameId == server->GetId() && server->GetGameData().gameType != GAME_TYPE_RANKING) { server->InternalKickPlayer(netKickRequest->playerId); } - } - else if (packet->GetMsg()->present == PokerTHMessage_PR_askKickPlayerMessage) - { - if (session.playerData && server->GetGameData().gameType != GAME_TYPE_RANKING) - { + } else if (packet->GetMsg()->present == PokerTHMessage_PR_askKickPlayerMessage) { + if (session.playerData && server->GetGameData().gameType != GAME_TYPE_RANKING) { AskKickPlayerMessage_t *netAskKick = &packet->GetMsg()->choice.askKickPlayerMessage; server->InternalAskVoteKick(session, netAskKick->playerId, SERVER_VOTE_KICK_TIMEOUT_SEC); } - } - else if (packet->GetMsg()->present == PokerTHMessage_PR_voteKickRequestMessage) - { - if (session.playerData) - { + } else if (packet->GetMsg()->present == PokerTHMessage_PR_voteKickRequestMessage) { + if (session.playerData) { VoteKickRequestMessage_t *netVoteKick = &packet->GetMsg()->choice.voteKickRequestMessage; server->InternalVoteKick(session, netVoteKick->petitionId, netVoteKick->voteKick ? KICK_VOTE_IN_FAVOUR : KICK_VOTE_AGAINST); } } // Chat text is always allowed. - else if (packet->GetMsg()->present == PokerTHMessage_PR_chatRequestMessage) - { + else if (packet->GetMsg()->present == PokerTHMessage_PR_chatRequestMessage) { // Only forward if this player is known and not a guest. - if (session.playerData && session.playerData->GetRights() != PLAYER_RIGHTS_GUEST) - { + if (session.playerData && session.playerData->GetRights() != PLAYER_RIGHTS_GUEST) { // Forward chat text to all players. // TODO: Some limitation needed. ChatRequestMessage_t *netChatRequest = &packet->GetMsg()->choice.chatRequestMessage; if (netChatRequest->chatRequestType.present == chatRequestType_PR_chatRequestTypeLobby - || netChatRequest->chatRequestType.present == chatRequestType_PR_chatRequestTypePrivate) - { + || netChatRequest->chatRequestType.present == chatRequestType_PR_chatRequestTypePrivate) { if (!server->IsRunning()) server->GetLobbyThread().HandleChatRequest(session, *netChatRequest); - } - else if (netChatRequest->chatRequestType.present == chatRequestType_PR_chatRequestTypeGame) - { + } else if (netChatRequest->chatRequestType.present == chatRequestType_PR_chatRequestTypeGame) { boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); packet->GetMsg()->present = PokerTHMessage_PR_chatMessage; ChatMessage_t *netChat = &packet->GetMsg()->choice.chatMessage; @@ -296,36 +281,28 @@ AbstractServerGameStateReceiving::ProcessPacket(boost::shared_ptr se // Send the message to the chat cleaner bot for ranking games. //if (server->GetGameData().gameType == GAME_TYPE_RANKING) //{ - server->GetLobbyThread().GetChatCleaner().HandleGameChatText( - server->GetId(), - session.playerData->GetUniqueId(), - session.playerData->GetName(), - string((char *)netChatRequest->chatText.buf, netChatRequest->chatText.size)); + server->GetLobbyThread().GetChatCleaner().HandleGameChatText( + server->GetId(), + session.playerData->GetUniqueId(), + session.playerData->GetName(), + string((char *)netChatRequest->chatText.buf, netChatRequest->chatText.size)); //} } } - } - else if (packet->GetMsg()->present == PokerTHMessage_PR_subscriptionRequestMessage) - { + } else if (packet->GetMsg()->present == PokerTHMessage_PR_subscriptionRequestMessage) { SubscriptionRequestMessage_t *netSubscription = &packet->GetMsg()->choice.subscriptionRequestMessage; - if (netSubscription->subscriptionAction == subscriptionAction_resubscribeGameList) - { + if (netSubscription->subscriptionAction == subscriptionAction_resubscribeGameList) { if (!session.sessionData->WantsLobbyMsg()) server->GetLobbyThread().ResubscribeLobbyMsg(session); - } - else + } else session.sessionData->ResetWantsLobbyMsg(); - } - else if (packet->GetMsg()->present == PokerTHMessage_PR_reportAvatarMessage) - { + } else if (packet->GetMsg()->present == PokerTHMessage_PR_reportAvatarMessage) { ReportAvatarMessage_t *netReport = &packet->GetMsg()->choice.reportAvatarMessage; boost::shared_ptr tmpPlayer = server->GetPlayerDataByUniqueId(netReport->reportedPlayerId); MD5Buf tmpMD5; memcpy(tmpMD5.GetData(), netReport->reportedAvatar.buf, MD5_DATA_SIZE); - if (tmpPlayer && tmpPlayer->GetDBId() && !tmpMD5.IsZero() && tmpPlayer->GetAvatarMD5() == tmpMD5) - { - if (!server->IsAvatarReported(tmpPlayer->GetUniqueId())) - { + if (tmpPlayer && tmpPlayer->GetDBId() && !tmpMD5.IsZero() && tmpPlayer->GetAvatarMD5() == tmpMD5) { + if (!server->IsAvatarReported(tmpPlayer->GetUniqueId())) { // Temporarily note that this avatar was reported. // This prevents spamming of the avatar report. server->AddReportedAvatar(tmpPlayer->GetUniqueId()); @@ -340,16 +317,14 @@ AbstractServerGameStateReceiving::ProcessPacket(boost::shared_ptr se tmpAvatarType.erase(0, 1); // Only store extension without the "." server->GetLobbyThread().GetDatabase()->AsyncReportAvatar( - session.playerData->GetUniqueId(), - tmpPlayer->GetUniqueId(), - tmpPlayer->GetDBId(), - tmpPlayer->GetAvatarMD5().ToString(), - tmpAvatarType, - myDBid != 0 ? &myDBid : NULL + session.playerData->GetUniqueId(), + tmpPlayer->GetUniqueId(), + tmpPlayer->GetDBId(), + tmpPlayer->GetAvatarMD5().ToString(), + tmpAvatarType, + myDBid != 0 ? &myDBid : NULL ); - } - else - { + } else { boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); packet->GetMsg()->present = PokerTHMessage_PR_reportAvatarAckMessage; ReportAvatarAckMessage_t *netReportAck = &packet->GetMsg()->choice.reportAvatarAckMessage; @@ -357,9 +332,7 @@ AbstractServerGameStateReceiving::ProcessPacket(boost::shared_ptr se netReportAck->reportResult = reportResult_avatarReportDuplicate; server->GetLobbyThread().GetSender().Send(session.sessionData, packet); } - } - else - { + } else { boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); packet->GetMsg()->present = PokerTHMessage_PR_reportAvatarAckMessage; ReportAvatarAckMessage_t *netReportAck = &packet->GetMsg()->choice.reportAvatarAckMessage; @@ -367,9 +340,7 @@ AbstractServerGameStateReceiving::ProcessPacket(boost::shared_ptr se netReportAck->reportResult = reportResult_avatarReportInvalid; server->GetLobbyThread().GetSender().Send(session.sessionData, packet); } - } - else - { + } else { // Packet processing in subclass. InternalProcessPacket(server, session, packet); } @@ -422,16 +393,12 @@ ServerGameStateInit::NotifySessionRemoved(boost::shared_ptr server) void ServerGameStateInit::HandleNewSession(boost::shared_ptr server, SessionWrapper session) { - if (session.sessionData && session.playerData) - { + if (session.sessionData && session.playerData) { const GameData &tmpGameData = server->GetGameData(); // Check the number of players. - if (server->GetCurNumberOfPlayers() >= (size_t)tmpGameData.maxNumberOfPlayers) - { + if (server->GetCurNumberOfPlayers() >= (size_t)tmpGameData.maxNumberOfPlayers) { server->MoveSessionToLobby(session, NTF_NET_REMOVED_GAME_FULL); - } - else - { + } else { session.playerData->SetGameAdmin(session.playerData->GetUniqueId() == server->GetAdminPlayerId()); // Send ack to client. @@ -454,8 +421,7 @@ ServerGameStateInit::HandleNewSession(boost::shared_ptr server, Sess PlayerDataList tmpPlayerList = server->GetFullPlayerDataList(); PlayerDataList::iterator player_i = tmpPlayerList.begin(); PlayerDataList::iterator player_end = tmpPlayerList.end(); - while (player_i != player_end) - { + while (player_i != player_end) { server->GetLobbyThread().GetSender().Send(session.sessionData, CreateNetPacketPlayerJoined(server->GetId(), *(*player_i))); ++player_i; } @@ -469,8 +435,7 @@ ServerGameStateInit::HandleNewSession(boost::shared_ptr server, Sess // Notify lobby. server->GetLobbyThread().NotifyPlayerJoinedGame(server->GetId(), session.playerData->GetUniqueId()); - if (server->GetCurNumberOfPlayers() == (size_t)tmpGameData.maxNumberOfPlayers) - { + if (server->GetCurNumberOfPlayers() == (size_t)tmpGameData.maxNumberOfPlayers) { // Automatically start the game if it is full. RegisterAutoStartTimer(server); } @@ -482,8 +447,7 @@ void ServerGameStateInit::RegisterAdminTimer(boost::shared_ptr server) { // No admin timeout in LAN games. - if (server->GetLobbyThread().GetServerMode() != SERVER_MODE_LAN) - { + if (server->GetLobbyThread().GetServerMode() != SERVER_MODE_LAN) { server->GetStateTimer1().expires_from_now( boost::posix_time::seconds(SERVER_GAME_ADMIN_TIMEOUT_SEC - SERVER_GAME_ADMIN_WARNING_REMAINING_SEC)); server->GetStateTimer1().async_wait( @@ -502,8 +466,7 @@ void ServerGameStateInit::RegisterAutoStartTimer(boost::shared_ptr server) { // No autostart in LAN games. - if (server->GetLobbyThread().GetServerMode() != SERVER_MODE_LAN) - { + if (server->GetLobbyThread().GetServerMode() != SERVER_MODE_LAN) { server->GetStateTimer2().expires_from_now( boost::posix_time::seconds(SERVER_AUTOSTART_GAME_DELAY_SEC)); server->GetStateTimer2().async_wait( @@ -521,8 +484,7 @@ ServerGameStateInit::UnregisterAutoStartTimer(boost::shared_ptr serv void ServerGameStateInit::TimerAutoStart(const boost::system::error_code &ec, boost::shared_ptr server) { - if (!ec && &server->GetState() == this) - { + if (!ec && &server->GetState() == this) { SendStartEvent(*server, false); } } @@ -530,12 +492,10 @@ ServerGameStateInit::TimerAutoStart(const boost::system::error_code &ec, boost:: void ServerGameStateInit::TimerAdminWarning(const boost::system::error_code &ec, boost::shared_ptr server) { - if (!ec && &server->GetState() == this) - { + if (!ec && &server->GetState() == this) { // Find game admin. SessionWrapper session = server->GetSessionManager().GetSessionByUniquePlayerId(server->GetAdminPlayerId()); - if (session.sessionData.get()) - { + if (session.sessionData.get()) { // Send him a warning. boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); packet->GetMsg()->present = PokerTHMessage_PR_timeoutWarningMessage; @@ -556,12 +516,10 @@ ServerGameStateInit::TimerAdminWarning(const boost::system::error_code &ec, boos void ServerGameStateInit::TimerAdminTimeout(const boost::system::error_code &ec, boost::shared_ptr server) { - if (!ec && &server->GetState() == this) - { + if (!ec && &server->GetState() == this) { // Find game admin. SessionWrapper session = server->GetSessionManager().GetSessionByUniquePlayerId(server->GetAdminPlayerId()); - if (session.sessionData.get()) - { + if (session.sessionData.get()) { // Remove him from the game. server->MoveSessionToLobby(session, NTF_NET_REMOVED_TIMEOUT); } @@ -571,11 +529,9 @@ ServerGameStateInit::TimerAdminTimeout(const boost::system::error_code &ec, boos void ServerGameStateInit::SendStartEvent(ServerGame &server, bool fillWithComputerPlayers) { - if (fillWithComputerPlayers) - { + if (fillWithComputerPlayers) { int remainingSlots = server.GetGameData().maxNumberOfPlayers - server.GetCurNumberOfPlayers(); - for (int i = 1; i <= remainingSlots; i++) - { + for (int i = 1; i <= remainingSlots; i++) { boost::shared_ptr tmpPlayerData( new PlayerData(server.GetLobbyThread().GetNextUniquePlayerId(), 0, PLAYER_TYPE_COMPUTER, PLAYER_RIGHTS_NORMAL, false)); @@ -608,29 +564,22 @@ ServerGameStateInit::SendStartEvent(ServerGame &server, bool fillWithComputerPla void ServerGameStateInit::InternalProcessPacket(boost::shared_ptr server, SessionWrapper session, boost::shared_ptr packet) { - if (packet->GetMsg()->present == PokerTHMessage_PR_startEventMessage) - { + if (packet->GetMsg()->present == PokerTHMessage_PR_startEventMessage) { StartEventMessage_t *netStartEvent = &packet->GetMsg()->choice.startEventMessage; // Only admins are allowed to start the game. if (session.playerData->IsGameAdmin() - && netStartEvent->gameId == server->GetId() - && (server->GetGameData().gameType != GAME_TYPE_RANKING // ranking games need to be full - || server->GetGameData().maxNumberOfPlayers == (int)server->GetCurNumberOfPlayers())) - { + && netStartEvent->gameId == server->GetId() + && (server->GetGameData().gameType != GAME_TYPE_RANKING // ranking games need to be full + || server->GetGameData().maxNumberOfPlayers == (int)server->GetCurNumberOfPlayers())) { SendStartEvent(*server, netStartEvent->fillWithComputerPlayers); - } - else // kick players who try to start but are not allowed to - { + } else { // kick players who try to start but are not allowed to server->MoveSessionToLobby(session, NTF_NET_REMOVED_START_FAILED); } - } - else if (packet->GetMsg()->present == PokerTHMessage_PR_invitePlayerToGameMessage) - { + } else if (packet->GetMsg()->present == PokerTHMessage_PR_invitePlayerToGameMessage) { InvitePlayerToGameMessage_t *netInvite = &packet->GetMsg()->choice.invitePlayerToGameMessage; // Only invite players which are not already within the group. - if (netInvite->gameId == server->GetId() && !server->IsPlayerConnected(netInvite->playerId)) - { + if (netInvite->gameId == server->GetId() && !server->IsPlayerConnected(netInvite->playerId)) { boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); packet->GetMsg()->present = PokerTHMessage_PR_inviteNotifyMessage; InviteNotifyMessage_t *netInvNotif = &packet->GetMsg()->choice.inviteNotifyMessage; @@ -640,13 +589,10 @@ ServerGameStateInit::InternalProcessPacket(boost::shared_ptr server, bool requestSent = server->GetLobbyThread().SendToLobbyPlayer(netInvite->playerId, packet); server->SendToAllPlayers(packet, SessionData::Game); - if (requestSent) - { + if (requestSent) { // This player has been invited. server->AddPlayerInvitation(netInvite->playerId); - } - else - { + } else { // Player is not in lobby - send reject message. boost::shared_ptr p2(new NetPacket(NetPacket::Alloc)); p2->GetMsg()->present = PokerTHMessage_PR_rejectInvNotifyMessage; @@ -658,16 +604,11 @@ ServerGameStateInit::InternalProcessPacket(boost::shared_ptr server, server->SendToAllPlayers(p2, SessionData::Game); } } - } - else if (packet->GetMsg()->present == PokerTHMessage_PR_resetTimeoutMessage) - { - if (session.playerData->IsGameAdmin()) - { + } else if (packet->GetMsg()->present == PokerTHMessage_PR_resetTimeoutMessage) { + if (session.playerData->IsGameAdmin()) { RegisterAdminTimer(server); } - } - else - { + } else { server->SessionError(session, ERR_SOCK_INVALID_PACKET); } } @@ -730,11 +671,9 @@ ServerGameStateStartGame::HandleNewSession(boost::shared_ptr server, void ServerGameStateStartGame::InternalProcessPacket(boost::shared_ptr server, SessionWrapper session, boost::shared_ptr packet) { - if (packet->GetMsg()->present == PokerTHMessage_PR_startEventAckMessage) - { + if (packet->GetMsg()->present == PokerTHMessage_PR_startEventAckMessage) { session.sessionData->SetReadyFlag(); - if (server->GetSessionManager().CountReadySessions() == server->GetSessionManager().GetRawSessionCount()) - { + if (server->GetSessionManager().CountReadySessions() == server->GetSessionManager().GetRawSessionCount()) { // Everyone is ready. server->GetSessionManager().ResetAllReadyFlags(); DoStart(server); @@ -745,8 +684,7 @@ ServerGameStateStartGame::InternalProcessPacket(boost::shared_ptr se void ServerGameStateStartGame::TimerTimeout(const boost::system::error_code &ec, boost::shared_ptr server) { - if (!ec && &server->GetState() == this) - { + if (!ec && &server->GetState() == this) { // On timeout: start anyway. server->GetSessionManager().ResetAllReadyFlags(); // TODO report successful start! -> new callback?! @@ -759,18 +697,14 @@ void ServerGameStateStartGame::DoStart(boost::shared_ptr server) { PlayerDataList tmpPlayerList(server->InternalStartGame()); - if (tmpPlayerList.size() <= 1) - { - if (!tmpPlayerList.empty()) - { + if (tmpPlayerList.size() <= 1) { + if (!tmpPlayerList.empty()) { boost::shared_ptr tmpPlayer(tmpPlayerList.front()); SessionWrapper tmpSession = server->GetSessionManager().GetSessionByUniquePlayerId(tmpPlayer->GetUniqueId()); if (tmpSession.sessionData) server->MoveSessionToLobby(tmpSession, NTF_NET_REMOVED_START_FAILED); } - } - else - { + } else { boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); packet->GetMsg()->present = PokerTHMessage_PR_gameStartMessage; GameStartMessage_t *netGameStart = &packet->GetMsg()->choice.gameStartMessage; @@ -781,12 +715,11 @@ ServerGameStateStartGame::DoStart(boost::shared_ptr server) // Assume player list is sorted by number. PlayerDataList::iterator player_i = tmpPlayerList.begin(); PlayerDataList::iterator player_end = tmpPlayerList.end(); - while (player_i != player_end) - { + while (player_i != player_end) { NonZeroId_t *playerSlot = (NonZeroId_t *)calloc(1, sizeof(NonZeroId_t)); *playerSlot = (*player_i)->GetUniqueId(); ASN_SEQUENCE_ADD(&netGameStart->playerSeats.list, playerSlot); - + ++player_i; } @@ -848,14 +781,10 @@ ServerGameStateHand::InternalProcessPacket(boost::shared_ptr /*serve void ServerGameStateHand::TimerLoop(const boost::system::error_code &ec, boost::shared_ptr server) { - if (!ec && &server->GetState() == this) - { - try - { + if (!ec && &server->GetState() == this) { + try { EngineLoop(server); - } - catch (const PokerTHException &e) - { + } catch (const PokerTHException &e) { LOG_ERROR("Game " << server->GetId() << " - Engine exception: " << e.what()); server->RemoveAllSessions(); // Close this game on error. } @@ -875,8 +804,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr server) int newRound = curGame.getCurrentHand()->getCurrentRound(); // If round changes, deal cards if needed. - if (newRound != curRound && newRound != GAME_STATE_POST_RIVER) - { + if (newRound != curRound && newRound != GAME_STATE_POST_RIVER) { if (newRound <= curRound) throw ServerException(__FILE__, __LINE__, ERR_NET_INVALID_GAME_ROUND, 0); @@ -885,9 +813,8 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr server) nonFoldPlayers.remove_if(boost::bind(&PlayerInterface::getMyAction, _1) == PLAYER_ACTION_FOLD); if (curGame.getCurrentHand()->getAllInCondition() - && !curGame.getCurrentHand()->getCardsShown() - && nonFoldPlayers.size() > 1) - { + && !curGame.getCurrentHand()->getCardsShown() + && nonFoldPlayers.size() > 1) { // Send cards of all active players to all players (all in). boost::shared_ptr allIn(new NetPacket(NetPacket::Alloc)); allIn->GetMsg()->present = PokerTHMessage_PR_allInShowCardsMessage; @@ -897,8 +824,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr server) PlayerListConstIterator i = nonFoldPlayers.begin(); PlayerListConstIterator end = nonFoldPlayers.end(); - while (i != end) - { + while (i != end) { PlayerAllIn_t *playerAllIn = (PlayerAllIn_t *)calloc(1, sizeof(PlayerAllIn_t)); playerAllIn->playerId = (*i)->getMyUniqueID(); int tmpCards[2]; @@ -917,9 +843,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr server) server->GetStateTimer1().async_wait( boost::bind( &ServerGameStateHand::TimerShowCards, this, boost::asio::placeholders::error, server)); - } - else - { + } else { SendNewRoundCards(*server, curGame, newRound); server->GetStateTimer1().expires_from_now( @@ -928,11 +852,8 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr server) boost::bind( &ServerGameStateHand::TimerLoop, this, boost::asio::placeholders::error, server)); } - } - else - { - if (newRound != GAME_STATE_POST_RIVER) // continue hand - { + } else { + if (newRound != GAME_STATE_POST_RIVER) { // continue hand if (curGame.getCurrentHand()->getAllInCondition()) throw ServerException(__FILE__, __LINE__, ERR_NET_INTERNAL_GAME_ERROR, 0); @@ -952,8 +873,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr server) server->SendToAllPlayers(notification, SessionData::Game); // If the player is computer controlled, let the engine act. - if (curPlayer->getMyType() == PLAYER_TYPE_COMPUTER) - { + if (curPlayer->getMyType() == PLAYER_TYPE_COMPUTER) { server->GetStateTimer1().expires_from_now( boost::posix_time::seconds(SERVER_COMPUTER_ACTION_DELAY_SEC)); server->GetStateTimer1().async_wait( @@ -961,8 +881,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr server) &ServerGameStateHand::TimerComputerAction, this, boost::asio::placeholders::error, server)); } // If the player we are waiting for left, continue without him. - else if (!server->GetSessionManager().IsPlayerConnected(curPlayer->getMyUniqueID())) - { + else if (!server->GetSessionManager().IsPlayerConnected(curPlayer->getMyUniqueID())) { PerformPlayerAction(*server, curPlayer, PLAYER_ACTION_FOLD, 0); server->GetStateTimer1().expires_from_now( @@ -970,14 +889,10 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr server) server->GetStateTimer1().async_wait( boost::bind( &ServerGameStateHand::TimerLoop, this, boost::asio::placeholders::error, server)); - } - else - { + } else { server->SetState(ServerGameStateWaitPlayerAction::Instance()); } - } - else // hand is over - { + } else { // hand is over // Engine will find out who won. curGame.getCurrentHand()->getCurrentBeRo()->postRiverRun(); @@ -985,8 +900,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr server) list > nonFoldPlayers = *curGame.getActivePlayerList(); nonFoldPlayers.remove_if(boost::bind(&PlayerInterface::getMyAction, _1) == PLAYER_ACTION_FOLD); - if (nonFoldPlayers.size() == 1) - { + if (nonFoldPlayers.size() == 1) { // End of Hand, but keep cards hidden. boost::shared_ptr player = nonFoldPlayers.front(); boost::shared_ptr endHand(new NetPacket(NetPacket::Alloc)); @@ -1000,9 +914,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr server) endHandHide->moneyWon = player->getLastMoneyWon(); endHandHide->playerMoney = player->getMyCash(); server->SendToAllPlayers(endHand, SessionData::Game); - } - else - { + } else { // End of Hand - show cards. const PlayerIdList showList(curGame.getCurrentHand()->getBoard()->getPlayerNeedToShowCards()); boost::shared_ptr endHand(new NetPacket(NetPacket::Alloc)); @@ -1016,11 +928,9 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr server) PlayerIdList::const_iterator i = showList.begin(); PlayerIdList::const_iterator end = showList.end(); - while (i != end) - { + while (i != end) { boost::shared_ptr tmpPlayer(curGame.getPlayerByUniqueId(*i)); - if (tmpPlayer) - { + if (tmpPlayer) { PlayerResult_t *playerResult = (PlayerResult_t *)calloc(1, sizeof(PlayerResult_t)); SetPlayerResult(*playerResult, tmpPlayer); @@ -1041,13 +951,10 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr server) list > playersWithCash = *curGame.getActivePlayerList(); playersWithCash.remove_if(boost::bind(&PlayerInterface::getMyCash, _1) < 1); - if (playersWithCash.empty()) - { + if (playersWithCash.empty()) { // No more players left - restart. server->SetState(SERVER_INITIAL_STATE::Instance()); - } - else if (playersWithCash.size() == 1) - { + } else if (playersWithCash.size() == 1) { boost::shared_ptr winnerPlayer = *(playersWithCash.begin()); server->InternalEndGame(); @@ -1057,9 +964,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr server) server->GetStateTimer1().async_wait( boost::bind( &ServerGameStateHand::TimerNextGame, this, boost::asio::placeholders::error, server, winnerPlayer->getMyUniqueID())); - } - else - { + } else { server->SetState(ServerGameStateWaitNextHand::Instance()); } } @@ -1069,8 +974,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr server) void ServerGameStateHand::TimerShowCards(const boost::system::error_code &ec, boost::shared_ptr server) { - if (!ec && &server->GetState() == this) - { + if (!ec && &server->GetState() == this) { Game &curGame = server->GetGame(); SendNewRoundCards(*server, curGame, curGame.getCurrentHand()->getCurrentRound()); @@ -1085,10 +989,8 @@ ServerGameStateHand::TimerShowCards(const boost::system::error_code &ec, boost:: void ServerGameStateHand::TimerComputerAction(const boost::system::error_code &ec, boost::shared_ptr server) { - if (!ec && &server->GetState() == this) - { - try - { + if (!ec && &server->GetState() == this) { + try { boost::shared_ptr curPlayer = server->GetGame().getCurrentPlayer(); if (!curPlayer) throw ServerException(__FILE__, __LINE__, ERR_NET_NO_CURRENT_PLAYER, 0); @@ -1096,9 +998,7 @@ ServerGameStateHand::TimerComputerAction(const boost::system::error_code &ec, bo curPlayer->action(); SendPlayerAction(*server, curPlayer); EngineLoop(server); - } - catch (const PokerTHException &e) - { + } catch (const PokerTHException &e) { LOG_ERROR("Game " << server->GetId() << " - Computer timer exception: " << e.what()); server->RemoveAllSessions(); // Close this game on error. } @@ -1108,8 +1008,7 @@ ServerGameStateHand::TimerComputerAction(const boost::system::error_code &ec, bo void ServerGameStateHand::TimerNextHand(const boost::system::error_code &ec, boost::shared_ptr server) { - if (!ec && &server->GetState() == this) - { + if (!ec && &server->GetState() == this) { StartNewHand(server); TimerLoop(ec, server); } @@ -1118,8 +1017,7 @@ ServerGameStateHand::TimerNextHand(const boost::system::error_code &ec, boost::s void ServerGameStateHand::TimerNextGame(const boost::system::error_code &ec, boost::shared_ptr server, unsigned winnerPlayerId) { - if (!ec && &server->GetState() == this) - { + if (!ec && &server->GetState() == this) { boost::shared_ptr endGame(new NetPacket(NetPacket::Alloc)); endGame->GetMsg()->present = PokerTHMessage_PR_endOfGameMessage; EndOfGameMessage_t *netEndGame = &endGame->GetMsg()->choice.endOfGameMessage; @@ -1142,17 +1040,16 @@ ServerGameStateHand::GetDealCardsDelaySec(ServerGame &server) int allInDelay = curGame.getCurrentHand()->getAllInCondition() ? SERVER_DEAL_ADD_ALL_IN_DELAY_SEC : 0; int delay = 0; - switch(curGame.getCurrentHand()->getCurrentRound()) - { - case GAME_STATE_FLOP: - delay = SERVER_DEAL_FLOP_CARDS_DELAY_SEC; - break; - case GAME_STATE_TURN: - delay = SERVER_DEAL_TURN_CARD_DELAY_SEC + allInDelay; - break; - case GAME_STATE_RIVER: - delay = SERVER_DEAL_RIVER_CARD_DELAY_SEC; - break; + switch(curGame.getCurrentHand()->getCurrentRound()) { + case GAME_STATE_FLOP: + delay = SERVER_DEAL_FLOP_CARDS_DELAY_SEC; + break; + case GAME_STATE_TURN: + delay = SERVER_DEAL_TURN_CARD_DELAY_SEC + allInDelay; + break; + case GAME_STATE_RIVER: + delay = SERVER_DEAL_RIVER_CARD_DELAY_SEC; + break; } return delay; } @@ -1174,12 +1071,10 @@ ServerGameStateHand::StartNewHand(boost::shared_ptr server) PlayerListIterator end = curGame.getSeatsList()->end(); // Send cards to all players. - while (i != end) - { + while (i != end) { // also send to inactive players, but not to disconnected players. boost::shared_ptr tmpPlayer = *i; - if (tmpPlayer->getNetSessionData()) - { + if (tmpPlayer->getNetSessionData()) { int cards[2]; bool errorFlag = false; tmpPlayer->getMyCards(cards); @@ -1189,15 +1084,12 @@ ServerGameStateHand::StartNewHand(boost::shared_ptr server) HandStartMessage_t *netHandStart = ¬ifyCards->GetMsg()->choice.handStartMessage; netHandStart->gameId = server->GetId(); string tmpPassword(tmpPlayer->getNetSessionData()->AuthGetPassword()); - if (tmpPassword.empty()) // encrypt only if password is present - { + if (tmpPassword.empty()) { // encrypt only if password is present netHandStart->yourCards.present = yourCards_PR_plainCards; PlainCards_t *plainCards = &netHandStart->yourCards.choice.plainCards; plainCards->plainCard1 = cards[0]; plainCards->plainCard2 = cards[1]; - } - else - { + } else { ostringstream cardDataStream; vector tmpCipher; cardDataStream @@ -1207,26 +1099,22 @@ ServerGameStateHand::StartNewHand(boost::shared_ptr server) << cards[0] << " " << cards[1]; if (CryptHelper::AES128Encrypt((const unsigned char *)tmpPassword.c_str(), - (unsigned)tmpPassword.size(), - cardDataStream.str(), - tmpCipher) - && !tmpCipher.empty()) - { + (unsigned)tmpPassword.size(), + cardDataStream.str(), + tmpCipher) + && !tmpCipher.empty()) { netHandStart->yourCards.present = yourCards_PR_encryptedCards; EncryptedCards_t *encryptedCards = &netHandStart->yourCards.choice.encryptedCards; OCTET_STRING_fromBuf( - &encryptedCards->cardData, - (const char *)&tmpCipher[0], - (int)tmpCipher.size()); - } - else - { + &encryptedCards->cardData, + (const char *)&tmpCipher[0], + (int)tmpCipher.size()); + } else { server->RemovePlayer(tmpPlayer->getMyUniqueID(), ERR_SOCK_INVALID_STATE); errorFlag = true; } } - if (!errorFlag) - { + if (!errorFlag) { netHandStart->smallBlind = curGame.getCurrentHand()->getSmallBlind(); server->GetLobbyThread().GetSender().Send(tmpPlayer->getNetSessionData(), notifyCards); } @@ -1241,11 +1129,9 @@ ServerGameStateHand::StartNewHand(boost::shared_ptr server) i = curGame.getActivePlayerList()->begin(); end = curGame.getActivePlayerList()->end(); - while (i != end) - { + while (i != end) { boost::shared_ptr tmpPlayer = *i; - if (tmpPlayer->getMyButton() == BUTTON_SMALL_BLIND) - { + if (tmpPlayer->getMyButton() == BUTTON_SMALL_BLIND) { boost::shared_ptr notifySmallBlind(new NetPacket(NetPacket::Alloc)); notifySmallBlind->GetMsg()->present = PokerTHMessage_PR_playersActionDoneMessage; PlayersActionDoneMessage_t *netSmallBlind = ¬ifySmallBlind->GetMsg()->choice.playersActionDoneMessage; @@ -1265,11 +1151,9 @@ ServerGameStateHand::StartNewHand(boost::shared_ptr server) i = curGame.getActivePlayerList()->begin(); end = curGame.getActivePlayerList()->end(); - while (i != end) - { + while (i != end) { boost::shared_ptr tmpPlayer = *i; - if (tmpPlayer->getMyButton() == BUTTON_BIG_BLIND) - { + if (tmpPlayer->getMyButton() == BUTTON_BIG_BLIND) { boost::shared_ptr notifyBigBlind(new NetPacket(NetPacket::Alloc)); notifyBigBlind->GetMsg()->present = PokerTHMessage_PR_playersActionDoneMessage; PlayersActionDoneMessage_t *netBigBlind = ¬ifyBigBlind->GetMsg()->choice.playersActionDoneMessage; @@ -1310,8 +1194,7 @@ ServerGameStateWaitPlayerAction::~ServerGameStateWaitPlayerAction() void ServerGameStateWaitPlayerAction::Enter(boost::shared_ptr server) { - if (server->GetGameData().playerActionTimeoutSec > 0) // zero means unlimited thinking time - { + if (server->GetGameData().playerActionTimeoutSec > 0) { // zero means unlimited thinking time #ifdef POKERTH_SERVER_TEST int timeoutSec = SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC; #else @@ -1341,8 +1224,7 @@ ServerGameStateWaitPlayerAction::HandleNewSession(boost::shared_ptr void ServerGameStateWaitPlayerAction::InternalProcessPacket(boost::shared_ptr server, SessionWrapper session, boost::shared_ptr packet) { - if (packet->GetMsg()->present == PokerTHMessage_PR_myActionRequestMessage) - { + if (packet->GetMsg()->present == PokerTHMessage_PR_myActionRequestMessage) { MyActionRequestMessage_t *netMyAction = &packet->GetMsg()->choice.myActionRequestMessage; // TODO consider game id. @@ -1359,14 +1241,12 @@ ServerGameStateWaitPlayerAction::InternalProcessPacket(boost::shared_ptr curPlayer = server->GetGame().getCurrentPlayer(); if (code == ACTION_CODE_VALID - && (curPlayer->getMyUniqueID() != tmpPlayer->getMyUniqueID())) - { + && (curPlayer->getMyUniqueID() != tmpPlayer->getMyUniqueID())) { code = ACTION_CODE_NOT_YOUR_TURN; } // If the client omitted some values, fill them in. - if (netMyAction->myAction == PLAYER_ACTION_CALL && netMyAction->myRelativeBet == 0) - { + if (netMyAction->myAction == PLAYER_ACTION_CALL && netMyAction->myRelativeBet == 0) { if (curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet() >= tmpPlayer->getMySet() + tmpPlayer->getMyCash()) netMyAction->myAction = PLAYER_ACTION_ALLIN; else @@ -1377,23 +1257,19 @@ ServerGameStateWaitPlayerAction::InternalProcessPacket(boost::shared_ptrcheckMyAction( - netMyAction->myAction, - netMyAction->myRelativeBet, - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet(), - curGame.getCurrentHand()->getCurrentBeRo()->getMinimumRaise(), - curGame.getCurrentHand()->getSmallBlind()) != 0)) - { + && (tmpPlayer->checkMyAction( + netMyAction->myAction, + netMyAction->myRelativeBet, + curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet(), + curGame.getCurrentHand()->getCurrentBeRo()->getMinimumRaise(), + curGame.getCurrentHand()->getSmallBlind()) != 0)) { code = ACTION_CODE_NOT_ALLOWED; } - if (code == ACTION_CODE_VALID) - { + if (code == ACTION_CODE_VALID) { PerformPlayerAction(*server, tmpPlayer, static_cast(netMyAction->myAction), netMyAction->myRelativeBet); server->SetState(ServerGameStateHand::Instance()); - } - else - { + } else { // Send reject message. boost::shared_ptr reject(new NetPacket(NetPacket::Alloc)); reject->GetMsg()->present = PokerTHMessage_PR_yourActionRejectedMessage; @@ -1411,10 +1287,8 @@ ServerGameStateWaitPlayerAction::InternalProcessPacket(boost::shared_ptr server) { - if (!ec && &server->GetState() == this) - { - try - { + if (!ec && &server->GetState() == this) { + try { Game &curGame = server->GetGame(); // Retrieve current player. boost::shared_ptr curPlayer = curGame.getCurrentPlayer(); @@ -1430,25 +1304,19 @@ ServerGameStateWaitPlayerAction::TimerTimeout(const boost::system::error_code &e curPlayer->incrementActionTimeoutCounter(); if (server->GetGameData().gameType == GAME_TYPE_RANKING - && server->GetGameData().playerActionTimeoutSec >= (int)server->GetSmallDelaySec()) - { - if (curPlayer->getActionTimeoutCounter() == SERVER_WARNING_ACTION_TIMEOUT_THRESHOLD) - { + && server->GetGameData().playerActionTimeoutSec >= (int)server->GetSmallDelaySec()) { + if (curPlayer->getActionTimeoutCounter() == SERVER_WARNING_ACTION_TIMEOUT_THRESHOLD) { boost::shared_ptr warning(new NetPacket(NetPacket::Alloc)); warning->GetMsg()->present = PokerTHMessage_PR_afkWarningMessage; AfkWarningMessage_t *netWarning = &warning->GetMsg()->choice.afkWarningMessage; netWarning->remainingTimeouts = SERVER_KICK_ACTION_TIMEOUT_REMAINING; server->GetLobbyThread().GetSender().Send(curPlayer->getNetSessionData(), warning); - } - else if (curPlayer->getActionTimeoutCounter() > SERVER_WARNING_ACTION_TIMEOUT_THRESHOLD + SERVER_KICK_ACTION_TIMEOUT_REMAINING) - { + } else if (curPlayer->getActionTimeoutCounter() > SERVER_WARNING_ACTION_TIMEOUT_THRESHOLD + SERVER_KICK_ACTION_TIMEOUT_REMAINING) { server->InternalKickPlayer(curPlayer->getMyUniqueID()); } } server->SetState(ServerGameStateHand::Instance()); - } - catch (const PokerTHException &e) - { + } catch (const PokerTHException &e) { LOG_ERROR("Game " << server->GetId() << " - Player timer exception: " << e.what()); server->RemoveAllSessions(); // Close this game on error. } @@ -1507,16 +1375,14 @@ ServerGameStateWaitNextHand::HandleNewSession(boost::shared_ptr serv void ServerGameStateWaitNextHand::InternalProcessPacket(boost::shared_ptr server, SessionWrapper session, boost::shared_ptr packet) { - if (packet->GetMsg()->present == PokerTHMessage_PR_showMyCardsRequestMessage) - { + if (packet->GetMsg()->present == PokerTHMessage_PR_showMyCardsRequestMessage) { Game &curGame = server->GetGame(); boost::shared_ptr show(new NetPacket(NetPacket::Alloc)); show->GetMsg()->present = PokerTHMessage_PR_afterHandShowCardsMessage; AfterHandShowCardsMessage_t *netShowCards = &show->GetMsg()->choice.afterHandShowCardsMessage; boost::shared_ptr tmpPlayer(curGame.getPlayerByUniqueId(session.playerData->GetUniqueId())); - if (tmpPlayer) - { + if (tmpPlayer) { SetPlayerResult(netShowCards->playerResult, tmpPlayer); server->SendToAllPlayers(show, SessionData::Game); } @@ -1526,8 +1392,7 @@ ServerGameStateWaitNextHand::InternalProcessPacket(boost::shared_ptr void ServerGameStateWaitNextHand::TimerTimeout(const boost::system::error_code &ec, boost::shared_ptr server) { - if (!ec && &server->GetState() == this) - { + if (!ec && &server->GetState() == this) { ServerGameStateHand::StartNewHand(server); server->SetState(ServerGameStateHand::Instance()); } diff --git a/src/net/common/serverlobbybot.cpp b/src/net/common/serverlobbybot.cpp index 71107d38..f674d890 100644 --- a/src/net/common/serverlobbybot.cpp +++ b/src/net/common/serverlobbybot.cpp @@ -34,7 +34,7 @@ using namespace std; ServerLobbyBot::ServerLobbyBot() -: m_ircRestartTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::second_timer::auto_start) + : m_ircRestartTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::second_timer::auto_start) { } @@ -82,8 +82,7 @@ ServerLobbyBot::SignalIrcServerError(int errorCode) void ServerLobbyBot::SignalLobbyMessage(unsigned playerId, const std::string &playerName, const std::string &msg) { - if (m_ircLobbyThread && !msg.empty()) - { + if (m_ircLobbyThread && !msg.empty()) { ostringstream ircMsg; if (playerId) ircMsg << playerName << " (" << playerId << "): " << msg; @@ -103,13 +102,10 @@ ServerLobbyBot::Run() void ServerLobbyBot::Process() { - if (m_ircRestartTimer.elapsed().total_seconds() > SERVER_RESTART_IRC_BOT_INTERVAL_SEC) - { - if (m_ircLobbyThread) - { + if (m_ircRestartTimer.elapsed().total_seconds() > SERVER_RESTART_IRC_BOT_INTERVAL_SEC) { + if (m_ircLobbyThread) { m_ircLobbyThread->SignalTermination(); - if (m_ircLobbyThread->Join(NET_ADMIN_IRC_TERMINATE_TIMEOUT_MSEC)) - { + if (m_ircLobbyThread->Join(NET_ADMIN_IRC_TERMINATE_TIMEOUT_MSEC)) { boost::shared_ptr tmpIrcThread(new IrcThread(*m_ircLobbyThread)); tmpIrcThread->Run(); m_ircLobbyThread = tmpIrcThread; diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index 9c0332a1..19c85f3e 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -30,9 +30,9 @@ #include #include #ifdef POKERTH_OFFICIAL_SERVER - #include +#include #else - #include +#include #endif #include #include @@ -89,100 +89,81 @@ public: InternalServerCallback(ServerLobbyThread &server) : m_server(server) {} virtual ~InternalServerCallback() {} - virtual void SignalNetError(SessionId /*session*/, int /*errorID*/, int /*osErrorID*/) - { + virtual void SignalNetError(SessionId /*session*/, int /*errorID*/, int /*osErrorID*/) { // We just ignore send errors for now, on server side. // A serious send error should trigger a read error or a read // returning 0 afterwards, and we will handle this error. } - virtual void SignalSessionTerminated(unsigned session) - { + virtual void SignalSessionTerminated(unsigned session) { m_server.GetSender().SignalSessionTerminated(session); } - virtual void SignalChatBotMessage(const string &msg) - { + virtual void SignalChatBotMessage(const string &msg) { m_server.SendChatBotMsg(msg); } - virtual void SignalChatBotMessage(unsigned gameId, const std::string &msg) - { + virtual void SignalChatBotMessage(unsigned gameId, const std::string &msg) { m_server.SendChatBotMsg(gameId, msg); } - virtual void SignalKickPlayer(unsigned playerId) - { + virtual void SignalKickPlayer(unsigned playerId) { m_server.RemovePlayer(playerId, ERR_NET_PLAYER_KICKED); } - virtual void SignalBanPlayer(unsigned playerId) - { + virtual void SignalBanPlayer(unsigned playerId) { string playerName(m_server.GetPlayerNameFromId(playerId)); - if (!playerName.empty()) - { + if (!playerName.empty()) { m_server.GetBanManager().BanPlayerName(playerName, 1); m_server.RemovePlayer(playerId, ERR_NET_PLAYER_KICKED); } } - virtual void ConnectSuccess() - { + virtual void ConnectSuccess() { LOG_MSG("Successfully connected to database."); } - virtual void ConnectFailed(const string &error) - { + virtual void ConnectFailed(const string &error) { LOG_ERROR("DB connect error: " << error); } - virtual void QueryError(const std::string &error) - { + virtual void QueryError(const std::string &error) { LOG_ERROR("DB query error: " << error); } - virtual void PlayerLoginSuccess(unsigned requestId, const DBPlayerData &dbPlayerData) - { + virtual void PlayerLoginSuccess(unsigned requestId, const DBPlayerData &dbPlayerData) { m_server.UserValid(requestId, dbPlayerData); } - virtual void PlayerLoginFailed(unsigned requestId) - { + virtual void PlayerLoginFailed(unsigned requestId) { m_server.UserInvalid(requestId); } - virtual void PlayerLoginBlocked(unsigned requestId) - { + virtual void PlayerLoginBlocked(unsigned requestId) { m_server.UserBlocked(requestId); } - virtual void AvatarIsBlacklisted(unsigned requestId) - { + virtual void AvatarIsBlacklisted(unsigned requestId) { m_server.AvatarBlacklisted(requestId); } - virtual void AvatarIsOK(unsigned requestId) - { + virtual void AvatarIsOK(unsigned requestId) { m_server.AvatarOK(requestId); } - virtual void CreateGameSuccess(unsigned requestId, DB_id gameId) - { + virtual void CreateGameSuccess(unsigned requestId, DB_id gameId) { m_server.SetGameDBId((u_int32_t)requestId, gameId); } - virtual void CreateGameFailed(unsigned requestId) - { + virtual void CreateGameFailed(unsigned requestId) { // TODO maybe handle request id. LOG_ERROR("DB create game failed for request " << requestId); } - virtual void ReportAvatarSuccess(unsigned requestId, unsigned replyId) - { + virtual void ReportAvatarSuccess(unsigned requestId, unsigned replyId) { m_server.SendReportAvatarResult(requestId, replyId, true); } - virtual void ReportAvatarFailed(unsigned requestId, unsigned replyId) - { + virtual void ReportAvatarFailed(unsigned requestId, unsigned replyId) { m_server.SendReportAvatarResult(requestId, replyId, false); } @@ -193,12 +174,12 @@ private: ServerLobbyThread::ServerLobbyThread(GuiInterface &gui, ServerMode mode, ServerIrcBotCallback &ircBotCb, ConfigFile &serverConfig, AvatarManager &avatarManager, boost::shared_ptr ioService) -: m_ioService(ioService), m_authContext(NULL), m_gui(gui), m_ircBotCb(ircBotCb), m_avatarManager(avatarManager), - m_mode(mode), m_serverConfig(serverConfig), m_curGameId(0), m_curUniquePlayerId(0), m_curSessionId(INVALID_SESSION + 1), - m_statDataChanged(false), m_removeGameTimer(*ioService), m_removePlayerTimer(*ioService), - m_sessionTimeoutTimer(*ioService), m_avatarCleanupTimer(*ioService), - m_saveStatisticsTimer(*ioService), m_loginLockTimer(*ioService), - m_startTime(boost::posix_time::second_clock::local_time()) + : m_ioService(ioService), m_authContext(NULL), m_gui(gui), m_ircBotCb(ircBotCb), m_avatarManager(avatarManager), + m_mode(mode), m_serverConfig(serverConfig), m_curGameId(0), m_curUniquePlayerId(0), m_curSessionId(INVALID_SESSION + 1), + m_statDataChanged(false), m_removeGameTimer(*ioService), m_removePlayerTimer(*ioService), + m_sessionTimeoutTimer(*ioService), m_avatarCleanupTimer(*ioService), + m_saveStatisticsTimer(*ioService), m_loginLockTimer(*ioService), + m_startTime(boost::posix_time::second_clock::local_time()) { m_internalServerCallback.reset(new InternalServerCallback(*this)); m_sender.reset(new SenderHelper(*m_internalServerCallback, m_ioService)); @@ -217,11 +198,9 @@ void ServerLobbyThread::Init(const string &logDir) { // Read previous server statistics. - if (!logDir.empty()) - { + if (!logDir.empty()) { boost::filesystem::path logPath(logDir); - if (!logDir.empty()) - { + if (!logDir.empty()) { logPath /= SERVER_STATISTICS_FILE_NAME; m_statisticsFileName = logPath.directory_string(); ReadStatisticsFile(); @@ -265,15 +244,12 @@ ServerLobbyThread::AddConnection(boost::shared_ptr sock) LOG_VERBOSE("Accepted connection - session #" << sessionData->GetId() << "."); bool hasClientIp = false; - if (m_sessionManager.GetRawSessionCount() <= SERVER_MAX_NUM_SESSIONS) - { + if (m_sessionManager.GetRawSessionCount() <= SERVER_MAX_NUM_SESSIONS) { boost::system::error_code errCode; tcp::endpoint clientEndpoint = sock->remote_endpoint(errCode); - if (!errCode) - { + if (!errCode) { string ipAddress = clientEndpoint.address().to_string(errCode); - if (!errCode && !ipAddress.empty()) - { + if (!errCode && !ipAddress.empty()) { sessionData->SetClientAddr(ipAddress); hasClientIp = true; @@ -285,17 +261,16 @@ ServerLobbyThread::AddConnection(boost::shared_ptr sock) netAnnounce->latestGameVersion.major = POKERTH_VERSION_MAJOR; netAnnounce->latestGameVersion.minor = POKERTH_VERSION_MINOR; netAnnounce->latestBetaRevision = POKERTH_BETA_REVISION; - switch (GetServerMode()) - { - case SERVER_MODE_LAN: - netAnnounce->serverType = serverType_serverTypeLAN; - break; - case SERVER_MODE_INTERNET_NOAUTH: - netAnnounce->serverType = serverType_serverTypeInternetNoAuth; - break; - case SERVER_MODE_INTERNET_AUTH: - netAnnounce->serverType = serverType_serverTypeInternetAuth; - break; + switch (GetServerMode()) { + case SERVER_MODE_LAN: + netAnnounce->serverType = serverType_serverTypeLAN; + break; + case SERVER_MODE_INTERNET_NOAUTH: + netAnnounce->serverType = serverType_serverTypeInternetNoAuth; + break; + case SERVER_MODE_INTERNET_AUTH: + netAnnounce->serverType = serverType_serverTypeInternetAuth; + break; } GetSender().Send(sessionData, packet); @@ -309,15 +284,12 @@ ServerLobbyThread::AddConnection(boost::shared_ptr sock) boost::asio::placeholders::bytes_transferred)); } } - if (!hasClientIp) - { + if (!hasClientIp) { // We do not accept sessions if we cannot // retrieve the client address. SessionError(SessionWrapper(sessionData, boost::shared_ptr()), ERR_NET_INVALID_SESSION); } - } - else - { + } else { // Server is full. // Gracefully close this session. SessionError(SessionWrapper(sessionData, boost::shared_ptr()), ERR_NET_SERVER_FULL); @@ -327,8 +299,7 @@ ServerLobbyThread::AddConnection(boost::shared_ptr sock) void ServerLobbyThread::ReAddSession(SessionWrapper session, int reason) { - if (session.sessionData.get() && session.playerData.get()) - { + if (session.sessionData.get() && session.playerData.get()) { boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); packet->GetMsg()->present = PokerTHMessage_PR_gamePlayerMessage; GamePlayerMessage_t *netPlayerMsg = &packet->GetMsg()->choice.gamePlayerMessage; @@ -336,26 +307,25 @@ ServerLobbyThread::ReAddSession(SessionWrapper session, int reason) netPlayerMsg->gamePlayerNotification.present = gamePlayerNotification_PR_removedFromGame; RemovedFromGame_t *removed = &netPlayerMsg->gamePlayerNotification.choice.removedFromGame; - switch (reason) - { - case NTF_NET_REMOVED_GAME_FULL : - removed->removedFromGameReason = removedFromGameReason_gameIsFull; - break; - case NTF_NET_REMOVED_ALREADY_RUNNING : - removed->removedFromGameReason = removedFromGameReason_gameIsRunning; - break; - case NTF_NET_REMOVED_KICKED : - removed->removedFromGameReason = removedFromGameReason_kickedFromGame; - break; - case NTF_NET_REMOVED_TIMEOUT : - removed->removedFromGameReason = removedFromGameReason_gameTimeout; - break; - case NTF_NET_REMOVED_START_FAILED : - removed->removedFromGameReason = removedFromGameReason_removedStartFailed; - break; - default : - removed->removedFromGameReason = removedFromGameReason_removedOnRequest; - break; + switch (reason) { + case NTF_NET_REMOVED_GAME_FULL : + removed->removedFromGameReason = removedFromGameReason_gameIsFull; + break; + case NTF_NET_REMOVED_ALREADY_RUNNING : + removed->removedFromGameReason = removedFromGameReason_gameIsRunning; + break; + case NTF_NET_REMOVED_KICKED : + removed->removedFromGameReason = removedFromGameReason_kickedFromGame; + break; + case NTF_NET_REMOVED_TIMEOUT : + removed->removedFromGameReason = removedFromGameReason_gameTimeout; + break; + case NTF_NET_REMOVED_START_FAILED : + removed->removedFromGameReason = removedFromGameReason_removedStartFailed; + break; + default : + removed->removedFromGameReason = removedFromGameReason_removedOnRequest; + break; } GetSender().Send(session.sessionData, packet); @@ -392,8 +362,7 @@ ServerLobbyThread::RemoveSessionFromGame(SessionWrapper session) void ServerLobbyThread::CloseSession(SessionWrapper session) { - if (session.sessionData && session.sessionData->GetState() != SessionData::Closed) // Make this call reentrant. - { + if (session.sessionData && session.sessionData->GetState() != SessionData::Closed) { // Make this call reentrant. LOG_VERBOSE("Closing session #" << session.sessionData->GetId() << "."); session.sessionData->SetState(SessionData::Closed); @@ -525,8 +494,7 @@ ServerLobbyThread::KickPlayerByName(const std::string &playerName) if (!session.sessionData.get()) session = m_gameSessionManager.GetSessionByPlayerName(playerName); - if (session.sessionData.get() && session.playerData.get()) - { + if (session.sessionData.get() && session.playerData.get()) { RemovePlayer(session.playerData->GetUniqueId(), ERR_NET_PLAYER_KICKED); retVal = true; } @@ -617,7 +585,7 @@ ServerLobbyThread::SendChatBotMsg(const std::string &message) GetIrcBotCallback().SignalLobbyMessage( 0, - "(chat bot)", + "(chat bot)", message); } @@ -634,8 +602,7 @@ ServerLobbyThread::SendChatBotMsg(unsigned gameId, const std::string &message) message.length()); GameMap::const_iterator pos = m_gameMap.find(gameId); - if (pos != m_gameMap.end()) - { + if (pos != m_gameMap.end()) { pos->second->SendToAllPlayers(packet, SessionData::Game); } } @@ -665,14 +632,13 @@ ServerLobbyThread::SendToLobbyPlayer(unsigned playerId, boost::shared_ptrrun(); // Will only be aborted asynchronously. - } catch (const PokerTHException &e) - { + } catch (const PokerTHException &e) { GetCallback().SignalNetServerError(e.GetErrorId(), e.GetOsErrorCode()); LOG_ERROR("Lobby exception: " << e.what()); } @@ -844,8 +808,7 @@ ServerLobbyThread::InitAuthContext() if (res != GSASL_OK) throw ServerException(__FILE__, __LINE__, ERR_NET_GSASL_INIT_FAILED, 0); - if (!gsasl_server_support_p(m_authContext, "SCRAM-SHA-1")) - { + if (!gsasl_server_support_p(m_authContext, "SCRAM-SHA-1")) { gsasl_done(m_authContext); throw ServerException(__FILE__, __LINE__, ERR_NET_GSASL_NO_SCRAM, 0); } @@ -861,69 +824,57 @@ ServerLobbyThread::ClearAuthContext() void ServerLobbyThread::InitChatCleaner() { - if (m_serverConfig.readConfigInt("UseChatCleaner") != 0) - { + if (m_serverConfig.readConfigInt("UseChatCleaner") != 0) { m_chatCleanerManager->Init( - m_serverConfig.readConfigString("ChatCleanerHostAddress"), - m_serverConfig.readConfigInt("ChatCleanerPort"), - m_serverConfig.readConfigInt("ChatCleanerUseIpv6") != 0, - m_serverConfig.readConfigString("ChatCleanerClientAuth"), - m_serverConfig.readConfigString("ChatCleanerServerAuth")); + m_serverConfig.readConfigString("ChatCleanerHostAddress"), + m_serverConfig.readConfigInt("ChatCleanerPort"), + m_serverConfig.readConfigInt("ChatCleanerUseIpv6") != 0, + m_serverConfig.readConfigString("ChatCleanerClientAuth"), + m_serverConfig.readConfigString("ChatCleanerServerAuth")); } } void ServerLobbyThread::HandleRead(const boost::system::error_code &ec, SessionId sessionId, size_t bytesRead) { - if (ec != boost::asio::error::operation_aborted) - { - try - { + if (ec != boost::asio::error::operation_aborted) { + try { // Find the session. SessionWrapper session = m_sessionManager.GetSessionById(sessionId); if (!session.sessionData) session = m_gameSessionManager.GetSessionById(sessionId); - if (session.sessionData) - { + if (session.sessionData) { ReceiveBuffer &buf = session.sessionData->GetReceiveBuffer(); - if (!ec) - { + if (!ec) { if (buf.recvBufUsed + bytesRead > RECV_BUF_SIZE) LOG_ERROR("Session " << session.sessionData->GetId() << " - Internal error: Receive buffer overflow!"); buf.recvBufUsed += bytesRead; GetReceiver().ScanPackets(buf); bool errorFlag = false; - while (!buf.receivedPackets.empty()) - { + while (!buf.receivedPackets.empty()) { boost::shared_ptr packet = buf.receivedPackets.front(); buf.receivedPackets.pop_front(); // Retrieve current game, if applicable. boost::shared_ptr game = InternalGetGameFromId(session.sessionData->GetGameId()); - if (game) - { + if (game) { // We need to catch game-specific exceptions, so that they do not affect the server. - try - { + try { game->HandlePacket(session, packet); - } catch (const PokerTHException &e) - { + } catch (const PokerTHException &e) { LOG_ERROR("Game " << game->GetId() << " - Read handler exception: " << e.what()); game->RemoveAllSessions(); errorFlag = true; break; } - } - else + } else HandlePacket(session, packet); } - if (buf.recvBufUsed >= RECV_BUF_SIZE) - { + if (buf.recvBufUsed >= RECV_BUF_SIZE) { LOG_ERROR("Session " << session.sessionData->GetId() << " - Full receive buf but no valid packet."); buf.recvBufUsed = 0; } - if (!errorFlag) - { + if (!errorFlag) { session.sessionData->GetAsioSocket()->async_read_some( boost::asio::buffer(buf.recvBuf + buf.recvBufUsed, RECV_BUF_SIZE - buf.recvBufUsed), boost::bind( @@ -933,9 +884,7 @@ ServerLobbyThread::HandleRead(const boost::system::error_code &ec, SessionId ses sessionId, boost::asio::placeholders::bytes_transferred)); } - } - else if (ec == boost::asio::error::interrupted || ec == boost::asio::error::try_again) - { + } else if (ec == boost::asio::error::interrupted || ec == boost::asio::error::try_again) { LOG_ERROR("Session " << sessionId << " - recv interrupted: " << ec); session.sessionData->GetAsioSocket()->async_read_some( boost::asio::buffer(buf.recvBuf + buf.recvBufUsed, RECV_BUF_SIZE - buf.recvBufUsed), @@ -945,9 +894,7 @@ ServerLobbyThread::HandleRead(const boost::system::error_code &ec, SessionId ses boost::asio::placeholders::error, sessionId, boost::asio::placeholders::bytes_transferred)); - } - else - { + } else { LOG_ERROR("Session " << sessionId << " - Connection closed: " << ec); // On error: Close this session. boost::shared_ptr game = InternalGetGameFromId(session.sessionData->GetGameId()); @@ -957,8 +904,7 @@ ServerLobbyThread::HandleRead(const boost::system::error_code &ec, SessionId ses CloseSession(session); } } - } catch (const exception &e) - { + } catch (const exception &e) { LOG_ERROR("Session " << sessionId << " - unhandled exception in HandleRead: " << e.what()); } } @@ -967,25 +913,20 @@ ServerLobbyThread::HandleRead(const boost::system::error_code &ec, SessionId ses void ServerLobbyThread::HandlePacket(SessionWrapper session, boost::shared_ptr packet) { - if (session.sessionData && packet) - { + if (session.sessionData && packet) { if (packet->IsClientActivity()) session.sessionData->ResetActivityTimer(); - if (session.sessionData->GetState() == SessionData::Init) - { + if (session.sessionData->GetState() == SessionData::Init) { if (packet->GetMsg()->present == PokerTHMessage_PR_initMessage) HandleNetPacketInit(session, packet->GetMsg()->choice.initMessage); - else if (packet->GetMsg()->present == PokerTHMessage_PR_authMessage) - { + else if (packet->GetMsg()->present == PokerTHMessage_PR_authMessage) { AuthMessage_t *authMsg = &packet->GetMsg()->choice.authMessage; if (authMsg->present == AuthMessage_PR_authClientResponse) HandleNetPacketAuthClientResponse(session, authMsg->choice.authClientResponse); else SessionError(session, ERR_SOCK_INVALID_STATE); - } - else if (packet->GetMsg()->present == PokerTHMessage_PR_avatarReplyMessage) - { + } else if (packet->GetMsg()->present == PokerTHMessage_PR_avatarReplyMessage) { AvatarReplyMessage_t *avatarReply = &packet->GetMsg()->choice.avatarReplyMessage; if (avatarReply->avatarResult.present == avatarResult_PR_avatarHeader) HandleNetPacketAvatarHeader(session, avatarReply->requestId, avatarReply->avatarResult.choice.avatarHeader); @@ -993,14 +934,10 @@ ServerLobbyThread::HandlePacket(SessionWrapper session, boost::shared_ptrrequestId, avatarReply->avatarResult.choice.unknownAvatar); else SessionError(session, ERR_SOCK_INVALID_STATE); - } - else + } else SessionError(session, ERR_SOCK_INVALID_STATE); - } - else if (session.sessionData->GetState() == SessionData::ReceivingAvatar) - { - if (packet->GetMsg()->present == PokerTHMessage_PR_avatarReplyMessage) - { + } else if (session.sessionData->GetState() == SessionData::ReceivingAvatar) { + if (packet->GetMsg()->present == PokerTHMessage_PR_avatarReplyMessage) { AvatarReplyMessage_t *avatarReply = &packet->GetMsg()->choice.avatarReplyMessage; if (avatarReply->avatarResult.present == avatarResult_PR_avatarData) HandleNetPacketAvatarFile(session, avatarReply->requestId, avatarReply->avatarResult.choice.avatarData); @@ -1008,28 +945,22 @@ ServerLobbyThread::HandlePacket(SessionWrapper session, boost::shared_ptrrequestId, avatarReply->avatarResult.choice.avatarEnd); else SessionError(session, ERR_SOCK_INVALID_STATE); - } - else + } else SessionError(session, ERR_SOCK_INVALID_STATE); - } - else - { + } else { if (packet->GetMsg()->present == PokerTHMessage_PR_playerInfoRequestMessage) HandleNetPacketRetrievePlayerInfo(session, packet->GetMsg()->choice.playerInfoRequestMessage); 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) - { + {} + else if (packet->GetMsg()->present == PokerTHMessage_PR_subscriptionRequestMessage) { SubscriptionRequestMessage_t *subscriptionRequest = &packet->GetMsg()->choice.subscriptionRequestMessage; if (subscriptionRequest->subscriptionAction == subscriptionAction_resubscribeGameList) InternalResubscribeMsg(session); else session.sessionData->ResetWantsLobbyMsg(); - } - else if (packet->GetMsg()->present == PokerTHMessage_PR_joinGameRequestMessage) - { + } else if (packet->GetMsg()->present == PokerTHMessage_PR_joinGameRequestMessage) { JoinGameRequestMessage_t *joinRequest = &packet->GetMsg()->choice.joinGameRequestMessage; string password; if (joinRequest->password) @@ -1038,8 +969,7 @@ ServerLobbyThread::HandlePacket(SessionWrapper session, boost::shared_ptrautoLeave, joinRequest->joinGameAction.choice.joinNewGame); else if (joinRequest->joinGameAction.present == joinGameAction_PR_joinExistingGame) HandleNetPacketJoinGame(session, password, joinRequest->autoLeave, joinRequest->joinGameAction.choice.joinExistingGame); - } - else if (packet->GetMsg()->present == PokerTHMessage_PR_chatRequestMessage) + } else if (packet->GetMsg()->present == PokerTHMessage_PR_chatRequestMessage) HandleNetPacketChatRequest(session, packet->GetMsg()->choice.chatRequestMessage); else if (packet->GetMsg()->present == PokerTHMessage_PR_rejectGameInvitationMessage) HandleNetPacketRejectGameInvitation(session, packet->GetMsg()->choice.rejectGameInvitationMessage); @@ -1057,8 +987,7 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const InitMessage // Before any other processing, perform some denial of service and // brute force attack prevention by checking whether the user recently sent an // Init packet. - if (m_serverConfig.readConfigInt("ServerBruteForceProtection") != 0) - { + if (m_serverConfig.readConfigInt("ServerBruteForceProtection") != 0) { bool recentlySentInit = false; { boost::mutex::scoped_lock lock(m_timerClientAddressMapMutex); @@ -1067,8 +996,7 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const InitMessage else m_timerClientAddressMap[session.sessionData->GetClientAddr()] = boost::timers::portable::microsec_timer(); } - if (recentlySentInit) - { + if (recentlySentInit) { SessionError(session, ERR_NET_INIT_BLOCKED); return; } @@ -1076,8 +1004,7 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const InitMessage // Check the protocol version. if (initMessage.requestedVersion.major != NET_VERSION_MAJOR - || session.playerData) // Has this session already sent an init? - { + || session.playerData) { // Has this session already sent an init? SessionError(session, ERR_NET_VERSION_NOT_SUPPORTED); return; } @@ -1086,30 +1013,25 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const InitMessage MD5Buf avatarMD5; bool noAuth = false; bool validGuest = false; - if (initMessage.login.present == login_PR_guestLogin) - { + if (initMessage.login.present == login_PR_guestLogin) { const GuestLogin_t *guestLogin = &initMessage.login.choice.guestLogin; playerName = STL_STRING_FROM_OCTET_STRING(guestLogin->nickName); // Verify guest player name. if (playerName.length() > sizeof(SERVER_GUEST_PLAYER_NAME - 1) - && playerName.substr(0, sizeof(SERVER_GUEST_PLAYER_NAME) - 1) == SERVER_GUEST_PLAYER_NAME) - { + && playerName.substr(0, sizeof(SERVER_GUEST_PLAYER_NAME) - 1) == SERVER_GUEST_PLAYER_NAME) { string guestId(playerName.substr(sizeof(SERVER_GUEST_PLAYER_NAME))); - if ((size_t)count_if(guestId.begin(), guestId.end(), ::isdigit) == guestId.size()) - { + if ((size_t)count_if(guestId.begin(), guestId.end(), ::isdigit) == guestId.size()) { validGuest = true; noAuth = true; } } - if (!validGuest) - { + if (!validGuest) { SessionError(session, ERR_NET_INVALID_PLAYER_NAME); return; } } #ifdef POKERTH_OFFICIAL_SERVER - else if (initMessage.login.present == login_PR_authenticatedLogin) - { + else if (initMessage.login.present == login_PR_authenticatedLogin) { const AuthenticatedLogin_t *authLogin = &initMessage.login.choice.authenticatedLogin; string inAuthData((const char *)authLogin->clientUserData.buf, authLogin->clientUserData.size); if (authLogin->avatar) @@ -1119,8 +1041,7 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const InitMessage playerName = session.sessionData->AuthGetUser(); } #else - else if (initMessage.login.present == login_PR_unauthenticatedLogin) - { + else if (initMessage.login.present == login_PR_unauthenticatedLogin) { const UnauthenticatedLogin_t *noauthLogin = &initMessage.login.choice.unauthenticatedLogin; playerName = STL_STRING_FROM_OCTET_STRING(noauthLogin->nickName); if (noauthLogin->avatar) @@ -1128,8 +1049,7 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const InitMessage noAuth = true; } #endif - else - { + else { SessionError(session, ERR_NET_INVALID_PASSWORD); return; } @@ -1138,30 +1058,26 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const InitMessage // Partly, this is also done in netpacket. // However, some disallowed names are checked only here. if (playerName.empty() - || playerName[0] == '#' - || playerName[0] == ' ' - || playerName.substr(0, sizeof(SERVER_COMPUTER_PLAYER_NAME) - 1) == SERVER_COMPUTER_PLAYER_NAME) - { + || playerName[0] == '#' + || playerName[0] == ' ' + || playerName.substr(0, sizeof(SERVER_COMPUTER_PLAYER_NAME) - 1) == SERVER_COMPUTER_PLAYER_NAME) { SessionError(session, ERR_NET_INVALID_PLAYER_NAME); return; } // Check whether this player is already connected. - if (IsPlayerConnected(playerName)) - { + if (IsPlayerConnected(playerName)) { SessionError(session, ERR_NET_PLAYER_NAME_IN_USE); return; } // Check whether the player name is banned. - if (GetBanManager().IsPlayerBanned(playerName)) - { + if (GetBanManager().IsPlayerBanned(playerName)) { SessionError(session, ERR_NET_PLAYER_BANNED); return; } // Check whether the peer IP address is banned. - if (GetBanManager().IsIPAddressBanned(session.sessionData->GetClientAddr())) - { + if (GetBanManager().IsIPAddressBanned(session.sessionData->GetClientAddr())) { SessionError(session, ERR_NET_PLAYER_BANNED); return; } @@ -1186,11 +1102,9 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const InitMessage void ServerLobbyThread::HandleNetPacketAuthClientResponse(SessionWrapper session, const AuthClientResponse_t &clientResponse) { - if (session.sessionData && session.playerData && session.sessionData->AuthGetCurStepNum() == 1) - { + if (session.sessionData && session.playerData && session.sessionData->AuthGetCurStepNum() == 1) { string authData = STL_STRING_FROM_OCTET_STRING(clientResponse.clientResponse); - if (session.sessionData->AuthStep(2, authData)) - { + if (session.sessionData->AuthStep(2, authData)) { string outVerification(session.sessionData->AuthGetNextOutMsg()); boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); @@ -1206,8 +1120,7 @@ ServerLobbyThread::HandleNetPacketAuthClientResponse(SessionWrapper session, con // The last message is only for server verification. // We are done now, the user has logged in. CheckAvatarBlacklist(session); - } - else + } else SessionError(session, ERR_NET_INVALID_PASSWORD); } } @@ -1215,10 +1128,8 @@ ServerLobbyThread::HandleNetPacketAuthClientResponse(SessionWrapper session, con void ServerLobbyThread::HandleNetPacketAvatarHeader(SessionWrapper session, unsigned /*requestId*/, const AvatarHeader_t &avatarHeader) { - if (session.playerData) - { - if (avatarHeader.avatarSize >= MIN_AVATAR_FILE_SIZE && avatarHeader.avatarSize <= MAX_AVATAR_FILE_SIZE) - { + if (session.playerData) { + if (avatarHeader.avatarSize >= MIN_AVATAR_FILE_SIZE && avatarHeader.avatarSize <= MAX_AVATAR_FILE_SIZE) { boost::shared_ptr tmpAvatarFile(new AvatarFile); tmpAvatarFile->fileData.reserve(avatarHeader.avatarSize); tmpAvatarFile->fileType = static_cast(avatarHeader.avatarType); @@ -1229,8 +1140,7 @@ ServerLobbyThread::HandleNetPacketAvatarHeader(SessionWrapper session, unsigned // Session is now receiving an avatar. session.sessionData->SetState(SessionData::ReceivingAvatar); - } - else + } else SessionError(session, ERR_NET_AVATAR_TOO_LARGE); } } @@ -1238,8 +1148,7 @@ ServerLobbyThread::HandleNetPacketAvatarHeader(SessionWrapper session, unsigned void ServerLobbyThread::HandleNetPacketUnknownAvatar(SessionWrapper session, unsigned /*requestId*/, const UnknownAvatar_t &/*unknownAvatar*/) { - if (session.playerData.get()) - { + if (session.playerData.get()) { // Free memory (just in case). session.playerData->SetNetAvatarFile(boost::shared_ptr()); session.playerData->SetAvatarMD5(MD5Buf()); @@ -1251,11 +1160,9 @@ ServerLobbyThread::HandleNetPacketUnknownAvatar(SessionWrapper session, unsigned void ServerLobbyThread::HandleNetPacketAvatarFile(SessionWrapper session, unsigned /*requestId*/, const AvatarData_t &avatarData) { - if (session.playerData.get()) - { + if (session.playerData.get()) { boost::shared_ptr tmpAvatar = session.playerData->GetNetAvatarFile(); - if (tmpAvatar.get() && tmpAvatar->fileData.size() + avatarData.avatarBlock.size <= tmpAvatar->reportedSize) - { + if (tmpAvatar.get() && tmpAvatar->fileData.size() + avatarData.avatarBlock.size <= tmpAvatar->reportedSize) { std::copy(&avatarData.avatarBlock.buf[0], &avatarData.avatarBlock.buf[avatarData.avatarBlock.size], back_inserter(tmpAvatar->fileData)); } } @@ -1264,17 +1171,13 @@ ServerLobbyThread::HandleNetPacketAvatarFile(SessionWrapper session, unsigned /* void ServerLobbyThread::HandleNetPacketAvatarEnd(SessionWrapper session, unsigned /*requestId*/, const AvatarEnd_t &/*avatarEnd*/) { - if (session.playerData.get()) - { + if (session.playerData.get()) { boost::shared_ptr tmpAvatar = session.playerData->GetNetAvatarFile(); MD5Buf avatarMD5 = session.playerData->GetAvatarMD5(); - if (!avatarMD5.IsZero() && tmpAvatar.get()) - { + if (!avatarMD5.IsZero() && tmpAvatar.get()) { unsigned avatarSize = (unsigned)tmpAvatar->fileData.size(); - if (avatarSize == tmpAvatar->reportedSize) - { - if (!GetAvatarManager().StoreAvatarInCache(avatarMD5, tmpAvatar->fileType, &tmpAvatar->fileData[0], avatarSize, true)) - { + if (avatarSize == tmpAvatar->reportedSize) { + if (!GetAvatarManager().StoreAvatarInCache(avatarMD5, tmpAvatar->fileType, &tmpAvatar->fileData[0], avatarSize, true)) { session.playerData->SetAvatarMD5(MD5Buf()); LOG_ERROR("Failed to store avatar in cache directory."); } @@ -1288,9 +1191,8 @@ ServerLobbyThread::HandleNetPacketAvatarEnd(SessionWrapper session, unsigned /*r // Init finished - start session. EstablishSession(session); LOG_MSG("Client \"" << session.sessionData->GetClientAddr() << "\" uploaded avatar \"" - << boost::filesystem::path(avatarFileName).file_string() << "\"."); - } - else + << boost::filesystem::path(avatarFileName).file_string() << "\"."); + } else SessionError(session, ERR_NET_WRONG_AVATAR_SIZE); } } @@ -1303,8 +1205,7 @@ ServerLobbyThread::HandleNetPacketRetrievePlayerInfo(SessionWrapper session, con boost::shared_ptr tmpPlayer = m_sessionManager.GetSessionByUniquePlayerId(playerInfoRequest.playerId).playerData; if (!tmpPlayer) tmpPlayer = m_gameSessionManager.GetSessionByUniquePlayerId(playerInfoRequest.playerId).playerData; - if (!tmpPlayer) - { + if (!tmpPlayer) { boost::mutex::scoped_lock lock(m_computerPlayersMutex); PlayerDataMap::const_iterator pos = m_computerPlayers.find(playerInfoRequest.playerId); if (pos != m_computerPlayers.end()) @@ -1316,8 +1217,7 @@ ServerLobbyThread::HandleNetPacketRetrievePlayerInfo(SessionWrapper session, con PlayerInfoReplyMessage_t *netPlayerInfoReply = &packet->GetMsg()->choice.playerInfoReplyMessage; netPlayerInfoReply->playerId = playerInfoRequest.playerId; - if (tmpPlayer) - { + if (tmpPlayer) { // Send player info to client. netPlayerInfoReply->playerInfoResult.present = playerInfoResult_PR_playerInfoData; PlayerInfoData *data = &netPlayerInfoReply->playerInfoResult.choice.playerInfoData; @@ -1328,15 +1228,13 @@ ServerLobbyThread::HandleNetPacketRetrievePlayerInfo(SessionWrapper session, con &data->playerName, tmpPlayer->GetName().c_str(), tmpPlayer->GetName().length()); - if (!tmpPlayer->GetCountry().empty()) - { + if (!tmpPlayer->GetCountry().empty()) { data->countryCode = OCTET_STRING_new_fromBuf( - &asn_DEF_UTF8String, - tmpPlayer->GetCountry().c_str(), - tmpPlayer->GetCountry().length()); + &asn_DEF_UTF8String, + tmpPlayer->GetCountry().c_str(), + tmpPlayer->GetCountry().length()); } - if (!tmpPlayer->GetAvatarMD5().IsZero()) - { + if (!tmpPlayer->GetAvatarMD5().IsZero()) { data->avatarData = (struct PlayerInfoData::avatarData *)calloc(1, sizeof(struct PlayerInfoData::avatarData)); data->avatarData->avatarType = static_cast(AvatarManager::GetAvatarFileType(tmpPlayer->GetAvatarFile())); OCTET_STRING_fromBuf( @@ -1344,9 +1242,7 @@ ServerLobbyThread::HandleNetPacketRetrievePlayerInfo(SessionWrapper session, con (char *)tmpPlayer->GetAvatarMD5().GetData(), MD5_DATA_SIZE); } - } - else - { + } else { // Unknown player id - notify client. netPlayerInfoReply->playerInfoResult.present = playerInfoResult_PR_unknownPlayerInfo; } @@ -1361,20 +1257,16 @@ ServerLobbyThread::HandleNetPacketRetrieveAvatar(SessionWrapper session, const A string tmpFile; MD5Buf tmpMD5; memcpy(tmpMD5.GetData(), retrieveAvatar.avatar.buf, MD5_DATA_SIZE); - if (GetAvatarManager().GetAvatarFileName(tmpMD5, tmpFile)) - { + if (GetAvatarManager().GetAvatarFileName(tmpMD5, tmpFile)) { NetPacketList tmpPackets; - if (GetAvatarManager().AvatarFileToNetPackets(tmpFile, retrieveAvatar.requestId, tmpPackets) == 0) - { + if (GetAvatarManager().AvatarFileToNetPackets(tmpFile, retrieveAvatar.requestId, tmpPackets) == 0) { avatarFound = true; GetSender().Send(session.sessionData, tmpPackets); - } - else + } else LOG_ERROR("Failed to read avatar file for network transmission."); } - if (!avatarFound) - { + if (!avatarFound) { // Notify client we didn't find the avatar. boost::shared_ptr unknownAvatar(new NetPacket(NetPacket::Alloc)); unknownAvatar->GetMsg()->present = PokerTHMessage_PR_avatarReplyMessage; @@ -1397,25 +1289,16 @@ ServerLobbyThread::HandleNetPacketCreateGame(SessionWrapper session, const std:: string gameName(STL_STRING_FROM_OCTET_STRING(newGame.gameInfo.gameName)); unsigned gameId = GetNextGameId(); - if (IsGameNameInUse(gameName)) - { + if (IsGameNameInUse(gameName)) { SendJoinGameFailed(session.sessionData, gameId, NTF_NET_JOIN_GAME_NAME_IN_USE); - } - else if (GetBanManager().IsBadGameName(gameName)) - { + } else if (GetBanManager().IsBadGameName(gameName)) { SendJoinGameFailed(session.sessionData, gameId, NTF_NET_JOIN_GAME_BAD_NAME); - } - else if (session.playerData->GetRights() == PLAYER_RIGHTS_GUEST - && tmpData.gameType != GAME_TYPE_NORMAL) - { + } else if (session.playerData->GetRights() == PLAYER_RIGHTS_GUEST + && tmpData.gameType != GAME_TYPE_NORMAL) { SendJoinGameFailed(session.sessionData, gameId, NTF_NET_JOIN_GUEST_FORBIDDEN); - } - else if (!ServerGame::CheckSettings(tmpData, password, GetServerMode())) - { + } else if (!ServerGame::CheckSettings(tmpData, password, GetServerMode())) { SendJoinGameFailed(session.sessionData, gameId, NTF_NET_JOIN_INVALID_SETTINGS); - } - else - { + } else { boost::shared_ptr game( new ServerGame( shared_from_this(), @@ -1442,39 +1325,27 @@ ServerLobbyThread::HandleNetPacketJoinGame(SessionWrapper session, const std::st // Join an existing game. GameMap::iterator pos = m_gameMap.find(joinGame.gameId); - if (pos != m_gameMap.end()) - { + if (pos != m_gameMap.end()) { ServerGame &game = *pos->second; const GameData &tmpData = game.GetGameData(); if (session.playerData->GetRights() == PLAYER_RIGHTS_GUEST - && tmpData.gameType != GAME_TYPE_NORMAL) - { + && tmpData.gameType != GAME_TYPE_NORMAL) { SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_GUEST_FORBIDDEN); - } - else if (tmpData.gameType == GAME_TYPE_INVITE_ONLY - && !game.IsPlayerInvited(session.playerData->GetUniqueId())) - { + } else if (tmpData.gameType == GAME_TYPE_INVITE_ONLY + && !game.IsPlayerInvited(session.playerData->GetUniqueId())) { SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_NOT_INVITED); - } - else if (!game.CheckPassword(password)) - { + } else if (!game.CheckPassword(password)) { SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_INVALID_PASSWORD); - } - else if (tmpData.gameType == GAME_TYPE_RANKING - && session.sessionData->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR - && session.sessionData->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4V6 - && session.sessionData->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4 - && game.IsClientAddressConnected(session.sessionData->GetClientAddr())) - { + } else if (tmpData.gameType == GAME_TYPE_RANKING + && session.sessionData->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR + && session.sessionData->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4V6 + && session.sessionData->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4 + && game.IsClientAddressConnected(session.sessionData->GetClientAddr())) { SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_IP_BLOCKED); - } - else - { + } else { MoveSessionToGame(game, session, autoLeave); } - } - else - { + } else { SendJoinGameFailed(session.sessionData, joinGame.gameId, NTF_NET_JOIN_GAME_INVALID); } } @@ -1483,10 +1354,8 @@ void ServerLobbyThread::HandleNetPacketChatRequest(SessionWrapper session, const ChatRequestMessage_t &chatRequest) { // Guests are not allowed to chat. - if (session.playerData && session.playerData->GetRights() != PLAYER_RIGHTS_GUEST) - { - if (chatRequest.chatRequestType.present == chatRequestType_PR_chatRequestTypeLobby) - { + if (session.playerData && session.playerData->GetRights() != PLAYER_RIGHTS_GUEST) { + if (chatRequest.chatRequestType.present == chatRequestType_PR_chatRequestTypeLobby) { boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); packet->GetMsg()->present = PokerTHMessage_PR_chatMessage; ChatMessage_t *netChat = &packet->GetMsg()->choice.chatMessage; @@ -1512,22 +1381,18 @@ ServerLobbyThread::HandleNetPacketChatRequest(SessionWrapper session, const Chat session.playerData->GetUniqueId(), session.playerData->GetName(), chatMsg); - } - else if (chatRequest.chatRequestType.present == chatRequestType_PR_chatRequestTypePrivate) - { + } else if (chatRequest.chatRequestType.present == chatRequestType_PR_chatRequestTypePrivate) { const ChatRequestTypePrivate_t *netPrivateChat = &chatRequest.chatRequestType.choice.chatRequestTypePrivate; SessionWrapper targetSession = m_sessionManager.GetSessionByUniquePlayerId(netPrivateChat->targetPlayerId); if (!targetSession.sessionData) targetSession = m_gameSessionManager.GetSessionByUniquePlayerId(netPrivateChat->targetPlayerId); - if (targetSession.sessionData && targetSession.playerData) - { + if (targetSession.sessionData && targetSession.playerData) { // Only allow private messages to players which are not in running games. // TODO: Send chat reject message if private message was not sent. unsigned gameId = targetSession.sessionData->GetGameId(); GameMap::const_iterator pos = m_gameMap.find(gameId); - if (pos == m_gameMap.end() || !pos->second->IsRunning()) - { + if (pos == m_gameMap.end() || !pos->second->IsRunning()) { boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); packet->GetMsg()->present = PokerTHMessage_PR_chatMessage; ChatMessage_t *netChat = &packet->GetMsg()->choice.chatMessage; @@ -1550,12 +1415,10 @@ ServerLobbyThread::HandleNetPacketRejectGameInvitation(SessionWrapper session, c { GameMap::iterator pos = m_gameMap.find(reject.gameId); - if (pos != m_gameMap.end() && session.playerData) - { + if (pos != m_gameMap.end() && session.playerData) { ServerGame &game = *pos->second; unsigned tmpPlayerId = session.playerData->GetUniqueId(); - if (game.IsPlayerInvited(tmpPlayerId)) - { + if (game.IsPlayerInvited(tmpPlayerId)) { // If he rejects, he is no longer invited. game.RemovePlayerInvitation(tmpPlayerId); // Send reject notification. @@ -1574,8 +1437,7 @@ ServerLobbyThread::HandleNetPacketRejectGameInvitation(SessionWrapper session, c void ServerLobbyThread::AuthChallenge(SessionWrapper session, const string &secret) { - if (session.sessionData && session.playerData && session.sessionData->AuthGetCurStepNum() == 1) - { + if (session.sessionData && session.playerData && session.sessionData->AuthGetCurStepNum() == 1) { session.sessionData->AuthSetPassword(secret); // For this auth session. string outChallenge(session.sessionData->AuthGetNextOutMsg()); @@ -1595,8 +1457,7 @@ ServerLobbyThread::AuthChallenge(SessionWrapper session, const string &secret) void ServerLobbyThread::CheckAvatarBlacklist(SessionWrapper session) { - if (session.sessionData && session.playerData) - { + if (session.sessionData && session.playerData) { const MD5Buf &avatarMD5 = session.playerData->GetAvatarMD5(); if (!avatarMD5.IsZero()) m_database->AsyncCheckAvatarBlacklist(session.playerData->GetUniqueId(), avatarMD5.ToString()); @@ -1609,8 +1470,7 @@ void ServerLobbyThread::AvatarBlacklisted(unsigned playerId) { SessionWrapper tmpSession = m_sessionManager.GetSessionByUniquePlayerId(playerId, true); - if (tmpSession.sessionData && tmpSession.playerData) - { + if (tmpSession.sessionData && tmpSession.playerData) { tmpSession.playerData->SetAvatarMD5(MD5Buf()); // Reset avatar if blacklisted. InitAfterLogin(tmpSession); } @@ -1626,17 +1486,13 @@ ServerLobbyThread::AvatarOK(unsigned playerId) void ServerLobbyThread::InitAfterLogin(SessionWrapper session) { - if (session.sessionData && session.playerData) - { + if (session.sessionData && session.playerData) { const MD5Buf &avatarMD5 = session.playerData->GetAvatarMD5(); string avatarFileName; if (!avatarMD5.IsZero() - && !GetAvatarManager().GetAvatarFileName(avatarMD5, avatarFileName)) - { + && !GetAvatarManager().GetAvatarFileName(avatarMD5, avatarFileName)) { RequestPlayerAvatar(session); - } - else - { + } else { if (!avatarFileName.empty()) session.playerData->SetAvatarFile(avatarFileName); EstablishSession(session); @@ -1653,8 +1509,7 @@ ServerLobbyThread::EstablishSession(SessionWrapper session) // Run postlogin for DB string tmpAvatarHash; string tmpAvatarType; - if (!session.playerData->GetAvatarMD5().IsZero()) - { + if (!session.playerData->GetAvatarMD5().IsZero()) { tmpAvatarHash = session.playerData->GetAvatarMD5().ToString(); tmpAvatarType = AvatarManager::GetAvatarFileExtension(AvatarManager::GetAvatarFileType(session.playerData->GetAvatarFile())); if (!tmpAvatarType.empty()) @@ -1696,8 +1551,7 @@ ServerLobbyThread::EstablishSession(SessionWrapper session) void ServerLobbyThread::AuthenticatePlayer(SessionWrapper session) { - if(session.playerData) - { + if(session.playerData) { m_database->AsyncPlayerLogin(session.playerData->GetUniqueId(), session.playerData->GetName()); } } @@ -1706,8 +1560,7 @@ void ServerLobbyThread::UserValid(unsigned playerId, const DBPlayerData &dbPlayerData) { SessionWrapper tmpSession = m_sessionManager.GetSessionByUniquePlayerId(playerId, true); - if (tmpSession.sessionData && tmpSession.playerData) - { + if (tmpSession.sessionData && tmpSession.playerData) { tmpSession.playerData->SetDBId(dbPlayerData.id); tmpSession.playerData->SetCountry(dbPlayerData.country); this->AuthChallenge(tmpSession, dbPlayerData.secret); @@ -1726,8 +1579,7 @@ ServerLobbyThread::SendReportAvatarResult(unsigned byPlayerId, unsigned reported SessionWrapper session = m_sessionManager.GetSessionByUniquePlayerId(byPlayerId); if (!session.sessionData) session = m_gameSessionManager.GetSessionByUniquePlayerId(byPlayerId); - if (session.sessionData) - { + if (session.sessionData) { boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); packet->GetMsg()->present = PokerTHMessage_PR_reportAvatarAckMessage; ReportAvatarAckMessage_t *netReportAck = &packet->GetMsg()->choice.reportAvatarAckMessage; @@ -1763,13 +1615,11 @@ ServerLobbyThread::RequestPlayerAvatar(SessionWrapper session) void ServerLobbyThread::TimerRemoveGame(const boost::system::error_code &ec) { - if (!ec) - { + if (!ec) { // Synchronously remove games which have been closed. GameMap::iterator i = m_gameMap.begin(); GameMap::iterator end = m_gameMap.end(); - while (i != end) - { + while (i != end) { GameMap::iterator next = i; ++next; boost::shared_ptr tmpGame = i->second; @@ -1789,17 +1639,14 @@ ServerLobbyThread::TimerRemoveGame(const boost::system::error_code &ec) void ServerLobbyThread::TimerRemovePlayer(const boost::system::error_code &ec) { - if (!ec) - { + if (!ec) { boost::mutex::scoped_lock lock(m_removePlayerListMutex); - if (!m_removePlayerList.empty()) - { + if (!m_removePlayerList.empty()) { RemovePlayerList::iterator i = m_removePlayerList.begin(); RemovePlayerList::iterator end = m_removePlayerList.end(); - while (i != end) - { + while (i != end) { InternalRemovePlayer(i->first, i->second); ++i; } @@ -1817,15 +1664,13 @@ ServerLobbyThread::TimerRemovePlayer(const boost::system::error_code &ec) void ServerLobbyThread::TimerUpdateClientLoginLock(const boost::system::error_code &ec) { - if (!ec) - { + if (!ec) { boost::mutex::scoped_lock lock(m_timerClientAddressMapMutex); TimerClientAddressMap::iterator i = m_timerClientAddressMap.begin(); TimerClientAddressMap::iterator end = m_timerClientAddressMap.end(); - while (i != end) - { + while (i != end) { TimerClientAddressMap::iterator next = i; ++next; if (i->second.elapsed().total_seconds() > (int)SERVER_INIT_LOGIN_CLIENT_LOCK_SEC) @@ -1844,8 +1689,7 @@ ServerLobbyThread::TimerUpdateClientLoginLock(const boost::system::error_code &e void ServerLobbyThread::TimerCheckSessionTimeouts(const boost::system::error_code &ec) { - if (!ec) - { + if (!ec) { m_sessionManager.ForEach(boost::bind(&ServerLobbyThread::InternalCheckSessionTimeouts, boost::ref(*this), _1)); m_gameSessionManager.ForEach(boost::bind(&ServerLobbyThread::InternalCheckSessionTimeouts, boost::ref(*this), _1)); // Restart timer @@ -1860,11 +1704,9 @@ ServerLobbyThread::TimerCheckSessionTimeouts(const boost::system::error_code &ec void ServerLobbyThread::TimerCleanupAvatarCache(const boost::system::error_code &ec) { - if (!ec) - { + if (!ec) { // Only act if there are no sessions. - if (!m_sessionManager.HasSessions() && !m_gameSessionManager.HasSessions()) - { + if (!m_sessionManager.HasSessions() && !m_gameSessionManager.HasSessions()) { LOG_VERBOSE("Cleaning up avatar cache."); m_avatarManager.RemoveOldAvatarCacheEntries(); @@ -1885,10 +1727,8 @@ ServerLobbyThread::IsGameNameInUse(const std::string &gameName) const GameMap::const_iterator i = m_gameMap.begin(); GameMap::const_iterator end = m_gameMap.end(); - while (i != end) - { - if ((*i).second->GetName() == gameName) - { + while (i != end) { + if ((*i).second->GetName() == gameName) { found = true; break; } @@ -1901,8 +1741,7 @@ boost::shared_ptr ServerLobbyThread::InternalGetGameFromId(unsigned gameId) { boost::shared_ptr game; - if (gameId) - { + if (gameId) { GameMap::iterator pos = m_gameMap.find(gameId); if (pos != m_gameMap.end()) @@ -1936,8 +1775,7 @@ ServerLobbyThread::InternalRemoveGame(boost::shared_ptr game) { { boost::mutex::scoped_lock lock(m_statMutex); - if (m_statData.numberOfGamesOpen) - { + if (m_statData.numberOfGamesOpen) { --m_statData.numberOfGamesOpen; m_statDataChanged = true; } @@ -1960,17 +1798,14 @@ ServerLobbyThread::InternalRemovePlayer(unsigned playerId, unsigned errorCode) SessionWrapper session = m_sessionManager.GetSessionByUniquePlayerId(playerId, true); if (session.sessionData.get()) SessionError(session, errorCode); - else - { + else { // Scan games for the player. GameMap::iterator i = m_gameMap.begin(); GameMap::iterator end = m_gameMap.end(); - while (i != end) - { + while (i != end) { boost::shared_ptr tmpGame = i->second; - if (tmpGame->GetPlayerDataByUniqueId(playerId).get()) - { + if (tmpGame->GetPlayerDataByUniqueId(playerId).get()) { tmpGame->RemovePlayer(playerId, errorCode); break; } @@ -1982,22 +1817,21 @@ ServerLobbyThread::InternalRemovePlayer(unsigned playerId, unsigned errorCode) void ServerLobbyThread::InternalResubscribeMsg(SessionWrapper session) { - if (!session.sessionData->WantsLobbyMsg()) - { + if (!session.sessionData->WantsLobbyMsg()) { session.sessionData->SetWantsLobbyMsg(); SendPlayerList(session.sessionData); SendGameList(session.sessionData); // Send new statistics information. -/* boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); - packet->GetMsg()->present = PokerTHMessage_PR_statisticsMessage; - StatisticsMessage_t *netStatistics = &packet->GetMsg()->choice.statisticsMessage; + /* boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); + packet->GetMsg()->present = PokerTHMessage_PR_statisticsMessage; + StatisticsMessage_t *netStatistics = &packet->GetMsg()->choice.statisticsMessage; - StatisticsData_t *data = (StatisticsData_t *)calloc(1, sizeof(struct StatisticsData)); - data->statisticsType = statisticsType_statNumberOfPlayers; - data->statisticsValue = m_sessionManager.GetRawSessionCount() + m_gameSessionManager.GetRawSessionCount(); - ASN_SEQUENCE_ADD(&netStatistics->statisticsData.list, data); + StatisticsData_t *data = (StatisticsData_t *)calloc(1, sizeof(struct StatisticsData)); + data->statisticsType = statisticsType_statNumberOfPlayers; + data->statisticsValue = m_sessionManager.GetRawSessionCount() + m_gameSessionManager.GetRawSessionCount(); + ASN_SEQUENCE_ADD(&netStatistics->statisticsData.list, data); - GetSender().Send(session.sessionData, packet);*/ + GetSender().Send(session.sessionData, packet);*/ } } @@ -2007,16 +1841,13 @@ ServerLobbyThread::HandleReAddedSession(SessionWrapper session) // Remove session from game session list. m_gameSessionManager.RemoveSession(session.sessionData->GetId()); - if (m_sessionManager.GetRawSessionCount() <= SERVER_MAX_NUM_SESSIONS) - { + if (m_sessionManager.GetRawSessionCount() <= SERVER_MAX_NUM_SESSIONS) { // Set state (back) to established. session.sessionData->SetState(SessionData::Established); session.sessionData->SetGameId(0); // Add session to lobby list. m_sessionManager.AddSession(session); - } - else - { + } else { // Gracefully close this session. SessionError(session, ERR_NET_SERVER_FULL); } @@ -2026,16 +1857,12 @@ void ServerLobbyThread::InternalCheckSessionTimeouts(SessionWrapper session) { bool closeSession = false; - if (session.sessionData.get()) - { - if (session.sessionData->GetState() == SessionData::Init && session.sessionData->GetAutoDisconnectTimerElapsedSec() >= SERVER_INIT_SESSION_TIMEOUT_SEC) - { + if (session.sessionData.get()) { + if (session.sessionData->GetState() == SessionData::Init && session.sessionData->GetAutoDisconnectTimerElapsedSec() >= SERVER_INIT_SESSION_TIMEOUT_SEC) { LOG_VERBOSE("Session init timeout, removing session #" << session.sessionData->GetId() << "."); closeSession = true; - } - else if (session.sessionData->GetActivityTimerElapsedSec() >= SERVER_SESSION_ACTIVITY_TIMEOUT_SEC - SERVER_TIMEOUT_WARNING_REMAINING_SEC - && !session.sessionData->HasActivityNoticeBeenSent()) - { + } else if (session.sessionData->GetActivityTimerElapsedSec() >= SERVER_SESSION_ACTIVITY_TIMEOUT_SEC - SERVER_TIMEOUT_WARNING_REMAINING_SEC + && !session.sessionData->HasActivityNoticeBeenSent()) { session.sessionData->MarkActivityNotice(); boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); @@ -2044,20 +1871,15 @@ ServerLobbyThread::InternalCheckSessionTimeouts(SessionWrapper session) netWarning->timeoutReason = timeoutReason_timeoutNoDataReceived; netWarning->remainingSeconds = SERVER_TIMEOUT_WARNING_REMAINING_SEC; GetSender().Send(session.sessionData, packet); - } - else if (session.sessionData->GetActivityTimerElapsedSec() >= SERVER_SESSION_ACTIVITY_TIMEOUT_SEC) - { + } else if (session.sessionData->GetActivityTimerElapsedSec() >= SERVER_SESSION_ACTIVITY_TIMEOUT_SEC) { LOG_VERBOSE("Activity timeout, removing session #" << session.sessionData->GetId() << "."); closeSession = true; - } - else if (session.sessionData->GetAutoDisconnectTimerElapsedSec() >= SERVER_SESSION_FORCED_TIMEOUT_SEC) - { + } else if (session.sessionData->GetAutoDisconnectTimerElapsedSec() >= SERVER_SESSION_FORCED_TIMEOUT_SEC) { LOG_VERBOSE("Auto disconnect timeout, removing session #" << session.sessionData->GetId() << "."); closeSession = true; } } - if (closeSession) - { + if (closeSession) { if (session.playerData.get()) RemovePlayer(session.playerData->GetUniqueId(), ERR_NET_SESSION_TIMED_OUT); else @@ -2068,8 +1890,7 @@ ServerLobbyThread::InternalCheckSessionTimeouts(SessionWrapper session) void ServerLobbyThread::SessionError(SessionWrapper session, int errorCode) { - if (session.sessionData) - { + if (session.sessionData) { SendError(session.sessionData, errorCode); CloseSession(session); } @@ -2097,38 +1918,37 @@ ServerLobbyThread::SendJoinGameFailed(boost::shared_ptr s, unsigned netJoinReply->joinGameResult.present = joinGameResult_PR_joinGameFailed; JoinGameFailed_t *joinFailed = &netJoinReply->joinGameResult.choice.joinGameFailed; - switch (reason) - { - case NTF_NET_JOIN_GAME_FULL : - joinFailed->joinGameFailureReason = joinGameFailureReason_gameIsFull; - break; - case NTF_NET_JOIN_ALREADY_RUNNING : - joinFailed->joinGameFailureReason = joinGameFailureReason_gameIsRunning; - break; - case NTF_NET_JOIN_INVALID_PASSWORD : - joinFailed->joinGameFailureReason = joinGameFailureReason_invalidPassword; - break; - case NTF_NET_JOIN_GUEST_FORBIDDEN : - joinFailed->joinGameFailureReason = joinGameFailureReason_notAllowedAsGuest; - break; - case NTF_NET_JOIN_NOT_INVITED : - joinFailed->joinGameFailureReason = joinGameFailureReason_notInvited; - break; - case NTF_NET_JOIN_GAME_NAME_IN_USE : - joinFailed->joinGameFailureReason = joinGameFailureReason_gameNameInUse; - break; - case NTF_NET_JOIN_GAME_BAD_NAME : - joinFailed->joinGameFailureReason = joinGameFailureReason_badGameName; - break; - case NTF_NET_JOIN_INVALID_SETTINGS : - joinFailed->joinGameFailureReason = joinGameFailureReason_invalidSettings; - break; - case NTF_NET_JOIN_IP_BLOCKED : - joinFailed->joinGameFailureReason = joinGameFailureReason_ipAddressBlocked; - break; - default : - joinFailed->joinGameFailureReason = joinGameFailureReason_invalidGame; - break; + switch (reason) { + case NTF_NET_JOIN_GAME_FULL : + joinFailed->joinGameFailureReason = joinGameFailureReason_gameIsFull; + break; + case NTF_NET_JOIN_ALREADY_RUNNING : + joinFailed->joinGameFailureReason = joinGameFailureReason_gameIsRunning; + break; + case NTF_NET_JOIN_INVALID_PASSWORD : + joinFailed->joinGameFailureReason = joinGameFailureReason_invalidPassword; + break; + case NTF_NET_JOIN_GUEST_FORBIDDEN : + joinFailed->joinGameFailureReason = joinGameFailureReason_notAllowedAsGuest; + break; + case NTF_NET_JOIN_NOT_INVITED : + joinFailed->joinGameFailureReason = joinGameFailureReason_notInvited; + break; + case NTF_NET_JOIN_GAME_NAME_IN_USE : + joinFailed->joinGameFailureReason = joinGameFailureReason_gameNameInUse; + break; + case NTF_NET_JOIN_GAME_BAD_NAME : + joinFailed->joinGameFailureReason = joinGameFailureReason_badGameName; + break; + case NTF_NET_JOIN_INVALID_SETTINGS : + joinFailed->joinGameFailureReason = joinGameFailureReason_invalidSettings; + break; + case NTF_NET_JOIN_IP_BLOCKED : + joinFailed->joinGameFailureReason = joinGameFailureReason_ipAddressBlocked; + break; + default : + joinFailed->joinGameFailureReason = joinGameFailureReason_invalidGame; + break; } GetSender().Send(s, packet); } @@ -2143,8 +1963,7 @@ ServerLobbyThread::SendPlayerList(boost::shared_ptr s) // Send all player ids to client. PlayerIdList::const_iterator i = idList.begin(); PlayerIdList::const_iterator end = idList.end(); - while (i != end) - { + while (i != end) { GetSender().Send(s, CreateNetPacketPlayerListNew(*i)); ++i; } @@ -2155,8 +1974,7 @@ ServerLobbyThread::SendGameList(boost::shared_ptr s) { GameMap::const_iterator game_i = m_gameMap.begin(); GameMap::const_iterator game_end = m_gameMap.end(); - while (game_i != game_end) - { + while (game_i != game_end) { GetSender().Send(s, CreateNetPacketGameListNew(*game_i->second)); ++game_i; } @@ -2169,8 +1987,7 @@ ServerLobbyThread::UpdateStatisticsNumberOfPlayers() unsigned curNumberOfPlayersOnServer = m_sessionManager.GetRawSessionCount() + m_gameSessionManager.GetRawSessionCount(); { boost::mutex::scoped_lock lock(m_statMutex); - if (curNumberOfPlayersOnServer != m_statData.numberOfPlayersOnServer) - { + if (curNumberOfPlayersOnServer != m_statData.numberOfPlayersOnServer) { m_statData.numberOfPlayersOnServer = stats.numberOfPlayersOnServer = curNumberOfPlayersOnServer; if (curNumberOfPlayersOnServer > m_statData.maxPlayersLoggedIn) m_statData.maxPlayersLoggedIn = curNumberOfPlayersOnServer; @@ -2184,8 +2001,7 @@ ServerLobbyThread::UpdateStatisticsNumberOfPlayers() void ServerLobbyThread::BroadcastStatisticsUpdate(const ServerStats &stats) { - if (stats.numberOfPlayersOnServer) - { + if (stats.numberOfPlayersOnServer) { boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); packet->GetMsg()->present = PokerTHMessage_PR_statisticsMessage; StatisticsMessage_t *netStatistics = &packet->GetMsg()->choice.statisticsMessage; @@ -2205,11 +2021,9 @@ ServerLobbyThread::ReadStatisticsFile() { ifstream i(m_statisticsFileName.c_str(), ios_base::in); - if (!i.fail() && !i.eof()) - { + if (!i.fail() && !i.eof()) { boost::mutex::scoped_lock lock(m_statMutex); - do - { + do { string statisticsType; unsigned statisticsValue; i >> statisticsType; @@ -2231,15 +2045,12 @@ ServerLobbyThread::ReadStatisticsFile() void ServerLobbyThread::TimerSaveStatisticsFile(const boost::system::error_code &ec) { - if (!ec) - { + if (!ec) { LOG_VERBOSE("Saving statistics."); boost::mutex::scoped_lock lock(m_statMutex); - if (m_statDataChanged) - { + if (m_statDataChanged) { ofstream o(m_statisticsFileName.c_str(), ios_base::out | ios_base::trunc); - if (!o.fail()) - { + if (!o.fail()) { o << SERVER_STATISTICS_STR_TOTAL_PLAYERS " " << m_statData.totalPlayersEverLoggedIn << endl; o << SERVER_STATISTICS_STR_TOTAL_GAMES " " << m_statData.totalGamesEverCreated << endl; o << SERVER_STATISTICS_STR_MAX_PLAYERS " " << m_statData.maxPlayersLoggedIn << endl; @@ -2355,8 +2166,7 @@ ServerLobbyThread::CreateNetPacketGameListNew(const ServerGame &game) PlayerIdList tmpList = game.GetPlayerIdList(); PlayerIdList::const_iterator i = tmpList.begin(); PlayerIdList::const_iterator end = tmpList.end(); - while (i != end) - { + while (i != end) { NonZeroId_t *playerId = (NonZeroId_t *)calloc(1, sizeof(NonZeroId_t)); *playerId = *i; ASN_SEQUENCE_ADD(&gameNew->playerIds.list, playerId); diff --git a/src/net/common/servermanager.cpp b/src/net/common/servermanager.cpp index 07254c3d..0e404f99 100644 --- a/src/net/common/servermanager.cpp +++ b/src/net/common/servermanager.cpp @@ -32,7 +32,7 @@ using namespace std; ServerManager::ServerManager(GuiInterface &gui, ConfigFile &config, AvatarManager &avatarManager) -: m_gui(gui), m_playerConfig(config), m_avatarManager(avatarManager) + : m_gui(gui), m_playerConfig(config), m_avatarManager(avatarManager) { m_ioService.reset(new boost::asio::io_service); m_adminBot.reset(new ServerAdminBot); @@ -52,19 +52,18 @@ ServerManager::Init(unsigned serverPort, bool ipv6, ServerTransportProtocol prot m_adminBot->Init(m_lobbyThread, ircAdminThread); m_lobbyBot->Init(m_lobbyThread, ircLobbyThread); - if (proto & TRANSPORT_PROTOCOL_TCP) - { + if (proto & TRANSPORT_PROTOCOL_TCP) { boost::shared_ptr tcpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService)); tcpAcceptHelper->Listen(serverPort, ipv6, false, logDir, m_lobbyThread); m_acceptHelperPool.push_back(tcpAcceptHelper); } // TODO: Re-add SCTP support once asio supports SCTP. -/* if (mode & TRANSPORT_PROTOCOL_SCTP) - { - boost::shared_ptr sctpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService)); - sctpAcceptHelper->Listen(serverPort, ipv6, true, logDir, m_lobbyThread); - m_acceptHelperPool.push_back(sctpAcceptHelper); - }*/ + /* if (mode & TRANSPORT_PROTOCOL_SCTP) + { + boost::shared_ptr sctpAcceptHelper(new ServerAcceptHelper(GetGui(), m_ioService)); + sctpAcceptHelper->Listen(serverPort, ipv6, true, logDir, m_lobbyThread); + m_acceptHelperPool.push_back(sctpAcceptHelper); + }*/ } GuiInterface & diff --git a/src/net/common/sessiondata.cpp b/src/net/common/sessiondata.cpp index d1d7da55..3739969d 100644 --- a/src/net/common/sessiondata.cpp +++ b/src/net/common/sessiondata.cpp @@ -23,11 +23,11 @@ using namespace std; SessionData::SessionData(boost::shared_ptr sock, SessionId id, SessionDataCallback &cb) -: m_socket(sock), m_id(id), m_gameId(0), m_state(SessionData::Init), m_readyFlag(false), m_wantsLobbyMsg(true), - m_activityTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::microsec_timer::auto_start), - m_activityTimeoutNoticeSent(false), - m_autoDisconnectTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::microsec_timer::auto_start), - m_callback(cb), m_authSession(NULL), m_curAuthStep(0) + : m_socket(sock), m_id(id), m_gameId(0), m_state(SessionData::Init), m_readyFlag(false), m_wantsLobbyMsg(true), + m_activityTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::microsec_timer::auto_start), + m_activityTimeoutNoticeSent(false), + m_autoDisconnectTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::microsec_timer::auto_start), + m_callback(cb), m_authSession(NULL), m_curAuthStep(0) { } @@ -96,8 +96,7 @@ SessionData::CreateClientAuthSession(Gsasl *context, const string &userName, con InternalClearAuthSession(); int errorCode; errorCode = gsasl_client_start(context, "SCRAM-SHA-1", &m_authSession); - if (errorCode == GSASL_OK) - { + if (errorCode == GSASL_OK) { gsasl_property_set(m_authSession, GSASL_AUTHID, userName.c_str()); gsasl_property_set(m_authSession, GSASL_PASSWORD, password.c_str()); @@ -111,19 +110,15 @@ SessionData::AuthStep(int stepNum, const std::string &inData) { bool retVal = false; boost::mutex::scoped_lock lock(m_dataMutex); - if (m_authSession && stepNum == m_curAuthStep + 1) - { + if (m_authSession && stepNum == m_curAuthStep + 1) { m_curAuthStep = stepNum; char *tmpOut; size_t tmpOutSize; int errorCode = gsasl_step(m_authSession, inData.c_str(), inData.length(), &tmpOut, &tmpOutSize); - if (errorCode == GSASL_NEEDS_MORE) - { + if (errorCode == GSASL_NEEDS_MORE) { m_nextGsaslMsg = string(tmpOut, tmpOutSize); retVal = true; - } - else if (errorCode == GSASL_OK && stepNum != 1) - { + } else if (errorCode == GSASL_OK && stepNum != 1) { m_nextGsaslMsg = string(tmpOut, tmpOutSize); retVal = true; InternalClearAuthSession(); @@ -137,8 +132,7 @@ string SessionData::AuthGetUser() const { string retStr; - if (m_authSession) - { + if (m_authSession) { const char *tmpUser = gsasl_property_fast(m_authSession, GSASL_AUTHID); if (tmpUser) retStr = tmpUser; @@ -175,8 +169,7 @@ SessionData::AuthGetCurStepNum() const void SessionData::InternalClearAuthSession() { - if (m_authSession) - { + if (m_authSession) { gsasl_finish(m_authSession); m_authSession = NULL; m_curAuthStep = 0; diff --git a/src/net/common/sessionmanager.cpp b/src/net/common/sessionmanager.cpp index 32a25219..c4117a59 100644 --- a/src/net/common/sessionmanager.cpp +++ b/src/net/common/sessionmanager.cpp @@ -56,8 +56,7 @@ SessionManager::AddSession(SessionWrapper session) // If pos points to a pair whose key is equivalent to the socket, this handle // already exists within the list. - if (pos != m_sessionMap.end() && session.sessionData->GetId() == pos->first) - { + if (pos != m_sessionMap.end() && session.sessionData->GetId() == pos->first) { throw ServerException(__FILE__, __LINE__, ERR_SOCK_CONN_EXISTS, 0); } m_sessionMap.insert(pos, SessionMap::value_type(session.sessionData->GetId(), session)); @@ -100,16 +99,13 @@ SessionManager::GetSessionByPlayerName(const string &playerName) const SessionMap::const_iterator session_i = m_sessionMap.begin(); SessionMap::const_iterator session_end = m_sessionMap.end(); - while (session_i != session_end) - { + while (session_i != session_end) { // Check all players which are fully connected. - if (session_i->second.sessionData->GetState() != SessionData::Init) - { + if (session_i->second.sessionData->GetState() != SessionData::Init) { boost::shared_ptr tmpPlayer(session_i->second.playerData); if (!tmpPlayer.get()) throw ServerException(__FILE__, __LINE__, ERR_NET_INVALID_SESSION, 0); - if (tmpPlayer->GetName() == playerName) - { + if (tmpPlayer->GetName() == playerName) { tmpSession = session_i->second; break; } @@ -129,14 +125,11 @@ SessionManager::GetSessionByUniquePlayerId(unsigned uniqueId, bool initSessions) SessionMap::const_iterator session_i = m_sessionMap.begin(); SessionMap::const_iterator session_end = m_sessionMap.end(); - while (session_i != session_end) - { + while (session_i != session_end) { // Check all players which are fully connected. - if (initSessions || session_i->second.sessionData->GetState() != SessionData::Init) - { + if (initSessions || session_i->second.sessionData->GetState() != SessionData::Init) { boost::shared_ptr tmpPlayer(session_i->second.playerData); - if (tmpPlayer && tmpPlayer->GetUniqueId() == uniqueId) - { + if (tmpPlayer && tmpPlayer->GetUniqueId() == uniqueId) { tmpSession = session_i->second; break; } @@ -156,11 +149,9 @@ SessionManager::GetPlayerDataList() const SessionMap::const_iterator session_i = m_sessionMap.begin(); SessionMap::const_iterator session_end = m_sessionMap.end(); - while (session_i != session_end) - { + while (session_i != session_end) { // Get all players in the game. - if (session_i->second.sessionData->GetState() == SessionData::Game) - { + if (session_i->second.sessionData->GetState() == SessionData::Game) { boost::shared_ptr tmpPlayer(session_i->second.playerData); if (!tmpPlayer.get() || tmpPlayer->GetName().empty()) throw ServerException(__FILE__, __LINE__, ERR_NET_INVALID_SESSION, 0); @@ -180,11 +171,9 @@ SessionManager::GetPlayerIdList(SessionData::State state) const SessionMap::const_iterator session_i = m_sessionMap.begin(); SessionMap::const_iterator session_end = m_sessionMap.end(); - while (session_i != session_end) - { + while (session_i != session_end) { // Get all players in the game. - if (session_i->second.sessionData->GetState() == state) - { + if (session_i->second.sessionData->GetState() == state) { playerList.push_back(session_i->second.playerData->GetUniqueId()); } ++session_i; @@ -227,10 +216,8 @@ SessionManager::IsClientAddressConnected(const std::string &clientAddress) const SessionMap::const_iterator i = m_sessionMap.begin(); SessionMap::const_iterator end = m_sessionMap.end(); - while (i != end) - { - if ((*i).second.sessionData->GetClientAddr() == clientAddress) - { + while (i != end) { + if ((*i).second.sessionData->GetClientAddr() == clientAddress) { retVal = true; break; } @@ -247,8 +234,7 @@ SessionManager::ForEach(boost::function func) SessionMap::iterator i = m_sessionMap.begin(); SessionMap::iterator end = m_sessionMap.end(); - while (i != end) - { + while (i != end) { SessionMap::iterator next = i; ++next; func((*i).second); @@ -265,8 +251,7 @@ SessionManager::CountReadySessions() const SessionMap::const_iterator i = m_sessionMap.begin(); SessionMap::const_iterator end = m_sessionMap.end(); - while (i != end) - { + while (i != end) { if ((*i).second.sessionData->IsReady()) ++counter; ++i; @@ -282,8 +267,7 @@ SessionManager::ResetAllReadyFlags() SessionMap::iterator i = m_sessionMap.begin(); SessionMap::iterator end = m_sessionMap.end(); - while (i != end) - { + while (i != end) { (*i).second.sessionData->ResetReadyFlag(); ++i; } @@ -297,8 +281,7 @@ SessionManager::Clear() SessionMap::iterator end = m_sessionMap.end(); boost::system::error_code ec; - while (i != end) - { + while (i != end) { i->second.sessionData->GetAsioSocket()->close(ec); ++i; } @@ -320,8 +303,7 @@ SessionManager::SendToAllSessions(SenderHelper &sender, boost::shared_ptrsecond.sessionData.get()) throw ServerException(__FILE__, __LINE__, ERR_NET_INVALID_SESSION, 0); @@ -340,8 +322,7 @@ SessionManager::SendLobbyMsgToAllSessions(SenderHelper &sender, boost::shared_pt SessionMap::iterator i = m_sessionMap.begin(); SessionMap::iterator end = m_sessionMap.end(); - while (i != end) - { + while (i != end) { if (!i->second.sessionData.get()) throw ServerException(__FILE__, __LINE__, ERR_NET_INVALID_SESSION, 0); @@ -360,8 +341,7 @@ SessionManager::SendToAllButOneSessions(SenderHelper &sender, boost::shared_ptr< SessionMap::iterator i = m_sessionMap.begin(); SessionMap::iterator end = m_sessionMap.end(); - while (i != end) - { + while (i != end) { // Send each fully connected client but one a copy of the packet. if (i->second.sessionData->GetState() == state) if (i->first != except) diff --git a/src/net/common/socket_startup.cpp b/src/net/common/socket_startup.cpp index 417fd859..762022fa 100644 --- a/src/net/common/socket_startup.cpp +++ b/src/net/common/socket_startup.cpp @@ -34,15 +34,18 @@ extern "C" { { return 0; } - int gcry_bmutex_init(void **obj) { + int gcry_bmutex_init(void **obj) + { *obj = (void*)(new boost::mutex); return 0; } - int gcry_bmutex_destroy(void **obj) { + int gcry_bmutex_destroy(void **obj) + { delete (boost::mutex *)(*obj); return 0; } - int gcry_bmutex_lock(void **obj) { + int gcry_bmutex_lock(void **obj) + { #if (BOOST_VERSION) >= 103500 ((boost::mutex *)(*obj))->lock(); #else @@ -50,7 +53,8 @@ extern "C" { #endif return 0; } - int gcry_bmutex_unlock(void **obj) { + int gcry_bmutex_unlock(void **obj) + { #if (BOOST_VERSION) >= 103500 ((boost::mutex *)(*obj))->unlock(); #else @@ -59,8 +63,7 @@ extern "C" { return 0; } - struct gcry_thread_cbs gcry_threads_boost = - { + struct gcry_thread_cbs gcry_threads_boost = { GCRY_THREAD_OPTION_USER, gcry_bthread_init, gcry_bmutex_init, gcry_bmutex_destroy, gcry_bmutex_lock, gcry_bmutex_unlock, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL @@ -124,16 +127,15 @@ socket_has_dual_stack() bool retVal = false; boost::asio::detail::socket_type test = socket(AF_INET6, SOCK_STREAM, 0); - if (test != boost::asio::detail::invalid_socket) - { + if (test != boost::asio::detail::invalid_socket) { int ipv6only = 0; if (setsockopt(test, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&ipv6only, sizeof(ipv6only)) == 0) retVal = true; - #ifdef _WIN32 +#ifdef _WIN32 closesocket(test); - #else +#else close(test); - #endif +#endif } return retVal; } diff --git a/src/net/common/transferhelper.cpp b/src/net/common/transferhelper.cpp index 7990a165..e04eee4b 100644 --- a/src/net/common/transferhelper.cpp +++ b/src/net/common/transferhelper.cpp @@ -71,16 +71,14 @@ TransferHelper::Process() bool retVal = false; int runningHandles = 0; CURLMcode curlResult; - do - { + do { curlResult = curl_multi_perform(m_data->curlMultiHandle, &runningHandles); } while (curlResult == CURLM_CALL_MULTI_PERFORM); if (curlResult != CURLM_OK) throw NetException(__FILE__, __LINE__, ERR_SOCK_TRANSFER_FAILED, 0); - if (runningHandles) - { + if (runningHandles) { struct timeval timeout; fd_set readSet; fd_set writeSet; @@ -96,15 +94,12 @@ TransferHelper::Process() curl_multi_fdset(m_data->curlMultiHandle, &readSet, &writeSet, &exceptSet, &maxfd); - if (maxfd >= 0) - { + if (maxfd >= 0) { int selectResult = select(maxfd+1, &readSet, &writeSet, &exceptSet, &timeout); if (selectResult == -1) throw NetException(__FILE__, __LINE__, ERR_SOCK_TRANSFER_SELECT_FAILED, 0); } - } - else - { + } else { // Retrieve actual error code. int numMsgs; CURLMsg *tmpMsg; @@ -119,8 +114,7 @@ TransferHelper::Process() Cleanup(); // Throw exception if an error occured. - if (code != CURLE_OK) - { + if (code != CURLE_OK) { if (code == CURLE_URL_MALFORMAT) throw NetException(__FILE__, __LINE__, ERR_SOCK_TRANSFER_INVALID_URL, 0); else @@ -135,18 +129,15 @@ TransferHelper::Process() void TransferHelper::Cleanup() { - if (m_data->curlMultiHandle) - { + if (m_data->curlMultiHandle) { curl_multi_cleanup(m_data->curlMultiHandle); m_data->curlMultiHandle = NULL; } - if (m_data->curlHandle) - { + if (m_data->curlHandle) { curl_easy_cleanup(m_data->curlHandle); m_data->curlHandle = NULL; } - if (m_data->targetFile) - { + if (m_data->targetFile) { fflush(m_data->targetFile); fclose(m_data->targetFile); m_data->targetFile = NULL; diff --git a/src/net/common/uploaderthread.cpp b/src/net/common/uploaderthread.cpp index c18a967e..e4d6f54f 100644 --- a/src/net/common/uploaderthread.cpp +++ b/src/net/common/uploaderthread.cpp @@ -30,7 +30,7 @@ using namespace boost::filesystem; UploaderThread::UploaderThread() -: m_uploadInProgress(false) + : m_uploadInProgress(false) { m_uploadHelper.reset(new UploadHelper()); } @@ -49,38 +49,30 @@ UploaderThread::QueueUpload(const string &url, const string &user, const string void UploaderThread::Main() { - while (!ShouldTerminate()) - { - try - { - if (m_uploadInProgress) - { + while (!ShouldTerminate()) { + try { + if (m_uploadInProgress) { m_uploadInProgress = !m_uploadHelper->Process(); } - if (!m_uploadInProgress) - { + if (!m_uploadInProgress) { Msleep(UPLOAD_DELAY_MSEC); // The upload needs only local state, as no value needs to be returned. UploadData data; { boost::mutex::scoped_lock lock(m_uploadQueueMutex); - if (!m_uploadQueue.empty()) - { + if (!m_uploadQueue.empty()) { data = m_uploadQueue.front(); m_uploadQueue.pop(); } } - if (!data.filename.empty() && data.filesize > 0) - { + if (!data.filename.empty() && data.filesize > 0) { path filepath(data.filename); m_uploadHelper->Init(data.address + filepath.leaf(), filepath.file_string(), data.user, data.pwd, data.filesize); m_uploadInProgress = true; } } - } - catch (const NetException &e) - { + } catch (const NetException &e) { LOG_ERROR("Upload failed: " << e.what()); m_uploadInProgress = false; } diff --git a/src/net/downloaderthread.h b/src/net/downloaderthread.h index 10b031c1..6f78185d 100644 --- a/src/net/downloaderthread.h +++ b/src/net/downloaderthread.h @@ -42,21 +42,19 @@ public: bool GetDownloadResult(unsigned &downloadId, std::vector &filedata); protected: - struct DownloadData - { + struct DownloadData { DownloadData() : id(0) {} DownloadData(unsigned i, const std::string &a, const std::string &f) - : id(i), address(a), filename(f) {} + : id(i), address(a), filename(f) {} unsigned id; std::string address; std::string filename; }; - struct ResultData - { + struct ResultData { ResultData() : id(0) {} ResultData(unsigned i, const std::vector &d) - : id(i), data(d) {} + : id(i), data(d) {} unsigned id; std::vector data; diff --git a/src/net/downloadhelper.h b/src/net/downloadhelper.h index cd954ed0..dc7d9e3c 100644 --- a/src/net/downloadhelper.h +++ b/src/net/downloadhelper.h @@ -32,7 +32,7 @@ public: protected: virtual void InternalInit(const std::string &url, const std::string &targetFileName, - const std::string &user, const std::string &password, int filesize); + const std::string &user, const std::string &password, int filesize); }; #endif diff --git a/src/net/encodedpacket.h b/src/net/encodedpacket.h index fcfc0b50..60e669c0 100644 --- a/src/net/encodedpacket.h +++ b/src/net/encodedpacket.h @@ -28,13 +28,11 @@ public: EncodedPacket(const unsigned char *data, unsigned size); ~EncodedPacket(); - unsigned GetSize() const - { + unsigned GetSize() const { return m_size; } - const unsigned char *GetData() const - { + const unsigned char *GetData() const { return m_data; } diff --git a/src/net/internalchatcleanerpacket.h b/src/net/internalchatcleanerpacket.h index efe80387..58398800 100644 --- a/src/net/internalchatcleanerpacket.h +++ b/src/net/internalchatcleanerpacket.h @@ -32,16 +32,13 @@ public: InternalChatCleanerPacket(); InternalChatCleanerPacket(ChatCleanerMessage_t *msg) - : m_msg(msg) - { + : m_msg(msg) { } ~InternalChatCleanerPacket(); - ChatCleanerMessage_t *GetMsg() - { + ChatCleanerMessage_t *GetMsg() { return m_msg; } - ChatCleanerMessage_t **GetMsgPtr() - { + ChatCleanerMessage_t **GetMsgPtr() { return &m_msg; } diff --git a/src/net/netcontext.h b/src/net/netcontext.h index 9520a881..6d6dfcf3 100644 --- a/src/net/netcontext.h +++ b/src/net/netcontext.h @@ -24,7 +24,7 @@ #include #ifndef _WIN32 - #define SOCKET int +#define SOCKET int #endif class NetContext diff --git a/src/net/netpacket.h b/src/net/netpacket.h index 11769122..fc548eb3 100644 --- a/src/net/netpacket.h +++ b/src/net/netpacket.h @@ -53,8 +53,12 @@ public: static boost::shared_ptr Create(char *data, unsigned &dataSize); - const PokerTHMessage_t *GetMsg() const {return m_msg;} - PokerTHMessage_t *GetMsg() {return m_msg;} + const PokerTHMessage_t *GetMsg() const { + return m_msg; + } + PokerTHMessage_t *GetMsg() { + return m_msg; + } bool IsClientActivity() const; diff --git a/src/net/receivebuffer.h b/src/net/receivebuffer.h index 253f1d91..d954ada9 100644 --- a/src/net/receivebuffer.h +++ b/src/net/receivebuffer.h @@ -26,9 +26,10 @@ // MUST be larger than MAX_PACKET_SIZE #define RECV_BUF_SIZE 2 * MAX_PACKET_SIZE -struct ReceiveBuffer -{ - ReceiveBuffer() : recvBufUsed(0) {recvBuf[0] = 0;} +struct ReceiveBuffer { + ReceiveBuffer() : recvBufUsed(0) { + recvBuf[0] = 0; + } NetPacketList receivedPackets; char recvBuf[RECV_BUF_SIZE]; unsigned recvBufUsed; diff --git a/src/net/serveraccepthelper.h b/src/net/serveraccepthelper.h index ef2a47b0..9c561dd1 100644 --- a/src/net/serveraccepthelper.h +++ b/src/net/serveraccepthelper.h @@ -37,13 +37,13 @@ public: // Set the parameters. void Listen(unsigned serverPort, bool ipv6, bool sctp, const std::string &logDir, - boost::shared_ptr lobbyThread); + boost::shared_ptr lobbyThread); protected: void InternalListen(unsigned serverPort, bool ipv6, bool sctp); void HandleAccept(boost::shared_ptr acceptedSocket, - const boost::system::error_code &error); + const boost::system::error_code &error); ServerCallback &GetCallback(); diff --git a/src/net/serverbanmanager.h b/src/net/serverbanmanager.h index 48b2763d..9e770dd3 100644 --- a/src/net/serverbanmanager.h +++ b/src/net/serverbanmanager.h @@ -50,14 +50,12 @@ public: protected: - struct TimedPlayerBan - { + struct TimedPlayerBan { boost::shared_ptr timer; std::string nameStr; boost::regex nameRegex; }; - struct TimedIPBan - { + struct TimedIPBan { boost::shared_ptr timer; std::string ipAddress; }; diff --git a/src/net/servergame.h b/src/net/servergame.h index 9c24b722..6903f36d 100644 --- a/src/net/servergame.h +++ b/src/net/servergame.h @@ -98,8 +98,7 @@ public: protected: - struct RankingData - { + struct RankingData { RankingData() : dbid(DB_ID_INVALID), place(0) {} RankingData(DB_id i, int p = 0) : dbid(i), place(p) {} DB_id dbid; @@ -210,14 +209,14 @@ private: boost::asio::deadline_timer m_stateTimer1; boost::asio::deadline_timer m_stateTimer2; -friend class ServerLobbyThread; -friend class AbstractServerGameStateReceiving; -friend class ServerGameStateInit; -friend class ServerGameStateWaitAck; -friend class ServerGameStateStartGame; -friend class ServerGameStateHand; -friend class ServerGameStateWaitPlayerAction; -friend class ServerGameStateWaitNextHand; + friend class ServerLobbyThread; + friend class AbstractServerGameStateReceiving; + friend class ServerGameStateInit; + friend class ServerGameStateWaitAck; + friend class ServerGameStateStartGame; + friend class ServerGameStateHand; + friend class ServerGameStateWaitPlayerAction; + friend class ServerGameStateWaitNextHand; }; #endif diff --git a/src/net/servergamestate.h b/src/net/servergamestate.h index 375ddfd9..399fcb02 100644 --- a/src/net/servergamestate.h +++ b/src/net/servergamestate.h @@ -160,8 +160,8 @@ protected: private: static ServerGameStateHand s_state; -friend class ServerGameStateStartGame; -friend class ServerGameStateWaitNextHand; + friend class ServerGameStateStartGame; + friend class ServerGameStateWaitNextHand; }; // State: Wait for a player action. diff --git a/src/net/serverlobbythread.h b/src/net/serverlobbythread.h index e98a601b..3c68a270 100644 --- a/src/net/serverlobbythread.h +++ b/src/net/serverlobbythread.h @@ -55,7 +55,7 @@ class ServerLobbyThread : public Thread, public boost::enable_shared_from_this ioService); + boost::shared_ptr ioService); virtual ~ServerLobbyThread(); void Init(const std::string &logDir); @@ -263,7 +263,7 @@ private: const boost::posix_time::ptime m_startTime; -friend class InternalServerCallback; + friend class InternalServerCallback; }; #endif diff --git a/src/net/servermanager.h b/src/net/servermanager.h index 9e7d88ca..8fca6dac 100644 --- a/src/net/servermanager.h +++ b/src/net/servermanager.h @@ -58,7 +58,7 @@ public: GuiInterface &GetGui(); ServerAdminBot &GetAdminBot(); ServerLobbyBot &GetLobbyBot(); - + protected: typedef std::list > AcceptHelperList; diff --git a/src/net/sessionmanager.h b/src/net/sessionmanager.h index 855ae2cd..6d73de91 100644 --- a/src/net/sessionmanager.h +++ b/src/net/sessionmanager.h @@ -31,8 +31,7 @@ class NetPacket; class SenderHelper; -struct SessionWrapper -{ +struct SessionWrapper { SessionWrapper() {} SessionWrapper(boost::shared_ptr s, boost::shared_ptr p) : sessionData(s), playerData(p) {} diff --git a/src/net/socket_helper.h b/src/net/socket_helper.h index ba1dfe26..43ad120e 100644 --- a/src/net/socket_helper.h +++ b/src/net/socket_helper.h @@ -21,21 +21,21 @@ #define _SOCKET_HELPER_H_ #ifndef bzero - #include - #define bzero(_ptr, _n) std::memset(_ptr, 0, _n) +#include +#define bzero(_ptr, _n) std::memset(_ptr, 0, _n) #endif #ifdef _WIN32 #ifdef __GNUC__ /* mingw provides stdint.h */ - #include - typedef uint16_t u_int16_t; - typedef uint32_t u_int32_t; +#include +typedef uint16_t u_int16_t; +typedef uint32_t u_int32_t; #else - typedef unsigned __int16 u_int16_t; - typedef unsigned __int32 u_int32_t; - typedef __int16 int16_t; - typedef __int32 int32_t; +typedef unsigned __int16 u_int16_t; +typedef unsigned __int32 u_int32_t; +typedef __int16 int16_t; +typedef __int32 int32_t; #endif typedef unsigned char u_char; diff --git a/src/net/transferdata.h b/src/net/transferdata.h index a2526b60..630aa036 100644 --- a/src/net/transferdata.h +++ b/src/net/transferdata.h @@ -25,8 +25,7 @@ #include -struct TransferData -{ +struct TransferData { CURL *curlHandle; CURLM *curlMultiHandle; FILE *targetFile; diff --git a/src/net/transferhelper.h b/src/net/transferhelper.h index d5d45baf..180ecf34 100644 --- a/src/net/transferhelper.h +++ b/src/net/transferhelper.h @@ -36,7 +36,7 @@ public: // Set the parameters. Does not do any error checking. // Throws an exception on failure. void Init(const std::string &url, const std::string &targetFileName, - const std::string &user = "", const std::string &password = "", int filesize = 0); + const std::string &user = "", const std::string &password = "", int filesize = 0); // Returns true when done, false should call again. // Throws an exception on error. @@ -49,7 +49,7 @@ protected: boost::shared_ptr GetData(); virtual void InternalInit(const std::string &url, const std::string &targetFileName, - const std::string &user, const std::string &password, int filesize) = 0; + const std::string &user, const std::string &password, int filesize) = 0; private: diff --git a/src/net/uploaderthread.h b/src/net/uploaderthread.h index a777eaad..5141cdba 100644 --- a/src/net/uploaderthread.h +++ b/src/net/uploaderthread.h @@ -39,11 +39,10 @@ public: void QueueUpload(const std::string &url, const std::string &user, const std::string &pwd, const std::string &filename, int filesize); protected: - struct UploadData - { + struct UploadData { UploadData() : filesize(0) {} UploadData(const std::string &a, const std::string &u, const std::string &p, const std::string &f, int s) - : address(a), user(u), pwd(p), filename(f), filesize(s) {} + : address(a), user(u), pwd(p), filename(f), filesize(s) {} std::string address; std::string user; diff --git a/src/net/uploadhelper.h b/src/net/uploadhelper.h index d82a0936..b0148291 100644 --- a/src/net/uploadhelper.h +++ b/src/net/uploadhelper.h @@ -32,7 +32,7 @@ public: protected: virtual void InternalInit(const std::string &url, const std::string &targetFileName, - const std::string &user, const std::string &password, int filesize); + const std::string &user, const std::string &password, int filesize); }; #endif diff --git a/src/playerdata.cpp b/src/playerdata.cpp index 47265915..572c9982 100644 --- a/src/playerdata.cpp +++ b/src/playerdata.cpp @@ -22,15 +22,15 @@ using namespace std; PlayerData::PlayerData(unsigned uniqueId, int number, PlayerType type, PlayerRights rights, bool isGameAdmin) -: m_uniqueId(uniqueId), m_dbId(DB_ID_INVALID), m_number(number), m_type(type), m_rights(rights), m_isGameAdmin(isGameAdmin) + : m_uniqueId(uniqueId), m_dbId(DB_ID_INVALID), m_number(number), m_type(type), m_rights(rights), m_isGameAdmin(isGameAdmin) { } PlayerData::PlayerData(const PlayerData &other) -: m_uniqueId(other.GetUniqueId()), m_dbId(other.GetDBId()), m_number(other.GetNumber()), m_name(other.GetName()), - m_password(), m_country(other.GetCountry()), m_avatarFile(other.GetAvatarFile()), m_avatarMD5(other.GetAvatarMD5()), - m_type(other.GetType()), m_rights(other.GetRights()), m_isGameAdmin(other.IsGameAdmin()), - m_netSessionData(other.GetNetSessionData()), m_netAvatarFile(), m_dataMutex() + : m_uniqueId(other.GetUniqueId()), m_dbId(other.GetDBId()), m_number(other.GetNumber()), m_name(other.GetName()), + m_password(), m_country(other.GetCountry()), m_avatarFile(other.GetAvatarFile()), m_avatarMD5(other.GetAvatarMD5()), + m_type(other.GetType()), m_rights(other.GetRights()), m_isGameAdmin(other.IsGameAdmin()), + m_netSessionData(other.GetNetSessionData()), m_netAvatarFile(), m_dataMutex() { } diff --git a/src/playerdata.h b/src/playerdata.h index b85f0860..bec13aeb 100644 --- a/src/playerdata.h +++ b/src/playerdata.h @@ -32,37 +32,32 @@ class SessionData; -enum PlayerType -{ +enum PlayerType { PLAYER_TYPE_COMPUTER, PLAYER_TYPE_HUMAN }; -enum PlayerRights -{ +enum PlayerRights { PLAYER_RIGHTS_GUEST = 1, PLAYER_RIGHTS_NORMAL, PLAYER_RIGHTS_ADMIN }; -enum AvatarFileType -{ +enum AvatarFileType { AVATAR_FILE_TYPE_UNKNOWN = 0, AVATAR_FILE_TYPE_PNG, AVATAR_FILE_TYPE_JPG, AVATAR_FILE_TYPE_GIF }; -struct AvatarFile -{ +struct AvatarFile { AvatarFile() : fileType(AVATAR_FILE_TYPE_UNKNOWN), reportedSize(0) {} std::vector fileData; AvatarFileType fileType; unsigned reportedSize; }; -struct PlayerInfo -{ +struct PlayerInfo { PlayerInfo() : ptype(PLAYER_TYPE_HUMAN), isGuest(false), hasAvatar(false), avatarType(AVATAR_FILE_TYPE_UNKNOWN) {} std::string playerName; PlayerType ptype; diff --git a/src/pokerth.cpp b/src/pokerth.cpp index dbd483db..708df2a9 100755 --- a/src/pokerth.cpp +++ b/src/pokerth.cpp @@ -27,7 +27,7 @@ #include #ifdef __APPLE__ - #include +#include #endif #include @@ -41,21 +41,21 @@ #include #ifdef _MSC_VER - #ifdef _DEBUG - #define _CRTDBG_MAP_ALLOC - #include +#ifdef _DEBUG +#define _CRTDBG_MAP_ALLOC +#include - #define ENABLE_LEAK_CHECK() \ +#define ENABLE_LEAK_CHECK() \ { \ int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); \ tmpFlag |= _CRTDBG_LEAK_CHECK_DF; \ _CrtSetDbgFlag(tmpFlag); \ } - #endif +#endif #endif #ifndef ENABLE_LEAK_CHECK - #define ENABLE_LEAK_CHECK() +#define ENABLE_LEAK_CHECK() #endif using namespace std; @@ -65,7 +65,7 @@ class Game; int main( int argc, char **argv ) { - + //ENABLE_LEAK_CHECK(); //_CrtSetBreakAlloc(49937); @@ -91,26 +91,26 @@ int main( int argc, char **argv ) ConfigFile *myConfig = new ConfigFile(argv[0], false); // set PlastiqueStyle even for mac-version to prevent artefacts on styled widgets - a.setStyle(new QPlastiqueStyle); + a.setStyle(new QPlastiqueStyle); QString myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); - //set QApplication default font + //set QApplication default font QFontDatabase::addApplicationFont (myAppDataPath +"fonts/n019003l.pfb"); - QFontDatabase::addApplicationFont (myAppDataPath +"fonts/VeraBd.ttf"); + QFontDatabase::addApplicationFont (myAppDataPath +"fonts/VeraBd.ttf"); QFontDatabase::addApplicationFont (myAppDataPath +"fonts/c059013l.pfb"); #ifdef _WIN32 - QString font1String("QApplication, QWidget, QDialog { font-size: 12px; }"); + QString font1String("QApplication, QWidget, QDialog { font-size: 12px; }"); #else - #ifdef __APPLE__ +#ifdef __APPLE__ // QString font1String("font-family: \"Lucida Grande\";"); - QString font1String("QApplication, QWidget, QDialog { font-size: 11px; }"); - #else - QString font1String("QApplication, QWidget, QDialog { font-family: \"Nimbus Sans L\"; font-size: 12px; }"); - #endif + QString font1String("QApplication, QWidget, QDialog { font-size: 11px; }"); +#else + QString font1String("QApplication, QWidget, QDialog { font-family: \"Nimbus Sans L\"; font-size: 12px; }"); #endif - a.setStyleSheet(font1String + " QDialogButtonBox, QMessageBox { dialogbuttonbox-buttons-have-icons: 1; dialog-ok-icon: url(:/gfx/dialog_ok_apply.png); dialog-cancel-icon: url(:/gfx/dialog_close.png); dialog-close-icon: url(:/gfx/dialog_close.png); dialog-yes-icon: url(:/gfx/dialog_ok_apply.png); dialog-no-icon: url(:/gfx/dialog_close.png) }"); +#endif + a.setStyleSheet(font1String + " QDialogButtonBox, QMessageBox { dialogbuttonbox-buttons-have-icons: 1; dialog-ok-icon: url(:/gfx/dialog_ok_apply.png); dialog-cancel-icon: url(:/gfx/dialog_close.png); dialog-close-icon: url(:/gfx/dialog_close.png); dialog-yes-icon: url(:/gfx/dialog_ok_apply.png); dialog-no-icon: url(:/gfx/dialog_close.png) }"); QPixmap *pixmap = new QPixmap(myAppDataPath + "gfx/gui/misc/welcomepokerth.png"); StartSplash splash(*pixmap); @@ -118,11 +118,11 @@ int main( int argc, char **argv ) splash.show(); splash.showMessage(QString("Version %1").arg(POKERTH_BETA_RELEASE_STRING), 0x0042, QColor(153,213,0)); } - + //Set translations QTranslator qtTranslator; - qtTranslator.load(QString(myAppDataPath +"translations/qt_") + QString::fromStdString(myConfig->readConfigString("Language"))); - a.installTranslator(&qtTranslator); + qtTranslator.load(QString(myAppDataPath +"translations/qt_") + QString::fromStdString(myConfig->readConfigString("Language"))); + a.installTranslator(&qtTranslator); QTranslator translator; translator.load(QString(myAppDataPath +"translations/pokerth_") + QString::fromStdString(myConfig->readConfigString("Language"))); @@ -132,17 +132,17 @@ int main( int argc, char **argv ) qRegisterMetaType >("boost::shared_ptr"); qRegisterMetaType("ServerStats"); qRegisterMetaType("DenyGameInvitationReason"); - /////////////////////////////////////////////////// + /////////////////////////////////////////////////// startWindowImpl mainWin(myConfig); a.setActivationWindow(&mainWin, true); int retVal = a.exec(); - + curl_global_cleanup(); socket_cleanup(); - - + + return retVal; - + } diff --git a/src/pokerth_server.cpp b/src/pokerth_server.cpp index 845b431e..1dd6c945 100644 --- a/src/pokerth_server.cpp +++ b/src/pokerth_server.cpp @@ -34,21 +34,21 @@ #include #ifdef _MSC_VER - #ifdef _DEBUG - #define _CRTDBG_MAP_ALLOC - #include +#ifdef _DEBUG +#define _CRTDBG_MAP_ALLOC +#include - #define ENABLE_LEAK_CHECK() \ +#define ENABLE_LEAK_CHECK() \ { \ int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); \ tmpFlag |= _CRTDBG_LEAK_CHECK_DF; \ _CrtSetDbgFlag(tmpFlag); \ } - #endif +#endif #endif #ifndef ENABLE_LEAK_CHECK - #define ENABLE_LEAK_CHECK() +#define ENABLE_LEAK_CHECK() #endif using namespace std; @@ -65,12 +65,12 @@ TerminateHandler(int /*signal*/) // TODO: Hack #ifdef _WIN32 - #include +#include #else - #include - #ifndef daemon - int daemon(int, int); - #endif +#include +#ifndef daemon +int daemon(int, int); +#endif #endif int @@ -87,33 +87,29 @@ main(int argc, char *argv[]) // Check command line options. po::options_description desc("Allowed options"); desc.add_options() - ("help,h", "produce help message") - ("version,v", "print version string") - ("log-level,l", po::value(), "set log level (0=minimal, 1=default, 2=verbose)") - ("pid-file,p", po::value(), "create pid-file in different location") - ("readonly-config", "treat config file as read-only") - ; + ("help,h", "produce help message") + ("version,v", "print version string") + ("log-level,l", po::value(), "set log level (0=minimal, 1=default, 2=verbose)") + ("pid-file,p", po::value(), "create pid-file in different location") + ("readonly-config", "treat config file as read-only") + ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); - if (vm.count("help")) - { + if (vm.count("help")) { cout << desc << endl; return 1; } - if (vm.count("version")) - { + if (vm.count("version")) { cout << "PokerTH server version " << POKERTH_BETA_RELEASE_STRING << endl << "Network protocol version " << NET_VERSION_MAJOR << "." << NET_VERSION_MINOR << endl; return 1; } - if (vm.count("log-level")) - { + if (vm.count("log-level")) { logLevel = vm["log-level"].as(); - if (logLevel < 0 || logLevel > 2) - { + if (logLevel < 0 || logLevel > 2) { cout << "Invalid log-level: \"" << logLevel << "\", allowed range 0-2." << endl; return 1; } @@ -131,8 +127,7 @@ main(int argc, char *argv[]) // TODO: Hack #ifndef _WIN32 - if (daemon(0, 0) != 0) - { + if (daemon(0, 0) != 0) { cout << "Failed to start daemon." << endl; return 1; } @@ -144,11 +139,10 @@ main(int argc, char *argv[]) socket_startup(); LOG_MSG("Starting PokerTH dedicated server. Availability: IPv6 " - << socket_has_ipv6() << ", SCTP " << socket_has_sctp() << ", Dual Stack " << socket_has_dual_stack() << "."); + << socket_has_ipv6() << ", SCTP " << socket_has_sctp() << ", Dual Stack " << socket_has_dual_stack() << "."); // Store pid in file. - if (pidFile.empty()) - { + if (pidFile.empty()) { path tmpPidPath(myConfig->readConfigString("LogDir")); tmpPidPath /= "pokerth.pid"; pidFile = tmpPidPath.directory_string(); @@ -169,8 +163,7 @@ main(int argc, char *argv[]) myServerGuiInterface->setSession(session); myServerGuiInterface->getSession()->startNetworkServer(true); - while (!g_pokerthTerminate) - { + while (!g_pokerthTerminate) { Thread::Msleep(100); if (myServerGuiInterface->getSession()->pollNetworkServerTerminated()) g_pokerthTerminate = true; diff --git a/src/serverdata.h b/src/serverdata.h index 76c512e9..1ee0aab5 100644 --- a/src/serverdata.h +++ b/src/serverdata.h @@ -24,8 +24,7 @@ #include -struct ServerInfo -{ +struct ServerInfo { ServerInfo() : id(0), supportsSctp(false), port(0) {} unsigned id; std::string name; diff --git a/src/session.cpp b/src/session.cpp index 80b2774d..59a2b4a2 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -43,96 +43,103 @@ using namespace std; Session::Session(GuiInterface *g, ConfigFile *c) - : currentGameNum(0), myGui(g), myConfig(c), myLog(0), myGameType(GAME_TYPE_NONE) + : currentGameNum(0), myGui(g), myConfig(c), myLog(0), myGameType(GAME_TYPE_NONE) { - myQtToolsInterface = CreateQtToolsWrapper(); - myLog = new Log(myConfig->readConfigString("LogDir"),myConfig->readConfigInt("LogOnOff")); + myQtToolsInterface = CreateQtToolsWrapper(); + myLog = new Log(myConfig->readConfigString("LogDir"),myConfig->readConfigInt("LogOnOff")); } Session::~Session() { - terminateNetworkClient(); - terminateNetworkServer(); - delete myQtToolsInterface; - myQtToolsInterface = 0; - delete myLog; - myLog = 0; + terminateNetworkClient(); + terminateNetworkServer(); + delete myQtToolsInterface; + myQtToolsInterface = 0; + delete myLog; + myLog = 0; } bool Session::init() { - myAvatarManager.reset(new AvatarManager( - myConfig->readConfigInt("ServerUsePutAvatars") == 1, - myConfig->readConfigString("ServerPutAvatarsAddress"), - myConfig->readConfigString("ServerPutAvatarsUser"), - myConfig->readConfigString("ServerPutAvatarsPassword") - )); - bool retVal = myAvatarManager->Init( - myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("AppDataDir")), - myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir"))); - addOwnAvatar(myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("MyAvatar"))); - myAvatarManager->RemoveOldAvatarCacheEntries(); - return retVal; + myAvatarManager.reset(new AvatarManager( + myConfig->readConfigInt("ServerUsePutAvatars") == 1, + myConfig->readConfigString("ServerPutAvatarsAddress"), + myConfig->readConfigString("ServerPutAvatarsUser"), + myConfig->readConfigString("ServerPutAvatarsPassword") + )); + bool retVal = myAvatarManager->Init( + myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("AppDataDir")), + myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir"))); + addOwnAvatar(myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("MyAvatar"))); + myAvatarManager->RemoveOldAvatarCacheEntries(); + return retVal; } void Session::init(boost::shared_ptr manager) { - myAvatarManager = manager; + myAvatarManager = manager; } void Session::addOwnAvatar(const std::string &avatarFile) { - myAvatarManager->AddSingleAvatar(avatarFile); + myAvatarManager->AddSingleAvatar(avatarFile); } -void Session::startLocalGame(const GameData &gameData, const StartData &startData) { +void Session::startLocalGame(const GameData &gameData, const StartData &startData) +{ - myGameType = GAME_TYPE_LOCAL; + myGameType = GAME_TYPE_LOCAL; - currentGame.reset(); - currentGameNum++; + currentGame.reset(); + currentGameNum++; - myGui->initGui(gameData.guiSpeed); + myGui->initGui(gameData.guiSpeed); - PlayerDataList playerDataList; - for(int i = 0; i < startData.numberOfPlayers; i++) { + PlayerDataList playerDataList; + for(int i = 0; i < startData.numberOfPlayers; i++) { - //Namen und Avatarpfad abfragen - ostringstream myName; - if (i==0) { myName << "MyName"; } - else { myName << "Opponent" << i << "Name"; } - ostringstream myAvatar; - if (i==0) { myAvatar << "MyAvatar"; } - else { myAvatar << "Opponent" << i << "Avatar"; } + //Namen und Avatarpfad abfragen + ostringstream myName; + if (i==0) { + myName << "MyName"; + } else { + myName << "Opponent" << i << "Name"; + } + ostringstream myAvatar; + if (i==0) { + myAvatar << "MyAvatar"; + } else { + myAvatar << "Opponent" << i << "Avatar"; + } - //PlayerData erzeugen - // UniqueId = PlayerNumber for local games. - boost::shared_ptr playerData(new PlayerData(i, i, - i == 0 ? PLAYER_TYPE_HUMAN : PLAYER_TYPE_COMPUTER, - PLAYER_RIGHTS_NORMAL, - i == 0)); - playerData->SetName(myConfig->readConfigString(myName.str())); - playerData->SetAvatarFile(myConfig->readConfigString(myAvatar.str())); + //PlayerData erzeugen + // UniqueId = PlayerNumber for local games. + boost::shared_ptr playerData(new PlayerData(i, i, + i == 0 ? PLAYER_TYPE_HUMAN : PLAYER_TYPE_COMPUTER, + PLAYER_RIGHTS_NORMAL, + i == 0)); + playerData->SetName(myConfig->readConfigString(myName.str())); + playerData->SetAvatarFile(myConfig->readConfigString(myAvatar.str())); - playerDataList.push_back(playerData); - } - // EngineFactory erstellen - boost::shared_ptr factory(new LocalEngineFactory(myConfig)); // LocalEngine erstellen + playerDataList.push_back(playerData); + } + // EngineFactory erstellen + boost::shared_ptr factory(new LocalEngineFactory(myConfig)); // LocalEngine erstellen - currentGame.reset(new Game(myGui, factory, playerDataList, gameData, startData, currentGameNum, myLog)); + currentGame.reset(new Game(myGui, factory, playerDataList, gameData, startData, currentGameNum, myLog)); - //// SPIEL-SCHLEIFE - currentGame->initHand(); - currentGame->startHand(); - // SPIEL-SCHLEIFE + //// SPIEL-SCHLEIFE + currentGame->initHand(); + currentGame->startHand(); + // SPIEL-SCHLEIFE } void Session::startClientGame(boost::shared_ptr game) { - currentGameNum++; + currentGameNum++; - currentGame = game; + currentGame = game; } boost::shared_ptr Session::getCurrentGame() @@ -142,116 +149,113 @@ boost::shared_ptr Session::getCurrentGame() GuiInterface *Session::getGui() { - return myGui; + return myGui; } Session::GameType Session::getGameType() { - return myGameType; + return myGameType; } boost::shared_ptr Session::getAvatarManager() { - return myAvatarManager; + return myAvatarManager; } void Session::startInternetClient() { - if (myNetClient || !myGui) - { - assert(false); - return; - } - myGameType = GAME_TYPE_INTERNET; + if (myNetClient || !myGui) { + assert(false); + return; + } + myGameType = GAME_TYPE_INTERNET; - myNetClient.reset(new ClientThread(*myGui, *myAvatarManager)); - bool useAvatarServer = myConfig->readConfigInt("UseAvatarServer") != 0; + myNetClient.reset(new ClientThread(*myGui, *myAvatarManager)); + bool useAvatarServer = myConfig->readConfigInt("UseAvatarServer") != 0; - myNetClient->Init( - myConfig->readConfigString("InternetServerAddress"), - myConfig->readConfigString("InternetServerListAddress"), - myConfig->readConfigInt("InternetServerConfigMode") == 0, - myConfig->readConfigInt("InternetServerPort"), - myConfig->readConfigInt("InternetServerUseIpv6") == 1, - myConfig->readConfigInt("InternetServerUseSctp") == 1, - useAvatarServer ? myConfig->readConfigString("AvatarServerAddress") : "", - myConfig->readConfigString("MyName"), - myConfig->readConfigString("MyAvatar"), - myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir"))); - myNetClient->Run(); + myNetClient->Init( + myConfig->readConfigString("InternetServerAddress"), + myConfig->readConfigString("InternetServerListAddress"), + myConfig->readConfigInt("InternetServerConfigMode") == 0, + myConfig->readConfigInt("InternetServerPort"), + myConfig->readConfigInt("InternetServerUseIpv6") == 1, + myConfig->readConfigInt("InternetServerUseSctp") == 1, + useAvatarServer ? myConfig->readConfigString("AvatarServerAddress") : "", + myConfig->readConfigString("MyName"), + myConfig->readConfigString("MyAvatar"), + myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir"))); + myNetClient->Run(); } void Session::startNetworkClient(const string &serverAddress, unsigned serverPort, bool ipv6, bool sctp) { - if (myNetClient || !myGui) - { - assert(false); - return; - } - myGameType = GAME_TYPE_NETWORK; + if (myNetClient || !myGui) { + assert(false); + return; + } + myGameType = GAME_TYPE_NETWORK; - myNetClient.reset(new ClientThread(*myGui, *myAvatarManager)); - myNetClient->Init( - serverAddress, - "", - false, - serverPort, - ipv6, - sctp, - "", // no avatar server - myConfig->readConfigString("MyName"), - myConfig->readConfigString("MyAvatar"), - myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir"))); - myNetClient->Run(); + myNetClient.reset(new ClientThread(*myGui, *myAvatarManager)); + myNetClient->Init( + serverAddress, + "", + false, + serverPort, + ipv6, + sctp, + "", // no avatar server + myConfig->readConfigString("MyName"), + myConfig->readConfigString("MyAvatar"), + myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir"))); + myNetClient->Run(); myNetClient->SendJoinFirstGame( - "", - myConfig->readConfigInt("NetAutoLeaveGameAfterFinish") == 1 + "", + myConfig->readConfigInt("NetAutoLeaveGameAfterFinish") == 1 ); } void Session::startNetworkClientForLocalServer(const GameData &gameData) { - if (myNetClient || !myGui) - { - assert(false); - return; - } - myGameType = GAME_TYPE_NETWORK; + if (myNetClient || !myGui) { + assert(false); + return; + } + myGameType = GAME_TYPE_NETWORK; - myNetClient.reset(new ClientThread(*myGui, *myAvatarManager)); - bool useIpv6 = myConfig->readConfigInt("ServerUseIpv6") == 1; - const char *loopbackAddr = useIpv6 ? "::1" : "127.0.0.1"; - myNetClient->Init( - loopbackAddr, - "", - false, - myConfig->readConfigInt("ServerPort"), - useIpv6, - myConfig->readConfigInt("ServerUseSctp") == 1, - "", // no avatar server - myConfig->readConfigString("MyName"), - myConfig->readConfigString("MyAvatar"), - myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir"))); - myNetClient->Run(); + myNetClient.reset(new ClientThread(*myGui, *myAvatarManager)); + bool useIpv6 = myConfig->readConfigInt("ServerUseIpv6") == 1; + const char *loopbackAddr = useIpv6 ? "::1" : "127.0.0.1"; + myNetClient->Init( + loopbackAddr, + "", + false, + myConfig->readConfigInt("ServerPort"), + useIpv6, + myConfig->readConfigInt("ServerUseSctp") == 1, + "", // no avatar server + myConfig->readConfigString("MyName"), + myConfig->readConfigString("MyAvatar"), + myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir"))); + myNetClient->Run(); myNetClient->SendCreateGame( - gameData, - NET_DEFAULT_GAME, - "", - myConfig->readConfigInt("NetAutoLeaveGameAfterFinish") == 1 + gameData, + NET_DEFAULT_GAME, + "", + myConfig->readConfigInt("NetAutoLeaveGameAfterFinish") == 1 ); } void Session::terminateNetworkClient() { - if (!myNetClient) - return; // already terminated - myNetClient->SignalTermination(); - // Give the threads some time to terminate. - if (myNetClient->Join(NET_CLIENT_TERMINATE_TIMEOUT_MSEC)) - myNetClient.reset(); + if (!myNetClient) + return; // already terminated + myNetClient->SignalTermination(); + // Give the threads some time to terminate. + if (myNetClient->Join(NET_CLIENT_TERMINATE_TIMEOUT_MSEC)) + myNetClient.reset(); - // If termination fails, leave a memory leak to prevent a crash. - myGameType = GAME_TYPE_NONE; + // If termination fails, leave a memory leak to prevent a crash. + myGameType = GAME_TYPE_NONE; } void Session::clientCreateGame(const GameData &gameData, const string &name, const string &password) @@ -259,10 +263,10 @@ void Session::clientCreateGame(const GameData &gameData, const string &name, con if (!myNetClient) return; // only act if client is running. myNetClient->SendCreateGame( - gameData, - name, - password, - myConfig->readConfigInt("NetAutoLeaveGameAfterFinish") == 1 + gameData, + name, + password, + myConfig->readConfigInt("NetAutoLeaveGameAfterFinish") == 1 ); } @@ -271,133 +275,127 @@ void Session::clientJoinGame(unsigned gameId, const std::string &password) if (!myNetClient) return; // only act if client is running. myNetClient->SendJoinGame( - gameId, - password, - myConfig->readConfigInt("NetAutoLeaveGameAfterFinish") == 1 + gameId, + password, + myConfig->readConfigInt("NetAutoLeaveGameAfterFinish") == 1 ); } void Session::startNetworkServer(bool dedicated) { - if (myNetServer) - { - assert(false); - return; - } + if (myNetServer) { + assert(false); + return; + } myNetServer.reset(new ServerManager(*myGui, *myConfig, *myAvatarManager)); - boost::shared_ptr tmpIrcAdminThread; - boost::shared_ptr tmpIrcLobbyThread; - if (myConfig->readConfigInt("UseAdminIRC")) - { - tmpIrcAdminThread = boost::shared_ptr(new IrcThread(&myNetServer->GetAdminBot())); + boost::shared_ptr tmpIrcAdminThread; + boost::shared_ptr tmpIrcLobbyThread; + if (myConfig->readConfigInt("UseAdminIRC")) { + tmpIrcAdminThread = boost::shared_ptr(new IrcThread(&myNetServer->GetAdminBot())); - tmpIrcAdminThread->Init( - myConfig->readConfigString("AdminIRCServerAddress"), - myConfig->readConfigInt("AdminIRCServerPort"), - myConfig->readConfigInt("AdminIRCServerUseIpv6") == 1, - myConfig->readConfigString("AdminIRCServerNick"), - myConfig->readConfigString("AdminIRCChannel"), - myConfig->readConfigString("AdminIRCChannelPassword")); - } + tmpIrcAdminThread->Init( + myConfig->readConfigString("AdminIRCServerAddress"), + myConfig->readConfigInt("AdminIRCServerPort"), + myConfig->readConfigInt("AdminIRCServerUseIpv6") == 1, + myConfig->readConfigString("AdminIRCServerNick"), + myConfig->readConfigString("AdminIRCChannel"), + myConfig->readConfigString("AdminIRCChannelPassword")); + } - if (myConfig->readConfigInt("UseLobbyIRC")) - { - tmpIrcLobbyThread = boost::shared_ptr(new IrcThread(&myNetServer->GetLobbyBot())); + if (myConfig->readConfigInt("UseLobbyIRC")) { + tmpIrcLobbyThread = boost::shared_ptr(new IrcThread(&myNetServer->GetLobbyBot())); - tmpIrcLobbyThread->Init( - myConfig->readConfigString("LobbyIRCServerAddress"), - myConfig->readConfigInt("LobbyIRCServerPort"), - myConfig->readConfigInt("LobbyIRCServerUseIpv6") == 1, - myConfig->readConfigString("LobbyIRCServerNick"), - myConfig->readConfigString("LobbyIRCChannel"), - myConfig->readConfigString("LobbyIRCChannelPassword")); - } + tmpIrcLobbyThread->Init( + myConfig->readConfigString("LobbyIRCServerAddress"), + myConfig->readConfigInt("LobbyIRCServerPort"), + myConfig->readConfigInt("LobbyIRCServerUseIpv6") == 1, + myConfig->readConfigString("LobbyIRCServerNick"), + myConfig->readConfigString("LobbyIRCChannel"), + myConfig->readConfigString("LobbyIRCChannelPassword")); + } - ServerMode mode; - if (dedicated) - { + ServerMode mode; + if (dedicated) { #ifdef POKERTH_OFFICIAL_SERVER - mode = SERVER_MODE_INTERNET_AUTH; + mode = SERVER_MODE_INTERNET_AUTH; #else - mode = SERVER_MODE_INTERNET_NOAUTH; + mode = SERVER_MODE_INTERNET_NOAUTH; #endif - } - else - mode = SERVER_MODE_LAN; + } else + mode = SERVER_MODE_LAN; - myNetServer->Init( - myConfig->readConfigInt("ServerPort"), - myConfig->readConfigInt("ServerUseIpv6") == 1, - myConfig->readConfigInt("ServerUseSctp") == 1 ? TRANSPORT_PROTOCOL_TCP_SCTP : TRANSPORT_PROTOCOL_TCP, - mode, - myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("LogDir")), - tmpIrcAdminThread, - tmpIrcLobbyThread - ); + myNetServer->Init( + myConfig->readConfigInt("ServerPort"), + myConfig->readConfigInt("ServerUseIpv6") == 1, + myConfig->readConfigInt("ServerUseSctp") == 1 ? TRANSPORT_PROTOCOL_TCP_SCTP : TRANSPORT_PROTOCOL_TCP, + mode, + myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("LogDir")), + tmpIrcAdminThread, + tmpIrcLobbyThread + ); - myNetServer->RunAll(); + myNetServer->RunAll(); } void Session::terminateNetworkServer() { - if (!myNetServer) - return; // already terminated - myNetServer->SignalTerminationAll(); - // Give the thread some time to terminate. - if (myNetServer->JoinAll(true)) - myNetServer.reset(); - // If termination fails, leave a memory leak to prevent a crash. + if (!myNetServer) + return; // already terminated + myNetServer->SignalTerminationAll(); + // Give the thread some time to terminate. + if (myNetServer->JoinAll(true)) + myNetServer.reset(); + // If termination fails, leave a memory leak to prevent a crash. } bool Session::pollNetworkServerTerminated() { - bool retVal = false; - if (!myNetServer) - retVal = true; // already terminated - else - { - myNetServer->Process(); - if (myNetServer->JoinAll(false)) - retVal = true; - } - return retVal; + bool retVal = false; + if (!myNetServer) + retVal = true; // already terminated + else { + myNetServer->Process(); + if (myNetServer->JoinAll(false)) + retVal = true; + } + return retVal; } void Session::sendLeaveCurrentGame() { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendLeaveCurrentGame(); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendLeaveCurrentGame(); } void Session::sendStartEvent(bool fillUpWithCpuPlayers) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendStartEvent(fillUpWithCpuPlayers); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendStartEvent(fillUpWithCpuPlayers); } void Session::sendClientPlayerAction() { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendPlayerAction(); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendPlayerAction(); } void Session::sendGameChatMessage(const std::string &message) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendGameChatMessage(message); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendGameChatMessage(message); } void Session::sendLobbyChatMessage(const std::string &message) { - if (!myNetClient) - return; - myNetClient->SendLobbyChatMessage(message); + if (!myNetClient) + return; + myNetClient->SendLobbyChatMessage(message); } void Session::sendPrivateChatMessage(unsigned targetPlayerId, const std::string &message) @@ -410,75 +408,75 @@ void Session::sendPrivateChatMessage(unsigned targetPlayerId, const std::string void Session::kickPlayer(unsigned playerId) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendKickPlayer(playerId); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendKickPlayer(playerId); } void Session::resetNetworkTimeout() { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendResetTimeout(); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendResetTimeout(); } void Session::kickPlayer(const string &playerName) { - if (!myNetClient) - return; // only act if client is running. - unsigned playerId; - if (myNetClient->GetPlayerIdFromName(playerName, playerId)) - kickPlayer(playerId); + if (!myNetClient) + return; // only act if client is running. + unsigned playerId; + if (myNetClient->GetPlayerIdFromName(playerName, playerId)) + kickPlayer(playerId); } void Session::startVoteKickPlayer(unsigned playerId) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendAskKickPlayer(playerId); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendAskKickPlayer(playerId); } void Session::selectServer(unsigned serverId) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SelectServer(serverId); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SelectServer(serverId); } void Session::setLogin(const std::string &userName, const std::string &password, bool isGuest) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SetLogin(userName, password, isGuest); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SetLogin(userName, password, isGuest); } void Session::invitePlayerToCurrentGame(unsigned playerId) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendInvitePlayerToCurrentGame(playerId); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendInvitePlayerToCurrentGame(playerId); } void Session::acceptGameInvitation(unsigned gameId) { - if (!myNetClient) - return; // only act if client is running. + if (!myNetClient) + return; // only act if client is running. myNetClient->SendJoinGame( - gameId, - "", - myConfig->readConfigInt("NetAutoLeaveGameAfterFinish") == 1 + gameId, + "", + myConfig->readConfigInt("NetAutoLeaveGameAfterFinish") == 1 ); } void Session::rejectGameInvitation(unsigned gameId, DenyGameInvitationReason reason) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendRejectGameInvitation(gameId, reason); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendRejectGameInvitation(gameId, reason); } void Session::reportBadAvatar(unsigned reportedPlayerId, const std::string &avatarHash) @@ -490,52 +488,52 @@ void Session::reportBadAvatar(unsigned reportedPlayerId, const std::string &avat void Session::voteKick(bool doKick) { - if (!myNetClient) - return; // only act if client is running. - myNetClient->SendVoteKick(doKick); + if (!myNetClient) + return; // only act if client is running. + myNetClient->SendVoteKick(doKick); } void Session::showMyCards() { if (!myNetClient) - return; // only act if client is running. + return; // only act if client is running. myNetClient->SendShowMyCards(); } bool Session::isNetworkClientRunning() const { - // This, and every place which calls this, is a HACK. - return myNetClient.get() != NULL; + // This, and every place which calls this, is a HACK. + return myNetClient.get() != NULL; } bool Session::isNetworkServerRunning() const { - // This, and every place which calls this, is a HACK. - return myNetServer.get() != NULL; + // This, and every place which calls this, is a HACK. + return myNetServer.get() != NULL; } ServerInfo Session::getClientServerInfo(unsigned serverId) const { - ServerInfo info; - if (myNetClient) - info = myNetClient->GetServerInfo(serverId); - return info; + ServerInfo info; + if (myNetClient) + info = myNetClient->GetServerInfo(serverId); + return info; } GameInfo Session::getClientGameInfo(unsigned playerId) const { - GameInfo info; - if (myNetClient) - info = myNetClient->GetGameInfo(playerId); - return info; + GameInfo info; + if (myNetClient) + info = myNetClient->GetGameInfo(playerId); + return info; } PlayerInfo Session::getClientPlayerInfo(unsigned playerId) const { - PlayerInfo info; - if (myNetClient) - info = myNetClient->GetPlayerInfo(playerId); - return info; + PlayerInfo info; + if (myNetClient) + info = myNetClient->GetPlayerInfo(playerId); + return info; } unsigned Session::getGameIdOfPlayer(unsigned playerId) const @@ -548,38 +546,37 @@ unsigned Session::getGameIdOfPlayer(unsigned playerId) const ServerStats Session::getClientStats() const { - ServerStats stats; - if (myNetClient) - stats = myNetClient->GetStatData(); - return stats; + ServerStats stats; + if (myNetClient) + stats = myNetClient->GetStatData(); + return stats; } unsigned Session::getClientCurrentGameId() const { - unsigned id = 0; - if (myNetClient) - id = myNetClient->GetGameId(); - return id; + unsigned id = 0; + if (myNetClient) + id = myNetClient->GetGameId(); + return id; } unsigned Session::getClientUniquePlayerId() const { - unsigned id = 0; - if (myNetClient) - id = myNetClient->GetGuiPlayerId(); - return id; + unsigned id = 0; + if (myNetClient) + id = myNetClient->GetGuiPlayerId(); + return id; } bool Session::getAvatarFile(const MD5Buf &avatarMD5, std::string &fileName) { - bool retVal = false; - if (myAvatarManager.get()) - { - string tmpFileName; - retVal = myAvatarManager->GetAvatarFileName(avatarMD5, tmpFileName); - if (retVal) - fileName = myQtToolsInterface->stringToUtf8(tmpFileName); - } - return retVal; + bool retVal = false; + if (myAvatarManager.get()) { + string tmpFileName; + retVal = myAvatarManager->GetAvatarFileName(avatarMD5, tmpFileName); + if (retVal) + fileName = myQtToolsInterface->stringToUtf8(tmpFileName); + } + return retVal; } diff --git a/src/session.h b/src/session.h index 52007c59..2b1efd93 100755 --- a/src/session.h +++ b/src/session.h @@ -40,96 +40,99 @@ class IrcThread; class AvatarManager; class QtToolsInterface; -class Session{ +class Session +{ public: - Session(GuiInterface*, ConfigFile*); + Session(GuiInterface*, ConfigFile*); - ~Session(); + ~Session(); - enum GameType { GAME_TYPE_NONE, GAME_TYPE_LOCAL, GAME_TYPE_NETWORK, GAME_TYPE_INTERNET }; + enum GameType { GAME_TYPE_NONE, GAME_TYPE_LOCAL, GAME_TYPE_NETWORK, GAME_TYPE_INTERNET }; - // Only one of the two inits should be called. - bool init(); - void init(boost::shared_ptr manager); + // Only one of the two inits should be called. + bool init(); + void init(boost::shared_ptr manager); - void addOwnAvatar(const std::string &avatarFile); + void addOwnAvatar(const std::string &avatarFile); - void startLocalGame(const GameData &gameData, const StartData &startData); - void startClientGame(boost::shared_ptr game); + void startLocalGame(const GameData &gameData, const StartData &startData); + void startClientGame(boost::shared_ptr game); boost::shared_ptr getCurrentGame(); - GuiInterface *getGui(); - Log* getMyLog() {return myLog; } - GameType getGameType(); + GuiInterface *getGui(); + Log* getMyLog() { + return myLog; + } + GameType getGameType(); - boost::shared_ptr getAvatarManager(); + boost::shared_ptr getAvatarManager(); - void startInternetClient(); - void startNetworkClient(const std::string &serverAddress, unsigned serverPort, bool ipv6, bool sctp); - void startNetworkClientForLocalServer(const GameData &gameData); - void terminateNetworkClient(); - void clientCreateGame(const GameData &gameData, const std::string &name, const std::string &password); - void clientJoinGame(unsigned gameId, const std::string &password); + void startInternetClient(); + void startNetworkClient(const std::string &serverAddress, unsigned serverPort, bool ipv6, bool sctp); + void startNetworkClientForLocalServer(const GameData &gameData); + void terminateNetworkClient(); + void clientCreateGame(const GameData &gameData, const std::string &name, const std::string &password); + void clientJoinGame(unsigned gameId, const std::string &password); - void startNetworkServer(bool dedicated); - void sendLeaveCurrentGame(); - void sendStartEvent(bool fillUpWithCpuPlayers); - void terminateNetworkServer(); - bool pollNetworkServerTerminated(); + void startNetworkServer(bool dedicated); + void sendLeaveCurrentGame(); + void sendStartEvent(bool fillUpWithCpuPlayers); + void terminateNetworkServer(); + bool pollNetworkServerTerminated(); - void sendClientPlayerAction(); + void sendClientPlayerAction(); - void sendGameChatMessage(const std::string &message); - void sendLobbyChatMessage(const std::string &message); + void sendGameChatMessage(const std::string &message); + void sendLobbyChatMessage(const std::string &message); void sendPrivateChatMessage(unsigned targetPlayerId, const std::string &message); - void kickPlayer(unsigned playerId); - void kickPlayer(const std::string &playerName); - void startVoteKickPlayer(unsigned playerId); - void voteKick(bool doKick); - void showMyCards(); - void selectServer(unsigned serverId); - void setLogin(const std::string &userName, const std::string &password, bool isGuest); + void kickPlayer(unsigned playerId); + void kickPlayer(const std::string &playerName); + void startVoteKickPlayer(unsigned playerId); + void voteKick(bool doKick); + void showMyCards(); + void selectServer(unsigned serverId); + void setLogin(const std::string &userName, const std::string &password, bool isGuest); - void invitePlayerToCurrentGame(unsigned playerId); - void acceptGameInvitation(unsigned gameId); - void rejectGameInvitation(unsigned gameId, DenyGameInvitationReason reason); + void invitePlayerToCurrentGame(unsigned playerId); + void acceptGameInvitation(unsigned gameId); + void rejectGameInvitation(unsigned gameId, DenyGameInvitationReason reason); void reportBadAvatar(unsigned reportedPlayerId, const std::string &avatarHash); - void resetNetworkTimeout(); + void resetNetworkTimeout(); - bool isNetworkClientRunning() const; // TODO hack - bool isNetworkServerRunning() const; // TODO hack + bool isNetworkClientRunning() const; // TODO hack + bool isNetworkServerRunning() const; // TODO hack - ServerInfo getClientServerInfo(unsigned serverId) const; - GameInfo getClientGameInfo(unsigned gameId) const; - PlayerInfo getClientPlayerInfo(unsigned playerId) const; + ServerInfo getClientServerInfo(unsigned serverId) const; + GameInfo getClientGameInfo(unsigned gameId) const; + PlayerInfo getClientPlayerInfo(unsigned playerId) const; unsigned getGameIdOfPlayer(unsigned playerId) const; - ServerStats getClientStats() const; - unsigned getClientCurrentGameId() const; - unsigned getClientUniquePlayerId() const; + ServerStats getClientStats() const; + unsigned getClientCurrentGameId() const; + unsigned getClientUniquePlayerId() const; - bool getAvatarFile(const MD5Buf &avatarMD5, std::string &fileName); + bool getAvatarFile(const MD5Buf &avatarMD5, std::string &fileName); private: - int currentGameNum; + int currentGameNum; - std::string myIrcNick; + std::string myIrcNick; - boost::shared_ptr myNetClient; - boost::shared_ptr myNetServer; + boost::shared_ptr myNetClient; + boost::shared_ptr myNetServer; - boost::shared_ptr myAvatarManager; + boost::shared_ptr myAvatarManager; - boost::shared_ptr currentGame; - GuiInterface *myGui; - ConfigFile *myConfig; - Log *myLog; - GameType myGameType; - QtToolsInterface *myQtToolsInterface; + boost::shared_ptr currentGame; + GuiInterface *myGui; + ConfigFile *myConfig; + Log *myLog; + GameType myGameType; + QtToolsInterface *myQtToolsInterface; }; #endif diff --git a/src/zlib_compress.cpp b/src/zlib_compress.cpp index aebbf1e2..6ddb7a0c 100644 --- a/src/zlib_compress.cpp +++ b/src/zlib_compress.cpp @@ -33,8 +33,7 @@ using namespace boost::filesystem; int main(int argc, char *argv[]) { - if (argc != 2) - { + if (argc != 2) { cout << "Usage: zlib_compress " << endl; return 1; } @@ -43,8 +42,7 @@ main(int argc, char *argv[]) path outputFilePath(inputFilePath); outputFilePath = change_extension(outputFilePath, extension(outputFilePath) + ".z"); // Check whether file exists. - if (!exists(inputFilePath)) - { + if (!exists(inputFilePath)) { cerr << "Input file does not exist." << endl; return 2; } @@ -56,8 +54,7 @@ main(int argc, char *argv[]) out.push(outFile); boost::iostreams::copy(inFile, out); cout << "Compression of \"" << inputFilePath.directory_string() << "\" to \"" << outputFilePath.directory_string() << "\" was successful." << endl; - } catch (...) - { + } catch (...) { cerr << "Compression failed." << endl; return 3; }