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:
lotodore committed 2011-02-11 20:02:08 +00:00
1 parent 29dca1846e
commit 02518c67b2
207 files changed
+7726 -6027

No files matched your search

+6 -3
View File
@@ -3,12 +3,15 @@
#include <QtCore> #include <QtCore>
class BadWordCheck: public QObject { class BadWordCheck: public QObject
Q_OBJECT {
Q_OBJECT
public: public:
BadWordCheck(); BadWordCheck();
void setBadWords(QStringList bw) { badWords = bw; } void setBadWords(QStringList bw) {
badWords = bw;
}
bool run(QString); bool run(QString);
+2 -3
View File
@@ -3,7 +3,7 @@
#include <QtCore> #include <QtCore>
CapsFloodCheck::CapsFloodCheck() CapsFloodCheck::CapsFloodCheck()
: capsNumberToTrigger(0) : capsNumberToTrigger(0)
{ {
} }
@@ -16,8 +16,7 @@ bool CapsFloodCheck::run(QString msg)
e.indexIn(msg); e.indexIn(msg);
if(e.matchedLength() != -1 ) return true; if(e.matchedLength() != -1 ) return true;
else return false; else return false;
} } else {
else {
// qDebug() << "The current Caps Flood RegExp is invalid" << endl; // qDebug() << "The current Caps Flood RegExp is invalid" << endl;
return false; return false;
} }
+6 -3
View File
@@ -3,12 +3,15 @@
#include <QtCore> #include <QtCore>
class CapsFloodCheck: public QObject { class CapsFloodCheck: public QObject
Q_OBJECT {
Q_OBJECT
public: public:
CapsFloodCheck(); CapsFloodCheck();
void setCapsNumberToTrigger(int n) { capsNumberToTrigger = n; } void setCapsNumberToTrigger(int n) {
capsNumberToTrigger = n;
}
bool run(QString); bool run(QString);
private: private:
+5 -5
View File
@@ -2,12 +2,12 @@
#include "cleanerserver.h" #include "cleanerserver.h"
#ifdef _WIN32 #ifdef _WIN32
#include <process.h> #include <process.h>
#else #else
#include <unistd.h> #include <unistd.h>
#ifndef daemon #ifndef daemon
int daemon(int, int); int daemon(int, int);
#endif #endif
#endif #endif
int main(int argc, char *argv[]) int main(int argc, char *argv[])
+31 -21
View File
@@ -50,8 +50,7 @@ CleanerConfig::CleanerConfig()
const char *appDataPath = getenv("AppData"); const char *appDataPath = getenv("AppData");
if (appDataPath && appDataPath[0] != 0) { if (appDataPath && appDataPath[0] != 0) {
configFileName = appDataPath; configFileName = appDataPath;
} } else {
else {
const int MaxPathSize = 1024; const int MaxPathSize = 1024;
char curDir[MaxPathSize + 1]; char curDir[MaxPathSize + 1];
curDir[0] = 0; curDir[0] = 0;
@@ -67,8 +66,7 @@ CleanerConfig::CleanerConfig()
// Datei wieder loeschen. // Datei wieder loeschen.
tmpFile.close(); tmpFile.close();
remove((configFileName + "\\" + tmpFileName).c_str()); remove((configFileName + "\\" + tmpFileName).c_str());
} } else {
else {
// Fehlgeschlagen, Verzeichnis nicht beschreibbar // Fehlgeschlagen, Verzeichnis nicht beschreibbar
curDir[0] = 0; curDir[0] = 0;
GetTempPathA(MaxPathSize, curDir); GetTempPathA(MaxPathSize, curDir);
@@ -183,17 +181,18 @@ CleanerConfig::CleanerConfig()
//Prüfen ob Configfile existiert --> sonst anlegen //Prüfen ob Configfile existiert --> sonst anlegen
TiXmlDocument doc(configFileName); TiXmlDocument doc(configFileName);
if(!doc.LoadFile()){ if(!doc.LoadFile()) {
myConfigState = NONEXISTING; myConfigState = NONEXISTING;
updateConfig(myConfigState); updateConfig(myConfigState);
} } else {
else {
//Check if config revision is ok. Otherwise --> update() //Check if config revision is ok. Otherwise --> update()
int tempRevision = 0; int tempRevision = 0;
TiXmlHandle docHandle( &doc ); TiXmlHandle docHandle( &doc );
TiXmlElement* confRevision = docHandle.FirstChild( "PokerTHCleaner" ).FirstChild( "Configuration" ).FirstChild( "ConfigRevision" ).ToElement(); TiXmlElement* confRevision = docHandle.FirstChild( "PokerTHCleaner" ).FirstChild( "Configuration" ).FirstChild( "ConfigRevision" ).ToElement();
if ( confRevision ) { confRevision->QueryIntAttribute("value", &tempRevision ); } if ( confRevision ) {
confRevision->QueryIntAttribute("value", &tempRevision );
}
if (tempRevision < configRev ) { /*löschen()*/ if (tempRevision < configRev ) { /*löschen()*/
myConfigState = OLD; myConfigState = OLD;
@@ -211,7 +210,8 @@ CleanerConfig::~CleanerConfig()
} }
void CleanerConfig::fillBuffer() { void CleanerConfig::fillBuffer()
{
string tempString1(""); string tempString1("");
string tempString2(""); string tempString2("");
@@ -247,13 +247,15 @@ void CleanerConfig::fillBuffer() {
configBufferList[i].defaultListValue = tempStringList2; 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; TiXmlDocument doc;
TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", ""); TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", "");
@@ -291,7 +293,8 @@ void CleanerConfig::writeBuffer() const {
} }
void CleanerConfig::updateConfig(ConfigState myConfigState) { void CleanerConfig::updateConfig(ConfigState myConfigState)
{
size_t i; size_t i;
@@ -406,8 +409,7 @@ void CleanerConfig::updateConfig(ConfigState myConfigState) {
} }
} }
} }
} } else {
else {
// if element is not there --> set it with defaultValue // if element is not there --> set it with defaultValue
TiXmlElement *tmpElement = new TiXmlElement(configList[i].name); TiXmlElement *tmpElement = new TiXmlElement(configList[i].name);
config->LinkEndChild( tmpElement ); config->LinkEndChild( tmpElement );
@@ -428,8 +430,9 @@ void CleanerConfig::updateConfig(ConfigState myConfigState) {
} }
} }
newDoc.SaveFile( configFileName ); newDoc.SaveFile( configFileName );
} else {
qDebug("Cannot update config file: Unable to load configuration.");
} }
else { qDebug("Cannot update config file: Unable to load configuration."); }
} }
@@ -449,7 +452,7 @@ string CleanerConfig::readConfigString(string varName) const
} }
return tempString; return tempString;
} }
int CleanerConfig::readConfigInt(string varName) const int CleanerConfig::readConfigInt(string varName) const
{ {
@@ -486,7 +489,7 @@ list<string> CleanerConfig::readConfigStringList(string varName) const
} }
return tempStringList; return tempStringList;
} }
list<int> CleanerConfig::readConfigIntList(string varName) const list<int> CleanerConfig::readConfigIntList(string varName) const
@@ -582,11 +585,14 @@ void CleanerConfig::writeConfigString(string varName, string varCont)
size_t i; size_t i;
for (i=0; i<configBufferList.size(); i++) { for (i=0; i<configBufferList.size(); i++) {
if (configBufferList[i].name == varName) { configBufferList[i].defaultValue = varCont; } 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); QString tmpString = QString::fromStdString(myString);
std::string myUtf8String = tmpString.toUtf8().constData(); std::string myUtf8String = tmpString.toUtf8().constData();
@@ -594,10 +600,14 @@ std::string CleanerConfig::stringToUtf8(const std::string &myString) {
return myUtf8String; 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()); QString tmpString = QString::fromUtf8(myString.c_str());
return tmpString.toStdString(); return tmpString.toStdString();
} }
std::string CleanerConfig::getDefaultLanguage() { return QLocale::system().name().toStdString(); } std::string CleanerConfig::getDefaultLanguage()
{
return QLocale::system().name().toStdString();
}
+6 -4
View File
@@ -28,13 +28,16 @@ enum ConfigState { NONEXISTING, OLD };
enum ConfigType { CONFIG_TYPE_INT, CONFIG_TYPE_STRING, CONFIG_TYPE_INT_LIST, CONFIG_TYPE_STRING_LIST }; enum ConfigType { CONFIG_TYPE_INT, CONFIG_TYPE_STRING, CONFIG_TYPE_INT_LIST, CONFIG_TYPE_STRING_LIST };
class CleanerConfig{ class CleanerConfig
{
public: public:
CleanerConfig(); CleanerConfig();
~CleanerConfig(); ~CleanerConfig();
std::string getConfigFileName() const { return configFileName; } std::string getConfigFileName() const {
return configFileName;
}
void fillBuffer(); void fillBuffer();
void writeBuffer() const; void writeBuffer() const;
@@ -57,8 +60,7 @@ public:
private: 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) {} 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; std::string name;
ConfigType type; ConfigType type;
+21 -34
View File
@@ -59,24 +59,19 @@ void CleanerServer::onRead()
{ {
qint64 bytesRead = tcpSocket->read((char *)m_recvBuf + m_recvBufUsed, sizeof(m_recvBuf) - m_recvBufUsed); qint64 bytesRead = tcpSocket->read((char *)m_recvBuf + m_recvBufUsed, sizeof(m_recvBuf) - m_recvBufUsed);
bool error = bytesRead < 1; bool error = bytesRead < 1;
if (!error) if (!error) {
{
m_recvBufUsed += bytesRead; m_recvBufUsed += bytesRead;
asn_dec_rval_t retVal; asn_dec_rval_t retVal;
do do {
{
// Try to decode the packets. // Try to decode the packets.
InternalChatCleanerPacket recvMsg; InternalChatCleanerPacket recvMsg;
retVal = ber_decode(0, &asn_DEF_ChatCleanerMessage, (void **)recvMsg.GetMsgPtr(), m_recvBuf, m_recvBufUsed); retVal = ber_decode(0, &asn_DEF_ChatCleanerMessage, (void **)recvMsg.GetMsgPtr(), m_recvBuf, m_recvBufUsed);
if(retVal.code == RC_OK) if(retVal.code == RC_OK) {
{ if (retVal.consumed < m_recvBufUsed) {
if (retVal.consumed < m_recvBufUsed)
{
m_recvBufUsed -= retVal.consumed; m_recvBufUsed -= retVal.consumed;
memmove(m_recvBuf, m_recvBuf + retVal.consumed, m_recvBufUsed); memmove(m_recvBuf, m_recvBuf + retVal.consumed, m_recvBufUsed);
} } else
else
m_recvBufUsed = 0; m_recvBufUsed = 0;
// Handle the packets. // Handle the packets.
@@ -85,8 +80,7 @@ void CleanerServer::onRead()
} while (!error && retVal.code == RC_OK); } while (!error && retVal.code == RC_OK);
} }
if (error) if (error) {
{
qDebug() << "Error handling packets from client."; qDebug() << "Error handling packets from client.";
tcpSocket->close(); tcpSocket->close();
} }
@@ -104,16 +98,14 @@ void CleanerServer::onRead()
tcpSocket->write(checkMessage.toAscii().data(), checkMessage.length());*/ tcpSocket->write(checkMessage.toAscii().data(), checkMessage.length());*/
} }
bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) { bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg)
{
bool error = true; bool error = true;
if (msg.GetMsg()->present == ChatCleanerMessage_PR_cleanerInitMessage) if (msg.GetMsg()->present == ChatCleanerMessage_PR_cleanerInitMessage) {
{
CleanerInitMessage_t *netInit = &msg.GetMsg()->choice.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); string tmpClientSecret((const char *)netInit->clientSecret.buf, netInit->clientSecret.size);
if (clientSecret == QString::fromStdString(tmpClientSecret)) if (clientSecret == QString::fromStdString(tmpClientSecret)) {
{
error = false; error = false;
InternalChatCleanerPacket tmpAck; InternalChatCleanerPacket tmpAck;
@@ -125,15 +117,11 @@ bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) {
tmpServerSecret.c_str(), tmpServerSecret.c_str(),
tmpServerSecret.length()); tmpServerSecret.length());
sendMessageToClient(tmpAck); sendMessageToClient(tmpAck);
} } else
else
qDebug() << "Invalid client secret."; qDebug() << "Invalid client secret.";
} } else
else
qDebug() << "Invalid client version: " << netInit->requestedVersion; qDebug() << "Invalid client version: " << netInit->requestedVersion;
} } else if (msg.GetMsg()->present == ChatCleanerMessage_PR_cleanerChatRequestMessage) {
else if (msg.GetMsg()->present == ChatCleanerMessage_PR_cleanerChatRequestMessage)
{
error = false; error = false;
CleanerChatRequestMessage_t *netRequest = &msg.GetMsg()->choice.cleanerChatRequestMessage; CleanerChatRequestMessage_t *netRequest = &msg.GetMsg()->choice.cleanerChatRequestMessage;
unsigned playerId = netRequest->playerId; unsigned playerId = netRequest->playerId;
@@ -145,8 +133,7 @@ bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) {
QString checkAction = checkreturn.at(0); QString checkAction = checkreturn.at(0);
QString checkMessage = checkreturn.at(1); QString checkMessage = checkreturn.at(1);
if (!checkAction.isEmpty()) if (!checkAction.isEmpty()) {
{
InternalChatCleanerPacket tmpReply; InternalChatCleanerPacket tmpReply;
tmpReply.GetMsg()->present = ChatCleanerMessage_PR_cleanerChatReplyMessage; tmpReply.GetMsg()->present = ChatCleanerMessage_PR_cleanerChatReplyMessage;
CleanerChatReplyMessage_t *netReply = &tmpReply.GetMsg()->choice.cleanerChatReplyMessage; CleanerChatReplyMessage_t *netReply = &tmpReply.GetMsg()->choice.cleanerChatReplyMessage;
@@ -156,11 +143,9 @@ bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) {
if(checkAction == "warn") { if(checkAction == "warn") {
netReply->cleanerActionType = cleanerActionType_cleanerActionWarning; netReply->cleanerActionType = cleanerActionType_cleanerActionWarning;
} } else if(checkAction == "kick") {
else if(checkAction == "kick") {
netReply->cleanerActionType = cleanerActionType_cleanerActionKick; netReply->cleanerActionType = cleanerActionType_cleanerActionKick;
} } else if(checkAction == "kickban") {
else if(checkAction == "kickban") {
netReply->cleanerActionType = cleanerActionType_cleanerActionBan; netReply->cleanerActionType = cleanerActionType_cleanerActionBan;
} }
@@ -176,13 +161,15 @@ bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) {
return error; return error;
} }
void CleanerServer::socketStateChanged(QAbstractSocket::SocketState state) { void CleanerServer::socketStateChanged(QAbstractSocket::SocketState state)
{
qDebug() << "Socket state changed to: " << QAbstractSocket::UnconnectedState; qDebug() << "Socket state changed to: " << QAbstractSocket::UnconnectedState;
if(state == QAbstractSocket::UnconnectedState) blockConnection = false; if(state == QAbstractSocket::UnconnectedState) blockConnection = false;
} }
void CleanerServer::refreshConfig() { void CleanerServer::refreshConfig()
{
QFileInfo configFileInfo(QString::fromUtf8(config->getConfigFileName().c_str())); QFileInfo configFileInfo(QString::fromUtf8(config->getConfigFileName().c_str()));
+3 -2
View File
@@ -8,8 +8,9 @@
class MessageFilter; class MessageFilter;
class CleanerConfig; class CleanerConfig;
class CleanerServer: public QObject { class CleanerServer: public QObject
Q_OBJECT {
Q_OBJECT
public: public:
CleanerServer(); CleanerServer();
+3 -5
View File
@@ -3,7 +3,7 @@
#include <QtCore> #include <QtCore>
LetterRepeatingCheck::LetterRepeatingCheck() LetterRepeatingCheck::LetterRepeatingCheck()
: letterNumberToTrigger(0) : letterNumberToTrigger(0)
{ {
} }
@@ -14,12 +14,10 @@ bool LetterRepeatingCheck::run(QString msg)
if(e.isValid()) { if(e.isValid()) {
if(e.exactMatch(msg)) { if(e.exactMatch(msg)) {
return true; return true;
} } else {
else {
return false; return false;
} }
} } else {
else {
// qDebug() << "The current Letter Repeating RegExp is invalid" << endl; // qDebug() << "The current Letter Repeating RegExp is invalid" << endl;
return false; return false;
} }
+6 -3
View File
@@ -3,12 +3,15 @@
#include <QtCore> #include <QtCore>
class LetterRepeatingCheck: public QObject { class LetterRepeatingCheck: public QObject
Q_OBJECT {
Q_OBJECT
public: public:
LetterRepeatingCheck(); LetterRepeatingCheck();
void setLetterNumberToTrigger(int n) { letterNumberToTrigger = n; } void setLetterNumberToTrigger(int n) {
letterNumberToTrigger = n;
}
bool run(QString); bool run(QString);
private: private:
+14 -18
View File
@@ -38,7 +38,8 @@ MessageFilter::MessageFilter(CleanerConfig *c): config(c)
cleanTimer->start(30000); cleanTimer->start(30000);
} }
MessageFilter::~MessageFilter() { MessageFilter::~MessageFilter()
{
delete myBadWordCheck; delete myBadWordCheck;
delete myTextFloodCheck; delete myTextFloodCheck;
@@ -62,7 +63,7 @@ QStringList MessageFilter::check(unsigned playerId, QString nick, QString msg)
if(myUrlCheck->run(msg)) offence = URL; if(myUrlCheck->run(msg)) offence = URL;
if(myTextFloodCheck->run(playerId)) offence = TEXT_FLOOD_LINES; if(myTextFloodCheck->run(playerId)) offence = TEXT_FLOOD_LINES;
if(offence){ if(offence) {
ActionType action = NOTHING; ActionType action = NOTHING;
QMap<unsigned, ClientWarnInfos>::const_iterator i = myClientWarnLevelList.find(playerId); QMap<unsigned, ClientWarnInfos>::const_iterator i = myClientWarnLevelList.find(playerId);
@@ -74,8 +75,7 @@ QStringList MessageFilter::check(unsigned playerId, QString nick, QString msg)
tmpInfos.nick = nick; tmpInfos.nick = nick;
myClientWarnLevelList.insert(playerId, tmpInfos); myClientWarnLevelList.insert(playerId, tmpInfos);
action = WARN; action = WARN;
} } else {
else {
if(i.value().warnLevel == warnLevelToKick || i.value().lastWarnType == offence) { if(i.value().warnLevel == warnLevelToKick || i.value().lastWarnType == offence) {
// Kick Command // Kick Command
action = KICK; action = KICK;
@@ -90,23 +90,20 @@ QStringList MessageFilter::check(unsigned playerId, QString nick, QString msg)
tmpInfos.kickNumber = 1; tmpInfos.kickNumber = 1;
tmpInfos.lastKickTimestamp = timer.elapsed().total_seconds(); tmpInfos.lastKickTimestamp = timer.elapsed().total_seconds();
myClientKickCounterList.insert(nick, tmpInfos); myClientKickCounterList.insert(nick, tmpInfos);
} } else {
else {
//pleayer is already on the list: either raise kickNumber or kickban when kickNumerToBan is reached //pleayer is already on the list: either raise kickNumber or kickban when kickNumerToBan is reached
if(j.value().kickNumber == kickNumberToBan) { if(j.value().kickNumber == kickNumberToBan) {
action = KICKBAN; action = KICKBAN;
//remove player from kickCounterList //remove player from kickCounterList
myClientKickCounterList.remove(j.key()); myClientKickCounterList.remove(j.key());
} } else {
else {
ClientKickInfos tmpInfos; ClientKickInfos tmpInfos;
tmpInfos.kickNumber = j.value().kickNumber+1; tmpInfos.kickNumber = j.value().kickNumber+1;
tmpInfos.lastKickTimestamp = timer.elapsed().total_seconds(); tmpInfos.lastKickTimestamp = timer.elapsed().total_seconds();
myClientKickCounterList.insert(nick, tmpInfos); myClientKickCounterList.insert(nick, tmpInfos);
} }
} }
} } else {
else {
ClientWarnInfos tmpInfos; ClientWarnInfos tmpInfos;
tmpInfos.warnLevel = i.value().warnLevel+1; tmpInfos.warnLevel = i.value().warnLevel+1;
tmpInfos.lastWarnType = offence; tmpInfos.lastWarnType = offence;
@@ -139,20 +136,18 @@ QStringList MessageFilter::check(unsigned playerId, QString nick, QString msg)
returnMessage = QString ("%1: Warning: You've triggered url spam protection, stop posting urls!\n").arg(nick); returnMessage = QString ("%1: Warning: You've triggered url spam protection, stop posting urls!\n").arg(nick);
} }
break; break;
default:; default:
;
} }
returnAction = QString("warn"); returnAction = QString("warn");
} } else if(action == KICK) {
else if(action == KICK) {
returnMessage = QString("%1 kicked! Please respect: http://chatrules.pokerth.net\n").arg(nick); returnMessage = QString("%1 kicked! Please respect: http://chatrules.pokerth.net\n").arg(nick);
returnAction = QString("kick"); returnAction = QString("kick");
} } else if(action == KICKBAN) {
else if(action == KICKBAN) {
returnMessage = QString("%1 kicked and banned! Please respect: http://chatrules.pokerth.net\n").arg(nick); returnMessage = QString("%1 kicked and banned! Please respect: http://chatrules.pokerth.net\n").arg(nick);
returnAction = QString("kickban"); returnAction = QString("kickban");
} }
} } else {
else {
returnAction = QString(""); returnAction = QString("");
returnMessage = QString(""); returnMessage = QString("");
} }
@@ -161,7 +156,8 @@ QStringList MessageFilter::check(unsigned playerId, QString nick, QString msg)
return returnList; return returnList;
} }
void MessageFilter::refreshConfig() { void MessageFilter::refreshConfig()
{
// global settings // global settings
warnLevelToKick = config->readConfigInt("WarnLevelToKick"); warnLevelToKick = config->readConfigInt("WarnLevelToKick");
+2 -1
View File
@@ -12,7 +12,8 @@ class CapsFloodCheck;
class LetterRepeatingCheck; class LetterRepeatingCheck;
class UrlCheck; class UrlCheck;
class MessageFilter: public QObject { class MessageFilter: public QObject
{
Q_OBJECT Q_OBJECT
public: public:
MessageFilter(CleanerConfig*); MessageFilter(CleanerConfig*);
+10 -11
View File
@@ -19,7 +19,8 @@ TextFloodCheck::~TextFloodCheck()
delete cleanTimer; delete cleanTimer;
} }
bool TextFloodCheck::run(unsigned playerId) { bool TextFloodCheck::run(unsigned playerId)
{
QMapIterator<unsigned, TextFloodInfos> it(msgTimesList); QMapIterator<unsigned, TextFloodInfos> it(msgTimesList);
while (it.hasNext()) { while (it.hasNext()) {
@@ -35,8 +36,7 @@ bool TextFloodCheck::run(unsigned playerId) {
tmpInfos1.timeStamp = timer.elapsed().total_seconds(); tmpInfos1.timeStamp = timer.elapsed().total_seconds();
msgTimesList.insert(playerId, tmpInfos1); msgTimesList.insert(playerId, tmpInfos1);
qDebug () << "Add Player: set player floodlevel to " << tmpInfos1.floodLevel; qDebug () << "Add Player: set player floodlevel to " << tmpInfos1.floodLevel;
} } else {
else {
TextFloodInfos tmpInfos2; TextFloodInfos tmpInfos2;
if(timer.elapsed().total_seconds()-i.value().timeStamp <= 1) { if(timer.elapsed().total_seconds()-i.value().timeStamp <= 1) {
if(i.value().floodLevel == textFloodLevelToTrigger) { if(i.value().floodLevel == textFloodLevelToTrigger) {
@@ -46,13 +46,11 @@ bool TextFloodCheck::run(unsigned playerId) {
qDebug () << "Trigger: set player floodlevel to " << tmpInfos3.floodLevel; qDebug () << "Trigger: set player floodlevel to " << tmpInfos3.floodLevel;
msgTimesList.insert(playerId, tmpInfos3); msgTimesList.insert(playerId, tmpInfos3);
return true; return true;
} } else {
else {
tmpInfos2.floodLevel = i.value().floodLevel+1; tmpInfos2.floodLevel = i.value().floodLevel+1;
qDebug () << "Raise: set player floodlevel to " << tmpInfos2.floodLevel << " from " << i.value().floodLevel; qDebug () << "Raise: set player floodlevel to " << tmpInfos2.floodLevel << " from " << i.value().floodLevel;
} }
} } else {
else {
tmpInfos2.floodLevel = i.value().floodLevel; tmpInfos2.floodLevel = i.value().floodLevel;
qDebug () << "Keep: player floodlevel is " << tmpInfos2.floodLevel << " from " << i.value().floodLevel; qDebug () << "Keep: player floodlevel is " << tmpInfos2.floodLevel << " from " << i.value().floodLevel;
} }
@@ -63,7 +61,8 @@ bool TextFloodCheck::run(unsigned playerId) {
return false; return false;
} }
void TextFloodCheck::cleanMsgTimesList() { void TextFloodCheck::cleanMsgTimesList()
{
QMapIterator<unsigned, TextFloodInfos> it(msgTimesList); QMapIterator<unsigned, TextFloodInfos> it(msgTimesList);
while (it.hasNext()) { while (it.hasNext()) {
@@ -73,8 +72,7 @@ void TextFloodCheck::cleanMsgTimesList() {
if(it.value().floodLevel == 0) { if(it.value().floodLevel == 0) {
msgTimesList.remove(it.key()); msgTimesList.remove(it.key());
qDebug () << "Refresh: player removed from List"; qDebug () << "Refresh: player removed from List";
} } else {
else {
TextFloodInfos tmpInfos; TextFloodInfos tmpInfos;
tmpInfos.floodLevel = it.value().floodLevel-1; tmpInfos.floodLevel = it.value().floodLevel-1;
tmpInfos.timeStamp = it.value().timeStamp; tmpInfos.timeStamp = it.value().timeStamp;
@@ -86,7 +84,8 @@ void TextFloodCheck::cleanMsgTimesList() {
} }
} }
void TextFloodCheck::removeNickFromList(unsigned playerId) { void TextFloodCheck::removeNickFromList(unsigned playerId)
{
// qDebug() << "id " << playerId << "removed from textfloodcheck list" << endl; // qDebug() << "id " << playerId << "removed from textfloodcheck list" << endl;
msgTimesList.remove(playerId); msgTimesList.remove(playerId);
+3 -1
View File
@@ -13,7 +13,9 @@ public:
TextFloodCheck(); TextFloodCheck();
~TextFloodCheck(); ~TextFloodCheck();
void setTextFloodLevelToTrigger(int level) { textFloodLevelToTrigger = level; } void setTextFloodLevelToTrigger(int level) {
textFloodLevelToTrigger = level;
}
bool run(unsigned); bool run(unsigned);
+3 -1
View File
@@ -22,7 +22,9 @@ bool UrlCheck::run(QString msg)
break; break;
} }
} }
if(!exception) { return true; } if(!exception) {
return true;
}
} }
} }
return false; return false;
+9 -4
View File
@@ -3,13 +3,18 @@
#include <QtCore> #include <QtCore>
class UrlCheck: public QObject { class UrlCheck: public QObject
Q_OBJECT {
Q_OBJECT
public: public:
UrlCheck(); UrlCheck();
void setUrlStrings(QStringList us) { urlStrings = us; } void setUrlStrings(QStringList us) {
void setUrlExceptionStrings(QStringList ues) { urlExceptionStrings = ues; } urlStrings = us;
}
void setUrlExceptionStrings(QStringList ues) {
urlExceptionStrings = ues;
}
bool run(QString); bool run(QString);
private: private:
+24 -17
View File
@@ -60,8 +60,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
const char *appDataPath = getenv("AppData"); const char *appDataPath = getenv("AppData");
if (appDataPath && appDataPath[0] != 0) { if (appDataPath && appDataPath[0] != 0) {
configFileName = appDataPath; configFileName = appDataPath;
} } else {
else {
const int MaxPathSize = 1024; const int MaxPathSize = 1024;
char curDir[MaxPathSize + 1]; char curDir[MaxPathSize + 1];
curDir[0] = 0; curDir[0] = 0;
@@ -77,8 +76,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
// Datei wieder loeschen. // Datei wieder loeschen.
tmpFile.close(); tmpFile.close();
remove((configFileName + "\\" + tmpFileName).c_str()); remove((configFileName + "\\" + tmpFileName).c_str());
} } else {
else {
// Fehlgeschlagen, Verzeichnis nicht beschreibbar // Fehlgeschlagen, Verzeichnis nicht beschreibbar
curDir[0] = 0; curDir[0] = 0;
GetTempPathA(MaxPathSize, curDir); GetTempPathA(MaxPathSize, curDir);
@@ -298,18 +296,19 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
//Prüfen ob Configfile existiert --> sonst anlegen //Prüfen ob Configfile existiert --> sonst anlegen
TiXmlDocument doc(configFileName); TiXmlDocument doc(configFileName);
if(!doc.LoadFile()){ if(!doc.LoadFile()) {
myConfigState = NONEXISTING; myConfigState = NONEXISTING;
updateConfig(myConfigState); updateConfig(myConfigState);
} } else {
else {
//Check if config revision and AppDataDir is ok. Otherwise --> update() //Check if config revision and AppDataDir is ok. Otherwise --> update()
int tempRevision = 0; int tempRevision = 0;
string tempAppDataPath (""); string tempAppDataPath ("");
TiXmlHandle docHandle( &doc ); TiXmlHandle docHandle( &doc );
TiXmlElement* confRevision = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( "ConfigRevision" ).ToElement(); TiXmlElement* confRevision = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( "ConfigRevision" ).ToElement();
if ( confRevision ) { confRevision->QueryIntAttribute("value", &tempRevision ); } if ( confRevision ) {
confRevision->QueryIntAttribute("value", &tempRevision );
}
TiXmlElement* confAppDataPath = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( "AppDataDir" ).ToElement(); TiXmlElement* confAppDataPath = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( "AppDataDir" ).ToElement();
if ( confAppDataPath ) { if ( confAppDataPath ) {
const char *tmpStr = confAppDataPath->Attribute("value"); const char *tmpStr = confAppDataPath->Attribute("value");
@@ -339,7 +338,8 @@ ConfigFile::~ConfigFile()
} }
void ConfigFile::fillBuffer() { void ConfigFile::fillBuffer()
{
boost::recursive_mutex::scoped_lock lock(m_configMutex); boost::recursive_mutex::scoped_lock lock(m_configMutex);
@@ -379,15 +379,17 @@ void ConfigFile::fillBuffer() {
} }
} else {
LOG_ERROR("Could not find the root element in the config file!");
} }
else { LOG_ERROR("Could not find the root element in the config file!"); }
// cout << configBufferList[i].name << " " << configBufferList[i].defaultValue << endl; // cout << configBufferList[i].name << " " << configBufferList[i].defaultValue << endl;
} }
} }
} }
void ConfigFile::writeBuffer() const { void ConfigFile::writeBuffer() const
{
boost::recursive_mutex::scoped_lock lock(m_configMutex); boost::recursive_mutex::scoped_lock lock(m_configMutex);
@@ -430,7 +432,8 @@ void ConfigFile::writeBuffer() const {
} }
} }
void ConfigFile::updateConfig(ConfigState myConfigState) { void ConfigFile::updateConfig(ConfigState myConfigState)
{
boost::recursive_mutex::scoped_lock lock(m_configMutex); boost::recursive_mutex::scoped_lock lock(m_configMutex);
@@ -554,8 +557,7 @@ void ConfigFile::updateConfig(ConfigState myConfigState) {
} }
} }
} }
} } else {
else {
// if element is not there --> set it with defaultValue // if element is not there --> set it with defaultValue
TiXmlElement *tmpElement = new TiXmlElement(configList[i].name); TiXmlElement *tmpElement = new TiXmlElement(configList[i].name);
config->LinkEndChild( tmpElement ); config->LinkEndChild( tmpElement );
@@ -576,8 +578,9 @@ void ConfigFile::updateConfig(ConfigState myConfigState) {
} }
} }
newDoc.SaveFile( configFileName ); newDoc.SaveFile( configFileName );
} else {
LOG_ERROR("Cannot update config file: Unable to load configuration.");
} }
else { LOG_ERROR("Cannot update config file: Unable to load configuration."); }
} }
@@ -719,7 +722,9 @@ void ConfigFile::writeConfigString(string varName, string varCont)
size_t i; size_t i;
for (i=0; i<configBufferList.size(); i++) { for (i=0; i<configBufferList.size(); i++) {
if (configBufferList[i].name == varName) { configBufferList[i].defaultValue = varCont; } if (configBufferList[i].name == varName) {
configBufferList[i].defaultValue = varCont;
}
} }
} }
@@ -731,7 +736,9 @@ void ConfigFile::writeConfigStringList(string varName, list<string> varCont)
size_t i; size_t i;
for (i=0; i<configBufferList.size(); i++) { for (i=0; i<configBufferList.size(); i++) {
if (configBufferList[i].name == varName) { configBufferList[i].defaultListValue = varCont; } if (configBufferList[i].name == varName) {
configBufferList[i].defaultListValue = varCont;
}
} }
} }
+6 -4
View File
@@ -30,7 +30,8 @@ enum ConfigType { CONFIG_TYPE_INT, CONFIG_TYPE_STRING, CONFIG_TYPE_INT_LIST, CON
class QtToolsInterface; class QtToolsInterface;
class ConfigFile{ class ConfigFile
{
public: public:
ConfigFile(char *argv0, bool readonly); ConfigFile(char *argv0, bool readonly);
@@ -40,7 +41,9 @@ public:
void writeBuffer() const; void writeBuffer() const;
void updateConfig(ConfigState); void updateConfig(ConfigState);
ConfigState getConfigState() const { return myConfigState; } ConfigState getConfigState() const {
return myConfigState;
}
std::string readConfigString(std::string varName) const; std::string readConfigString(std::string varName) const;
std::list<std::string> readConfigStringList(std::string varName) const; std::list<std::string> readConfigStringList(std::string varName) const;
@@ -56,8 +59,7 @@ private:
mutable boost::recursive_mutex m_configMutex; 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) {} 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; std::string name;
ConfigType type; ConfigType type;
+39 -85
View File
@@ -56,23 +56,16 @@ PokerTHMessage_t *
receiveMessage(tcp::socket &socket) receiveMessage(tcp::socket &socket)
{ {
PokerTHMessage_t *msg = NULL; PokerTHMessage_t *msg = NULL;
do do {
{
asn_dec_rval_t retVal = ber_decode(0, &asn_DEF_PokerTHMessage, (void **)&msg, recBuf.data(), recBufPos); 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.code == RC_OK && msg != NULL) {
{ if (retVal.consumed < recBufPos) {
if (retVal.consumed < recBufPos)
{
recBufPos -= retVal.consumed; recBufPos -= retVal.consumed;
memmove(recBuf.c_array(), recBuf.c_array() + retVal.consumed, recBufPos); memmove(recBuf.c_array(), recBuf.c_array() + retVal.consumed, recBufPos);
} } else {
else
{
recBufPos = 0; recBufPos = 0;
} }
} } else {
else
{
// Free the partially decoded message (if applicable). // Free the partially decoded message (if applicable).
ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg); ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg);
msg = NULL; msg = NULL;
@@ -86,11 +79,9 @@ bool
sendMessage(tcp::socket &socket, PokerTHMessage_t *msg) sendMessage(tcp::socket &socket, PokerTHMessage_t *msg)
{ {
bool retVal = false; bool retVal = false;
if (msg) if (msg) {
{
asn_enc_rval_t e = der_encode_to_buffer(&asn_DEF_PokerTHMessage, msg, sendBuf.data(), BUF_SIZE); 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)); socket.send(boost::asio::buffer(sendBuf.data(), e.encoded));
retVal = true; retVal = true;
} }
@@ -102,8 +93,7 @@ sendMessage(tcp::socket &socket, PokerTHMessage_t *msg)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
try try {
{
// Check command line options. // Check command line options.
po::options_description desc("Allowed options"); po::options_description desc("Allowed options");
desc.add_options() desc.add_options()
@@ -119,13 +109,11 @@ main(int argc, char *argv[])
po::store(po::parse_command_line(argc, argv, desc), vm); po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm); po::notify(vm);
if (vm.count("help")) if (vm.count("help")) {
{
cout << desc << endl; cout << desc << endl;
return 1; 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; cout << "Missing option!" << endl << desc << endl;
return 1; return 1;
} }
@@ -135,22 +123,19 @@ main(int argc, char *argv[])
int mode = vm["mode"].as<int>(); int mode = vm["mode"].as<int>();
string username(vm["username"].as<string>()); string username(vm["username"].as<string>());
string password; string password;
if (vm.count("password")) if (vm.count("password")) {
{
password = vm["password"].as<string>(); password = vm["password"].as<string>();
} }
// Initialise gsasl. // Initialise gsasl.
Gsasl *authContext; Gsasl *authContext;
Gsasl_session *authSession; Gsasl_session *authSession;
int res = gsasl_init(&authContext); int res = gsasl_init(&authContext);
if (res != GSASL_OK) if (res != GSASL_OK) {
{
cout << "gsasl init failed" << endl; cout << "gsasl init failed" << endl;
return 1; return 1;
} }
if (!gsasl_client_support_p(authContext, "SCRAM-SHA-1")) if (!gsasl_client_support_p(authContext, "SCRAM-SHA-1")) {
{
gsasl_done(authContext); gsasl_done(authContext);
cout << "This version of gsasl does not support SCRAM-SHA-1" << endl; cout << "This version of gsasl does not support SCRAM-SHA-1" << endl;
return 1; return 1;
@@ -165,26 +150,22 @@ main(int argc, char *argv[])
tcp::resolver::iterator end; tcp::resolver::iterator end;
tcp::socket socket(io_service); tcp::socket socket(io_service);
boost::system::error_code error = boost::asio::error::host_not_found; boost::system::error_code error = boost::asio::error::host_not_found;
while (error && endpoint_iterator != end) while (error && endpoint_iterator != end) {
{
socket.close(); socket.close();
socket.connect(*endpoint_iterator++, error); socket.connect(*endpoint_iterator++, error);
} }
if (error) if (error) {
{
cout << "Connect failed" << endl; cout << "Connect failed" << endl;
return 1; return 1;
} }
if (mode == 1) if (mode == 1) {
{
cout << "Connect.value " << perfTimer.elapsed().total_milliseconds() << endl; cout << "Connect.value " << perfTimer.elapsed().total_milliseconds() << endl;
} }
perfTimer.restart(); perfTimer.restart();
// Receive server information // Receive server information
PokerTHMessage_t *msg = receiveMessage(socket); PokerTHMessage_t *msg = receiveMessage(socket);
if (!msg || msg->present != PokerTHMessage_PR_announceMessage) if (!msg || msg->present != PokerTHMessage_PR_announceMessage) {
{
cout << "Announce failed" << endl; cout << "Announce failed" << endl;
return 1; return 1;
} }
@@ -196,24 +177,19 @@ main(int argc, char *argv[])
InitMessage_t *netInit = &msg->choice.initMessage; InitMessage_t *netInit = &msg->choice.initMessage;
netInit->requestedVersion.major = 1; netInit->requestedVersion.major = 1;
netInit->requestedVersion.minor = 0; netInit->requestedVersion.minor = 0;
if (password.empty()) if (password.empty()) {
{
netInit->login.present = login_PR_guestLogin; netInit->login.present = login_PR_guestLogin;
GuestLogin_t *guestLogin = &netInit->login.choice.guestLogin; GuestLogin_t *guestLogin = &netInit->login.choice.guestLogin;
OCTET_STRING_fromBuf(&guestLogin->nickName, OCTET_STRING_fromBuf(&guestLogin->nickName,
username.c_str(), username.c_str(),
username.length()); username.length());
if (!sendMessage(socket, msg)) if (!sendMessage(socket, msg)) {
{
cout << "Init guest failed" << endl; cout << "Init guest failed" << endl;
return 1; return 1;
} }
} } else {
else
{
int errorCode = gsasl_client_start(authContext, "SCRAM-SHA-1", &authSession); 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_AUTHID, username.c_str());
gsasl_property_set(authSession, GSASL_PASSWORD, password.c_str()); gsasl_property_set(authSession, GSASL_PASSWORD, password.c_str());
@@ -224,12 +200,9 @@ main(int argc, char *argv[])
size_t tmpOutSize; size_t tmpOutSize;
string nextGsaslMsg; string nextGsaslMsg;
errorCode = gsasl_step(authSession, NULL, 0, &tmpOut, &tmpOutSize); errorCode = gsasl_step(authSession, NULL, 0, &tmpOut, &tmpOutSize);
if (errorCode == GSASL_NEEDS_MORE) if (errorCode == GSASL_NEEDS_MORE) {
{
nextGsaslMsg = string(tmpOut, tmpOutSize); nextGsaslMsg = string(tmpOut, tmpOutSize);
} } else {
else
{
cout << "gsasl step 1 failed" << endl; cout << "gsasl step 1 failed" << endl;
return 1; return 1;
} }
@@ -238,15 +211,13 @@ main(int argc, char *argv[])
OCTET_STRING_fromBuf(&authLogin->clientUserData, OCTET_STRING_fromBuf(&authLogin->clientUserData,
nextGsaslMsg.c_str(), nextGsaslMsg.c_str(),
nextGsaslMsg.length()); nextGsaslMsg.length());
if (!sendMessage(socket, msg)) if (!sendMessage(socket, msg)) {
{
cout << "Init auth request failed" << endl; cout << "Init auth request failed" << endl;
return 1; return 1;
} }
msg = receiveMessage(socket); msg = receiveMessage(socket);
if (!msg || msg->present != PokerTHMessage_PR_authMessage) if (!msg || msg->present != PokerTHMessage_PR_authMessage) {
{
cout << "Auth request failed" << endl; cout << "Auth request failed" << endl;
return 1; return 1;
} }
@@ -255,12 +226,9 @@ main(int argc, char *argv[])
AuthServerChallenge_t *netChallenge = &netAuth->choice.authServerChallenge; AuthServerChallenge_t *netChallenge = &netAuth->choice.authServerChallenge;
string challengeStr = STL_STRING_FROM_OCTET_STRING(netChallenge->serverChallenge); string challengeStr = STL_STRING_FROM_OCTET_STRING(netChallenge->serverChallenge);
errorCode = gsasl_step(authSession, challengeStr.c_str(), challengeStr.size(), &tmpOut, &tmpOutSize); 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); nextGsaslMsg = string(tmpOut, tmpOutSize);
} } else {
else
{
cout << "gsasl step 2 failed" << endl; cout << "gsasl step 2 failed" << endl;
return 1; return 1;
} }
@@ -275,14 +243,12 @@ main(int argc, char *argv[])
OCTET_STRING_fromBuf(&outResponse->clientResponse, OCTET_STRING_fromBuf(&outResponse->clientResponse,
nextGsaslMsg.c_str(), nextGsaslMsg.c_str(),
nextGsaslMsg.length()); nextGsaslMsg.length());
if (!sendMessage(socket, msg)) if (!sendMessage(socket, msg)) {
{
cout << "Init auth response failed" << endl; cout << "Init auth response failed" << endl;
return 1; return 1;
} }
msg = receiveMessage(socket); msg = receiveMessage(socket);
if (!msg || msg->present != PokerTHMessage_PR_authMessage) if (!msg || msg->present != PokerTHMessage_PR_authMessage) {
{
cout << "Auth response failed" << endl; cout << "Auth response failed" << endl;
return 1; return 1;
} }
@@ -291,15 +257,13 @@ main(int argc, char *argv[])
// Receive init ack // Receive init ack
msg = receiveMessage(socket); msg = receiveMessage(socket);
if (!msg || msg->present != PokerTHMessage_PR_initAckMessage) if (!msg || msg->present != PokerTHMessage_PR_initAckMessage) {
{
cout << "Init ack failed" << endl; cout << "Init ack failed" << endl;
return 1; return 1;
} }
ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg); ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg);
if (mode == 1) if (mode == 1) {
{
cout << "Init.value " << perfTimer.elapsed().total_milliseconds() << endl; cout << "Init.value " << perfTimer.elapsed().total_milliseconds() << endl;
} }
perfTimer.restart(); perfTimer.restart();
@@ -330,48 +294,38 @@ main(int argc, char *argv[])
OCTET_STRING_fromBuf(&joinNew->gameInfo.gameName, OCTET_STRING_fromBuf(&joinNew->gameInfo.gameName,
tmpGameName.c_str(), tmpGameName.c_str(),
tmpGameName.length()); tmpGameName.length());
if (!sendMessage(socket, msg)) if (!sendMessage(socket, msg)) {
{
cout << "Create game failed" << endl; cout << "Create game failed" << endl;
return 1; return 1;
} }
msg = NULL; msg = NULL;
// Receive join game ack // Receive join game ack
do do {
{
ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg); ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg);
msg = receiveMessage(socket); msg = receiveMessage(socket);
if (!msg) if (!msg) {
{
cout << "Receive in lobby failed" << endl; cout << "Receive in lobby failed" << endl;
return 1; return 1;
} }
if (msg->present == PokerTHMessage_PR_errorMessage) if (msg->present == PokerTHMessage_PR_errorMessage) {
{
cout << "Received error" << endl; cout << "Received error" << endl;
return 1; return 1;
} }
} while (msg->present != PokerTHMessage_PR_joinGameReplyMessage); } 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; cout << "Join game ack failed" << endl;
return 1; return 1;
} }
ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg); ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg);
if (mode == 1) if (mode == 1) {
{
cout << "CreateGame.value " << perfTimer.elapsed().total_milliseconds() << endl; cout << "CreateGame.value " << perfTimer.elapsed().total_milliseconds() << endl;
} } else {
else
{
cout << "Success" << endl; cout << "Success" << endl;
} }
perfTimer.restart(); perfTimer.restart();
gsasl_done(authContext); gsasl_done(authContext);
} } catch (...) {
catch (...)
{
cout << "Exception caught" << endl; cout << "Exception caught" << endl;
return 1; return 1;
} }
+58 -116
View File
@@ -48,14 +48,13 @@
using namespace std; using namespace std;
using namespace boost::filesystem; using namespace boost::filesystem;
struct AvatarFileState struct AvatarFileState {
{
ifstream inputStream; ifstream inputStream;
}; };
AvatarManager::AvatarManager(bool useExternalServer, const std::string &externalServerAddress, AvatarManager::AvatarManager(bool useExternalServer, const std::string &externalServerAddress,
const string &externalServerUser, const string &externalServerPassword) const string &externalServerUser, const string &externalServerPassword)
: m_useExternalServer(useExternalServer), m_externalServerAddress(externalServerAddress), : m_useExternalServer(useExternalServer), m_externalServerAddress(externalServerAddress),
m_externalServerUser(externalServerUser), m_externalServerPassword(externalServerPassword) m_externalServerUser(externalServerUser), m_externalServerPassword(externalServerPassword)
{ {
m_uploader.reset(new UploaderThread()); m_uploader.reset(new UploaderThread());
@@ -87,8 +86,7 @@ AvatarManager::Init(const string &dataDir, const string &cacheDir)
} }
if (cacheDir.empty() || tmpCachePath.empty()) if (cacheDir.empty() || tmpCachePath.empty())
LOG_ERROR("Cache directory was not set!"); LOG_ERROR("Cache directory was not set!");
else else {
{
boost::mutex::scoped_lock lock(m_cachedAvatarsMutex); boost::mutex::scoped_lock lock(m_cachedAvatarsMutex);
tmpRet = InternalReadDirectory(tmpCachePath.directory_string(), m_cachedAvatars); tmpRet = InternalReadDirectory(tmpCachePath.directory_string(), m_cachedAvatars);
retVal = retVal && tmpRet; retVal = retVal && tmpRet;
@@ -105,20 +103,17 @@ AvatarManager::AddSingleAvatar(const std::string &fileName)
path filePath(fileName); path filePath(fileName);
string tmpFileName(filePath.file_string()); string tmpFileName(filePath.file_string());
if (!fileName.empty() && !tmpFileName.empty()) if (!fileName.empty() && !tmpFileName.empty()) {
{
unsigned outFileSize = 0; unsigned outFileSize = 0;
AvatarFileType outFileType; AvatarFileType outFileType;
boost::shared_ptr<AvatarFileState> tmpFileState = OpenAvatarFileForChunkRead(tmpFileName, outFileSize, outFileType); boost::shared_ptr<AvatarFileState> tmpFileState = OpenAvatarFileForChunkRead(tmpFileName, outFileSize, outFileType);
// Check whether the avatar file is valid. // Check whether the avatar file is valid.
if (tmpFileState.get()) if (tmpFileState.get()) {
{
tmpFileState.reset(); tmpFileState.reset();
MD5Buf md5buf; MD5Buf md5buf;
if (CryptHelper::MD5Sum(tmpFileName, md5buf)) if (CryptHelper::MD5Sum(tmpFileName, md5buf)) {
{
boost::mutex::scoped_lock lock(m_avatarsMutex); boost::mutex::scoped_lock lock(m_avatarsMutex);
m_avatars.insert(AvatarMap::value_type(md5buf, tmpFileName)); m_avatars.insert(AvatarMap::value_type(md5buf, tmpFileName));
retVal = true; retVal = true;
@@ -133,13 +128,11 @@ AvatarManager::OpenAvatarFileForChunkRead(const std::string &fileName, unsigned
{ {
outFileSize = 0; outFileSize = 0;
boost::shared_ptr<AvatarFileState> retVal; boost::shared_ptr<AvatarFileState> retVal;
try try {
{
outFileType = GetAvatarFileType(fileName); outFileType = GetAvatarFileType(fileName);
boost::shared_ptr<AvatarFileState> fileState(new AvatarFileState); boost::shared_ptr<AvatarFileState> fileState(new AvatarFileState);
fileState->inputStream.open(fileName.c_str(), ios_base::in | ios_base::binary); fileState->inputStream.open(fileName.c_str(), ios_base::in | ios_base::binary);
if (!fileState->inputStream.fail()) if (!fileState->inputStream.fail()) {
{
// Find out file size. // Find out file size.
// Not fully portable, but works on win/linux/mac. // Not fully portable, but works on win/linux/mac.
fileState->inputStream.seekg(0, ios_base::beg); 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); fileState->inputStream.seekg(0, ios_base::beg);
std::streamoff posDiff(endPos - startPos); std::streamoff posDiff(endPos - startPos);
outFileSize = (unsigned)posDiff; 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. // Validate type of file by verifying image header.
unsigned char fileHeader[MAX_HEADER_SIZE]; unsigned char fileHeader[MAX_HEADER_SIZE];
fileState->inputStream.read((char *)fileHeader, sizeof(fileHeader)); fileState->inputStream.read((char *)fileHeader, sizeof(fileHeader));
@@ -160,8 +152,7 @@ AvatarManager::OpenAvatarFileForChunkRead(const std::string &fileName, unsigned
retVal = fileState; retVal = fileState;
} }
} }
} catch (...) } catch (...) {
{
LOG_ERROR("Exception caught when trying to open avatar."); LOG_ERROR("Exception caught when trying to open avatar.");
} }
return retVal; return retVal;
@@ -171,17 +162,13 @@ unsigned
AvatarManager::ChunkReadAvatarFile(boost::shared_ptr<AvatarFileState> fileState, unsigned char *data, unsigned chunkSize) AvatarManager::ChunkReadAvatarFile(boost::shared_ptr<AvatarFileState> fileState, unsigned char *data, unsigned chunkSize)
{ {
unsigned retVal = 0; unsigned retVal = 0;
if (fileState.get()) if (fileState.get()) {
{ try {
try if (!fileState->inputStream.fail() && !fileState->inputStream.eof()) {
{
if (!fileState->inputStream.fail() && !fileState->inputStream.eof())
{
fileState->inputStream.read((char *)data, chunkSize); fileState->inputStream.read((char *)data, chunkSize);
retVal = fileState->inputStream.gcount(); retVal = fileState->inputStream.gcount();
} }
} catch (...) } catch (...) {
{
LOG_ERROR("Exception caught when trying to read avatar."); LOG_ERROR("Exception caught when trying to read avatar.");
} }
} }
@@ -195,8 +182,7 @@ AvatarManager::AvatarFileToNetPackets(const string &fileName, unsigned requestId
unsigned fileSize = 0; unsigned fileSize = 0;
AvatarFileType fileType; AvatarFileType fileType;
boost::shared_ptr<AvatarFileState> tmpState = OpenAvatarFileForChunkRead(fileName, fileSize, 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)); boost::shared_ptr<NetPacket> avatarHeader(new NetPacket(NetPacket::Alloc));
avatarHeader->GetMsg()->present = PokerTHMessage_PR_avatarReplyMessage; avatarHeader->GetMsg()->present = PokerTHMessage_PR_avatarReplyMessage;
AvatarReplyMessage_t *netHeader = &avatarHeader->GetMsg()->choice.avatarReplyMessage; AvatarReplyMessage_t *netHeader = &avatarHeader->GetMsg()->choice.avatarReplyMessage;
@@ -209,11 +195,9 @@ AvatarManager::AvatarFileToNetPackets(const string &fileName, unsigned requestId
unsigned numBytes = 0; unsigned numBytes = 0;
unsigned totalBytesRead = 0; unsigned totalBytesRead = 0;
vector<unsigned char> tmpData(MAX_FILE_DATA_SIZE); vector<unsigned char> tmpData(MAX_FILE_DATA_SIZE);
do do {
{
numBytes = ChunkReadAvatarFile(tmpState, &tmpData[0], MAX_FILE_DATA_SIZE); numBytes = ChunkReadAvatarFile(tmpState, &tmpData[0], MAX_FILE_DATA_SIZE);
if (numBytes) if (numBytes) {
{
totalBytesRead += numBytes; totalBytesRead += numBytes;
boost::shared_ptr<NetPacket> avatarFile(new NetPacket(NetPacket::Alloc)); boost::shared_ptr<NetPacket> avatarFile(new NetPacket(NetPacket::Alloc));
@@ -231,8 +215,7 @@ AvatarManager::AvatarFileToNetPackets(const string &fileName, unsigned requestId
if (fileSize != totalBytesRead) if (fileSize != totalBytesRead)
retVal = ERR_NET_WRONG_AVATAR_SIZE; retVal = ERR_NET_WRONG_AVATAR_SIZE;
else else {
{
boost::shared_ptr<NetPacket> avatarEnd(new NetPacket(NetPacket::Alloc)); boost::shared_ptr<NetPacket> avatarEnd(new NetPacket(NetPacket::Alloc));
avatarEnd->GetMsg()->present = PokerTHMessage_PR_avatarReplyMessage; avatarEnd->GetMsg()->present = PokerTHMessage_PR_avatarReplyMessage;
AvatarReplyMessage_t *netEnd = &avatarEnd->GetMsg()->choice.avatarReplyMessage; AvatarReplyMessage_t *netEnd = &avatarEnd->GetMsg()->choice.avatarReplyMessage;
@@ -268,8 +251,7 @@ string
AvatarManager::GetAvatarFileExtension(AvatarFileType fileType) AvatarManager::GetAvatarFileExtension(AvatarFileType fileType)
{ {
string ext; string ext;
switch (fileType) switch (fileType) {
{
case AVATAR_FILE_TYPE_PNG: case AVATAR_FILE_TYPE_PNG:
ext = ".png"; ext = ".png";
break; break;
@@ -289,17 +271,14 @@ bool
AvatarManager::GetHashForAvatar(const std::string &fileName, MD5Buf &md5buf) const AvatarManager::GetHashForAvatar(const std::string &fileName, MD5Buf &md5buf) const
{ {
bool found = false; bool found = false;
if (exists(fileName)) if (exists(fileName)) {
{
// Scan default avatars first. // Scan default avatars first.
{ {
boost::mutex::scoped_lock lock(m_avatarsMutex); boost::mutex::scoped_lock lock(m_avatarsMutex);
AvatarMap::const_iterator i = m_avatars.begin(); AvatarMap::const_iterator i = m_avatars.begin();
AvatarMap::const_iterator end = m_avatars.end(); AvatarMap::const_iterator end = m_avatars.end();
while (i != end) while (i != end) {
{ if (i->second == fileName) {
if (i->second == fileName)
{
md5buf = i->first; md5buf = i->first;
found = true; found = true;
break; break;
@@ -308,15 +287,12 @@ AvatarManager::GetHashForAvatar(const std::string &fileName, MD5Buf &md5buf) con
} }
} }
// Check cached avatars next. // Check cached avatars next.
if (!found) if (!found) {
{
boost::mutex::scoped_lock lock(m_cachedAvatarsMutex); boost::mutex::scoped_lock lock(m_cachedAvatarsMutex);
AvatarMap::const_iterator i = m_cachedAvatars.begin(); AvatarMap::const_iterator i = m_cachedAvatars.begin();
AvatarMap::const_iterator end = m_cachedAvatars.end(); AvatarMap::const_iterator end = m_cachedAvatars.end();
while (i != end) while (i != end) {
{ if (i->second == fileName) {
if (i->second == fileName)
{
md5buf = i->first; md5buf = i->first;
found = true; found = true;
break; break;
@@ -326,8 +302,7 @@ AvatarManager::GetHashForAvatar(const std::string &fileName, MD5Buf &md5buf) con
} }
// Calculate md5 sum if not found. // Calculate md5 sum if not found.
if (!found) if (!found) {
{
if (CryptHelper::MD5Sum(fileName, md5buf)) if (CryptHelper::MD5Sum(fileName, md5buf))
found = true; found = true;
} }
@@ -342,18 +317,15 @@ AvatarManager::GetAvatarFileName(const MD5Buf &md5buf, std::string &fileName) co
{ {
boost::mutex::scoped_lock lock(m_avatarsMutex); boost::mutex::scoped_lock lock(m_avatarsMutex);
AvatarMap::const_iterator pos = m_avatars.find(md5buf); AvatarMap::const_iterator pos = m_avatars.find(md5buf);
if (pos != m_avatars.end()) if (pos != m_avatars.end()) {
{
fileName = pos->second; fileName = pos->second;
retVal = true; retVal = true;
} }
} }
if (!retVal) if (!retVal) {
{
boost::mutex::scoped_lock lock(m_cachedAvatarsMutex); boost::mutex::scoped_lock lock(m_cachedAvatarsMutex);
AvatarMap::const_iterator pos = m_cachedAvatars.find(md5buf); AvatarMap::const_iterator pos = m_cachedAvatars.find(md5buf);
if (pos != m_cachedAvatars.end()) if (pos != m_cachedAvatars.end()) {
{
fileName = pos->second; fileName = pos->second;
retVal = true; retVal = true;
} }
@@ -377,24 +349,19 @@ AvatarManager::StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFil
boost::mutex::scoped_lock lock(m_cacheDirMutex); boost::mutex::scoped_lock lock(m_cacheDirMutex);
cacheDir = m_cacheDir; cacheDir = m_cacheDir;
} }
try try {
{
string ext(GetAvatarFileExtension(avatarFileType)); string ext(GetAvatarFileExtension(avatarFileType));
if (!ext.empty() && !cacheDir.empty()) if (!ext.empty() && !cacheDir.empty()) {
{
// Check header before storing file. // Check header before storing file.
if (IsValidAvatarFileType(avatarFileType, data, size)) if (IsValidAvatarFileType(avatarFileType, data, size)) {
{
path tmpPath(cacheDir); path tmpPath(cacheDir);
tmpPath /= (md5buf.ToString() + ext); tmpPath /= (md5buf.ToString() + ext);
string fileName(tmpPath.file_string()); string fileName(tmpPath.file_string());
ofstream o(fileName.c_str(), ios_base::out | ios_base::binary | ios_base::trunc); 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.write((const char *)data, size);
o.close(); o.close();
if (upload && m_useExternalServer) if (upload && m_useExternalServer) {
{
m_uploader->QueueUpload(m_externalServerAddress, m_externalServerUser, m_externalServerPassword, fileName, size); 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."); LOG_ERROR("Exception caught when trying to store avatar.");
} }
return retVal; return retVal;
@@ -418,27 +384,23 @@ AvatarManager::IsValidAvatarFileType(AvatarFileType avatarFileType, const unsign
{ {
bool validType = false; bool validType = false;
switch (avatarFileType) switch (avatarFileType) {
{
case AVATAR_FILE_TYPE_PNG: case AVATAR_FILE_TYPE_PNG:
if (fileHeaderSize >= PNG_HEADER_SIZE if (fileHeaderSize >= PNG_HEADER_SIZE
&& memcmp(fileHeader, PNG_HEADER, PNG_HEADER_SIZE) == 0) && memcmp(fileHeader, PNG_HEADER, PNG_HEADER_SIZE) == 0) {
{
validType = true; validType = true;
} }
break; break;
case AVATAR_FILE_TYPE_JPG: case AVATAR_FILE_TYPE_JPG:
if (fileHeaderSize >= JPG_HEADER_SIZE if (fileHeaderSize >= JPG_HEADER_SIZE
&& memcmp(fileHeader, JPG_HEADER, JPG_HEADER_SIZE) == 0) && memcmp(fileHeader, JPG_HEADER, JPG_HEADER_SIZE) == 0) {
{
validType = true; validType = true;
} }
break; break;
case AVATAR_FILE_TYPE_GIF: case AVATAR_FILE_TYPE_GIF:
if (fileHeaderSize >= GIF_HEADER_SIZE if (fileHeaderSize >= GIF_HEADER_SIZE
&& (memcmp(fileHeader, GIF_HEADER_1, GIF_HEADER_SIZE) == 0 && (memcmp(fileHeader, GIF_HEADER_1, GIF_HEADER_SIZE) == 0
|| memcmp(fileHeader, GIF_HEADER_2, GIF_HEADER_SIZE) == 0)) || memcmp(fileHeader, GIF_HEADER_2, GIF_HEADER_SIZE) == 0)) {
{
validType = true; validType = true;
} }
break; break;
@@ -456,13 +418,11 @@ AvatarManager::RemoveOldAvatarCacheEntries()
boost::mutex::scoped_lock lock(m_cacheDirMutex); boost::mutex::scoped_lock lock(m_cacheDirMutex);
cacheDir = m_cacheDir; cacheDir = m_cacheDir;
} }
try try {
{
path cachePath(cacheDir); path cachePath(cacheDir);
cacheDir = cachePath.directory_string(); cacheDir = cachePath.directory_string();
// Never delete anything if we do not have a special cache dir set. // 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); boost::mutex::scoped_lock lock(m_cachedAvatarsMutex);
// First pass: Remove files which no longer exist. // First pass: Remove files which no longer exist.
@@ -473,18 +433,15 @@ AvatarManager::RemoveOldAvatarCacheEntries()
{ {
AvatarMap::const_iterator i = m_cachedAvatars.begin(); AvatarMap::const_iterator i = m_cachedAvatars.begin();
AvatarMap::const_iterator end = m_cachedAvatars.end(); AvatarMap::const_iterator end = m_cachedAvatars.end();
while (i != end) while (i != end) {
{
bool keepFile = false; bool keepFile = false;
path filePath(i->second); path filePath(i->second);
string fileString(filePath.file_string()); string fileString(filePath.file_string());
// Only consider files which are definitely in the cache dir. // 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. // Only consider files with MD5 as file name.
MD5Buf tmpBuf; MD5Buf tmpBuf;
if (exists(filePath) && tmpBuf.FromString(basename(filePath))) if (exists(filePath) && tmpBuf.FromString(basename(filePath))) {
{
++fileCount; ++fileCount;
timeMap.insert(TimeAvatarMap::value_type(last_write_time(filePath), i->first)); timeMap.insert(TimeAvatarMap::value_type(last_write_time(filePath), i->first));
keepFile = true; keepFile = true;
@@ -500,8 +457,7 @@ AvatarManager::RemoveOldAvatarCacheEntries()
{ {
AvatarList::const_iterator i = removeList.begin(); AvatarList::const_iterator i = removeList.begin();
AvatarList::const_iterator end = removeList.end(); AvatarList::const_iterator end = removeList.end();
while (i != end) while (i != end) {
{
m_cachedAvatars.erase(*i); m_cachedAvatars.erase(*i);
++i; ++i;
} }
@@ -514,14 +470,11 @@ AvatarManager::RemoveOldAvatarCacheEntries()
// - delete until only MAX_NUMBER_OF_FILES/2 are left. // - delete until only MAX_NUMBER_OF_FILES/2 are left.
// 2. Files are older than 30 days. // 2. Files are older than 30 days.
if (m_cachedAvatars.size() > MAX_NUMBER_OF_FILES) if (m_cachedAvatars.size() > MAX_NUMBER_OF_FILES) {
{ while (!timeMap.empty() && m_cachedAvatars.size() > MAX_NUMBER_OF_FILES / 2) {
while (!timeMap.empty() && m_cachedAvatars.size() > MAX_NUMBER_OF_FILES / 2)
{
TimeAvatarMap::iterator i = timeMap.begin(); TimeAvatarMap::iterator i = timeMap.begin();
AvatarMap::iterator pos = m_cachedAvatars.find(i->second); AvatarMap::iterator pos = m_cachedAvatars.find(i->second);
if (pos != m_cachedAvatars.end()) if (pos != m_cachedAvatars.end()) {
{
path tmpPath(pos->second); path tmpPath(pos->second);
remove(tmpPath); remove(tmpPath);
m_cachedAvatars.erase(pos); m_cachedAvatars.erase(pos);
@@ -532,14 +485,12 @@ AvatarManager::RemoveOldAvatarCacheEntries()
// Get reference time. // Get reference time.
time_t curTime = time(NULL); time_t curTime = time(NULL);
while (!timeMap.empty() && !m_cachedAvatars.empty()) while (!timeMap.empty() && !m_cachedAvatars.empty()) {
{
TimeAvatarMap::iterator i = timeMap.begin(); TimeAvatarMap::iterator i = timeMap.begin();
if (curTime - i->first < (int)MAX_AVATAR_CACHE_AGE) if (curTime - i->first < (int)MAX_AVATAR_CACHE_AGE)
break; break;
AvatarMap::iterator pos = m_cachedAvatars.find(i->second); AvatarMap::iterator pos = m_cachedAvatars.find(i->second);
if (pos != m_cachedAvatars.end()) if (pos != m_cachedAvatars.end()) {
{
path tmpPath(pos->second); path tmpPath(pos->second);
remove(tmpPath); remove(tmpPath);
m_cachedAvatars.erase(pos); m_cachedAvatars.erase(pos);
@@ -547,8 +498,7 @@ AvatarManager::RemoveOldAvatarCacheEntries()
timeMap.erase(i); timeMap.erase(i);
} }
} }
} catch (...) } catch (...) {
{
LOG_ERROR("Exception caught while cleaning up cache."); LOG_ERROR("Exception caught while cleaning up cache.");
} }
} }
@@ -559,37 +509,29 @@ AvatarManager::InternalReadDirectory(const std::string &dir, AvatarMap &avatars)
bool retVal = true; bool retVal = true;
path tmpPath(dir); path tmpPath(dir);
if (exists(tmpPath) && is_directory(tmpPath)) if (exists(tmpPath) && is_directory(tmpPath)) {
{ try {
try
{
// This method is not thread safe. Only call after locking the map. // This method is not thread safe. Only call after locking the map.
directory_iterator i(tmpPath); directory_iterator i(tmpPath);
directory_iterator end; directory_iterator end;
while (i != end) while (i != end) {
{ if (is_regular(i->status())) {
if (is_regular(i->status()))
{
string md5sum(basename(i->path())); string md5sum(basename(i->path()));
MD5Buf md5buf; MD5Buf md5buf;
string fileName(i->path().file_string()); string fileName(i->path().file_string());
if (md5buf.FromString(md5sum)) if (md5buf.FromString(md5sum)) {
{
// Only consider files with md5sum as name. // Only consider files with md5sum as name.
avatars.insert(AvatarMap::value_type(md5buf, fileName)); avatars.insert(AvatarMap::value_type(md5buf, fileName));
} }
} }
++i; ++i;
} }
} catch (...) } catch (...) {
{
LOG_ERROR("Exception caught when trying to scan avatar directory."); LOG_ERROR("Exception caught when trying to scan avatar directory.");
retVal = false; retVal = false;
} }
} } else {
else
{
LOG_ERROR("Avatar directory does not exist."); LOG_ERROR("Avatar directory does not exist.");
retVal = false; retVal = false;
} }
+20 -40
View File
@@ -53,8 +53,7 @@ HashBuf::ToString() const
char tmpBuf[2 + 1]; char tmpBuf[2 + 1];
tmpBuf[sizeof(tmpBuf) - 1] = 0; tmpBuf[sizeof(tmpBuf) - 1] = 0;
const unsigned char *tmpData = GetData(); const unsigned char *tmpData = GetData();
for (int i = 0; i < GetDataSize(); i++) for (int i = 0; i < GetDataSize(); i++) {
{
sprintf(tmpBuf, "%02x", tmpData[i]); sprintf(tmpBuf, "%02x", tmpData[i]);
retValue += tmpBuf; retValue += tmpBuf;
} }
@@ -67,8 +66,7 @@ HashBuf::FromString(const std::string &text)
// Convert hex-based string to MD5 data. // Convert hex-based string to MD5 data.
bool retVal = false; bool retVal = false;
int tmpSize = GetDataSize(); int tmpSize = GetDataSize();
if (text.size() == 2 * (unsigned)tmpSize) if (text.size() == 2 * (unsigned)tmpSize) {
{
unsigned char *tmpData = GetData(); unsigned char *tmpData = GetData();
const char *t = text.c_str(); const char *t = text.c_str();
int i = 0; int i = 0;
@@ -92,8 +90,7 @@ HashBuf::IsZero() const
int dataSize = GetDataSize(); int dataSize = GetDataSize();
const unsigned char *tmpData = GetData(); const unsigned char *tmpData = GetData();
int i; int i;
for (i = 0; i < dataSize; i++) for (i = 0; i < dataSize; i++) {
{
if (tmpData[i] != 0) if (tmpData[i] != 0)
break; break;
} }
@@ -166,8 +163,7 @@ CryptHelper::MD5Sum(const std::string &fileName, MD5Buf &buf)
bool retVal = false; bool retVal = false;
FILE *file = fopen(fileName.c_str(), "rb"); FILE *file = fopen(fileName.c_str(), "rb");
if (file) if (file) {
{
// Calculate MD5 sum of file. // Calculate MD5 sum of file.
unsigned char readBuf[8192]; unsigned char readBuf[8192];
MD5_CTX context; MD5_CTX context;
@@ -211,15 +207,12 @@ CryptHelper::HMACSha1(const unsigned char *keyData, unsigned keySize, const unsi
retVal = false; retVal = false;
gcry_md_hd_t hd; gcry_md_hd_t hd;
gcry_error_t err = gcry_md_open(&hd, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC); 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); err = gcry_md_setkey(hd, keyData, keySize);
if (!err) if (!err) {
{
gcry_md_write(hd, plainData, plainSize); gcry_md_write(hd, plainData, plainSize);
unsigned char *hash = gcry_md_read(hd, 0); unsigned char *hash = gcry_md_read(hd, 0);
if (hash) if (hash) {
{
memcpy(buf.GetData(), hash, buf.GetDataSize()); memcpy(buf.GetData(), hash, buf.GetDataSize());
retVal = true; retVal = true;
} }
@@ -260,8 +253,7 @@ CryptHelper::AES128Encrypt(const unsigned char *keyData, unsigned keySize, const
{ {
bool retVal = false; bool retVal = false;
unsigned plainSize = static_cast<unsigned>(plainStr.size()); unsigned plainSize = static_cast<unsigned>(plainStr.size());
if (keySize && plainSize) if (keySize && plainSize) {
{
unsigned char key[AES_BLOCK_SIZE]; unsigned char key[AES_BLOCK_SIZE];
unsigned char iv[AES_BLOCK_SIZE]; unsigned char iv[AES_BLOCK_SIZE];
BytesToKey(keyData, keySize, key, iv); 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); int success = EVP_EncryptInit(&encryptCtx, EVP_aes_128_cbc(), key, iv);
EVP_CIPHER_CTX_set_padding(&encryptCtx, 0); EVP_CIPHER_CTX_set_padding(&encryptCtx, 0);
if (success) if (success) {
{
success = EVP_EncryptUpdate(&encryptCtx, &outCipher[0], &outCipherSize, paddedPlainStr, paddedPlainSize); 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. // Since padding is off, this will not modify the cipher. However, parameters need to be set.
EVP_EncryptFinal(&encryptCtx, &outCipher[0], &outCipherSize); EVP_EncryptFinal(&encryptCtx, &outCipher[0], &outCipherSize);
retVal = true; retVal = true;
} }
} } else
else
outCipher.clear(); outCipher.clear();
#else #else
gcry_cipher_hd_t hd; gcry_cipher_hd_t hd;
gcry_error_t err = gcry_cipher_open(&hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC, 0); 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_setkey(hd, key, sizeof(key));
gcry_cipher_setiv(hd, iv, sizeof(iv)); gcry_cipher_setiv(hd, iv, sizeof(iv));
err = gcry_cipher_encrypt(hd, &outCipher[0], cipherSize, paddedPlainStr, paddedPlainSize); 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; retVal = true;
else else
outCipher.clear(); outCipher.clear();
} } else
else
outCipher.clear(); outCipher.clear();
gcry_cipher_close(hd); 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) CryptHelper::AES128Decrypt(const unsigned char *keyData, unsigned keySize, const unsigned char *cipher, unsigned cipherSize, string &outPlain)
{ {
bool retVal = false; bool retVal = false;
if (keySize && cipherSize) if (keySize && cipherSize) {
{
unsigned char key[AES_BLOCK_SIZE]; unsigned char key[AES_BLOCK_SIZE];
unsigned char iv[AES_BLOCK_SIZE]; unsigned char iv[AES_BLOCK_SIZE];
BytesToKey(keyData, keySize, key, iv); 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); int success = EVP_DecryptInit(&decryptCtx, EVP_aes_128_cbc(), key, iv);
EVP_CIPHER_CTX_set_padding(&decryptCtx, 0); EVP_CIPHER_CTX_set_padding(&decryptCtx, 0);
if (success) if (success) {
{
success = EVP_DecryptUpdate(&decryptCtx, (unsigned char *)&outPlain[0], &outPlainSize, cipher, cipherSize); 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. // 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); EVP_DecryptFinal(&decryptCtx, (unsigned char *)outPlain.c_str(), &outPlainSize);
retVal = true; retVal = true;
} }
} } else
else
outPlain.clear(); outPlain.clear();
#else #else
gcry_cipher_hd_t hd; gcry_cipher_hd_t hd;
gcry_error_t err = gcry_cipher_open(&hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC, 0); 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_setkey(hd, key, sizeof(key));
gcry_cipher_setiv(hd, iv, sizeof(iv)); gcry_cipher_setiv(hd, iv, sizeof(iv));
err = gcry_cipher_decrypt(hd, &outPlain[0], outPlain.size(), cipher, cipherSize); 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; retVal = true;
else else
outPlain.clear(); outPlain.clear();
} } else
else
outPlain.clear(); outPlain.clear();
gcry_cipher_close(hd); gcry_cipher_close(hd);
#endif #endif
// Remove trailing zeroes (padding). // Remove trailing zeroes (padding).
if (!outPlain.empty()) if (!outPlain.empty()) {
{
size_t pos = outPlain.find_first_of('\0'); size_t pos = outPlain.find_first_of('\0');
if (pos != string::npos) if (pos != string::npos)
outPlain = outPlain.substr(0, pos); outPlain = outPlain.substr(0, pos);
+6 -12
View File
@@ -54,11 +54,9 @@ loghelper_init(const string &logDir, int logLevel)
void void
internal_log_err(const string &msg) 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); 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 << second_clock::local_time() << " ERR: " << msg;
o.flush(); o.flush();
} }
@@ -68,10 +66,8 @@ internal_log_err(const string &msg)
void void
internal_log_msg(const std::string &msg) internal_log_msg(const std::string &msg)
{ {
if (g_logLevel) if (g_logLevel) {
{ if (!g_logFile.empty()) {
if (!g_logFile.empty())
{
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app); ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
if (!o.fail()) if (!o.fail())
o << second_clock::local_time() << " MSG: " << msg; o << second_clock::local_time() << " MSG: " << msg;
@@ -82,10 +78,8 @@ internal_log_msg(const std::string &msg)
void void
internal_log_level(const std::string &msg, int logLevel) internal_log_level(const std::string &msg, int logLevel)
{ {
if (g_logLevel >= logLevel) if (g_logLevel >= logLevel) {
{ if (!g_logFile.empty()) {
if (!g_logFile.empty())
{
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app); ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
if (!o.fail()) if (!o.fail())
o << second_clock::local_time() << " OUT: " << msg; o << second_clock::local_time() << " OUT: " << msg;
+1 -1
View File
@@ -23,7 +23,7 @@
using namespace std; using namespace std;
PokerTHException::PokerTHException(const char *sourcefile, int sourceline, int errorId, int osErrorCode) 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; ostringstream msgStream;
msgStream << sourcefile << " (" << sourceline << "): Error " << errorId; msgStream << sourcefile << " (" << sourceline << "): Error " << errorId;
+7 -15
View File
@@ -26,8 +26,7 @@ inline void ADD_MSEC_TO_XTIME(boost::xtime &xt, unsigned msec)
{ {
xt.sec += msec / 1000; xt.sec += msec / 1000;
xt.nsec += (msec % 1000) * 1000000; xt.nsec += (msec % 1000) * 1000000;
if (xt.nsec > NANOSECONDS_PER_SECOND) if (xt.nsec > NANOSECONDS_PER_SECOND) {
{
xt.sec++; xt.sec++;
xt.nsec -= NANOSECONDS_PER_SECOND; xt.nsec -= NANOSECONDS_PER_SECOND;
} }
@@ -39,8 +38,7 @@ class ThreadStarter
{ {
public: public:
ThreadStarter(Thread &thread) : m_thread(thread) {} ThreadStarter(Thread &thread) : m_thread(thread) {}
void operator()() void operator()() {
{
m_thread.MainWrapper(); m_thread.MainWrapper();
} }
@@ -62,8 +60,7 @@ Thread::Run()
boost::mutex::scoped_lock threadLock(m_threadObjMutex); boost::mutex::scoped_lock threadLock(m_threadObjMutex);
// Create the boost thread object. // Create the boost thread object.
if (!m_threadObj.get()) if (!m_threadObj.get()) {
{
// Initialise data structures within the context of the thread // Initialise data structures within the context of the thread
// who runs/terminates this thread. // who runs/terminates this thread.
m_userReqTerminateLock.reset(new boost::timed_mutex::scoped_try_lock(m_shouldTerminateMutex)); m_userReqTerminateLock.reset(new boost::timed_mutex::scoped_try_lock(m_shouldTerminateMutex));
@@ -89,14 +86,11 @@ Thread::Join(unsigned msecTimeout)
return true; return true;
bool tmpIsTerminated; bool tmpIsTerminated;
if (msecTimeout == THREAD_WAIT_INFINITE) if (msecTimeout == THREAD_WAIT_INFINITE) {
{
// Wait infinitely. // Wait infinitely.
boost::timed_mutex::scoped_lock lock(m_isTerminatedMutex); boost::timed_mutex::scoped_lock lock(m_isTerminatedMutex);
tmpIsTerminated = true; tmpIsTerminated = true;
} } else {
else
{
// Wait for the termination of the application code. // Wait for the termination of the application code.
#if (BOOST_VERSION) >= 103500 #if (BOOST_VERSION) >= 103500
boost::defer_lock_t defer; boost::defer_lock_t defer;
@@ -113,12 +107,10 @@ Thread::Join(unsigned msecTimeout)
#endif #endif
} }
if (tmpIsTerminated) if (tmpIsTerminated) {
{
boost::mutex::scoped_lock lock(m_threadObjMutex); boost::mutex::scoped_lock lock(m_threadObjMutex);
// Wait for "real" termination of the thread. // Wait for "real" termination of the thread.
if (m_threadObj.get()) if (m_threadObj.get()) {
{
m_threadObj->join(); m_threadObj->join();
m_threadObj.reset(); m_threadObj.reset();
} }
+3 -5
View File
@@ -25,7 +25,7 @@
#endif #endif
#if defined(__FreeBSD__) || defined(__NetBSD__) #if defined(__FreeBSD__) || defined(__NetBSD__)
#define HAVE_ICONV_CONST #define HAVE_ICONV_CONST
#endif #endif
#include <string> #include <string>
@@ -57,8 +57,7 @@ ConvHelper::NativeToUtf8(const std::string &inStr)
if (conversion == (iconv_t)(-1)) if (conversion == (iconv_t)(-1))
LOG_ERROR("iconv_open() failed: " << strerror(errno)); LOG_ERROR("iconv_open() failed: " << strerror(errno));
else else {
{
size_t retval = iconv(conversion, &inbuf, &insize, &outbuf, &outsize); size_t retval = iconv(conversion, &inbuf, &insize, &outbuf, &outsize);
if (retval == (size_t)-1) if (retval == (size_t)-1)
@@ -91,8 +90,7 @@ ConvHelper::Utf8ToNative(const std::string &inStr)
if (conversion == (iconv_t)(-1)) if (conversion == (iconv_t)(-1))
LOG_ERROR("iconv_open() failed: " << strerror(errno)); LOG_ERROR("iconv_open() failed: " << strerror(errno));
else else {
{
size_t retval = iconv(conversion, &inbuf, &insize, &outbuf, &outsize); size_t retval = iconv(conversion, &inbuf, &insize, &outbuf, &outsize);
if (retval == (size_t)-1) if (retval == (size_t)-1)
+28 -28
View File
@@ -25,28 +25,28 @@
#define HAVE_SSIZE_T #define HAVE_SSIZE_T
#include <sys/types.h> #include <sys/types.h>
#ifdef _WIN64 // This is only for Windows. #ifdef _WIN64 // This is only for Windows.
#ifndef _SSIZE_T_ #ifndef _SSIZE_T_
typedef long long ssize_t; typedef long long ssize_t;
#define _SSIZE_T_ #define _SSIZE_T_
#endif #endif
#ifndef _PID_T_ #ifndef _PID_T_
typedef __int64 pid_t; typedef __int64 pid_t;
#define _PID_T_ #define _PID_T_
#endif #endif
#elif _WIN32 #elif _WIN32
#ifndef _SSIZE_T_ #ifndef _SSIZE_T_
typedef int ssize_t; typedef int ssize_t;
#define _SSIZE_T_ #define _SSIZE_T_
#endif #endif
#ifndef _PID_T_ #ifndef _PID_T_
typedef int pid_t; typedef int pid_t;
#define _PID_T_ #define _PID_T_
#endif #endif
#endif #endif
#endif #endif
#ifdef X509_NAME #ifdef X509_NAME
#undef X509_NAME // Again for Windows - conflict with WinCrypt.h. #undef X509_NAME // Again for Windows - conflict with WinCrypt.h.
#endif #endif
// For BSD-Systems, we assume that OpenSSL is part of the operating system. // 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 // http://www.openssl.org/support/faq.html#LEGAL2
// //
#if defined(_WIN64) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) #if defined(_WIN64) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
#define HAVE_OPENSSL #define HAVE_OPENSSL
#endif #endif
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include <openssl/md5.h> #include <openssl/md5.h>
#include <openssl/sha.h> #include <openssl/sha.h>
#include <openssl/hmac.h> #include <openssl/hmac.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/evp.h> #include <openssl/evp.h>
#else #else
// For all other systems, we use GnuTLS. // For all other systems, we use GnuTLS.
#include <gnutls/openssl.h> #include <gnutls/openssl.h>
#include <gcrypt.h> #include <gcrypt.h>
#define PKTH_USE_GNUTLS #define PKTH_USE_GNUTLS
#endif #endif
#endif #endif
+6 -2
View File
@@ -31,8 +31,12 @@ public:
PokerTHException(const char *sourcefile, int sourceline, int errorId, int osErrorCode); PokerTHException(const char *sourcefile, int sourceline, int errorId, int osErrorCode);
virtual ~PokerTHException() throw(); virtual ~PokerTHException() throw();
int GetErrorId() const {return m_errorId;} int GetErrorId() const {
int GetOsErrorCode() const {return m_osErrorCode;} return m_errorId;
}
int GetOsErrorCode() const {
return m_osErrorCode;
}
virtual const char *what() const throw(); virtual const char *what() const throw();
+1 -1
View File
@@ -82,7 +82,7 @@ private:
mutable boost::shared_ptr<boost::barrier> m_threadStartBarrier; mutable boost::shared_ptr<boost::barrier> m_threadStartBarrier;
friend class ThreadStarter; friend class ThreadStarter;
}; };
#endif #endif
+4 -8
View File
@@ -33,22 +33,18 @@ Convert(const std::string &inStr, int fromCP, int toCP)
// convert str from current Windows source to target charset // convert str from current Windows source to target charset
string retStr(inStr); string retStr(inStr);
if (!inStr.empty()) if (!inStr.empty()) {
{
int len = (int)inStr.length() + 1; int len = (int)inStr.length() + 1;
int reqLen = ::MultiByteToWideChar(fromCP, 0, inStr.c_str(), len, NULL, 0); int reqLen = ::MultiByteToWideChar(fromCP, 0, inStr.c_str(), len, NULL, 0);
if (reqLen) if (reqLen) {
{
wchar_t *wstr = new wchar_t[reqLen]; wchar_t *wstr = new wchar_t[reqLen];
wstr[0] = L'\0'; 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; len = reqLen;
reqLen = ::WideCharToMultiByte(toCP, 0, wstr, len, NULL, 0, NULL, NULL); reqLen = ::WideCharToMultiByte(toCP, 0, wstr, len, NULL, 0, NULL, NULL);
if (reqLen) if (reqLen) {
{
char *str = new char[reqLen]; char *str = new char[reqLen];
if (::WideCharToMultiByte(toCP, 0, wstr, len, str, reqLen, NULL, NULL) == (int)reqLen) if (::WideCharToMultiByte(toCP, 0, wstr, len, str, reqLen, NULL, NULL) == (int)reqLen)
retStr = str; retStr = str;
+2 -2
View File
@@ -24,7 +24,7 @@ using namespace std;
ServerDBGeneric::ServerDBGeneric(ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService) 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 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)); m_ioService->post(boost::bind(&ServerDBCallback::ReportAvatarFailed, &m_callback, requestId, replyId));
} }
+1 -2
View File
@@ -27,8 +27,7 @@
typedef unsigned DB_id; typedef unsigned DB_id;
#define DB_ID_INVALID 0 #define DB_ID_INVALID 0
struct DBPlayerData struct DBPlayerData {
{
DBPlayerData() : id(DB_ID_INVALID) {} DBPlayerData() : id(DB_ID_INVALID) {}
DB_id id; DB_id id;
std::string secret; std::string secret;
+2 -1
View File
@@ -23,7 +23,8 @@
#include <game_defs.h> #include <game_defs.h>
#include <engine_defs.h> #include <engine_defs.h>
class BeRoInterface{ class BeRoInterface
{
public: public:
virtual ~BeRoInterface(); virtual ~BeRoInterface();
+2 -1
View File
@@ -24,7 +24,8 @@
class HandInterface; class HandInterface;
class BoardInterface { class BoardInterface
{
public: public:
+2 -1
View File
@@ -26,7 +26,8 @@
#include "berointerface.h" #include "berointerface.h"
#include "log.h" #include "log.h"
class EngineFactory{ class EngineFactory
{
public: public:
virtual ~EngineFactory(); virtual ~EngineFactory();
+9 -8
View File
@@ -25,7 +25,8 @@
#include "playerinterface.h" #include "playerinterface.h"
#include "berointerface.h" #include "berointerface.h"
class HandInterface{ class HandInterface
{
public: public:
virtual ~HandInterface(); virtual ~HandInterface();
@@ -84,13 +85,13 @@ protected:
virtual PlayerListIterator getActivePlayerIt(unsigned) const =0; virtual PlayerListIterator getActivePlayerIt(unsigned) const =0;
virtual PlayerListIterator getRunningPlayerIt(unsigned) const =0; virtual PlayerListIterator getRunningPlayerIt(unsigned) const =0;
friend class Game; friend class Game;
friend class LocalBeRo; friend class LocalBeRo;
friend class LocalBeRoPreflop; friend class LocalBeRoPreflop;
friend class LocalBeRoFlop; friend class LocalBeRoFlop;
friend class LocalBeRoTurn; friend class LocalBeRoTurn;
friend class LocalBeRoRiver; friend class LocalBeRoRiver;
friend class LocalBeRoPostRiver; friend class LocalBeRoPostRiver;
}; };
#endif #endif
+14 -17
View File
@@ -22,14 +22,12 @@
using namespace std; using namespace std;
struct RoundData struct RoundData {
{
int hand; int hand;
double data[4]; double data[4];
}; };
static const RoundData PreflopValues[] = static const RoundData PreflopValues[] = {
{
{ 0, { 0.392398, 0.276545, 0.212940, 0.178564 } }, { 0, { 0.392398, 0.276545, 0.212940, 0.178564 } },
{ 10, { 0.341141, 0.213735, 0.153802, 0.121123 } }, { 10, { 0.341141, 0.213735, 0.153802, 0.121123 } },
{ 11, { 0.374930, 0.252093, 0.194671, 0.161691 } }, { 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 } } { 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 } }, { 106, { 0.160312, 0.078750, 0.048325, 0.033350 } },
{ 206, { 0.185012, 0.099666, 0.071425, 0.053450 } }, { 206, { 0.185012, 0.099666, 0.071425, 0.053450 } },
{ 306, { 0.199662, 0.115567, 0.081625, 0.067500 } }, { 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 } } { 71212, { 0.751687, 0.628100, 0.560100, 0.516900 } }
}; };
struct calcHandsData struct calcHandsData {
{
int hand; int hand;
int data[10][2]; 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} } }, { 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} } }, { 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} } }, { 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; int check = -1;
for (unsigned val = 0; val < NUM_HAND_CHANCE_PREFLOP; val++) { for (unsigned val = 0; val < NUM_HAND_CHANCE_PREFLOP; val++) {
if(handCode == handChancePreflop[val].hand) { if(handCode == handChancePreflop[val].hand) {
check = 1; check = 1;
for(int i=0;i<10;i++) { for(int i=0; i<10; i++) {
for(int j=0;j<2;j++) { for(int j=0; j<2; j++) {
values[i][j] = handChancePreflop[val].data[i][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; int check = -1;
@@ -1060,7 +1057,7 @@ vector< vector<int> > ArrayData::getHandChancePreflop(int handCode) {
chance[0].resize(10); chance[0].resize(10);
chance[1].resize(10); chance[1].resize(10);
for(i=0;i<10;i++) { for(i=0; i<10; i++) {
chance[0][i] = 0; chance[0][i] = 0;
chance[1][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++) { for (unsigned val = 0; val < NUM_HAND_CHANCE_PREFLOP; val++) {
if(handCode == handChancePreflop[val].hand) { if(handCode == handChancePreflop[val].hand) {
check = 1; check = 1;
for(int i=0;i<10;i++) { for(int i=0; i<10; i++) {
for(int j=0;j<2;j++) { for(int j=0; j<2; j++) {
chance[j][i] = handChancePreflop[val].data[i][j]; chance[j][i] = handChancePreflop[val].data[i][j];
} }
} }
+2 -1
View File
@@ -24,7 +24,8 @@
#include<vector> #include<vector>
class ArrayData{ class ArrayData
{
public: public:
ArrayData(); ArrayData();
+155 -100
View File
@@ -30,7 +30,8 @@ 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) { if((one-1)%13<(two-1)%13) {
int temp = one; int temp = one;
@@ -43,11 +44,16 @@ int CardsValue::holeCardsClass(int one, int two) const {
if((one-1)%13+2 > 10) return 10; if((one-1)%13+2 > 10) return 10;
else { else {
switch((one-1)%13+2) { switch((one-1)%13+2) {
case 10: return 9; case 10:
case 9: return 8; return 9;
case 8: return 7; case 9:
case 7: return 6; return 8;
default: return 5; case 8:
return 7;
case 7:
return 6;
default:
return 5;
} }
} }
} }
@@ -56,107 +62,149 @@ int CardsValue::holeCardsClass(int one, int two) const {
case 14: { case 14: {
if((one-1)/13 == (two-1)/13) { if((one-1)/13 == (two-1)/13) {
switch((one-1)%13-(two-1)%13) { switch((one-1)%13-(two-1)%13) {
case 1: return 10; case 1:
case 2: return 9; return 10;
case 3: return 9; case 2:
case 4: return 8; return 9;
default: return 7; case 3:
return 9;
case 4:
return 8;
default:
return 7;
} }
} } else {
else {
switch((one-1)%13-(two-1)%13) { switch((one-1)%13-(two-1)%13) {
case 1: return 9; case 1:
case 2: return 8; return 9;
case 3: return 7; case 2:
case 4: return 7; return 8;
default: return 4; case 3:
return 7;
case 4:
return 7;
default:
return 4;
} }
} }
} break; }
break;
//K�ig //K�ig
case 13: { case 13: {
if((one-1)/13 == (two-1)/13) { if((one-1)/13 == (two-1)/13) {
switch((one-1)%13-(two-1)%13) { switch((one-1)%13-(two-1)%13) {
case 1: return 9; case 1:
case 2: return 8; return 9;
case 3: return 8; case 2:
case 4: return 6; return 8;
default: return 5; case 3:
return 8;
case 4:
return 6;
default:
return 5;
} }
} } else {
else {
switch((one-1)%13-(two-1)%13) { switch((one-1)%13-(two-1)%13) {
case 1: return 7; case 1:
case 2: return 6; return 7;
case 3: return 6; case 2:
default: return 4; return 6;
case 3:
return 6;
default:
return 4;
} }
} }
} break; }
break;
//Dame //Dame
case 12: { case 12: {
if((one-1)/13 == (two-1)/13) { if((one-1)/13 == (two-1)/13) {
switch((one-1)%13-(two-1)%13) { switch((one-1)%13-(two-1)%13) {
case 1: return 8; case 1:
case 2: return 7; return 8;
case 3: return 6; case 2:
case 4: return 5; return 7;
default: return 4; case 3:
return 6;
case 4:
return 5;
default:
return 4;
} }
} } else {
else {
switch((one-1)%13-(two-1)%13) { switch((one-1)%13-(two-1)%13) {
case 1: return 6; case 1:
case 2: return 6; return 6;
case 3: return 4; case 2:
default: return 3; return 6;
case 3:
return 4;
default:
return 3;
} }
} }
} break; }
break;
//Bube //Bube
case 11: { case 11: {
if((one-1)/13 == (two-1)/13) { if((one-1)/13 == (two-1)/13) {
switch((one-1)%13-(two-1)%13) { switch((one-1)%13-(two-1)%13) {
case 1: return 7; case 1:
case 2: return 6; return 7;
case 3: return 5; case 2:
case 4: return 4; return 6;
default: return 3; case 3:
return 5;
case 4:
return 4;
default:
return 3;
} }
} } else {
else {
switch((one-1)%13-(two-1)%13) { switch((one-1)%13-(two-1)%13) {
case 1: return 6; case 1:
case 2: return 5; return 6;
case 3: return 4; case 2:
default: return 2; return 5;
case 3:
return 4;
default:
return 2;
} }
} }
} break; }
break;
//10 //10
case 10: { case 10: {
if((one-1)/13 == (two-1)/13) { if((one-1)/13 == (two-1)/13) {
switch((one-1)%13-(two-1)%13) { switch((one-1)%13-(two-1)%13) {
case 1: return 6; case 1:
case 2: return 5; return 6;
default: return 2; case 2:
return 5;
default:
return 2;
} }
} } else {
else {
switch((one-1)%13-(two-1)%13) { switch((one-1)%13-(two-1)%13) {
case 1: return 5; case 1:
case 2: return 4; return 5;
default: return 1; case 2:
return 4;
default:
return 1;
} }
} }
} break; }
break;
//Rest //Rest
default: { default: {
if((one-1)%13 - (two-1)%13 <= 2) { if((one-1)%13 - (two-1)%13 <= 2) {
if((one-1)/13 == (two-1)/13) return 5; if((one-1)/13 == (two-1)/13) return 5;
else return 3; else return 3;
} } else {
else {
if((one-1)%13 - (two-1)%13 == 3) return 2; if((one-1)%13 - (two-1)%13 == 3) return 2;
else return 1; else return 1;
} }
@@ -166,7 +214,8 @@ int CardsValue::holeCardsClass(int one, int two) const {
} }
int CardsValue::holeCardsToIntCode(int* cards) const { int CardsValue::holeCardsToIntCode(int* cards) const
{
// Code der HoleCards ermitteln // Code der HoleCards ermitteln
if(cards[0]%13 == cards[1]%13) { 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 !!! // one possibility !!!
@@ -198,8 +248,9 @@ int* CardsValue::intCodeToHoleCards(int code) const {
cards[0] = code/1000; cards[0] = code/1000;
cards[1] = (code-cards[0]*1000)/10; cards[1] = (code-cards[0]*1000)/10;
if(cards[0]==cards[1]) { cards[1] +=13; } if(cards[0]==cards[1]) {
else { cards[1] +=13;
} else {
if(code%10 == 0) cards[1] +=13; 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]; 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 ] ) // Kartenwerte umwandeln (z.B. [ 11 (Karo K�ig) -> 0 11 ] oder [ 31 (Pik 7) -> 2 5 ] )
@@ -368,8 +420,7 @@ int array[7][3];
} }
} }
return 700000000+array[j1][1]*1000000+array[j1+4][1]*10000; return 700000000+array[j1][1]*1000000+array[j1+4][1]*10000;
} } else {
else {
if(position) { if(position) {
// Position-Array fuellen // Position-Array fuellen
for(j2=0; j2<4; j2++) { for(j2=0; j2<4; j2++) {
@@ -414,8 +465,13 @@ int array[7][3];
position[4] = array[j5][2]; position[4] = array[j5][2];
} }
// Paar und Drilling des Full House ermitteln ermitteln // Paar und Drilling des Full House ermitteln ermitteln
if(array[j3][1]==array[j1][1]) { drei = array[j1][1]; zwei = array[j4][1]; } if(array[j3][1]==array[j1][1]) {
else { drei = array[j4][1]; zwei = 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; return 600000000+drei*1000000+zwei*10000;
} }
} }
@@ -454,26 +510,24 @@ int array[7][3];
if(j1==0) { if(j1==0) {
if(position) { if(position) {
// Position-Array fuellen // Position-Array fuellen
for(j2=0; j2<5;j2++) { for(j2=0; j2<5; j2++) {
position[j2] = array[j2][2]; position[j2] = array[j2][2];
} }
} }
return 300000000+array[j1][1]*1000000+array[j1+3][1]*10000+array[j1+4][1]*100; return 300000000+array[j1][1]*1000000+array[j1+3][1]*10000+array[j1+4][1]*100;
} } else {
else {
if(j1==1) { if(j1==1) {
if(position) { if(position) {
// Position-Array fuellen // Position-Array fuellen
for(j2=0; j2<5;j2++) { for(j2=0; j2<5; j2++) {
position[j2] = array[j2][2]; position[j2] = array[j2][2];
} }
} }
return 300000000+array[j1][1]*1000000+array[j1-1][1]*10000+array[j1+3][1]*100; return 300000000+array[j1][1]*1000000+array[j1-1][1]*10000+array[j1+3][1]*100;
} } else {
else {
if(position) { if(position) {
// Position-Array fuellen // Position-Array fuellen
for(j2=0; j2<3;j2++) { for(j2=0; j2<3; j2++) {
position[j2] = array[j1+j2][2]; position[j2] = array[j1+j2][2];
} }
position[3] = array[0][2]; position[3] = array[0][2];
@@ -501,8 +555,7 @@ int array[7][3];
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; return 200000000+array[j1][1]*1000000+array[j2][1]*10000+array[j2+2][1]*100;
} } else {
else {
if(position) { if(position) {
// Position-Array fuellen // Position-Array fuellen
position[0] = array[j1][2]; position[0] = array[j1][2];
@@ -513,8 +566,7 @@ int array[7][3];
} }
return 200000000+array[j1][1]*1000000+array[j2][1]*10000+array[j1+2][1]*100; return 200000000+array[j1][1]*1000000+array[j2][1]*10000+array[j1+2][1]*100;
} }
} } else {
else {
if(position) { if(position) {
// Position-Array fuellen // Position-Array fuellen
position[0] = array[j1][2]; position[0] = array[j1][2];
@@ -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]; return 100000000+array[j1][1]*1000000+array[j1-2][1]*10000+array[j1-1][1]*100+array[j1+2][1];
} } else {
else {
if(position) { if(position) {
// Position-Array fuellen // Position-Array fuellen
for(j2=0; j2<2; j2++) { for(j2=0; j2<2; j2++) {
@@ -595,7 +646,7 @@ vector< vector<int> > CardsValue::calcCardsChance(GameState beRoID, int* playerC
chance[0].resize(10); chance[0].resize(10);
chance[1].resize(10); chance[1].resize(10);
for(i=0;i<10;i++) { for(i=0; i<10; i++) {
chance[0][i] = 0; chance[0][i] = 0;
chance[1][i] = 0; chance[1][i] = 0;
} }
@@ -605,7 +656,7 @@ vector< vector<int> > CardsValue::calcCardsChance(GameState beRoID, int* playerC
cards[0] = playerCards[0]; cards[0] = playerCards[0];
cards[1] = playerCards[1]; 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) { switch(beRoID) {
case GAME_STATE_PREFLOP: { case GAME_STATE_PREFLOP: {
@@ -615,12 +666,13 @@ vector< vector<int> > CardsValue::calcCardsChance(GameState beRoID, int* playerC
delete myArrayData; delete myArrayData;
} break; }
break;
case GAME_STATE_FLOP: { case GAME_STATE_FLOP: {
for(i=0;i<51;i++) { for(i=0; i<51; i++) {
if(i!=cards[0] && i!=cards[1] && i!=cards[2] && i!=cards[3] && i!=cards[4]) { if(i!=cards[0] && i!=cards[1] && i!=cards[2] && i!=cards[3] && i!=cards[4]) {
for(j=i+1;j<52;j++) { for(j=i+1; j<52; j++) {
if(j!=cards[0] && j!=cards[1] && j!=cards[2] && j!=cards[3] && j!=cards[4]) { if(j!=cards[0] && j!=cards[1] && j!=cards[2] && j!=cards[3] && j!=cards[4]) {
cards[5] = i; cards[5] = i;
cards[6] = j; cards[6] = j;
@@ -630,31 +682,34 @@ vector< vector<int> > CardsValue::calcCardsChance(GameState beRoID, int* playerC
} }
} }
} }
for(i=0;i<10;i++) { for(i=0; i<10; i++) {
if(chance[0][i] > 0) chance[1][i] = 1; if(chance[0][i] > 0) chance[1][i] = 1;
chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5); chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5);
} }
} break; }
break;
case GAME_STATE_TURN: { case GAME_STATE_TURN: {
for(i=0;i<52;i++) { 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]) { if(i!=cards[0] && i!=cards[1] && i!=cards[2] && i!=cards[3] && i!=cards[4] && i!=cards[5]) {
cards[6] = i; cards[6] = i;
(chance[0][cardsValue(cards,0)/100000000])++; (chance[0][cardsValue(cards,0)/100000000])++;
sum++; sum++;
} }
} }
for(i=0;i<10;i++) { for(i=0; i<10; i++) {
if(chance[0][i] > 0) chance[1][i] = 1; if(chance[0][i] > 0) chance[1][i] = 1;
chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5); chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5);
} }
} break; }
break;
case GAME_STATE_RIVER: { case GAME_STATE_RIVER: {
chance[0][cardsValue(cards,0)/100000000] = 100; chance[0][cardsValue(cards,0)/100000000] = 100;
chance[1][cardsValue(cards,0)/100000000] = 1; chance[1][cardsValue(cards,0)/100000000] = 1;
} break; }
break;
default: { default: {
} }
} }
+2 -1
View File
@@ -28,7 +28,8 @@
class CardsValue{ class CardsValue
{
public: public:
CardsValue(); CardsValue();
+20 -14
View File
@@ -26,7 +26,7 @@
using namespace std; using namespace std;
LocalBeRo::LocalBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS) 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(); currentPlayersTurnIt = myHand->getRunningPlayerList()->begin();
lastPlayersTurnIt = myHand->getRunningPlayerList()->begin(); lastPlayersTurnIt = myHand->getRunningPlayerList()->begin();
@@ -68,7 +68,8 @@ int LocalBeRo::getHighestCardsValue() const
return 0; return 0;
} }
void LocalBeRo::nextPlayer() { void LocalBeRo::nextPlayer()
{
PlayerListConstIterator currentPlayersTurnConstIt = myHand->getRunningPlayerIt(currentPlayersTurnId); PlayerListConstIterator currentPlayersTurnConstIt = myHand->getRunningPlayerIt(currentPlayersTurnId);
if(currentPlayersTurnConstIt == myHand->getRunningPlayerList()->end()) { if(currentPlayersTurnConstIt == myHand->getRunningPlayerList()->end()) {
@@ -79,14 +80,14 @@ void LocalBeRo::nextPlayer() {
} }
void LocalBeRo::run() { void LocalBeRo::run()
{
if(firstRunGui) { if(firstRunGui) {
firstRunGui = false; firstRunGui = false;
myHand->setLastPlayersTurn(-1); myHand->setLastPlayersTurn(-1);
myHand->getGuiInterface()->dealBeRoCards(myBeRoID); myHand->getGuiInterface()->dealBeRoCards(myBeRoID);
} } else {
else {
if(firstRun) { if(firstRun) {
@@ -138,13 +139,18 @@ void LocalBeRo::run() {
myHand->getBoard()->getMyCards(tempBoardCardsArray); myHand->getBoard()->getMyCards(tempBoardCardsArray);
switch(myBeRoID) { 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; 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; 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; break;
default: { LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR - wrong myBeRoID"); } default: {
LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR - wrong myBeRoID");
}
} }
logBoardCardsDone = true; logBoardCardsDone = true;
@@ -183,11 +189,12 @@ void LocalBeRo::run() {
myHand->getGuiInterface()->refreshSet(); myHand->getGuiInterface()->refreshSet();
myHand->getGuiInterface()->refreshCash(); 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(); myHand->switchRounds();
} } else {
else {
// aktuelle bero ist wirklich dran // aktuelle bero ist wirklich dran
// Anzahl der effektiv gespielten Runden (des human player) erhöhen // Anzahl der effektiv gespielten Runden (des human player) erhöhen
@@ -229,8 +236,7 @@ void LocalBeRo::run() {
if( currentPlayersTurnId == 0) { if( currentPlayersTurnId == 0) {
// Wir sind dran // Wir sind dran
myHand->getGuiInterface()->meInAction(); myHand->getGuiInterface()->meInAction();
} } else {
else {
//Gegner sind dran //Gegner sind dran
myHand->getGuiInterface()->beRoAnimation2(myBeRoID); myHand->getGuiInterface()->beRoAnimation2(myBeRoID);
+101 -34
View File
@@ -26,23 +26,36 @@
#include "berointerface.h" #include "berointerface.h"
#include "handinterface.h" #include "handinterface.h"
class LocalBeRo : public BeRoInterface{ class LocalBeRo : public BeRoInterface
{
public: public:
LocalBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS); LocalBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS);
~LocalBeRo(); ~LocalBeRo();
GameState getMyBeRoID() const { return myBeRoID; } GameState getMyBeRoID() const {
return myBeRoID;
}
int getHighestCardsValue() const; int getHighestCardsValue() const;
void setHighestCardsValue(int /*theValue*/) { } void setHighestCardsValue(int /*theValue*/) { }
void setMinimumRaise ( int theValue ) { minimumRaise = theValue; } void setMinimumRaise ( int theValue ) {
int getMinimumRaise() const { return minimumRaise; } minimumRaise = theValue;
}
int getMinimumRaise() const {
return minimumRaise;
}
void setFullBetRule ( bool theValue ) { fullBetRule = theValue; } void setFullBetRule ( bool theValue ) {
bool getFullBetRule() const { return fullBetRule; } fullBetRule = theValue;
}
bool getFullBetRule() const {
return fullBetRule;
}
void skipFirstRunGui() { firstRunGui = false; } void skipFirstRunGui() {
firstRunGui = false;
}
void nextPlayer(); void nextPlayer();
void run(); void run();
@@ -52,48 +65,102 @@ public:
protected: protected:
HandInterface* getMyHand() const { return myHand; } HandInterface* getMyHand() const {
return myHand;
}
int getDealerPosition() const {return dealerPosition; } int getDealerPosition() const {
void setDealerPosition(int theValue) { dealerPosition = theValue; } return dealerPosition;
}
void setDealerPosition(int theValue) {
dealerPosition = theValue;
}
void setCurrentPlayersTurnId(unsigned theValue) { currentPlayersTurnId = theValue; } void setCurrentPlayersTurnId(unsigned theValue) {
unsigned getCurrentPlayersTurnId() const { return currentPlayersTurnId;} currentPlayersTurnId = theValue;
}
unsigned getCurrentPlayersTurnId() const {
return currentPlayersTurnId;
}
void setFirstRoundLastPlayersTurnId(unsigned theValue) { firstRoundLastPlayersTurnId = theValue; } void setFirstRoundLastPlayersTurnId(unsigned theValue) {
unsigned getFirstRoundLastPlayersTurnId() const { return firstRoundLastPlayersTurnId;} firstRoundLastPlayersTurnId = theValue;
}
unsigned getFirstRoundLastPlayersTurnId() const {
return firstRoundLastPlayersTurnId;
}
void setCurrentPlayersTurnIt(PlayerListIterator theValue) { currentPlayersTurnIt = theValue; } void setCurrentPlayersTurnIt(PlayerListIterator theValue) {
PlayerListIterator getCurrentPlayersTurnIt() const { return currentPlayersTurnIt; } currentPlayersTurnIt = theValue;
}
PlayerListIterator getCurrentPlayersTurnIt() const {
return currentPlayersTurnIt;
}
void setLastPlayersTurnIt(PlayerListIterator theValue) { lastPlayersTurnIt = theValue; } void setLastPlayersTurnIt(PlayerListIterator theValue) {
PlayerListIterator getLastPlayersTurnIt() const { return lastPlayersTurnIt; } lastPlayersTurnIt = theValue;
}
PlayerListIterator getLastPlayersTurnIt() const {
return lastPlayersTurnIt;
}
void setHighestSet(int theValue) { highestSet = theValue; } void setHighestSet(int theValue) {
int getHighestSet() const { return highestSet;} highestSet = theValue;
}
int getHighestSet() const {
return highestSet;
}
void setFirstRun(bool theValue) { firstRun = theValue;} void setFirstRun(bool theValue) {
bool getFirstRun() const { return firstRun;} firstRun = theValue;
}
bool getFirstRun() const {
return firstRun;
}
void setFirstRound(bool theValue) { firstRound = theValue;} void setFirstRound(bool theValue) {
bool getFirstRound() const { return firstRound;} firstRound = theValue;
}
bool getFirstRound() const {
return firstRound;
}
void setDealerPositionId(unsigned theValue) { dealerPositionId = theValue;} void setDealerPositionId(unsigned theValue) {
unsigned getDealerPositionId() const { return dealerPositionId; } dealerPositionId = theValue;
}
unsigned getDealerPositionId() const {
return dealerPositionId;
}
void setSmallBlindPositionId(unsigned theValue) { smallBlindPositionId = theValue;} void setSmallBlindPositionId(unsigned theValue) {
unsigned getSmallBlindPositionId() const { return smallBlindPositionId; } smallBlindPositionId = theValue;
}
unsigned getSmallBlindPositionId() const {
return smallBlindPositionId;
}
void setBigBlindPositionId(unsigned theValue) { bigBlindPositionId = theValue;} void setBigBlindPositionId(unsigned theValue) {
unsigned getBigBlindPositionId() const { return bigBlindPositionId; } bigBlindPositionId = theValue;
}
unsigned getBigBlindPositionId() const {
return bigBlindPositionId;
}
void setSmallBlindPosition(int theValue) { smallBlindPosition = theValue;} void setSmallBlindPosition(int theValue) {
int getSmallBlindPosition() const { return smallBlindPosition; } smallBlindPosition = theValue;
}
int getSmallBlindPosition() const {
return smallBlindPosition;
}
void setSmallBlind(int theValue) { smallBlind = theValue; } void setSmallBlind(int theValue) {
int getSmallBlind() const { return smallBlind; } smallBlind = theValue;
}
int getSmallBlind() const {
return smallBlind;
}
+2 -1
View File
@@ -25,7 +25,8 @@
class HandInterface; class HandInterface;
class LocalBeRoFlop : public LocalBeRo{ class LocalBeRoFlop : public LocalBeRo
{
public: public:
LocalBeRoFlop(HandInterface*, int, unsigned, int); 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; PlayerListConstIterator it_c;
PlayerListIterator it; PlayerListIterator it;
+8 -3
View File
@@ -26,13 +26,18 @@
class HandInterface; class HandInterface;
class LocalBeRoPostRiver : public LocalBeRo{ class LocalBeRoPostRiver : public LocalBeRo
{
public: public:
LocalBeRoPostRiver(HandInterface*, int, int, int); LocalBeRoPostRiver(HandInterface*, int, int, int);
~LocalBeRoPostRiver(); ~LocalBeRoPostRiver();
void setHighestCardsValue(int theValue) { highestCardsValue = theValue;} void setHighestCardsValue(int theValue) {
int getHighestCardsValue() const { return highestCardsValue;} highestCardsValue = theValue;
}
int getHighestCardsValue() const {
return highestCardsValue;
}
void run(); void run();
+7 -6
View File
@@ -38,7 +38,8 @@ LocalBeRoPreflop::~LocalBeRoPreflop()
{ {
} }
void LocalBeRoPreflop::run() { void LocalBeRoPreflop::run()
{
if(getFirstRun()) { if(getFirstRun()) {
@@ -151,11 +152,12 @@ void LocalBeRoPreflop::run() {
getMyHand()->getGuiInterface()->refreshSet(); getMyHand()->getGuiInterface()->refreshSet();
getMyHand()->getGuiInterface()->refreshCash(); 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(); getMyHand()->switchRounds();
} } else {
else {
// lastPlayersTurn -> PreflopFirstRound is over // lastPlayersTurn -> PreflopFirstRound is over
if( getCurrentPlayersTurnId() == getFirstRoundLastPlayersTurnId() ) { if( getCurrentPlayersTurnId() == getFirstRoundLastPlayersTurnId() ) {
setFirstRound(false); setFirstRound(false);
@@ -175,8 +177,7 @@ void LocalBeRoPreflop::run() {
if( getCurrentPlayersTurnId() == 0) { if( getCurrentPlayersTurnId() == 0) {
// Wir sind dran // Wir sind dran
getMyHand()->getGuiInterface()->meInAction(); getMyHand()->getGuiInterface()->meInAction();
} } else {
else {
//Gegner sind dran //Gegner sind dran
getMyHand()->getGuiInterface()->beRoAnimation2(getMyBeRoID()); getMyHand()->getGuiInterface()->beRoAnimation2(getMyBeRoID());
} }
+2 -1
View File
@@ -25,7 +25,8 @@
class HandInterface; class HandInterface;
class LocalBeRoPreflop : public LocalBeRo{ class LocalBeRoPreflop : public LocalBeRo
{
public: public:
LocalBeRoPreflop(HandInterface*, int, unsigned, int); LocalBeRoPreflop(HandInterface*, int, unsigned, int);
+2 -1
View File
@@ -26,7 +26,8 @@
class HandInterface; class HandInterface;
class LocalBeRoRiver : public LocalBeRo{ class LocalBeRoRiver : public LocalBeRo
{
public: public:
LocalBeRoRiver(HandInterface*, int, unsigned, int); LocalBeRoRiver(HandInterface*, int, unsigned, int);
~LocalBeRoRiver(); ~LocalBeRoRiver();
+2 -1
View File
@@ -25,7 +25,8 @@
class HandInterface; class HandInterface;
class LocalBeRoTurn : public LocalBeRo{ class LocalBeRoTurn : public LocalBeRo
{
public: public:
LocalBeRoTurn(HandInterface*, int, unsigned, int); LocalBeRoTurn(HandInterface*, int, unsigned, int);
~LocalBeRoTurn(); ~LocalBeRoTurn();
+11 -6
View File
@@ -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; seatsList = sl;
activePlayerList = apl; activePlayerList = apl;
runningPlayerList = rpl; runningPlayerList = rpl;
} }
void LocalBoard::collectSets() { void LocalBoard::collectSets()
{
sets = 0; sets = 0;
@@ -53,7 +55,8 @@ void LocalBoard::collectSets() {
} }
void LocalBoard::collectPot() { void LocalBoard::collectPot()
{
pot += sets; pot += sets;
sets = 0; sets = 0;
@@ -65,7 +68,8 @@ void LocalBoard::collectPot() {
} }
void LocalBoard::distributePot() { void LocalBoard::distributePot()
{
winners.clear(); winners.clear();
@@ -176,7 +180,7 @@ void LocalBoard::distributePot() {
winnerHit = false; 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); // winnerPointer = (winnerPointer+1)%(MAX_NUMBER_OF_PLAYERS);
@@ -247,7 +251,8 @@ void LocalBoard::distributePot() {
}*/ }*/
} }
void LocalBoard::determinePlayerNeedToShowCards() { void LocalBoard::determinePlayerNeedToShowCards()
{
playerNeedToShowCards.clear(); playerNeedToShowCards.clear();
+40 -13
View File
@@ -30,23 +30,42 @@ class PlayerInterface;
class HandInterface; class HandInterface;
class LocalBoard : public BoardInterface{ class LocalBoard : public BoardInterface
{
public: public:
LocalBoard(unsigned dealerPosition); LocalBoard(unsigned dealerPosition);
~LocalBoard(); ~LocalBoard();
void setPlayerLists(PlayerList, PlayerList, PlayerList); void setPlayerLists(PlayerList, PlayerList, PlayerList);
void setMyCards(int* theValue) { int i; for(i=0; i<5; i++) myCards[i] = theValue[i]; } void setMyCards(int* theValue) {
void getMyCards(int* theValue) { int i; for(i=0; i<5; i++) theValue[i] = myCards[i]; } 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 setAllInCondition(bool theValue) {
void setLastActionPlayer(unsigned theValue) { lastActionPlayer = theValue; } allInCondition = theValue;
}
void setLastActionPlayer(unsigned theValue) {
lastActionPlayer = theValue;
}
int getPot() const { return pot;} int getPot() const {
void setPot(int theValue) { pot = theValue;} return pot;
int getSets() const { return sets; } }
void setSets(int theValue) { sets = theValue; } void setPot(int theValue) {
pot = theValue;
}
int getSets() const {
return sets;
}
void setSets(int theValue) {
sets = theValue;
}
void collectSets() ; void collectSets() ;
void collectPot() ; void collectPot() ;
@@ -54,11 +73,19 @@ public:
void distributePot(); void distributePot();
void determinePlayerNeedToShowCards(); void determinePlayerNeedToShowCards();
std::list<unsigned> getWinners() const { return winners; } std::list<unsigned> getWinners() const {
void setWinners(const std::list<unsigned> &w) { winners = w; } return winners;
}
void setWinners(const std::list<unsigned> &w) {
winners = w;
}
std::list<unsigned> getPlayerNeedToShowCards() const { return playerNeedToShowCards; } std::list<unsigned> getPlayerNeedToShowCards() const {
void setPlayerNeedToShowCards(const std::list<unsigned> &p) { playerNeedToShowCards = p; } return playerNeedToShowCards;
}
void setPlayerNeedToShowCards(const std::list<unsigned> &p) {
playerNeedToShowCards = p;
}
private: private:
@@ -32,7 +32,7 @@
LocalEngineFactory::LocalEngineFactory(ConfigFile *c) LocalEngineFactory::LocalEngineFactory(ConfigFile *c)
: myConfig(c) : myConfig(c)
{ {
} }
+41 -26
View File
@@ -31,7 +31,7 @@
using namespace std; 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) 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), : 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) cardsShown(false), bettingRoundsPlayed(0)
{ {
@@ -104,9 +104,9 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
//QSqlDatabase * test = myGui->getMyLog()->getMySqliteLogDb(); //QSqlDatabase * test = myGui->getMyLog()->getMySqliteLogDb();
// if(!mySqliteLogDb->open()) { // if(!mySqliteLogDb->open()) {
// QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel); // QMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().data(), QMessageBox::Cancel);
// } // }
@@ -248,10 +248,11 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
(*it)->setMyBestHandPosition(temp5Array); (*it)->setMyBestHandPosition(temp5Array);
} break; }
break;
case 2: { case 2: {
/* tempBoardArray[0] = 48; /* tempBoardArray[0] = 48;
tempBoardArray[1] = 21; tempBoardArray[1] = 21;
tempBoardArray[2] = 4; tempBoardArray[2] = 4;
tempBoardArray[3] = 9; tempBoardArray[3] = 9;
@@ -343,8 +344,10 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
// //
// (*it)->setMyBestHandPosition(temp5Array); // (*it)->setMyBestHandPosition(temp5Array);
} break; }
default: {} break;
default:
{}
} }
@@ -367,7 +370,8 @@ LocalHand::~LocalHand()
{ {
} }
void LocalHand::start() { void LocalHand::start()
{
//Log blinds sets for new Hand //Log blinds sets for new Hand
PlayerListConstIterator it_sB, it_bB; PlayerListConstIterator it_sB, it_bB;
@@ -375,8 +379,9 @@ void LocalHand::start() {
it_bB = getActivePlayerIt(getCurrentBeRo()->getBigBlindPositionId()); it_bB = getActivePlayerIt(getCurrentBeRo()->getBigBlindPositionId());
if(it_sB != getActivePlayerList()->end() && it_bB != getActivePlayerList()->end()) { 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()); 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");
} }
else { LOG_ERROR(__FILE__ << " (" << __LINE__ << "): Log Error: cannot find sBID or bBID"); }
myGui->flushLogAtHand(); myGui->flushLogAtHand();
// deal cards // deal cards
@@ -389,7 +394,8 @@ void LocalHand::start() {
myGui->nextPlayerAnimation(); myGui->nextPlayerAnimation();
} }
void LocalHand::assignButtons() { void LocalHand::assignButtons()
{
size_t i; size_t i;
PlayerListIterator it; PlayerListIterator it;
@@ -475,8 +481,7 @@ void LocalHand::assignButtons() {
// 1 to do not log this // 1 to do not log this
(*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1); (*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1);
} } else {
else {
(*it_c)->setMySet(smallBlind); (*it_c)->setMySet(smallBlind);
} }
} }
@@ -491,8 +496,7 @@ void LocalHand::assignButtons() {
// 1 to do not log this // 1 to do not log this
(*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1); (*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1);
} } else {
else {
(*it_c)->setMySet(2*smallBlind); (*it_c)->setMySet(2*smallBlind);
} }
} }
@@ -500,7 +504,8 @@ void LocalHand::assignButtons() {
} }
void LocalHand::switchRounds() { void LocalHand::switchRounds()
{
PlayerListIterator it, it_1; PlayerListIterator it, it_1;
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
@@ -627,27 +632,33 @@ void LocalHand::switchRounds() {
case 0: { case 0: {
// start preflop // start preflop
myGui->preflopAnimation1(); myGui->preflopAnimation1();
} break; }
break;
case 1: { case 1: {
// start flop // start flop
myGui->flopAnimation1(); myGui->flopAnimation1();
} break; }
break;
case 2: { case 2: {
// start turn // start turn
myGui->turnAnimation1(); myGui->turnAnimation1();
} break; }
break;
case 3: { case 3: {
// start river // start river
myGui->riverAnimation1(); myGui->riverAnimation1();
} break; }
break;
case 4: { case 4: {
// start post river // start post river
myGui->postRiverAnimation1(); myGui->postRiverAnimation1();
} break; }
default: {} break;
default:
{}
@@ -655,7 +666,8 @@ void LocalHand::switchRounds() {
} }
PlayerListIterator LocalHand::getSeatIt(unsigned uniqueId) const { PlayerListIterator LocalHand::getSeatIt(unsigned uniqueId) const
{
PlayerListIterator it; 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; 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; PlayerListIterator it;
@@ -698,7 +712,8 @@ PlayerListIterator LocalHand::getRunningPlayerIt(unsigned uniqueId) const {
} }
void LocalHand::setLastActionPlayer(unsigned theValue) { void LocalHand::setLastActionPlayer(unsigned theValue)
{
lastActionPlayer = theValue; lastActionPlayer = theValue;
myBoard->setLastActionPlayer(theValue); myBoard->setLastActionPlayer(theValue);
} }
+95 -32
View File
@@ -31,57 +31,120 @@
class Log; class Log;
class LocalHand : public HandInterface{ class LocalHand : public HandInterface
{
public: public:
LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface*, boost::shared_ptr<BoardInterface>, Log*, PlayerList, PlayerList, PlayerList, int, int, unsigned, int, int); LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface*, boost::shared_ptr<BoardInterface>, Log*, PlayerList, PlayerList, PlayerList, int, int, unsigned, int, int);
~LocalHand(); ~LocalHand();
void start(); void start();
PlayerList getSeatsList() const {return seatsList;} PlayerList getSeatsList() const {
PlayerList getActivePlayerList() const {return activePlayerList;} return seatsList;
PlayerList getRunningPlayerList() const {return runningPlayerList;} }
PlayerList getActivePlayerList() const {
return activePlayerList;
}
PlayerList getRunningPlayerList() const {
return runningPlayerList;
}
boost::shared_ptr<BoardInterface> getBoard() const { return myBoard; } boost::shared_ptr<BoardInterface> getBoard() const {
boost::shared_ptr<BeRoInterface> getPreflop() const { return myBeRo[GAME_STATE_PREFLOP]; } return myBoard;
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> getPreflop() const {
boost::shared_ptr<BeRoInterface> getRiver() const { return myBeRo[GAME_STATE_RIVER]; } return myBeRo[GAME_STATE_PREFLOP];
GuiInterface* getGuiInterface() const { return myGui; } }
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const { return myBeRo[currentRound]; } 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; } void setMyID(int theValue) {
int getMyID() const { return myID; } myID = theValue;
}
int getMyID() const {
return myID;
}
void setStartQuantityPlayers(int theValue) { startQuantityPlayers = theValue; } void setStartQuantityPlayers(int theValue) {
int getStartQuantityPlayers() const { return startQuantityPlayers; } startQuantityPlayers = theValue;
}
int getStartQuantityPlayers() const {
return startQuantityPlayers;
}
void setCurrentRound(int theValue) { currentRound = theValue; } void setCurrentRound(int theValue) {
int getCurrentRound() const { return currentRound; } currentRound = theValue;
}
int getCurrentRound() const {
return currentRound;
}
void setDealerPosition(int theValue) { dealerPosition = theValue; } void setDealerPosition(int theValue) {
int getDealerPosition() const { return dealerPosition; } dealerPosition = theValue;
}
int getDealerPosition() const {
return dealerPosition;
}
void setSmallBlind(int theValue) { smallBlind = theValue; } void setSmallBlind(int theValue) {
int getSmallBlind() const { return smallBlind; } smallBlind = theValue;
}
int getSmallBlind() const {
return smallBlind;
}
void setAllInCondition(bool theValue) { allInCondition = theValue; } void setAllInCondition(bool theValue) {
bool getAllInCondition() const { return allInCondition; } allInCondition = theValue;
}
bool getAllInCondition() const {
return allInCondition;
}
void setStartCash(int theValue) { startCash = theValue; } void setStartCash(int theValue) {
int getStartCash() const { return startCash; } startCash = theValue;
}
int getStartCash() const {
return startCash;
}
void setBettingRoundsPlayed(int theValue) { bettingRoundsPlayed = theValue; } void setBettingRoundsPlayed(int theValue) {
int getBettingRoundsPlayed() const { return bettingRoundsPlayed; } bettingRoundsPlayed = theValue;
}
int getBettingRoundsPlayed() const {
return bettingRoundsPlayed;
}
void setLastPlayersTurn(int theValue) { lastPlayersTurn = theValue; } void setLastPlayersTurn(int theValue) {
int getLastPlayersTurn() const { return lastPlayersTurn; } lastPlayersTurn = theValue;
}
int getLastPlayersTurn() const {
return lastPlayersTurn;
}
void setLastActionPlayer ( unsigned theValue ); void setLastActionPlayer ( unsigned theValue );
unsigned getLastActionPlayer() const { return lastActionPlayer; } unsigned getLastActionPlayer() const {
return lastActionPlayer;
}
void setCardsShown(bool theValue) { cardsShown = theValue; } void setCardsShown(bool theValue) {
bool getCardsShown() const { return cardsShown; } cardsShown = theValue;
}
bool getCardsShown() const {
return cardsShown;
}
void assignButtons(); void assignButtons();
File diff suppressed because it is too large. Load diff
+150 -53
View File
@@ -30,7 +30,8 @@ class CardsValue;
class ConfigFile; class ConfigFile;
class HandInterface; class HandInterface;
class LocalPlayer : public PlayerInterface{ class LocalPlayer : public PlayerInterface
{
public: public:
LocalPlayer(ConfigFile*, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); LocalPlayer(ConfigFile*, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB);
@@ -38,92 +39,178 @@ public:
void setHand(HandInterface *); void setHand(HandInterface *);
int getMyID() const { return myID; } int getMyID() const {
unsigned getMyUniqueID() const { return myUniqueID; } return myID;
PlayerType getMyType() const { return myType; } }
unsigned getMyUniqueID() const {
return myUniqueID;
}
PlayerType getMyType() const {
return myType;
}
void setMyDude(int theValue) { myDude = theValue; } void setMyDude(int theValue) {
int getMyDude() const { return myDude; } myDude = theValue;
}
int getMyDude() const {
return myDude;
}
void setMyDude4(int theValue) { myDude4 = theValue; } void setMyDude4(int theValue) {
int getMyDude4() const { return myDude4; } myDude4 = theValue;
}
int getMyDude4() const {
return myDude4;
}
void setMyName(const std::string& theValue) { myName = theValue; } void setMyName(const std::string& theValue) {
std::string getMyName() const { return myName; } myName = theValue;
}
std::string getMyName() const {
return myName;
}
void setMyAvatar(const std::string& theValue) { myAvatar = theValue; } void setMyAvatar(const std::string& theValue) {
std::string getMyAvatar() const { return myAvatar; } myAvatar = theValue;
}
std::string getMyAvatar() const {
return myAvatar;
}
void setMyCash(int theValue) { myCash = theValue; } void setMyCash(int theValue) {
int getMyCash() const { return myCash; } myCash = theValue;
}
int getMyCash() const {
return myCash;
}
void setMySet(int theValue) { myLastRelativeSet = theValue; mySet += theValue; myCash -= theValue; } void setMySet(int theValue) {
void setMySetAbsolute(int theValue) { mySet = theValue; } myLastRelativeSet = theValue;
void setMySetNull() { mySet = 0; myLastRelativeSet = 0; } mySet += theValue;
int getMySet() const { return mySet;} myCash -= theValue;
int getMyLastRelativeSet() const { return myLastRelativeSet; } }
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) { void setMyAction(int theValue, bool blind = 0) {
myAction = theValue; myAction = theValue;
// logging for human player // logging for human player
if(myAction && !blind) currentHand->getGuiInterface()->logPlayerActionMsg(myName, myID, myAction, mySet); if(myAction && !blind) currentHand->getGuiInterface()->logPlayerActionMsg(myName, myID, myAction, mySet);
} }
int getMyAction() const { return myAction; } int getMyAction() const {
return myAction;
}
void setMyButton(int theValue) { myButton = theValue; } void setMyButton(int theValue) {
int getMyButton() const { return myButton; } myButton = theValue;
}
int getMyButton() const {
return myButton;
}
void setMyActiveStatus(bool theValue) { myActiveStatus = theValue; } void setMyActiveStatus(bool theValue) {
bool getMyActiveStatus() const { return myActiveStatus; } myActiveStatus = theValue;
}
bool getMyActiveStatus() const {
return myActiveStatus;
}
void setMyStayOnTableStatus(bool theValue) { myStayOnTableStatus = theValue; } void setMyStayOnTableStatus(bool theValue) {
bool getMyStayOnTableStatus() const { return myStayOnTableStatus; } myStayOnTableStatus = theValue;
}
bool getMyStayOnTableStatus() const {
return myStayOnTableStatus;
}
void setMyCards(int* theValue) { int i; for(i=0; i<2; i++) myCards[i] = theValue[i]; } void setMyCards(int* theValue) {
void getMyCards(int* theValue) const { int i; for(i=0; i<2; i++) theValue[i] = myCards[i]; } 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;} void setMyTurn(bool theValue) {
bool getMyTurn() const{ return myTurn;} myTurn = theValue;
}
bool getMyTurn() const {
return myTurn;
}
void setMyCardsFlip(bool theValue, int state){ void setMyCardsFlip(bool theValue, int state) {
myCardsFlip = theValue; myCardsFlip = theValue;
// log flipping cards // log flipping cards
if(myCardsFlip) { if(myCardsFlip) {
switch(state) { 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; break;
case 2: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]); case 2:
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]);
break; 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; break;
default: ; default:
;
} }
} }
} }
bool getMyCardsFlip() const{ return myCardsFlip;} bool getMyCardsFlip() const {
return myCardsFlip;
}
void setMyCardsValueInt(int theValue) { myCardsValueInt = theValue;} void setMyCardsValueInt(int theValue) {
int getMyCardsValueInt() const { return myCardsValueInt; } myCardsValueInt = theValue;
}
int getMyCardsValueInt() const {
return myCardsValueInt;
}
void setMyBestHandPosition(int* theValue) void setMyBestHandPosition(int* theValue) {
{
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
myBestHandPosition[i] = theValue[i]; myBestHandPosition[i] = theValue[i];
} }
void getMyBestHandPosition(int* theValue) const void getMyBestHandPosition(int* theValue) const {
{
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
theValue[i] = myBestHandPosition[i]; theValue[i] = myBestHandPosition[i];
} }
void setMyRoundStartCash(int theValue) { myRoundStartCash = theValue;} void setMyRoundStartCash(int theValue) {
int getMyRoundStartCash() const { return myRoundStartCash; } myRoundStartCash = theValue;
}
int getMyRoundStartCash() const {
return myRoundStartCash;
}
void setLastMoneyWon ( int theValue ) { lastMoneyWon = theValue; } void setLastMoneyWon ( int theValue ) {
int getLastMoneyWon() const { return lastMoneyWon; } 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; } void setMyAverageSets(int theValue) {
int getMyAverageSets() const { return (myAverageSets[0]+myAverageSets[1]+myAverageSets[2]+myAverageSets[3])/4; } 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) { void setMyAggressive(bool theValue) {
int i; int i;
@@ -140,17 +227,27 @@ public:
return sum; return sum;
} }
void setSBluff ( int theValue ) { sBluff = theValue; } void setSBluff ( int theValue ) {
int getSBluff() const { return sBluff; } sBluff = theValue;
}
int getSBluff() const {
return sBluff;
}
void setSBluffStatus ( bool theValue ) { sBluffStatus = theValue; } void setSBluffStatus ( bool theValue ) {
bool getSBluffStatus() const { return sBluffStatus; } sBluffStatus = theValue;
}
bool getSBluffStatus() const {
return sBluffStatus;
}
void setMyWinnerState ( bool theValue, int pot ) { void setMyWinnerState ( bool theValue, int pot ) {
if(theValue) myWinnerState = theValue; 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;
}
+1 -1
View File
@@ -24,7 +24,7 @@
class Replay class Replay
{ {
public: public:
Replay(); Replay();
~Replay(); ~Replay();
+6 -8
View File
@@ -27,7 +27,8 @@
using namespace std; 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; int r = end-start+1;
unsigned char rand_buf[4]; 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++) { for (i=0; i<howMany; i++) {
if(!RAND_bytes(rand_buf, 4)) if(!RAND_bytes(rand_buf, 4)) {
{
LOG_MSG("RAND_bytes failed!"); LOG_MSG("RAND_bytes failed!");
} }
@@ -54,14 +54,13 @@ void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool
} }
} }
} } else {
else {
int *tempArray = new int[end-start+1]; int *tempArray = new int[end-start+1];
for (i=0; i<(end-start+1); i++) tempArray[i]=1; for (i=0; i<(end-start+1); i++) tempArray[i]=1;
if(bad) { if(bad) {
for(i=0;i<countBad;i++) { for(i=0; i<countBad; i++) {
tempArray[bad[i]]=0; tempArray[bad[i]]=0;
} }
} }
@@ -69,8 +68,7 @@ void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool
int counter(0); int counter(0);
while (counter < howMany) { while (counter < howMany) {
if(!RAND_bytes(rand_buf, 4)) if(!RAND_bytes(rand_buf, 4)) {
{
LOG_MSG("RAND_bytes failed!"); LOG_MSG("RAND_bytes failed!");
} }
+2 -1
View File
@@ -20,7 +20,8 @@
#ifndef TOOLS_H #ifndef TOOLS_H
#define TOOLS_H #define TOOLS_H
class Tools{ class Tools
{
public: public:
static void getRandNumber(int, int, int, int*, bool, int* = 0, int = 0); static void getRandNumber(int, int, int, int*, bool, int* = 0, int = 0);
+6 -4
View File
@@ -166,7 +166,8 @@ Log::~Log()
} }
void 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;
@@ -196,7 +197,7 @@ Log::logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned deal
sql += "," + boost::lexical_cast<string>(startCash); sql += "," + boost::lexical_cast<string>(startCash);
sql += "," + boost::lexical_cast<string>(startSmallBlind); sql += "," + boost::lexical_cast<string>(startSmallBlind);
sql += "," + boost::lexical_cast<string>(dealerPosition); sql += "," + boost::lexical_cast<string>(dealerPosition);
for(it_c = seatsList->begin();it_c!=seatsList->end();it_c++) { for(it_c = seatsList->begin(); it_c!=seatsList->end(); it_c++) {
if((*it_c)->getMyActiveStatus()) { if((*it_c)->getMyActiveStatus()) {
sql += ",\"" + (*it_c)->getMyName() +"\""; sql += ",\"" + (*it_c)->getMyName() +"\"";
} else { } else {
@@ -213,7 +214,8 @@ Log::logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned deal
} }
void 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) {
@@ -247,7 +249,7 @@ Log::logNewHandMsg(int handID, unsigned dealerPosition, int smallBlind, unsigned
sql += "," + boost::lexical_cast<string>(smallBlindPosition+1); sql += "," + boost::lexical_cast<string>(smallBlindPosition+1);
sql += "," + boost::lexical_cast<string>(bigBlind); sql += "," + boost::lexical_cast<string>(bigBlind);
sql += "," + boost::lexical_cast<string>(bigBlindPosition+1); sql += "," + boost::lexical_cast<string>(bigBlindPosition+1);
for(it_c = seatsList->begin();it_c!=seatsList->end();it_c++) { for(it_c = seatsList->begin(); it_c!=seatsList->end(); it_c++) {
if((*it_c)->getMyActiveStatus()) { if((*it_c)->getMyActiveStatus()) {
sql += "," + boost::lexical_cast<string>((*it_c)->getMyCash()); sql += "," + boost::lexical_cast<string>((*it_c)->getMyCash());
} else { } else {
+1 -1
View File
@@ -20,7 +20,7 @@
#include "clientbero.h" #include "clientbero.h"
ClientBeRo::ClientBeRo(HandInterface* hi, int /*id*/, unsigned /*dP*/, int sB, GameState gS) 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), : 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), firstRoundLastPlayersTurnId(0), highestSet(0), firstRound(true), smallBlindPosition(0), smallBlind(sB), minimumRaise(2*sB), fullBetRule(false),
lastActionPlayer(0) lastActionPlayer(0)
{ {
+2 -1
View File
@@ -28,7 +28,8 @@ class HandInterface;
/** /**
@author FThauer FHammer <webmaster@pokerth.net> @author FThauer FHammer <webmaster@pokerth.net>
*/ */
class ClientBeRo : public BeRoInterface{ class ClientBeRo : public BeRoInterface
{
public: public:
ClientBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS); ClientBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS);
~ClientBeRo(); ~ClientBeRo();
+1 -1
View File
@@ -24,7 +24,7 @@
using namespace std; using namespace std;
ClientBoard::ClientBoard(unsigned dp) 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; myCards[0] = myCards[1] = myCards[2] = myCards[3] = myCards[4] = 0;
} }
+1 -1
View File
@@ -22,7 +22,7 @@
using namespace std; 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) 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), : 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), smallBlind(sB), startCash(sC), lastPlayersTurn(-1), allInCondition(0),
cardsShown(false), bettingRoundsPlayed(0) cardsShown(false), bettingRoundsPlayed(0)
{ {
+1 -1
View File
@@ -32,7 +32,7 @@
class ClientHand : public HandInterface class ClientHand : public HandInterface
{ {
public: public:
ClientHand ( boost::shared_ptr<EngineFactory> f, GuiInterface*, boost::shared_ptr<BoardInterface>, Log*, PlayerList, PlayerList, PlayerList , int, int, int, int, int ); ClientHand ( boost::shared_ptr<EngineFactory> f, GuiInterface*, boost::shared_ptr<BoardInterface>, Log*, PlayerList, PlayerList, PlayerList , int, int, int, int, int );
~ClientHand(); ~ClientHand();
+12 -11
View File
@@ -23,7 +23,7 @@ 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) 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), : 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), 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), myAction(0), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(true), myTurn(false), myCardsFlip(false), myRoundStartCash(0),
lastMoneyWon(0), sBluff(0), sBluffStatus(false), myWinnerState(false) lastMoneyWon(0), sBluff(0), sBluffStatus(false), myWinnerState(false)
@@ -266,13 +266,17 @@ ClientPlayer::setMyCardsFlip(bool theValue, int state)
// log flipping cards // log flipping cards
if (myCardsFlip) { if (myCardsFlip) {
switch(state) { 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; break;
case 2: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]); case 2:
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]);
break; 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; break;
default: ; default:
;
} }
} }
} }
@@ -363,8 +367,7 @@ void
ClientPlayer::setMyAggressive(bool theValue) ClientPlayer::setMyAggressive(bool theValue)
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); 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[i] = myAggressive[i+1];
} }
myAggressive[6] = theValue; myAggressive[6] = theValue;
@@ -375,8 +378,7 @@ ClientPlayer::getMyAggressive() const
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
int sum = 0; int sum = 0;
for (int i=0; i<7; i++) for (int i=0; i<7; i++) {
{
sum += myAggressive[i]; sum += myAggressive[i];
} }
return sum; return sum;
@@ -527,8 +529,7 @@ bool ClientPlayer::checkIfINeedToShowCards()
{ {
boost::recursive_mutex::scoped_lock lock(m_syncMutex); boost::recursive_mutex::scoped_lock lock(m_syncMutex);
std::list<unsigned> playerNeedToShowCardsList = currentHand->getBoard()->getPlayerNeedToShowCards(); std::list<unsigned> playerNeedToShowCardsList = currentHand->getBoard()->getPlayerNeedToShowCards();
for(std::list<unsigned>::iterator it = playerNeedToShowCardsList.begin(); it != playerNeedToShowCardsList.end(); ++it) for(std::list<unsigned>::iterator it = playerNeedToShowCardsList.begin(); it != playerNeedToShowCardsList.end(); ++it) {
{
if(*it == myUniqueID) return true; if(*it == myUniqueID) return true;
} }
+5 -2
View File
@@ -29,7 +29,8 @@ class CardsValue;
class ConfigFile; class ConfigFile;
class HandInterface; class HandInterface;
class ClientPlayer : public PlayerInterface{ class ClientPlayer : public PlayerInterface
{
public: public:
ClientPlayer(ConfigFile*, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB); ClientPlayer(ConfigFile*, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB);
~ClientPlayer(); ~ClientPlayer();
@@ -134,7 +135,9 @@ public:
boost::shared_ptr<SessionData> getNetSessionData(); boost::shared_ptr<SessionData> getNetSessionData();
// unused as client // unused as client
unsigned getActionTimeoutCounter() const {return 0;} unsigned getActionTimeoutCounter() const {
return 0;
}
void incrementActionTimeoutCounter() {} void incrementActionTimeoutCounter() {}
void resetActionTimeoutCounter() {} void resetActionTimeoutCounter() {}
+2 -1
View File
@@ -25,7 +25,8 @@
class SessionData; class SessionData;
class PlayerInterface{ class PlayerInterface
{
public: public:
virtual ~PlayerInterface() =0; virtual ~PlayerInterface() =0;
+11 -18
View File
@@ -33,7 +33,7 @@ using namespace std;
Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory, Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
const PlayerDataList &playerDataList, const GameData &gameData, const PlayerDataList &playerDataList, const GameData &gameData,
const StartData &startData, int gameId, Log* log) const StartData &startData, int gameId, Log* log)
: myFactory(factory), myGui(gui), myLog(log), startQuantityPlayers(startData.numberOfPlayers), : myFactory(factory), myGui(gui), myLog(log), startQuantityPlayers(startData.numberOfPlayers),
startCash(gameData.startMoney), startSmallBlind(gameData.firstSmallBlind), startCash(gameData.startMoney), startSmallBlind(gameData.firstSmallBlind),
myGameID(gameId), currentSmallBlind(gameData.firstSmallBlind), currentHandID(0), dealerPosition(0), myGameID(gameId), currentSmallBlind(gameData.firstSmallBlind), currentHandID(0), dealerPosition(0),
lastHandBlindsRaised(1), lastTimeBlindsRaised(0), myGameData(gameData), lastHandBlindsRaised(1), lastTimeBlindsRaised(0), myGameData(gameData),
@@ -56,8 +56,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
PlayerDataList::const_iterator player_i = playerDataList.begin(); PlayerDataList::const_iterator player_i = playerDataList.begin();
PlayerDataList::const_iterator player_end = playerDataList.end(); PlayerDataList::const_iterator player_end = playerDataList.end();
while (player_i != player_end) while (player_i != player_end) {
{
if ((*player_i)->GetUniqueId() == dealerPosition) if ((*player_i)->GetUniqueId() == dealerPosition)
break; break;
++player_i; ++player_i;
@@ -84,8 +83,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
PlayerType type = PLAYER_TYPE_COMPUTER; PlayerType type = PLAYER_TYPE_COMPUTER;
boost::shared_ptr<SessionData> myNetSession; boost::shared_ptr<SessionData> myNetSession;
if (player_i != player_end) if (player_i != player_end) {
{
uniqueId = (*player_i)->GetUniqueId(); uniqueId = (*player_i)->GetUniqueId();
type = (*player_i)->GetType(); type = (*player_i)->GetType();
myName = (*player_i)->GetName(); myName = (*player_i)->GetName();
@@ -207,10 +205,8 @@ boost::shared_ptr<PlayerInterface> Game::getPlayerByUniqueId(unsigned id)
boost::shared_ptr<PlayerInterface> tmpPlayer; boost::shared_ptr<PlayerInterface> tmpPlayer;
PlayerListIterator i = getSeatsList()->begin(); PlayerListIterator i = getSeatsList()->begin();
PlayerListIterator end = getSeatsList()->end(); PlayerListIterator end = getSeatsList()->end();
while (i != end) while (i != end) {
{ if ((*i)->getMyUniqueID() == id) {
if ((*i)->getMyUniqueID() == id)
{
tmpPlayer = *i; tmpPlayer = *i;
break; break;
} }
@@ -227,7 +223,8 @@ boost::shared_ptr<PlayerInterface> Game::getCurrentPlayer()
return tmpPlayer; return tmpPlayer;
} }
void Game::raiseBlinds() { void Game::raiseBlinds()
{
bool raiseBlinds = false; bool raiseBlinds = false;
@@ -236,8 +233,7 @@ void Game::raiseBlinds() {
raiseBlinds = true; raiseBlinds = true;
lastHandBlindsRaised = currentHandID; lastHandBlindsRaised = currentHandID;
} }
} } else {
else {
if (lastTimeBlindsRaised + myGameData.raiseSmallBlindEveryMinutesValue <= blindsTimer.elapsed().total_seconds()/60) { if (lastTimeBlindsRaised + myGameData.raiseSmallBlindEveryMinutesValue <= blindsTimer.elapsed().total_seconds()/60) {
raiseBlinds = true; raiseBlinds = true;
lastTimeBlindsRaised = blindsTimer.elapsed().total_seconds()/60; lastTimeBlindsRaised = blindsTimer.elapsed().total_seconds()/60;
@@ -248,18 +244,15 @@ void Game::raiseBlinds() {
// Now we check how the blinds should be raised // Now we check how the blinds should be raised
if (myGameData.raiseMode == DOUBLE_BLINDS) { if (myGameData.raiseMode == DOUBLE_BLINDS) {
currentSmallBlind *= 2; currentSmallBlind *= 2;
} } else {
else {
if(!blindsList.empty()) { if(!blindsList.empty()) {
currentSmallBlind = blindsList.front(); currentSmallBlind = blindsList.front();
blindsList.pop_front(); blindsList.pop_front();
} } else {
else {
// The position exceeds the list // The position exceeds the list
if (myGameData.afterManualBlindsMode == AFTERMB_DOUBLE_BLINDS) { if (myGameData.afterManualBlindsMode == AFTERMB_DOUBLE_BLINDS) {
currentSmallBlind *= 2; currentSmallBlind *= 2;
} } else {
else {
if(myGameData.afterManualBlindsMode == AFTERMB_RAISE_ABOUT) { if(myGameData.afterManualBlindsMode == AFTERMB_RAISE_ABOUT) {
currentSmallBlind += myGameData.afterMBAlwaysRaiseValue; currentSmallBlind += myGameData.afterMBAlwaysRaiseValue;
} }
+47 -16
View File
@@ -35,7 +35,8 @@ struct GameData;
struct StartData; struct StartData;
class Game { class Game
{
public: public:
Game(GuiInterface *gui, boost::shared_ptr<EngineFactory> factory, Game(GuiInterface *gui, boost::shared_ptr<EngineFactory> factory,
@@ -50,28 +51,58 @@ public:
boost::shared_ptr<HandInterface> getCurrentHand(); boost::shared_ptr<HandInterface> getCurrentHand();
const boost::shared_ptr<HandInterface> getCurrentHand() const; const boost::shared_ptr<HandInterface> getCurrentHand() const;
PlayerList getSeatsList() const {return seatsList;} PlayerList getSeatsList() const {
PlayerList getActivePlayerList() const {return activePlayerList;} return seatsList;
PlayerList getRunningPlayerList() const {return runningPlayerList;} }
PlayerList getActivePlayerList() const {
return activePlayerList;
}
PlayerList getRunningPlayerList() const {
return runningPlayerList;
}
void setStartQuantityPlayers(int theValue) { startQuantityPlayers = theValue; } void setStartQuantityPlayers(int theValue) {
int getStartQuantityPlayers() const { return startQuantityPlayers; } startQuantityPlayers = theValue;
}
int getStartQuantityPlayers() const {
return startQuantityPlayers;
}
void setStartSmallBlind(int theValue) { startSmallBlind = theValue; } void setStartSmallBlind(int theValue) {
int getStartSmallBlind() const { return startSmallBlind; } startSmallBlind = theValue;
}
int getStartSmallBlind() const {
return startSmallBlind;
}
void setStartCash(int theValue) { startCash = theValue; } void setStartCash(int theValue) {
int getStartCash() const { return startCash; } startCash = theValue;
}
int getStartCash() const {
return startCash;
}
int getMyGameID() const { return myGameID; } int getMyGameID() const {
return myGameID;
}
void setCurrentSmallBlind(int theValue) { currentSmallBlind = theValue; } void setCurrentSmallBlind(int theValue) {
int getCurrentSmallBlind() const { return currentSmallBlind; } currentSmallBlind = theValue;
}
int getCurrentSmallBlind() const {
return currentSmallBlind;
}
void setCurrentHandID(int theValue) { currentHandID = theValue; } void setCurrentHandID(int theValue) {
int getCurrentHandID() const { return currentHandID; } currentHandID = theValue;
}
int getCurrentHandID() const {
return currentHandID;
}
unsigned getDealerPosition() const { return dealerPosition; } unsigned getDealerPosition() const {
return dealerPosition;
}
boost::shared_ptr<PlayerInterface> getPlayerByUniqueId(unsigned id); boost::shared_ptr<PlayerInterface> getPlayerByUniqueId(unsigned id);
boost::shared_ptr<PlayerInterface> getCurrentPlayer(); boost::shared_ptr<PlayerInterface> getCurrentPlayer();
+15 -18
View File
@@ -51,7 +51,8 @@ enum ServerMode {
enum ServerTransportProtocol { enum ServerTransportProtocol {
TRANSPORT_PROTOCOL_TCP = 1, TRANSPORT_PROTOCOL_TCP = 1,
TRANSPORT_PROTOCOL_SCTP = 2, TRANSPORT_PROTOCOL_SCTP = 2,
TRANSPORT_PROTOCOL_TCP_SCTP = 3}; TRANSPORT_PROTOCOL_TCP_SCTP = 3
};
enum GameState { enum GameState {
GAME_STATE_PREFLOP = 0, GAME_STATE_PREFLOP = 0,
@@ -60,7 +61,8 @@ enum GameState {
GAME_STATE_RIVER, GAME_STATE_RIVER,
GAME_STATE_POST_RIVER, GAME_STATE_POST_RIVER,
GAME_STATE_PREFLOP_SMALL_BLIND = 0xF0, GAME_STATE_PREFLOP_SMALL_BLIND = 0xF0,
GAME_STATE_PREFLOP_BIG_BLIND = 0xF1 }; GAME_STATE_PREFLOP_BIG_BLIND = 0xF1
};
enum PlayerAction { enum PlayerAction {
PLAYER_ACTION_NONE = 0, PLAYER_ACTION_NONE = 0,
@@ -69,18 +71,17 @@ enum PlayerAction {
PLAYER_ACTION_CALL, PLAYER_ACTION_CALL,
PLAYER_ACTION_BET, PLAYER_ACTION_BET,
PLAYER_ACTION_RAISE, PLAYER_ACTION_RAISE,
PLAYER_ACTION_ALLIN }; PLAYER_ACTION_ALLIN
};
enum PlayerActionCode enum PlayerActionCode {
{
ACTION_CODE_VALID = 0, ACTION_CODE_VALID = 0,
ACTION_CODE_INVALID_STATE, ACTION_CODE_INVALID_STATE,
ACTION_CODE_NOT_YOUR_TURN, ACTION_CODE_NOT_YOUR_TURN,
ACTION_CODE_NOT_ALLOWED ACTION_CODE_NOT_ALLOWED
}; };
enum DenyKickPlayerReason enum DenyKickPlayerReason {
{
KICK_DENIED_INVALID_STATE = 0, KICK_DENIED_INVALID_STATE = 0,
KICK_DENIED_TOO_FEW_PLAYERS, KICK_DENIED_TOO_FEW_PLAYERS,
KICK_DENIED_TEMPORARY, KICK_DENIED_TEMPORARY,
@@ -88,28 +89,24 @@ enum DenyKickPlayerReason
KICK_DENIED_INVALID_PLAYER_ID KICK_DENIED_INVALID_PLAYER_ID
}; };
enum KickVote enum KickVote {
{
KICK_VOTE_AGAINST = 0, KICK_VOTE_AGAINST = 0,
KICK_VOTE_IN_FAVOUR KICK_VOTE_IN_FAVOUR
}; };
enum DenyVoteReason enum DenyVoteReason {
{
VOTE_DENIED_INVALID_PETITION = 0, VOTE_DENIED_INVALID_PETITION = 0,
VOTE_DENIED_ALREADY_VOTED VOTE_DENIED_ALREADY_VOTED
}; };
enum EndPetitionReason enum EndPetitionReason {
{
PETITION_END_ENOUGH_VOTES = 0, PETITION_END_ENOUGH_VOTES = 0,
PETITION_END_NOT_ENOUGH_PLAYERS, PETITION_END_NOT_ENOUGH_PLAYERS,
PETITION_END_PLAYER_LEFT, PETITION_END_PLAYER_LEFT,
PETITION_END_TIMEOUT PETITION_END_TIMEOUT
}; };
enum DenyGameInvitationReason enum DenyGameInvitationReason {
{
DENY_GAME_INVITATION_NO = 0, DENY_GAME_INVITATION_NO = 0,
DENY_GAME_INVITATION_BUSY DENY_GAME_INVITATION_BUSY
}; };
@@ -118,15 +115,15 @@ enum Button {
BUTTON_NONE = 0, BUTTON_NONE = 0,
BUTTON_DEALER, BUTTON_DEALER,
BUTTON_SMALL_BLIND, BUTTON_SMALL_BLIND,
BUTTON_BIG_BLIND }; BUTTON_BIG_BLIND
};
enum NetTimeoutReason { enum NetTimeoutReason {
NETWORK_TIMEOUT_GENERIC = 0, NETWORK_TIMEOUT_GENERIC = 0,
NETWORK_TIMEOUT_GAME_ADMIN_IDLE NETWORK_TIMEOUT_GAME_ADMIN_IDLE
}; };
struct ServerStats struct ServerStats {
{
ServerStats() ServerStats()
: numberOfPlayersOnServer(0), numberOfGamesOpen(0), totalPlayersEverLoggedIn(0), : numberOfPlayersOnServer(0), numberOfGamesOpen(0), totalPlayersEverLoggedIn(0),
totalGamesEverCreated(0), maxGamesOpen(0), maxPlayersLoggedIn(0) {} totalGamesEverCreated(0), maxGamesOpen(0), maxPlayersLoggedIn(0) {}
+9 -18
View File
@@ -28,43 +28,37 @@
typedef std::list<unsigned> PlayerIdList; typedef std::list<unsigned> PlayerIdList;
enum GameMode enum GameMode {
{
GAME_MODE_CREATED = 1, GAME_MODE_CREATED = 1,
GAME_MODE_STARTED, GAME_MODE_STARTED,
GAME_MODE_CLOSED GAME_MODE_CLOSED
}; };
enum GameType enum GameType {
{
GAME_TYPE_NORMAL = 1, GAME_TYPE_NORMAL = 1,
GAME_TYPE_REGISTERED_ONLY, GAME_TYPE_REGISTERED_ONLY,
GAME_TYPE_INVITE_ONLY, GAME_TYPE_INVITE_ONLY,
GAME_TYPE_RANKING GAME_TYPE_RANKING
}; };
enum RaiseIntervalMode enum RaiseIntervalMode {
{
RAISE_ON_HANDNUMBER = 1, RAISE_ON_HANDNUMBER = 1,
RAISE_ON_MINUTES RAISE_ON_MINUTES
}; };
enum RaiseMode enum RaiseMode {
{
DOUBLE_BLINDS = 1, DOUBLE_BLINDS = 1,
MANUAL_BLINDS_ORDER MANUAL_BLINDS_ORDER
}; };
enum AfterManualBlindsMode enum AfterManualBlindsMode {
{
AFTERMB_DOUBLE_BLINDS = 1, AFTERMB_DOUBLE_BLINDS = 1,
AFTERMB_RAISE_ABOUT, AFTERMB_RAISE_ABOUT,
AFTERMB_STAY_AT_LAST_BLIND AFTERMB_STAY_AT_LAST_BLIND
}; };
// For the sake of simplicity, this is a struct. // For the sake of simplicity, this is a struct.
struct GameData struct GameData {
{
GameData() : gameType(GAME_TYPE_NORMAL), maxNumberOfPlayers(0), startMoney(0), GameData() : gameType(GAME_TYPE_NORMAL), maxNumberOfPlayers(0), startMoney(0),
firstSmallBlind(0), raiseIntervalMode(RAISE_ON_HANDNUMBER), firstSmallBlind(0), raiseIntervalMode(RAISE_ON_HANDNUMBER),
raiseSmallBlindEveryHandsValue(8), raiseSmallBlindEveryMinutesValue(1), raiseSmallBlindEveryHandsValue(8), raiseSmallBlindEveryMinutesValue(1),
@@ -87,8 +81,7 @@ struct GameData
int playerActionTimeoutSec; int playerActionTimeoutSec;
}; };
struct GameInfo struct GameInfo {
{
GameInfo() : mode(GAME_MODE_CREATED), adminPlayerId(0), isPasswordProtected(false) {} GameInfo() : mode(GAME_MODE_CREATED), adminPlayerId(0), isPasswordProtected(false) {}
std::string name; std::string name;
GameData data; GameData data;
@@ -98,15 +91,13 @@ struct GameInfo
bool isPasswordProtected; bool isPasswordProtected;
}; };
struct StartData struct StartData {
{
StartData() : startDealerPlayerId(0), numberOfPlayers(0) {} StartData() : startDealerPlayerId(0), numberOfPlayers(0) {}
unsigned startDealerPlayerId; unsigned startDealerPlayerId;
int numberOfPlayers; int numberOfPlayers;
}; };
struct VoteKickData struct VoteKickData {
{
VoteKickData() VoteKickData()
: petitionId(0), kickPlayerId(0), numVotesToKick(0), : petitionId(0), kickPlayerId(0), numVotesToKick(0),
numVotesInFavourOfKicking(0), numVotesAgainstKicking(0), timeLimitSec(0), numVotesInFavourOfKicking(0), numVotesAgainstKicking(0), timeLimitSec(0),
+189 -48
View File
@@ -25,7 +25,7 @@ using namespace std;
ServerGuiWrapper::ServerGuiWrapper(ConfigFile *config, ClientCallback *clientcb, ServerCallback *servercb, IrcCallback *irccb) 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)
{ {
} }
@@ -117,57 +117,198 @@ void ServerGuiWrapper::logPlayerWinGame(std::string /*playerName*/, int /*gameID
void ServerGuiWrapper::flushLogAtGame(int /*gameID*/) {} void ServerGuiWrapper::flushLogAtGame(int /*gameID*/) {}
void ServerGuiWrapper::flushLogAtHand() {} void ServerGuiWrapper::flushLogAtHand() {}
void ServerGuiWrapper::SignalNetClientServerListAdd(unsigned serverId) { if (myClientcb) myClientcb->SignalNetClientServerListAdd(serverId); } void ServerGuiWrapper::SignalNetClientServerListAdd(unsigned serverId)
void ServerGuiWrapper::SignalNetClientServerListClear() { if (myClientcb) myClientcb->SignalNetClientServerListClear(); } {
void ServerGuiWrapper::SignalNetClientServerListShow() { if (myClientcb) myClientcb->SignalNetClientServerListShow(); } 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::SignalNetClientLoginShow()
void ServerGuiWrapper::SignalNetClientPostRiverShowCards(unsigned playerId) { if (myClientcb) myClientcb->SignalNetClientPostRiverShowCards(playerId); } {
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::SignalNetClientConnect(int actionID)
void ServerGuiWrapper::SignalNetClientGameInfo(int actionID) { if (myClientcb) myClientcb->SignalNetClientGameInfo(actionID); } {
void ServerGuiWrapper::SignalNetClientError(int errorID, int osErrorID) { if (myClientcb) myClientcb->SignalNetClientError(errorID, osErrorID); } if (myClientcb) myClientcb->SignalNetClientConnect(actionID);
void ServerGuiWrapper::SignalNetClientNotification(int notificationId) { if (myClientcb) myClientcb->SignalNetClientNotification(notificationId); } }
void ServerGuiWrapper::SignalNetClientStatsUpdate(const ServerStats &stats) { if (myClientcb) myClientcb->SignalNetClientStatsUpdate(stats); } void ServerGuiWrapper::SignalNetClientGameInfo(int actionID)
void ServerGuiWrapper::SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec) { if (myClientcb) myClientcb->SignalNetClientShowTimeoutDialog(reason, remainingSec); } {
void ServerGuiWrapper::SignalNetClientRemovedFromGame(int notificationId) { if (myClientcb) myClientcb->SignalNetClientRemovedFromGame(notificationId); } if (myClientcb) myClientcb->SignalNetClientGameInfo(actionID);
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::SignalNetClientError(int errorID, int osErrorID)
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); } if (myClientcb) myClientcb->SignalNetClientError(errorID, osErrorID);
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::SignalNetClientNotification(int notificationId)
void ServerGuiWrapper::SignalNetClientGameListRemove(unsigned gameId) { if (myClientcb) myClientcb->SignalNetClientGameListRemove(gameId); } {
void ServerGuiWrapper::SignalNetClientGameListUpdateMode(unsigned gameId, GameMode mode) { if (myClientcb) myClientcb->SignalNetClientGameListUpdateMode(gameId, mode); } if (myClientcb) myClientcb->SignalNetClientNotification(notificationId);
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::SignalNetClientStatsUpdate(const ServerStats &stats)
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); } if (myClientcb) myClientcb->SignalNetClientStatsUpdate(stats);
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::SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec)
void ServerGuiWrapper::SignalNetClientMsgBox(const string &msg) { if (myClientcb) myClientcb->SignalNetClientMsgBox(msg); } {
void ServerGuiWrapper::SignalNetClientMsgBox(unsigned msgId) { if (myClientcb) myClientcb->SignalNetClientMsgBox(msgId); } if (myClientcb) myClientcb->SignalNetClientShowTimeoutDialog(reason, remainingSec);
void ServerGuiWrapper::SignalNetClientWaitDialog() { if (myClientcb) myClientcb->SignalNetClientWaitDialog(); } }
void ServerGuiWrapper::SignalNetClientWarningAutoFoldInRankingGame(unsigned remainingAutoFolds) { if (myClientcb) myClientcb->SignalNetClientWarningAutoFoldInRankingGame(remainingAutoFolds); } 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::SignalNetServerSuccess(int actionID)
void ServerGuiWrapper::SignalNetServerError(int errorID, int osErrorID) { if (myServercb) myServercb->SignalNetServerError(errorID, osErrorID); } {
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::SignalIrcConnect(const string &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); } if (myIrccb) myIrccb->SignalIrcConnect(server);
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::SignalIrcSelfJoined(const string &nickName, const std::string &channel)
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); } if (myIrccb) myIrccb->SignalIrcSelfJoined(nickName, channel);
void ServerGuiWrapper::SignalIrcError(int errorCode) { if (myIrccb) myIrccb->SignalIrcError(errorCode); } }
void ServerGuiWrapper::SignalIrcServerError(int errorCode) {if (myIrccb) myIrccb->SignalIrcServerError(errorCode); } 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::SignalLobbyPlayerJoined(unsigned playerId, const std::string &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); } 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::SignalSelfGameInvitation(unsigned gameId, unsigned 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); } 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);
}
+6 -2
View File
@@ -36,8 +36,12 @@ public:
boost::shared_ptr<Session> getSession(); boost::shared_ptr<Session> getSession();
void setSession(boost::shared_ptr<Session> session); void setSession(boost::shared_ptr<Session> session);
gameTableImpl* getMyW() const {return NULL;} gameTableImpl* getMyW() const {
guiLog* getMyGuiLog() const {return NULL;} return NULL;
}
guiLog* getMyGuiLog() const {
return NULL;
}
void refreshSet() const; void refreshSet() const;
void refreshCash() const; void refreshCash() const;
+2 -1
View File
@@ -31,7 +31,8 @@ class guiLog;
class Session; class Session;
class gameTableImpl; class gameTableImpl;
class GuiInterface : public ClientCallback, public ServerCallback, public IrcCallback { class GuiInterface : public ClientCallback, public ServerCallback, public IrcCallback
{
public: public:
virtual ~GuiInterface(); virtual ~GuiInterface();
+3 -2
View File
@@ -24,8 +24,9 @@
class ConfigFile; class ConfigFile;
class aboutPokerthImpl: public QDialog, public Ui::aboutPokerth { class aboutPokerthImpl: public QDialog, public Ui::aboutPokerth
Q_OBJECT {
Q_OBJECT
public: public:
aboutPokerthImpl(QWidget *parent = 0, ConfigFile *c =0); aboutPokerthImpl(QWidget *parent = 0, ConfigFile *c =0);
@@ -37,33 +37,40 @@ changeCompleteBlindsDialogImpl::changeCompleteBlindsDialogImpl(QWidget *parent,
} }
void changeCompleteBlindsDialogImpl::exec() { void changeCompleteBlindsDialogImpl::exec()
{
QDialog::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"), QMessageBox::warning(this, tr("Manual Blinds Order"),
tr("You cannot set more than 30 manual blinds."), tr("You cannot set more than 30 manual blinds."),
QMessageBox::Close); } QMessageBox::Close);
else { } else {
listWidget_blinds->addItem(QString::number(spinBox_input->value(),10)); listWidget_blinds->addItem(QString::number(spinBox_input->value(),10));
sortBlindsList(); sortBlindsList();
} }
} }
void changeCompleteBlindsDialogImpl::removeBlindFromList() { void changeCompleteBlindsDialogImpl::removeBlindFromList()
{
listWidget_blinds->takeItem(listWidget_blinds->currentRow()); listWidget_blinds->takeItem(listWidget_blinds->currentRow());
sortBlindsList(); sortBlindsList();
} }
void changeCompleteBlindsDialogImpl::sortBlindsList() { void changeCompleteBlindsDialogImpl::sortBlindsList()
{
int i; int i;
QList<int> tempIntList; QList<int> tempIntList;
@@ -27,8 +27,9 @@
class ConfigFile; class ConfigFile;
class changeCompleteBlindsDialogImpl: public QDialog, public Ui::changeCompleteBlindsDialog { class changeCompleteBlindsDialogImpl: public QDialog, public Ui::changeCompleteBlindsDialog
Q_OBJECT {
Q_OBJECT
public: public:
changeCompleteBlindsDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); changeCompleteBlindsDialogImpl(QWidget *parent = 0, ConfigFile *c = 0);
@@ -36,7 +37,9 @@ public:
public slots: public slots:
bool getSettingsCorrect() const { return settingsCorrect;} bool getSettingsCorrect() const {
return settingsCorrect;
}
void updateSpinBoxInputMinimum(int); void updateSpinBoxInputMinimum(int);
void addBlindValueToList(); void addBlindValueToList();
@@ -76,7 +76,8 @@ changeContentDialogImpl::changeContentDialogImpl(QWidget *parent, ConfigFile *co
} }
void changeContentDialogImpl::saveContent() { void changeContentDialogImpl::saveContent()
{
switch (myType) { switch (myType) {
case CHANGE_HUMAN_PLAYER_NAME: { case CHANGE_HUMAN_PLAYER_NAME: {
@@ -28,7 +28,8 @@ enum DialogType { CHANGE_HUMAN_PLAYER_NAME=0, CHANGE_NICK_ALREADY_IN_USE, CHANGE
class ConfigFile; class ConfigFile;
class changeContentDialogImpl: public QDialog, public Ui::changeContentDialog { class changeContentDialogImpl: public QDialog, public Ui::changeContentDialog
{
Q_OBJECT Q_OBJECT
public: public:
changeContentDialogImpl(QWidget *parent, ConfigFile *config, DialogType t); changeContentDialogImpl(QWidget *parent, ConfigFile *config, DialogType t);
+43 -29
View File
@@ -39,21 +39,22 @@ ChatTools::~ChatTools()
{ {
} }
void ChatTools::sendMessage() { void ChatTools::sendMessage()
{
if(myLineEdit->text().size() && mySession) { if(myLineEdit->text().size() && mySession) {
fillChatLinesHistory(myLineEdit->text()); fillChatLinesHistory(myLineEdit->text());
if(myChatType == INGAME_CHAT) { if(myChatType == INGAME_CHAT) {
mySession->sendGameChatMessage(myLineEdit->text().toUtf8().constData()); mySession->sendGameChatMessage(myLineEdit->text().toUtf8().constData());
} } else {
else {
mySession->sendLobbyChatMessage(myLineEdit->text().toUtf8().constData()); mySession->sendLobbyChatMessage(myLineEdit->text().toUtf8().constData());
} }
myLineEdit->setText(""); myLineEdit->setText("");
} }
} }
void ChatTools::receiveMessage(QString playerName, QString message) { void ChatTools::receiveMessage(QString playerName, QString message)
{
if(myTextBrowser) { if(myTextBrowser) {
@@ -72,8 +73,7 @@ void ChatTools::receiveMessage(QString playerName, QString message) {
if(myLobby->isVisible() && myConfig->readConfigInt("PlayLobbyChatNotification")) { if(myLobby->isVisible() && myConfig->readConfigInt("PlayLobbyChatNotification")) {
myLobby->getMyW()->getMySDLPlayer()->playSound("lobbychatnotify",0); myLobby->getMyW()->getMySDLPlayer()->playSound("lobbychatnotify",0);
} }
} } else if(message.contains(myNick, Qt::CaseInsensitive)) {
else if(message.contains(myNick, Qt::CaseInsensitive)) {
switch (myChatType) { switch (myChatType) {
case INET_LOBBY_CHAT: { case INET_LOBBY_CHAT: {
@@ -85,33 +85,42 @@ void ChatTools::receiveMessage(QString playerName, QString message) {
} }
} }
break; break;
case LAN_LOBBY_CHAT: tempMsg = QString("<span style=\"font-weight:bold;\">"+message+"</span>"); case LAN_LOBBY_CHAT:
tempMsg = QString("<span style=\"font-weight:bold;\">"+message+"</span>");
break; break;
case INGAME_CHAT: tempMsg = QString("<span style=\"color:#"+myStyle->getChatTextNickNotifyColor()+";\">"+message+"</span>"); case INGAME_CHAT:
tempMsg = QString("<span style=\"color:#"+myStyle->getChatTextNickNotifyColor()+";\">"+message+"</span>");
break; break;
default: tempMsg = message; default:
tempMsg = message;
} }
} } else if(playerName == myNick) {
else if(playerName == myNick) {
switch (myChatType) { switch (myChatType) {
case INET_LOBBY_CHAT: tempMsg = QString("<span style=\"font-weight:normal; color:"+myLobby->palette().link().color().name()+";\">"+message+"</span>"); case INET_LOBBY_CHAT:
tempMsg = QString("<span style=\"font-weight:normal; color:"+myLobby->palette().link().color().name()+";\">"+message+"</span>");
break; break;
case LAN_LOBBY_CHAT: tempMsg = QString("<span style=\"font-weight:normal;\">"+message+"</span>"); case LAN_LOBBY_CHAT:
tempMsg = QString("<span style=\"font-weight:normal;\">"+message+"</span>");
break; break;
case INGAME_CHAT: tempMsg = QString("<span style=\"color:#"+myStyle->getChatLogTextColor()+";\">"+message+"</span>"); case INGAME_CHAT:
tempMsg = QString("<span style=\"color:#"+myStyle->getChatLogTextColor()+";\">"+message+"</span>");
break; break;
default: tempMsg = message; default:
tempMsg = message;
} }
} } else {
else {
switch (myChatType) { switch (myChatType) {
case INET_LOBBY_CHAT: tempMsg = QString("<span style=\"font-weight:normal; color:"+myLobby->palette().text().color().name()+";\">"+message+"</span>"); case INET_LOBBY_CHAT:
tempMsg = QString("<span style=\"font-weight:normal; color:"+myLobby->palette().text().color().name()+";\">"+message+"</span>");
break; break;
case LAN_LOBBY_CHAT: tempMsg = QString("<span style=\"font-weight:normal;\">"+message+"</span>"); case LAN_LOBBY_CHAT:
tempMsg = QString("<span style=\"font-weight:normal;\">"+message+"</span>");
break; break;
case INGAME_CHAT: tempMsg = QString("<span style=\"color:#"+myStyle->getChatLogTextColor()+";\">"+message+"</span>"); case INGAME_CHAT:
tempMsg = QString("<span style=\"color:#"+myStyle->getChatLogTextColor()+";\">"+message+"</span>");
break; break;
default: tempMsg = message; default:
tempMsg = message;
} }
} }
@@ -129,26 +138,28 @@ void ChatTools::receiveMessage(QString playerName, QString message) {
if(message.indexOf(QString("/me "))==0) { if(message.indexOf(QString("/me "))==0) {
myTextBrowser->append(tempMsg.replace("/me ","<i>*"+playerName+" ")+"</i>"); myTextBrowser->append(tempMsg.replace("/me ","<i>*"+playerName+" ")+"</i>");
} } else {
else {
myTextBrowser->append(playerName + ": " + tempMsg); myTextBrowser->append(playerName + ": " + tempMsg);
} }
} }
} }
} }
void ChatTools::clearChat() { void ChatTools::clearChat()
{
if(myTextBrowser) if(myTextBrowser)
myTextBrowser->clear(); 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; chatLinesHistory << fillString;
if(chatLinesHistory.size() > 50) chatLinesHistory.removeFirst(); if(chatLinesHistory.size() > 50) chatLinesHistory.removeFirst();
@@ -156,7 +167,8 @@ void ChatTools::fillChatLinesHistory(QString fillString) {
} }
void ChatTools::showChatHistoryIndex(int index) { void ChatTools::showChatHistoryIndex(int index)
{
if(index <= chatLinesHistory.size()) { if(index <= chatLinesHistory.size()) {
@@ -168,7 +180,8 @@ void ChatTools::showChatHistoryIndex(int index) {
} }
} }
void ChatTools::nickAutoCompletition() { void ChatTools::nickAutoCompletition()
{
QString myChatString = myLineEdit->text(); QString myChatString = myLineEdit->text();
QStringList myChatStringList = myChatString.split(" "); QStringList myChatStringList = myChatString.split(" ");
@@ -224,7 +237,8 @@ void ChatTools::nickAutoCompletition() {
} }
} }
void ChatTools::setChatTextEdited() { void ChatTools::setChatTextEdited()
{
nickAutoCompletitionCounter = 0; nickAutoCompletitionCounter = 0;
} }
+18 -6
View File
@@ -41,7 +41,9 @@ public:
~ChatTools(); ~ChatTools();
void setSession(boost::shared_ptr<Session> session) { mySession = session; } void setSession(boost::shared_ptr<Session> session) {
mySession = session;
}
public slots: public slots:
@@ -52,16 +54,26 @@ public slots:
void fillChatLinesHistory(QString fillString); void fillChatLinesHistory(QString fillString);
void showChatHistoryIndex(int index); void showChatHistoryIndex(int index);
int getChatLinesHistorySize() { return chatLinesHistory.size(); } int getChatLinesHistorySize() {
return chatLinesHistory.size();
}
void nickAutoCompletition(); void nickAutoCompletition();
void setChatTextEdited(); void setChatTextEdited();
void setPlayerNicksList(QStringList value) { myNickStringList = value; } void setPlayerNicksList(QStringList value) {
void setMyNick ( const QString& theValue ) { myNick = theValue; } myNickStringList = value;
QString getMyNick () { return myNick; } }
void setMyNick ( const QString& theValue ) {
myNick = theValue;
}
QString getMyNick () {
return myNick;
}
void setMyStyle ( GameTableStyleReader* theValue ) { myStyle = theValue; } void setMyStyle ( GameTableStyleReader* theValue ) {
myStyle = theValue;
}
void refreshIgnoreList(); void refreshIgnoreList();
@@ -38,26 +38,37 @@ void connectToServerDialogImpl::exec()
QDialog::exec(); QDialog::exec();
} }
void connectToServerDialogImpl::refresh(int actionID) { void connectToServerDialogImpl::refresh(int actionID)
{
bool skip = false; bool skip = false;
switch (actionID) { switch (actionID) {
case MSG_SOCK_INIT_DONE: { label_actionMessage->setText(tr("Resolving address...")); } case MSG_SOCK_INIT_DONE: {
label_actionMessage->setText(tr("Resolving address..."));
}
break; break;
case MSG_SOCK_SERVER_LIST_DONE : { label_actionMessage->setText(tr("Reading server list...")); } case MSG_SOCK_SERVER_LIST_DONE : {
label_actionMessage->setText(tr("Reading server list..."));
}
break; break;
case MSG_SOCK_RESOLVE_DONE: { label_actionMessage->setText(tr("Connecting to server...")); } case MSG_SOCK_RESOLVE_DONE: {
label_actionMessage->setText(tr("Connecting to server..."));
}
break; break;
case MSG_SOCK_CONNECT_DONE: { label_actionMessage->setText(tr("Starting session...")); } case MSG_SOCK_CONNECT_DONE: {
label_actionMessage->setText(tr("Starting session..."));
}
break; break;
case MSG_SOCK_SESSION_DONE: { label_actionMessage->setText(tr("Connection established!")); } case MSG_SOCK_SESSION_DONE: {
label_actionMessage->setText(tr("Connection established!"));
}
break; break;
default: skip = true; default:
skip = true;
} }
if (!skip) if (!skip) {
{
progressBar->setValue(actionID*(100/MSG_SOCK_LIMIT_CONNECT)); progressBar->setValue(actionID*(100/MSG_SOCK_LIMIT_CONNECT));
if (actionID == MSG_SOCK_LIMIT_CONNECT) if (actionID == MSG_SOCK_LIMIT_CONNECT)
@@ -26,8 +26,9 @@
#include <QtCore> #include <QtCore>
class connectToServerDialogImpl: public QDialog, public Ui::connectToServerDialog { class connectToServerDialogImpl: public QDialog, public Ui::connectToServerDialog
Q_OBJECT {
Q_OBJECT
public: public:
connectToServerDialogImpl(QWidget *parent = 0); connectToServerDialogImpl(QWidget *parent = 0);
@@ -56,7 +56,8 @@ createInternetGameDialogImpl::createInternetGameDialogImpl(QWidget *parent, Conf
} }
void createInternetGameDialogImpl::exec(bool guestMode, QString playerName) { void createInternetGameDialogImpl::exec(bool guestMode, QString playerName)
{
currentGuestMode = guestMode; currentGuestMode = guestMode;
currentPlayerName = playerName; currentPlayerName = playerName;
@@ -64,15 +65,18 @@ void createInternetGameDialogImpl::exec(bool guestMode, QString playerName) {
QDialog::exec(); 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 //Network Game Settings
spinBox_netDelayBetweenHands->setValue(myConfig->readConfigInt("NetDelayBetweenHands")); spinBox_netDelayBetweenHands->setValue(myConfig->readConfigInt("NetDelayBetweenHands"));
@@ -89,8 +93,7 @@ void createInternetGameDialogImpl::fillFormular(bool guestMode, QString playerNa
lineEdit_gameName->setText(tr("%1's game").arg(playerName)); lineEdit_gameName->setText(tr("%1's game").arg(playerName));
lineEdit_gameName->setDisabled(true); lineEdit_gameName->setDisabled(true);
} } else {
else {
comboBox_gameType->setDisabled(false); comboBox_gameType->setDisabled(false);
comboBox_gameType->setCurrentIndex(myConfig->readConfigInt("InternetGameType")); comboBox_gameType->setCurrentIndex(myConfig->readConfigInt("InternetGameType"));
lineEdit_gameName->setDisabled(false); lineEdit_gameName->setDisabled(false);
@@ -100,19 +103,26 @@ void createInternetGameDialogImpl::fillFormular(bool guestMode, QString playerNa
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) { if(show) {
myChangeCompleteBlindsDialog->exec(); myChangeCompleteBlindsDialog->exec();
@@ -124,7 +134,8 @@ void createInternetGameDialogImpl::callChangeBlindsDialog(bool show) {
} }
} }
void createInternetGameDialogImpl::gameTypeChanged() { void createInternetGameDialogImpl::gameTypeChanged()
{
switch (comboBox_gameType->currentIndex()) { switch (comboBox_gameType->currentIndex()) {
@@ -193,8 +204,7 @@ void createInternetGameDialogImpl::gameTypeChanged() {
myChangeCompleteBlindsDialog->radioButton_alwaysDoubleBlinds->setChecked(TRUE); myChangeCompleteBlindsDialog->radioButton_alwaysDoubleBlinds->setChecked(TRUE);
myChangeCompleteBlindsDialog->radioButton_manualBlindsOrder->setChecked(FALSE); myChangeCompleteBlindsDialog->radioButton_manualBlindsOrder->setChecked(FALSE);
myChangeCompleteBlindsDialog->listWidget_blinds->clear(); myChangeCompleteBlindsDialog->listWidget_blinds->clear();
} } else {
else {
//read config values //read config values
myChangeCompleteBlindsDialog->spinBox_firstSmallBlind->setValue(myConfig->readConfigInt("NetFirstSmallBlind")); myChangeCompleteBlindsDialog->spinBox_firstSmallBlind->setValue(myConfig->readConfigInt("NetFirstSmallBlind"));
myChangeCompleteBlindsDialog->radioButton_raiseBlindsAtHands->setChecked(myConfig->readConfigInt("NetRaiseBlindsAtHands")); myChangeCompleteBlindsDialog->radioButton_raiseBlindsAtHands->setChecked(myConfig->readConfigInt("NetRaiseBlindsAtHands"));
@@ -29,13 +29,16 @@ class Session;
class ConfigFile; class ConfigFile;
class changeCompleteBlindsDialogImpl; class changeCompleteBlindsDialogImpl;
class createInternetGameDialogImpl: public QDialog, public Ui::createInternetGameDialog { class createInternetGameDialogImpl: public QDialog, public Ui::createInternetGameDialog
Q_OBJECT {
Q_OBJECT
public: public:
createInternetGameDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); createInternetGameDialogImpl(QWidget *parent = 0, ConfigFile *c = 0);
void exec(bool guestMode, QString playerName); void exec(bool guestMode, QString playerName);
changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() { return myChangeCompleteBlindsDialog; } changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() {
return myChangeCompleteBlindsDialog;
}
public slots: public slots:
@@ -47,21 +47,25 @@ createNetworkGameDialogImpl::createNetworkGameDialogImpl(QWidget *parent, Config
} }
void createNetworkGameDialogImpl::exec() { void createNetworkGameDialogImpl::exec()
{
fillFormular(); fillFormular();
QDialog::exec(); QDialog::exec();
} }
void createNetworkGameDialogImpl::createGame() { void createNetworkGameDialogImpl::createGame()
{
} }
void createNetworkGameDialogImpl::cancel() { void createNetworkGameDialogImpl::cancel()
{
} }
void createNetworkGameDialogImpl::fillFormular() { void createNetworkGameDialogImpl::fillFormular()
{
//Network Game Settings //Network Game Settings
spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers")); spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers"));
@@ -95,20 +99,25 @@ void createNetworkGameDialogImpl::fillFormular() {
myChangeCompleteBlindsDialog->radioButton_afterThisStayAtLastBlind->setChecked(myConfig->readConfigInt("NetAfterMBStayAtLastBlind")); myChangeCompleteBlindsDialog->radioButton_afterThisStayAtLastBlind->setChecked(myConfig->readConfigInt("NetAfterMBStayAtLastBlind"));
} }
void createNetworkGameDialogImpl::showDialog() { void createNetworkGameDialogImpl::showDialog()
{
fillFormular(); fillFormular();
exec(); 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) { if(show) {
myChangeCompleteBlindsDialog->exec(); myChangeCompleteBlindsDialog->exec();
@@ -30,13 +30,16 @@ class ConfigFile;
class changeCompleteBlindsDialogImpl; class changeCompleteBlindsDialogImpl;
class createNetworkGameDialogImpl: public QDialog, public Ui::createNetworkGameDialog { class createNetworkGameDialogImpl: public QDialog, public Ui::createNetworkGameDialog
Q_OBJECT {
Q_OBJECT
public: public:
createNetworkGameDialogImpl(QWidget *parent = 0, ConfigFile *c = 0); createNetworkGameDialogImpl(QWidget *parent = 0, ConfigFile *c = 0);
void exec(); void exec();
changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() { return myChangeCompleteBlindsDialog; } changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() {
return myChangeCompleteBlindsDialog;
}
public slots: public slots:
+147 -129
View File
@@ -162,8 +162,7 @@ void gameLobbyDialogImpl::exec()
if(myConfig->readConfigInt("UseLobbyChat")) { if(myConfig->readConfigInt("UseLobbyChat")) {
groupBox_lobbyChat->show(); groupBox_lobbyChat->show();
} } else {
else {
groupBox_lobbyChat->hide(); groupBox_lobbyChat->hide();
} }
readDialogSettings(); readDialogSettings();
@@ -171,8 +170,7 @@ void gameLobbyDialogImpl::exec()
PlayerInfo playerInfo(mySession->getClientPlayerInfo(mySession->getClientUniquePlayerId())); PlayerInfo playerInfo(mySession->getClientPlayerInfo(mySession->getClientUniquePlayerId()));
if(playerInfo.isGuest) { if(playerInfo.isGuest) {
guestUserMode(); guestUserMode();
} } else {
else {
registeredUserMode(); registeredUserMode();
} }
@@ -191,7 +189,8 @@ gameLobbyDialogImpl::~gameLobbyDialogImpl()
} }
void gameLobbyDialogImpl::setSession(boost::shared_ptr<Session> session) { void gameLobbyDialogImpl::setSession(boost::shared_ptr<Session> session)
{
mySession = session; mySession = session;
myChat->setSession(mySession); myChat->setSession(mySession);
} }
@@ -215,16 +214,14 @@ void gameLobbyDialogImpl::createGame()
if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) { if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) {
gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER; gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER;
gameData.raiseSmallBlindEveryHandsValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value(); gameData.raiseSmallBlindEveryHandsValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value();
} } else {
else {
gameData.raiseIntervalMode = RAISE_ON_MINUTES; gameData.raiseIntervalMode = RAISE_ON_MINUTES;
gameData.raiseSmallBlindEveryMinutesValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value(); gameData.raiseSmallBlindEveryMinutesValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value();
} }
if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) { if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) {
gameData.raiseMode = DOUBLE_BLINDS; gameData.raiseMode = DOUBLE_BLINDS;
} } else {
else {
gameData.raiseMode = MANUAL_BLINDS_ORDER; gameData.raiseMode = MANUAL_BLINDS_ORDER;
std::list<int> tempBlindList; std::list<int> tempBlindList;
int i; int i;
@@ -234,13 +231,15 @@ void gameLobbyDialogImpl::createGame()
} }
gameData.manualBlindsList = tempBlindList; gameData.manualBlindsList = tempBlindList;
if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; } if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) {
else { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS;
} else {
if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysRaiseAbout->isChecked()) { if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysRaiseAbout->isChecked()) {
gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT; gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT;
gameData.afterMBAlwaysRaiseValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_afterThisAlwaysRaiseValue->value(); gameData.afterMBAlwaysRaiseValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_afterThisAlwaysRaiseValue->value();
} else {
gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND;
} }
else { gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; }
} }
} }
@@ -296,8 +295,7 @@ void gameLobbyDialogImpl::joinGame()
{ {
assert(mySession); assert(mySession);
QItemSelectionModel *selection = treeView_GameList->selectionModel(); QItemSelectionModel *selection = treeView_GameList->selectionModel();
if (!inGame && selection->hasSelection()) if (!inGame && selection->hasSelection()) {
{
unsigned gameId = selection->selectedRows().first().data(Qt::UserRole).toUInt(); unsigned gameId = selection->selectedRows().first().data(Qt::UserRole).toUInt();
GameInfo info(mySession->getClientGameInfo(gameId)); GameInfo info(mySession->getClientGameInfo(gameId));
bool ok = true; bool ok = true;
@@ -313,7 +311,8 @@ void gameLobbyDialogImpl::joinGame()
} }
} }
void gameLobbyDialogImpl::joinAnyGame() { void gameLobbyDialogImpl::joinAnyGame()
{
if(comboBox_gameListFilter->currentIndex() != 3 && comboBox_gameListFilter->currentIndex() != 0) comboBox_gameListFilter->setCurrentIndex(0); if(comboBox_gameListFilter->currentIndex() != 3 && comboBox_gameListFilter->currentIndex() != 0) comboBox_gameListFilter->setCurrentIndex(0);
@@ -327,8 +326,7 @@ void gameLobbyDialogImpl::joinAnyGame() {
int players = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",0,0).toInt(); int players = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",0,0).toInt();
int maxPlayers = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",1,1).toInt(); int maxPlayers = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",1,1).toInt();
if (myGameListModel->item(it, 2)->data(16) == "open" && myGameListModel->item(it, 4)->data(16) == "nonpriv" && players < maxPlayers) if (myGameListModel->item(it, 2)->data(16) == "open" && myGameListModel->item(it, 4)->data(16) == "nonpriv" && players < maxPlayers) {
{
if(players > mostConnectedPlayers) { if(players > mostConnectedPlayers) {
mostConnectedPlayers = players; mostConnectedPlayers = players;
gameToJoinId = it; gameToJoinId = it;
@@ -344,7 +342,8 @@ void gameLobbyDialogImpl::joinAnyGame() {
} }
} }
void gameLobbyDialogImpl::refresh(int actionID) { void gameLobbyDialogImpl::refresh(int actionID)
{
if (actionID == MSG_NET_GAME_CLIENT_START) { if (actionID == MSG_NET_GAME_CLIENT_START) {
myGameListModel->clear(); myGameListModel->clear();
@@ -375,8 +374,7 @@ void gameLobbyDialogImpl::refresh(int actionID) {
this->accept(); this->accept();
myW->show(); myW->show();
} } else if(actionID == MSG_NET_GAME_CLIENT_SYNCSTART) {
else if(actionID == MSG_NET_GAME_CLIENT_SYNCSTART) {
waitStartGameMsgBoxTimer->start(2000); waitStartGameMsgBoxTimer->start(2000);
} }
@@ -392,8 +390,7 @@ void gameLobbyDialogImpl::removedFromGame(int /*reason*/)
void gameLobbyDialogImpl::gameSelected(const QModelIndex &index) void gameLobbyDialogImpl::gameSelected(const QModelIndex &index)
{ {
if (!inGame && index.isValid() ) if (!inGame && index.isValid() ) {
{
pushButton_JoinGame->setEnabled(true); pushButton_JoinGame->setEnabled(true);
currentGameName = myGameListModel->item(myGameListSortFilterProxyModel->mapToSource(index).row(), 0)->text(); currentGameName = myGameListModel->item(myGameListSortFilterProxyModel->mapToSource(index).row(), 0)->text();
@@ -438,8 +435,7 @@ void gameLobbyDialogImpl::gameSelected(const QModelIndex &index)
treeWidget_connectedPlayers->clear(); treeWidget_connectedPlayers->clear();
PlayerIdList::const_iterator i = info.players.begin(); PlayerIdList::const_iterator i = info.players.begin();
PlayerIdList::const_iterator end = info.players.end(); PlayerIdList::const_iterator end = info.players.end();
while (i != end) while (i != end) {
{
bool admin = info.adminPlayerId == *i; bool admin = info.adminPlayerId == *i;
PlayerInfo playerInfo(mySession->getClientPlayerInfo(*i)); PlayerInfo playerInfo(mySession->getClientPlayerInfo(*i));
addConnectedPlayer(*i, QString::fromUtf8(playerInfo.playerName.c_str()), admin); addConnectedPlayer(*i, QString::fromUtf8(playerInfo.playerName.c_str()), admin);
@@ -468,8 +464,7 @@ void gameLobbyDialogImpl::updateGameItem(QList <QStandardItem*> itemList, unsign
PlayerIdList::const_iterator i = info.players.begin(); PlayerIdList::const_iterator i = info.players.begin();
PlayerIdList::const_iterator end = info.players.end(); PlayerIdList::const_iterator end = info.players.end();
while (i != end) while (i != end) {
{
if(myPlayerId == *i) { if(myPlayerId == *i) {
itemList.at(0)->setData( "MeInThisGame", 16); itemList.at(0)->setData( "MeInThisGame", 16);
itemList.at(0)->setBackground(QBrush(QColor(0, 255, 0, 127))); itemList.at(0)->setBackground(QBrush(QColor(0, 255, 0, 127)));
@@ -478,8 +473,7 @@ void gameLobbyDialogImpl::updateGameItem(QList <QStandardItem*> itemList, unsign
itemList.at(3)->setBackground(QBrush(QColor(0, 255, 0, 127))); itemList.at(3)->setBackground(QBrush(QColor(0, 255, 0, 127)));
itemList.at(4)->setBackground(QBrush(QColor(0, 255, 0, 127))); itemList.at(4)->setBackground(QBrush(QColor(0, 255, 0, 127)));
break; break;
} } else {
else {
itemList.at(0)->setData( "", 16); itemList.at(0)->setData( "", 16);
itemList.at(0)->setBackground(QBrush()); itemList.at(0)->setBackground(QBrush());
itemList.at(1)->setBackground(QBrush()); itemList.at(1)->setBackground(QBrush());
@@ -493,14 +487,16 @@ void gameLobbyDialogImpl::updateGameItem(QList <QStandardItem*> itemList, unsign
QString playerStr; QString playerStr;
playerStr.sprintf("%u/%u", (unsigned)info.players.size(), (unsigned)info.data.maxNumberOfPlayers); playerStr.sprintf("%u/%u", (unsigned)info.players.size(), (unsigned)info.data.maxNumberOfPlayers);
itemList.at(1)->setData(playerStr, Qt::DisplayRole); itemList.at(1)->setData(playerStr, Qt::DisplayRole);
if((unsigned)info.players.size() == (unsigned)info.data.maxNumberOfPlayers) { itemList.at(1)->setData("totalfull", 16); } if((unsigned)info.players.size() == (unsigned)info.data.maxNumberOfPlayers) {
else { itemList.at(1)->setData("nonfull", 16); }\ itemList.at(1)->setData("totalfull", 16);
} else {
itemList.at(1)->setData("nonfull", 16);
}\
if (info.mode == GAME_MODE_STARTED) { if (info.mode == GAME_MODE_STARTED) {
itemList.at(2)->setData(tr("running"), Qt::DisplayRole); itemList.at(2)->setData(tr("running"), Qt::DisplayRole);
itemList.at(2)->setData("running", 16); itemList.at(2)->setData("running", 16);
} } else {
else {
itemList.at(2)->setData(tr("open"), Qt::DisplayRole); itemList.at(2)->setData(tr("open"), Qt::DisplayRole);
itemList.at(2)->setData("open", 16); itemList.at(2)->setData("open", 16);
} }
@@ -536,8 +532,7 @@ void gameLobbyDialogImpl::updateGameItem(QList <QStandardItem*> itemList, unsign
itemList.at(4)->setIcon(QIcon(":/gfx/lock.png")); itemList.at(4)->setIcon(QIcon(":/gfx/lock.png"));
itemList.at(4)->setData(" ", Qt::DisplayRole); itemList.at(4)->setData(" ", Qt::DisplayRole);
itemList.at(4)->setData("private", 16); itemList.at(4)->setData("private", 16);
} } else {
else {
itemList.at(4)->setData("", Qt::DisplayRole); itemList.at(4)->setData("", Qt::DisplayRole);
itemList.at(4)->setData("nonpriv", 16); itemList.at(4)->setData("nonpriv", 16);
} }
@@ -566,8 +561,7 @@ void gameLobbyDialogImpl::updateGameMode(unsigned gameId, int /*newMode*/)
{ {
int it = 0; int it = 0;
while (myGameListModel->item(it)) { while (myGameListModel->item(it)) {
if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) {
{
QList <QStandardItem*> itemList; QList <QStandardItem*> itemList;
itemList << myGameListModel->item(it, 0) << myGameListModel->item(it, 1) << myGameListModel->item(it, 2) << myGameListModel->item(it, 3) << myGameListModel->item(it, 4); itemList << myGameListModel->item(it, 0) << myGameListModel->item(it, 1) << myGameListModel->item(it, 2) << myGameListModel->item(it, 3) << myGameListModel->item(it, 4);
updateGameItem(itemList, gameId); updateGameItem(itemList, gameId);
@@ -586,8 +580,7 @@ void gameLobbyDialogImpl::removeGame(unsigned gameId)
{ {
int it = 0; int it = 0;
while (myGameListModel->item(it)) { while (myGameListModel->item(it)) {
if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) if (myGameListModel->item(it, 0)->data(Qt::UserRole) == gameId) {
{
myGameListModel->removeRow(it); myGameListModel->removeRow(it);
break; break;
} }
@@ -597,15 +590,20 @@ void gameLobbyDialogImpl::removeGame(unsigned gameId)
refreshGameStats(); refreshGameStats();
} }
void gameLobbyDialogImpl::refreshGameStats() { void gameLobbyDialogImpl::refreshGameStats()
{
int runningGamesCounter = 0; int runningGamesCounter = 0;
int openGamesCounter = 0; int openGamesCounter = 0;
int it = 0; int it = 0;
while (myGameListModel->item(it)) { while (myGameListModel->item(it)) {
if (myGameListModel->item(it, 2)->data(16) == "running") { runningGamesCounter++; } if (myGameListModel->item(it, 2)->data(16) == "running") {
if (myGameListModel->item(it, 2)->data(16) == "open") { openGamesCounter++; } runningGamesCounter++;
}
if (myGameListModel->item(it, 2)->data(16) == "open") {
openGamesCounter++;
}
++it; ++it;
} }
@@ -617,7 +615,8 @@ void gameLobbyDialogImpl::refreshGameStats() {
} }
void gameLobbyDialogImpl::refreshPlayerStats() { void gameLobbyDialogImpl::refreshPlayerStats()
{
ServerStats stats = mySession->getClientStats(); ServerStats stats = mySession->getClientStats();
label_connectedPlayersCounter->setText(tr("connected players: %1").arg(myNickListModel->rowCount())); label_connectedPlayersCounter->setText(tr("connected players: %1").arg(myNickListModel->rowCount()));
@@ -625,8 +624,7 @@ void gameLobbyDialogImpl::refreshPlayerStats() {
void gameLobbyDialogImpl::gameAddPlayer(unsigned gameId, unsigned playerId) void gameLobbyDialogImpl::gameAddPlayer(unsigned gameId, unsigned playerId)
{ {
if (!inGame) if (!inGame) {
{
QItemSelectionModel *selection = treeView_GameList->selectionModel(); QItemSelectionModel *selection = treeView_GameList->selectionModel();
if (selection->hasSelection()) { if (selection->hasSelection()) {
if(selection->selectedRows().at(0).data(Qt::UserRole).toUInt() == gameId) { if(selection->selectedRows().at(0).data(Qt::UserRole).toUInt() == gameId) {
@@ -665,8 +663,7 @@ void gameLobbyDialogImpl::gameAddPlayer(unsigned gameId, unsigned playerId)
void gameLobbyDialogImpl::gameRemovePlayer(unsigned gameId, unsigned playerId) void gameLobbyDialogImpl::gameRemovePlayer(unsigned gameId, unsigned playerId)
{ {
if (!inGame) if (!inGame) {
{
QItemSelectionModel *selection = treeView_GameList->selectionModel(); QItemSelectionModel *selection = treeView_GameList->selectionModel();
if (selection->hasSelection()) { if (selection->hasSelection()) {
if(selection->selectedRows().at(0).data(Qt::UserRole).toUInt() == gameId) { if(selection->selectedRows().at(0).data(Qt::UserRole).toUInt() == gameId) {
@@ -777,12 +774,13 @@ void gameLobbyDialogImpl::clearDialog()
readDialogSettings(); readDialogSettings();
} }
void gameLobbyDialogImpl::checkPlayerQuantity() { void gameLobbyDialogImpl::checkPlayerQuantity()
{
assert(mySession); assert(mySession);
GameInfo info(mySession->getClientGameInfo(mySession->getClientCurrentGameId())); GameInfo info(mySession->getClientGameInfo(mySession->getClientCurrentGameId()));
if(isGameAdministrator && info.data.gameType != GAME_TYPE_RANKING){ if(isGameAdministrator && info.data.gameType != GAME_TYPE_RANKING) {
pushButton_Kick->show(); pushButton_Kick->show();
pushButton_StartGame->show(); pushButton_StartGame->show();
@@ -793,14 +791,12 @@ void gameLobbyDialogImpl::checkPlayerQuantity() {
if(treeWidget_connectedPlayers->topLevelItemCount() == treeWidget_connectedPlayers->headerItem()->data(0, Qt::UserRole).toInt()) { if(treeWidget_connectedPlayers->topLevelItemCount() == treeWidget_connectedPlayers->headerItem()->data(0, Qt::UserRole).toInt()) {
blinkingButtonAnimationTimer->start(); blinkingButtonAnimationTimer->start();
} } else {
else {
blinkingButtonAnimationTimer->stop(); blinkingButtonAnimationTimer->stop();
blinkingButtonAnimationState = false; blinkingButtonAnimationState = false;
blinkingStartButtonAnimation(); blinkingStartButtonAnimation();
} }
} } else {
else {
pushButton_StartGame->setEnabled(false); pushButton_StartGame->setEnabled(false);
blinkingButtonAnimationTimer->stop(); blinkingButtonAnimationTimer->stop();
blinkingButtonAnimationState = false; blinkingButtonAnimationState = false;
@@ -816,7 +812,8 @@ void gameLobbyDialogImpl::checkPlayerQuantity() {
} }
void gameLobbyDialogImpl::blinkingStartButtonAnimation() { void gameLobbyDialogImpl::blinkingStartButtonAnimation()
{
if(blinkingButtonAnimationState) { if(blinkingButtonAnimationState) {
QPalette p = pushButton_StartGame->palette(); QPalette p = pushButton_StartGame->palette();
@@ -824,16 +821,14 @@ void gameLobbyDialogImpl::blinkingStartButtonAnimation() {
p.setColor(QPalette::ButtonText, QColor(Qt::white)); p.setColor(QPalette::ButtonText, QColor(Qt::white));
pushButton_StartGame->setPalette(p); pushButton_StartGame->setPalette(p);
blinkingButtonAnimationState = false; blinkingButtonAnimationState = false;
} } else {
else {
if(pushButton_StartGame->isEnabled()) { if(pushButton_StartGame->isEnabled()) {
QPalette p = pushButton_StartGame->palette(); QPalette p = pushButton_StartGame->palette();
p.setColor(QPalette::Button, defaultStartButtonColor); p.setColor(QPalette::Button, defaultStartButtonColor);
p.setColor(QPalette::ButtonText, defaultStartButtonTextColor); p.setColor(QPalette::ButtonText, defaultStartButtonTextColor);
pushButton_StartGame->setPalette(p); pushButton_StartGame->setPalette(p);
blinkingButtonAnimationState = true; blinkingButtonAnimationState = true;
} } else {
else {
QPalette p = pushButton_StartGame->palette(); QPalette p = pushButton_StartGame->palette();
p.setColor(QPalette::Button, disabledStartButtonColor); p.setColor(QPalette::Button, disabledStartButtonColor);
p.setColor(QPalette::ButtonText, disabledStartButtonTextColor); p.setColor(QPalette::ButtonText, disabledStartButtonTextColor);
@@ -843,7 +838,8 @@ void gameLobbyDialogImpl::blinkingStartButtonAnimation() {
} }
} }
void gameLobbyDialogImpl::joinedNetworkGame(unsigned playerId, QString playerName, bool isGameAdmin) { void gameLobbyDialogImpl::joinedNetworkGame(unsigned playerId, QString playerName, bool isGameAdmin)
{
// Update dialog // Update dialog
inGame = true; inGame = true;
@@ -874,7 +870,8 @@ void gameLobbyDialogImpl::joinedNetworkGame(unsigned playerId, QString playerNam
} }
void gameLobbyDialogImpl::addConnectedPlayer(unsigned playerId, QString playerName, bool isGameAdmin) { void gameLobbyDialogImpl::addConnectedPlayer(unsigned playerId, QString playerName, bool isGameAdmin)
{
QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_connectedPlayers, 0); QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget_connectedPlayers, 0);
item->setData(0, Qt::UserRole, playerId); item->setData(0, Qt::UserRole, playerId);
@@ -885,8 +882,7 @@ void gameLobbyDialogImpl::addConnectedPlayer(unsigned playerId, QString playerNa
if(this->isVisible() && inGame && myConfig->readConfigInt("PlayNetworkGameNotification")) { if(this->isVisible() && inGame && myConfig->readConfigInt("PlayNetworkGameNotification")) {
if(treeWidget_connectedPlayers->topLevelItemCount() < treeWidget_connectedPlayers->headerItem()->data(0, Qt::UserRole).toInt()) { if(treeWidget_connectedPlayers->topLevelItemCount() < treeWidget_connectedPlayers->headerItem()->data(0, Qt::UserRole).toInt()) {
myW->getMySDLPlayer()->playSound("playerconnected", 0); myW->getMySDLPlayer()->playSound("playerconnected", 0);
} } else {
else {
myW->getMySDLPlayer()->playSound("onlinegameready", 0); myW->getMySDLPlayer()->playSound("onlinegameready", 0);
showAutoStartTimer(); showAutoStartTimer();
} }
@@ -898,13 +894,13 @@ void gameLobbyDialogImpl::addConnectedPlayer(unsigned playerId, QString playerNa
refreshConnectedPlayerAvatars(); refreshConnectedPlayerAvatars();
} }
void gameLobbyDialogImpl::updatePlayer(unsigned playerId, QString newPlayerName) { void gameLobbyDialogImpl::updatePlayer(unsigned playerId, QString newPlayerName)
{
//rename player in connected players list //rename player in connected players list
QTreeWidgetItemIterator it(treeWidget_connectedPlayers); QTreeWidgetItemIterator it(treeWidget_connectedPlayers);
while (*it) { while (*it) {
if ((*it)->data(0, Qt::UserRole) == playerId) if ((*it)->data(0, Qt::UserRole) == playerId) {
{
(*it)->setData(0, Qt::DisplayRole, newPlayerName); (*it)->setData(0, Qt::DisplayRole, newPlayerName);
break; break;
} }
@@ -927,14 +923,16 @@ void gameLobbyDialogImpl::updatePlayer(unsigned playerId, QString newPlayerName)
myNickListModel->item(it1, 0)->setData(countryString, 33); myNickListModel->item(it1, 0)->setData(countryString, 33);
if(playerInfo.isGuest || countryString.isEmpty()) { if(playerInfo.isGuest || countryString.isEmpty()) {
myNickListModel->item(it1, 0)->setIcon(QIcon(":/cflags/cflags/undefined.png")); myNickListModel->item(it1, 0)->setIcon(QIcon(":/cflags/cflags/undefined.png"));
} } else {
else {
myNickListModel->item(it1, 0)->setIcon(QIcon(QString(":/cflags/cflags/%1.png").arg(countryString))); myNickListModel->item(it1, 0)->setIcon(QIcon(QString(":/cflags/cflags/%1.png").arg(countryString)));
} }
unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerId); unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerId);
if(gameIdOfPlayer) { myNickListModel->item(it1, 0)->setData("active", 34); } if(gameIdOfPlayer) {
else { myNickListModel->item(it1, 0)->setData("idle", 34); } myNickListModel->item(it1, 0)->setData("active", 34);
} else {
myNickListModel->item(it1, 0)->setData("idle", 34);
}
break; break;
} }
@@ -947,12 +945,12 @@ void gameLobbyDialogImpl::updatePlayer(unsigned playerId, QString newPlayerName)
} }
} }
void gameLobbyDialogImpl::removePlayer(unsigned playerId, QString) { void gameLobbyDialogImpl::removePlayer(unsigned playerId, QString)
{
QTreeWidgetItemIterator it(treeWidget_connectedPlayers); QTreeWidgetItemIterator it(treeWidget_connectedPlayers);
while (*it) { while (*it) {
if ((*it)->data(0, Qt::UserRole) == playerId) if ((*it)->data(0, Qt::UserRole) == playerId) {
{
treeWidget_connectedPlayers->takeTopLevelItem(treeWidget_connectedPlayers->indexOfTopLevelItem(*it)); treeWidget_connectedPlayers->takeTopLevelItem(treeWidget_connectedPlayers->indexOfTopLevelItem(*it));
break; break;
} }
@@ -988,14 +986,16 @@ void gameLobbyDialogImpl::playerJoinedLobby(unsigned playerId, QString /*playerN
item->setData(countryString, 33); item->setData(countryString, 33);
if(playerInfo.isGuest || countryString.isEmpty()) { if(playerInfo.isGuest || countryString.isEmpty()) {
item->setIcon(QIcon(":/cflags/cflags/undefined.png")); item->setIcon(QIcon(":/cflags/cflags/undefined.png"));
} } else {
else {
item->setIcon(QIcon(QString(":/cflags/cflags/%1.png").arg(countryString))); item->setIcon(QIcon(QString(":/cflags/cflags/%1.png").arg(countryString)));
} }
unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerId); unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerId);
if(gameIdOfPlayer) { item->setData("active", 34); } if(gameIdOfPlayer) {
else { item->setData("idle", 34); } item->setData("active", 34);
} else {
item->setData("idle", 34);
}
myNickListModel->appendRow(item); myNickListModel->appendRow(item);
@@ -1013,14 +1013,14 @@ void gameLobbyDialogImpl::newGameAdmin(unsigned playerId, QString)
++it; ++it;
} }
if (inGame && myPlayerId == playerId) if (inGame && myPlayerId == playerId) {
{
isGameAdministrator = true; isGameAdministrator = true;
checkPlayerQuantity(); checkPlayerQuantity();
} }
} }
void gameLobbyDialogImpl::refreshConnectedPlayerAvatars() { void gameLobbyDialogImpl::refreshConnectedPlayerAvatars()
{
QTreeWidgetItemIterator it(treeWidget_connectedPlayers); QTreeWidgetItemIterator it(treeWidget_connectedPlayers);
while (*it) { while (*it) {
@@ -1047,7 +1047,8 @@ void gameLobbyDialogImpl::refreshConnectedPlayerAvatars() {
} }
} }
void gameLobbyDialogImpl::joinedGameDialogUpdate() { void gameLobbyDialogImpl::joinedGameDialogUpdate()
{
groupBox_GameInfo->setEnabled(true); groupBox_GameInfo->setEnabled(true);
groupBox_GameInfo->setTitle(currentGameName); groupBox_GameInfo->setTitle(currentGameName);
@@ -1097,7 +1098,8 @@ void gameLobbyDialogImpl::joinedGameDialogUpdate() {
header->setData(0, Qt::UserRole, info.data.maxNumberOfPlayers); header->setData(0, Qt::UserRole, info.data.maxNumberOfPlayers);
} }
void gameLobbyDialogImpl::leftGameDialogUpdate() { void gameLobbyDialogImpl::leftGameDialogUpdate()
{
// un-select current game. // un-select current game.
treeView_GameList->clearSelection(); treeView_GameList->clearSelection();
@@ -1135,16 +1137,19 @@ void gameLobbyDialogImpl::leftGameDialogUpdate() {
lineEdit_ChatInput->setFocus(); lineEdit_ChatInput->setFocus();
} }
void gameLobbyDialogImpl::updateDialogBlinds(const GameData &gameData) { void gameLobbyDialogImpl::updateDialogBlinds(const GameData &gameData)
{
if(gameData.raiseIntervalMode == RAISE_ON_HANDNUMBER) { label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryHandsValue)+" "+tr("hands")); } if(gameData.raiseIntervalMode == RAISE_ON_HANDNUMBER) {
else { label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryMinutesValue)+" "+tr("minutes")); } label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryHandsValue)+" "+tr("hands"));
} else {
label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryMinutesValue)+" "+tr("minutes"));
}
if(gameData.raiseMode == DOUBLE_BLINDS) { if(gameData.raiseMode == DOUBLE_BLINDS) {
label_blindsRaiseMode->setText(tr("double blinds")); label_blindsRaiseMode->setText(tr("double blinds"));
label_blindsList->hide(); label_blindsList->hide();
label_gameDesc6->hide(); label_gameDesc6->hide();
} } else {
else {
label_blindsRaiseMode->setText(tr("manual blinds order")); label_blindsRaiseMode->setText(tr("manual blinds order"));
label_blindsList->show(); label_blindsList->show();
label_gameDesc6->show(); label_gameDesc6->show();
@@ -1159,19 +1164,22 @@ void gameLobbyDialogImpl::updateDialogBlinds(const GameData &gameData) {
} }
} }
void gameLobbyDialogImpl::playerSelected(QTreeWidgetItem* item, QTreeWidgetItem*) { void gameLobbyDialogImpl::playerSelected(QTreeWidgetItem* item, QTreeWidgetItem*)
{
if (item) if (item)
pushButton_Kick->setEnabled(isGameAdministrator); pushButton_Kick->setEnabled(isGameAdministrator);
} }
void gameLobbyDialogImpl::startGame() { void gameLobbyDialogImpl::startGame()
{
assert(mySession); assert(mySession);
mySession->sendStartEvent(checkBox_fillUpWithComputerOpponents->isChecked()); mySession->sendStartEvent(checkBox_fillUpWithComputerOpponents->isChecked());
} }
void gameLobbyDialogImpl::leaveGame() { void gameLobbyDialogImpl::leaveGame()
{
assert(mySession); assert(mySession);
mySession->sendLeaveCurrentGame(); mySession->sendLeaveCurrentGame();
@@ -1185,18 +1193,19 @@ void gameLobbyDialogImpl::leaveGame() {
waitStartGameMsgBox->hide(); waitStartGameMsgBox->hide();
} }
void gameLobbyDialogImpl::kickPlayer() { void gameLobbyDialogImpl::kickPlayer()
{
QTreeWidgetItem *item = treeWidget_connectedPlayers->currentItem(); QTreeWidgetItem *item = treeWidget_connectedPlayers->currentItem();
if (item) if (item) {
{
QString playerName = item->text(0); QString playerName = item->text(0);
if(playerName == QString::fromUtf8(myConfig->readConfigString("MyName").c_str())) { if(playerName == QString::fromUtf8(myConfig->readConfigString("MyName").c_str())) {
{ QMessageBox::warning(this, tr("Server Error"), {
QMessageBox::warning(this, tr("Server Error"),
tr("You should not kick yourself from this game!"), tr("You should not kick yourself from this game!"),
QMessageBox::Close); } QMessageBox::Close);
} }
else { } else {
assert(mySession); assert(mySession);
mySession->kickPlayer(item->data(0, Qt::UserRole).toUInt()); mySession->kickPlayer(item->data(0, Qt::UserRole).toUInt());
} }
@@ -1204,23 +1213,30 @@ void gameLobbyDialogImpl::kickPlayer() {
pushButton_Kick->setEnabled(false); pushButton_Kick->setEnabled(false);
} }
void gameLobbyDialogImpl::keyPressEvent ( QKeyEvent * event ) { void gameLobbyDialogImpl::keyPressEvent ( QKeyEvent * event )
{
// qDebug() << event->key() << "\n"; // qDebug() << event->key() << "\n";
if (event->key() == Qt::Key_Enter && lineEdit_ChatInput->hasFocus()) { myChat->sendMessage(); } if (event->key() == Qt::Key_Enter && lineEdit_ChatInput->hasFocus()) {
myChat->sendMessage();
}
if (event->key() == Qt::Key_Up && lineEdit_ChatInput->hasFocus()) { if (event->key() == Qt::Key_Up && lineEdit_ChatInput->hasFocus()) {
if((keyUpCounter + 1) <= myChat->getChatLinesHistorySize()) { keyUpCounter++; } if((keyUpCounter + 1) <= myChat->getChatLinesHistorySize()) {
keyUpCounter++;
}
// std::cout << "Up keyUpCounter: " << keyUpCounter << "\n"; // std::cout << "Up keyUpCounter: " << keyUpCounter << "\n";
myChat->showChatHistoryIndex(keyUpCounter); myChat->showChatHistoryIndex(keyUpCounter);
} else if(event->key() == Qt::Key_Down && lineEdit_ChatInput->hasFocus()) {
if((keyUpCounter - 1) >= 0) {
keyUpCounter--;
} }
else if(event->key() == Qt::Key_Down && lineEdit_ChatInput->hasFocus()) {
if((keyUpCounter - 1) >= 0) { keyUpCounter--; }
// std::cout << "Down keyUpCounter: " << keyUpCounter << "\n"; // std::cout << "Down keyUpCounter: " << keyUpCounter << "\n";
myChat->showChatHistoryIndex(keyUpCounter); myChat->showChatHistoryIndex(keyUpCounter);
} else {
keyUpCounter = 0;
} }
else { keyUpCounter = 0; }
// if (event->key() == Qt::Key_Tab) event->ignore(); else { /*blah*/ } // if (event->key() == Qt::Key_Tab) event->ignore(); else { /*blah*/ }
@@ -1237,23 +1253,23 @@ bool gameLobbyDialogImpl::eventFilter(QObject *obj, QEvent *event)
if (obj == lineEdit_ChatInput && lineEdit_ChatInput->text() != "" && event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Tab) { if (obj == lineEdit_ChatInput && lineEdit_ChatInput->text() != "" && event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Tab) {
myChat->nickAutoCompletition(); myChat->nickAutoCompletition();
return true; return true;
} } else if (obj == lineEdit_searchForPlayers && focusEvent->gotFocus() && lineEdit_searchForPlayers->text() == tr("search for player ...")) {
else if (obj == lineEdit_searchForPlayers && focusEvent->gotFocus() && lineEdit_searchForPlayers->text() == tr("search for player ...")) {
lineEdit_searchForPlayers->clear(); lineEdit_searchForPlayers->clear();
return QDialog::eventFilter(obj, event); return QDialog::eventFilter(obj, event);
} } else {
else {
// pass the event on to the parent class // pass the event on to the parent class
return QDialog::eventFilter(obj, event); return QDialog::eventFilter(obj, event);
} }
} }
bool gameLobbyDialogImpl::event ( QEvent * event ) { bool gameLobbyDialogImpl::event ( QEvent * event )
{
return QDialog::event(event); return QDialog::event(event);
} }
void gameLobbyDialogImpl::showGameDescription(bool show) { void gameLobbyDialogImpl::showGameDescription(bool show)
{
if(show) { if(show) {
label_gameType->show(); label_gameType->show();
@@ -1263,8 +1279,7 @@ void gameLobbyDialogImpl::showGameDescription(bool show) {
label_gameDesc5->show(); label_gameDesc5->show();
label_gameDesc6->show(); label_gameDesc6->show();
label_gameDesc7->show(); label_gameDesc7->show();
} } else {
else {
label_gameType->hide(); label_gameType->hide();
label_gameDesc2->hide(); label_gameDesc2->hide();
label_gameDesc3->hide(); label_gameDesc3->hide();
@@ -1275,7 +1290,8 @@ void gameLobbyDialogImpl::showGameDescription(bool show) {
} }
} }
void gameLobbyDialogImpl::showWaitStartGameMsgBox() { void gameLobbyDialogImpl::showWaitStartGameMsgBox()
{
if(this->isVisible()) { if(this->isVisible()) {
waitStartGameMsgBox->show(); waitStartGameMsgBox->show();
@@ -1284,7 +1300,8 @@ void gameLobbyDialogImpl::showWaitStartGameMsgBox() {
} }
} }
void gameLobbyDialogImpl::joinAnyGameButtonRefresh() { void gameLobbyDialogImpl::joinAnyGameButtonRefresh()
{
int openNonPrivateNonFullGamesCounter = 0; int openNonPrivateNonFullGamesCounter = 0;
@@ -1335,7 +1352,8 @@ void gameLobbyDialogImpl::writeDialogSettings(int saveMode)
myConfig->writeConfigInt("DlgGameLobbyNickListSortFilterIndex", comboBox_nickListFilter->currentIndex()); myConfig->writeConfigInt("DlgGameLobbyNickListSortFilterIndex", comboBox_nickListFilter->currentIndex());
} }
break; break;
default:; default:
;
} }
myConfig->writeBuffer(); myConfig->writeBuffer();
@@ -1348,7 +1366,8 @@ void gameLobbyDialogImpl::readDialogSettings()
comboBox_nickListFilter->setCurrentIndex(myConfig->readConfigInt("DlgGameLobbyNickListSortFilterIndex")); comboBox_nickListFilter->setCurrentIndex(myConfig->readConfigInt("DlgGameLobbyNickListSortFilterIndex"));
} }
void gameLobbyDialogImpl::changeGameListFilter(int index) { void gameLobbyDialogImpl::changeGameListFilter(int index)
{
switch(index) { switch(index) {
case 0: { case 0: {
@@ -1386,7 +1405,8 @@ void gameLobbyDialogImpl::changeGameListFilter(int index) {
myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp("private", Qt::CaseInsensitive, QRegExp::FixedString)); myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp("private", Qt::CaseInsensitive, QRegExp::FixedString));
} }
break; break;
default:; default:
;
} }
myGameListSortFilterProxyModel->setFilterRegExp(QString()); myGameListSortFilterProxyModel->setFilterRegExp(QString());
myGameListSortFilterProxyModel->setFilterKeyColumn(0); myGameListSortFilterProxyModel->setFilterKeyColumn(0);
@@ -1409,7 +1429,8 @@ void gameLobbyDialogImpl::changeNickListFilter(int state)
writeDialogSettings(2); writeDialogSettings(2);
} }
void gameLobbyDialogImpl::changeGameListSorting() { void gameLobbyDialogImpl::changeGameListSorting()
{
writeDialogSettings(0); writeDialogSettings(0);
} }
@@ -1442,8 +1463,7 @@ void gameLobbyDialogImpl::showNickListContextMenu(QPoint p)
nickListInviteAction->setEnabled(true); nickListInviteAction->setEnabled(true);
nickListInviteAction->setText(tr("Invite %1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str()))); nickListInviteAction->setText(tr("Invite %1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str())));
} } else {
else {
nickListInviteAction->setText(tr("Invite player ...")); nickListInviteAction->setText(tr("Invite player ..."));
nickListInviteAction->setEnabled(false); nickListInviteAction->setEnabled(false);
} }
@@ -1452,8 +1472,7 @@ void gameLobbyDialogImpl::showNickListContextMenu(QPoint p)
nickListIgnorePlayerAction->setEnabled(true); nickListIgnorePlayerAction->setEnabled(true);
nickListIgnorePlayerAction->setText(tr("Ignore %1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str()))); nickListIgnorePlayerAction->setText(tr("Ignore %1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str())));
} } else {
else {
nickListIgnorePlayerAction->setEnabled(false); nickListIgnorePlayerAction->setEnabled(false);
nickListIgnorePlayerAction->setText(tr("Ignore player ...")); nickListIgnorePlayerAction->setText(tr("Ignore player ..."));
@@ -1464,8 +1483,7 @@ void gameLobbyDialogImpl::showNickListContextMenu(QPoint p)
QString playerInGameInfoString; QString playerInGameInfoString;
if(gameIdOfPlayer) { if(gameIdOfPlayer) {
playerInGameInfoString = tr("%1 is playing in \"%2\".").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str())).arg(QString::fromUtf8(mySession->getClientGameInfo(gameIdOfPlayer).name.c_str())); playerInGameInfoString = tr("%1 is playing in \"%2\".").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str())).arg(QString::fromUtf8(mySession->getClientGameInfo(gameIdOfPlayer).name.c_str()));
} } else {
else {
playerInGameInfoString = tr("%1 is not playing at the moment.").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str())); playerInGameInfoString = tr("%1 is not playing at the moment.").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str()));
} }
nickListPlayerInGameInfo->setText(playerInGameInfoString); nickListPlayerInGameInfo->setText(playerInGameInfoString);
@@ -1492,7 +1510,8 @@ void gameLobbyDialogImpl::showInfoMsgBox()
dialog.exec(2, tr("You have entered a game with type \"invite-only\".\nFeel free to invite other players by right-clicking on their nick in the available players list."), tr("PokerTH - Info Message"), QPixmap(":/gfx/ktip.png"), QDialogButtonBox::Ok, true); dialog.exec(2, tr("You have entered a game with type \"invite-only\".\nFeel free to invite other players by right-clicking on their nick in the available players list."), tr("PokerTH - Info Message"), QPixmap(":/gfx/ktip.png"), QDialogButtonBox::Ok, true);
} }
break; break;
default:; default:
;
break; break;
} }
} }
@@ -1502,8 +1521,7 @@ void gameLobbyDialogImpl::showInvitationDialog(unsigned gameId, unsigned playerI
if(inviteDialogIsCurrentlyShown || playerIsOnIgnoreList(playerIdFrom)) { if(inviteDialogIsCurrentlyShown || playerIsOnIgnoreList(playerIdFrom)) {
mySession->rejectGameInvitation(gameId, DENY_GAME_INVITATION_BUSY); mySession->rejectGameInvitation(gameId, DENY_GAME_INVITATION_BUSY);
} } else {
else {
inviteDialogIsCurrentlyShown = true; inviteDialogIsCurrentlyShown = true;
@@ -1512,8 +1530,7 @@ void gameLobbyDialogImpl::showInvitationDialog(unsigned gameId, unsigned playerI
mySession->acceptGameInvitation(gameId); mySession->acceptGameInvitation(gameId);
inviteDialogIsCurrentlyShown = false; inviteDialogIsCurrentlyShown = false;
} } else {
else {
mySession->rejectGameInvitation(gameId, DENY_GAME_INVITATION_NO); mySession->rejectGameInvitation(gameId, DENY_GAME_INVITATION_NO);
inviteDialogIsCurrentlyShown = false; inviteDialogIsCurrentlyShown = false;
} }
@@ -1538,7 +1555,8 @@ void gameLobbyDialogImpl::chatInfoPlayerRejectedInvitation(unsigned gameId, unsi
} }
bool gameLobbyDialogImpl::playerIsOnIgnoreList(unsigned playerId) { bool gameLobbyDialogImpl::playerIsOnIgnoreList(unsigned playerId)
{
list<std::string> playerIgnoreList = myConfig->readConfigStringList("PlayerIgnoreList"); list<std::string> playerIgnoreList = myConfig->readConfigStringList("PlayerIgnoreList");
list<std::string>::iterator it1; list<std::string>::iterator it1;
@@ -1552,7 +1570,8 @@ bool gameLobbyDialogImpl::playerIsOnIgnoreList(unsigned playerId) {
} }
void gameLobbyDialogImpl::putPlayerOnIgnoreList() { void gameLobbyDialogImpl::putPlayerOnIgnoreList()
{
if(myNickListSelectionModel->currentIndex().isValid()) { if(myNickListSelectionModel->currentIndex().isValid()) {
@@ -1599,8 +1618,7 @@ void gameLobbyDialogImpl::updateAutoStartTimer()
if(autoStartTimerCounter) { if(autoStartTimerCounter) {
QString string(tr("The game will start in<br><b>%1</b> seconds.").arg(autoStartTimerCounter)); QString string(tr("The game will start in<br><b>%1</b> seconds.").arg(autoStartTimerCounter));
autoStartTimerOverlay->setText("<span style='color:#008B00; font-size:9pt;'>"+string+"</span>"); autoStartTimerOverlay->setText("<span style='color:#008B00; font-size:9pt;'>"+string+"</span>");
} } else {
else {
autoStartTimer->stop(); autoStartTimer->stop();
autoStartTimerOverlay->hide(); autoStartTimerOverlay->hide();
} }
@@ -35,7 +35,8 @@ class MyNickListSortFilterProxyModel;
@author FThauer FHammer <webmaster@pokerth.net> @author FThauer FHammer <webmaster@pokerth.net>
*/ */
class gameLobbyDialogImpl: public QDialog, public Ui::gameLobbyDialog { class gameLobbyDialogImpl: public QDialog, public Ui::gameLobbyDialog
{
Q_OBJECT Q_OBJECT
public: public:
gameLobbyDialogImpl(startWindowImpl *parent = 0, ConfigFile* = 0); gameLobbyDialogImpl(startWindowImpl *parent = 0, ConfigFile* = 0);
@@ -44,12 +45,19 @@ public:
void exec(); void exec();
ChatTools *getMyChat() { return myChat; } ChatTools *getMyChat() {
return myChat;
}
void setSession(boost::shared_ptr<Session> session); void setSession(boost::shared_ptr<Session> session);
boost::shared_ptr<Session> getSession() { assert(mySession.get()); return mySession; } boost::shared_ptr<Session> getSession() {
assert(mySession.get());
return mySession;
}
void setMyW ( gameTableImpl* theValue ) { myW = theValue; } void setMyW ( gameTableImpl* theValue ) {
myW = theValue;
}
public slots: public slots:
@@ -69,9 +77,15 @@ public slots:
void updateStats(ServerStats stats); void updateStats(ServerStats stats);
void refreshGameStats(); void refreshGameStats();
void refreshPlayerStats(); void refreshPlayerStats();
void setCurrentGameName ( const QString& theValue ) { currentGameName = theValue; } void setCurrentGameName ( const QString& theValue ) {
QString getCurrentGameName() const { return currentGameName; } currentGameName = theValue;
gameTableImpl* getMyW() const { return myW; } }
QString getCurrentGameName() const {
return currentGameName;
}
gameTableImpl* getMyW() const {
return myW;
}
void checkPlayerQuantity(); void checkPlayerQuantity();
void blinkingStartButtonAnimation(); void blinkingStartButtonAnimation();
void joinedNetworkGame(unsigned, QString, bool); void joinedNetworkGame(unsigned, QString, bool);
@@ -7,7 +7,8 @@ MyGameListSortFilterProxyModel::MyGameListSortFilterProxyModel(QObject *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 index0 = sourceModel()->index(sourceRow, 0, sourceParent);
QModelIndex index1 = sourceModel()->index(sourceRow, 1, sourceParent); QModelIndex index1 = sourceModel()->index(sourceRow, 1, sourceParent);
@@ -5,19 +5,27 @@
class MyGameListSortFilterProxyModel : public QSortFilterProxyModel class MyGameListSortFilterProxyModel : public QSortFilterProxyModel
{ {
Q_OBJECT Q_OBJECT
public: public:
MyGameListSortFilterProxyModel(QObject *parent = 0); MyGameListSortFilterProxyModel(QObject *parent = 0);
void setColumn1RegExp(QRegExp column1) { column1RegExp = column1; } void setColumn1RegExp(QRegExp column1) {
void setColumn2RegExp(QRegExp column2) { column2RegExp = column2; } column1RegExp = column1;
void setColumn3RegExp(QRegExp column3) { column3RegExp = column3; } }
void setColumn4RegExp(QRegExp column4) { column4RegExp = column4; } void setColumn2RegExp(QRegExp column2) {
column2RegExp = column2;
}
void setColumn3RegExp(QRegExp column3) {
column3RegExp = column3;
}
void setColumn4RegExp(QRegExp column4) {
column4RegExp = column4;
}
protected: protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
private: private:
QRegExp column1RegExp; QRegExp column1RegExp;
QRegExp column2RegExp; QRegExp column2RegExp;
QRegExp column3RegExp; QRegExp column3RegExp;
@@ -28,7 +28,8 @@ MyGameListTreeWidget::~MyGameListTreeWidget()
{ {
} }
void MyGameListTreeWidget::setGameListBackgroundImage(QString pmString) { void MyGameListTreeWidget::setGameListBackgroundImage(QString pmString)
{
gameListBGPixmap.load(pmString); gameListBGPixmap.load(pmString);
} }
@@ -53,7 +54,8 @@ void MyGameListTreeWidget::setGameListBackgroundImage(QString pmString) {
// QTreeWidget::paintEvent(event); // QTreeWidget::paintEvent(event);
// } // }
void MyGameListTreeWidget::scrollContentsBy ( int dx, int dy ) { void MyGameListTreeWidget::scrollContentsBy ( int dx, int dy )
{
viewport()->update(); viewport()->update();
@@ -17,7 +17,7 @@
class MyGameListTreeWidget : public QTreeWidget class MyGameListTreeWidget : public QTreeWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
MyGameListTreeWidget(QDialog*); MyGameListTreeWidget(QDialog*);
File diff suppressed because it is too large. Load diff
+27 -9
View File
@@ -51,7 +51,8 @@ class CardDeckStyleReader;
class SDLPlayer; class SDLPlayer;
class gameTableImpl: public QMainWindow, public Ui::gameTable { class gameTableImpl: public QMainWindow, public Ui::gameTable
{
Q_OBJECT Q_OBJECT
public: public:
@@ -60,14 +61,28 @@ public:
~gameTableImpl(); ~gameTableImpl();
boost::shared_ptr<Session> getSession(); boost::shared_ptr<Session> getSession();
SDLPlayer* getMySDLPlayer() const { return mySDLPlayer; } SDLPlayer* getMySDLPlayer() const {
ChatTools* getMyChat() const { return myChat; } return mySDLPlayer;
ConfigFile* getMyConfig() const { return myConfig; } }
GameTableStyleReader* getMyGameTableStyle() const { return myGameTableStyle; } ChatTools* getMyChat() const {
bool getGuestMode() const { return guestMode; } return myChat;
}
ConfigFile* getMyConfig() const {
return myConfig;
}
GameTableStyleReader* getMyGameTableStyle() const {
return myGameTableStyle;
}
bool getGuestMode() const {
return guestMode;
}
void setStartWindow(startWindowImpl* s) { myStartWindow = s; } void setStartWindow(startWindowImpl* s) {
void setGuiLog(guiLog* l) { myGuiLog = l; } myStartWindow = s;
}
void setGuiLog(guiLog* l) {
myGuiLog = l;
}
void setSpeeds(); void setSpeeds();
@@ -160,7 +175,10 @@ public slots:
void startTimeoutAnimation(int playerId, int timoutSec); void startTimeoutAnimation(int playerId, int timoutSec);
void stopTimeoutAnimation(int playerId); void stopTimeoutAnimation(int playerId);
void setGameSpeed(const int theValue) { guiGameSpeed = theValue; setSpeeds(); } // Achtung Faktor 10!!! void setGameSpeed(const int theValue) {
guiGameSpeed = theValue; // Achtung Faktor 10!!!
setSpeeds();
}
void callSettingsDialog(); void callSettingsDialog();
void applySettings(settingsDialogImpl*); void applySettings(settingsDialogImpl*);
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -35,7 +35,7 @@ class GameTableStyleReader;
class guiLog : public QObject class guiLog : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
guiLog(gameTableImpl*, ConfigFile *c); guiLog(gameTableImpl*, ConfigFile *c);
@@ -94,7 +94,7 @@ private:
GameTableStyleReader *myStyle; GameTableStyleReader *myStyle;
friend class GuiWrapper; friend class GuiWrapper;
}; };
#endif #endif
+4 -5
View File
@@ -25,7 +25,8 @@ MyActionButton::~MyActionButton()
} }
void MyActionButton::paintEvent(QPaintEvent * event) { void MyActionButton::paintEvent(QPaintEvent * event)
{
QPushButton::paintEvent(event); QPushButton::paintEvent(event);
@@ -37,11 +38,9 @@ void MyActionButton::paintEvent(QPaintEvent * event) {
painter.setFont(f); painter.setFont(f);
if(objectName()==("pushButton_AllIn")) { if(objectName()==("pushButton_AllIn")) {
painter.drawText(6,6,15,15,Qt::AlignLeft,fKeyText); painter.drawText(6,6,15,15,Qt::AlignLeft,fKeyText);
} } else if(objectName()==("pushButton_showMyCards")) {
else if(objectName()==("pushButton_showMyCards")){
painter.drawText(6,6,15,15,Qt::AlignLeft,QString("F5")); painter.drawText(6,6,15,15,Qt::AlignLeft,QString("F5"));
} } else {
else {
painter.drawText(8,15,15,15,Qt::AlignLeft,fKeyText); painter.drawText(8,15,15,15,Qt::AlignLeft,fKeyText);
} }
} }
+6 -2
View File
@@ -25,9 +25,13 @@ public:
~MyActionButton(); ~MyActionButton();
void paintEvent(QPaintEvent * event); void paintEvent(QPaintEvent * event);
void setFKeyText ( const QString& theValue ){fKeyText = theValue;} void setFKeyText ( const QString& theValue ) {
fKeyText = theValue;
}
void setMyStyle ( GameTableStyleReader* theValue ) { myStyle = theValue; } void setMyStyle ( GameTableStyleReader* theValue ) {
myStyle = theValue;
}
private: private:
+95 -113
View File
@@ -47,7 +47,8 @@ MyAvatarLabel::~MyAvatarLabel()
{ {
} }
void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) { void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event )
{
assert(myW->getSession()->getCurrentGame()); assert(myW->getSession()->getCurrentGame());
if (myW->getSession()->isNetworkClientRunning()) { if (myW->getSession()->isNetworkClientRunning()) {
@@ -67,8 +68,7 @@ void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) {
if(activePlayerCounter > 2 && !voteRunning && info.data.gameType != GAME_TYPE_RANKING && !myW->getGuestMode()) { if(activePlayerCounter > 2 && !voteRunning && info.data.gameType != GAME_TYPE_RANKING && !myW->getGuestMode()) {
setVoteOnKickContextMenuEnabled(TRUE); setVoteOnKickContextMenuEnabled(TRUE);
} } else {
else {
setVoteOnKickContextMenuEnabled(FALSE); setVoteOnKickContextMenuEnabled(FALSE);
} }
@@ -78,12 +78,10 @@ void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) {
for (it_c=seatList->begin(); it_c!=seatList->end(); ++it_c) { for (it_c=seatList->begin(); it_c!=seatList->end(); ++it_c) {
if(myId == j) { if(myId == j) {
if(j == 0) if(j == 0) {
{
action_EditTip->setDisabled(true); action_EditTip->setDisabled(true);
} }
if(myW->myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK) if(myW->myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_NETWORK) {
{
action_EditTip->setDisabled(true); action_EditTip->setDisabled(true);
} }
@@ -94,8 +92,7 @@ void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) {
if(myW->getSession()->getGameType() == Session::GAME_TYPE_INTERNET && !((*it_c)->getMyAvatar().empty()) ) { if(myW->getSession()->getGameType() == Session::GAME_TYPE_INTERNET && !((*it_c)->getMyAvatar().empty()) ) {
action_ReportBadAvatar->setVisible(TRUE); action_ReportBadAvatar->setVisible(TRUE);
} } else {
else {
action_ReportBadAvatar->setVisible(FALSE); action_ReportBadAvatar->setVisible(FALSE);
} }
} }
@@ -115,84 +112,77 @@ void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) {
} }
} }
void MyAvatarLabel::showContextMenu(const QPoint &pos) { void MyAvatarLabel::showContextMenu(const QPoint &pos)
{
myContextMenu->popup(pos); myContextMenu->popup(pos);
} }
void MyAvatarLabel::setPlayerRating(QString playerInfo) void MyAvatarLabel::setPlayerRating(QString playerInfo)
{ {
int found=0; int found=0;
QStringList playerInfoList=playerInfo.split("\"", QString::KeepEmptyParts, Qt::CaseSensitive), tipInfo; QStringList playerInfoList=playerInfo.split("\"", QString::KeepEmptyParts, Qt::CaseSensitive), tipInfo;
boost::shared_ptr<Game> currentGame = myW->myStartWindow->getSession()->getCurrentGame(); boost::shared_ptr<Game> currentGame = myW->myStartWindow->getSession()->getCurrentGame();
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
PlayerList seatsList = currentGame->getSeatsList(); PlayerList seatsList = currentGame->getSeatsList();
std::list<std::string> tipsList = myW->getMyConfig()->readConfigStringList("PlayerTooltips"); std::list<std::string> tipsList = myW->getMyConfig()->readConfigStringList("PlayerTooltips");
std::list<std::string> result; std::list<std::string> result;
std::string separator="(!#$%)"; std::string separator="(!#$%)";
std::list<std::string>::iterator iterator; std::list<std::string>::iterator iterator;
for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) { for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) {
tipInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive); tipInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive);
if(tipInfo.at(0)==playerInfoList.at(0)) if(tipInfo.at(0)==playerInfoList.at(0)) {
{
result.push_back(tipInfo.at(0).toUtf8().constData()+separator+tipInfo.at(1).toUtf8().constData()+separator+playerInfoList.at(1).toUtf8().constData()+separator); result.push_back(tipInfo.at(0).toUtf8().constData()+separator+tipInfo.at(1).toUtf8().constData()+separator+playerInfoList.at(1).toUtf8().constData()+separator);
found=1; found=1;
} } else {
else
{
result.push_back(tipInfo.at(0).toUtf8().constData()+separator+tipInfo.at(1).toUtf8().constData()+separator+tipInfo.at(2).toUtf8().constData()+separator); result.push_back(tipInfo.at(0).toUtf8().constData()+separator+tipInfo.at(1).toUtf8().constData()+separator+tipInfo.at(2).toUtf8().constData()+separator);
} }
} }
if(found==0) if(found==0) {
{
result.push_back(playerInfoList.at(0).toUtf8().constData()+separator+separator+playerInfoList.at(1).toUtf8().constData()+separator); result.push_back(playerInfoList.at(0).toUtf8().constData()+separator+separator+playerInfoList.at(1).toUtf8().constData()+separator);
} }
myW->getMyConfig()->writeConfigStringList("PlayerTooltips", result); myW->getMyConfig()->writeConfigStringList("PlayerTooltips", result);
myW->getMyConfig()->writeBuffer(); myW->getMyConfig()->writeBuffer();
refreshStars(); refreshStars();
} }
void MyAvatarLabel::startChangePlayerTip(QString playerName) void MyAvatarLabel::startChangePlayerTip(QString playerName)
{ {
if(myW->tabWidget_Left->widget(2) == myW->tab_Kick) if(myW->tabWidget_Left->widget(2) == myW->tab_Kick) {
{
myW->tabWidget_Left->insertTab(3, myW->tab_editTip, playerName); myW->tabWidget_Left->insertTab(3, myW->tab_editTip, playerName);
myW->tabWidget_Left->setCurrentIndex(3); myW->tabWidget_Left->setCurrentIndex(3);
} } else {
else
{
myW->tabWidget_Left->insertTab(2, myW->tab_editTip, playerName); myW->tabWidget_Left->insertTab(2, myW->tab_editTip, playerName);
myW->tabWidget_Left->setCurrentIndex(2); myW->tabWidget_Left->setCurrentIndex(2);
} }
myW->textEdit_tipInput->setPlainText(getPlayerTip(playerName)); myW->textEdit_tipInput->setPlainText(getPlayerTip(playerName));
} }
void MyAvatarLabel::refreshStars() void MyAvatarLabel::refreshStars()
{ {
boost::shared_ptr<Game> curGame = myW->myStartWindow->getSession()->getCurrentGame(); boost::shared_ptr<Game> curGame = myW->myStartWindow->getSession()->getCurrentGame();
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
int seatPlace; int seatPlace;
PlayerList seatsList = curGame->getSeatsList(); PlayerList seatsList = curGame->getSeatsList();
for (seatPlace=0,it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c, seatPlace++) { for (seatPlace=0,it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c, seatPlace++) {
for(int i=1;i<=5;i++)myW->playerStarsArray[i][seatPlace]->setText(""); for(int i=1; i<=5; i++)myW->playerStarsArray[i][seatPlace]->setText("");
if(myW->myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET && !myW->getSession()->getClientPlayerInfo((*it_c)->getMyUniqueID()).isGuest && (*it_c)->getMyType() != PLAYER_TYPE_COMPUTER) if(myW->myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET && !myW->getSession()->getClientPlayerInfo((*it_c)->getMyUniqueID()).isGuest && (*it_c)->getMyType() != PLAYER_TYPE_COMPUTER)
if((*it_c)->getMyStayOnTableStatus() == TRUE && (*it_c)->getMyName()!="" && seatPlace!=0) { if((*it_c)->getMyStayOnTableStatus() == TRUE && (*it_c)->getMyName()!="" && seatPlace!=0) {
int playerStars=getPlayerRating(QString::fromUtf8((*it_c)->getMyName().c_str())); int playerStars=getPlayerRating(QString::fromUtf8((*it_c)->getMyName().c_str()));
for(int i=1;i<=5;i++) for(int i=1; i<=5; i++) {
{
myW->playerStarsArray[i][seatPlace]->setText("<a style='color: yellow;' href='"+QString::fromUtf8((*it_c)->getMyName().c_str())+"\""+QString::number(i)+"'>&#9734;</a>"); myW->playerStarsArray[i][seatPlace]->setText("<a style='color: yellow;' href='"+QString::fromUtf8((*it_c)->getMyName().c_str())+"\""+QString::number(i)+"'>&#9734;</a>");
} }
for(int i=1;i<=playerStars;i++) for(int i=1; i<=playerStars; i++) {
{
myW->playerStarsArray[i][seatPlace]->setText("<a style='color: #"+myW->getMyGameTableStyle()->getRatingStarsColor()+";' href='"+QString::fromUtf8((*it_c)->getMyName().c_str())+"\""+QString::number(i)+"'>&#9733;</a>"); myW->playerStarsArray[i][seatPlace]->setText("<a style='color: #"+myW->getMyGameTableStyle()->getRatingStarsColor()+";' href='"+QString::fromUtf8((*it_c)->getMyName().c_str())+"\""+QString::number(i)+"'>&#9733;</a>");
} }
} }
} }
} }
void MyAvatarLabel::refreshTooltips() { void MyAvatarLabel::refreshTooltips()
{
boost::shared_ptr<Game> currentGame = myW->myStartWindow->getSession()->getCurrentGame(); boost::shared_ptr<Game> currentGame = myW->myStartWindow->getSession()->getCurrentGame();
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
int seatPlace; int seatPlace;
@@ -200,22 +190,19 @@ void MyAvatarLabel::refreshTooltips() {
for (seatPlace=0,it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c, seatPlace++) { for (seatPlace=0,it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c, seatPlace++) {
if((*it_c)->getMyStayOnTableStatus() == TRUE || (*it_c)->getMyActiveStatus()) { if((*it_c)->getMyStayOnTableStatus() == TRUE || (*it_c)->getMyActiveStatus()) {
bool computerPlayer = false; bool computerPlayer = false;
if((*it_c)->getMyType() == PLAYER_TYPE_COMPUTER) { computerPlayer = true; } if((*it_c)->getMyType() == PLAYER_TYPE_COMPUTER) {
if(!computerPlayer && getPlayerTip(QString::fromUtf8((*it_c)->getMyName().c_str()))!="") computerPlayer = true;
{ }
if(!computerPlayer && getPlayerTip(QString::fromUtf8((*it_c)->getMyName().c_str()))!="") {
myW->playerTipLabelArray[(*it_c)->getMyID()]->setText(QString("<a style='text-decoration: none; color: #"+myW->getMyGameTableStyle()->getPlayerInfoHintTextColor()+"; font-size: 14px; font-weight: bold; font-family:serif;' href=\'")+QString::fromUtf8((*it_c)->getMyName().c_str())+"\'>i</a>"); myW->playerTipLabelArray[(*it_c)->getMyID()]->setText(QString("<a style='text-decoration: none; color: #"+myW->getMyGameTableStyle()->getPlayerInfoHintTextColor()+"; font-size: 14px; font-weight: bold; font-family:serif;' href=\'")+QString::fromUtf8((*it_c)->getMyName().c_str())+"\'>i</a>");
myW->playerTipLabelArray[(*it_c)->getMyID()]->setToolTip( getPlayerTip(QString::fromUtf8((*it_c)->getMyName().c_str())) ); myW->playerTipLabelArray[(*it_c)->getMyID()]->setToolTip( getPlayerTip(QString::fromUtf8((*it_c)->getMyName().c_str())) );
myW->playerAvatarLabelArray[(*it_c)->getMyID()]->setToolTip( getPlayerTip(QString::fromUtf8((*it_c)->getMyName().c_str())) ); myW->playerAvatarLabelArray[(*it_c)->getMyID()]->setToolTip( getPlayerTip(QString::fromUtf8((*it_c)->getMyName().c_str())) );
} } else {
else
{
myW->playerTipLabelArray[(*it_c)->getMyID()]->setText(""); myW->playerTipLabelArray[(*it_c)->getMyID()]->setText("");
myW->playerTipLabelArray[(*it_c)->getMyID()]->setToolTip(""); myW->playerTipLabelArray[(*it_c)->getMyID()]->setToolTip("");
myW->playerAvatarLabelArray[(*it_c)->getMyID()]->setToolTip(""); myW->playerAvatarLabelArray[(*it_c)->getMyID()]->setToolTip("");
} }
} } else {
else
{
myW->playerTipLabelArray[(*it_c)->getMyID()]->setText(""); myW->playerTipLabelArray[(*it_c)->getMyID()]->setText("");
myW->playerTipLabelArray[(*it_c)->getMyID()]->setToolTip(""); myW->playerTipLabelArray[(*it_c)->getMyID()]->setToolTip("");
myW->playerAvatarLabelArray[(*it_c)->getMyID()]->setToolTip(""); myW->playerAvatarLabelArray[(*it_c)->getMyID()]->setToolTip("");
@@ -224,80 +211,72 @@ void MyAvatarLabel::refreshTooltips() {
} }
refreshStars(); refreshStars();
} }
int MyAvatarLabel::getPlayerRating(QString playerName) int MyAvatarLabel::getPlayerRating(QString playerName)
{ {
std::list<std::string> tipsList = myW->getMyConfig()->readConfigStringList("PlayerTooltips"); std::list<std::string> tipsList = myW->getMyConfig()->readConfigStringList("PlayerTooltips");
std::list<std::string>::iterator iterator; std::list<std::string>::iterator iterator;
QStringList playerInfo; QStringList playerInfo;
QString result="0"; QString result="0";
for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) { for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) {
playerInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive); playerInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive);
if(playerInfo.at(0)==playerName) if(playerInfo.at(0)==playerName) {
{
result=playerInfo.at(2); result=playerInfo.at(2);
break; break;
} }
} }
return result.toInt(); return result.toInt();
} }
QString MyAvatarLabel::getPlayerTip(QString playerName) QString MyAvatarLabel::getPlayerTip(QString playerName)
{ {
std::list<std::string> tipsList = myW->getMyConfig()->readConfigStringList("PlayerTooltips"); std::list<std::string> tipsList = myW->getMyConfig()->readConfigStringList("PlayerTooltips");
std::list<std::string>::iterator iterator; std::list<std::string>::iterator iterator;
QStringList playerInfo; QStringList playerInfo;
for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) { for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) {
playerInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive); playerInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive);
if(playerInfo.at(0)==playerName)return playerInfo.at(1); if(playerInfo.at(0)==playerName)return playerInfo.at(1);
} }
return QString(""); return QString("");
} }
void MyAvatarLabel::setPlayerTip() void MyAvatarLabel::setPlayerTip()
{ {
int found=0; int found=0;
std::string rating="1", separator="(!#$%)"; std::string rating="1", separator="(!#$%)";
std::string tip = std::string((const char*)myW->textEdit_tipInput->toPlainText().toUtf8()); std::string tip = std::string((const char*)myW->textEdit_tipInput->toPlainText().toUtf8());
std::string playerName; std::string playerName;
if(myW->tabWidget_Left->widget(2) == myW->tab_editTip)playerName = myW->tabWidget_Left->tabText(2).toUtf8().constData(); if(myW->tabWidget_Left->widget(2) == myW->tab_editTip)playerName = myW->tabWidget_Left->tabText(2).toUtf8().constData();
if(myW->tabWidget_Left->widget(3) == myW->tab_editTip)playerName = myW->tabWidget_Left->tabText(3).toUtf8().constData(); if(myW->tabWidget_Left->widget(3) == myW->tab_editTip)playerName = myW->tabWidget_Left->tabText(3).toUtf8().constData();
QStringList playerInfo; QStringList playerInfo;
std::list<std::string> tipsList = myW->getMyConfig()->readConfigStringList("PlayerTooltips"); std::list<std::string> tipsList = myW->getMyConfig()->readConfigStringList("PlayerTooltips");
std::list<std::string> result; std::list<std::string> result;
std::list<std::string>::iterator iterator; std::list<std::string>::iterator iterator;
for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) { for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) {
playerInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive); playerInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive);
if(QString::fromUtf8(playerName.c_str())==playerInfo.at(0)) if(QString::fromUtf8(playerName.c_str())==playerInfo.at(0)) {
{
result.push_back(playerName+separator+QString::fromUtf8(tip.c_str()).toUtf8().constData()+separator+playerInfo.at(2).toStdString()+separator); result.push_back(playerName+separator+QString::fromUtf8(tip.c_str()).toUtf8().constData()+separator+playerInfo.at(2).toStdString()+separator);
found=1; found=1;
} } else {
else
{
result.push_back(playerInfo.at(0).toUtf8().constData()+separator+playerInfo.at(1).toUtf8().constData()+separator+playerInfo.at(2).toStdString()+separator); result.push_back(playerInfo.at(0).toUtf8().constData()+separator+playerInfo.at(1).toUtf8().constData()+separator+playerInfo.at(2).toStdString()+separator);
} }
} }
if(found==0) if(found==0) {
{
result.push_back(playerName.c_str()+separator+QString::fromUtf8(tip.c_str()).toUtf8().constData()+separator+QString("0").toStdString()+separator); result.push_back(playerName.c_str()+separator+QString::fromUtf8(tip.c_str()).toUtf8().constData()+separator+QString("0").toStdString()+separator);
} }
myW->getMyConfig()->writeConfigStringList("PlayerTooltips", result); myW->getMyConfig()->writeConfigStringList("PlayerTooltips", result);
myW->getMyConfig()->writeBuffer(); myW->getMyConfig()->writeBuffer();
if(myW->tabWidget_Left->widget(3) == myW->tab_editTip) if(myW->tabWidget_Left->widget(3) == myW->tab_editTip) {
{
myW->tabWidget_Left->removeTab(3); myW->tabWidget_Left->removeTab(3);
} } else if(myW->tabWidget_Left->widget(2) == myW->tab_editTip) {
else if(myW->tabWidget_Left->widget(2) == myW->tab_editTip)
{
myW->tabWidget_Left->removeTab(2); myW->tabWidget_Left->removeTab(2);
} }
refreshTooltips(); refreshTooltips();
} }
@@ -316,7 +295,8 @@ void MyAvatarLabel::setVoteOnKickContextMenuEnabled(bool b)
action_VoteForKick->setEnabled(b); action_VoteForKick->setEnabled(b);
} }
void MyAvatarLabel::setPixmap ( const QPixmap &pix, const bool trans) { void MyAvatarLabel::setPixmap ( const QPixmap &pix, const bool trans)
{
myPixmap = pix.scaled(50,50, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); myPixmap = pix.scaled(50,50, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
transparent = trans; transparent = trans;
@@ -324,19 +304,16 @@ void MyAvatarLabel::setPixmap ( const QPixmap &pix, const bool trans) {
} }
void MyAvatarLabel::setPixmapAndCountry ( const QPixmap &pix,QString countryString, int seatPlace, const bool trans) { void MyAvatarLabel::setPixmapAndCountry ( const QPixmap &pix,QString countryString, int seatPlace, const bool trans)
{
QPixmap resultAvatar(pix.scaled(50,50, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); QPixmap resultAvatar(pix.scaled(50,50, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
QPainter painter(&resultAvatar); QPainter painter(&resultAvatar);
int showCountryFlags = myW->getMyConfig()->readConfigInt("ShowCountryFlagInAvatar"); int showCountryFlags = myW->getMyConfig()->readConfigInt("ShowCountryFlagInAvatar");
if(showCountryFlags && !countryString.isEmpty()) if(showCountryFlags && !countryString.isEmpty()) {
{ if(seatPlace<=2||seatPlace>=8) {
if(seatPlace<=2||seatPlace>=8)
{
painter.drawPixmap(resultAvatar.width()-(QPixmap(countryString)).width(),resultAvatar.height()-(QPixmap(countryString)).height(),QPixmap(countryString)); painter.drawPixmap(resultAvatar.width()-(QPixmap(countryString)).width(),resultAvatar.height()-(QPixmap(countryString)).height(),QPixmap(countryString));
} } else {
else
{
painter.drawPixmap(resultAvatar.width()-(QPixmap(countryString)).width(),0,QPixmap(countryString)); painter.drawPixmap(resultAvatar.width()-(QPixmap(countryString)).width(),0,QPixmap(countryString));
} }
} }
@@ -347,7 +324,8 @@ void MyAvatarLabel::setPixmapAndCountry ( const QPixmap &pix,QString countryStri
} }
void MyAvatarLabel::paintEvent(QPaintEvent*) { void MyAvatarLabel::paintEvent(QPaintEvent*)
{
QPainter painter(this); QPainter painter(this);
if(transparent) if(transparent)
@@ -358,7 +336,8 @@ void MyAvatarLabel::paintEvent(QPaintEvent*) {
painter.drawPixmap(0,0,myPixmap); painter.drawPixmap(0,0,myPixmap);
} }
bool MyAvatarLabel::playerIsOnIgnoreList(QString playerName) { bool MyAvatarLabel::playerIsOnIgnoreList(QString playerName)
{
list<std::string> playerIgnoreList = myW->getMyConfig()->readConfigStringList("PlayerIgnoreList"); list<std::string> playerIgnoreList = myW->getMyConfig()->readConfigStringList("PlayerIgnoreList");
list<std::string>::iterator it1; list<std::string>::iterator it1;
@@ -372,7 +351,8 @@ bool MyAvatarLabel::playerIsOnIgnoreList(QString playerName) {
} }
void MyAvatarLabel::putPlayerOnIgnoreList() { void MyAvatarLabel::putPlayerOnIgnoreList()
{
QStringList list; QStringList list;
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
@@ -396,7 +376,8 @@ void MyAvatarLabel::putPlayerOnIgnoreList() {
} }
} }
void MyAvatarLabel::reportBadAvatar() { void MyAvatarLabel::reportBadAvatar()
{
boost::shared_ptr<Game> currentGame = myW->getSession()->getCurrentGame(); boost::shared_ptr<Game> currentGame = myW->getSession()->getCurrentGame();
int j=0; int j=0;
@@ -425,7 +406,8 @@ void MyAvatarLabel::reportBadAvatar() {
} }
void MyAvatarLabel::startEditTip() { void MyAvatarLabel::startEditTip()
{
boost::shared_ptr<Game> currentGame = myW->getSession()->getCurrentGame(); boost::shared_ptr<Game> currentGame = myW->getSession()->getCurrentGame();
int j=0; int j=0;
PlayerListConstIterator it_c; PlayerListConstIterator it_c;
Loaded 100 of 207 files, more files were not shown because too many files have changed in this diff. Show more