Reformatting code using Kernighan & Ritchie style, tabs, tab width=4.
Command line: astyle --style=kr --indent=force-tab=4 --lineend=linux -n -r <file names>
This commit is contained in:
1 parent
29dca1846e
commit
02518c67b2
232 files changed
+22743
-21044
No files matched your search
@@ -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()))
|
||||
|
||||
@@ -3,17 +3,20 @@
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
#include <QtCore>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -3,14 +3,17 @@
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
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;
|
||||
|
||||
@@ -2,21 +2,21 @@
|
||||
#include "cleanerserver.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <process.h>
|
||||
#include <process.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#ifndef daemon
|
||||
int daemon(int, int);
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#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();
|
||||
}
|
||||
+158
-148
@@ -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<string> 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<string> 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; i<configBufferList.size(); i++) {
|
||||
|
||||
|
||||
TiXmlElement* conf = docHandle.FirstChild( "PokerTHCleaner" ).FirstChild( "Configuration" ).FirstChild( configList[i].name ).ToElement();
|
||||
|
||||
|
||||
if ( conf ) {
|
||||
|
||||
const char *tmpStr1 = conf->Attribute("value");
|
||||
@@ -233,38 +233,40 @@ void CleanerConfig::fillBuffer() {
|
||||
|
||||
const char *tmpStr2 = conf->Attribute("type");
|
||||
if (tmpStr2) {
|
||||
tempString2 = tmpStr2;
|
||||
tempString2 = tmpStr2;
|
||||
if(tempString2 == "list") {
|
||||
|
||||
|
||||
list<string> 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<string> tempList = configBufferList[i].defaultListValue;
|
||||
list<string>::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<configList.size(); i++) {
|
||||
TiXmlElement *tmpElement = new TiXmlElement(configList[i].name);
|
||||
@@ -320,7 +323,7 @@ void CleanerConfig::updateConfig(ConfigState myConfigState) {
|
||||
list<string> tempList = configList[i].defaultListValue;
|
||||
list<string>::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<configList.size(); i++) {
|
||||
for (i=0; i<configList.size(); i++) {
|
||||
|
||||
TiXmlElement* oldConf = oldDocHandle.FirstChild( "PokerTHCleaner" ).FirstChild( "Configuration" ).FirstChild( configList[i].name ).ToElement();
|
||||
|
||||
|
||||
if ( oldConf ) {
|
||||
// if element is already there --> 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<string> 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<string> tempList = tempStringList2;
|
||||
list<string>::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<string> tempList = configList[i].defaultListValue;
|
||||
list<string>::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<configBufferList.size(); i++) {
|
||||
for (i=0; i<configBufferList.size(); i++) {
|
||||
|
||||
if (configBufferList[i].name == varName) {
|
||||
tempString = configBufferList[i].defaultValue;
|
||||
tempString = configBufferList[i].defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
return tempString;
|
||||
}
|
||||
}
|
||||
|
||||
int CleanerConfig::readConfigInt(string varName) const
|
||||
{
|
||||
@@ -458,35 +461,35 @@ int CleanerConfig::readConfigInt(string varName) const
|
||||
string tempString("");
|
||||
int tempInt=0;
|
||||
|
||||
for (i=0; i<configBufferList.size(); i++) {
|
||||
for (i=0; i<configBufferList.size(); i++) {
|
||||
|
||||
if (configBufferList[i].name == varName) {
|
||||
tempString = configBufferList[i].defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
istringstream isst;
|
||||
isst.str (tempString);
|
||||
isst >> tempInt;
|
||||
|
||||
|
||||
return tempInt;
|
||||
}
|
||||
|
||||
list<string> CleanerConfig::readConfigStringList(string varName) const
|
||||
{
|
||||
|
||||
size_t i;
|
||||
size_t i;
|
||||
list<string> tempStringList;
|
||||
|
||||
for (i=0; i<configBufferList.size(); i++) {
|
||||
for (i=0; i<configBufferList.size(); i++) {
|
||||
|
||||
if (configBufferList[i].name == varName) {
|
||||
tempStringList = configBufferList[i].defaultListValue;
|
||||
tempStringList = configBufferList[i].defaultListValue;
|
||||
}
|
||||
}
|
||||
|
||||
return tempStringList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
list<int> CleanerConfig::readConfigIntList(string varName) const
|
||||
@@ -496,19 +499,19 @@ list<int> CleanerConfig::readConfigIntList(string varName) const
|
||||
list<string> tempStringList;
|
||||
list<int> tempIntList;
|
||||
|
||||
for (i=0; i<configBufferList.size(); i++) {
|
||||
for (i=0; i<configBufferList.size(); i++) {
|
||||
|
||||
if (configBufferList[i].name == varName) {
|
||||
tempStringList = configBufferList[i].defaultListValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
istringstream isst;
|
||||
string tempString;
|
||||
int tempInt;
|
||||
list<string>::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<configBufferList.size(); i++) {
|
||||
for (i=0; i<configBufferList.size(); i++) {
|
||||
|
||||
if (configBufferList[i].name == varName) {
|
||||
intToString << varCont;
|
||||
configBufferList[i].defaultValue = intToString.str();
|
||||
configBufferList[i].defaultValue = intToString.str();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -544,20 +547,20 @@ void CleanerConfig::writeConfigIntList(string varName, list<int> varCont)
|
||||
ostringstream intToString;
|
||||
list<string> stringList;
|
||||
|
||||
for (i=0; i<configBufferList.size(); i++) {
|
||||
for (i=0; i<configBufferList.size(); i++) {
|
||||
|
||||
if (configBufferList[i].name == varName) {
|
||||
string tempString;
|
||||
list<int>::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<string> varCont)
|
||||
size_t i;
|
||||
list<string> stringList;
|
||||
|
||||
for (i=0; i<configBufferList.size(); i++) {
|
||||
for (i=0; i<configBufferList.size(); i++) {
|
||||
|
||||
if (configBufferList[i].name == varName) {
|
||||
|
||||
configBufferList[i].defaultListValue = varCont;
|
||||
|
||||
configBufferList[i].defaultListValue = varCont;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -581,23 +584,30 @@ void CleanerConfig::writeConfigString(string varName, string varCont)
|
||||
{
|
||||
|
||||
size_t i;
|
||||
for (i=0; i<configBufferList.size(); i++) {
|
||||
if (configBufferList[i].name == varName) { configBufferList[i].defaultValue = varCont; }
|
||||
for (i=0; i<configBufferList.size(); i++) {
|
||||
if (configBufferList[i].name == varName) {
|
||||
configBufferList[i].defaultValue = varCont;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
std::string CleanerConfig::stringToUtf8(const std::string &myString) {
|
||||
std::string CleanerConfig::stringToUtf8(const std::string &myString)
|
||||
{
|
||||
|
||||
QString tmpString = QString::fromStdString(myString);
|
||||
std::string myUtf8String = tmpString.toUtf8().constData();
|
||||
|
||||
|
||||
return myUtf8String;
|
||||
}
|
||||
|
||||
std::string CleanerConfig::stringFromUtf8(const std::string &myString) {
|
||||
std::string CleanerConfig::stringFromUtf8(const std::string &myString)
|
||||
{
|
||||
QString tmpString = QString::fromUtf8(myString.c_str());
|
||||
|
||||
|
||||
return tmpString.toStdString();
|
||||
}
|
||||
|
||||
std::string CleanerConfig::getDefaultLanguage() { return QLocale::system().name().toStdString(); }
|
||||
std::string CleanerConfig::getDefaultLanguage()
|
||||
{
|
||||
return QLocale::system().name().toStdString();
|
||||
}
|
||||
@@ -28,14 +28,17 @@ enum ConfigState { NONEXISTING, OLD };
|
||||
enum ConfigType { CONFIG_TYPE_INT, CONFIG_TYPE_STRING, CONFIG_TYPE_INT_LIST, CONFIG_TYPE_STRING_LIST };
|
||||
|
||||
|
||||
class CleanerConfig{
|
||||
class CleanerConfig
|
||||
{
|
||||
public:
|
||||
CleanerConfig();
|
||||
|
||||
~CleanerConfig();
|
||||
|
||||
std::string getConfigFileName() const { return configFileName; }
|
||||
|
||||
|
||||
std::string getConfigFileName() const {
|
||||
return configFileName;
|
||||
}
|
||||
|
||||
void fillBuffer();
|
||||
void writeBuffer() const;
|
||||
|
||||
@@ -45,7 +48,7 @@ public:
|
||||
std::string readConfigString(std::string varName) const;
|
||||
std::list<int> readConfigIntList(std::string varName) const;
|
||||
std::list<std::string> 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<int> 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<std::string> &l =std::list<std::string>()) : name(n), type(t), defaultValue(d), defaultListValue(l) {}
|
||||
std::string name;
|
||||
ConfigType type;
|
||||
std::string defaultValue;
|
||||
std::list<std::string> defaultListValue;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
std::vector<ConfigInfo> configList;
|
||||
std::vector<ConfigInfo> configBufferList;
|
||||
|
||||
|
||||
@@ -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()));
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -3,23 +3,21 @@
|
||||
#include <QtCore>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -3,14 +3,17 @@
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
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;
|
||||
|
||||
+155
-159
@@ -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<unsigned, ClientWarnInfos>::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<QString, ClientKickInfos>::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<QString, ClientKickInfos>::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<std::string> badWordsList = config->readConfigStringList("BadWordsList");
|
||||
std::list<std::string>::iterator it1;
|
||||
QStringList bwList;
|
||||
// special check settings
|
||||
//Bad Words
|
||||
std::list<std::string> badWordsList = config->readConfigStringList("BadWordsList");
|
||||
std::list<std::string>::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<std::string> urlStringsList = config->readConfigStringList("UrlStringsList");
|
||||
std::list<std::string>::iterator it2;
|
||||
QStringList urlList;
|
||||
std::list<std::string> urlStringsList = config->readConfigStringList("UrlStringsList");
|
||||
std::list<std::string>::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<std::string> urlExceptionStringsList = config->readConfigStringList("UrlExceptionStringsList");
|
||||
std::list<std::string>::iterator it3;
|
||||
QStringList urlExceptionList;
|
||||
std::list<std::string> urlExceptionStringsList = config->readConfigStringList("UrlExceptionStringsList");
|
||||
std::list<std::string>::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<QString, ClientKickInfos> it(myClientKickCounterList);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if(timer.elapsed().total_seconds()-it.value().lastKickTimestamp > static_cast<unsigned>(config->readConfigInt("SecondsToForgetAboutKick"))) {
|
||||
QMapIterator<QString, ClientKickInfos> it(myClientKickCounterList);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if(timer.elapsed().total_seconds()-it.value().lastKickTimestamp > static_cast<unsigned>(config->readConfigInt("SecondsToForgetAboutKick"))) {
|
||||
// qDebug() << it.key() << "removed from kick counter list" << endl;
|
||||
myClientKickCounterList.remove(it.key());
|
||||
}
|
||||
}
|
||||
myClientKickCounterList.remove(it.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<unsigned, ClientWarnInfos> myClientWarnLevelList;
|
||||
QMap<QString, ClientKickInfos> myClientKickCounterList;
|
||||
QMap<unsigned, ClientWarnInfos> myClientWarnLevelList;
|
||||
QMap<QString, ClientKickInfos> 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
|
||||
@@ -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<unsigned, TextFloodInfos> 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<unsigned, TextFloodInfos>::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<unsigned, TextFloodInfos> 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);
|
||||
}
|
||||
@@ -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<unsigned, TextFloodInfos> msgTimesList;
|
||||
|
||||
|
||||
int textFloodLevelToTrigger;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -3,15 +3,20 @@
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
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;
|
||||
|
||||
+514
-507
File diff suppressed because it is too large.
Load diff
+10
-8
@@ -30,17 +30,20 @@ enum ConfigType { CONFIG_TYPE_INT, CONFIG_TYPE_STRING, CONFIG_TYPE_INT_LIST, CON
|
||||
|
||||
class QtToolsInterface;
|
||||
|
||||
class ConfigFile{
|
||||
class ConfigFile
|
||||
{
|
||||
public:
|
||||
ConfigFile(char *argv0, bool readonly);
|
||||
|
||||
~ConfigFile();
|
||||
|
||||
|
||||
void fillBuffer();
|
||||
void writeBuffer() const;
|
||||
|
||||
void updateConfig(ConfigState);
|
||||
ConfigState getConfigState() const { return myConfigState; }
|
||||
ConfigState getConfigState() const {
|
||||
return myConfigState;
|
||||
}
|
||||
|
||||
std::string readConfigString(std::string varName) const;
|
||||
std::list<std::string> readConfigStringList(std::string varName) const;
|
||||
@@ -50,22 +53,21 @@ public:
|
||||
std::list<int> readConfigIntList(std::string varName) const;
|
||||
void writeConfigInt(std::string varName, int varCont);
|
||||
void writeConfigIntList(std::string varName, std::list<int> 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<std::string> &l =std::list<std::string>()) : name(n), type(t), defaultValue(d), defaultListValue(l) {}
|
||||
std::string name;
|
||||
ConfigType type;
|
||||
std::string defaultValue;
|
||||
std::list<std::string> defaultListValue;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
std::vector<ConfigInfo> configList;
|
||||
std::vector<ConfigInfo> configBufferList;
|
||||
|
||||
|
||||
+49
-95
@@ -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<string>(), "PokerTH server name")
|
||||
("port,P", po::value<string>(), "PokerTH server port")
|
||||
("mode,m", po::value<int>(), "set mode (0=connection test, 1=lag test)")
|
||||
("username,u", po::value<string>(), "user name used for test")
|
||||
("password,p", po::value<string>(), "password used for test")
|
||||
;
|
||||
("help,h", "produce help message")
|
||||
("server,s", po::value<string>(), "PokerTH server name")
|
||||
("port,P", po::value<string>(), "PokerTH server port")
|
||||
("mode,m", po::value<int>(), "set mode (0=connection test, 1=lag test)")
|
||||
("username,u", po::value<string>(), "user name used for test")
|
||||
("password,p", po::value<string>(), "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<int>();
|
||||
string username(vm["username"].as<string>());
|
||||
string password;
|
||||
if (vm.count("password"))
|
||||
{
|
||||
if (vm.count("password")) {
|
||||
password = vm["password"].as<string>();
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<AvatarFileState> 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<AvatarFileState> retVal;
|
||||
try
|
||||
{
|
||||
try {
|
||||
outFileType = GetAvatarFileType(fileName);
|
||||
boost::shared_ptr<AvatarFileState> 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<AvatarFileState> 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<AvatarFileState> 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<NetPacket> 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<unsigned char> 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<NetPacket> 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<NetPacket> 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;
|
||||
}
|
||||
|
||||
@@ -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<unsigned>(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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
#define HAVE_ICONV_CONST
|
||||
#define HAVE_ICONV_CONST
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
@@ -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)
|
||||
|
||||
+28
-28
@@ -25,28 +25,28 @@
|
||||
#define HAVE_SSIZE_T
|
||||
#include <sys/types.h>
|
||||
#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 <openssl/ssl.h>
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/hmac.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/hmac.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/evp.h>
|
||||
#else
|
||||
// For all other systems, we use GnuTLS.
|
||||
#include <gnutls/openssl.h>
|
||||
#include <gcrypt.h>
|
||||
#define PKTH_USE_GNUTLS
|
||||
// For all other systems, we use GnuTLS.
|
||||
#include <gnutls/openssl.h>
|
||||
#include <gcrypt.h>
|
||||
#define PKTH_USE_GNUTLS
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -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();
|
||||
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ private:
|
||||
|
||||
mutable boost::shared_ptr<boost::barrier> m_threadStartBarrier;
|
||||
|
||||
friend class ThreadStarter;
|
||||
friend class ThreadStarter;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -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;
|
||||
|
||||
@@ -24,7 +24,7 @@ using namespace std;
|
||||
|
||||
|
||||
ServerDBGeneric::ServerDBGeneric(ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> 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));
|
||||
}
|
||||
@@ -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 <db/serverdbnoaction.h>
|
||||
|
||||
|
||||
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 <db/serverdbnoaction.h>
|
||||
|
||||
|
||||
ServerDBNoAction::ServerDBNoAction()
|
||||
{
|
||||
}
|
||||
|
||||
ServerDBNoAction::~ServerDBNoAction()
|
||||
{
|
||||
}
|
||||
+1
-2
@@ -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;
|
||||
|
||||
+51
-51
@@ -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 <db/serverdbinterface.h>
|
||||
|
||||
|
||||
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 <db/serverdbinterface.h>
|
||||
|
||||
|
||||
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_
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// C++ Implementation: berointerface
|
||||
//
|
||||
// Description:
|
||||
// Description:
|
||||
//
|
||||
//
|
||||
// Author: FThauer FHammer <webmaster@pokerth.net>, (C) 2007
|
||||
|
||||
@@ -23,11 +23,12 @@
|
||||
#include <game_defs.h>
|
||||
#include <engine_defs.h>
|
||||
|
||||
class BeRoInterface{
|
||||
class BeRoInterface
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~BeRoInterface();
|
||||
|
||||
|
||||
virtual GameState getMyBeRoID() const =0;
|
||||
|
||||
virtual void setCurrentPlayersTurnId(unsigned) =0;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -26,11 +26,12 @@
|
||||
#include "berointerface.h"
|
||||
#include "log.h"
|
||||
|
||||
class EngineFactory{
|
||||
class EngineFactory
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
virtual ~EngineFactory();
|
||||
|
||||
|
||||
virtual boost::shared_ptr<HandInterface> createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) =0;
|
||||
virtual boost::shared_ptr<BoardInterface> createBoard(unsigned dp) =0;
|
||||
virtual boost::shared_ptr<PlayerInterface> createPlayer(int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB) =0;
|
||||
|
||||
+11
-10
@@ -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
|
||||
@@ -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<int> > ArrayData::getHandChancePreflop(int handCode) {
|
||||
vector< vector<int> > ArrayData::getHandChancePreflop(int handCode)
|
||||
{
|
||||
|
||||
int check = -1;
|
||||
|
||||
@@ -1060,7 +1057,7 @@ vector< vector<int> > 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<int> > 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];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,12 @@
|
||||
|
||||
#include<vector>
|
||||
|
||||
class ArrayData{
|
||||
class ArrayData
|
||||
{
|
||||
public:
|
||||
ArrayData();
|
||||
ArrayData();
|
||||
|
||||
~ArrayData();
|
||||
~ArrayData();
|
||||
|
||||
void getHandChancePreflop(int, int**);
|
||||
std::vector< std::vector<int> > getHandChancePreflop(int);
|
||||
|
||||
@@ -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<int> > 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<int> > 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<int> > 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<int> > 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;
|
||||
//
|
||||
//}
|
||||
@@ -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<int> > calcCardsChance(GameState, int*, int*) const;
|
||||
//int** showdown(GameState, int**, int);
|
||||
std::vector< std::vector<int> > calcCardsChance(GameState, int*, int*) const;
|
||||
//int** showdown(GameState, int**, int);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -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; i<myHand->getActivePlayerList()->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; i<MAX_NUMBER_OF_PLAYERS; i++) { myHand->getGuiInterface()->refreshAction(i,PLAYER_ACTION_NONE); }
|
||||
|
||||
for(int i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
myHand->getGuiInterface()->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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
|
||||
class HandInterface;
|
||||
|
||||
class LocalBeRoFlop : public LocalBeRo{
|
||||
class LocalBeRoFlop : public LocalBeRo
|
||||
{
|
||||
|
||||
public:
|
||||
LocalBeRoFlop(HandInterface*, int, unsigned, int);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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; i<MAX_NUMBER_OF_PLAYERS; i++) { getMyHand()->getGuiInterface()->refreshAction(i,PLAYER_ACTION_NONE); }
|
||||
for(int i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
getMyHand()->getGuiInterface()->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());
|
||||
}
|
||||
|
||||
@@ -25,8 +25,9 @@
|
||||
|
||||
class HandInterface;
|
||||
|
||||
class LocalBeRoPreflop : public LocalBeRo{
|
||||
|
||||
class LocalBeRoPreflop : public LocalBeRo
|
||||
{
|
||||
|
||||
public:
|
||||
LocalBeRoPreflop(HandInterface*, int, unsigned, int);
|
||||
~LocalBeRoPreflop();
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
class HandInterface;
|
||||
|
||||
|
||||
class LocalBeRoRiver : public LocalBeRo{
|
||||
class LocalBeRoRiver : public LocalBeRo
|
||||
{
|
||||
public:
|
||||
LocalBeRoRiver(HandInterface*, int, unsigned, int);
|
||||
~LocalBeRoRiver();
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
|
||||
class HandInterface;
|
||||
|
||||
class LocalBeRoTurn : public LocalBeRo{
|
||||
class LocalBeRoTurn : public LocalBeRo
|
||||
{
|
||||
public:
|
||||
LocalBeRoTurn(HandInterface*, int, unsigned, int);
|
||||
~LocalBeRoTurn();
|
||||
|
||||
@@ -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; j<potLevel.size(); j++) {
|
||||
// find seat with potLevel[j]-ID
|
||||
// find seat with potLevel[j]-ID
|
||||
for(it=seatsList->begin(); 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; k<MAX_NUMBER_OF_PLAYERS && !winnerHit; k++){
|
||||
for(k=0; k<MAX_NUMBER_OF_PLAYERS && !winnerHit; k++) {
|
||||
|
||||
// winnerPointer = (winnerPointer+1)%(MAX_NUMBER_OF_PLAYERS);
|
||||
|
||||
@@ -231,7 +235,7 @@ void LocalBoard::distributePot() {
|
||||
}
|
||||
}
|
||||
|
||||
// winners sort and unique
|
||||
// winners sort and unique
|
||||
winners.sort();
|
||||
winners.unique();
|
||||
|
||||
@@ -247,195 +251,196 @@ void LocalBoard::distributePot() {
|
||||
}*/
|
||||
}
|
||||
|
||||
void LocalBoard::determinePlayerNeedToShowCards() {
|
||||
void LocalBoard::determinePlayerNeedToShowCards()
|
||||
{
|
||||
|
||||
playerNeedToShowCards.clear();
|
||||
playerNeedToShowCards.clear();
|
||||
|
||||
// in All In Condition everybody have to show the cards
|
||||
if(allInCondition) {
|
||||
// in All In Condition everybody have to show the cards
|
||||
if(allInCondition) {
|
||||
|
||||
PlayerListConstIterator it_c;
|
||||
PlayerListConstIterator it_c;
|
||||
|
||||
for(it_c = activePlayerList->begin(); 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<unsigned> it_c;
|
||||
// std::_List_const_iterator<unsigned> it_c;
|
||||
|
||||
std::list<int*> level;
|
||||
std::list<int*> 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<int*> level_it;
|
||||
std::_List_iterator<int*> level_it_tmp;
|
||||
std::_List_iterator<int*> next_level_it;
|
||||
std::_List_iterator<int*> level_it;
|
||||
std::_List_iterator<int*> level_it_tmp;
|
||||
std::_List_iterator<int*> 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<unsigned> playerNeedToShowCardsIt;
|
||||
//
|
||||
|
||||
@@ -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<unsigned> getWinners() const { return winners; }
|
||||
void setWinners(const std::list<unsigned> &w) { winners = w; }
|
||||
std::list<unsigned> getWinners() const {
|
||||
return winners;
|
||||
}
|
||||
void setWinners(const std::list<unsigned> &w) {
|
||||
winners = w;
|
||||
}
|
||||
|
||||
std::list<unsigned> getPlayerNeedToShowCards() const { return playerNeedToShowCards; }
|
||||
void setPlayerNeedToShowCards(const std::list<unsigned> &p) { playerNeedToShowCards = p; }
|
||||
std::list<unsigned> getPlayerNeedToShowCards() const {
|
||||
return playerNeedToShowCards;
|
||||
}
|
||||
void setPlayerNeedToShowCards(const std::list<unsigned> &p) {
|
||||
playerNeedToShowCards = p;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
@@ -67,14 +94,14 @@ private:
|
||||
PlayerList runningPlayerList;
|
||||
|
||||
std::list<unsigned> winners;
|
||||
std::list<unsigned> playerNeedToShowCards;
|
||||
std::list<unsigned> playerNeedToShowCards;
|
||||
|
||||
int myCards[5];
|
||||
int pot;
|
||||
int sets;
|
||||
unsigned dealerPosition;
|
||||
bool allInCondition;
|
||||
unsigned lastActionPlayer;
|
||||
unsigned dealerPosition;
|
||||
bool allInCondition;
|
||||
unsigned lastActionPlayer;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
|
||||
LocalEngineFactory::LocalEngineFactory(ConfigFile *c)
|
||||
: myConfig(c)
|
||||
: myConfig(c)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
using namespace std;
|
||||
|
||||
LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> 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<EngineFactory> 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<EngineFactory> 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<EngineFactory> 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);
|
||||
}
|
||||
@@ -31,57 +31,120 @@
|
||||
|
||||
class Log;
|
||||
|
||||
class LocalHand : public HandInterface{
|
||||
class LocalHand : public HandInterface
|
||||
{
|
||||
public:
|
||||
LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface*, boost::shared_ptr<BoardInterface>, 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<BoardInterface> getBoard() const { return myBoard; }
|
||||
boost::shared_ptr<BeRoInterface> getPreflop() const { return myBeRo[GAME_STATE_PREFLOP]; }
|
||||
boost::shared_ptr<BeRoInterface> getFlop() const { return myBeRo[GAME_STATE_FLOP]; }
|
||||
boost::shared_ptr<BeRoInterface> getTurn() const { return myBeRo[GAME_STATE_TURN]; }
|
||||
boost::shared_ptr<BeRoInterface> getRiver() const { return myBeRo[GAME_STATE_RIVER]; }
|
||||
GuiInterface* getGuiInterface() const { return myGui; }
|
||||
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const { return myBeRo[currentRound]; }
|
||||
boost::shared_ptr<BoardInterface> getBoard() const {
|
||||
return myBoard;
|
||||
}
|
||||
boost::shared_ptr<BeRoInterface> getPreflop() const {
|
||||
return myBeRo[GAME_STATE_PREFLOP];
|
||||
}
|
||||
boost::shared_ptr<BeRoInterface> getFlop() const {
|
||||
return myBeRo[GAME_STATE_FLOP];
|
||||
}
|
||||
boost::shared_ptr<BeRoInterface> getTurn() const {
|
||||
return myBeRo[GAME_STATE_TURN];
|
||||
}
|
||||
boost::shared_ptr<BeRoInterface> getRiver() const {
|
||||
return myBeRo[GAME_STATE_RIVER];
|
||||
}
|
||||
GuiInterface* getGuiInterface() const {
|
||||
return myGui;
|
||||
}
|
||||
boost::shared_ptr<BeRoInterface> 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<EngineFactory> myFactory;
|
||||
GuiInterface *myGui;
|
||||
boost::shared_ptr<BoardInterface> 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<boost::shared_ptr<BeRoInterface> > 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;
|
||||
|
||||
+4460
-4451
File diff suppressed because it is too large.
Load diff
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
|
||||
class Replay
|
||||
{
|
||||
public:
|
||||
Replay();
|
||||
~Replay();
|
||||
public:
|
||||
Replay();
|
||||
~Replay();
|
||||
|
||||
private:
|
||||
QSqlDatabase *replaySqliteLogDb;
|
||||
QSqlDatabase *replaySqliteLogDb;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -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<howMany; i++) {
|
||||
|
||||
if(!RAND_bytes(rand_buf, 4))
|
||||
{
|
||||
if(!RAND_bytes(rand_buf, 4)) {
|
||||
LOG_MSG("RAND_bytes failed!");
|
||||
}
|
||||
|
||||
@@ -54,23 +54,21 @@ void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
int *tempArray = new int[end-start+1];
|
||||
for (i=0; i<(end-start+1); i++) tempArray[i]=1;
|
||||
|
||||
if(bad) {
|
||||
for(i=0;i<countBad;i++) {
|
||||
for(i=0; i<countBad; i++) {
|
||||
tempArray[bad[i]]=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int counter(0);
|
||||
while (counter < howMany) {
|
||||
|
||||
if(!RAND_bytes(rand_buf, 4))
|
||||
{
|
||||
if(!RAND_bytes(rand_buf, 4)) {
|
||||
LOG_MSG("RAND_bytes failed!");
|
||||
}
|
||||
|
||||
@@ -82,14 +80,14 @@ void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool
|
||||
if(randNumber < ( (unsigned int) ( ((double)numeric_limits<unsigned int>::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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
+175
-173
@@ -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<string>(logDirString.c_str());
|
||||
mySqliteLogFileName += "pokerth-log-" + boost::lexical_cast<string>(curDateTime) + ".pdb";
|
||||
string mySqliteLogFileName = boost::lexical_cast<string>(logDirString.c_str());
|
||||
mySqliteLogFileName += "pokerth-log-" + boost::lexical_cast<string>(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<string>(POKERTH_BETA_RELEASE_STRING) + "\",";
|
||||
sql += "\"" + boost::lexical_cast<string>(curDate) + "\",";
|
||||
sql += "\"" + boost::lexical_cast<string>(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<string>(POKERTH_BETA_RELEASE_STRING) + "\",";
|
||||
sql += "\"" + boost::lexical_cast<string>(curDate) + "\",";
|
||||
sql += "\"" + boost::lexical_cast<string>(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<std::string>(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<std::string>(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<std::string>(i) + "_Cash INTEGER";
|
||||
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Card_1 INTEGER";
|
||||
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Card_2 INTEGER";
|
||||
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Hand_text TEXT";
|
||||
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Hand_int INTEGER";
|
||||
}
|
||||
for(i=1; i<=5; i++) {
|
||||
sql += ",BoardCard_" + boost::lexical_cast<std::string>(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<std::string>(i) + "_Cash INTEGER";
|
||||
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Card_1 INTEGER";
|
||||
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Card_2 INTEGER";
|
||||
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Hand_text TEXT";
|
||||
sql += ",Seat_" + boost::lexical_cast<std::string>(i) + "_Hand_int INTEGER";
|
||||
}
|
||||
for(i=1; i<=5; i++) {
|
||||
sql += ",BoardCard_" + boost::lexical_cast<std::string>(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<std::string>(i);
|
||||
}
|
||||
sql += ") VALUES (";
|
||||
sql += boost::lexical_cast<string>(curGameID);
|
||||
sql += "," + boost::lexical_cast<string>(startCash);
|
||||
sql += "," + boost::lexical_cast<string>(startSmallBlind);
|
||||
sql += "," + boost::lexical_cast<string>(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<std::string>(i);
|
||||
}
|
||||
sql += ") VALUES (";
|
||||
sql += boost::lexical_cast<string>(curGameID);
|
||||
sql += "," + boost::lexical_cast<string>(startCash);
|
||||
sql += "," + boost::lexical_cast<string>(startSmallBlind);
|
||||
sql += "," + boost::lexical_cast<string>(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<std::string>(i) + "_Cash";
|
||||
}
|
||||
sql += ") VALUES (";
|
||||
sql += boost::lexical_cast<string>(handID);
|
||||
sql += "," + boost::lexical_cast<string>(curGameID);
|
||||
sql += "," + boost::lexical_cast<string>(dealerPosition+1);
|
||||
sql += "," + boost::lexical_cast<string>(smallBlind);
|
||||
sql += "," + boost::lexical_cast<string>(smallBlindPosition+1);
|
||||
sql += "," + boost::lexical_cast<string>(bigBlind);
|
||||
sql += "," + boost::lexical_cast<string>(bigBlindPosition+1);
|
||||
for(it_c = seatsList->begin();it_c!=seatsList->end();it_c++) {
|
||||
if((*it_c)->getMyActiveStatus()) {
|
||||
sql += "," + boost::lexical_cast<string>((*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<std::string>(i) + "_Cash";
|
||||
}
|
||||
sql += ") VALUES (";
|
||||
sql += boost::lexical_cast<string>(handID);
|
||||
sql += "," + boost::lexical_cast<string>(curGameID);
|
||||
sql += "," + boost::lexical_cast<string>(dealerPosition+1);
|
||||
sql += "," + boost::lexical_cast<string>(smallBlind);
|
||||
sql += "," + boost::lexical_cast<string>(smallBlindPosition+1);
|
||||
sql += "," + boost::lexical_cast<string>(bigBlind);
|
||||
sql += "," + boost::lexical_cast<string>(bigBlindPosition+1);
|
||||
for(it_c = seatsList->begin(); it_c!=seatsList->end(); it_c++) {
|
||||
if((*it_c)->getMyActiveStatus()) {
|
||||
sql += "," + boost::lexical_cast<string>((*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
|
||||
|
||||
+7
-7
@@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ class HandInterface;
|
||||
/**
|
||||
@author FThauer FHammer <webmaster@pokerth.net>
|
||||
*/
|
||||
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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -22,15 +22,15 @@
|
||||
using namespace std;
|
||||
|
||||
ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,97 +32,97 @@
|
||||
|
||||
class ClientHand : public HandInterface
|
||||
{
|
||||
public:
|
||||
ClientHand ( boost::shared_ptr<EngineFactory> f, GuiInterface*, boost::shared_ptr<BoardInterface>, Log*, PlayerList, PlayerList, PlayerList , int, int, int, int, int );
|
||||
~ClientHand();
|
||||
public:
|
||||
ClientHand ( boost::shared_ptr<EngineFactory> f, GuiInterface*, boost::shared_ptr<BoardInterface>, 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<BoardInterface> getBoard() const;
|
||||
boost::shared_ptr<BeRoInterface> getPreflop() const;
|
||||
boost::shared_ptr<BeRoInterface> getFlop() const;
|
||||
boost::shared_ptr<BeRoInterface> getTurn() const;
|
||||
boost::shared_ptr<BeRoInterface> getRiver() const;
|
||||
GuiInterface* getGuiInterface() const;
|
||||
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const;
|
||||
boost::shared_ptr<BoardInterface> getBoard() const;
|
||||
boost::shared_ptr<BeRoInterface> getPreflop() const;
|
||||
boost::shared_ptr<BeRoInterface> getFlop() const;
|
||||
boost::shared_ptr<BeRoInterface> getTurn() const;
|
||||
boost::shared_ptr<BeRoInterface> getRiver() const;
|
||||
GuiInterface* getGuiInterface() const;
|
||||
boost::shared_ptr<BeRoInterface> 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<EngineFactory> myFactory;
|
||||
GuiInterface *myGui;
|
||||
boost::shared_ptr<BoardInterface> myBoard;
|
||||
Log *myLog;
|
||||
boost::shared_ptr<EngineFactory> myFactory;
|
||||
GuiInterface *myGui;
|
||||
boost::shared_ptr<BoardInterface> myBoard;
|
||||
Log *myLog;
|
||||
|
||||
PlayerList seatsList;
|
||||
PlayerList activePlayerList;
|
||||
PlayerList runningPlayerList;
|
||||
PlayerList seatsList;
|
||||
PlayerList activePlayerList;
|
||||
PlayerList runningPlayerList;
|
||||
|
||||
std::vector<boost::shared_ptr<BeRoInterface> > myBeRo;
|
||||
std::vector<boost::shared_ptr<BeRoInterface> > 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
|
||||
|
||||
@@ -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<unsigned> playerNeedToShowCardsList = currentHand->getBoard()->getPlayerNeedToShowCards();
|
||||
for(std::list<unsigned>::iterator it = playerNeedToShowCardsList.begin(); it != playerNeedToShowCardsList.end(); ++it)
|
||||
{
|
||||
if(*it == myUniqueID) return true;
|
||||
}
|
||||
for(std::list<unsigned>::iterator it = playerNeedToShowCardsList.begin(); it != playerNeedToShowCardsList.end(); ++it) {
|
||||
if(*it == myUniqueID) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
@@ -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<SessionData> 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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+28
-35
@@ -32,12 +32,12 @@ using namespace std;
|
||||
|
||||
Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> 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<EngineFactory> 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<EngineFactory> 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<boost::shared_ptr<PlayerInterface> >);
|
||||
@@ -84,8 +83,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||
PlayerType type = PLAYER_TYPE_COMPUTER;
|
||||
boost::shared_ptr<SessionData> 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<EngineFactory> 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<PlayerInterface> Game::getPlayerByUniqueId(unsigned id)
|
||||
boost::shared_ptr<PlayerInterface> 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<PlayerInterface> 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;
|
||||
}
|
||||
}
|
||||
|
||||
+52
-21
@@ -35,12 +35,13 @@ struct GameData;
|
||||
struct StartData;
|
||||
|
||||
|
||||
class Game {
|
||||
class Game
|
||||
{
|
||||
|
||||
public:
|
||||
Game(GuiInterface *gui, boost::shared_ptr<EngineFactory> factory,
|
||||
const PlayerDataList &playerDataList, const GameData &gameData,
|
||||
const StartData &startData, int gameId, Log *myLog);
|
||||
Game(GuiInterface *gui, boost::shared_ptr<EngineFactory> factory,
|
||||
const PlayerDataList &playerDataList, const GameData &gameData,
|
||||
const StartData &startData, int gameId, Log *myLog);
|
||||
|
||||
~Game();
|
||||
|
||||
@@ -50,28 +51,58 @@ public:
|
||||
boost::shared_ptr<HandInterface> getCurrentHand();
|
||||
const boost::shared_ptr<HandInterface> 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<PlayerInterface> getPlayerByUniqueId(unsigned id);
|
||||
boost::shared_ptr<PlayerInterface> getCurrentPlayer();
|
||||
@@ -82,7 +113,7 @@ private:
|
||||
boost::shared_ptr<EngineFactory> myFactory;
|
||||
|
||||
GuiInterface *myGui;
|
||||
Log *myLog;
|
||||
Log *myLog;
|
||||
boost::shared_ptr<HandInterface> currentHand;
|
||||
boost::shared_ptr<BoardInterface> currentBoard;
|
||||
|
||||
|
||||
+68
-71
@@ -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
|
||||
+12
-21
@@ -28,43 +28,37 @@
|
||||
|
||||
typedef std::list<unsigned> 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;
|
||||
|
||||
@@ -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> 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> 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);
|
||||
}
|
||||
+112
-108
@@ -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<Session> getSession();
|
||||
void setSession(boost::shared_ptr<Session> session);
|
||||
boost::shared_ptr<Session> getSession();
|
||||
void setSession(boost::shared_ptr<Session> 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> 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> 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<Session> mySession;
|
||||
ConfigFile *myConfig;
|
||||
boost::shared_ptr<Session> mySession;
|
||||
ConfigFile *myConfig;
|
||||
|
||||
ClientCallback *myClientcb;
|
||||
ServerCallback *myServercb;
|
||||
IrcCallback *myIrccb;
|
||||
ClientCallback *myClientcb;
|
||||
ServerCallback *myServercb;
|
||||
IrcCallback *myIrccb;
|
||||
};
|
||||
|
||||
#endif
|
||||
+61
-60
@@ -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<Session> getSession() =0;
|
||||
virtual void setSession(boost::shared_ptr<Session> session) =0;
|
||||
virtual boost::shared_ptr<Session> getSession() =0;
|
||||
virtual void setSession(boost::shared_ptr<Session> 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;
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
@@ -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<int> tempIntList;
|
||||
QStringList tempStringList;
|
||||
bool ok = TRUE;
|
||||
|
||||
|
||||
for(i=0; i<listWidget_blinds->count(); 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; i<tempIntList.count(); i++) {
|
||||
//
|
||||
//
|
||||
// std::cout << tempIntList[i] << "\n";
|
||||
tempStringList << QString::number(tempIntList[i],10);
|
||||
}
|
||||
//
|
||||
//
|
||||
listWidget_blinds->clear();
|
||||
listWidget_blinds->addItems(tempStringList);
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
+153
-139
@@ -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("<span style=\"font-weight:bold; color:red;\">"+message+"</span>");
|
||||
//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("<span style=\"font-weight:bold; color:red;\">"+message+"</span>");
|
||||
//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("<span style=\"font-weight:bold; color:"+myLobby->palette().link().color().name()+";\">"+message+"</span>");
|
||||
//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("<span style=\"font-weight:bold;\">"+message+"</span>");
|
||||
break;
|
||||
case INGAME_CHAT: tempMsg = QString("<span style=\"color:#"+myStyle->getChatTextNickNotifyColor()+";\">"+message+"</span>");
|
||||
break;
|
||||
default: tempMsg = message;
|
||||
}
|
||||
}
|
||||
else if(playerName == myNick) {
|
||||
switch (myChatType) {
|
||||
case INET_LOBBY_CHAT: tempMsg = QString("<span style=\"font-weight:normal; color:"+myLobby->palette().link().color().name()+";\">"+message+"</span>");
|
||||
break;
|
||||
case LAN_LOBBY_CHAT: tempMsg = QString("<span style=\"font-weight:normal;\">"+message+"</span>");
|
||||
break;
|
||||
case INGAME_CHAT: tempMsg = QString("<span style=\"color:#"+myStyle->getChatLogTextColor()+";\">"+message+"</span>");
|
||||
break;
|
||||
default: tempMsg = message;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (myChatType) {
|
||||
case INET_LOBBY_CHAT: tempMsg = QString("<span style=\"font-weight:normal; color:"+myLobby->palette().text().color().name()+";\">"+message+"</span>");
|
||||
break;
|
||||
case LAN_LOBBY_CHAT: tempMsg = QString("<span style=\"font-weight:normal;\">"+message+"</span>");
|
||||
break;
|
||||
case INGAME_CHAT: tempMsg = QString("<span style=\"color:#"+myStyle->getChatLogTextColor()+";\">"+message+"</span>");
|
||||
break;
|
||||
default: tempMsg = message;
|
||||
}
|
||||
switch (myChatType) {
|
||||
case INET_LOBBY_CHAT: {
|
||||
tempMsg = QString("<span style=\"font-weight:bold; color:"+myLobby->palette().link().color().name()+";\">"+message+"</span>");
|
||||
//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("<span style=\"font-weight:bold;\">"+message+"</span>");
|
||||
break;
|
||||
case INGAME_CHAT:
|
||||
tempMsg = QString("<span style=\"color:#"+myStyle->getChatTextNickNotifyColor()+";\">"+message+"</span>");
|
||||
break;
|
||||
default:
|
||||
tempMsg = message;
|
||||
}
|
||||
} else if(playerName == myNick) {
|
||||
switch (myChatType) {
|
||||
case INET_LOBBY_CHAT:
|
||||
tempMsg = QString("<span style=\"font-weight:normal; color:"+myLobby->palette().link().color().name()+";\">"+message+"</span>");
|
||||
break;
|
||||
case LAN_LOBBY_CHAT:
|
||||
tempMsg = QString("<span style=\"font-weight:normal;\">"+message+"</span>");
|
||||
break;
|
||||
case INGAME_CHAT:
|
||||
tempMsg = QString("<span style=\"color:#"+myStyle->getChatLogTextColor()+";\">"+message+"</span>");
|
||||
break;
|
||||
default:
|
||||
tempMsg = message;
|
||||
}
|
||||
} else {
|
||||
switch (myChatType) {
|
||||
case INET_LOBBY_CHAT:
|
||||
tempMsg = QString("<span style=\"font-weight:normal; color:"+myLobby->palette().text().color().name()+";\">"+message+"</span>");
|
||||
break;
|
||||
case LAN_LOBBY_CHAT:
|
||||
tempMsg = QString("<span style=\"font-weight:normal;\">"+message+"</span>");
|
||||
break;
|
||||
case INGAME_CHAT:
|
||||
tempMsg = QString("<span style=\"color:#"+myStyle->getChatLogTextColor()+";\">"+message+"</span>");
|
||||
break;
|
||||
default:
|
||||
tempMsg = message;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool nickFoundOnIgnoreList = false;
|
||||
list<std::string>::iterator it1;
|
||||
bool nickFoundOnIgnoreList = false;
|
||||
list<std::string>::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 ","<i>*"+playerName+" ")+"</i>");
|
||||
}
|
||||
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");
|
||||
}
|
||||
@@ -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> session) { mySession = session; }
|
||||
void setSession(boost::shared_ptr<Session> 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<Session> mySession;
|
||||
ChatType myChatType;
|
||||
ConfigFile *myConfig;
|
||||
QLineEdit *myLineEdit;
|
||||
QStandardItemModel *myNickListModel;
|
||||
QStringList myNickStringList;
|
||||
QTextBrowser *myTextBrowser;
|
||||
boost::shared_ptr<Session> mySession;
|
||||
ChatType myChatType;
|
||||
ConfigFile *myConfig;
|
||||
|
||||
QString myNick;
|
||||
QString myNick;
|
||||
|
||||
GameTableStyleReader *myStyle;
|
||||
gameLobbyDialogImpl *myLobby;
|
||||
GameTableStyleReader *myStyle;
|
||||
gameLobbyDialogImpl *myLobby;
|
||||
|
||||
std::list<std::string> ignoreList;
|
||||
std::list<std::string> ignoreList;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -21,13 +21,13 @@
|
||||
#include <net/socket_msg.h>
|
||||
|
||||
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)
|
||||
|
||||
@@ -26,10 +26,11 @@
|
||||
#include <QtCore>
|
||||
|
||||
|
||||
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();
|
||||
|
||||
|
||||
@@ -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("<i>First small blind: $%1</i>").arg(RANKING_GAME_START_SBLIND));
|
||||
raiseMode = new QLabel(tr("<i>Double blinds every %1'th hand</i>").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("<i>First small blind: $%1</i>").arg(RANKING_GAME_START_SBLIND));
|
||||
raiseMode = new QLabel(tr("<i>Double blinds every %1'th hand</i>").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<int> myBlindsList = myConfig->readConfigIntList("NetManualBlindsList");
|
||||
std::list<int>::iterator it1;
|
||||
std::list<int> myBlindsList = myConfig->readConfigIntList("NetManualBlindsList");
|
||||
std::list<int>::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"));
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -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<int> myBlindsList = myConfig->readConfigIntList("NetManualBlindsList");
|
||||
std::list<int>::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();
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// C++ Interface: gamelobbydialogimpl
|
||||
//
|
||||
// Description:
|
||||
// Description:
|
||||
//
|
||||
//
|
||||
// Author: FThauer FHammer <webmaster@pokerth.net>, (C) 2007
|
||||
@@ -35,134 +35,148 @@ class MyNickListSortFilterProxyModel;
|
||||
@author FThauer FHammer <webmaster@pokerth.net>
|
||||
*/
|
||||
|
||||
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> session);
|
||||
boost::shared_ptr<Session> getSession() { assert(mySession.get()); return mySession; }
|
||||
void setSession(boost::shared_ptr<Session> session);
|
||||
boost::shared_ptr<Session> 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 <QStandardItem*>, 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 <QStandardItem*>, 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<Session> mySession;
|
||||
createInternetGameDialogImpl *myCreateInternetGameDialog;
|
||||
QString currentGameName;
|
||||
unsigned myPlayerId;
|
||||
bool isGameAdministrator;
|
||||
bool inGame;
|
||||
bool guestMode;
|
||||
gameTableImpl* myW;
|
||||
startWindowImpl* myStartWindow;
|
||||
ConfigFile *myConfig;
|
||||
boost::shared_ptr<Session> 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);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -3,21 +3,22 @@
|
||||
#include <QtCore>
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -4,24 +4,32 @@
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Loaded 100 of 232 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user