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:
@@ -3,12 +3,15 @@
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
class BadWordCheck: public QObject {
|
||||
class BadWordCheck: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
BadWordCheck();
|
||||
|
||||
void setBadWords(QStringList bw) { badWords = bw; }
|
||||
void setBadWords(QStringList bw) {
|
||||
badWords = bw;
|
||||
}
|
||||
|
||||
bool run(QString);
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@ bool CapsFloodCheck::run(QString msg)
|
||||
e.indexIn(msg);
|
||||
if(e.matchedLength() != -1 ) return true;
|
||||
else return false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// qDebug() << "The current Caps Flood RegExp is invalid" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3,12 +3,15 @@
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
class CapsFloodCheck: public QObject {
|
||||
class CapsFloodCheck: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CapsFloodCheck();
|
||||
|
||||
void setCapsNumberToTrigger(int n) { capsNumberToTrigger = n; }
|
||||
void setCapsNumberToTrigger(int n) {
|
||||
capsNumberToTrigger = n;
|
||||
}
|
||||
bool run(QString);
|
||||
|
||||
private:
|
||||
|
||||
@@ -50,8 +50,7 @@ CleanerConfig::CleanerConfig()
|
||||
const char *appDataPath = getenv("AppData");
|
||||
if (appDataPath && appDataPath[0] != 0) {
|
||||
configFileName = appDataPath;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
const int MaxPathSize = 1024;
|
||||
char curDir[MaxPathSize + 1];
|
||||
curDir[0] = 0;
|
||||
@@ -67,8 +66,7 @@ CleanerConfig::CleanerConfig()
|
||||
// Datei wieder loeschen.
|
||||
tmpFile.close();
|
||||
remove((configFileName + "\\" + tmpFileName).c_str());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Fehlgeschlagen, Verzeichnis nicht beschreibbar
|
||||
curDir[0] = 0;
|
||||
GetTempPathA(MaxPathSize, curDir);
|
||||
@@ -186,14 +184,15 @@ CleanerConfig::CleanerConfig()
|
||||
if(!doc.LoadFile()) {
|
||||
myConfigState = NONEXISTING;
|
||||
updateConfig(myConfigState);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//Check if config revision is ok. Otherwise --> update()
|
||||
int tempRevision = 0;
|
||||
|
||||
TiXmlHandle docHandle( &doc );
|
||||
TiXmlElement* confRevision = docHandle.FirstChild( "PokerTHCleaner" ).FirstChild( "Configuration" ).FirstChild( "ConfigRevision" ).ToElement();
|
||||
if ( confRevision ) { confRevision->QueryIntAttribute("value", &tempRevision ); }
|
||||
if ( confRevision ) {
|
||||
confRevision->QueryIntAttribute("value", &tempRevision );
|
||||
}
|
||||
|
||||
if (tempRevision < configRev ) { /*löschen()*/
|
||||
myConfigState = OLD;
|
||||
@@ -211,7 +210,8 @@ CleanerConfig::~CleanerConfig()
|
||||
}
|
||||
|
||||
|
||||
void CleanerConfig::fillBuffer() {
|
||||
void CleanerConfig::fillBuffer()
|
||||
{
|
||||
|
||||
string tempString1("");
|
||||
string tempString2("");
|
||||
@@ -247,13 +247,15 @@ void CleanerConfig::fillBuffer() {
|
||||
configBufferList[i].defaultListValue = tempStringList2;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qDebug("Could not find the root element in the config file!");
|
||||
}
|
||||
else { qDebug("Could not find the root element in the config file!"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CleanerConfig::writeBuffer() const {
|
||||
void CleanerConfig::writeBuffer() const
|
||||
{
|
||||
|
||||
TiXmlDocument doc;
|
||||
TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", "");
|
||||
@@ -291,7 +293,8 @@ void CleanerConfig::writeBuffer() const {
|
||||
|
||||
}
|
||||
|
||||
void CleanerConfig::updateConfig(ConfigState myConfigState) {
|
||||
void CleanerConfig::updateConfig(ConfigState myConfigState)
|
||||
{
|
||||
|
||||
size_t i;
|
||||
|
||||
@@ -406,8 +409,7 @@ void CleanerConfig::updateConfig(ConfigState myConfigState) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// if element is not there --> set it with defaultValue
|
||||
TiXmlElement *tmpElement = new TiXmlElement(configList[i].name);
|
||||
config->LinkEndChild( tmpElement );
|
||||
@@ -428,8 +430,9 @@ void CleanerConfig::updateConfig(ConfigState myConfigState) {
|
||||
}
|
||||
}
|
||||
newDoc.SaveFile( configFileName );
|
||||
} else {
|
||||
qDebug("Cannot update config file: Unable to load configuration.");
|
||||
}
|
||||
else { qDebug("Cannot update config file: Unable to load configuration."); }
|
||||
|
||||
|
||||
}
|
||||
@@ -582,11 +585,14 @@ void CleanerConfig::writeConfigString(string varName, string varCont)
|
||||
|
||||
size_t i;
|
||||
for (i=0; i<configBufferList.size(); i++) {
|
||||
if (configBufferList[i].name == varName) { configBufferList[i].defaultValue = varCont; }
|
||||
if (configBufferList[i].name == varName) {
|
||||
configBufferList[i].defaultValue = varCont;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
std::string CleanerConfig::stringToUtf8(const std::string &myString) {
|
||||
std::string CleanerConfig::stringToUtf8(const std::string &myString)
|
||||
{
|
||||
|
||||
QString tmpString = QString::fromStdString(myString);
|
||||
std::string myUtf8String = tmpString.toUtf8().constData();
|
||||
@@ -594,10 +600,14 @@ std::string CleanerConfig::stringToUtf8(const std::string &myString) {
|
||||
return myUtf8String;
|
||||
}
|
||||
|
||||
std::string CleanerConfig::stringFromUtf8(const std::string &myString) {
|
||||
std::string CleanerConfig::stringFromUtf8(const std::string &myString)
|
||||
{
|
||||
QString tmpString = QString::fromUtf8(myString.c_str());
|
||||
|
||||
return tmpString.toStdString();
|
||||
}
|
||||
|
||||
std::string CleanerConfig::getDefaultLanguage() { return QLocale::system().name().toStdString(); }
|
||||
std::string CleanerConfig::getDefaultLanguage()
|
||||
{
|
||||
return QLocale::system().name().toStdString();
|
||||
}
|
||||
|
||||
@@ -28,13 +28,16 @@ enum ConfigState { NONEXISTING, OLD };
|
||||
enum ConfigType { CONFIG_TYPE_INT, CONFIG_TYPE_STRING, CONFIG_TYPE_INT_LIST, CONFIG_TYPE_STRING_LIST };
|
||||
|
||||
|
||||
class CleanerConfig{
|
||||
class CleanerConfig
|
||||
{
|
||||
public:
|
||||
CleanerConfig();
|
||||
|
||||
~CleanerConfig();
|
||||
|
||||
std::string getConfigFileName() const { return configFileName; }
|
||||
std::string getConfigFileName() const {
|
||||
return configFileName;
|
||||
}
|
||||
|
||||
void fillBuffer();
|
||||
void writeBuffer() const;
|
||||
@@ -57,8 +60,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
struct ConfigInfo
|
||||
{
|
||||
struct ConfigInfo {
|
||||
ConfigInfo(const std::string &n, ConfigType t, const std::string &d, const std::list<std::string> &l =std::list<std::string>()) : name(n), type(t), defaultValue(d), defaultListValue(l) {}
|
||||
std::string name;
|
||||
ConfigType type;
|
||||
|
||||
@@ -59,24 +59,19 @@ void CleanerServer::onRead()
|
||||
{
|
||||
qint64 bytesRead = tcpSocket->read((char *)m_recvBuf + m_recvBufUsed, sizeof(m_recvBuf) - m_recvBufUsed);
|
||||
bool error = bytesRead < 1;
|
||||
if (!error)
|
||||
{
|
||||
if (!error) {
|
||||
m_recvBufUsed += bytesRead;
|
||||
|
||||
asn_dec_rval_t retVal;
|
||||
do
|
||||
{
|
||||
do {
|
||||
// Try to decode the packets.
|
||||
InternalChatCleanerPacket recvMsg;
|
||||
retVal = ber_decode(0, &asn_DEF_ChatCleanerMessage, (void **)recvMsg.GetMsgPtr(), m_recvBuf, m_recvBufUsed);
|
||||
if(retVal.code == RC_OK)
|
||||
{
|
||||
if (retVal.consumed < m_recvBufUsed)
|
||||
{
|
||||
if(retVal.code == RC_OK) {
|
||||
if (retVal.consumed < m_recvBufUsed) {
|
||||
m_recvBufUsed -= retVal.consumed;
|
||||
memmove(m_recvBuf, m_recvBuf + retVal.consumed, m_recvBufUsed);
|
||||
}
|
||||
else
|
||||
} else
|
||||
m_recvBufUsed = 0;
|
||||
|
||||
// Handle the packets.
|
||||
@@ -85,8 +80,7 @@ void CleanerServer::onRead()
|
||||
} while (!error && retVal.code == RC_OK);
|
||||
}
|
||||
|
||||
if (error)
|
||||
{
|
||||
if (error) {
|
||||
qDebug() << "Error handling packets from client.";
|
||||
tcpSocket->close();
|
||||
}
|
||||
@@ -104,16 +98,14 @@ void CleanerServer::onRead()
|
||||
tcpSocket->write(checkMessage.toAscii().data(), checkMessage.length());*/
|
||||
}
|
||||
|
||||
bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) {
|
||||
bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg)
|
||||
{
|
||||
bool error = true;
|
||||
if (msg.GetMsg()->present == ChatCleanerMessage_PR_cleanerInitMessage)
|
||||
{
|
||||
if (msg.GetMsg()->present == ChatCleanerMessage_PR_cleanerInitMessage) {
|
||||
CleanerInitMessage_t *netInit = &msg.GetMsg()->choice.cleanerInitMessage;
|
||||
if (netInit->requestedVersion == CLEANER_PROTOCOL_VERSION)
|
||||
{
|
||||
if (netInit->requestedVersion == CLEANER_PROTOCOL_VERSION) {
|
||||
string tmpClientSecret((const char *)netInit->clientSecret.buf, netInit->clientSecret.size);
|
||||
if (clientSecret == QString::fromStdString(tmpClientSecret))
|
||||
{
|
||||
if (clientSecret == QString::fromStdString(tmpClientSecret)) {
|
||||
error = false;
|
||||
|
||||
InternalChatCleanerPacket tmpAck;
|
||||
@@ -125,15 +117,11 @@ bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) {
|
||||
tmpServerSecret.c_str(),
|
||||
tmpServerSecret.length());
|
||||
sendMessageToClient(tmpAck);
|
||||
}
|
||||
else
|
||||
} else
|
||||
qDebug() << "Invalid client secret.";
|
||||
}
|
||||
else
|
||||
} else
|
||||
qDebug() << "Invalid client version: " << netInit->requestedVersion;
|
||||
}
|
||||
else if (msg.GetMsg()->present == ChatCleanerMessage_PR_cleanerChatRequestMessage)
|
||||
{
|
||||
} else if (msg.GetMsg()->present == ChatCleanerMessage_PR_cleanerChatRequestMessage) {
|
||||
error = false;
|
||||
CleanerChatRequestMessage_t *netRequest = &msg.GetMsg()->choice.cleanerChatRequestMessage;
|
||||
unsigned playerId = netRequest->playerId;
|
||||
@@ -145,8 +133,7 @@ bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) {
|
||||
QString checkAction = checkreturn.at(0);
|
||||
QString checkMessage = checkreturn.at(1);
|
||||
|
||||
if (!checkAction.isEmpty())
|
||||
{
|
||||
if (!checkAction.isEmpty()) {
|
||||
InternalChatCleanerPacket tmpReply;
|
||||
tmpReply.GetMsg()->present = ChatCleanerMessage_PR_cleanerChatReplyMessage;
|
||||
CleanerChatReplyMessage_t *netReply = &tmpReply.GetMsg()->choice.cleanerChatReplyMessage;
|
||||
@@ -156,11 +143,9 @@ bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) {
|
||||
|
||||
if(checkAction == "warn") {
|
||||
netReply->cleanerActionType = cleanerActionType_cleanerActionWarning;
|
||||
}
|
||||
else if(checkAction == "kick") {
|
||||
} else if(checkAction == "kick") {
|
||||
netReply->cleanerActionType = cleanerActionType_cleanerActionKick;
|
||||
}
|
||||
else if(checkAction == "kickban") {
|
||||
} else if(checkAction == "kickban") {
|
||||
netReply->cleanerActionType = cleanerActionType_cleanerActionBan;
|
||||
}
|
||||
|
||||
@@ -176,13 +161,15 @@ bool CleanerServer::handleMessage(InternalChatCleanerPacket &msg) {
|
||||
return error;
|
||||
}
|
||||
|
||||
void CleanerServer::socketStateChanged(QAbstractSocket::SocketState state) {
|
||||
void CleanerServer::socketStateChanged(QAbstractSocket::SocketState state)
|
||||
{
|
||||
|
||||
qDebug() << "Socket state changed to: " << QAbstractSocket::UnconnectedState;
|
||||
if(state == QAbstractSocket::UnconnectedState) blockConnection = false;
|
||||
}
|
||||
|
||||
void CleanerServer::refreshConfig() {
|
||||
void CleanerServer::refreshConfig()
|
||||
{
|
||||
|
||||
QFileInfo configFileInfo(QString::fromUtf8(config->getConfigFileName().c_str()));
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
class MessageFilter;
|
||||
class CleanerConfig;
|
||||
|
||||
class CleanerServer: public QObject {
|
||||
class CleanerServer: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
@@ -14,12 +14,10 @@ bool LetterRepeatingCheck::run(QString msg)
|
||||
if(e.isValid()) {
|
||||
if(e.exactMatch(msg)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// qDebug() << "The current Letter Repeating RegExp is invalid" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3,12 +3,15 @@
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
class LetterRepeatingCheck: public QObject {
|
||||
class LetterRepeatingCheck: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LetterRepeatingCheck();
|
||||
|
||||
void setLetterNumberToTrigger(int n) { letterNumberToTrigger = n; }
|
||||
void setLetterNumberToTrigger(int n) {
|
||||
letterNumberToTrigger = n;
|
||||
}
|
||||
bool run(QString);
|
||||
|
||||
private:
|
||||
|
||||
@@ -38,7 +38,8 @@ MessageFilter::MessageFilter(CleanerConfig *c): config(c)
|
||||
cleanTimer->start(30000);
|
||||
}
|
||||
|
||||
MessageFilter::~MessageFilter() {
|
||||
MessageFilter::~MessageFilter()
|
||||
{
|
||||
|
||||
delete myBadWordCheck;
|
||||
delete myTextFloodCheck;
|
||||
@@ -74,8 +75,7 @@ QStringList MessageFilter::check(unsigned playerId, QString nick, QString msg)
|
||||
tmpInfos.nick = nick;
|
||||
myClientWarnLevelList.insert(playerId, tmpInfos);
|
||||
action = WARN;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(i.value().warnLevel == warnLevelToKick || i.value().lastWarnType == offence) {
|
||||
// Kick Command
|
||||
action = KICK;
|
||||
@@ -90,23 +90,20 @@ QStringList MessageFilter::check(unsigned playerId, QString nick, QString msg)
|
||||
tmpInfos.kickNumber = 1;
|
||||
tmpInfos.lastKickTimestamp = timer.elapsed().total_seconds();
|
||||
myClientKickCounterList.insert(nick, tmpInfos);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//pleayer is already on the list: either raise kickNumber or kickban when kickNumerToBan is reached
|
||||
if(j.value().kickNumber == kickNumberToBan) {
|
||||
action = KICKBAN;
|
||||
//remove player from kickCounterList
|
||||
myClientKickCounterList.remove(j.key());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ClientKickInfos tmpInfos;
|
||||
tmpInfos.kickNumber = j.value().kickNumber+1;
|
||||
tmpInfos.lastKickTimestamp = timer.elapsed().total_seconds();
|
||||
myClientKickCounterList.insert(nick, tmpInfos);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ClientWarnInfos tmpInfos;
|
||||
tmpInfos.warnLevel = i.value().warnLevel+1;
|
||||
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);
|
||||
}
|
||||
break;
|
||||
default:;
|
||||
default:
|
||||
;
|
||||
}
|
||||
returnAction = QString("warn");
|
||||
}
|
||||
else if(action == KICK) {
|
||||
} else if(action == KICK) {
|
||||
returnMessage = QString("%1 kicked! Please respect: http://chatrules.pokerth.net\n").arg(nick);
|
||||
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);
|
||||
returnAction = QString("kickban");
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
returnAction = QString("");
|
||||
returnMessage = QString("");
|
||||
}
|
||||
@@ -161,7 +156,8 @@ QStringList MessageFilter::check(unsigned playerId, QString nick, QString msg)
|
||||
return returnList;
|
||||
}
|
||||
|
||||
void MessageFilter::refreshConfig() {
|
||||
void MessageFilter::refreshConfig()
|
||||
{
|
||||
|
||||
// global settings
|
||||
warnLevelToKick = config->readConfigInt("WarnLevelToKick");
|
||||
|
||||
@@ -12,7 +12,8 @@ class CapsFloodCheck;
|
||||
class LetterRepeatingCheck;
|
||||
class UrlCheck;
|
||||
|
||||
class MessageFilter: public QObject {
|
||||
class MessageFilter: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MessageFilter(CleanerConfig*);
|
||||
|
||||
@@ -19,7 +19,8 @@ TextFloodCheck::~TextFloodCheck()
|
||||
delete cleanTimer;
|
||||
}
|
||||
|
||||
bool TextFloodCheck::run(unsigned playerId) {
|
||||
bool TextFloodCheck::run(unsigned playerId)
|
||||
{
|
||||
|
||||
QMapIterator<unsigned, TextFloodInfos> it(msgTimesList);
|
||||
while (it.hasNext()) {
|
||||
@@ -35,8 +36,7 @@ bool TextFloodCheck::run(unsigned playerId) {
|
||||
tmpInfos1.timeStamp = timer.elapsed().total_seconds();
|
||||
msgTimesList.insert(playerId, tmpInfos1);
|
||||
qDebug () << "Add Player: set player floodlevel to " << tmpInfos1.floodLevel;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
TextFloodInfos tmpInfos2;
|
||||
if(timer.elapsed().total_seconds()-i.value().timeStamp <= 1) {
|
||||
if(i.value().floodLevel == textFloodLevelToTrigger) {
|
||||
@@ -46,13 +46,11 @@ bool TextFloodCheck::run(unsigned playerId) {
|
||||
qDebug () << "Trigger: set player floodlevel to " << tmpInfos3.floodLevel;
|
||||
msgTimesList.insert(playerId, tmpInfos3);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
tmpInfos2.floodLevel = i.value().floodLevel+1;
|
||||
qDebug () << "Raise: set player floodlevel to " << tmpInfos2.floodLevel << " from " << i.value().floodLevel;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
tmpInfos2.floodLevel = 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;
|
||||
}
|
||||
|
||||
void TextFloodCheck::cleanMsgTimesList() {
|
||||
void TextFloodCheck::cleanMsgTimesList()
|
||||
{
|
||||
|
||||
QMapIterator<unsigned, TextFloodInfos> it(msgTimesList);
|
||||
while (it.hasNext()) {
|
||||
@@ -73,8 +72,7 @@ void TextFloodCheck::cleanMsgTimesList() {
|
||||
if(it.value().floodLevel == 0) {
|
||||
msgTimesList.remove(it.key());
|
||||
qDebug () << "Refresh: player removed from List";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
TextFloodInfos tmpInfos;
|
||||
tmpInfos.floodLevel = it.value().floodLevel-1;
|
||||
tmpInfos.timeStamp = it.value().timeStamp;
|
||||
@@ -86,7 +84,8 @@ void TextFloodCheck::cleanMsgTimesList() {
|
||||
}
|
||||
}
|
||||
|
||||
void TextFloodCheck::removeNickFromList(unsigned playerId) {
|
||||
void TextFloodCheck::removeNickFromList(unsigned playerId)
|
||||
{
|
||||
|
||||
// qDebug() << "id " << playerId << "removed from textfloodcheck list" << endl;
|
||||
msgTimesList.remove(playerId);
|
||||
|
||||
@@ -13,7 +13,9 @@ public:
|
||||
TextFloodCheck();
|
||||
~TextFloodCheck();
|
||||
|
||||
void setTextFloodLevelToTrigger(int level) { textFloodLevelToTrigger = level; }
|
||||
void setTextFloodLevelToTrigger(int level) {
|
||||
textFloodLevelToTrigger = level;
|
||||
}
|
||||
|
||||
bool run(unsigned);
|
||||
|
||||
|
||||
@@ -22,7 +22,9 @@ bool UrlCheck::run(QString msg)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!exception) { return true; }
|
||||
if(!exception) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -3,13 +3,18 @@
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
class UrlCheck: public QObject {
|
||||
class UrlCheck: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UrlCheck();
|
||||
|
||||
void setUrlStrings(QStringList us) { urlStrings = us; }
|
||||
void setUrlExceptionStrings(QStringList ues) { urlExceptionStrings = ues; }
|
||||
void setUrlStrings(QStringList us) {
|
||||
urlStrings = us;
|
||||
}
|
||||
void setUrlExceptionStrings(QStringList ues) {
|
||||
urlExceptionStrings = ues;
|
||||
}
|
||||
bool run(QString);
|
||||
|
||||
private:
|
||||
|
||||
+23
-16
@@ -60,8 +60,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
|
||||
const char *appDataPath = getenv("AppData");
|
||||
if (appDataPath && appDataPath[0] != 0) {
|
||||
configFileName = appDataPath;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
const int MaxPathSize = 1024;
|
||||
char curDir[MaxPathSize + 1];
|
||||
curDir[0] = 0;
|
||||
@@ -77,8 +76,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
|
||||
// Datei wieder loeschen.
|
||||
tmpFile.close();
|
||||
remove((configFileName + "\\" + tmpFileName).c_str());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Fehlgeschlagen, Verzeichnis nicht beschreibbar
|
||||
curDir[0] = 0;
|
||||
GetTempPathA(MaxPathSize, curDir);
|
||||
@@ -301,15 +299,16 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
|
||||
if(!doc.LoadFile()) {
|
||||
myConfigState = NONEXISTING;
|
||||
updateConfig(myConfigState);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//Check if config revision and AppDataDir is ok. Otherwise --> update()
|
||||
int tempRevision = 0;
|
||||
string tempAppDataPath ("");
|
||||
|
||||
TiXmlHandle docHandle( &doc );
|
||||
TiXmlElement* confRevision = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( "ConfigRevision" ).ToElement();
|
||||
if ( confRevision ) { confRevision->QueryIntAttribute("value", &tempRevision ); }
|
||||
if ( confRevision ) {
|
||||
confRevision->QueryIntAttribute("value", &tempRevision );
|
||||
}
|
||||
TiXmlElement* confAppDataPath = docHandle.FirstChild( "PokerTH" ).FirstChild( "Configuration" ).FirstChild( "AppDataDir" ).ToElement();
|
||||
if ( confAppDataPath ) {
|
||||
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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigFile::writeBuffer() const {
|
||||
void ConfigFile::writeBuffer() const
|
||||
{
|
||||
|
||||
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);
|
||||
|
||||
@@ -554,8 +557,7 @@ void ConfigFile::updateConfig(ConfigState myConfigState) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// if element is not there --> set it with defaultValue
|
||||
TiXmlElement *tmpElement = new TiXmlElement(configList[i].name);
|
||||
config->LinkEndChild( tmpElement );
|
||||
@@ -576,8 +578,9 @@ void ConfigFile::updateConfig(ConfigState myConfigState) {
|
||||
}
|
||||
}
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ enum ConfigType { CONFIG_TYPE_INT, CONFIG_TYPE_STRING, CONFIG_TYPE_INT_LIST, CON
|
||||
|
||||
class QtToolsInterface;
|
||||
|
||||
class ConfigFile{
|
||||
class ConfigFile
|
||||
{
|
||||
public:
|
||||
ConfigFile(char *argv0, bool readonly);
|
||||
|
||||
@@ -40,7 +41,9 @@ public:
|
||||
void writeBuffer() const;
|
||||
|
||||
void updateConfig(ConfigState);
|
||||
ConfigState getConfigState() const { return myConfigState; }
|
||||
ConfigState getConfigState() const {
|
||||
return myConfigState;
|
||||
}
|
||||
|
||||
std::string readConfigString(std::string varName) const;
|
||||
std::list<std::string> readConfigStringList(std::string varName) const;
|
||||
@@ -56,8 +59,7 @@ private:
|
||||
|
||||
mutable boost::recursive_mutex m_configMutex;
|
||||
|
||||
struct ConfigInfo
|
||||
{
|
||||
struct ConfigInfo {
|
||||
ConfigInfo(const std::string &n, ConfigType t, const std::string &d, const std::list<std::string> &l =std::list<std::string>()) : name(n), type(t), defaultValue(d), defaultListValue(l) {}
|
||||
std::string name;
|
||||
ConfigType type;
|
||||
|
||||
+39
-85
@@ -56,23 +56,16 @@ PokerTHMessage_t *
|
||||
receiveMessage(tcp::socket &socket)
|
||||
{
|
||||
PokerTHMessage_t *msg = NULL;
|
||||
do
|
||||
{
|
||||
do {
|
||||
asn_dec_rval_t retVal = ber_decode(0, &asn_DEF_PokerTHMessage, (void **)&msg, recBuf.data(), recBufPos);
|
||||
if(retVal.code == RC_OK && msg != NULL)
|
||||
{
|
||||
if (retVal.consumed < recBufPos)
|
||||
{
|
||||
if(retVal.code == RC_OK && msg != NULL) {
|
||||
if (retVal.consumed < recBufPos) {
|
||||
recBufPos -= retVal.consumed;
|
||||
memmove(recBuf.c_array(), recBuf.c_array() + retVal.consumed, recBufPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
recBufPos = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Free the partially decoded message (if applicable).
|
||||
ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg);
|
||||
msg = NULL;
|
||||
@@ -86,11 +79,9 @@ bool
|
||||
sendMessage(tcp::socket &socket, PokerTHMessage_t *msg)
|
||||
{
|
||||
bool retVal = false;
|
||||
if (msg)
|
||||
{
|
||||
if (msg) {
|
||||
asn_enc_rval_t e = der_encode_to_buffer(&asn_DEF_PokerTHMessage, msg, sendBuf.data(), BUF_SIZE);
|
||||
if (e.encoded != -1)
|
||||
{
|
||||
if (e.encoded != -1) {
|
||||
socket.send(boost::asio::buffer(sendBuf.data(), e.encoded));
|
||||
retVal = true;
|
||||
}
|
||||
@@ -102,8 +93,7 @@ sendMessage(tcp::socket &socket, PokerTHMessage_t *msg)
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
// Check command line options.
|
||||
po::options_description desc("Allowed options");
|
||||
desc.add_options()
|
||||
@@ -119,13 +109,11 @@ main(int argc, char *argv[])
|
||||
po::store(po::parse_command_line(argc, argv, desc), vm);
|
||||
po::notify(vm);
|
||||
|
||||
if (vm.count("help"))
|
||||
{
|
||||
if (vm.count("help")) {
|
||||
cout << desc << endl;
|
||||
return 1;
|
||||
}
|
||||
if (!vm.count("server") || !vm.count("port") || !vm.count("mode") || !vm.count("username"))
|
||||
{
|
||||
if (!vm.count("server") || !vm.count("port") || !vm.count("mode") || !vm.count("username")) {
|
||||
cout << "Missing option!" << endl << desc << endl;
|
||||
return 1;
|
||||
}
|
||||
@@ -135,22 +123,19 @@ main(int argc, char *argv[])
|
||||
int mode = vm["mode"].as<int>();
|
||||
string username(vm["username"].as<string>());
|
||||
string password;
|
||||
if (vm.count("password"))
|
||||
{
|
||||
if (vm.count("password")) {
|
||||
password = vm["password"].as<string>();
|
||||
}
|
||||
// Initialise gsasl.
|
||||
Gsasl *authContext;
|
||||
Gsasl_session *authSession;
|
||||
int res = gsasl_init(&authContext);
|
||||
if (res != GSASL_OK)
|
||||
{
|
||||
if (res != GSASL_OK) {
|
||||
cout << "gsasl init failed" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!gsasl_client_support_p(authContext, "SCRAM-SHA-1"))
|
||||
{
|
||||
if (!gsasl_client_support_p(authContext, "SCRAM-SHA-1")) {
|
||||
gsasl_done(authContext);
|
||||
cout << "This version of gsasl does not support SCRAM-SHA-1" << endl;
|
||||
return 1;
|
||||
@@ -165,26 +150,22 @@ main(int argc, char *argv[])
|
||||
tcp::resolver::iterator end;
|
||||
tcp::socket socket(io_service);
|
||||
boost::system::error_code error = boost::asio::error::host_not_found;
|
||||
while (error && endpoint_iterator != end)
|
||||
{
|
||||
while (error && endpoint_iterator != end) {
|
||||
socket.close();
|
||||
socket.connect(*endpoint_iterator++, error);
|
||||
}
|
||||
if (error)
|
||||
{
|
||||
if (error) {
|
||||
cout << "Connect failed" << endl;
|
||||
return 1;
|
||||
}
|
||||
if (mode == 1)
|
||||
{
|
||||
if (mode == 1) {
|
||||
cout << "Connect.value " << perfTimer.elapsed().total_milliseconds() << endl;
|
||||
}
|
||||
perfTimer.restart();
|
||||
|
||||
// Receive server information
|
||||
PokerTHMessage_t *msg = receiveMessage(socket);
|
||||
if (!msg || msg->present != PokerTHMessage_PR_announceMessage)
|
||||
{
|
||||
if (!msg || msg->present != PokerTHMessage_PR_announceMessage) {
|
||||
cout << "Announce failed" << endl;
|
||||
return 1;
|
||||
}
|
||||
@@ -196,24 +177,19 @@ main(int argc, char *argv[])
|
||||
InitMessage_t *netInit = &msg->choice.initMessage;
|
||||
netInit->requestedVersion.major = 1;
|
||||
netInit->requestedVersion.minor = 0;
|
||||
if (password.empty())
|
||||
{
|
||||
if (password.empty()) {
|
||||
netInit->login.present = login_PR_guestLogin;
|
||||
GuestLogin_t *guestLogin = &netInit->login.choice.guestLogin;
|
||||
OCTET_STRING_fromBuf(&guestLogin->nickName,
|
||||
username.c_str(),
|
||||
username.length());
|
||||
if (!sendMessage(socket, msg))
|
||||
{
|
||||
if (!sendMessage(socket, msg)) {
|
||||
cout << "Init guest failed" << endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
int errorCode = gsasl_client_start(authContext, "SCRAM-SHA-1", &authSession);
|
||||
if (errorCode == GSASL_OK)
|
||||
{
|
||||
if (errorCode == GSASL_OK) {
|
||||
gsasl_property_set(authSession, GSASL_AUTHID, username.c_str());
|
||||
gsasl_property_set(authSession, GSASL_PASSWORD, password.c_str());
|
||||
|
||||
@@ -224,12 +200,9 @@ main(int argc, char *argv[])
|
||||
size_t tmpOutSize;
|
||||
string nextGsaslMsg;
|
||||
errorCode = gsasl_step(authSession, NULL, 0, &tmpOut, &tmpOutSize);
|
||||
if (errorCode == GSASL_NEEDS_MORE)
|
||||
{
|
||||
if (errorCode == GSASL_NEEDS_MORE) {
|
||||
nextGsaslMsg = string(tmpOut, tmpOutSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cout << "gsasl step 1 failed" << endl;
|
||||
return 1;
|
||||
}
|
||||
@@ -238,15 +211,13 @@ main(int argc, char *argv[])
|
||||
OCTET_STRING_fromBuf(&authLogin->clientUserData,
|
||||
nextGsaslMsg.c_str(),
|
||||
nextGsaslMsg.length());
|
||||
if (!sendMessage(socket, msg))
|
||||
{
|
||||
if (!sendMessage(socket, msg)) {
|
||||
cout << "Init auth request failed" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
msg = receiveMessage(socket);
|
||||
if (!msg || msg->present != PokerTHMessage_PR_authMessage)
|
||||
{
|
||||
if (!msg || msg->present != PokerTHMessage_PR_authMessage) {
|
||||
cout << "Auth request failed" << endl;
|
||||
return 1;
|
||||
}
|
||||
@@ -255,12 +226,9 @@ main(int argc, char *argv[])
|
||||
AuthServerChallenge_t *netChallenge = &netAuth->choice.authServerChallenge;
|
||||
string challengeStr = STL_STRING_FROM_OCTET_STRING(netChallenge->serverChallenge);
|
||||
errorCode = gsasl_step(authSession, challengeStr.c_str(), challengeStr.size(), &tmpOut, &tmpOutSize);
|
||||
if (errorCode == GSASL_NEEDS_MORE)
|
||||
{
|
||||
if (errorCode == GSASL_NEEDS_MORE) {
|
||||
nextGsaslMsg = string(tmpOut, tmpOutSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cout << "gsasl step 2 failed" << endl;
|
||||
return 1;
|
||||
}
|
||||
@@ -275,14 +243,12 @@ main(int argc, char *argv[])
|
||||
OCTET_STRING_fromBuf(&outResponse->clientResponse,
|
||||
nextGsaslMsg.c_str(),
|
||||
nextGsaslMsg.length());
|
||||
if (!sendMessage(socket, msg))
|
||||
{
|
||||
if (!sendMessage(socket, msg)) {
|
||||
cout << "Init auth response failed" << endl;
|
||||
return 1;
|
||||
}
|
||||
msg = receiveMessage(socket);
|
||||
if (!msg || msg->present != PokerTHMessage_PR_authMessage)
|
||||
{
|
||||
if (!msg || msg->present != PokerTHMessage_PR_authMessage) {
|
||||
cout << "Auth response failed" << endl;
|
||||
return 1;
|
||||
}
|
||||
@@ -291,15 +257,13 @@ main(int argc, char *argv[])
|
||||
|
||||
// Receive init ack
|
||||
msg = receiveMessage(socket);
|
||||
if (!msg || msg->present != PokerTHMessage_PR_initAckMessage)
|
||||
{
|
||||
if (!msg || msg->present != PokerTHMessage_PR_initAckMessage) {
|
||||
cout << "Init ack failed" << endl;
|
||||
return 1;
|
||||
}
|
||||
ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg);
|
||||
|
||||
if (mode == 1)
|
||||
{
|
||||
if (mode == 1) {
|
||||
cout << "Init.value " << perfTimer.elapsed().total_milliseconds() << endl;
|
||||
}
|
||||
perfTimer.restart();
|
||||
@@ -330,48 +294,38 @@ main(int argc, char *argv[])
|
||||
OCTET_STRING_fromBuf(&joinNew->gameInfo.gameName,
|
||||
tmpGameName.c_str(),
|
||||
tmpGameName.length());
|
||||
if (!sendMessage(socket, msg))
|
||||
{
|
||||
if (!sendMessage(socket, msg)) {
|
||||
cout << "Create game failed" << endl;
|
||||
return 1;
|
||||
}
|
||||
msg = NULL;
|
||||
// Receive join game ack
|
||||
do
|
||||
{
|
||||
do {
|
||||
ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg);
|
||||
msg = receiveMessage(socket);
|
||||
if (!msg)
|
||||
{
|
||||
if (!msg) {
|
||||
cout << "Receive in lobby failed" << endl;
|
||||
return 1;
|
||||
}
|
||||
if (msg->present == PokerTHMessage_PR_errorMessage)
|
||||
{
|
||||
if (msg->present == PokerTHMessage_PR_errorMessage) {
|
||||
cout << "Received error" << endl;
|
||||
return 1;
|
||||
}
|
||||
} while (msg->present != PokerTHMessage_PR_joinGameReplyMessage);
|
||||
if (msg->choice.joinGameReplyMessage.joinGameResult.present != joinGameResult_PR_joinGameAck)
|
||||
{
|
||||
if (msg->choice.joinGameReplyMessage.joinGameResult.present != joinGameResult_PR_joinGameAck) {
|
||||
cout << "Join game ack failed" << endl;
|
||||
return 1;
|
||||
}
|
||||
ASN_STRUCT_FREE(asn_DEF_PokerTHMessage, msg);
|
||||
|
||||
if (mode == 1)
|
||||
{
|
||||
if (mode == 1) {
|
||||
cout << "CreateGame.value " << perfTimer.elapsed().total_milliseconds() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cout << "Success" << endl;
|
||||
}
|
||||
perfTimer.restart();
|
||||
gsasl_done(authContext);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
} catch (...) {
|
||||
cout << "Exception caught" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -48,8 +48,7 @@
|
||||
using namespace std;
|
||||
using namespace boost::filesystem;
|
||||
|
||||
struct AvatarFileState
|
||||
{
|
||||
struct AvatarFileState {
|
||||
ifstream inputStream;
|
||||
};
|
||||
|
||||
@@ -87,8 +86,7 @@ AvatarManager::Init(const string &dataDir, const string &cacheDir)
|
||||
}
|
||||
if (cacheDir.empty() || tmpCachePath.empty())
|
||||
LOG_ERROR("Cache directory was not set!");
|
||||
else
|
||||
{
|
||||
else {
|
||||
boost::mutex::scoped_lock lock(m_cachedAvatarsMutex);
|
||||
tmpRet = InternalReadDirectory(tmpCachePath.directory_string(), m_cachedAvatars);
|
||||
retVal = retVal && tmpRet;
|
||||
@@ -105,20 +103,17 @@ AvatarManager::AddSingleAvatar(const std::string &fileName)
|
||||
path filePath(fileName);
|
||||
string tmpFileName(filePath.file_string());
|
||||
|
||||
if (!fileName.empty() && !tmpFileName.empty())
|
||||
{
|
||||
if (!fileName.empty() && !tmpFileName.empty()) {
|
||||
unsigned outFileSize = 0;
|
||||
AvatarFileType outFileType;
|
||||
boost::shared_ptr<AvatarFileState> tmpFileState = OpenAvatarFileForChunkRead(tmpFileName, outFileSize, outFileType);
|
||||
|
||||
// Check whether the avatar file is valid.
|
||||
if (tmpFileState.get())
|
||||
{
|
||||
if (tmpFileState.get()) {
|
||||
tmpFileState.reset();
|
||||
|
||||
MD5Buf md5buf;
|
||||
if (CryptHelper::MD5Sum(tmpFileName, md5buf))
|
||||
{
|
||||
if (CryptHelper::MD5Sum(tmpFileName, md5buf)) {
|
||||
boost::mutex::scoped_lock lock(m_avatarsMutex);
|
||||
m_avatars.insert(AvatarMap::value_type(md5buf, tmpFileName));
|
||||
retVal = true;
|
||||
@@ -133,13 +128,11 @@ AvatarManager::OpenAvatarFileForChunkRead(const std::string &fileName, unsigned
|
||||
{
|
||||
outFileSize = 0;
|
||||
boost::shared_ptr<AvatarFileState> retVal;
|
||||
try
|
||||
{
|
||||
try {
|
||||
outFileType = GetAvatarFileType(fileName);
|
||||
boost::shared_ptr<AvatarFileState> fileState(new AvatarFileState);
|
||||
fileState->inputStream.open(fileName.c_str(), ios_base::in | ios_base::binary);
|
||||
if (!fileState->inputStream.fail())
|
||||
{
|
||||
if (!fileState->inputStream.fail()) {
|
||||
// Find out file size.
|
||||
// Not fully portable, but works on win/linux/mac.
|
||||
fileState->inputStream.seekg(0, ios_base::beg);
|
||||
@@ -149,8 +142,7 @@ AvatarManager::OpenAvatarFileForChunkRead(const std::string &fileName, unsigned
|
||||
fileState->inputStream.seekg(0, ios_base::beg);
|
||||
std::streamoff posDiff(endPos - startPos);
|
||||
outFileSize = (unsigned)posDiff;
|
||||
if (outFileSize >= MIN_AVATAR_FILE_SIZE && outFileSize <= MAX_AVATAR_FILE_SIZE)
|
||||
{
|
||||
if (outFileSize >= MIN_AVATAR_FILE_SIZE && outFileSize <= MAX_AVATAR_FILE_SIZE) {
|
||||
// Validate type of file by verifying image header.
|
||||
unsigned char fileHeader[MAX_HEADER_SIZE];
|
||||
fileState->inputStream.read((char *)fileHeader, sizeof(fileHeader));
|
||||
@@ -160,8 +152,7 @@ AvatarManager::OpenAvatarFileForChunkRead(const std::string &fileName, unsigned
|
||||
retVal = fileState;
|
||||
}
|
||||
}
|
||||
} catch (...)
|
||||
{
|
||||
} catch (...) {
|
||||
LOG_ERROR("Exception caught when trying to open avatar.");
|
||||
}
|
||||
return retVal;
|
||||
@@ -171,17 +162,13 @@ unsigned
|
||||
AvatarManager::ChunkReadAvatarFile(boost::shared_ptr<AvatarFileState> fileState, unsigned char *data, unsigned chunkSize)
|
||||
{
|
||||
unsigned retVal = 0;
|
||||
if (fileState.get())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!fileState->inputStream.fail() && !fileState->inputStream.eof())
|
||||
{
|
||||
if (fileState.get()) {
|
||||
try {
|
||||
if (!fileState->inputStream.fail() && !fileState->inputStream.eof()) {
|
||||
fileState->inputStream.read((char *)data, chunkSize);
|
||||
retVal = fileState->inputStream.gcount();
|
||||
}
|
||||
} catch (...)
|
||||
{
|
||||
} catch (...) {
|
||||
LOG_ERROR("Exception caught when trying to read avatar.");
|
||||
}
|
||||
}
|
||||
@@ -195,8 +182,7 @@ AvatarManager::AvatarFileToNetPackets(const string &fileName, unsigned requestId
|
||||
unsigned fileSize = 0;
|
||||
AvatarFileType fileType;
|
||||
boost::shared_ptr<AvatarFileState> tmpState = OpenAvatarFileForChunkRead(fileName, fileSize, fileType);
|
||||
if (tmpState.get() && fileSize && fileType != AVATAR_FILE_TYPE_UNKNOWN)
|
||||
{
|
||||
if (tmpState.get() && fileSize && fileType != AVATAR_FILE_TYPE_UNKNOWN) {
|
||||
boost::shared_ptr<NetPacket> avatarHeader(new NetPacket(NetPacket::Alloc));
|
||||
avatarHeader->GetMsg()->present = PokerTHMessage_PR_avatarReplyMessage;
|
||||
AvatarReplyMessage_t *netHeader = &avatarHeader->GetMsg()->choice.avatarReplyMessage;
|
||||
@@ -209,11 +195,9 @@ AvatarManager::AvatarFileToNetPackets(const string &fileName, unsigned requestId
|
||||
unsigned numBytes = 0;
|
||||
unsigned totalBytesRead = 0;
|
||||
vector<unsigned char> tmpData(MAX_FILE_DATA_SIZE);
|
||||
do
|
||||
{
|
||||
do {
|
||||
numBytes = ChunkReadAvatarFile(tmpState, &tmpData[0], MAX_FILE_DATA_SIZE);
|
||||
if (numBytes)
|
||||
{
|
||||
if (numBytes) {
|
||||
totalBytesRead += numBytes;
|
||||
|
||||
boost::shared_ptr<NetPacket> avatarFile(new NetPacket(NetPacket::Alloc));
|
||||
@@ -231,8 +215,7 @@ AvatarManager::AvatarFileToNetPackets(const string &fileName, unsigned requestId
|
||||
|
||||
if (fileSize != totalBytesRead)
|
||||
retVal = ERR_NET_WRONG_AVATAR_SIZE;
|
||||
else
|
||||
{
|
||||
else {
|
||||
boost::shared_ptr<NetPacket> avatarEnd(new NetPacket(NetPacket::Alloc));
|
||||
avatarEnd->GetMsg()->present = PokerTHMessage_PR_avatarReplyMessage;
|
||||
AvatarReplyMessage_t *netEnd = &avatarEnd->GetMsg()->choice.avatarReplyMessage;
|
||||
@@ -268,8 +251,7 @@ string
|
||||
AvatarManager::GetAvatarFileExtension(AvatarFileType fileType)
|
||||
{
|
||||
string ext;
|
||||
switch (fileType)
|
||||
{
|
||||
switch (fileType) {
|
||||
case AVATAR_FILE_TYPE_PNG:
|
||||
ext = ".png";
|
||||
break;
|
||||
@@ -289,17 +271,14 @@ bool
|
||||
AvatarManager::GetHashForAvatar(const std::string &fileName, MD5Buf &md5buf) const
|
||||
{
|
||||
bool found = false;
|
||||
if (exists(fileName))
|
||||
{
|
||||
if (exists(fileName)) {
|
||||
// Scan default avatars first.
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_avatarsMutex);
|
||||
AvatarMap::const_iterator i = m_avatars.begin();
|
||||
AvatarMap::const_iterator end = m_avatars.end();
|
||||
while (i != end)
|
||||
{
|
||||
if (i->second == fileName)
|
||||
{
|
||||
while (i != end) {
|
||||
if (i->second == fileName) {
|
||||
md5buf = i->first;
|
||||
found = true;
|
||||
break;
|
||||
@@ -308,15 +287,12 @@ AvatarManager::GetHashForAvatar(const std::string &fileName, MD5Buf &md5buf) con
|
||||
}
|
||||
}
|
||||
// Check cached avatars next.
|
||||
if (!found)
|
||||
{
|
||||
if (!found) {
|
||||
boost::mutex::scoped_lock lock(m_cachedAvatarsMutex);
|
||||
AvatarMap::const_iterator i = m_cachedAvatars.begin();
|
||||
AvatarMap::const_iterator end = m_cachedAvatars.end();
|
||||
while (i != end)
|
||||
{
|
||||
if (i->second == fileName)
|
||||
{
|
||||
while (i != end) {
|
||||
if (i->second == fileName) {
|
||||
md5buf = i->first;
|
||||
found = true;
|
||||
break;
|
||||
@@ -326,8 +302,7 @@ AvatarManager::GetHashForAvatar(const std::string &fileName, MD5Buf &md5buf) con
|
||||
}
|
||||
|
||||
// Calculate md5 sum if not found.
|
||||
if (!found)
|
||||
{
|
||||
if (!found) {
|
||||
if (CryptHelper::MD5Sum(fileName, md5buf))
|
||||
found = true;
|
||||
}
|
||||
@@ -342,18 +317,15 @@ AvatarManager::GetAvatarFileName(const MD5Buf &md5buf, std::string &fileName) co
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_avatarsMutex);
|
||||
AvatarMap::const_iterator pos = m_avatars.find(md5buf);
|
||||
if (pos != m_avatars.end())
|
||||
{
|
||||
if (pos != m_avatars.end()) {
|
||||
fileName = pos->second;
|
||||
retVal = true;
|
||||
}
|
||||
}
|
||||
if (!retVal)
|
||||
{
|
||||
if (!retVal) {
|
||||
boost::mutex::scoped_lock lock(m_cachedAvatarsMutex);
|
||||
AvatarMap::const_iterator pos = m_cachedAvatars.find(md5buf);
|
||||
if (pos != m_cachedAvatars.end())
|
||||
{
|
||||
if (pos != m_cachedAvatars.end()) {
|
||||
fileName = pos->second;
|
||||
retVal = true;
|
||||
}
|
||||
@@ -377,24 +349,19 @@ AvatarManager::StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFil
|
||||
boost::mutex::scoped_lock lock(m_cacheDirMutex);
|
||||
cacheDir = m_cacheDir;
|
||||
}
|
||||
try
|
||||
{
|
||||
try {
|
||||
string ext(GetAvatarFileExtension(avatarFileType));
|
||||
if (!ext.empty() && !cacheDir.empty())
|
||||
{
|
||||
if (!ext.empty() && !cacheDir.empty()) {
|
||||
// Check header before storing file.
|
||||
if (IsValidAvatarFileType(avatarFileType, data, size))
|
||||
{
|
||||
if (IsValidAvatarFileType(avatarFileType, data, size)) {
|
||||
path tmpPath(cacheDir);
|
||||
tmpPath /= (md5buf.ToString() + ext);
|
||||
string fileName(tmpPath.file_string());
|
||||
ofstream o(fileName.c_str(), ios_base::out | ios_base::binary | ios_base::trunc);
|
||||
if (!o.fail())
|
||||
{
|
||||
if (!o.fail()) {
|
||||
o.write((const char *)data, size);
|
||||
o.close();
|
||||
if (upload && m_useExternalServer)
|
||||
{
|
||||
if (upload && m_useExternalServer) {
|
||||
m_uploader->QueueUpload(m_externalServerAddress, m_externalServerUser, m_externalServerPassword, fileName, size);
|
||||
}
|
||||
|
||||
@@ -406,8 +373,7 @@ AvatarManager::StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFil
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (...)
|
||||
{
|
||||
} catch (...) {
|
||||
LOG_ERROR("Exception caught when trying to store avatar.");
|
||||
}
|
||||
return retVal;
|
||||
@@ -418,27 +384,23 @@ AvatarManager::IsValidAvatarFileType(AvatarFileType avatarFileType, const unsign
|
||||
{
|
||||
bool validType = false;
|
||||
|
||||
switch (avatarFileType)
|
||||
{
|
||||
switch (avatarFileType) {
|
||||
case AVATAR_FILE_TYPE_PNG:
|
||||
if (fileHeaderSize >= PNG_HEADER_SIZE
|
||||
&& memcmp(fileHeader, PNG_HEADER, PNG_HEADER_SIZE) == 0)
|
||||
{
|
||||
&& memcmp(fileHeader, PNG_HEADER, PNG_HEADER_SIZE) == 0) {
|
||||
validType = true;
|
||||
}
|
||||
break;
|
||||
case AVATAR_FILE_TYPE_JPG:
|
||||
if (fileHeaderSize >= JPG_HEADER_SIZE
|
||||
&& memcmp(fileHeader, JPG_HEADER, JPG_HEADER_SIZE) == 0)
|
||||
{
|
||||
&& memcmp(fileHeader, JPG_HEADER, JPG_HEADER_SIZE) == 0) {
|
||||
validType = true;
|
||||
}
|
||||
break;
|
||||
case AVATAR_FILE_TYPE_GIF:
|
||||
if (fileHeaderSize >= GIF_HEADER_SIZE
|
||||
&& (memcmp(fileHeader, GIF_HEADER_1, GIF_HEADER_SIZE) == 0
|
||||
|| memcmp(fileHeader, GIF_HEADER_2, GIF_HEADER_SIZE) == 0))
|
||||
{
|
||||
|| memcmp(fileHeader, GIF_HEADER_2, GIF_HEADER_SIZE) == 0)) {
|
||||
validType = true;
|
||||
}
|
||||
break;
|
||||
@@ -456,13 +418,11 @@ AvatarManager::RemoveOldAvatarCacheEntries()
|
||||
boost::mutex::scoped_lock lock(m_cacheDirMutex);
|
||||
cacheDir = m_cacheDir;
|
||||
}
|
||||
try
|
||||
{
|
||||
try {
|
||||
path cachePath(cacheDir);
|
||||
cacheDir = cachePath.directory_string();
|
||||
// Never delete anything if we do not have a special cache dir set.
|
||||
if (!cacheDir.empty())
|
||||
{
|
||||
if (!cacheDir.empty()) {
|
||||
boost::mutex::scoped_lock lock(m_cachedAvatarsMutex);
|
||||
|
||||
// First pass: Remove files which no longer exist.
|
||||
@@ -473,18 +433,15 @@ AvatarManager::RemoveOldAvatarCacheEntries()
|
||||
{
|
||||
AvatarMap::const_iterator i = m_cachedAvatars.begin();
|
||||
AvatarMap::const_iterator end = m_cachedAvatars.end();
|
||||
while (i != end)
|
||||
{
|
||||
while (i != end) {
|
||||
bool keepFile = false;
|
||||
path filePath(i->second);
|
||||
string fileString(filePath.file_string());
|
||||
// Only consider files which are definitely in the cache dir.
|
||||
if (fileString.size() > cacheDir.size() && fileString.substr(0, cacheDir.size()) == cacheDir)
|
||||
{
|
||||
if (fileString.size() > cacheDir.size() && fileString.substr(0, cacheDir.size()) == cacheDir) {
|
||||
// Only consider files with MD5 as file name.
|
||||
MD5Buf tmpBuf;
|
||||
if (exists(filePath) && tmpBuf.FromString(basename(filePath)))
|
||||
{
|
||||
if (exists(filePath) && tmpBuf.FromString(basename(filePath))) {
|
||||
++fileCount;
|
||||
timeMap.insert(TimeAvatarMap::value_type(last_write_time(filePath), i->first));
|
||||
keepFile = true;
|
||||
@@ -500,8 +457,7 @@ AvatarManager::RemoveOldAvatarCacheEntries()
|
||||
{
|
||||
AvatarList::const_iterator i = removeList.begin();
|
||||
AvatarList::const_iterator end = removeList.end();
|
||||
while (i != end)
|
||||
{
|
||||
while (i != end) {
|
||||
m_cachedAvatars.erase(*i);
|
||||
++i;
|
||||
}
|
||||
@@ -514,14 +470,11 @@ AvatarManager::RemoveOldAvatarCacheEntries()
|
||||
// - delete until only MAX_NUMBER_OF_FILES/2 are left.
|
||||
// 2. Files are older than 30 days.
|
||||
|
||||
if (m_cachedAvatars.size() > MAX_NUMBER_OF_FILES)
|
||||
{
|
||||
while (!timeMap.empty() && m_cachedAvatars.size() > MAX_NUMBER_OF_FILES / 2)
|
||||
{
|
||||
if (m_cachedAvatars.size() > MAX_NUMBER_OF_FILES) {
|
||||
while (!timeMap.empty() && m_cachedAvatars.size() > MAX_NUMBER_OF_FILES / 2) {
|
||||
TimeAvatarMap::iterator i = timeMap.begin();
|
||||
AvatarMap::iterator pos = m_cachedAvatars.find(i->second);
|
||||
if (pos != m_cachedAvatars.end())
|
||||
{
|
||||
if (pos != m_cachedAvatars.end()) {
|
||||
path tmpPath(pos->second);
|
||||
remove(tmpPath);
|
||||
m_cachedAvatars.erase(pos);
|
||||
@@ -532,14 +485,12 @@ AvatarManager::RemoveOldAvatarCacheEntries()
|
||||
|
||||
// Get reference time.
|
||||
time_t curTime = time(NULL);
|
||||
while (!timeMap.empty() && !m_cachedAvatars.empty())
|
||||
{
|
||||
while (!timeMap.empty() && !m_cachedAvatars.empty()) {
|
||||
TimeAvatarMap::iterator i = timeMap.begin();
|
||||
if (curTime - i->first < (int)MAX_AVATAR_CACHE_AGE)
|
||||
break;
|
||||
AvatarMap::iterator pos = m_cachedAvatars.find(i->second);
|
||||
if (pos != m_cachedAvatars.end())
|
||||
{
|
||||
if (pos != m_cachedAvatars.end()) {
|
||||
path tmpPath(pos->second);
|
||||
remove(tmpPath);
|
||||
m_cachedAvatars.erase(pos);
|
||||
@@ -547,8 +498,7 @@ AvatarManager::RemoveOldAvatarCacheEntries()
|
||||
timeMap.erase(i);
|
||||
}
|
||||
}
|
||||
} catch (...)
|
||||
{
|
||||
} catch (...) {
|
||||
LOG_ERROR("Exception caught while cleaning up cache.");
|
||||
}
|
||||
}
|
||||
@@ -559,37 +509,29 @@ AvatarManager::InternalReadDirectory(const std::string &dir, AvatarMap &avatars)
|
||||
bool retVal = true;
|
||||
path tmpPath(dir);
|
||||
|
||||
if (exists(tmpPath) && is_directory(tmpPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (exists(tmpPath) && is_directory(tmpPath)) {
|
||||
try {
|
||||
// This method is not thread safe. Only call after locking the map.
|
||||
directory_iterator i(tmpPath);
|
||||
directory_iterator end;
|
||||
|
||||
while (i != end)
|
||||
{
|
||||
if (is_regular(i->status()))
|
||||
{
|
||||
while (i != end) {
|
||||
if (is_regular(i->status())) {
|
||||
string md5sum(basename(i->path()));
|
||||
MD5Buf md5buf;
|
||||
string fileName(i->path().file_string());
|
||||
if (md5buf.FromString(md5sum))
|
||||
{
|
||||
if (md5buf.FromString(md5sum)) {
|
||||
// Only consider files with md5sum as name.
|
||||
avatars.insert(AvatarMap::value_type(md5buf, fileName));
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
} catch (...)
|
||||
{
|
||||
} catch (...) {
|
||||
LOG_ERROR("Exception caught when trying to scan avatar directory.");
|
||||
retVal = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
LOG_ERROR("Avatar directory does not exist.");
|
||||
retVal = false;
|
||||
}
|
||||
|
||||
@@ -53,8 +53,7 @@ HashBuf::ToString() const
|
||||
char tmpBuf[2 + 1];
|
||||
tmpBuf[sizeof(tmpBuf) - 1] = 0;
|
||||
const unsigned char *tmpData = GetData();
|
||||
for (int i = 0; i < GetDataSize(); i++)
|
||||
{
|
||||
for (int i = 0; i < GetDataSize(); i++) {
|
||||
sprintf(tmpBuf, "%02x", tmpData[i]);
|
||||
retValue += tmpBuf;
|
||||
}
|
||||
@@ -67,8 +66,7 @@ HashBuf::FromString(const std::string &text)
|
||||
// Convert hex-based string to MD5 data.
|
||||
bool retVal = false;
|
||||
int tmpSize = GetDataSize();
|
||||
if (text.size() == 2 * (unsigned)tmpSize)
|
||||
{
|
||||
if (text.size() == 2 * (unsigned)tmpSize) {
|
||||
unsigned char *tmpData = GetData();
|
||||
const char *t = text.c_str();
|
||||
int i = 0;
|
||||
@@ -92,8 +90,7 @@ HashBuf::IsZero() const
|
||||
int dataSize = GetDataSize();
|
||||
const unsigned char *tmpData = GetData();
|
||||
int i;
|
||||
for (i = 0; i < dataSize; i++)
|
||||
{
|
||||
for (i = 0; i < dataSize; i++) {
|
||||
if (tmpData[i] != 0)
|
||||
break;
|
||||
}
|
||||
@@ -166,8 +163,7 @@ CryptHelper::MD5Sum(const std::string &fileName, MD5Buf &buf)
|
||||
bool retVal = false;
|
||||
FILE *file = fopen(fileName.c_str(), "rb");
|
||||
|
||||
if (file)
|
||||
{
|
||||
if (file) {
|
||||
// Calculate MD5 sum of file.
|
||||
unsigned char readBuf[8192];
|
||||
MD5_CTX context;
|
||||
@@ -211,15 +207,12 @@ CryptHelper::HMACSha1(const unsigned char *keyData, unsigned keySize, const unsi
|
||||
retVal = false;
|
||||
gcry_md_hd_t hd;
|
||||
gcry_error_t err = gcry_md_open(&hd, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC);
|
||||
if (!err)
|
||||
{
|
||||
if (!err) {
|
||||
err = gcry_md_setkey(hd, keyData, keySize);
|
||||
if (!err)
|
||||
{
|
||||
if (!err) {
|
||||
gcry_md_write(hd, plainData, plainSize);
|
||||
unsigned char *hash = gcry_md_read(hd, 0);
|
||||
if (hash)
|
||||
{
|
||||
if (hash) {
|
||||
memcpy(buf.GetData(), hash, buf.GetDataSize());
|
||||
retVal = true;
|
||||
}
|
||||
@@ -260,8 +253,7 @@ CryptHelper::AES128Encrypt(const unsigned char *keyData, unsigned keySize, const
|
||||
{
|
||||
bool retVal = false;
|
||||
unsigned plainSize = static_cast<unsigned>(plainStr.size());
|
||||
if (keySize && plainSize)
|
||||
{
|
||||
if (keySize && plainSize) {
|
||||
unsigned char key[AES_BLOCK_SIZE];
|
||||
unsigned char iv[AES_BLOCK_SIZE];
|
||||
BytesToKey(keyData, keySize, key, iv);
|
||||
@@ -281,24 +273,20 @@ CryptHelper::AES128Encrypt(const unsigned char *keyData, unsigned keySize, const
|
||||
|
||||
int success = EVP_EncryptInit(&encryptCtx, EVP_aes_128_cbc(), key, iv);
|
||||
EVP_CIPHER_CTX_set_padding(&encryptCtx, 0);
|
||||
if (success)
|
||||
{
|
||||
if (success) {
|
||||
success = EVP_EncryptUpdate(&encryptCtx, &outCipher[0], &outCipherSize, paddedPlainStr, paddedPlainSize);
|
||||
|
||||
if (success && outCipherSize)
|
||||
{
|
||||
if (success && outCipherSize) {
|
||||
// Since padding is off, this will not modify the cipher. However, parameters need to be set.
|
||||
EVP_EncryptFinal(&encryptCtx, &outCipher[0], &outCipherSize);
|
||||
retVal = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
outCipher.clear();
|
||||
#else
|
||||
gcry_cipher_hd_t hd;
|
||||
gcry_error_t err = gcry_cipher_open(&hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC, 0);
|
||||
if (!err)
|
||||
{
|
||||
if (!err) {
|
||||
gcry_cipher_setkey(hd, key, sizeof(key));
|
||||
gcry_cipher_setiv(hd, iv, sizeof(iv));
|
||||
err = gcry_cipher_encrypt(hd, &outCipher[0], cipherSize, paddedPlainStr, paddedPlainSize);
|
||||
@@ -306,8 +294,7 @@ CryptHelper::AES128Encrypt(const unsigned char *keyData, unsigned keySize, const
|
||||
retVal = true;
|
||||
else
|
||||
outCipher.clear();
|
||||
}
|
||||
else
|
||||
} else
|
||||
outCipher.clear();
|
||||
|
||||
gcry_cipher_close(hd);
|
||||
@@ -320,8 +307,7 @@ bool
|
||||
CryptHelper::AES128Decrypt(const unsigned char *keyData, unsigned keySize, const unsigned char *cipher, unsigned cipherSize, string &outPlain)
|
||||
{
|
||||
bool retVal = false;
|
||||
if (keySize && cipherSize)
|
||||
{
|
||||
if (keySize && cipherSize) {
|
||||
unsigned char key[AES_BLOCK_SIZE];
|
||||
unsigned char iv[AES_BLOCK_SIZE];
|
||||
BytesToKey(keyData, keySize, key, iv);
|
||||
@@ -333,24 +319,20 @@ CryptHelper::AES128Decrypt(const unsigned char *keyData, unsigned keySize, const
|
||||
|
||||
int success = EVP_DecryptInit(&decryptCtx, EVP_aes_128_cbc(), key, iv);
|
||||
EVP_CIPHER_CTX_set_padding(&decryptCtx, 0);
|
||||
if (success)
|
||||
{
|
||||
if (success) {
|
||||
success = EVP_DecryptUpdate(&decryptCtx, (unsigned char *)&outPlain[0], &outPlainSize, cipher, cipherSize);
|
||||
|
||||
if (success && outPlainSize)
|
||||
{
|
||||
if (success && outPlainSize) {
|
||||
// Since padding is off, this will not modify the plain text. However, parameters need to be set.
|
||||
EVP_DecryptFinal(&decryptCtx, (unsigned char *)outPlain.c_str(), &outPlainSize);
|
||||
retVal = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
outPlain.clear();
|
||||
#else
|
||||
gcry_cipher_hd_t hd;
|
||||
gcry_error_t err = gcry_cipher_open(&hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC, 0);
|
||||
if (!err)
|
||||
{
|
||||
if (!err) {
|
||||
gcry_cipher_setkey(hd, key, sizeof(key));
|
||||
gcry_cipher_setiv(hd, iv, sizeof(iv));
|
||||
err = gcry_cipher_decrypt(hd, &outPlain[0], outPlain.size(), cipher, cipherSize);
|
||||
@@ -358,15 +340,13 @@ CryptHelper::AES128Decrypt(const unsigned char *keyData, unsigned keySize, const
|
||||
retVal = true;
|
||||
else
|
||||
outPlain.clear();
|
||||
}
|
||||
else
|
||||
} else
|
||||
outPlain.clear();
|
||||
|
||||
gcry_cipher_close(hd);
|
||||
#endif
|
||||
// Remove trailing zeroes (padding).
|
||||
if (!outPlain.empty())
|
||||
{
|
||||
if (!outPlain.empty()) {
|
||||
size_t pos = outPlain.find_first_of('\0');
|
||||
if (pos != string::npos)
|
||||
outPlain = outPlain.substr(0, pos);
|
||||
|
||||
@@ -54,11 +54,9 @@ loghelper_init(const string &logDir, int logLevel)
|
||||
void
|
||||
internal_log_err(const string &msg)
|
||||
{
|
||||
if (!g_logFile.empty())
|
||||
{
|
||||
if (!g_logFile.empty()) {
|
||||
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
||||
if (!o.fail())
|
||||
{
|
||||
if (!o.fail()) {
|
||||
o << second_clock::local_time() << " ERR: " << msg;
|
||||
o.flush();
|
||||
}
|
||||
@@ -68,10 +66,8 @@ internal_log_err(const string &msg)
|
||||
void
|
||||
internal_log_msg(const std::string &msg)
|
||||
{
|
||||
if (g_logLevel)
|
||||
{
|
||||
if (!g_logFile.empty())
|
||||
{
|
||||
if (g_logLevel) {
|
||||
if (!g_logFile.empty()) {
|
||||
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
||||
if (!o.fail())
|
||||
o << second_clock::local_time() << " MSG: " << msg;
|
||||
@@ -82,10 +78,8 @@ internal_log_msg(const std::string &msg)
|
||||
void
|
||||
internal_log_level(const std::string &msg, int logLevel)
|
||||
{
|
||||
if (g_logLevel >= logLevel)
|
||||
{
|
||||
if (!g_logFile.empty())
|
||||
{
|
||||
if (g_logLevel >= logLevel) {
|
||||
if (!g_logFile.empty()) {
|
||||
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
||||
if (!o.fail())
|
||||
o << second_clock::local_time() << " OUT: " << msg;
|
||||
|
||||
@@ -26,8 +26,7 @@ inline void ADD_MSEC_TO_XTIME(boost::xtime &xt, unsigned msec)
|
||||
{
|
||||
xt.sec += msec / 1000;
|
||||
xt.nsec += (msec % 1000) * 1000000;
|
||||
if (xt.nsec > NANOSECONDS_PER_SECOND)
|
||||
{
|
||||
if (xt.nsec > NANOSECONDS_PER_SECOND) {
|
||||
xt.sec++;
|
||||
xt.nsec -= NANOSECONDS_PER_SECOND;
|
||||
}
|
||||
@@ -39,8 +38,7 @@ class ThreadStarter
|
||||
{
|
||||
public:
|
||||
ThreadStarter(Thread &thread) : m_thread(thread) {}
|
||||
void operator()()
|
||||
{
|
||||
void operator()() {
|
||||
m_thread.MainWrapper();
|
||||
}
|
||||
|
||||
@@ -62,8 +60,7 @@ Thread::Run()
|
||||
boost::mutex::scoped_lock threadLock(m_threadObjMutex);
|
||||
|
||||
// Create the boost thread object.
|
||||
if (!m_threadObj.get())
|
||||
{
|
||||
if (!m_threadObj.get()) {
|
||||
// Initialise data structures within the context of the thread
|
||||
// who runs/terminates this thread.
|
||||
m_userReqTerminateLock.reset(new boost::timed_mutex::scoped_try_lock(m_shouldTerminateMutex));
|
||||
@@ -89,14 +86,11 @@ Thread::Join(unsigned msecTimeout)
|
||||
return true;
|
||||
|
||||
bool tmpIsTerminated;
|
||||
if (msecTimeout == THREAD_WAIT_INFINITE)
|
||||
{
|
||||
if (msecTimeout == THREAD_WAIT_INFINITE) {
|
||||
// Wait infinitely.
|
||||
boost::timed_mutex::scoped_lock lock(m_isTerminatedMutex);
|
||||
tmpIsTerminated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Wait for the termination of the application code.
|
||||
#if (BOOST_VERSION) >= 103500
|
||||
boost::defer_lock_t defer;
|
||||
@@ -113,12 +107,10 @@ Thread::Join(unsigned msecTimeout)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (tmpIsTerminated)
|
||||
{
|
||||
if (tmpIsTerminated) {
|
||||
boost::mutex::scoped_lock lock(m_threadObjMutex);
|
||||
// Wait for "real" termination of the thread.
|
||||
if (m_threadObj.get())
|
||||
{
|
||||
if (m_threadObj.get()) {
|
||||
m_threadObj->join();
|
||||
m_threadObj.reset();
|
||||
}
|
||||
|
||||
@@ -57,8 +57,7 @@ ConvHelper::NativeToUtf8(const std::string &inStr)
|
||||
|
||||
if (conversion == (iconv_t)(-1))
|
||||
LOG_ERROR("iconv_open() failed: " << strerror(errno));
|
||||
else
|
||||
{
|
||||
else {
|
||||
size_t retval = iconv(conversion, &inbuf, &insize, &outbuf, &outsize);
|
||||
|
||||
if (retval == (size_t)-1)
|
||||
@@ -91,8 +90,7 @@ ConvHelper::Utf8ToNative(const std::string &inStr)
|
||||
|
||||
if (conversion == (iconv_t)(-1))
|
||||
LOG_ERROR("iconv_open() failed: " << strerror(errno));
|
||||
else
|
||||
{
|
||||
else {
|
||||
size_t retval = iconv(conversion, &inbuf, &insize, &outbuf, &outsize);
|
||||
|
||||
if (retval == (size_t)-1)
|
||||
|
||||
@@ -31,8 +31,12 @@ public:
|
||||
PokerTHException(const char *sourcefile, int sourceline, int errorId, int osErrorCode);
|
||||
virtual ~PokerTHException() throw();
|
||||
|
||||
int GetErrorId() const {return m_errorId;}
|
||||
int GetOsErrorCode() const {return m_osErrorCode;}
|
||||
int GetErrorId() const {
|
||||
return m_errorId;
|
||||
}
|
||||
int GetOsErrorCode() const {
|
||||
return m_osErrorCode;
|
||||
}
|
||||
|
||||
virtual const char *what() const throw();
|
||||
|
||||
|
||||
@@ -33,22 +33,18 @@ Convert(const std::string &inStr, int fromCP, int toCP)
|
||||
// convert str from current Windows source to target charset
|
||||
string retStr(inStr);
|
||||
|
||||
if (!inStr.empty())
|
||||
{
|
||||
if (!inStr.empty()) {
|
||||
int len = (int)inStr.length() + 1;
|
||||
int reqLen = ::MultiByteToWideChar(fromCP, 0, inStr.c_str(), len, NULL, 0);
|
||||
|
||||
if (reqLen)
|
||||
{
|
||||
if (reqLen) {
|
||||
wchar_t *wstr = new wchar_t[reqLen];
|
||||
wstr[0] = L'\0';
|
||||
if (::MultiByteToWideChar(fromCP, 0, inStr.c_str(), len, wstr, reqLen) == (int)reqLen)
|
||||
{
|
||||
if (::MultiByteToWideChar(fromCP, 0, inStr.c_str(), len, wstr, reqLen) == (int)reqLen) {
|
||||
len = reqLen;
|
||||
reqLen = ::WideCharToMultiByte(toCP, 0, wstr, len, NULL, 0, NULL, NULL);
|
||||
|
||||
if (reqLen)
|
||||
{
|
||||
if (reqLen) {
|
||||
char *str = new char[reqLen];
|
||||
if (::WideCharToMultiByte(toCP, 0, wstr, len, str, reqLen, NULL, NULL) == (int)reqLen)
|
||||
retStr = str;
|
||||
|
||||
+1
-2
@@ -27,8 +27,7 @@
|
||||
typedef unsigned DB_id;
|
||||
#define DB_ID_INVALID 0
|
||||
|
||||
struct DBPlayerData
|
||||
{
|
||||
struct DBPlayerData {
|
||||
DBPlayerData() : id(DB_ID_INVALID) {}
|
||||
DB_id id;
|
||||
std::string secret;
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
#include <game_defs.h>
|
||||
#include <engine_defs.h>
|
||||
|
||||
class BeRoInterface{
|
||||
class BeRoInterface
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~BeRoInterface();
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
|
||||
class HandInterface;
|
||||
|
||||
class BoardInterface {
|
||||
class BoardInterface
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
#include "berointerface.h"
|
||||
#include "log.h"
|
||||
|
||||
class EngineFactory{
|
||||
class EngineFactory
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~EngineFactory();
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
#include "playerinterface.h"
|
||||
#include "berointerface.h"
|
||||
|
||||
class HandInterface{
|
||||
class HandInterface
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~HandInterface();
|
||||
|
||||
@@ -22,14 +22,12 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct RoundData
|
||||
{
|
||||
struct RoundData {
|
||||
int hand;
|
||||
double data[4];
|
||||
};
|
||||
|
||||
static const RoundData PreflopValues[] =
|
||||
{
|
||||
static const RoundData PreflopValues[] = {
|
||||
{ 0, { 0.392398, 0.276545, 0.212940, 0.178564 } },
|
||||
{ 10, { 0.341141, 0.213735, 0.153802, 0.121123 } },
|
||||
{ 11, { 0.374930, 0.252093, 0.194671, 0.161691 } },
|
||||
@@ -201,8 +199,7 @@ static const RoundData PreflopValues[] =
|
||||
{ 12120, { 0.855608, 0.736617, 0.642366, 0.562044 } }
|
||||
};
|
||||
|
||||
static const RoundData FlopValues[] =
|
||||
{
|
||||
static const RoundData FlopValues[] = {
|
||||
{ 106, { 0.160312, 0.078750, 0.048325, 0.033350 } },
|
||||
{ 206, { 0.185012, 0.099666, 0.071425, 0.053450 } },
|
||||
{ 306, { 0.199662, 0.115567, 0.081625, 0.067500 } },
|
||||
@@ -839,14 +836,12 @@ static const RoundData FlopValues[] =
|
||||
{ 71212, { 0.751687, 0.628100, 0.560100, 0.516900 } }
|
||||
};
|
||||
|
||||
struct calcHandsData
|
||||
{
|
||||
struct calcHandsData {
|
||||
int hand;
|
||||
int data[10][2];
|
||||
};
|
||||
|
||||
static const calcHandsData handChancePreflop[] =
|
||||
{
|
||||
static const calcHandsData handChancePreflop[] = {
|
||||
{ 0, { { 0,0}, { 36,1}, { 40,1}, { 12,1}, { 1,1}, { 2,1}, { 9,1}, { 1,1}, { 0,1}, { 0,1} } },
|
||||
{ 10, { { 19,1}, { 45,1}, { 23,1}, { 4,1}, { 5,1}, { 2,1}, { 2,1}, { 0,1}, { 0,1}, { 0,1} } },
|
||||
{ 11, { { 18,1}, { 42,1}, { 22,1}, { 4,1}, { 5,1}, { 6,1}, { 2,1}, { 0,1}, { 0,1}, { 0,1} } },
|
||||
@@ -1030,7 +1025,8 @@ ArrayData::~ArrayData()
|
||||
{
|
||||
}
|
||||
|
||||
void ArrayData::getHandChancePreflop(int handCode, int** values) {
|
||||
void ArrayData::getHandChancePreflop(int handCode, int** values)
|
||||
{
|
||||
|
||||
int check = -1;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
|
||||
#include<vector>
|
||||
|
||||
class ArrayData{
|
||||
class ArrayData
|
||||
{
|
||||
public:
|
||||
ArrayData();
|
||||
|
||||
|
||||
@@ -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) {
|
||||
int temp = one;
|
||||
@@ -43,11 +44,16 @@ int CardsValue::holeCardsClass(int one, int two) const {
|
||||
if((one-1)%13+2 > 10) return 10;
|
||||
else {
|
||||
switch((one-1)%13+2) {
|
||||
case 10: return 9;
|
||||
case 9: return 8;
|
||||
case 8: return 7;
|
||||
case 7: return 6;
|
||||
default: return 5;
|
||||
case 10:
|
||||
return 9;
|
||||
case 9:
|
||||
return 8;
|
||||
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: {
|
||||
if((one-1)/13 == (two-1)/13) {
|
||||
switch((one-1)%13-(two-1)%13) {
|
||||
case 1: return 10;
|
||||
case 2: return 9;
|
||||
case 3: return 9;
|
||||
case 4: return 8;
|
||||
default: return 7;
|
||||
case 1:
|
||||
return 10;
|
||||
case 2:
|
||||
return 9;
|
||||
case 3:
|
||||
return 9;
|
||||
case 4:
|
||||
return 8;
|
||||
default:
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch((one-1)%13-(two-1)%13) {
|
||||
case 1: return 9;
|
||||
case 2: return 8;
|
||||
case 3: return 7;
|
||||
case 4: return 7;
|
||||
default: return 4;
|
||||
case 1:
|
||||
return 9;
|
||||
case 2:
|
||||
return 8;
|
||||
case 3:
|
||||
return 7;
|
||||
case 4:
|
||||
return 7;
|
||||
default:
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
//K�ig
|
||||
case 13: {
|
||||
if((one-1)/13 == (two-1)/13) {
|
||||
switch((one-1)%13-(two-1)%13) {
|
||||
case 1: return 9;
|
||||
case 2: return 8;
|
||||
case 3: return 8;
|
||||
case 4: return 6;
|
||||
default: return 5;
|
||||
case 1:
|
||||
return 9;
|
||||
case 2:
|
||||
return 8;
|
||||
case 3:
|
||||
return 8;
|
||||
case 4:
|
||||
return 6;
|
||||
default:
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch((one-1)%13-(two-1)%13) {
|
||||
case 1: return 7;
|
||||
case 2: return 6;
|
||||
case 3: return 6;
|
||||
default: return 4;
|
||||
case 1:
|
||||
return 7;
|
||||
case 2:
|
||||
return 6;
|
||||
case 3:
|
||||
return 6;
|
||||
default:
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
//Dame
|
||||
case 12: {
|
||||
if((one-1)/13 == (two-1)/13) {
|
||||
switch((one-1)%13-(two-1)%13) {
|
||||
case 1: return 8;
|
||||
case 2: return 7;
|
||||
case 3: return 6;
|
||||
case 4: return 5;
|
||||
default: return 4;
|
||||
case 1:
|
||||
return 8;
|
||||
case 2:
|
||||
return 7;
|
||||
case 3:
|
||||
return 6;
|
||||
case 4:
|
||||
return 5;
|
||||
default:
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch((one-1)%13-(two-1)%13) {
|
||||
case 1: return 6;
|
||||
case 2: return 6;
|
||||
case 3: return 4;
|
||||
default: return 3;
|
||||
case 1:
|
||||
return 6;
|
||||
case 2:
|
||||
return 6;
|
||||
case 3:
|
||||
return 4;
|
||||
default:
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
//Bube
|
||||
case 11: {
|
||||
if((one-1)/13 == (two-1)/13) {
|
||||
switch((one-1)%13-(two-1)%13) {
|
||||
case 1: return 7;
|
||||
case 2: return 6;
|
||||
case 3: return 5;
|
||||
case 4: return 4;
|
||||
default: return 3;
|
||||
case 1:
|
||||
return 7;
|
||||
case 2:
|
||||
return 6;
|
||||
case 3:
|
||||
return 5;
|
||||
case 4:
|
||||
return 4;
|
||||
default:
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch((one-1)%13-(two-1)%13) {
|
||||
case 1: return 6;
|
||||
case 2: return 5;
|
||||
case 3: return 4;
|
||||
default: return 2;
|
||||
case 1:
|
||||
return 6;
|
||||
case 2:
|
||||
return 5;
|
||||
case 3:
|
||||
return 4;
|
||||
default:
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
//10
|
||||
case 10: {
|
||||
if((one-1)/13 == (two-1)/13) {
|
||||
switch((one-1)%13-(two-1)%13) {
|
||||
case 1: return 6;
|
||||
case 2: return 5;
|
||||
default: return 2;
|
||||
case 1:
|
||||
return 6;
|
||||
case 2:
|
||||
return 5;
|
||||
default:
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch((one-1)%13-(two-1)%13) {
|
||||
case 1: return 5;
|
||||
case 2: return 4;
|
||||
default: return 1;
|
||||
case 1:
|
||||
return 5;
|
||||
case 2:
|
||||
return 4;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
//Rest
|
||||
default: {
|
||||
if((one-1)%13 - (two-1)%13 <= 2) {
|
||||
if((one-1)/13 == (two-1)/13) return 5;
|
||||
else return 3;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if((one-1)%13 - (two-1)%13 == 3) return 2;
|
||||
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
|
||||
if(cards[0]%13 == cards[1]%13) {
|
||||
@@ -189,7 +238,8 @@ int CardsValue::holeCardsToIntCode(int* cards) const {
|
||||
|
||||
}
|
||||
|
||||
int* CardsValue::intCodeToHoleCards(int code) const {
|
||||
int* CardsValue::intCodeToHoleCards(int code) const
|
||||
{
|
||||
|
||||
// one possibility !!!
|
||||
|
||||
@@ -198,8 +248,9 @@ int* CardsValue::intCodeToHoleCards(int code) const {
|
||||
cards[0] = code/1000;
|
||||
cards[1] = (code-cards[0]*1000)/10;
|
||||
|
||||
if(cards[0]==cards[1]) { cards[1] +=13; }
|
||||
else {
|
||||
if(cards[0]==cards[1]) {
|
||||
cards[1] +=13;
|
||||
} else {
|
||||
if(code%10 == 0) cards[1] +=13;
|
||||
}
|
||||
|
||||
@@ -207,7 +258,8 @@ 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 j1, j2, j3, j4, j5, k1, k2, ktemp[3];
|
||||
@@ -368,8 +420,7 @@ int array[7][3];
|
||||
}
|
||||
}
|
||||
return 700000000+array[j1][1]*1000000+array[j1+4][1]*10000;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
for(j2=0; j2<4; j2++) {
|
||||
@@ -414,8 +465,13 @@ int array[7][3];
|
||||
position[4] = array[j5][2];
|
||||
}
|
||||
// Paar und Drilling des Full House ermitteln ermitteln
|
||||
if(array[j3][1]==array[j1][1]) { drei = array[j1][1]; zwei = array[j4][1]; }
|
||||
else { drei = array[j4][1]; zwei = array[j1][1]; }
|
||||
if(array[j3][1]==array[j1][1]) {
|
||||
drei = array[j1][1];
|
||||
zwei = array[j4][1];
|
||||
} else {
|
||||
drei = array[j4][1];
|
||||
zwei = array[j1][1];
|
||||
}
|
||||
return 600000000+drei*1000000+zwei*10000;
|
||||
}
|
||||
}
|
||||
@@ -459,8 +515,7 @@ int array[7][3];
|
||||
}
|
||||
}
|
||||
return 300000000+array[j1][1]*1000000+array[j1+3][1]*10000+array[j1+4][1]*100;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(j1==1) {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
@@ -469,8 +524,7 @@ int array[7][3];
|
||||
}
|
||||
}
|
||||
return 300000000+array[j1][1]*1000000+array[j1-1][1]*10000+array[j1+3][1]*100;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
for(j2=0; j2<3; j2++) {
|
||||
@@ -501,8 +555,7 @@ int array[7][3];
|
||||
position[4] = array[j2+2][2];
|
||||
}
|
||||
return 200000000+array[j1][1]*1000000+array[j2][1]*10000+array[j2+2][1]*100;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
position[0] = array[j1][2];
|
||||
@@ -513,8 +566,7 @@ int array[7][3];
|
||||
}
|
||||
return 200000000+array[j1][1]*1000000+array[j2][1]*10000+array[j1+2][1]*100;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
position[0] = array[j1][2];
|
||||
@@ -559,8 +611,7 @@ int array[7][3];
|
||||
}
|
||||
}
|
||||
return 100000000+array[j1][1]*1000000+array[j1-2][1]*10000+array[j1-1][1]*100+array[j1+2][1];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
for(j2=0; j2<2; j2++) {
|
||||
@@ -615,7 +666,8 @@ vector< vector<int> > CardsValue::calcCardsChance(GameState beRoID, int* playerC
|
||||
|
||||
delete myArrayData;
|
||||
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case GAME_STATE_FLOP: {
|
||||
|
||||
for(i=0; i<51; i++) {
|
||||
@@ -635,7 +687,8 @@ vector< vector<int> > CardsValue::calcCardsChance(GameState beRoID, int* playerC
|
||||
chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5);
|
||||
}
|
||||
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case GAME_STATE_TURN: {
|
||||
|
||||
for(i=0; i<52; i++) {
|
||||
@@ -650,11 +703,13 @@ vector< vector<int> > CardsValue::calcCardsChance(GameState beRoID, int* playerC
|
||||
chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5);
|
||||
}
|
||||
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case GAME_STATE_RIVER: {
|
||||
chance[0][cardsValue(cards,0)/100000000] = 100;
|
||||
chance[1][cardsValue(cards,0)/100000000] = 1;
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
|
||||
|
||||
|
||||
class CardsValue{
|
||||
class CardsValue
|
||||
{
|
||||
public:
|
||||
CardsValue();
|
||||
|
||||
|
||||
@@ -68,7 +68,8 @@ int LocalBeRo::getHighestCardsValue() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
void LocalBeRo::nextPlayer() {
|
||||
void LocalBeRo::nextPlayer()
|
||||
{
|
||||
|
||||
PlayerListConstIterator currentPlayersTurnConstIt = myHand->getRunningPlayerIt(currentPlayersTurnId);
|
||||
if(currentPlayersTurnConstIt == myHand->getRunningPlayerList()->end()) {
|
||||
@@ -79,14 +80,14 @@ void LocalBeRo::nextPlayer() {
|
||||
|
||||
}
|
||||
|
||||
void LocalBeRo::run() {
|
||||
void LocalBeRo::run()
|
||||
{
|
||||
|
||||
if(firstRunGui) {
|
||||
firstRunGui = false;
|
||||
myHand->setLastPlayersTurn(-1);
|
||||
myHand->getGuiInterface()->dealBeRoCards(myBeRoID);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
if(firstRun) {
|
||||
|
||||
@@ -138,13 +139,18 @@ void LocalBeRo::run() {
|
||||
myHand->getBoard()->getMyCards(tempBoardCardsArray);
|
||||
|
||||
switch(myBeRoID) {
|
||||
case GAME_STATE_FLOP: myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2]);
|
||||
case GAME_STATE_FLOP:
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2]);
|
||||
break;
|
||||
case GAME_STATE_TURN: myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3]);
|
||||
case GAME_STATE_TURN:
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3]);
|
||||
break;
|
||||
case GAME_STATE_RIVER: myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3], tempBoardCardsArray[4]);
|
||||
case GAME_STATE_RIVER:
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3], tempBoardCardsArray[4]);
|
||||
break;
|
||||
default: { LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR - wrong myBeRoID"); }
|
||||
default: {
|
||||
LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR - wrong myBeRoID");
|
||||
}
|
||||
}
|
||||
logBoardCardsDone = true;
|
||||
|
||||
@@ -183,11 +189,12 @@ void LocalBeRo::run() {
|
||||
|
||||
myHand->getGuiInterface()->refreshSet();
|
||||
myHand->getGuiInterface()->refreshCash();
|
||||
for(int i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { myHand->getGuiInterface()->refreshAction(i,PLAYER_ACTION_NONE); }
|
||||
for(int i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
myHand->getGuiInterface()->refreshAction(i,PLAYER_ACTION_NONE);
|
||||
}
|
||||
|
||||
myHand->switchRounds();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// aktuelle bero ist wirklich dran
|
||||
|
||||
// Anzahl der effektiv gespielten Runden (des human player) erhöhen
|
||||
@@ -229,8 +236,7 @@ void LocalBeRo::run() {
|
||||
if( currentPlayersTurnId == 0) {
|
||||
// Wir sind dran
|
||||
myHand->getGuiInterface()->meInAction();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
//Gegner sind dran
|
||||
myHand->getGuiInterface()->beRoAnimation2(myBeRoID);
|
||||
|
||||
@@ -26,23 +26,36 @@
|
||||
#include "berointerface.h"
|
||||
#include "handinterface.h"
|
||||
|
||||
class LocalBeRo : public BeRoInterface{
|
||||
class LocalBeRo : public BeRoInterface
|
||||
{
|
||||
public:
|
||||
LocalBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS);
|
||||
~LocalBeRo();
|
||||
|
||||
GameState getMyBeRoID() const { return myBeRoID; }
|
||||
GameState getMyBeRoID() const {
|
||||
return myBeRoID;
|
||||
}
|
||||
|
||||
int getHighestCardsValue() const;
|
||||
void setHighestCardsValue(int /*theValue*/) { }
|
||||
|
||||
void setMinimumRaise ( int theValue ) { minimumRaise = theValue; }
|
||||
int getMinimumRaise() const { return minimumRaise; }
|
||||
void setMinimumRaise ( int theValue ) {
|
||||
minimumRaise = theValue;
|
||||
}
|
||||
int getMinimumRaise() const {
|
||||
return minimumRaise;
|
||||
}
|
||||
|
||||
void setFullBetRule ( bool theValue ) { fullBetRule = theValue; }
|
||||
bool getFullBetRule() const { return fullBetRule; }
|
||||
void setFullBetRule ( bool theValue ) {
|
||||
fullBetRule = theValue;
|
||||
}
|
||||
bool getFullBetRule() const {
|
||||
return fullBetRule;
|
||||
}
|
||||
|
||||
void skipFirstRunGui() { firstRunGui = false; }
|
||||
void skipFirstRunGui() {
|
||||
firstRunGui = false;
|
||||
}
|
||||
|
||||
void nextPlayer();
|
||||
void run();
|
||||
@@ -52,48 +65,102 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
HandInterface* getMyHand() const { return myHand; }
|
||||
HandInterface* getMyHand() const {
|
||||
return myHand;
|
||||
}
|
||||
|
||||
int getDealerPosition() const {return dealerPosition; }
|
||||
void setDealerPosition(int theValue) { dealerPosition = theValue; }
|
||||
int getDealerPosition() const {
|
||||
return dealerPosition;
|
||||
}
|
||||
void setDealerPosition(int theValue) {
|
||||
dealerPosition = theValue;
|
||||
}
|
||||
|
||||
void setCurrentPlayersTurnId(unsigned theValue) { currentPlayersTurnId = theValue; }
|
||||
unsigned getCurrentPlayersTurnId() const { return currentPlayersTurnId;}
|
||||
void setCurrentPlayersTurnId(unsigned theValue) {
|
||||
currentPlayersTurnId = theValue;
|
||||
}
|
||||
unsigned getCurrentPlayersTurnId() const {
|
||||
return currentPlayersTurnId;
|
||||
}
|
||||
|
||||
void setFirstRoundLastPlayersTurnId(unsigned theValue) { firstRoundLastPlayersTurnId = theValue; }
|
||||
unsigned getFirstRoundLastPlayersTurnId() const { return firstRoundLastPlayersTurnId;}
|
||||
void setFirstRoundLastPlayersTurnId(unsigned theValue) {
|
||||
firstRoundLastPlayersTurnId = theValue;
|
||||
}
|
||||
unsigned getFirstRoundLastPlayersTurnId() const {
|
||||
return firstRoundLastPlayersTurnId;
|
||||
}
|
||||
|
||||
void setCurrentPlayersTurnIt(PlayerListIterator theValue) { currentPlayersTurnIt = theValue; }
|
||||
PlayerListIterator getCurrentPlayersTurnIt() const { return currentPlayersTurnIt; }
|
||||
void setCurrentPlayersTurnIt(PlayerListIterator theValue) {
|
||||
currentPlayersTurnIt = theValue;
|
||||
}
|
||||
PlayerListIterator getCurrentPlayersTurnIt() const {
|
||||
return currentPlayersTurnIt;
|
||||
}
|
||||
|
||||
void setLastPlayersTurnIt(PlayerListIterator theValue) { lastPlayersTurnIt = theValue; }
|
||||
PlayerListIterator getLastPlayersTurnIt() const { return lastPlayersTurnIt; }
|
||||
void setLastPlayersTurnIt(PlayerListIterator theValue) {
|
||||
lastPlayersTurnIt = theValue;
|
||||
}
|
||||
PlayerListIterator getLastPlayersTurnIt() const {
|
||||
return lastPlayersTurnIt;
|
||||
}
|
||||
|
||||
void setHighestSet(int theValue) { highestSet = theValue; }
|
||||
int getHighestSet() const { return highestSet;}
|
||||
void setHighestSet(int theValue) {
|
||||
highestSet = theValue;
|
||||
}
|
||||
int getHighestSet() const {
|
||||
return highestSet;
|
||||
}
|
||||
|
||||
void setFirstRun(bool theValue) { firstRun = theValue;}
|
||||
bool getFirstRun() const { return firstRun;}
|
||||
void setFirstRun(bool theValue) {
|
||||
firstRun = theValue;
|
||||
}
|
||||
bool getFirstRun() const {
|
||||
return firstRun;
|
||||
}
|
||||
|
||||
void setFirstRound(bool theValue) { firstRound = theValue;}
|
||||
bool getFirstRound() const { return firstRound;}
|
||||
void setFirstRound(bool theValue) {
|
||||
firstRound = theValue;
|
||||
}
|
||||
bool getFirstRound() const {
|
||||
return firstRound;
|
||||
}
|
||||
|
||||
|
||||
void setDealerPositionId(unsigned theValue) { dealerPositionId = theValue;}
|
||||
unsigned getDealerPositionId() const { return dealerPositionId; }
|
||||
void setDealerPositionId(unsigned theValue) {
|
||||
dealerPositionId = theValue;
|
||||
}
|
||||
unsigned getDealerPositionId() const {
|
||||
return dealerPositionId;
|
||||
}
|
||||
|
||||
void setSmallBlindPositionId(unsigned theValue) { smallBlindPositionId = theValue;}
|
||||
unsigned getSmallBlindPositionId() const { return smallBlindPositionId; }
|
||||
void setSmallBlindPositionId(unsigned theValue) {
|
||||
smallBlindPositionId = theValue;
|
||||
}
|
||||
unsigned getSmallBlindPositionId() const {
|
||||
return smallBlindPositionId;
|
||||
}
|
||||
|
||||
void setBigBlindPositionId(unsigned theValue) { bigBlindPositionId = theValue;}
|
||||
unsigned getBigBlindPositionId() const { return bigBlindPositionId; }
|
||||
void setBigBlindPositionId(unsigned theValue) {
|
||||
bigBlindPositionId = theValue;
|
||||
}
|
||||
unsigned getBigBlindPositionId() const {
|
||||
return bigBlindPositionId;
|
||||
}
|
||||
|
||||
|
||||
void setSmallBlindPosition(int theValue) { smallBlindPosition = theValue;}
|
||||
int getSmallBlindPosition() const { return smallBlindPosition; }
|
||||
void setSmallBlindPosition(int theValue) {
|
||||
smallBlindPosition = theValue;
|
||||
}
|
||||
int getSmallBlindPosition() const {
|
||||
return smallBlindPosition;
|
||||
}
|
||||
|
||||
void setSmallBlind(int theValue) { smallBlind = theValue; }
|
||||
int getSmallBlind() const { return smallBlind; }
|
||||
void setSmallBlind(int theValue) {
|
||||
smallBlind = theValue;
|
||||
}
|
||||
int getSmallBlind() const {
|
||||
return smallBlind;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
|
||||
class HandInterface;
|
||||
|
||||
class LocalBeRoFlop : public LocalBeRo{
|
||||
class LocalBeRoFlop : public LocalBeRo
|
||||
{
|
||||
|
||||
public:
|
||||
LocalBeRoFlop(HandInterface*, int, unsigned, int);
|
||||
|
||||
@@ -33,10 +33,12 @@ LocalBeRoPostRiver::~LocalBeRoPostRiver()
|
||||
{
|
||||
}
|
||||
|
||||
void LocalBeRoPostRiver::run() {
|
||||
void LocalBeRoPostRiver::run()
|
||||
{
|
||||
}
|
||||
|
||||
void LocalBeRoPostRiver::postRiverRun() {
|
||||
void LocalBeRoPostRiver::postRiverRun()
|
||||
{
|
||||
|
||||
PlayerListConstIterator it_c;
|
||||
PlayerListIterator it;
|
||||
|
||||
@@ -26,13 +26,18 @@
|
||||
class HandInterface;
|
||||
|
||||
|
||||
class LocalBeRoPostRiver : public LocalBeRo{
|
||||
class LocalBeRoPostRiver : public LocalBeRo
|
||||
{
|
||||
public:
|
||||
LocalBeRoPostRiver(HandInterface*, int, int, int);
|
||||
~LocalBeRoPostRiver();
|
||||
|
||||
void setHighestCardsValue(int theValue) { highestCardsValue = theValue;}
|
||||
int getHighestCardsValue() const { return highestCardsValue;}
|
||||
void setHighestCardsValue(int theValue) {
|
||||
highestCardsValue = theValue;
|
||||
}
|
||||
int getHighestCardsValue() const {
|
||||
return highestCardsValue;
|
||||
}
|
||||
|
||||
void run();
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@ LocalBeRoPreflop::~LocalBeRoPreflop()
|
||||
{
|
||||
}
|
||||
|
||||
void LocalBeRoPreflop::run() {
|
||||
void LocalBeRoPreflop::run()
|
||||
{
|
||||
|
||||
if(getFirstRun()) {
|
||||
|
||||
@@ -151,11 +152,12 @@ void LocalBeRoPreflop::run() {
|
||||
|
||||
getMyHand()->getGuiInterface()->refreshSet();
|
||||
getMyHand()->getGuiInterface()->refreshCash();
|
||||
for(int i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { getMyHand()->getGuiInterface()->refreshAction(i,PLAYER_ACTION_NONE); }
|
||||
for(int i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
|
||||
getMyHand()->getGuiInterface()->refreshAction(i,PLAYER_ACTION_NONE);
|
||||
}
|
||||
|
||||
getMyHand()->switchRounds();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// lastPlayersTurn -> PreflopFirstRound is over
|
||||
if( getCurrentPlayersTurnId() == getFirstRoundLastPlayersTurnId() ) {
|
||||
setFirstRound(false);
|
||||
@@ -175,8 +177,7 @@ void LocalBeRoPreflop::run() {
|
||||
if( getCurrentPlayersTurnId() == 0) {
|
||||
// Wir sind dran
|
||||
getMyHand()->getGuiInterface()->meInAction();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//Gegner sind dran
|
||||
getMyHand()->getGuiInterface()->beRoAnimation2(getMyBeRoID());
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
|
||||
class HandInterface;
|
||||
|
||||
class LocalBeRoPreflop : public LocalBeRo{
|
||||
class LocalBeRoPreflop : public LocalBeRo
|
||||
{
|
||||
|
||||
public:
|
||||
LocalBeRoPreflop(HandInterface*, int, unsigned, int);
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
class HandInterface;
|
||||
|
||||
|
||||
class LocalBeRoRiver : public LocalBeRo{
|
||||
class LocalBeRoRiver : public LocalBeRo
|
||||
{
|
||||
public:
|
||||
LocalBeRoRiver(HandInterface*, int, unsigned, int);
|
||||
~LocalBeRoRiver();
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
|
||||
class HandInterface;
|
||||
|
||||
class LocalBeRoTurn : public LocalBeRo{
|
||||
class LocalBeRoTurn : public LocalBeRo
|
||||
{
|
||||
public:
|
||||
LocalBeRoTurn(HandInterface*, int, unsigned, int);
|
||||
~LocalBeRoTurn();
|
||||
|
||||
@@ -36,13 +36,15 @@ LocalBoard::~LocalBoard()
|
||||
{
|
||||
}
|
||||
|
||||
void LocalBoard::setPlayerLists(PlayerList sl, PlayerList apl, PlayerList rpl) {
|
||||
void LocalBoard::setPlayerLists(PlayerList sl, PlayerList apl, PlayerList rpl)
|
||||
{
|
||||
seatsList = sl;
|
||||
activePlayerList = apl;
|
||||
runningPlayerList = rpl;
|
||||
}
|
||||
|
||||
void LocalBoard::collectSets() {
|
||||
void LocalBoard::collectSets()
|
||||
{
|
||||
|
||||
sets = 0;
|
||||
|
||||
@@ -53,7 +55,8 @@ void LocalBoard::collectSets() {
|
||||
|
||||
}
|
||||
|
||||
void LocalBoard::collectPot() {
|
||||
void LocalBoard::collectPot()
|
||||
{
|
||||
|
||||
pot += sets;
|
||||
sets = 0;
|
||||
@@ -65,7 +68,8 @@ void LocalBoard::collectPot() {
|
||||
|
||||
}
|
||||
|
||||
void LocalBoard::distributePot() {
|
||||
void LocalBoard::distributePot()
|
||||
{
|
||||
|
||||
winners.clear();
|
||||
|
||||
@@ -247,7 +251,8 @@ void LocalBoard::distributePot() {
|
||||
}*/
|
||||
}
|
||||
|
||||
void LocalBoard::determinePlayerNeedToShowCards() {
|
||||
void LocalBoard::determinePlayerNeedToShowCards()
|
||||
{
|
||||
|
||||
playerNeedToShowCards.clear();
|
||||
|
||||
|
||||
@@ -30,23 +30,42 @@ class PlayerInterface;
|
||||
class HandInterface;
|
||||
|
||||
|
||||
class LocalBoard : public BoardInterface{
|
||||
class LocalBoard : public BoardInterface
|
||||
{
|
||||
public:
|
||||
LocalBoard(unsigned dealerPosition);
|
||||
~LocalBoard();
|
||||
|
||||
void setPlayerLists(PlayerList, PlayerList, PlayerList);
|
||||
|
||||
void setMyCards(int* theValue) { int i; for(i=0; i<5; i++) myCards[i] = theValue[i]; }
|
||||
void getMyCards(int* theValue) { int i; for(i=0; i<5; i++) theValue[i] = myCards[i]; }
|
||||
void setMyCards(int* theValue) {
|
||||
int i;
|
||||
for(i=0; i<5; i++) myCards[i] = theValue[i];
|
||||
}
|
||||
void getMyCards(int* theValue) {
|
||||
int i;
|
||||
for(i=0; i<5; i++) theValue[i] = myCards[i];
|
||||
}
|
||||
|
||||
void setAllInCondition(bool theValue) { allInCondition = theValue; }
|
||||
void setLastActionPlayer(unsigned theValue) { lastActionPlayer = theValue; }
|
||||
void setAllInCondition(bool theValue) {
|
||||
allInCondition = theValue;
|
||||
}
|
||||
void setLastActionPlayer(unsigned theValue) {
|
||||
lastActionPlayer = theValue;
|
||||
}
|
||||
|
||||
int getPot() const { return pot;}
|
||||
void setPot(int theValue) { pot = theValue;}
|
||||
int getSets() const { return sets; }
|
||||
void setSets(int theValue) { sets = theValue; }
|
||||
int getPot() const {
|
||||
return pot;
|
||||
}
|
||||
void setPot(int theValue) {
|
||||
pot = theValue;
|
||||
}
|
||||
int getSets() const {
|
||||
return sets;
|
||||
}
|
||||
void setSets(int theValue) {
|
||||
sets = theValue;
|
||||
}
|
||||
|
||||
void collectSets() ;
|
||||
void collectPot() ;
|
||||
@@ -54,11 +73,19 @@ public:
|
||||
void distributePot();
|
||||
void determinePlayerNeedToShowCards();
|
||||
|
||||
std::list<unsigned> getWinners() const { return winners; }
|
||||
void setWinners(const std::list<unsigned> &w) { winners = w; }
|
||||
std::list<unsigned> getWinners() const {
|
||||
return winners;
|
||||
}
|
||||
void setWinners(const std::list<unsigned> &w) {
|
||||
winners = w;
|
||||
}
|
||||
|
||||
std::list<unsigned> getPlayerNeedToShowCards() const { return playerNeedToShowCards; }
|
||||
void setPlayerNeedToShowCards(const std::list<unsigned> &p) { playerNeedToShowCards = p; }
|
||||
std::list<unsigned> getPlayerNeedToShowCards() const {
|
||||
return playerNeedToShowCards;
|
||||
}
|
||||
void setPlayerNeedToShowCards(const std::list<unsigned> &p) {
|
||||
playerNeedToShowCards = p;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -248,7 +248,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
|
||||
(*it)->setMyBestHandPosition(temp5Array);
|
||||
|
||||
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 2: {
|
||||
|
||||
/* tempBoardArray[0] = 48;
|
||||
@@ -343,8 +344,10 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
|
||||
//
|
||||
// (*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
|
||||
PlayerListConstIterator it_sB, it_bB;
|
||||
@@ -375,8 +379,9 @@ void LocalHand::start() {
|
||||
it_bB = getActivePlayerIt(getCurrentBeRo()->getBigBlindPositionId());
|
||||
if(it_sB != getActivePlayerList()->end() && it_bB != getActivePlayerList()->end()) {
|
||||
myGui->logNewBlindsSetsMsg((*it_sB)->getMySet(), (*it_bB)->getMySet(), (*it_sB)->getMyName().c_str(), (*it_bB)->getMyName().c_str());
|
||||
} else {
|
||||
LOG_ERROR(__FILE__ << " (" << __LINE__ << "): Log Error: cannot find sBID or bBID");
|
||||
}
|
||||
else { LOG_ERROR(__FILE__ << " (" << __LINE__ << "): Log Error: cannot find sBID or bBID"); }
|
||||
myGui->flushLogAtHand();
|
||||
|
||||
// deal cards
|
||||
@@ -389,7 +394,8 @@ void LocalHand::start() {
|
||||
myGui->nextPlayerAnimation();
|
||||
}
|
||||
|
||||
void LocalHand::assignButtons() {
|
||||
void LocalHand::assignButtons()
|
||||
{
|
||||
|
||||
size_t i;
|
||||
PlayerListIterator it;
|
||||
@@ -475,8 +481,7 @@ void LocalHand::assignButtons() {
|
||||
// 1 to do not log this
|
||||
(*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1);
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
(*it_c)->setMySet(smallBlind);
|
||||
}
|
||||
}
|
||||
@@ -491,8 +496,7 @@ void LocalHand::assignButtons() {
|
||||
// 1 to do not log this
|
||||
(*it_c)->setMyAction(PLAYER_ACTION_ALLIN,1);
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
(*it_c)->setMySet(2*smallBlind);
|
||||
}
|
||||
}
|
||||
@@ -500,7 +504,8 @@ void LocalHand::assignButtons() {
|
||||
}
|
||||
|
||||
|
||||
void LocalHand::switchRounds() {
|
||||
void LocalHand::switchRounds()
|
||||
{
|
||||
|
||||
PlayerListIterator it, it_1;
|
||||
PlayerListConstIterator it_c;
|
||||
@@ -627,27 +632,33 @@ void LocalHand::switchRounds() {
|
||||
case 0: {
|
||||
// start preflop
|
||||
myGui->preflopAnimation1();
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 1: {
|
||||
// start flop
|
||||
myGui->flopAnimation1();
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 2: {
|
||||
// start turn
|
||||
myGui->turnAnimation1();
|
||||
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 3: {
|
||||
// start river
|
||||
myGui->riverAnimation1();
|
||||
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 4: {
|
||||
// start post river
|
||||
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;
|
||||
|
||||
@@ -669,7 +681,8 @@ PlayerListIterator LocalHand::getSeatIt(unsigned uniqueId) const {
|
||||
|
||||
}
|
||||
|
||||
PlayerListIterator LocalHand::getActivePlayerIt(unsigned uniqueId) const {
|
||||
PlayerListIterator LocalHand::getActivePlayerIt(unsigned uniqueId) const
|
||||
{
|
||||
|
||||
PlayerListIterator it;
|
||||
|
||||
@@ -683,7 +696,8 @@ PlayerListIterator LocalHand::getActivePlayerIt(unsigned uniqueId) const {
|
||||
|
||||
}
|
||||
|
||||
PlayerListIterator LocalHand::getRunningPlayerIt(unsigned uniqueId) const {
|
||||
PlayerListIterator LocalHand::getRunningPlayerIt(unsigned uniqueId) const
|
||||
{
|
||||
|
||||
PlayerListIterator it;
|
||||
|
||||
@@ -698,7 +712,8 @@ PlayerListIterator LocalHand::getRunningPlayerIt(unsigned uniqueId) const {
|
||||
|
||||
}
|
||||
|
||||
void LocalHand::setLastActionPlayer(unsigned theValue) {
|
||||
void LocalHand::setLastActionPlayer(unsigned theValue)
|
||||
{
|
||||
lastActionPlayer = theValue;
|
||||
myBoard->setLastActionPlayer(theValue);
|
||||
}
|
||||
|
||||
@@ -31,57 +31,120 @@
|
||||
|
||||
class Log;
|
||||
|
||||
class LocalHand : public HandInterface{
|
||||
class LocalHand : public HandInterface
|
||||
{
|
||||
public:
|
||||
LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface*, boost::shared_ptr<BoardInterface>, Log*, PlayerList, PlayerList, PlayerList, int, int, unsigned, int, int);
|
||||
~LocalHand();
|
||||
|
||||
void start();
|
||||
|
||||
PlayerList getSeatsList() const {return seatsList;}
|
||||
PlayerList getActivePlayerList() const {return activePlayerList;}
|
||||
PlayerList getRunningPlayerList() const {return runningPlayerList;}
|
||||
PlayerList getSeatsList() const {
|
||||
return seatsList;
|
||||
}
|
||||
PlayerList getActivePlayerList() const {
|
||||
return activePlayerList;
|
||||
}
|
||||
PlayerList getRunningPlayerList() const {
|
||||
return runningPlayerList;
|
||||
}
|
||||
|
||||
boost::shared_ptr<BoardInterface> getBoard() const { return myBoard; }
|
||||
boost::shared_ptr<BeRoInterface> getPreflop() const { return myBeRo[GAME_STATE_PREFLOP]; }
|
||||
boost::shared_ptr<BeRoInterface> getFlop() const { return myBeRo[GAME_STATE_FLOP]; }
|
||||
boost::shared_ptr<BeRoInterface> getTurn() const { return myBeRo[GAME_STATE_TURN]; }
|
||||
boost::shared_ptr<BeRoInterface> getRiver() const { return myBeRo[GAME_STATE_RIVER]; }
|
||||
GuiInterface* getGuiInterface() const { return myGui; }
|
||||
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const { return myBeRo[currentRound]; }
|
||||
boost::shared_ptr<BoardInterface> getBoard() const {
|
||||
return myBoard;
|
||||
}
|
||||
boost::shared_ptr<BeRoInterface> getPreflop() const {
|
||||
return myBeRo[GAME_STATE_PREFLOP];
|
||||
}
|
||||
boost::shared_ptr<BeRoInterface> getFlop() const {
|
||||
return myBeRo[GAME_STATE_FLOP];
|
||||
}
|
||||
boost::shared_ptr<BeRoInterface> getTurn() const {
|
||||
return myBeRo[GAME_STATE_TURN];
|
||||
}
|
||||
boost::shared_ptr<BeRoInterface> getRiver() const {
|
||||
return myBeRo[GAME_STATE_RIVER];
|
||||
}
|
||||
GuiInterface* getGuiInterface() const {
|
||||
return myGui;
|
||||
}
|
||||
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const {
|
||||
return myBeRo[currentRound];
|
||||
}
|
||||
|
||||
void setMyID(int theValue) { myID = theValue; }
|
||||
int getMyID() const { return myID; }
|
||||
void setMyID(int theValue) {
|
||||
myID = theValue;
|
||||
}
|
||||
int getMyID() const {
|
||||
return myID;
|
||||
}
|
||||
|
||||
void setStartQuantityPlayers(int theValue) { startQuantityPlayers = theValue; }
|
||||
int getStartQuantityPlayers() const { return startQuantityPlayers; }
|
||||
void setStartQuantityPlayers(int theValue) {
|
||||
startQuantityPlayers = theValue;
|
||||
}
|
||||
int getStartQuantityPlayers() const {
|
||||
return startQuantityPlayers;
|
||||
}
|
||||
|
||||
void setCurrentRound(int theValue) { currentRound = theValue; }
|
||||
int getCurrentRound() const { return currentRound; }
|
||||
void setCurrentRound(int theValue) {
|
||||
currentRound = theValue;
|
||||
}
|
||||
int getCurrentRound() const {
|
||||
return currentRound;
|
||||
}
|
||||
|
||||
void setDealerPosition(int theValue) { dealerPosition = theValue; }
|
||||
int getDealerPosition() const { return dealerPosition; }
|
||||
void setDealerPosition(int theValue) {
|
||||
dealerPosition = theValue;
|
||||
}
|
||||
int getDealerPosition() const {
|
||||
return dealerPosition;
|
||||
}
|
||||
|
||||
void setSmallBlind(int theValue) { smallBlind = theValue; }
|
||||
int getSmallBlind() const { return smallBlind; }
|
||||
void setSmallBlind(int theValue) {
|
||||
smallBlind = theValue;
|
||||
}
|
||||
int getSmallBlind() const {
|
||||
return smallBlind;
|
||||
}
|
||||
|
||||
void setAllInCondition(bool theValue) { allInCondition = theValue; }
|
||||
bool getAllInCondition() const { return allInCondition; }
|
||||
void setAllInCondition(bool theValue) {
|
||||
allInCondition = theValue;
|
||||
}
|
||||
bool getAllInCondition() const {
|
||||
return allInCondition;
|
||||
}
|
||||
|
||||
void setStartCash(int theValue) { startCash = theValue; }
|
||||
int getStartCash() const { return startCash; }
|
||||
void setStartCash(int theValue) {
|
||||
startCash = theValue;
|
||||
}
|
||||
int getStartCash() const {
|
||||
return startCash;
|
||||
}
|
||||
|
||||
void setBettingRoundsPlayed(int theValue) { bettingRoundsPlayed = theValue; }
|
||||
int getBettingRoundsPlayed() const { return bettingRoundsPlayed; }
|
||||
void setBettingRoundsPlayed(int theValue) {
|
||||
bettingRoundsPlayed = theValue;
|
||||
}
|
||||
int getBettingRoundsPlayed() const {
|
||||
return bettingRoundsPlayed;
|
||||
}
|
||||
|
||||
void setLastPlayersTurn(int theValue) { lastPlayersTurn = theValue; }
|
||||
int getLastPlayersTurn() const { return lastPlayersTurn; }
|
||||
void setLastPlayersTurn(int theValue) {
|
||||
lastPlayersTurn = theValue;
|
||||
}
|
||||
int getLastPlayersTurn() const {
|
||||
return lastPlayersTurn;
|
||||
}
|
||||
|
||||
void setLastActionPlayer ( unsigned theValue );
|
||||
unsigned getLastActionPlayer() const { return lastActionPlayer; }
|
||||
unsigned getLastActionPlayer() const {
|
||||
return lastActionPlayer;
|
||||
}
|
||||
|
||||
void setCardsShown(bool theValue) { cardsShown = theValue; }
|
||||
bool getCardsShown() const { return cardsShown; }
|
||||
void setCardsShown(bool theValue) {
|
||||
cardsShown = theValue;
|
||||
}
|
||||
bool getCardsShown() const {
|
||||
return cardsShown;
|
||||
}
|
||||
|
||||
void assignButtons();
|
||||
|
||||
|
||||
@@ -29,14 +29,12 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct RoundData
|
||||
{
|
||||
struct RoundData {
|
||||
int hand;
|
||||
double data[4];
|
||||
};
|
||||
|
||||
static const RoundData PreflopValues[] =
|
||||
{
|
||||
static const RoundData PreflopValues[] = {
|
||||
{ 0, { 0.392398, 0.276545, 0.212940, 0.178564 } },
|
||||
{ 10, { 0.341141, 0.213735, 0.153802, 0.121123 } },
|
||||
{ 11, { 0.374930, 0.252093, 0.194671, 0.161691 } },
|
||||
@@ -208,8 +206,7 @@ static const RoundData PreflopValues[] =
|
||||
{ 12120, { 0.855608, 0.736617, 0.642366, 0.562044 } }
|
||||
};
|
||||
|
||||
static const RoundData FlopValues[] =
|
||||
{
|
||||
static const RoundData FlopValues[] = {
|
||||
{ 106, { 0.160312, 0.078750, 0.048325, 0.033350 } },
|
||||
{ 206, { 0.185012, 0.099666, 0.071425, 0.053450 } },
|
||||
{ 306, { 0.199662, 0.115567, 0.081625, 0.067500 } },
|
||||
@@ -862,34 +859,44 @@ LocalPlayer::LocalPlayer(ConfigFile *c, int id, unsigned uniqueId, PlayerType ty
|
||||
|
||||
case 0: {
|
||||
myCash=4140;
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 1: {
|
||||
myCash=4940;
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 2: {
|
||||
myCash=4660;
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 3: {
|
||||
myCash=4960;
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 4: {
|
||||
myCash=5680;
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 5: {
|
||||
myCash=4960;
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 6: {
|
||||
myCash=4960;
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 7: {
|
||||
myCash=5780;
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 8: {
|
||||
myCash=4960;
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 9: {
|
||||
myCash=4960;
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
default: {
|
||||
}
|
||||
@@ -996,10 +1003,14 @@ LocalPlayer::~LocalPlayer()
|
||||
}
|
||||
|
||||
|
||||
void LocalPlayer::setHand(HandInterface* br) { currentHand = br; }
|
||||
void LocalPlayer::setHand(HandInterface* br)
|
||||
{
|
||||
currentHand = br;
|
||||
}
|
||||
|
||||
|
||||
void LocalPlayer::action() {
|
||||
void LocalPlayer::action()
|
||||
{
|
||||
|
||||
// int myOldCash = myCash;
|
||||
// int oldHighestSet = currentHand->getCurrentBeRo()->getHighestSet();
|
||||
@@ -1015,7 +1026,8 @@ void LocalPlayer::action() {
|
||||
currentHand->getBoard()->collectSets();
|
||||
currentHand->getGuiInterface()->refreshPot();
|
||||
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 1: {
|
||||
|
||||
if(myConfig->readConfigInt("EngineVersion")) flopEngine3();
|
||||
@@ -1024,7 +1036,8 @@ void LocalPlayer::action() {
|
||||
currentHand->getBoard()->collectSets();
|
||||
currentHand->getGuiInterface()->refreshPot();
|
||||
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 2: {
|
||||
|
||||
if(myConfig->readConfigInt("EngineVersion")) turnEngine3();
|
||||
@@ -1033,7 +1046,8 @@ void LocalPlayer::action() {
|
||||
currentHand->getBoard()->collectSets();
|
||||
currentHand->getGuiInterface()->refreshPot();
|
||||
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 3: {
|
||||
|
||||
if(myConfig->readConfigInt("EngineVersion")) riverEngine3();
|
||||
@@ -1042,8 +1056,10 @@ void LocalPlayer::action() {
|
||||
currentHand->getBoard()->collectSets();
|
||||
currentHand->getGuiInterface()->refreshPot();
|
||||
|
||||
} break;
|
||||
default: {}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{}
|
||||
}
|
||||
|
||||
// cout << currentHand->getCurrentBeRo()->getMinimumRaise() << endl;
|
||||
@@ -1063,17 +1079,20 @@ void LocalPlayer::action() {
|
||||
// cout << "playerID in action(): " << (*(currentHand->getCurrentBeRo()->getCurrentPlayersTurnIt()))->getMyID() << endl;
|
||||
}
|
||||
|
||||
int LocalPlayer::checkMyAction(int targetAction, int targetBet, int highestSet, int minimumRaise, int smallBlind) {
|
||||
int LocalPlayer::checkMyAction(int targetAction, int targetBet, int highestSet, int minimumRaise, int smallBlind)
|
||||
{
|
||||
|
||||
switch(targetAction) {
|
||||
case PLAYER_ACTION_FOLD: {
|
||||
return 0;
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case PLAYER_ACTION_CHECK: {
|
||||
if(getMySet() == highestSet) {
|
||||
return 0;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case PLAYER_ACTION_CALL: {
|
||||
if(getMySet() < highestSet && targetBet <= getMyCash()) {
|
||||
// not all in
|
||||
@@ -1085,22 +1104,26 @@ int LocalPlayer::checkMyAction(int targetAction, int targetBet, int highestSet,
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case PLAYER_ACTION_BET: {
|
||||
if(highestSet == 0 && targetBet <= getMyCash() && targetBet >= 2*smallBlind) {
|
||||
return 0;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case PLAYER_ACTION_RAISE: {
|
||||
if(highestSet > 0 && targetBet >= minimumRaise && targetBet <= getMyCash()) {
|
||||
return 0;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case PLAYER_ACTION_ALLIN: {
|
||||
if(targetBet == getMyCash()) {
|
||||
return 0;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
|
||||
}
|
||||
@@ -1110,7 +1133,8 @@ int LocalPlayer::checkMyAction(int targetAction, int targetBet, int highestSet,
|
||||
|
||||
}
|
||||
|
||||
void LocalPlayer::preflopEngine() {
|
||||
void LocalPlayer::preflopEngine()
|
||||
{
|
||||
|
||||
int bet = 0;
|
||||
int raise = 0;
|
||||
@@ -1253,8 +1277,7 @@ void LocalPlayer::preflopEngine() {
|
||||
if(myButton == 3 && mySet == currentHand->getCurrentBeRo()->getHighestSet()) myAction = 2;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// call
|
||||
if(myOdds >= myNiveau[0] || (mySet >= currentHand->getCurrentBeRo()->getHighestSet()/2 && myOdds >= myNiveau[0]-8)) {
|
||||
// bigBlind --> check
|
||||
@@ -1264,8 +1287,7 @@ void LocalPlayer::preflopEngine() {
|
||||
if(myCash-currentHand->getCurrentBeRo()->getHighestSet() <= (myCash*1)/5) {
|
||||
raise = myCash;
|
||||
myAction = 5;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
myAction = 3;
|
||||
}
|
||||
}
|
||||
@@ -1292,8 +1314,7 @@ void LocalPlayer::preflopEngine() {
|
||||
if(myCash-currentHand->getCurrentBeRo()->getHighestSet() <= (myCash*1)/6) {
|
||||
raise = myCash;
|
||||
myAction = 5;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
myAction = 3;
|
||||
// bigBlind --> check
|
||||
if(myButton == 3 && mySet == currentHand->getCurrentBeRo()->getHighestSet()) myAction = 2;
|
||||
@@ -1336,7 +1357,8 @@ void LocalPlayer::preflopEngine() {
|
||||
|
||||
if(DEBUG_MODE) {
|
||||
switch(myUniqueID) {
|
||||
case 0: {}
|
||||
case 0:
|
||||
{}
|
||||
break;
|
||||
case 1: {
|
||||
// player 1
|
||||
@@ -1464,7 +1486,8 @@ void LocalPlayer::preflopEngine() {
|
||||
// }
|
||||
}
|
||||
break;
|
||||
default: {}
|
||||
default:
|
||||
{}
|
||||
}
|
||||
|
||||
|
||||
@@ -1475,7 +1498,8 @@ void LocalPlayer::preflopEngine() {
|
||||
}
|
||||
|
||||
|
||||
void LocalPlayer::flopEngine() {
|
||||
void LocalPlayer::flopEngine()
|
||||
{
|
||||
|
||||
int raise = 0;
|
||||
int bet = 0;
|
||||
@@ -1605,24 +1629,21 @@ void LocalPlayer::flopEngine() {
|
||||
if(cBluff > 70 && myOdds >= myNiveau[2] + 8) myAction = 3;
|
||||
if(cBluff > 60 && myOdds >= myNiveau[2] + 12) myAction = 3;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// call -> über niveau0, schon einiges gesetzt im flop, schon einiges insgesamt gesetzt
|
||||
if(myOdds >= myNiveau[0] || (mySet >= currentHand->getCurrentBeRo()->getHighestSet()/2 && myOdds >= myNiveau[0]-5) || (myRoundStartCash-myCash > individualHighestSet && myNiveau[0]-3)) {
|
||||
// all in bei knappem call
|
||||
if(currentHand->getCurrentBeRo()->getHighestSet() > (myCash*3.0)/4.0) {
|
||||
raise = myCash;
|
||||
myAction = 5;
|
||||
}
|
||||
else myAction = 3;
|
||||
} else myAction = 3;
|
||||
}
|
||||
// fold
|
||||
else {
|
||||
myAction = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// bet
|
||||
if(myOdds >= myNiveau[1]) {
|
||||
bet = (((int)myOdds-myNiveau[1])/8)*2*currentHand->getSmallBlind();
|
||||
@@ -1708,8 +1729,7 @@ void LocalPlayer::flopEngine() {
|
||||
myAction = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(sBluffStatus && myOdds < myNiveau[1]) {
|
||||
|
||||
// cout << "sBLUFF!" << endl;
|
||||
@@ -1747,7 +1767,8 @@ void LocalPlayer::flopEngine() {
|
||||
// if(currentHand->getCurrentBeRo()->getHighestSet() > 0) {
|
||||
// myAction = PLAYER_ACTION_CALL;
|
||||
// }
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 2: {
|
||||
// myAction = PLAYER_ACTION_BET;
|
||||
// raise = 25;
|
||||
@@ -1897,7 +1918,8 @@ void LocalPlayer::flopEngine() {
|
||||
myAction = PLAYER_ACTION_CHECK;
|
||||
}
|
||||
break;
|
||||
default: {}
|
||||
default:
|
||||
{}
|
||||
}
|
||||
|
||||
|
||||
@@ -2164,7 +2186,8 @@ void LocalPlayer::flopEngine() {
|
||||
}
|
||||
|
||||
|
||||
void LocalPlayer::turnEngine() {
|
||||
void LocalPlayer::turnEngine()
|
||||
{
|
||||
|
||||
// int tempArray[6];
|
||||
// int boardCards[5];
|
||||
@@ -2306,16 +2329,14 @@ void LocalPlayer::turnEngine() {
|
||||
if(cBluff > 80 && myOdds >= myNiveau[2] + 5) myAction = 3;
|
||||
if(cBluff > 70 && myOdds >= myNiveau[2] + 10) myAction = 3;
|
||||
if(cBluff > 60 && myOdds >= myNiveau[2] + 15) myAction = 3;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// call -> über niveau0, schon einiges gesetzt im flop, schon einiges insgesamt gesetzt
|
||||
if(myOdds >= myNiveau[0] || (mySet >= currentHand->getCurrentBeRo()->getHighestSet()/2 && myOdds >= myNiveau[0]-5) || (myRoundStartCash-myCash > individualHighestSet && myNiveau[0]-3)) {
|
||||
// all in bei knappem call
|
||||
if(currentHand->getCurrentBeRo()->getHighestSet() > (myCash*3.0)/4.0) {
|
||||
raise = myCash;
|
||||
myAction = 5;
|
||||
}
|
||||
else myAction = 3;
|
||||
} else myAction = 3;
|
||||
}
|
||||
// fold
|
||||
else {
|
||||
@@ -2408,8 +2429,7 @@ void LocalPlayer::turnEngine() {
|
||||
myAction = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(sBluffStatus && myOdds < myNiveau[1]) {
|
||||
|
||||
// cout << "sBLUFF!" << endl;
|
||||
@@ -2668,7 +2688,8 @@ void LocalPlayer::turnEngine() {
|
||||
|
||||
}
|
||||
break;
|
||||
default: {}
|
||||
default:
|
||||
{}
|
||||
}
|
||||
|
||||
|
||||
@@ -2691,7 +2712,8 @@ void LocalPlayer::turnEngine() {
|
||||
}
|
||||
|
||||
|
||||
void LocalPlayer::riverEngine() {
|
||||
void LocalPlayer::riverEngine()
|
||||
{
|
||||
|
||||
// int tempArray[6];
|
||||
// int boardCards[5];
|
||||
@@ -2823,24 +2845,21 @@ void LocalPlayer::riverEngine() {
|
||||
}
|
||||
myAction = 5;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// call -> über niveau0, schon einiges gesetzt im flop, schon einiges insgesamt gesetzt
|
||||
if(myOdds >= myNiveau[0] || (mySet >= currentHand->getCurrentBeRo()->getHighestSet()/2 && myOdds >= myNiveau[0]-5) || (myRoundStartCash-myCash > individualHighestSet && myNiveau[0]-3)) {
|
||||
// all in bei knappem call
|
||||
if(myCash-currentHand->getCurrentBeRo()->getHighestSet() <= (myCash*1)/4) {
|
||||
raise = myCash;
|
||||
myAction = 5;
|
||||
}
|
||||
else myAction = 3;
|
||||
} else myAction = 3;
|
||||
}
|
||||
// fold
|
||||
else {
|
||||
myAction = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// bet
|
||||
if(myOdds >= myNiveau[1]) {
|
||||
bet = (((int)myOdds-myNiveau[1])/3)*2*currentHand->getSmallBlind();
|
||||
@@ -2922,8 +2941,7 @@ void LocalPlayer::riverEngine() {
|
||||
myAction = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(sBluffStatus && myOdds < myNiveau[1]) {
|
||||
|
||||
// cout << "sBLUFF!" << endl;
|
||||
@@ -2961,7 +2979,8 @@ void LocalPlayer::riverEngine() {
|
||||
// if(currentHand->getCurrentBeRo()->getHighestSet() > 60) {
|
||||
// myAction = PLAYER_ACTION_CALL;
|
||||
// }
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
case 2: {
|
||||
// myAction = PLAYER_ACTION_BET;
|
||||
// raise = 25;
|
||||
@@ -3179,7 +3198,8 @@ void LocalPlayer::riverEngine() {
|
||||
|
||||
}
|
||||
break;
|
||||
default: {}
|
||||
default:
|
||||
{}
|
||||
}
|
||||
|
||||
|
||||
@@ -3193,7 +3213,8 @@ void LocalPlayer::riverEngine() {
|
||||
}
|
||||
|
||||
|
||||
void LocalPlayer::evaluation(int bet, int raise) {
|
||||
void LocalPlayer::evaluation(int bet, int raise)
|
||||
{
|
||||
|
||||
|
||||
int highestSet = 0;
|
||||
@@ -3204,13 +3225,16 @@ void LocalPlayer::evaluation(int bet, int raise) {
|
||||
// cout << "myAction(evaluation): " << myAction << endl;
|
||||
switch(myAction) {
|
||||
// none
|
||||
case 0: {}
|
||||
case 0:
|
||||
{}
|
||||
break;
|
||||
// fold
|
||||
case 1: {}
|
||||
case 1:
|
||||
{}
|
||||
break;
|
||||
// check
|
||||
case 2: {}
|
||||
case 2:
|
||||
{}
|
||||
break;
|
||||
// call
|
||||
case 3: {
|
||||
@@ -3270,8 +3294,7 @@ void LocalPlayer::evaluation(int bet, int raise) {
|
||||
mySet = highestSet;
|
||||
myAction = 3;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(raise < currentHand->getCurrentBeRo()->getMinimumRaise()) {
|
||||
raise = currentHand->getCurrentBeRo()->getMinimumRaise();
|
||||
}
|
||||
@@ -3320,9 +3343,11 @@ void LocalPlayer::evaluation(int bet, int raise) {
|
||||
}
|
||||
break;
|
||||
// all in
|
||||
case 6: {}
|
||||
case 6:
|
||||
{}
|
||||
break;
|
||||
default: {}
|
||||
default:
|
||||
{}
|
||||
}
|
||||
|
||||
// cout << "highestSet(ende evaluation): " << highestSet << endl;
|
||||
@@ -3334,7 +3359,8 @@ void LocalPlayer::evaluation(int bet, int raise) {
|
||||
}
|
||||
|
||||
|
||||
int LocalPlayer::flopCardsValue(int* cards) {
|
||||
int LocalPlayer::flopCardsValue(int* cards)
|
||||
{
|
||||
|
||||
int array[5][3];
|
||||
int j1, j2, j3, j4, j5, k1, k2, ktemp[3];
|
||||
@@ -3393,8 +3419,7 @@ int LocalPlayer::flopCardsValue(int* cards) {
|
||||
if(array[0][1]-4 == array[4][1]) {
|
||||
// cout << "Straight Flush";
|
||||
return 80000;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Straight Flush Ausnahme: 5-4-3-2-A
|
||||
if(array[0][1]==12 && array[1][1]==3 && array[2][1]==2 && array[3][1]==1 && array[4][1]==0) {
|
||||
// cout << "Straight Flush Ass unten";
|
||||
@@ -3430,8 +3455,7 @@ int LocalPlayer::flopCardsValue(int* cards) {
|
||||
}
|
||||
return (70000 + temp*100 + array[j1][1]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Bauchschuss ?
|
||||
if(array[j1][1]-4 == array[j1+3][1]) {
|
||||
// cout << "Straight-Flush-Bauchschuss";
|
||||
@@ -3439,8 +3463,7 @@ int LocalPlayer::flopCardsValue(int* cards) {
|
||||
if(array[j1+j2][2] <= 1) temp++;
|
||||
}
|
||||
return (71000 + temp*100 + array[j1][1]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Test auf Straight-Flush-Ausnahme 5-4-3-2-A
|
||||
if(array[j1][1] == 12 && (array[j1+1][1]<=3 || (array[j1+2][1]<=3 && array[j1][0]==array[j1+4][0]))) {
|
||||
// cout << "Straight-Flush-Draw Ass unten";
|
||||
@@ -3671,8 +3694,7 @@ int LocalPlayer::flopCardsValue(int* cards) {
|
||||
if(j5 != j1 && j5 != j2 && j5 != j3 && j5 != j4) {
|
||||
if(array[j5][1] < array[j4][1]) {
|
||||
temp2 = 0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
temp2 = 1;
|
||||
}
|
||||
}
|
||||
@@ -3682,8 +3704,7 @@ int LocalPlayer::flopCardsValue(int* cards) {
|
||||
}
|
||||
breakLoop = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Bauchschuss ?
|
||||
if((array[j1][1]-2 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-1 == array[j2][1] && array[j2][1]-2 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-1 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-2 == array[j4][1])) {
|
||||
// cout << "Straight-Draw Bauchschuss";
|
||||
@@ -3749,8 +3770,7 @@ int LocalPlayer::flopCardsValue(int* cards) {
|
||||
if(j5 != j1 && j5 != j2 && j5 != j3 && j5 != j4) {
|
||||
if(array[j5][1] < array[j4][1]) {
|
||||
temp2 = 0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
temp2 = 1;
|
||||
}
|
||||
}
|
||||
@@ -3759,8 +3779,7 @@ int LocalPlayer::flopCardsValue(int* cards) {
|
||||
tempValue = (40000 + (temp1+1)*1000 + temp2*100 + array[j1][1]);
|
||||
}
|
||||
breakLoop = 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Test auf Straßenansatz-Ausnahme 5-4-3-2-A
|
||||
if(array[j1][1] == 12 && ((array[j1][1]-9 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-9 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-2 == array[j4][1]) || (array[j1][1]-9 == array[j2][1] && array[j2][1]-2 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-10 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]))) {
|
||||
// cout << "Straight-Draw Ass unten";
|
||||
@@ -3876,8 +3895,7 @@ int LocalPlayer::flopCardsValue(int* cards) {
|
||||
if(temp == 2) {
|
||||
if(temp2Array[0] != temp2Array[1]) {
|
||||
return (22200 + temp2Array[0]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(temp2Array[0] == array[j1][1]) {
|
||||
return (22100 + temp2Array[0]);
|
||||
} else {
|
||||
@@ -3936,8 +3954,7 @@ int LocalPlayer::flopCardsValue(int* cards) {
|
||||
return (10000 + temp2*100 + temp1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// STraight (==4)
|
||||
if(((int)(tempValue/10000)) == 4) {
|
||||
return (((int)(tempValue/1000))*1000 + 200+ (tempValue - ((int)(tempValue/100))*100));
|
||||
@@ -3976,7 +3993,8 @@ int LocalPlayer::flopCardsValue(int* cards) {
|
||||
}
|
||||
|
||||
|
||||
void LocalPlayer::calcMyOdds() {
|
||||
void LocalPlayer::calcMyOdds()
|
||||
{
|
||||
|
||||
int handCode;
|
||||
|
||||
@@ -4155,7 +4173,8 @@ void LocalPlayer::calcMyOdds() {
|
||||
|
||||
}
|
||||
break;
|
||||
default: LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR - wrong init of currentRound");
|
||||
default:
|
||||
LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR - wrong init of currentRound");
|
||||
|
||||
|
||||
}
|
||||
@@ -4174,7 +4193,8 @@ void LocalPlayer::calcMyOdds() {
|
||||
|
||||
|
||||
|
||||
int LocalPlayer::turnCardsValue(int* cards) {
|
||||
int LocalPlayer::turnCardsValue(int* cards)
|
||||
{
|
||||
|
||||
int array[6][3];
|
||||
int j1, j2, j3, j4, j5, k1, k2, ktemp[3];
|
||||
@@ -4230,8 +4250,7 @@ int LocalPlayer::turnCardsValue(int* cards) {
|
||||
// cout << "Straight Flush" << endl;
|
||||
// -> Sieg -> alles mitgehen
|
||||
return 100;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Straight Flush Ausnahme: 5-4-3-2-A
|
||||
for(j2=j1+1; j2<3; j2++) {
|
||||
if(array[j1][1]-9==array[j2][1] && array[j2][1]-1==array[j2+1][1] && array[j2+1][1]-1==array[j2+2][1] && array[j2+2][1]-1==array[j2+3][1] && array[j1][0]==array[j2+2][0] && array[j1][0]==array[j2+3][0]) {
|
||||
@@ -4270,14 +4289,12 @@ int LocalPlayer::turnCardsValue(int* cards) {
|
||||
// cout << "zusammenhaengender Straight-Flush-Draw in der Mitte ";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Bauchschuss ?
|
||||
if(array[j1][1]-4 == array[j1+3][1]) {
|
||||
// cout << "Straight-Flush-Bauchschuss ";
|
||||
break;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Test auf Straight-Flush-Ausnahme 5-4-3-2-A
|
||||
if(array[j1][1] == 12 && (array[j1+1][1]<=3 || (array[j1+2][1]<=3 && array[j1][0]==array[j1+4][0]) || (array[j1+3][1]<=3 && array[j1][0]==array[j1+4][0] && array[j1][0]==array[j1+4][0]))) {
|
||||
// cout << "Straight-Flush-Draw Ass unten ";
|
||||
@@ -4362,14 +4379,12 @@ int LocalPlayer::turnCardsValue(int* cards) {
|
||||
// cout << "zusammenhaengender Straight-Draw in der Mitte ";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Bauchschuss ?
|
||||
if((array[j1][1]-2 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-1 == array[j2][1] && array[j2][1]-2 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-1 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-2 == array[j4][1])) {
|
||||
// cout << "Straight-Bauchschuss ";
|
||||
break;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Test auf Straßenansatz-Ausnahme 5-4-3-2-A
|
||||
if((array[j1][1]-9 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-9 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-2 == array[j4][1]) || (array[j1][1]-9 == array[j2][1] && array[j2][1]-2 == array[j3][1] && array[j3][1]-1 == array[j4][1]) || (array[j1][1]-10 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1])) {
|
||||
// cout << "Straight-Draw Ass unten ";
|
||||
@@ -4424,7 +4439,8 @@ int LocalPlayer::turnCardsValue(int* cards) {
|
||||
|
||||
|
||||
|
||||
void LocalPlayer::preflopEngine3() {
|
||||
void LocalPlayer::preflopEngine3()
|
||||
{
|
||||
|
||||
// cout << "nextID " << currentHand->getPlayerArray()[(myID+1)%5]->getMyID() << endl;
|
||||
|
||||
@@ -4452,8 +4468,7 @@ void LocalPlayer::preflopEngine3() {
|
||||
// FOLD --> wenn Potential negativ oder HighestSet zu hoch
|
||||
if( (potential*setToHighest<0 || (setToHighest > tempFold * currentHand->getSmallBlind() && potential<1) || (setToHighest > 2 * tempFold * currentHand->getSmallBlind() && potential<2) || (setToHighest > 4 * tempFold * currentHand->getSmallBlind() && potential<3) || (setToHighest > 10 * tempFold * currentHand->getSmallBlind() && potential<4)) && myCardsValue->holeCardsClass(myCards[0], myCards[1]) < 9 && bluff > 15) {
|
||||
myAction=1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// RAISE --> wenn hohes Potential
|
||||
if((potential >= 4 && 6 * currentHand->getSmallBlind() >= currentHand->getCurrentBeRo()->getHighestSet()) || bluff <= 6) {
|
||||
int raise = 0;
|
||||
@@ -4463,8 +4478,7 @@ void LocalPlayer::preflopEngine3() {
|
||||
// bluff - raise
|
||||
if(bluff <=2 && 4 * currentHand->getSmallBlind() > currentHand->getCurrentBeRo()->getHighestSet()) {
|
||||
raise = 3 * currentHand->getCurrentBeRo()->getHighestSet();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// bluff - call
|
||||
if(bluff >= 98) {
|
||||
// All In
|
||||
@@ -4500,8 +4514,7 @@ void LocalPlayer::preflopEngine3() {
|
||||
myAction = 3;
|
||||
}
|
||||
|
||||
}
|
||||
else raise = (potential - 4 ) * 2 * currentHand->getCurrentBeRo()->getHighestSet();
|
||||
} else raise = (potential - 4 ) * 2 * currentHand->getCurrentBeRo()->getHighestSet();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4510,8 +4523,7 @@ void LocalPlayer::preflopEngine3() {
|
||||
// bluff - raise
|
||||
if(bluff <= 6 && 4 * currentHand->getSmallBlind() > currentHand->getCurrentBeRo()->getHighestSet()) {
|
||||
raise = 2*currentHand->getCurrentBeRo()->getHighestSet();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// bluff - call
|
||||
if(bluff >= 93) {
|
||||
|
||||
@@ -4529,8 +4541,7 @@ void LocalPlayer::preflopEngine3() {
|
||||
mySet = currentHand->getCurrentBeRo()->getHighestSet();
|
||||
myAction = 3;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// doch nich raisen, sondern nur checken, weil highestSets bereits sehr hoch !!!
|
||||
if(! (4 * currentHand->getSmallBlind() > currentHand->getCurrentBeRo()->getHighestSet())) {
|
||||
|
||||
@@ -4548,8 +4559,7 @@ void LocalPlayer::preflopEngine3() {
|
||||
mySet = currentHand->getCurrentBeRo()->getHighestSet();
|
||||
myAction = 3;
|
||||
}
|
||||
}
|
||||
else raise = (potential - 3 ) * currentHand->getCurrentBeRo()->getHighestSet();
|
||||
} else raise = (potential - 3 ) * currentHand->getCurrentBeRo()->getHighestSet();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4601,7 +4611,8 @@ void LocalPlayer::preflopEngine3() {
|
||||
}
|
||||
}
|
||||
|
||||
void LocalPlayer::flopEngine3() {
|
||||
void LocalPlayer::flopEngine3()
|
||||
{
|
||||
|
||||
// Prozent ausrechnen
|
||||
|
||||
@@ -4684,8 +4695,7 @@ void LocalPlayer::flopEngine3() {
|
||||
// FOLD --> wenn potential negativ oder HighestSet zu hoch
|
||||
if(( potential*setToHighest<0 || (setToHighest > tempFold * currentHand->getSmallBlind() && potential<1) || (setToHighest > 3 * tempFold * currentHand->getSmallBlind() && potential<2) || (setToHighest > 9 * tempFold * currentHand->getSmallBlind() && potential<3) || (setToHighest > 20*tempFold * currentHand->getSmallBlind() && potential<4) || (setToHighest > 40 *tempFold * currentHand->getSmallBlind() && potential<5)) && percent < 0.90 && bluff > 18) {
|
||||
myAction=1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// CHECK und BET --> wenn noch keiner was gesetzt hat
|
||||
if(currentHand->getCurrentBeRo()->getHighestSet() == 0) {
|
||||
// CHECK --> wenn Potential klein oder check-bluff sonst bet oder bet-bluff
|
||||
@@ -4772,7 +4782,8 @@ void LocalPlayer::flopEngine3() {
|
||||
|
||||
}
|
||||
|
||||
void LocalPlayer::turnEngine3() {
|
||||
void LocalPlayer::turnEngine3()
|
||||
{
|
||||
|
||||
// Prozent ausrechnen
|
||||
|
||||
@@ -4851,8 +4862,7 @@ void LocalPlayer::turnEngine3() {
|
||||
// --> wenn potential negativ oder HighestSet zu hoch
|
||||
if( (potential*setToHighest<0 || (setToHighest > tempFold * currentHand->getSmallBlind() && potential<1) || (setToHighest > 3 * tempFold * currentHand->getSmallBlind() && potential<2) || (setToHighest > 9 * tempFold * currentHand->getSmallBlind() && potential<3) || (setToHighest > 20*tempFold * currentHand->getSmallBlind() && potential<4) || (setToHighest > 40 *tempFold * currentHand->getSmallBlind() && potential<5)) && percent < 0.90 && bluff > 15) {
|
||||
myAction=1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// CHECK und BET --> wenn noch keiner was gesetzt hat
|
||||
if(currentHand->getCurrentBeRo()->getHighestSet() == 0) {
|
||||
// CHECK --> wenn Potential klein
|
||||
@@ -4938,7 +4948,8 @@ void LocalPlayer::turnEngine3() {
|
||||
|
||||
}
|
||||
|
||||
void LocalPlayer::riverEngine3() {
|
||||
void LocalPlayer::riverEngine3()
|
||||
{
|
||||
|
||||
// Prozent ausrechnen
|
||||
|
||||
@@ -5013,8 +5024,7 @@ void LocalPlayer::riverEngine3() {
|
||||
// --> wenn potential negativ oder HighestSet zu hoch
|
||||
if( (potential*setToHighest<0 || (setToHighest > tempFold * currentHand->getSmallBlind() && potential<1) || (setToHighest > 3 * tempFold * currentHand->getSmallBlind() && potential<2) || (setToHighest > 9 * tempFold * currentHand->getSmallBlind() && potential<3) || (setToHighest > 20*tempFold * currentHand->getSmallBlind() && potential<4) || (setToHighest > 40 *tempFold * currentHand->getSmallBlind() && potential<5)) && percent < 0.90 && bluff > 15) {
|
||||
myAction=1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// CHECK und BET --> wenn noch keiner was gesetzt hat
|
||||
if(currentHand->getCurrentBeRo()->getHighestSet() == 0) {
|
||||
// CHECK --> wenn Potential klein
|
||||
@@ -5131,8 +5141,7 @@ LocalPlayer::resetActionTimeoutCounter()
|
||||
bool LocalPlayer::checkIfINeedToShowCards()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ class CardsValue;
|
||||
class ConfigFile;
|
||||
class HandInterface;
|
||||
|
||||
class LocalPlayer : public PlayerInterface{
|
||||
class LocalPlayer : public PlayerInterface
|
||||
{
|
||||
public:
|
||||
LocalPlayer(ConfigFile*, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB);
|
||||
|
||||
@@ -38,92 +39,178 @@ public:
|
||||
|
||||
void setHand(HandInterface *);
|
||||
|
||||
int getMyID() const { return myID; }
|
||||
unsigned getMyUniqueID() const { return myUniqueID; }
|
||||
PlayerType getMyType() const { return myType; }
|
||||
int getMyID() const {
|
||||
return myID;
|
||||
}
|
||||
unsigned getMyUniqueID() const {
|
||||
return myUniqueID;
|
||||
}
|
||||
PlayerType getMyType() const {
|
||||
return myType;
|
||||
}
|
||||
|
||||
void setMyDude(int theValue) { myDude = theValue; }
|
||||
int getMyDude() const { return myDude; }
|
||||
void setMyDude(int theValue) {
|
||||
myDude = theValue;
|
||||
}
|
||||
int getMyDude() const {
|
||||
return myDude;
|
||||
}
|
||||
|
||||
void setMyDude4(int theValue) { myDude4 = theValue; }
|
||||
int getMyDude4() const { return myDude4; }
|
||||
void setMyDude4(int theValue) {
|
||||
myDude4 = theValue;
|
||||
}
|
||||
int getMyDude4() const {
|
||||
return myDude4;
|
||||
}
|
||||
|
||||
void setMyName(const std::string& theValue) { myName = theValue; }
|
||||
std::string getMyName() const { return myName; }
|
||||
void setMyName(const std::string& theValue) {
|
||||
myName = theValue;
|
||||
}
|
||||
std::string getMyName() const {
|
||||
return myName;
|
||||
}
|
||||
|
||||
void setMyAvatar(const std::string& theValue) { myAvatar = theValue; }
|
||||
std::string getMyAvatar() const { return myAvatar; }
|
||||
void setMyAvatar(const std::string& theValue) {
|
||||
myAvatar = theValue;
|
||||
}
|
||||
std::string getMyAvatar() const {
|
||||
return myAvatar;
|
||||
}
|
||||
|
||||
void setMyCash(int theValue) { myCash = theValue; }
|
||||
int getMyCash() const { return myCash; }
|
||||
void setMyCash(int theValue) {
|
||||
myCash = theValue;
|
||||
}
|
||||
int getMyCash() const {
|
||||
return myCash;
|
||||
}
|
||||
|
||||
void setMySet(int theValue) { myLastRelativeSet = theValue; mySet += theValue; myCash -= theValue; }
|
||||
void setMySetAbsolute(int theValue) { mySet = theValue; }
|
||||
void setMySetNull() { mySet = 0; myLastRelativeSet = 0; }
|
||||
int getMySet() const { return mySet;}
|
||||
int getMyLastRelativeSet() const { return myLastRelativeSet; }
|
||||
void setMySet(int theValue) {
|
||||
myLastRelativeSet = theValue;
|
||||
mySet += theValue;
|
||||
myCash -= theValue;
|
||||
}
|
||||
void setMySetAbsolute(int theValue) {
|
||||
mySet = theValue;
|
||||
}
|
||||
void setMySetNull() {
|
||||
mySet = 0;
|
||||
myLastRelativeSet = 0;
|
||||
}
|
||||
int getMySet() const {
|
||||
return mySet;
|
||||
}
|
||||
int getMyLastRelativeSet() const {
|
||||
return myLastRelativeSet;
|
||||
}
|
||||
|
||||
void setMyAction(int theValue, bool blind = 0) {
|
||||
myAction = theValue;
|
||||
// logging for human player
|
||||
if(myAction && !blind) currentHand->getGuiInterface()->logPlayerActionMsg(myName, myID, myAction, mySet);
|
||||
}
|
||||
int getMyAction() const { return myAction; }
|
||||
int getMyAction() const {
|
||||
return myAction;
|
||||
}
|
||||
|
||||
void setMyButton(int theValue) { myButton = theValue; }
|
||||
int getMyButton() const { return myButton; }
|
||||
void setMyButton(int theValue) {
|
||||
myButton = theValue;
|
||||
}
|
||||
int getMyButton() const {
|
||||
return myButton;
|
||||
}
|
||||
|
||||
void setMyActiveStatus(bool theValue) { myActiveStatus = theValue; }
|
||||
bool getMyActiveStatus() const { return myActiveStatus; }
|
||||
void setMyActiveStatus(bool theValue) {
|
||||
myActiveStatus = theValue;
|
||||
}
|
||||
bool getMyActiveStatus() const {
|
||||
return myActiveStatus;
|
||||
}
|
||||
|
||||
void setMyStayOnTableStatus(bool theValue) { myStayOnTableStatus = theValue; }
|
||||
bool getMyStayOnTableStatus() const { return myStayOnTableStatus; }
|
||||
void setMyStayOnTableStatus(bool theValue) {
|
||||
myStayOnTableStatus = theValue;
|
||||
}
|
||||
bool getMyStayOnTableStatus() const {
|
||||
return myStayOnTableStatus;
|
||||
}
|
||||
|
||||
void setMyCards(int* theValue) { int i; for(i=0; i<2; i++) myCards[i] = theValue[i]; }
|
||||
void getMyCards(int* theValue) const { int i; for(i=0; i<2; i++) theValue[i] = myCards[i]; }
|
||||
void setMyCards(int* theValue) {
|
||||
int i;
|
||||
for(i=0; i<2; i++) myCards[i] = theValue[i];
|
||||
}
|
||||
void getMyCards(int* theValue) const {
|
||||
int i;
|
||||
for(i=0; i<2; i++) theValue[i] = myCards[i];
|
||||
}
|
||||
|
||||
void setMyTurn(bool theValue){ myTurn = theValue;}
|
||||
bool getMyTurn() const{ return myTurn;}
|
||||
void setMyTurn(bool theValue) {
|
||||
myTurn = theValue;
|
||||
}
|
||||
bool getMyTurn() const {
|
||||
return myTurn;
|
||||
}
|
||||
|
||||
void setMyCardsFlip(bool theValue, int state) {
|
||||
myCardsFlip = theValue;
|
||||
// log flipping cards
|
||||
if(myCardsFlip) {
|
||||
switch(state) {
|
||||
case 1: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt);
|
||||
case 1:
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt);
|
||||
break;
|
||||
case 2: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]);
|
||||
case 2:
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]);
|
||||
break;
|
||||
case 3: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt, "has");
|
||||
case 3:
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt, "has");
|
||||
break;
|
||||
default: ;
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool getMyCardsFlip() const{ return myCardsFlip;}
|
||||
bool getMyCardsFlip() const {
|
||||
return myCardsFlip;
|
||||
}
|
||||
|
||||
void setMyCardsValueInt(int theValue) { myCardsValueInt = theValue;}
|
||||
int getMyCardsValueInt() const { return myCardsValueInt; }
|
||||
void setMyCardsValueInt(int theValue) {
|
||||
myCardsValueInt = theValue;
|
||||
}
|
||||
int getMyCardsValueInt() const {
|
||||
return myCardsValueInt;
|
||||
}
|
||||
|
||||
void setMyBestHandPosition(int* theValue)
|
||||
{
|
||||
void setMyBestHandPosition(int* theValue) {
|
||||
for (int i = 0; i < 5; i++)
|
||||
myBestHandPosition[i] = theValue[i];
|
||||
}
|
||||
void getMyBestHandPosition(int* theValue) const
|
||||
{
|
||||
void getMyBestHandPosition(int* theValue) const {
|
||||
for (int i = 0; i < 5; i++)
|
||||
theValue[i] = myBestHandPosition[i];
|
||||
}
|
||||
|
||||
void setMyRoundStartCash(int theValue) { myRoundStartCash = theValue;}
|
||||
int getMyRoundStartCash() const { return myRoundStartCash; }
|
||||
void setMyRoundStartCash(int theValue) {
|
||||
myRoundStartCash = theValue;
|
||||
}
|
||||
int getMyRoundStartCash() const {
|
||||
return myRoundStartCash;
|
||||
}
|
||||
|
||||
void setLastMoneyWon ( int theValue ) { lastMoneyWon = theValue; }
|
||||
int getLastMoneyWon() const { return lastMoneyWon; }
|
||||
void setLastMoneyWon ( int theValue ) {
|
||||
lastMoneyWon = theValue;
|
||||
}
|
||||
int getLastMoneyWon() const {
|
||||
return lastMoneyWon;
|
||||
}
|
||||
|
||||
void setMyAverageSets(int theValue) { myAverageSets[0] = myAverageSets[1]; myAverageSets[1] = myAverageSets[2]; myAverageSets[2] = myAverageSets[3]; myAverageSets[3] = theValue; }
|
||||
int getMyAverageSets() const { return (myAverageSets[0]+myAverageSets[1]+myAverageSets[2]+myAverageSets[3])/4; }
|
||||
void setMyAverageSets(int theValue) {
|
||||
myAverageSets[0] = myAverageSets[1];
|
||||
myAverageSets[1] = myAverageSets[2];
|
||||
myAverageSets[2] = myAverageSets[3];
|
||||
myAverageSets[3] = theValue;
|
||||
}
|
||||
int getMyAverageSets() const {
|
||||
return (myAverageSets[0]+myAverageSets[1]+myAverageSets[2]+myAverageSets[3])/4;
|
||||
}
|
||||
|
||||
void setMyAggressive(bool theValue) {
|
||||
int i;
|
||||
@@ -140,17 +227,27 @@ public:
|
||||
return sum;
|
||||
}
|
||||
|
||||
void setSBluff ( int theValue ) { sBluff = theValue; }
|
||||
int getSBluff() const { return sBluff; }
|
||||
void setSBluff ( int theValue ) {
|
||||
sBluff = theValue;
|
||||
}
|
||||
int getSBluff() const {
|
||||
return sBluff;
|
||||
}
|
||||
|
||||
void setSBluffStatus ( bool theValue ) { sBluffStatus = theValue; }
|
||||
bool getSBluffStatus() const { return sBluffStatus; }
|
||||
void setSBluffStatus ( bool theValue ) {
|
||||
sBluffStatus = theValue;
|
||||
}
|
||||
bool getSBluffStatus() const {
|
||||
return sBluffStatus;
|
||||
}
|
||||
|
||||
void setMyWinnerState ( bool theValue, int pot ) {
|
||||
if(theValue) myWinnerState = theValue;
|
||||
currentHand->getGuiInterface()->logPlayerWinsMsg(myName, pot, theValue);
|
||||
}
|
||||
bool getMyWinnerState() const { return myWinnerState;}
|
||||
bool getMyWinnerState() const {
|
||||
return myWinnerState;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool different, int* bad, int countBad) {
|
||||
void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool different, int* bad, int countBad)
|
||||
{
|
||||
|
||||
int r = end-start+1;
|
||||
unsigned char rand_buf[4];
|
||||
@@ -39,8 +40,7 @@ void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool
|
||||
|
||||
for (i=0; i<howMany; i++) {
|
||||
|
||||
if(!RAND_bytes(rand_buf, 4))
|
||||
{
|
||||
if(!RAND_bytes(rand_buf, 4)) {
|
||||
LOG_MSG("RAND_bytes failed!");
|
||||
}
|
||||
|
||||
@@ -54,8 +54,7 @@ void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
int *tempArray = new int[end-start+1];
|
||||
for (i=0; i<(end-start+1); i++) tempArray[i]=1;
|
||||
@@ -69,8 +68,7 @@ void Tools::getRandNumber(int start, int end, int howMany, int* randArray, bool
|
||||
int counter(0);
|
||||
while (counter < howMany) {
|
||||
|
||||
if(!RAND_bytes(rand_buf, 4))
|
||||
{
|
||||
if(!RAND_bytes(rand_buf, 4)) {
|
||||
LOG_MSG("RAND_bytes failed!");
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
#ifndef TOOLS_H
|
||||
#define TOOLS_H
|
||||
|
||||
class Tools{
|
||||
class Tools
|
||||
{
|
||||
public:
|
||||
static void getRandNumber(int, int, int, int*, bool, int* = 0, int = 0);
|
||||
|
||||
|
||||
+4
-2
@@ -166,7 +166,8 @@ Log::~Log()
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -213,7 +214,8 @@ Log::logNewGameMsg(int gameID, int startCash, int startSmallBlind, unsigned deal
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ class HandInterface;
|
||||
/**
|
||||
@author FThauer FHammer <webmaster@pokerth.net>
|
||||
*/
|
||||
class ClientBeRo : public BeRoInterface{
|
||||
class ClientBeRo : public BeRoInterface
|
||||
{
|
||||
public:
|
||||
ClientBeRo(HandInterface* hi, int id, unsigned dP, int sB, GameState gS);
|
||||
~ClientBeRo();
|
||||
|
||||
@@ -266,13 +266,17 @@ ClientPlayer::setMyCardsFlip(bool theValue, int state)
|
||||
// log flipping cards
|
||||
if (myCardsFlip) {
|
||||
switch(state) {
|
||||
case 1: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt);
|
||||
case 1:
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt);
|
||||
break;
|
||||
case 2: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]);
|
||||
case 2:
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1]);
|
||||
break;
|
||||
case 3: currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt, "has");
|
||||
case 3:
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myID, myCards[0], myCards[1], myCardsValueInt, "has");
|
||||
break;
|
||||
default: ;
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -363,8 +367,7 @@ void
|
||||
ClientPlayer::setMyAggressive(bool theValue)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
for (int i=0; i<6; i++)
|
||||
{
|
||||
for (int i=0; i<6; i++) {
|
||||
myAggressive[i] = myAggressive[i+1];
|
||||
}
|
||||
myAggressive[6] = theValue;
|
||||
@@ -375,8 +378,7 @@ ClientPlayer::getMyAggressive() const
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
int sum = 0;
|
||||
for (int i=0; i<7; i++)
|
||||
{
|
||||
for (int i=0; i<7; i++) {
|
||||
sum += myAggressive[i];
|
||||
}
|
||||
return sum;
|
||||
@@ -527,8 +529,7 @@ bool ClientPlayer::checkIfINeedToShowCards()
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
std::list<unsigned> playerNeedToShowCardsList = currentHand->getBoard()->getPlayerNeedToShowCards();
|
||||
for(std::list<unsigned>::iterator it = playerNeedToShowCardsList.begin(); it != playerNeedToShowCardsList.end(); ++it)
|
||||
{
|
||||
for(std::list<unsigned>::iterator it = playerNeedToShowCardsList.begin(); it != playerNeedToShowCardsList.end(); ++it) {
|
||||
if(*it == myUniqueID) return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ class CardsValue;
|
||||
class ConfigFile;
|
||||
class HandInterface;
|
||||
|
||||
class ClientPlayer : public PlayerInterface{
|
||||
class ClientPlayer : public PlayerInterface
|
||||
{
|
||||
public:
|
||||
ClientPlayer(ConfigFile*, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, int mB);
|
||||
~ClientPlayer();
|
||||
@@ -134,7 +135,9 @@ public:
|
||||
boost::shared_ptr<SessionData> getNetSessionData();
|
||||
|
||||
// unused as client
|
||||
unsigned getActionTimeoutCounter() const {return 0;}
|
||||
unsigned getActionTimeoutCounter() const {
|
||||
return 0;
|
||||
}
|
||||
void incrementActionTimeoutCounter() {}
|
||||
void resetActionTimeoutCounter() {}
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
|
||||
class SessionData;
|
||||
|
||||
class PlayerInterface{
|
||||
class PlayerInterface
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~PlayerInterface() =0;
|
||||
|
||||
+10
-17
@@ -56,8 +56,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||
PlayerDataList::const_iterator player_i = playerDataList.begin();
|
||||
PlayerDataList::const_iterator player_end = playerDataList.end();
|
||||
|
||||
while (player_i != player_end)
|
||||
{
|
||||
while (player_i != player_end) {
|
||||
if ((*player_i)->GetUniqueId() == dealerPosition)
|
||||
break;
|
||||
++player_i;
|
||||
@@ -84,8 +83,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||
PlayerType type = PLAYER_TYPE_COMPUTER;
|
||||
boost::shared_ptr<SessionData> myNetSession;
|
||||
|
||||
if (player_i != player_end)
|
||||
{
|
||||
if (player_i != player_end) {
|
||||
uniqueId = (*player_i)->GetUniqueId();
|
||||
type = (*player_i)->GetType();
|
||||
myName = (*player_i)->GetName();
|
||||
@@ -207,10 +205,8 @@ boost::shared_ptr<PlayerInterface> Game::getPlayerByUniqueId(unsigned id)
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer;
|
||||
PlayerListIterator i = getSeatsList()->begin();
|
||||
PlayerListIterator end = getSeatsList()->end();
|
||||
while (i != end)
|
||||
{
|
||||
if ((*i)->getMyUniqueID() == id)
|
||||
{
|
||||
while (i != end) {
|
||||
if ((*i)->getMyUniqueID() == id) {
|
||||
tmpPlayer = *i;
|
||||
break;
|
||||
}
|
||||
@@ -227,7 +223,8 @@ boost::shared_ptr<PlayerInterface> Game::getCurrentPlayer()
|
||||
return tmpPlayer;
|
||||
}
|
||||
|
||||
void Game::raiseBlinds() {
|
||||
void Game::raiseBlinds()
|
||||
{
|
||||
|
||||
bool raiseBlinds = false;
|
||||
|
||||
@@ -236,8 +233,7 @@ void Game::raiseBlinds() {
|
||||
raiseBlinds = true;
|
||||
lastHandBlindsRaised = currentHandID;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (lastTimeBlindsRaised + myGameData.raiseSmallBlindEveryMinutesValue <= blindsTimer.elapsed().total_seconds()/60) {
|
||||
raiseBlinds = true;
|
||||
lastTimeBlindsRaised = blindsTimer.elapsed().total_seconds()/60;
|
||||
@@ -248,18 +244,15 @@ void Game::raiseBlinds() {
|
||||
// Now we check how the blinds should be raised
|
||||
if (myGameData.raiseMode == DOUBLE_BLINDS) {
|
||||
currentSmallBlind *= 2;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(!blindsList.empty()) {
|
||||
currentSmallBlind = blindsList.front();
|
||||
blindsList.pop_front();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// The position exceeds the list
|
||||
if (myGameData.afterManualBlindsMode == AFTERMB_DOUBLE_BLINDS) {
|
||||
currentSmallBlind *= 2;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(myGameData.afterManualBlindsMode == AFTERMB_RAISE_ABOUT) {
|
||||
currentSmallBlind += myGameData.afterMBAlwaysRaiseValue;
|
||||
}
|
||||
|
||||
+47
-16
@@ -35,7 +35,8 @@ struct GameData;
|
||||
struct StartData;
|
||||
|
||||
|
||||
class Game {
|
||||
class Game
|
||||
{
|
||||
|
||||
public:
|
||||
Game(GuiInterface *gui, boost::shared_ptr<EngineFactory> factory,
|
||||
@@ -50,28 +51,58 @@ public:
|
||||
boost::shared_ptr<HandInterface> getCurrentHand();
|
||||
const boost::shared_ptr<HandInterface> getCurrentHand() const;
|
||||
|
||||
PlayerList getSeatsList() const {return seatsList;}
|
||||
PlayerList getActivePlayerList() const {return activePlayerList;}
|
||||
PlayerList getRunningPlayerList() const {return runningPlayerList;}
|
||||
PlayerList getSeatsList() const {
|
||||
return seatsList;
|
||||
}
|
||||
PlayerList getActivePlayerList() const {
|
||||
return activePlayerList;
|
||||
}
|
||||
PlayerList getRunningPlayerList() const {
|
||||
return runningPlayerList;
|
||||
}
|
||||
|
||||
void setStartQuantityPlayers(int theValue) { startQuantityPlayers = theValue; }
|
||||
int getStartQuantityPlayers() const { return startQuantityPlayers; }
|
||||
void setStartQuantityPlayers(int theValue) {
|
||||
startQuantityPlayers = theValue;
|
||||
}
|
||||
int getStartQuantityPlayers() const {
|
||||
return startQuantityPlayers;
|
||||
}
|
||||
|
||||
void setStartSmallBlind(int theValue) { startSmallBlind = theValue; }
|
||||
int getStartSmallBlind() const { return startSmallBlind; }
|
||||
void setStartSmallBlind(int theValue) {
|
||||
startSmallBlind = theValue;
|
||||
}
|
||||
int getStartSmallBlind() const {
|
||||
return startSmallBlind;
|
||||
}
|
||||
|
||||
void setStartCash(int theValue) { startCash = theValue; }
|
||||
int getStartCash() const { return startCash; }
|
||||
void setStartCash(int theValue) {
|
||||
startCash = theValue;
|
||||
}
|
||||
int getStartCash() const {
|
||||
return startCash;
|
||||
}
|
||||
|
||||
int getMyGameID() const { return myGameID; }
|
||||
int getMyGameID() const {
|
||||
return myGameID;
|
||||
}
|
||||
|
||||
void setCurrentSmallBlind(int theValue) { currentSmallBlind = theValue; }
|
||||
int getCurrentSmallBlind() const { return currentSmallBlind; }
|
||||
void setCurrentSmallBlind(int theValue) {
|
||||
currentSmallBlind = theValue;
|
||||
}
|
||||
int getCurrentSmallBlind() const {
|
||||
return currentSmallBlind;
|
||||
}
|
||||
|
||||
void setCurrentHandID(int theValue) { currentHandID = theValue; }
|
||||
int getCurrentHandID() const { return currentHandID; }
|
||||
void setCurrentHandID(int theValue) {
|
||||
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> getCurrentPlayer();
|
||||
|
||||
+15
-18
@@ -51,7 +51,8 @@ enum ServerMode {
|
||||
enum ServerTransportProtocol {
|
||||
TRANSPORT_PROTOCOL_TCP = 1,
|
||||
TRANSPORT_PROTOCOL_SCTP = 2,
|
||||
TRANSPORT_PROTOCOL_TCP_SCTP = 3};
|
||||
TRANSPORT_PROTOCOL_TCP_SCTP = 3
|
||||
};
|
||||
|
||||
enum GameState {
|
||||
GAME_STATE_PREFLOP = 0,
|
||||
@@ -60,7 +61,8 @@ enum GameState {
|
||||
GAME_STATE_RIVER,
|
||||
GAME_STATE_POST_RIVER,
|
||||
GAME_STATE_PREFLOP_SMALL_BLIND = 0xF0,
|
||||
GAME_STATE_PREFLOP_BIG_BLIND = 0xF1 };
|
||||
GAME_STATE_PREFLOP_BIG_BLIND = 0xF1
|
||||
};
|
||||
|
||||
enum PlayerAction {
|
||||
PLAYER_ACTION_NONE = 0,
|
||||
@@ -69,18 +71,17 @@ enum PlayerAction {
|
||||
PLAYER_ACTION_CALL,
|
||||
PLAYER_ACTION_BET,
|
||||
PLAYER_ACTION_RAISE,
|
||||
PLAYER_ACTION_ALLIN };
|
||||
PLAYER_ACTION_ALLIN
|
||||
};
|
||||
|
||||
enum PlayerActionCode
|
||||
{
|
||||
enum PlayerActionCode {
|
||||
ACTION_CODE_VALID = 0,
|
||||
ACTION_CODE_INVALID_STATE,
|
||||
ACTION_CODE_NOT_YOUR_TURN,
|
||||
ACTION_CODE_NOT_ALLOWED
|
||||
};
|
||||
|
||||
enum DenyKickPlayerReason
|
||||
{
|
||||
enum DenyKickPlayerReason {
|
||||
KICK_DENIED_INVALID_STATE = 0,
|
||||
KICK_DENIED_TOO_FEW_PLAYERS,
|
||||
KICK_DENIED_TEMPORARY,
|
||||
@@ -88,28 +89,24 @@ enum DenyKickPlayerReason
|
||||
KICK_DENIED_INVALID_PLAYER_ID
|
||||
};
|
||||
|
||||
enum KickVote
|
||||
{
|
||||
enum KickVote {
|
||||
KICK_VOTE_AGAINST = 0,
|
||||
KICK_VOTE_IN_FAVOUR
|
||||
};
|
||||
|
||||
enum DenyVoteReason
|
||||
{
|
||||
enum DenyVoteReason {
|
||||
VOTE_DENIED_INVALID_PETITION = 0,
|
||||
VOTE_DENIED_ALREADY_VOTED
|
||||
};
|
||||
|
||||
enum EndPetitionReason
|
||||
{
|
||||
enum EndPetitionReason {
|
||||
PETITION_END_ENOUGH_VOTES = 0,
|
||||
PETITION_END_NOT_ENOUGH_PLAYERS,
|
||||
PETITION_END_PLAYER_LEFT,
|
||||
PETITION_END_TIMEOUT
|
||||
};
|
||||
|
||||
enum DenyGameInvitationReason
|
||||
{
|
||||
enum DenyGameInvitationReason {
|
||||
DENY_GAME_INVITATION_NO = 0,
|
||||
DENY_GAME_INVITATION_BUSY
|
||||
};
|
||||
@@ -118,15 +115,15 @@ enum Button {
|
||||
BUTTON_NONE = 0,
|
||||
BUTTON_DEALER,
|
||||
BUTTON_SMALL_BLIND,
|
||||
BUTTON_BIG_BLIND };
|
||||
BUTTON_BIG_BLIND
|
||||
};
|
||||
|
||||
enum NetTimeoutReason {
|
||||
NETWORK_TIMEOUT_GENERIC = 0,
|
||||
NETWORK_TIMEOUT_GAME_ADMIN_IDLE
|
||||
};
|
||||
|
||||
struct ServerStats
|
||||
{
|
||||
struct ServerStats {
|
||||
ServerStats()
|
||||
: numberOfPlayersOnServer(0), numberOfGamesOpen(0), totalPlayersEverLoggedIn(0),
|
||||
totalGamesEverCreated(0), maxGamesOpen(0), maxPlayersLoggedIn(0) {}
|
||||
|
||||
+9
-18
@@ -28,43 +28,37 @@
|
||||
|
||||
typedef std::list<unsigned> PlayerIdList;
|
||||
|
||||
enum GameMode
|
||||
{
|
||||
enum GameMode {
|
||||
GAME_MODE_CREATED = 1,
|
||||
GAME_MODE_STARTED,
|
||||
GAME_MODE_CLOSED
|
||||
};
|
||||
|
||||
enum GameType
|
||||
{
|
||||
enum GameType {
|
||||
GAME_TYPE_NORMAL = 1,
|
||||
GAME_TYPE_REGISTERED_ONLY,
|
||||
GAME_TYPE_INVITE_ONLY,
|
||||
GAME_TYPE_RANKING
|
||||
};
|
||||
|
||||
enum RaiseIntervalMode
|
||||
{
|
||||
enum RaiseIntervalMode {
|
||||
RAISE_ON_HANDNUMBER = 1,
|
||||
RAISE_ON_MINUTES
|
||||
};
|
||||
|
||||
enum RaiseMode
|
||||
{
|
||||
enum RaiseMode {
|
||||
DOUBLE_BLINDS = 1,
|
||||
MANUAL_BLINDS_ORDER
|
||||
};
|
||||
|
||||
enum AfterManualBlindsMode
|
||||
{
|
||||
enum AfterManualBlindsMode {
|
||||
AFTERMB_DOUBLE_BLINDS = 1,
|
||||
AFTERMB_RAISE_ABOUT,
|
||||
AFTERMB_STAY_AT_LAST_BLIND
|
||||
};
|
||||
|
||||
// For the sake of simplicity, this is a struct.
|
||||
struct GameData
|
||||
{
|
||||
struct GameData {
|
||||
GameData() : gameType(GAME_TYPE_NORMAL), maxNumberOfPlayers(0), startMoney(0),
|
||||
firstSmallBlind(0), raiseIntervalMode(RAISE_ON_HANDNUMBER),
|
||||
raiseSmallBlindEveryHandsValue(8), raiseSmallBlindEveryMinutesValue(1),
|
||||
@@ -87,8 +81,7 @@ struct GameData
|
||||
int playerActionTimeoutSec;
|
||||
};
|
||||
|
||||
struct GameInfo
|
||||
{
|
||||
struct GameInfo {
|
||||
GameInfo() : mode(GAME_MODE_CREATED), adminPlayerId(0), isPasswordProtected(false) {}
|
||||
std::string name;
|
||||
GameData data;
|
||||
@@ -98,15 +91,13 @@ struct GameInfo
|
||||
bool isPasswordProtected;
|
||||
};
|
||||
|
||||
struct StartData
|
||||
{
|
||||
struct StartData {
|
||||
StartData() : startDealerPlayerId(0), numberOfPlayers(0) {}
|
||||
unsigned startDealerPlayerId;
|
||||
int numberOfPlayers;
|
||||
};
|
||||
|
||||
struct VoteKickData
|
||||
{
|
||||
struct VoteKickData {
|
||||
VoteKickData()
|
||||
: petitionId(0), kickPlayerId(0), numVotesToKick(0),
|
||||
numVotesInFavourOfKicking(0), numVotesAgainstKicking(0), timeLimitSec(0),
|
||||
|
||||
@@ -117,57 +117,198 @@ void ServerGuiWrapper::logPlayerWinGame(std::string /*playerName*/, int /*gameID
|
||||
void ServerGuiWrapper::flushLogAtGame(int /*gameID*/) {}
|
||||
void ServerGuiWrapper::flushLogAtHand() {}
|
||||
|
||||
void ServerGuiWrapper::SignalNetClientServerListAdd(unsigned serverId) { if (myClientcb) myClientcb->SignalNetClientServerListAdd(serverId); }
|
||||
void ServerGuiWrapper::SignalNetClientServerListClear() { if (myClientcb) myClientcb->SignalNetClientServerListClear(); }
|
||||
void ServerGuiWrapper::SignalNetClientServerListShow() { if (myClientcb) myClientcb->SignalNetClientServerListShow(); }
|
||||
void ServerGuiWrapper::SignalNetClientServerListAdd(unsigned serverId)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientServerListAdd(serverId);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientServerListClear()
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientServerListClear();
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientServerListShow()
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientServerListShow();
|
||||
}
|
||||
|
||||
void ServerGuiWrapper::SignalNetClientLoginShow() { if (myClientcb) myClientcb->SignalNetClientLoginShow(); }
|
||||
void ServerGuiWrapper::SignalNetClientPostRiverShowCards(unsigned playerId) { if (myClientcb) myClientcb->SignalNetClientPostRiverShowCards(playerId); }
|
||||
void ServerGuiWrapper::SignalNetClientLoginShow()
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientLoginShow();
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientPostRiverShowCards(unsigned playerId)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientPostRiverShowCards(playerId);
|
||||
}
|
||||
|
||||
void ServerGuiWrapper::SignalNetClientConnect(int actionID) { if (myClientcb) myClientcb->SignalNetClientConnect(actionID); }
|
||||
void ServerGuiWrapper::SignalNetClientGameInfo(int actionID) { if (myClientcb) myClientcb->SignalNetClientGameInfo(actionID); }
|
||||
void ServerGuiWrapper::SignalNetClientError(int errorID, int osErrorID) { if (myClientcb) myClientcb->SignalNetClientError(errorID, osErrorID); }
|
||||
void ServerGuiWrapper::SignalNetClientNotification(int notificationId) { if (myClientcb) myClientcb->SignalNetClientNotification(notificationId); }
|
||||
void ServerGuiWrapper::SignalNetClientStatsUpdate(const ServerStats &stats) { if (myClientcb) myClientcb->SignalNetClientStatsUpdate(stats); }
|
||||
void ServerGuiWrapper::SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec) { if (myClientcb) myClientcb->SignalNetClientShowTimeoutDialog(reason, remainingSec); }
|
||||
void ServerGuiWrapper::SignalNetClientRemovedFromGame(int notificationId) { if (myClientcb) myClientcb->SignalNetClientRemovedFromGame(notificationId); }
|
||||
void ServerGuiWrapper::SignalNetClientSelfJoined(unsigned playerId, const string &playerName, bool isGameAdmin) { if (myClientcb) myClientcb->SignalNetClientSelfJoined(playerId, playerName, isGameAdmin); }
|
||||
void ServerGuiWrapper::SignalNetClientPlayerJoined(unsigned playerId, const string &playerName, bool isGameAdmin) { if (myClientcb) myClientcb->SignalNetClientPlayerJoined(playerId, playerName, isGameAdmin); }
|
||||
void ServerGuiWrapper::SignalNetClientPlayerChanged(unsigned playerId, const string &newPlayerName) { if (myClientcb) myClientcb->SignalNetClientPlayerChanged(playerId, newPlayerName); }
|
||||
void ServerGuiWrapper::SignalNetClientPlayerLeft(unsigned playerId, const string &playerName, int removeReason) { if (myClientcb) myClientcb->SignalNetClientPlayerLeft(playerId, playerName, removeReason); }
|
||||
void ServerGuiWrapper::SignalNetClientNewGameAdmin(unsigned playerId, const string &playerName) { if (myClientcb) myClientcb->SignalNetClientNewGameAdmin(playerId, playerName); }
|
||||
void ServerGuiWrapper::SignalNetClientGameListNew(unsigned gameId) { if (myClientcb) myClientcb->SignalNetClientGameListNew(gameId); }
|
||||
void ServerGuiWrapper::SignalNetClientGameListRemove(unsigned gameId) { if (myClientcb) myClientcb->SignalNetClientGameListRemove(gameId); }
|
||||
void ServerGuiWrapper::SignalNetClientGameListUpdateMode(unsigned gameId, GameMode mode) { if (myClientcb) myClientcb->SignalNetClientGameListUpdateMode(gameId, mode); }
|
||||
void ServerGuiWrapper::SignalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId) { if (myClientcb) myClientcb->SignalNetClientGameListUpdateAdmin(gameId, adminPlayerId); }
|
||||
void ServerGuiWrapper::SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId) { if (myClientcb) myClientcb->SignalNetClientGameListPlayerJoined(gameId, playerId); }
|
||||
void ServerGuiWrapper::SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId) { if (myClientcb) myClientcb->SignalNetClientGameListPlayerLeft(gameId, playerId); }
|
||||
void ServerGuiWrapper::SignalNetClientGameStart(boost::shared_ptr<Game> game) { if (myClientcb) myClientcb->SignalNetClientGameStart(game); }
|
||||
void ServerGuiWrapper::SignalNetClientGameChatMsg(const string &playerName, const string &msg) { if (myClientcb) myClientcb->SignalNetClientGameChatMsg(playerName, msg); }
|
||||
void ServerGuiWrapper::SignalNetClientLobbyChatMsg(const string &playerName, const string &msg) { if (myClientcb) myClientcb->SignalNetClientLobbyChatMsg(playerName, msg); }
|
||||
void ServerGuiWrapper::SignalNetClientMsgBox(const string &msg) { if (myClientcb) myClientcb->SignalNetClientMsgBox(msg); }
|
||||
void ServerGuiWrapper::SignalNetClientMsgBox(unsigned msgId) { if (myClientcb) myClientcb->SignalNetClientMsgBox(msgId); }
|
||||
void ServerGuiWrapper::SignalNetClientWaitDialog() { if (myClientcb) myClientcb->SignalNetClientWaitDialog(); }
|
||||
void ServerGuiWrapper::SignalNetClientWarningAutoFoldInRankingGame(unsigned remainingAutoFolds) { if (myClientcb) myClientcb->SignalNetClientWarningAutoFoldInRankingGame(remainingAutoFolds); }
|
||||
void ServerGuiWrapper::SignalNetClientConnect(int actionID)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientConnect(actionID);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientGameInfo(int actionID)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientGameInfo(actionID);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientError(int errorID, int osErrorID)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientError(errorID, osErrorID);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientNotification(int notificationId)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientNotification(notificationId);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientStatsUpdate(const ServerStats &stats)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientStatsUpdate(stats);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientShowTimeoutDialog(NetTimeoutReason reason, unsigned remainingSec)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientShowTimeoutDialog(reason, remainingSec);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientRemovedFromGame(int notificationId)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientRemovedFromGame(notificationId);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientSelfJoined(unsigned playerId, const string &playerName, bool isGameAdmin)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientSelfJoined(playerId, playerName, isGameAdmin);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientPlayerJoined(unsigned playerId, const string &playerName, bool isGameAdmin)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientPlayerJoined(playerId, playerName, isGameAdmin);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientPlayerChanged(unsigned playerId, const string &newPlayerName)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientPlayerChanged(playerId, newPlayerName);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientPlayerLeft(unsigned playerId, const string &playerName, int removeReason)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientPlayerLeft(playerId, playerName, removeReason);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientNewGameAdmin(unsigned playerId, const string &playerName)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientNewGameAdmin(playerId, playerName);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientGameListNew(unsigned gameId)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientGameListNew(gameId);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientGameListRemove(unsigned gameId)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientGameListRemove(gameId);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientGameListUpdateMode(unsigned gameId, GameMode mode)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientGameListUpdateMode(gameId, mode);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientGameListUpdateAdmin(unsigned gameId, unsigned adminPlayerId)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientGameListUpdateAdmin(gameId, adminPlayerId);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientGameListPlayerJoined(gameId, playerId);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientGameListPlayerLeft(gameId, playerId);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientGameStart(boost::shared_ptr<Game> game)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientGameStart(game);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientGameChatMsg(const string &playerName, const string &msg)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientGameChatMsg(playerName, msg);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientLobbyChatMsg(const string &playerName, const string &msg)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientLobbyChatMsg(playerName, msg);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientMsgBox(const string &msg)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientMsgBox(msg);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientMsgBox(unsigned msgId)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientMsgBox(msgId);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientWaitDialog()
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientWaitDialog();
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetClientWarningAutoFoldInRankingGame(unsigned remainingAutoFolds)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalNetClientWarningAutoFoldInRankingGame(remainingAutoFolds);
|
||||
}
|
||||
|
||||
|
||||
void ServerGuiWrapper::SignalNetServerSuccess(int actionID) { if (myServercb) myServercb->SignalNetServerSuccess(actionID); }
|
||||
void ServerGuiWrapper::SignalNetServerError(int errorID, int osErrorID) { if (myServercb) myServercb->SignalNetServerError(errorID, osErrorID); }
|
||||
void ServerGuiWrapper::SignalNetServerSuccess(int actionID)
|
||||
{
|
||||
if (myServercb) myServercb->SignalNetServerSuccess(actionID);
|
||||
}
|
||||
void ServerGuiWrapper::SignalNetServerError(int errorID, int osErrorID)
|
||||
{
|
||||
if (myServercb) myServercb->SignalNetServerError(errorID, osErrorID);
|
||||
}
|
||||
|
||||
void ServerGuiWrapper::SignalIrcConnect(const string &server) { if (myIrccb) myIrccb->SignalIrcConnect(server); }
|
||||
void ServerGuiWrapper::SignalIrcSelfJoined(const string &nickName, const std::string &channel) { if (myIrccb) myIrccb->SignalIrcSelfJoined(nickName, channel); }
|
||||
void ServerGuiWrapper::SignalIrcPlayerJoined(const string &nickName) { if (myIrccb) myIrccb->SignalIrcPlayerJoined(nickName); }
|
||||
void ServerGuiWrapper::SignalIrcPlayerChanged(const string &oldNick, const string &newNick) { if (myIrccb) myIrccb->SignalIrcPlayerChanged(oldNick, newNick); }
|
||||
void ServerGuiWrapper::SignalIrcPlayerKicked(const string &nickName, const string &byWhom, const string &reason) { if (myIrccb) myIrccb->SignalIrcPlayerKicked(nickName, byWhom, reason); }
|
||||
void ServerGuiWrapper::SignalIrcPlayerLeft(const string &nickName) { if (myIrccb) myIrccb->SignalIrcPlayerLeft(nickName); }
|
||||
void ServerGuiWrapper::SignalIrcChatMsg(const string &nickName, const string &msg) { if (myIrccb) myIrccb->SignalIrcChatMsg(nickName, msg); }
|
||||
void ServerGuiWrapper::SignalIrcError(int errorCode) { if (myIrccb) myIrccb->SignalIrcError(errorCode); }
|
||||
void ServerGuiWrapper::SignalIrcServerError(int errorCode) {if (myIrccb) myIrccb->SignalIrcServerError(errorCode); }
|
||||
void ServerGuiWrapper::SignalIrcConnect(const string &server)
|
||||
{
|
||||
if (myIrccb) myIrccb->SignalIrcConnect(server);
|
||||
}
|
||||
void ServerGuiWrapper::SignalIrcSelfJoined(const string &nickName, const std::string &channel)
|
||||
{
|
||||
if (myIrccb) myIrccb->SignalIrcSelfJoined(nickName, channel);
|
||||
}
|
||||
void ServerGuiWrapper::SignalIrcPlayerJoined(const string &nickName)
|
||||
{
|
||||
if (myIrccb) myIrccb->SignalIrcPlayerJoined(nickName);
|
||||
}
|
||||
void ServerGuiWrapper::SignalIrcPlayerChanged(const string &oldNick, const string &newNick)
|
||||
{
|
||||
if (myIrccb) myIrccb->SignalIrcPlayerChanged(oldNick, newNick);
|
||||
}
|
||||
void ServerGuiWrapper::SignalIrcPlayerKicked(const string &nickName, const string &byWhom, const string &reason)
|
||||
{
|
||||
if (myIrccb) myIrccb->SignalIrcPlayerKicked(nickName, byWhom, reason);
|
||||
}
|
||||
void ServerGuiWrapper::SignalIrcPlayerLeft(const string &nickName)
|
||||
{
|
||||
if (myIrccb) myIrccb->SignalIrcPlayerLeft(nickName);
|
||||
}
|
||||
void ServerGuiWrapper::SignalIrcChatMsg(const string &nickName, const string &msg)
|
||||
{
|
||||
if (myIrccb) myIrccb->SignalIrcChatMsg(nickName, msg);
|
||||
}
|
||||
void ServerGuiWrapper::SignalIrcError(int errorCode)
|
||||
{
|
||||
if (myIrccb) myIrccb->SignalIrcError(errorCode);
|
||||
}
|
||||
void ServerGuiWrapper::SignalIrcServerError(int errorCode)
|
||||
{
|
||||
if (myIrccb) myIrccb->SignalIrcServerError(errorCode);
|
||||
}
|
||||
|
||||
void ServerGuiWrapper::SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName) { if (myClientcb) myClientcb->SignalLobbyPlayerJoined(playerId, nickName); }
|
||||
void ServerGuiWrapper::SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason) { if (myClientcb) myClientcb->SignalLobbyPlayerKicked(nickName, byWhom, reason); }
|
||||
void ServerGuiWrapper::SignalLobbyPlayerLeft(unsigned playerId) { if (myClientcb) myClientcb->SignalLobbyPlayerLeft(playerId); }
|
||||
void ServerGuiWrapper::SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalLobbyPlayerJoined(playerId, nickName);
|
||||
}
|
||||
void ServerGuiWrapper::SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalLobbyPlayerKicked(nickName, byWhom, reason);
|
||||
}
|
||||
void ServerGuiWrapper::SignalLobbyPlayerLeft(unsigned playerId)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalLobbyPlayerLeft(playerId);
|
||||
}
|
||||
|
||||
void ServerGuiWrapper::SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom) { if (myClientcb) myClientcb->SignalSelfGameInvitation(gameId, playerIdFrom); }
|
||||
void ServerGuiWrapper::SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom) { if (myClientcb) myClientcb->SignalPlayerGameInvitation(gameId, playerIdWho, playerIdFrom); }
|
||||
void ServerGuiWrapper::SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason) { if (myClientcb) myClientcb->SignalRejectedGameInvitation(gameId, playerIdWho, reason); }
|
||||
void ServerGuiWrapper::SignalSelfGameInvitation(unsigned gameId, unsigned playerIdFrom)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalSelfGameInvitation(gameId, playerIdFrom);
|
||||
}
|
||||
void ServerGuiWrapper::SignalPlayerGameInvitation(unsigned gameId, unsigned playerIdWho, unsigned playerIdFrom)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalPlayerGameInvitation(gameId, playerIdWho, playerIdFrom);
|
||||
}
|
||||
void ServerGuiWrapper::SignalRejectedGameInvitation(unsigned gameId, unsigned playerIdWho, DenyGameInvitationReason reason)
|
||||
{
|
||||
if (myClientcb) myClientcb->SignalRejectedGameInvitation(gameId, playerIdWho, reason);
|
||||
}
|
||||
|
||||
@@ -36,8 +36,12 @@ public:
|
||||
boost::shared_ptr<Session> getSession();
|
||||
void setSession(boost::shared_ptr<Session> session);
|
||||
|
||||
gameTableImpl* getMyW() const {return NULL;}
|
||||
guiLog* getMyGuiLog() const {return NULL;}
|
||||
gameTableImpl* getMyW() const {
|
||||
return NULL;
|
||||
}
|
||||
guiLog* getMyGuiLog() const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void refreshSet() const;
|
||||
void refreshCash() const;
|
||||
|
||||
@@ -31,7 +31,8 @@ class guiLog;
|
||||
class Session;
|
||||
class gameTableImpl;
|
||||
|
||||
class GuiInterface : public ClientCallback, public ServerCallback, public IrcCallback {
|
||||
class GuiInterface : public ClientCallback, public ServerCallback, public IrcCallback
|
||||
{
|
||||
public:
|
||||
virtual ~GuiInterface();
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
|
||||
class ConfigFile;
|
||||
|
||||
class aboutPokerthImpl: public QDialog, public Ui::aboutPokerth {
|
||||
class aboutPokerthImpl: public QDialog, public Ui::aboutPokerth
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
aboutPokerthImpl(QWidget *parent = 0, ConfigFile *c =0);
|
||||
|
||||
@@ -37,33 +37,40 @@ changeCompleteBlindsDialogImpl::changeCompleteBlindsDialogImpl(QWidget *parent,
|
||||
|
||||
}
|
||||
|
||||
void changeCompleteBlindsDialogImpl::exec() {
|
||||
void changeCompleteBlindsDialogImpl::exec()
|
||||
{
|
||||
|
||||
|
||||
QDialog::exec();
|
||||
}
|
||||
|
||||
void changeCompleteBlindsDialogImpl::updateSpinBoxInputMinimum(int value) { spinBox_input->setMinimum(value+1); }
|
||||
void changeCompleteBlindsDialogImpl::updateSpinBoxInputMinimum(int value)
|
||||
{
|
||||
spinBox_input->setMinimum(value+1);
|
||||
}
|
||||
|
||||
void changeCompleteBlindsDialogImpl::addBlindValueToList() {
|
||||
void changeCompleteBlindsDialogImpl::addBlindValueToList()
|
||||
{
|
||||
|
||||
if(listWidget_blinds->count() == 30) {
|
||||
QMessageBox::warning(this, tr("Manual Blinds Order"),
|
||||
tr("You cannot set more than 30 manual blinds."),
|
||||
QMessageBox::Close); }
|
||||
else {
|
||||
QMessageBox::Close);
|
||||
} else {
|
||||
listWidget_blinds->addItem(QString::number(spinBox_input->value(),10));
|
||||
sortBlindsList();
|
||||
}
|
||||
}
|
||||
|
||||
void changeCompleteBlindsDialogImpl::removeBlindFromList() {
|
||||
void changeCompleteBlindsDialogImpl::removeBlindFromList()
|
||||
{
|
||||
|
||||
listWidget_blinds->takeItem(listWidget_blinds->currentRow());
|
||||
sortBlindsList();
|
||||
}
|
||||
|
||||
void changeCompleteBlindsDialogImpl::sortBlindsList() {
|
||||
void changeCompleteBlindsDialogImpl::sortBlindsList()
|
||||
{
|
||||
|
||||
int i;
|
||||
QList<int> tempIntList;
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
|
||||
class ConfigFile;
|
||||
|
||||
class changeCompleteBlindsDialogImpl: public QDialog, public Ui::changeCompleteBlindsDialog {
|
||||
class changeCompleteBlindsDialogImpl: public QDialog, public Ui::changeCompleteBlindsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
changeCompleteBlindsDialogImpl(QWidget *parent = 0, ConfigFile *c = 0);
|
||||
@@ -36,7 +37,9 @@ public:
|
||||
|
||||
|
||||
public slots:
|
||||
bool getSettingsCorrect() const { return settingsCorrect;}
|
||||
bool getSettingsCorrect() const {
|
||||
return settingsCorrect;
|
||||
}
|
||||
|
||||
void updateSpinBoxInputMinimum(int);
|
||||
void addBlindValueToList();
|
||||
|
||||
@@ -76,7 +76,8 @@ changeContentDialogImpl::changeContentDialogImpl(QWidget *parent, ConfigFile *co
|
||||
|
||||
}
|
||||
|
||||
void changeContentDialogImpl::saveContent() {
|
||||
void changeContentDialogImpl::saveContent()
|
||||
{
|
||||
|
||||
switch (myType) {
|
||||
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 changeContentDialogImpl: public QDialog, public Ui::changeContentDialog {
|
||||
class changeContentDialogImpl: public QDialog, public Ui::changeContentDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
changeContentDialogImpl(QWidget *parent, ConfigFile *config, DialogType t);
|
||||
|
||||
@@ -39,21 +39,22 @@ ChatTools::~ChatTools()
|
||||
{
|
||||
}
|
||||
|
||||
void ChatTools::sendMessage() {
|
||||
void ChatTools::sendMessage()
|
||||
{
|
||||
|
||||
if(myLineEdit->text().size() && mySession) {
|
||||
fillChatLinesHistory(myLineEdit->text());
|
||||
if(myChatType == INGAME_CHAT) {
|
||||
mySession->sendGameChatMessage(myLineEdit->text().toUtf8().constData());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mySession->sendLobbyChatMessage(myLineEdit->text().toUtf8().constData());
|
||||
}
|
||||
myLineEdit->setText("");
|
||||
}
|
||||
}
|
||||
|
||||
void ChatTools::receiveMessage(QString playerName, QString message) {
|
||||
void ChatTools::receiveMessage(QString playerName, QString message)
|
||||
{
|
||||
|
||||
if(myTextBrowser) {
|
||||
|
||||
@@ -72,8 +73,7 @@ void ChatTools::receiveMessage(QString playerName, QString message) {
|
||||
if(myLobby->isVisible() && myConfig->readConfigInt("PlayLobbyChatNotification")) {
|
||||
myLobby->getMyW()->getMySDLPlayer()->playSound("lobbychatnotify",0);
|
||||
}
|
||||
}
|
||||
else if(message.contains(myNick, Qt::CaseInsensitive)) {
|
||||
} else if(message.contains(myNick, Qt::CaseInsensitive)) {
|
||||
|
||||
switch (myChatType) {
|
||||
case INET_LOBBY_CHAT: {
|
||||
@@ -85,33 +85,42 @@ void ChatTools::receiveMessage(QString playerName, QString message) {
|
||||
}
|
||||
}
|
||||
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;
|
||||
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;
|
||||
default: tempMsg = message;
|
||||
default:
|
||||
tempMsg = message;
|
||||
}
|
||||
}
|
||||
else if(playerName == myNick) {
|
||||
} else if(playerName == myNick) {
|
||||
switch (myChatType) {
|
||||
case INET_LOBBY_CHAT: tempMsg = QString("<span style=\"font-weight:normal; color:"+myLobby->palette().link().color().name()+";\">"+message+"</span>");
|
||||
case INET_LOBBY_CHAT:
|
||||
tempMsg = QString("<span style=\"font-weight:normal; color:"+myLobby->palette().link().color().name()+";\">"+message+"</span>");
|
||||
break;
|
||||
case LAN_LOBBY_CHAT: tempMsg = QString("<span style=\"font-weight:normal;\">"+message+"</span>");
|
||||
case LAN_LOBBY_CHAT:
|
||||
tempMsg = QString("<span style=\"font-weight:normal;\">"+message+"</span>");
|
||||
break;
|
||||
case INGAME_CHAT: tempMsg = QString("<span style=\"color:#"+myStyle->getChatLogTextColor()+";\">"+message+"</span>");
|
||||
case INGAME_CHAT:
|
||||
tempMsg = QString("<span style=\"color:#"+myStyle->getChatLogTextColor()+";\">"+message+"</span>");
|
||||
break;
|
||||
default: tempMsg = message;
|
||||
default:
|
||||
tempMsg = message;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
default: tempMsg = message;
|
||||
default:
|
||||
tempMsg = message;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -129,26 +138,28 @@ void ChatTools::receiveMessage(QString playerName, QString message) {
|
||||
|
||||
if(message.indexOf(QString("/me "))==0) {
|
||||
myTextBrowser->append(tempMsg.replace("/me ","<i>*"+playerName+" ")+"</i>");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
myTextBrowser->append(playerName + ": " + tempMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChatTools::clearChat() {
|
||||
void ChatTools::clearChat()
|
||||
{
|
||||
|
||||
if(myTextBrowser)
|
||||
myTextBrowser->clear();
|
||||
}
|
||||
|
||||
void ChatTools::checkInputLength(QString string) {
|
||||
void ChatTools::checkInputLength(QString string)
|
||||
{
|
||||
|
||||
if(string.toUtf8().length() > 120) myLineEdit->setMaxLength(string.length());
|
||||
}
|
||||
|
||||
void ChatTools::fillChatLinesHistory(QString fillString) {
|
||||
void ChatTools::fillChatLinesHistory(QString fillString)
|
||||
{
|
||||
|
||||
chatLinesHistory << fillString;
|
||||
if(chatLinesHistory.size() > 50) chatLinesHistory.removeFirst();
|
||||
@@ -156,7 +167,8 @@ void ChatTools::fillChatLinesHistory(QString fillString) {
|
||||
|
||||
}
|
||||
|
||||
void ChatTools::showChatHistoryIndex(int index) {
|
||||
void ChatTools::showChatHistoryIndex(int index)
|
||||
{
|
||||
|
||||
if(index <= chatLinesHistory.size()) {
|
||||
|
||||
@@ -168,7 +180,8 @@ void ChatTools::showChatHistoryIndex(int index) {
|
||||
}
|
||||
}
|
||||
|
||||
void ChatTools::nickAutoCompletition() {
|
||||
void ChatTools::nickAutoCompletition()
|
||||
{
|
||||
|
||||
QString myChatString = myLineEdit->text();
|
||||
QStringList myChatStringList = myChatString.split(" ");
|
||||
@@ -224,7 +237,8 @@ void ChatTools::nickAutoCompletition() {
|
||||
}
|
||||
}
|
||||
|
||||
void ChatTools::setChatTextEdited() {
|
||||
void ChatTools::setChatTextEdited()
|
||||
{
|
||||
|
||||
nickAutoCompletitionCounter = 0;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,9 @@ public:
|
||||
|
||||
~ChatTools();
|
||||
|
||||
void setSession(boost::shared_ptr<Session> session) { mySession = session; }
|
||||
void setSession(boost::shared_ptr<Session> session) {
|
||||
mySession = session;
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -52,16 +54,26 @@ public slots:
|
||||
|
||||
void fillChatLinesHistory(QString fillString);
|
||||
void showChatHistoryIndex(int index);
|
||||
int getChatLinesHistorySize() { return chatLinesHistory.size(); }
|
||||
int getChatLinesHistorySize() {
|
||||
return chatLinesHistory.size();
|
||||
}
|
||||
|
||||
void nickAutoCompletition();
|
||||
void setChatTextEdited();
|
||||
|
||||
void setPlayerNicksList(QStringList value) { myNickStringList = value; }
|
||||
void setMyNick ( const QString& theValue ) { myNick = theValue; }
|
||||
QString getMyNick () { return myNick; }
|
||||
void setPlayerNicksList(QStringList value) {
|
||||
myNickStringList = value;
|
||||
}
|
||||
void setMyNick ( const QString& theValue ) {
|
||||
myNick = theValue;
|
||||
}
|
||||
QString getMyNick () {
|
||||
return myNick;
|
||||
}
|
||||
|
||||
void setMyStyle ( GameTableStyleReader* theValue ) { myStyle = theValue; }
|
||||
void setMyStyle ( GameTableStyleReader* theValue ) {
|
||||
myStyle = theValue;
|
||||
}
|
||||
void refreshIgnoreList();
|
||||
|
||||
|
||||
|
||||
@@ -38,26 +38,37 @@ void connectToServerDialogImpl::exec()
|
||||
QDialog::exec();
|
||||
}
|
||||
|
||||
void connectToServerDialogImpl::refresh(int actionID) {
|
||||
void connectToServerDialogImpl::refresh(int actionID)
|
||||
{
|
||||
|
||||
bool skip = false;
|
||||
switch (actionID) {
|
||||
|
||||
case MSG_SOCK_INIT_DONE: { label_actionMessage->setText(tr("Resolving address...")); }
|
||||
case MSG_SOCK_INIT_DONE: {
|
||||
label_actionMessage->setText(tr("Resolving address..."));
|
||||
}
|
||||
break;
|
||||
case MSG_SOCK_SERVER_LIST_DONE : { label_actionMessage->setText(tr("Reading server list...")); }
|
||||
case MSG_SOCK_SERVER_LIST_DONE : {
|
||||
label_actionMessage->setText(tr("Reading server list..."));
|
||||
}
|
||||
break;
|
||||
case MSG_SOCK_RESOLVE_DONE: { label_actionMessage->setText(tr("Connecting to server...")); }
|
||||
case MSG_SOCK_RESOLVE_DONE: {
|
||||
label_actionMessage->setText(tr("Connecting to server..."));
|
||||
}
|
||||
break;
|
||||
case MSG_SOCK_CONNECT_DONE: { label_actionMessage->setText(tr("Starting session...")); }
|
||||
case MSG_SOCK_CONNECT_DONE: {
|
||||
label_actionMessage->setText(tr("Starting session..."));
|
||||
}
|
||||
break;
|
||||
case MSG_SOCK_SESSION_DONE: { label_actionMessage->setText(tr("Connection established!")); }
|
||||
case MSG_SOCK_SESSION_DONE: {
|
||||
label_actionMessage->setText(tr("Connection established!"));
|
||||
}
|
||||
break;
|
||||
default: skip = true;
|
||||
default:
|
||||
skip = true;
|
||||
}
|
||||
|
||||
if (!skip)
|
||||
{
|
||||
if (!skip) {
|
||||
progressBar->setValue(actionID*(100/MSG_SOCK_LIMIT_CONNECT));
|
||||
|
||||
if (actionID == MSG_SOCK_LIMIT_CONNECT)
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
#include <QtCore>
|
||||
|
||||
|
||||
class connectToServerDialogImpl: public QDialog, public Ui::connectToServerDialog {
|
||||
class connectToServerDialogImpl: public QDialog, public Ui::connectToServerDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
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;
|
||||
currentPlayerName = playerName;
|
||||
@@ -64,15 +65,18 @@ void createInternetGameDialogImpl::exec(bool guestMode, QString playerName) {
|
||||
QDialog::exec();
|
||||
}
|
||||
|
||||
void createInternetGameDialogImpl::createGame() {
|
||||
void createInternetGameDialogImpl::createGame()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void createInternetGameDialogImpl::cancel() {
|
||||
void createInternetGameDialogImpl::cancel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void createInternetGameDialogImpl::fillFormular(bool guestMode, QString playerName) {
|
||||
void createInternetGameDialogImpl::fillFormular(bool guestMode, QString playerName)
|
||||
{
|
||||
|
||||
//Network Game Settings
|
||||
spinBox_netDelayBetweenHands->setValue(myConfig->readConfigInt("NetDelayBetweenHands"));
|
||||
@@ -89,8 +93,7 @@ void createInternetGameDialogImpl::fillFormular(bool guestMode, QString playerNa
|
||||
lineEdit_gameName->setText(tr("%1's game").arg(playerName));
|
||||
lineEdit_gameName->setDisabled(true);
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
comboBox_gameType->setDisabled(false);
|
||||
comboBox_gameType->setCurrentIndex(myConfig->readConfigInt("InternetGameType"));
|
||||
lineEdit_gameName->setDisabled(false);
|
||||
@@ -100,19 +103,26 @@ void createInternetGameDialogImpl::fillFormular(bool guestMode, QString playerNa
|
||||
gameTypeChanged();
|
||||
}
|
||||
|
||||
void createInternetGameDialogImpl::keyPressEvent ( QKeyEvent * event ) {
|
||||
void createInternetGameDialogImpl::keyPressEvent ( QKeyEvent * event )
|
||||
{
|
||||
|
||||
|
||||
if (event->key() == 16777220) { pushButton_createGame->click(); } //ENTER
|
||||
if (event->key() == 16777220) {
|
||||
pushButton_createGame->click(); //ENTER
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void createInternetGameDialogImpl::clearGamePassword(bool clear) {
|
||||
void createInternetGameDialogImpl::clearGamePassword(bool clear)
|
||||
{
|
||||
|
||||
if(!clear) { lineEdit_Password->clear(); }
|
||||
if(!clear) {
|
||||
lineEdit_Password->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void createInternetGameDialogImpl::callChangeBlindsDialog(bool show) {
|
||||
void createInternetGameDialogImpl::callChangeBlindsDialog(bool show)
|
||||
{
|
||||
|
||||
if(show) {
|
||||
myChangeCompleteBlindsDialog->exec();
|
||||
@@ -124,7 +134,8 @@ void createInternetGameDialogImpl::callChangeBlindsDialog(bool show) {
|
||||
}
|
||||
}
|
||||
|
||||
void createInternetGameDialogImpl::gameTypeChanged() {
|
||||
void createInternetGameDialogImpl::gameTypeChanged()
|
||||
{
|
||||
|
||||
switch (comboBox_gameType->currentIndex()) {
|
||||
|
||||
@@ -193,8 +204,7 @@ void createInternetGameDialogImpl::gameTypeChanged() {
|
||||
myChangeCompleteBlindsDialog->radioButton_alwaysDoubleBlinds->setChecked(TRUE);
|
||||
myChangeCompleteBlindsDialog->radioButton_manualBlindsOrder->setChecked(FALSE);
|
||||
myChangeCompleteBlindsDialog->listWidget_blinds->clear();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//read config values
|
||||
myChangeCompleteBlindsDialog->spinBox_firstSmallBlind->setValue(myConfig->readConfigInt("NetFirstSmallBlind"));
|
||||
myChangeCompleteBlindsDialog->radioButton_raiseBlindsAtHands->setChecked(myConfig->readConfigInt("NetRaiseBlindsAtHands"));
|
||||
|
||||
@@ -29,13 +29,16 @@ class Session;
|
||||
class ConfigFile;
|
||||
class changeCompleteBlindsDialogImpl;
|
||||
|
||||
class createInternetGameDialogImpl: public QDialog, public Ui::createInternetGameDialog {
|
||||
class createInternetGameDialogImpl: public QDialog, public Ui::createInternetGameDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
createInternetGameDialogImpl(QWidget *parent = 0, ConfigFile *c = 0);
|
||||
|
||||
void exec(bool guestMode, QString playerName);
|
||||
changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() { return myChangeCompleteBlindsDialog; }
|
||||
changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() {
|
||||
return myChangeCompleteBlindsDialog;
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
@@ -47,21 +47,25 @@ createNetworkGameDialogImpl::createNetworkGameDialogImpl(QWidget *parent, Config
|
||||
}
|
||||
|
||||
|
||||
void createNetworkGameDialogImpl::exec() {
|
||||
void createNetworkGameDialogImpl::exec()
|
||||
{
|
||||
|
||||
fillFormular();
|
||||
QDialog::exec();
|
||||
}
|
||||
|
||||
void createNetworkGameDialogImpl::createGame() {
|
||||
void createNetworkGameDialogImpl::createGame()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void createNetworkGameDialogImpl::cancel() {
|
||||
void createNetworkGameDialogImpl::cancel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void createNetworkGameDialogImpl::fillFormular() {
|
||||
void createNetworkGameDialogImpl::fillFormular()
|
||||
{
|
||||
|
||||
//Network Game Settings
|
||||
spinBox_quantityPlayers->setValue(myConfig->readConfigInt("NetNumberOfPlayers"));
|
||||
@@ -95,20 +99,25 @@ void createNetworkGameDialogImpl::fillFormular() {
|
||||
myChangeCompleteBlindsDialog->radioButton_afterThisStayAtLastBlind->setChecked(myConfig->readConfigInt("NetAfterMBStayAtLastBlind"));
|
||||
}
|
||||
|
||||
void createNetworkGameDialogImpl::showDialog() {
|
||||
void createNetworkGameDialogImpl::showDialog()
|
||||
{
|
||||
|
||||
fillFormular();
|
||||
exec();
|
||||
}
|
||||
|
||||
void createNetworkGameDialogImpl::keyPressEvent ( QKeyEvent * event ) {
|
||||
void createNetworkGameDialogImpl::keyPressEvent ( QKeyEvent * event )
|
||||
{
|
||||
|
||||
|
||||
if (event->key() == 16777220) { pushButton_createGame->click(); } //ENTER
|
||||
if (event->key() == 16777220) {
|
||||
pushButton_createGame->click(); //ENTER
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void createNetworkGameDialogImpl::callChangeBlindsDialog(bool show) {
|
||||
void createNetworkGameDialogImpl::callChangeBlindsDialog(bool show)
|
||||
{
|
||||
|
||||
if(show) {
|
||||
myChangeCompleteBlindsDialog->exec();
|
||||
|
||||
@@ -30,13 +30,16 @@ class ConfigFile;
|
||||
class changeCompleteBlindsDialogImpl;
|
||||
|
||||
|
||||
class createNetworkGameDialogImpl: public QDialog, public Ui::createNetworkGameDialog {
|
||||
class createNetworkGameDialogImpl: public QDialog, public Ui::createNetworkGameDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
createNetworkGameDialogImpl(QWidget *parent = 0, ConfigFile *c = 0);
|
||||
|
||||
void exec();
|
||||
changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() { return myChangeCompleteBlindsDialog; }
|
||||
changeCompleteBlindsDialogImpl* getChangeCompleteBlindsDialog() {
|
||||
return myChangeCompleteBlindsDialog;
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
@@ -162,8 +162,7 @@ void gameLobbyDialogImpl::exec()
|
||||
|
||||
if(myConfig->readConfigInt("UseLobbyChat")) {
|
||||
groupBox_lobbyChat->show();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
groupBox_lobbyChat->hide();
|
||||
}
|
||||
readDialogSettings();
|
||||
@@ -171,8 +170,7 @@ void gameLobbyDialogImpl::exec()
|
||||
PlayerInfo playerInfo(mySession->getClientPlayerInfo(mySession->getClientUniquePlayerId()));
|
||||
if(playerInfo.isGuest) {
|
||||
guestUserMode();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
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;
|
||||
myChat->setSession(mySession);
|
||||
}
|
||||
@@ -215,16 +214,14 @@ void gameLobbyDialogImpl::createGame()
|
||||
if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_raiseBlindsAtHands->isChecked()) {
|
||||
gameData.raiseIntervalMode = RAISE_ON_HANDNUMBER;
|
||||
gameData.raiseSmallBlindEveryHandsValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryHands->value();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
gameData.raiseIntervalMode = RAISE_ON_MINUTES;
|
||||
gameData.raiseSmallBlindEveryMinutesValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_raiseSmallBlindEveryMinutes->value();
|
||||
}
|
||||
|
||||
if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_alwaysDoubleBlinds->isChecked()) {
|
||||
gameData.raiseMode = DOUBLE_BLINDS;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
gameData.raiseMode = MANUAL_BLINDS_ORDER;
|
||||
std::list<int> tempBlindList;
|
||||
int i;
|
||||
@@ -234,13 +231,15 @@ void gameLobbyDialogImpl::createGame()
|
||||
}
|
||||
gameData.manualBlindsList = tempBlindList;
|
||||
|
||||
if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) { gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS; }
|
||||
else {
|
||||
if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysDoubleBlinds->isChecked()) {
|
||||
gameData.afterManualBlindsMode = AFTERMB_DOUBLE_BLINDS;
|
||||
} else {
|
||||
if(myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->radioButton_afterThisAlwaysRaiseAbout->isChecked()) {
|
||||
gameData.afterManualBlindsMode = AFTERMB_RAISE_ABOUT;
|
||||
gameData.afterMBAlwaysRaiseValue = myCreateInternetGameDialog->getChangeCompleteBlindsDialog()->spinBox_afterThisAlwaysRaiseValue->value();
|
||||
} else {
|
||||
gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND;
|
||||
}
|
||||
else { gameData.afterManualBlindsMode = AFTERMB_STAY_AT_LAST_BLIND; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,8 +295,7 @@ void gameLobbyDialogImpl::joinGame()
|
||||
{
|
||||
assert(mySession);
|
||||
QItemSelectionModel *selection = treeView_GameList->selectionModel();
|
||||
if (!inGame && selection->hasSelection())
|
||||
{
|
||||
if (!inGame && selection->hasSelection()) {
|
||||
unsigned gameId = selection->selectedRows().first().data(Qt::UserRole).toUInt();
|
||||
GameInfo info(mySession->getClientGameInfo(gameId));
|
||||
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);
|
||||
|
||||
@@ -327,8 +326,7 @@ void gameLobbyDialogImpl::joinAnyGame() {
|
||||
|
||||
int players = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",0,0).toInt();
|
||||
int maxPlayers = myGameListModel->item(it, 1)->data(Qt::DisplayRole).toString().section("/",1,1).toInt();
|
||||
if (myGameListModel->item(it, 2)->data(16) == "open" && myGameListModel->item(it, 4)->data(16) == "nonpriv" && players < maxPlayers)
|
||||
{
|
||||
if (myGameListModel->item(it, 2)->data(16) == "open" && myGameListModel->item(it, 4)->data(16) == "nonpriv" && players < maxPlayers) {
|
||||
if(players > mostConnectedPlayers) {
|
||||
mostConnectedPlayers = players;
|
||||
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) {
|
||||
myGameListModel->clear();
|
||||
@@ -375,8 +374,7 @@ void gameLobbyDialogImpl::refresh(int actionID) {
|
||||
|
||||
this->accept();
|
||||
myW->show();
|
||||
}
|
||||
else if(actionID == MSG_NET_GAME_CLIENT_SYNCSTART) {
|
||||
} else if(actionID == MSG_NET_GAME_CLIENT_SYNCSTART) {
|
||||
|
||||
waitStartGameMsgBoxTimer->start(2000);
|
||||
}
|
||||
@@ -392,8 +390,7 @@ void gameLobbyDialogImpl::removedFromGame(int /*reason*/)
|
||||
void gameLobbyDialogImpl::gameSelected(const QModelIndex &index)
|
||||
{
|
||||
|
||||
if (!inGame && index.isValid() )
|
||||
{
|
||||
if (!inGame && index.isValid() ) {
|
||||
pushButton_JoinGame->setEnabled(true);
|
||||
|
||||
currentGameName = myGameListModel->item(myGameListSortFilterProxyModel->mapToSource(index).row(), 0)->text();
|
||||
@@ -438,8 +435,7 @@ void gameLobbyDialogImpl::gameSelected(const QModelIndex &index)
|
||||
treeWidget_connectedPlayers->clear();
|
||||
PlayerIdList::const_iterator i = info.players.begin();
|
||||
PlayerIdList::const_iterator end = info.players.end();
|
||||
while (i != end)
|
||||
{
|
||||
while (i != end) {
|
||||
bool admin = info.adminPlayerId == *i;
|
||||
PlayerInfo playerInfo(mySession->getClientPlayerInfo(*i));
|
||||
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 end = info.players.end();
|
||||
|
||||
while (i != end)
|
||||
{
|
||||
while (i != end) {
|
||||
if(myPlayerId == *i) {
|
||||
itemList.at(0)->setData( "MeInThisGame", 16);
|
||||
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(4)->setBackground(QBrush(QColor(0, 255, 0, 127)));
|
||||
break;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
itemList.at(0)->setData( "", 16);
|
||||
itemList.at(0)->setBackground(QBrush());
|
||||
itemList.at(1)->setBackground(QBrush());
|
||||
@@ -493,14 +487,16 @@ void gameLobbyDialogImpl::updateGameItem(QList <QStandardItem*> itemList, unsign
|
||||
QString playerStr;
|
||||
playerStr.sprintf("%u/%u", (unsigned)info.players.size(), (unsigned)info.data.maxNumberOfPlayers);
|
||||
itemList.at(1)->setData(playerStr, Qt::DisplayRole);
|
||||
if((unsigned)info.players.size() == (unsigned)info.data.maxNumberOfPlayers) { itemList.at(1)->setData("totalfull", 16); }
|
||||
else { itemList.at(1)->setData("nonfull", 16); }\
|
||||
if((unsigned)info.players.size() == (unsigned)info.data.maxNumberOfPlayers) {
|
||||
itemList.at(1)->setData("totalfull", 16);
|
||||
} else {
|
||||
itemList.at(1)->setData("nonfull", 16);
|
||||
}\
|
||||
|
||||
if (info.mode == GAME_MODE_STARTED) {
|
||||
itemList.at(2)->setData(tr("running"), Qt::DisplayRole);
|
||||
itemList.at(2)->setData("running", 16);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
itemList.at(2)->setData(tr("open"), Qt::DisplayRole);
|
||||
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)->setData(" ", Qt::DisplayRole);
|
||||
itemList.at(4)->setData("private", 16);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
itemList.at(4)->setData("", Qt::DisplayRole);
|
||||
itemList.at(4)->setData("nonpriv", 16);
|
||||
}
|
||||
@@ -566,8 +561,7 @@ void gameLobbyDialogImpl::updateGameMode(unsigned gameId, int /*newMode*/)
|
||||
{
|
||||
int it = 0;
|
||||
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;
|
||||
itemList << myGameListModel->item(it, 0) << myGameListModel->item(it, 1) << myGameListModel->item(it, 2) << myGameListModel->item(it, 3) << myGameListModel->item(it, 4);
|
||||
updateGameItem(itemList, gameId);
|
||||
@@ -586,8 +580,7 @@ void gameLobbyDialogImpl::removeGame(unsigned gameId)
|
||||
{
|
||||
int it = 0;
|
||||
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);
|
||||
break;
|
||||
}
|
||||
@@ -597,15 +590,20 @@ void gameLobbyDialogImpl::removeGame(unsigned gameId)
|
||||
refreshGameStats();
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::refreshGameStats() {
|
||||
void gameLobbyDialogImpl::refreshGameStats()
|
||||
{
|
||||
|
||||
int runningGamesCounter = 0;
|
||||
int openGamesCounter = 0;
|
||||
|
||||
int it = 0;
|
||||
while (myGameListModel->item(it)) {
|
||||
if (myGameListModel->item(it, 2)->data(16) == "running") { runningGamesCounter++; }
|
||||
if (myGameListModel->item(it, 2)->data(16) == "open") { openGamesCounter++; }
|
||||
if (myGameListModel->item(it, 2)->data(16) == "running") {
|
||||
runningGamesCounter++;
|
||||
}
|
||||
if (myGameListModel->item(it, 2)->data(16) == "open") {
|
||||
openGamesCounter++;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
@@ -617,7 +615,8 @@ void gameLobbyDialogImpl::refreshGameStats() {
|
||||
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::refreshPlayerStats() {
|
||||
void gameLobbyDialogImpl::refreshPlayerStats()
|
||||
{
|
||||
|
||||
ServerStats stats = mySession->getClientStats();
|
||||
label_connectedPlayersCounter->setText(tr("connected players: %1").arg(myNickListModel->rowCount()));
|
||||
@@ -625,8 +624,7 @@ void gameLobbyDialogImpl::refreshPlayerStats() {
|
||||
|
||||
void gameLobbyDialogImpl::gameAddPlayer(unsigned gameId, unsigned playerId)
|
||||
{
|
||||
if (!inGame)
|
||||
{
|
||||
if (!inGame) {
|
||||
QItemSelectionModel *selection = treeView_GameList->selectionModel();
|
||||
if (selection->hasSelection()) {
|
||||
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)
|
||||
{
|
||||
if (!inGame)
|
||||
{
|
||||
if (!inGame) {
|
||||
QItemSelectionModel *selection = treeView_GameList->selectionModel();
|
||||
if (selection->hasSelection()) {
|
||||
if(selection->selectedRows().at(0).data(Qt::UserRole).toUInt() == gameId) {
|
||||
@@ -777,7 +774,8 @@ void gameLobbyDialogImpl::clearDialog()
|
||||
readDialogSettings();
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::checkPlayerQuantity() {
|
||||
void gameLobbyDialogImpl::checkPlayerQuantity()
|
||||
{
|
||||
|
||||
assert(mySession);
|
||||
GameInfo info(mySession->getClientGameInfo(mySession->getClientCurrentGameId()));
|
||||
@@ -793,14 +791,12 @@ void gameLobbyDialogImpl::checkPlayerQuantity() {
|
||||
|
||||
if(treeWidget_connectedPlayers->topLevelItemCount() == treeWidget_connectedPlayers->headerItem()->data(0, Qt::UserRole).toInt()) {
|
||||
blinkingButtonAnimationTimer->start();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
blinkingButtonAnimationTimer->stop();
|
||||
blinkingButtonAnimationState = false;
|
||||
blinkingStartButtonAnimation();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
pushButton_StartGame->setEnabled(false);
|
||||
blinkingButtonAnimationTimer->stop();
|
||||
blinkingButtonAnimationState = false;
|
||||
@@ -816,7 +812,8 @@ void gameLobbyDialogImpl::checkPlayerQuantity() {
|
||||
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::blinkingStartButtonAnimation() {
|
||||
void gameLobbyDialogImpl::blinkingStartButtonAnimation()
|
||||
{
|
||||
|
||||
if(blinkingButtonAnimationState) {
|
||||
QPalette p = pushButton_StartGame->palette();
|
||||
@@ -824,16 +821,14 @@ void gameLobbyDialogImpl::blinkingStartButtonAnimation() {
|
||||
p.setColor(QPalette::ButtonText, QColor(Qt::white));
|
||||
pushButton_StartGame->setPalette(p);
|
||||
blinkingButtonAnimationState = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(pushButton_StartGame->isEnabled()) {
|
||||
QPalette p = pushButton_StartGame->palette();
|
||||
p.setColor(QPalette::Button, defaultStartButtonColor);
|
||||
p.setColor(QPalette::ButtonText, defaultStartButtonTextColor);
|
||||
pushButton_StartGame->setPalette(p);
|
||||
blinkingButtonAnimationState = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
QPalette p = pushButton_StartGame->palette();
|
||||
p.setColor(QPalette::Button, disabledStartButtonColor);
|
||||
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
|
||||
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);
|
||||
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(treeWidget_connectedPlayers->topLevelItemCount() < treeWidget_connectedPlayers->headerItem()->data(0, Qt::UserRole).toInt()) {
|
||||
myW->getMySDLPlayer()->playSound("playerconnected", 0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
myW->getMySDLPlayer()->playSound("onlinegameready", 0);
|
||||
showAutoStartTimer();
|
||||
}
|
||||
@@ -898,13 +894,13 @@ void gameLobbyDialogImpl::addConnectedPlayer(unsigned playerId, QString playerNa
|
||||
refreshConnectedPlayerAvatars();
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::updatePlayer(unsigned playerId, QString newPlayerName) {
|
||||
void gameLobbyDialogImpl::updatePlayer(unsigned playerId, QString newPlayerName)
|
||||
{
|
||||
|
||||
//rename player in connected players list
|
||||
QTreeWidgetItemIterator it(treeWidget_connectedPlayers);
|
||||
while (*it) {
|
||||
if ((*it)->data(0, Qt::UserRole) == playerId)
|
||||
{
|
||||
if ((*it)->data(0, Qt::UserRole) == playerId) {
|
||||
(*it)->setData(0, Qt::DisplayRole, newPlayerName);
|
||||
break;
|
||||
}
|
||||
@@ -927,14 +923,16 @@ void gameLobbyDialogImpl::updatePlayer(unsigned playerId, QString newPlayerName)
|
||||
myNickListModel->item(it1, 0)->setData(countryString, 33);
|
||||
if(playerInfo.isGuest || countryString.isEmpty()) {
|
||||
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)));
|
||||
}
|
||||
|
||||
unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerId);
|
||||
if(gameIdOfPlayer) { myNickListModel->item(it1, 0)->setData("active", 34); }
|
||||
else { myNickListModel->item(it1, 0)->setData("idle", 34); }
|
||||
if(gameIdOfPlayer) {
|
||||
myNickListModel->item(it1, 0)->setData("active", 34);
|
||||
} else {
|
||||
myNickListModel->item(it1, 0)->setData("idle", 34);
|
||||
}
|
||||
|
||||
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);
|
||||
while (*it) {
|
||||
if ((*it)->data(0, Qt::UserRole) == playerId)
|
||||
{
|
||||
if ((*it)->data(0, Qt::UserRole) == playerId) {
|
||||
treeWidget_connectedPlayers->takeTopLevelItem(treeWidget_connectedPlayers->indexOfTopLevelItem(*it));
|
||||
break;
|
||||
}
|
||||
@@ -988,14 +986,16 @@ void gameLobbyDialogImpl::playerJoinedLobby(unsigned playerId, QString /*playerN
|
||||
item->setData(countryString, 33);
|
||||
if(playerInfo.isGuest || countryString.isEmpty()) {
|
||||
item->setIcon(QIcon(":/cflags/cflags/undefined.png"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
item->setIcon(QIcon(QString(":/cflags/cflags/%1.png").arg(countryString)));
|
||||
}
|
||||
|
||||
unsigned gameIdOfPlayer = mySession->getGameIdOfPlayer(playerId);
|
||||
if(gameIdOfPlayer) { item->setData("active", 34); }
|
||||
else { item->setData("idle", 34); }
|
||||
if(gameIdOfPlayer) {
|
||||
item->setData("active", 34);
|
||||
} else {
|
||||
item->setData("idle", 34);
|
||||
}
|
||||
|
||||
|
||||
myNickListModel->appendRow(item);
|
||||
@@ -1013,14 +1013,14 @@ void gameLobbyDialogImpl::newGameAdmin(unsigned playerId, QString)
|
||||
++it;
|
||||
}
|
||||
|
||||
if (inGame && myPlayerId == playerId)
|
||||
{
|
||||
if (inGame && myPlayerId == playerId) {
|
||||
isGameAdministrator = true;
|
||||
checkPlayerQuantity();
|
||||
}
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::refreshConnectedPlayerAvatars() {
|
||||
void gameLobbyDialogImpl::refreshConnectedPlayerAvatars()
|
||||
{
|
||||
|
||||
QTreeWidgetItemIterator it(treeWidget_connectedPlayers);
|
||||
while (*it) {
|
||||
@@ -1047,7 +1047,8 @@ void gameLobbyDialogImpl::refreshConnectedPlayerAvatars() {
|
||||
}
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::joinedGameDialogUpdate() {
|
||||
void gameLobbyDialogImpl::joinedGameDialogUpdate()
|
||||
{
|
||||
|
||||
groupBox_GameInfo->setEnabled(true);
|
||||
groupBox_GameInfo->setTitle(currentGameName);
|
||||
@@ -1097,7 +1098,8 @@ void gameLobbyDialogImpl::joinedGameDialogUpdate() {
|
||||
header->setData(0, Qt::UserRole, info.data.maxNumberOfPlayers);
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::leftGameDialogUpdate() {
|
||||
void gameLobbyDialogImpl::leftGameDialogUpdate()
|
||||
{
|
||||
|
||||
// un-select current game.
|
||||
treeView_GameList->clearSelection();
|
||||
@@ -1135,16 +1137,19 @@ void gameLobbyDialogImpl::leftGameDialogUpdate() {
|
||||
lineEdit_ChatInput->setFocus();
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::updateDialogBlinds(const GameData &gameData) {
|
||||
void gameLobbyDialogImpl::updateDialogBlinds(const GameData &gameData)
|
||||
{
|
||||
|
||||
if(gameData.raiseIntervalMode == RAISE_ON_HANDNUMBER) { label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryHandsValue)+" "+tr("hands")); }
|
||||
else { label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryMinutesValue)+" "+tr("minutes")); }
|
||||
if(gameData.raiseIntervalMode == RAISE_ON_HANDNUMBER) {
|
||||
label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryHandsValue)+" "+tr("hands"));
|
||||
} else {
|
||||
label_blindsRaiseIntervall->setText(QString::number(gameData.raiseSmallBlindEveryMinutesValue)+" "+tr("minutes"));
|
||||
}
|
||||
if(gameData.raiseMode == DOUBLE_BLINDS) {
|
||||
label_blindsRaiseMode->setText(tr("double blinds"));
|
||||
label_blindsList->hide();
|
||||
label_gameDesc6->hide();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
label_blindsRaiseMode->setText(tr("manual blinds order"));
|
||||
label_blindsList->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)
|
||||
pushButton_Kick->setEnabled(isGameAdministrator);
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::startGame() {
|
||||
void gameLobbyDialogImpl::startGame()
|
||||
{
|
||||
|
||||
assert(mySession);
|
||||
mySession->sendStartEvent(checkBox_fillUpWithComputerOpponents->isChecked());
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::leaveGame() {
|
||||
void gameLobbyDialogImpl::leaveGame()
|
||||
{
|
||||
|
||||
assert(mySession);
|
||||
mySession->sendLeaveCurrentGame();
|
||||
@@ -1185,18 +1193,19 @@ void gameLobbyDialogImpl::leaveGame() {
|
||||
waitStartGameMsgBox->hide();
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::kickPlayer() {
|
||||
void gameLobbyDialogImpl::kickPlayer()
|
||||
{
|
||||
|
||||
QTreeWidgetItem *item = treeWidget_connectedPlayers->currentItem();
|
||||
if (item)
|
||||
{
|
||||
if (item) {
|
||||
QString playerName = item->text(0);
|
||||
if(playerName == QString::fromUtf8(myConfig->readConfigString("MyName").c_str())) {
|
||||
{ QMessageBox::warning(this, tr("Server Error"),
|
||||
{
|
||||
QMessageBox::warning(this, tr("Server Error"),
|
||||
tr("You should not kick yourself from this game!"),
|
||||
QMessageBox::Close); }
|
||||
QMessageBox::Close);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assert(mySession);
|
||||
mySession->kickPlayer(item->data(0, Qt::UserRole).toUInt());
|
||||
}
|
||||
@@ -1204,23 +1213,30 @@ void gameLobbyDialogImpl::kickPlayer() {
|
||||
pushButton_Kick->setEnabled(false);
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::keyPressEvent ( QKeyEvent * event ) {
|
||||
void gameLobbyDialogImpl::keyPressEvent ( QKeyEvent * event )
|
||||
{
|
||||
|
||||
// qDebug() << event->key() << "\n";
|
||||
|
||||
if (event->key() == Qt::Key_Enter && lineEdit_ChatInput->hasFocus()) { myChat->sendMessage(); }
|
||||
if (event->key() == Qt::Key_Enter && lineEdit_ChatInput->hasFocus()) {
|
||||
myChat->sendMessage();
|
||||
}
|
||||
|
||||
if (event->key() == Qt::Key_Up && lineEdit_ChatInput->hasFocus()) {
|
||||
if((keyUpCounter + 1) <= myChat->getChatLinesHistorySize()) { keyUpCounter++; }
|
||||
if((keyUpCounter + 1) <= myChat->getChatLinesHistorySize()) {
|
||||
keyUpCounter++;
|
||||
}
|
||||
// std::cout << "Up keyUpCounter: " << keyUpCounter << "\n";
|
||||
myChat->showChatHistoryIndex(keyUpCounter);
|
||||
} else if(event->key() == Qt::Key_Down && lineEdit_ChatInput->hasFocus()) {
|
||||
if((keyUpCounter - 1) >= 0) {
|
||||
keyUpCounter--;
|
||||
}
|
||||
else if(event->key() == Qt::Key_Down && lineEdit_ChatInput->hasFocus()) {
|
||||
if((keyUpCounter - 1) >= 0) { keyUpCounter--; }
|
||||
// std::cout << "Down keyUpCounter: " << keyUpCounter << "\n";
|
||||
myChat->showChatHistoryIndex(keyUpCounter);
|
||||
} else {
|
||||
keyUpCounter = 0;
|
||||
}
|
||||
else { keyUpCounter = 0; }
|
||||
|
||||
// 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) {
|
||||
myChat->nickAutoCompletition();
|
||||
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();
|
||||
return QDialog::eventFilter(obj, event);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// pass the event on to the parent class
|
||||
return QDialog::eventFilter(obj, event);
|
||||
}
|
||||
}
|
||||
|
||||
bool gameLobbyDialogImpl::event ( QEvent * event ) {
|
||||
bool gameLobbyDialogImpl::event ( QEvent * event )
|
||||
{
|
||||
|
||||
return QDialog::event(event);
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::showGameDescription(bool show) {
|
||||
void gameLobbyDialogImpl::showGameDescription(bool show)
|
||||
{
|
||||
|
||||
if(show) {
|
||||
label_gameType->show();
|
||||
@@ -1263,8 +1279,7 @@ void gameLobbyDialogImpl::showGameDescription(bool show) {
|
||||
label_gameDesc5->show();
|
||||
label_gameDesc6->show();
|
||||
label_gameDesc7->show();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
label_gameType->hide();
|
||||
label_gameDesc2->hide();
|
||||
label_gameDesc3->hide();
|
||||
@@ -1275,7 +1290,8 @@ void gameLobbyDialogImpl::showGameDescription(bool show) {
|
||||
}
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::showWaitStartGameMsgBox() {
|
||||
void gameLobbyDialogImpl::showWaitStartGameMsgBox()
|
||||
{
|
||||
|
||||
if(this->isVisible()) {
|
||||
waitStartGameMsgBox->show();
|
||||
@@ -1284,7 +1300,8 @@ void gameLobbyDialogImpl::showWaitStartGameMsgBox() {
|
||||
}
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::joinAnyGameButtonRefresh() {
|
||||
void gameLobbyDialogImpl::joinAnyGameButtonRefresh()
|
||||
{
|
||||
|
||||
int openNonPrivateNonFullGamesCounter = 0;
|
||||
|
||||
@@ -1335,7 +1352,8 @@ void gameLobbyDialogImpl::writeDialogSettings(int saveMode)
|
||||
myConfig->writeConfigInt("DlgGameLobbyNickListSortFilterIndex", comboBox_nickListFilter->currentIndex());
|
||||
}
|
||||
break;
|
||||
default:;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
myConfig->writeBuffer();
|
||||
@@ -1348,7 +1366,8 @@ void gameLobbyDialogImpl::readDialogSettings()
|
||||
comboBox_nickListFilter->setCurrentIndex(myConfig->readConfigInt("DlgGameLobbyNickListSortFilterIndex"));
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::changeGameListFilter(int index) {
|
||||
void gameLobbyDialogImpl::changeGameListFilter(int index)
|
||||
{
|
||||
|
||||
switch(index) {
|
||||
case 0: {
|
||||
@@ -1386,7 +1405,8 @@ void gameLobbyDialogImpl::changeGameListFilter(int index) {
|
||||
myGameListSortFilterProxyModel->setColumn4RegExp(QRegExp("private", Qt::CaseInsensitive, QRegExp::FixedString));
|
||||
}
|
||||
break;
|
||||
default:;
|
||||
default:
|
||||
;
|
||||
}
|
||||
myGameListSortFilterProxyModel->setFilterRegExp(QString());
|
||||
myGameListSortFilterProxyModel->setFilterKeyColumn(0);
|
||||
@@ -1409,7 +1429,8 @@ void gameLobbyDialogImpl::changeNickListFilter(int state)
|
||||
writeDialogSettings(2);
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::changeGameListSorting() {
|
||||
void gameLobbyDialogImpl::changeGameListSorting()
|
||||
{
|
||||
|
||||
writeDialogSettings(0);
|
||||
}
|
||||
@@ -1442,8 +1463,7 @@ void gameLobbyDialogImpl::showNickListContextMenu(QPoint p)
|
||||
nickListInviteAction->setEnabled(true);
|
||||
nickListInviteAction->setText(tr("Invite %1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str())));
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
nickListInviteAction->setText(tr("Invite player ..."));
|
||||
nickListInviteAction->setEnabled(false);
|
||||
}
|
||||
@@ -1452,8 +1472,7 @@ void gameLobbyDialogImpl::showNickListContextMenu(QPoint p)
|
||||
|
||||
nickListIgnorePlayerAction->setEnabled(true);
|
||||
nickListIgnorePlayerAction->setText(tr("Ignore %1").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str())));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
nickListIgnorePlayerAction->setEnabled(false);
|
||||
nickListIgnorePlayerAction->setText(tr("Ignore player ..."));
|
||||
@@ -1464,8 +1483,7 @@ void gameLobbyDialogImpl::showNickListContextMenu(QPoint p)
|
||||
QString playerInGameInfoString;
|
||||
if(gameIdOfPlayer) {
|
||||
playerInGameInfoString = tr("%1 is playing in \"%2\".").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str())).arg(QString::fromUtf8(mySession->getClientGameInfo(gameIdOfPlayer).name.c_str()));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
playerInGameInfoString = tr("%1 is not playing at the moment.").arg(QString::fromUtf8(mySession->getClientPlayerInfo(playerUid).playerName.c_str()));
|
||||
}
|
||||
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);
|
||||
}
|
||||
break;
|
||||
default:;
|
||||
default:
|
||||
;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1502,8 +1521,7 @@ void gameLobbyDialogImpl::showInvitationDialog(unsigned gameId, unsigned playerI
|
||||
if(inviteDialogIsCurrentlyShown || playerIsOnIgnoreList(playerIdFrom)) {
|
||||
|
||||
mySession->rejectGameInvitation(gameId, DENY_GAME_INVITATION_BUSY);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
inviteDialogIsCurrentlyShown = true;
|
||||
|
||||
@@ -1512,8 +1530,7 @@ void gameLobbyDialogImpl::showInvitationDialog(unsigned gameId, unsigned playerI
|
||||
|
||||
mySession->acceptGameInvitation(gameId);
|
||||
inviteDialogIsCurrentlyShown = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mySession->rejectGameInvitation(gameId, DENY_GAME_INVITATION_NO);
|
||||
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>::iterator it1;
|
||||
@@ -1552,7 +1570,8 @@ bool gameLobbyDialogImpl::playerIsOnIgnoreList(unsigned playerId) {
|
||||
}
|
||||
|
||||
|
||||
void gameLobbyDialogImpl::putPlayerOnIgnoreList() {
|
||||
void gameLobbyDialogImpl::putPlayerOnIgnoreList()
|
||||
{
|
||||
|
||||
if(myNickListSelectionModel->currentIndex().isValid()) {
|
||||
|
||||
@@ -1599,8 +1618,7 @@ void gameLobbyDialogImpl::updateAutoStartTimer()
|
||||
if(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>");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
autoStartTimer->stop();
|
||||
autoStartTimerOverlay->hide();
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ class MyNickListSortFilterProxyModel;
|
||||
@author FThauer FHammer <webmaster@pokerth.net>
|
||||
*/
|
||||
|
||||
class gameLobbyDialogImpl: public QDialog, public Ui::gameLobbyDialog {
|
||||
class gameLobbyDialogImpl: public QDialog, public Ui::gameLobbyDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
gameLobbyDialogImpl(startWindowImpl *parent = 0, ConfigFile* = 0);
|
||||
@@ -44,12 +45,19 @@ public:
|
||||
|
||||
void exec();
|
||||
|
||||
ChatTools *getMyChat() { return myChat; }
|
||||
ChatTools *getMyChat() {
|
||||
return myChat;
|
||||
}
|
||||
|
||||
void setSession(boost::shared_ptr<Session> session);
|
||||
boost::shared_ptr<Session> getSession() { assert(mySession.get()); return mySession; }
|
||||
boost::shared_ptr<Session> getSession() {
|
||||
assert(mySession.get());
|
||||
return mySession;
|
||||
}
|
||||
|
||||
void setMyW ( gameTableImpl* theValue ) { myW = theValue; }
|
||||
void setMyW ( gameTableImpl* theValue ) {
|
||||
myW = theValue;
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -69,9 +77,15 @@ public slots:
|
||||
void updateStats(ServerStats stats);
|
||||
void refreshGameStats();
|
||||
void refreshPlayerStats();
|
||||
void setCurrentGameName ( const QString& theValue ) { currentGameName = theValue; }
|
||||
QString getCurrentGameName() const { return currentGameName; }
|
||||
gameTableImpl* getMyW() const { return myW; }
|
||||
void setCurrentGameName ( const QString& theValue ) {
|
||||
currentGameName = theValue;
|
||||
}
|
||||
QString getCurrentGameName() const {
|
||||
return currentGameName;
|
||||
}
|
||||
gameTableImpl* getMyW() const {
|
||||
return myW;
|
||||
}
|
||||
void checkPlayerQuantity();
|
||||
void blinkingStartButtonAnimation();
|
||||
void joinedNetworkGame(unsigned, QString, bool);
|
||||
|
||||
@@ -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 index1 = sourceModel()->index(sourceRow, 1, sourceParent);
|
||||
|
||||
@@ -9,10 +9,18 @@ Q_OBJECT
|
||||
|
||||
public:
|
||||
MyGameListSortFilterProxyModel(QObject *parent = 0);
|
||||
void setColumn1RegExp(QRegExp column1) { column1RegExp = column1; }
|
||||
void setColumn2RegExp(QRegExp column2) { column2RegExp = column2; }
|
||||
void setColumn3RegExp(QRegExp column3) { column3RegExp = column3; }
|
||||
void setColumn4RegExp(QRegExp column4) { column4RegExp = column4; }
|
||||
void setColumn1RegExp(QRegExp column1) {
|
||||
column1RegExp = column1;
|
||||
}
|
||||
void setColumn2RegExp(QRegExp column2) {
|
||||
column2RegExp = column2;
|
||||
}
|
||||
void setColumn3RegExp(QRegExp column3) {
|
||||
column3RegExp = column3;
|
||||
}
|
||||
void setColumn4RegExp(QRegExp column4) {
|
||||
column4RegExp = column4;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
||||
|
||||
@@ -28,7 +28,8 @@ MyGameListTreeWidget::~MyGameListTreeWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void MyGameListTreeWidget::setGameListBackgroundImage(QString pmString) {
|
||||
void MyGameListTreeWidget::setGameListBackgroundImage(QString pmString)
|
||||
{
|
||||
|
||||
gameListBGPixmap.load(pmString);
|
||||
}
|
||||
@@ -53,7 +54,8 @@ void MyGameListTreeWidget::setGameListBackgroundImage(QString pmString) {
|
||||
// QTreeWidget::paintEvent(event);
|
||||
// }
|
||||
|
||||
void MyGameListTreeWidget::scrollContentsBy ( int dx, int dy ) {
|
||||
void MyGameListTreeWidget::scrollContentsBy ( int dx, int dy )
|
||||
{
|
||||
|
||||
viewport()->update();
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,7 +51,8 @@ class CardDeckStyleReader;
|
||||
|
||||
class SDLPlayer;
|
||||
|
||||
class gameTableImpl: public QMainWindow, public Ui::gameTable {
|
||||
class gameTableImpl: public QMainWindow, public Ui::gameTable
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@@ -60,14 +61,28 @@ public:
|
||||
~gameTableImpl();
|
||||
|
||||
boost::shared_ptr<Session> getSession();
|
||||
SDLPlayer* getMySDLPlayer() const { return mySDLPlayer; }
|
||||
ChatTools* getMyChat() const { return myChat; }
|
||||
ConfigFile* getMyConfig() const { return myConfig; }
|
||||
GameTableStyleReader* getMyGameTableStyle() const { return myGameTableStyle; }
|
||||
bool getGuestMode() const { return guestMode; }
|
||||
SDLPlayer* getMySDLPlayer() const {
|
||||
return mySDLPlayer;
|
||||
}
|
||||
ChatTools* getMyChat() const {
|
||||
return myChat;
|
||||
}
|
||||
ConfigFile* getMyConfig() const {
|
||||
return myConfig;
|
||||
}
|
||||
GameTableStyleReader* getMyGameTableStyle() const {
|
||||
return myGameTableStyle;
|
||||
}
|
||||
bool getGuestMode() const {
|
||||
return guestMode;
|
||||
}
|
||||
|
||||
void setStartWindow(startWindowImpl* s) { myStartWindow = s; }
|
||||
void setGuiLog(guiLog* l) { myGuiLog = l; }
|
||||
void setStartWindow(startWindowImpl* s) {
|
||||
myStartWindow = s;
|
||||
}
|
||||
void setGuiLog(guiLog* l) {
|
||||
myGuiLog = l;
|
||||
}
|
||||
|
||||
void setSpeeds();
|
||||
|
||||
@@ -160,7 +175,10 @@ public slots:
|
||||
void startTimeoutAnimation(int playerId, int timoutSec);
|
||||
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 applySettings(settingsDialogImpl*);
|
||||
|
||||
+796
-399
File diff suppressed because it is too large
Load Diff
@@ -25,7 +25,8 @@ MyActionButton::~MyActionButton()
|
||||
}
|
||||
|
||||
|
||||
void MyActionButton::paintEvent(QPaintEvent * event) {
|
||||
void MyActionButton::paintEvent(QPaintEvent * event)
|
||||
{
|
||||
|
||||
QPushButton::paintEvent(event);
|
||||
|
||||
@@ -37,11 +38,9 @@ void MyActionButton::paintEvent(QPaintEvent * event) {
|
||||
painter.setFont(f);
|
||||
if(objectName()==("pushButton_AllIn")) {
|
||||
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"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
painter.drawText(8,15,15,15,Qt::AlignLeft,fKeyText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,13 @@ public:
|
||||
~MyActionButton();
|
||||
|
||||
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:
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ MyAvatarLabel::~MyAvatarLabel()
|
||||
{
|
||||
}
|
||||
|
||||
void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) {
|
||||
void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event )
|
||||
{
|
||||
|
||||
assert(myW->getSession()->getCurrentGame());
|
||||
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()) {
|
||||
setVoteOnKickContextMenuEnabled(TRUE);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setVoteOnKickContextMenuEnabled(FALSE);
|
||||
}
|
||||
|
||||
@@ -78,12 +78,10 @@ void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) {
|
||||
for (it_c=seatList->begin(); it_c!=seatList->end(); ++it_c) {
|
||||
|
||||
if(myId == j) {
|
||||
if(j == 0)
|
||||
{
|
||||
if(j == 0) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -94,8 +92,7 @@ void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) {
|
||||
|
||||
if(myW->getSession()->getGameType() == Session::GAME_TYPE_INTERNET && !((*it_c)->getMyAvatar().empty()) ) {
|
||||
action_ReportBadAvatar->setVisible(TRUE);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
action_ReportBadAvatar->setVisible(FALSE);
|
||||
}
|
||||
}
|
||||
@@ -115,7 +112,8 @@ void MyAvatarLabel::contextMenuEvent ( QContextMenuEvent *event ) {
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatarLabel::showContextMenu(const QPoint &pos) {
|
||||
void MyAvatarLabel::showContextMenu(const QPoint &pos)
|
||||
{
|
||||
|
||||
myContextMenu->popup(pos);
|
||||
}
|
||||
@@ -133,18 +131,14 @@ std::string separator="(!#$%)";
|
||||
std::list<std::string>::iterator iterator;
|
||||
for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) {
|
||||
tipInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive);
|
||||
if(tipInfo.at(0)==playerInfoList.at(0))
|
||||
{
|
||||
if(tipInfo.at(0)==playerInfoList.at(0)) {
|
||||
result.push_back(tipInfo.at(0).toUtf8().constData()+separator+tipInfo.at(1).toUtf8().constData()+separator+playerInfoList.at(1).toUtf8().constData()+separator);
|
||||
found=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
result.push_back(tipInfo.at(0).toUtf8().constData()+separator+tipInfo.at(1).toUtf8().constData()+separator+tipInfo.at(2).toUtf8().constData()+separator);
|
||||
}
|
||||
}
|
||||
if(found==0)
|
||||
{
|
||||
if(found==0) {
|
||||
result.push_back(playerInfoList.at(0).toUtf8().constData()+separator+separator+playerInfoList.at(1).toUtf8().constData()+separator);
|
||||
}
|
||||
myW->getMyConfig()->writeConfigStringList("PlayerTooltips", result);
|
||||
@@ -155,13 +149,10 @@ refreshStars();
|
||||
|
||||
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->setCurrentIndex(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
myW->tabWidget_Left->insertTab(2, myW->tab_editTip, playerName);
|
||||
myW->tabWidget_Left->setCurrentIndex(2);
|
||||
}
|
||||
@@ -179,12 +170,10 @@ for (seatPlace=0,it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c, seatPl
|
||||
if(myW->myStartWindow->getSession()->getGameType() == Session::GAME_TYPE_INTERNET && !myW->getSession()->getClientPlayerInfo((*it_c)->getMyUniqueID()).isGuest && (*it_c)->getMyType() != PLAYER_TYPE_COMPUTER)
|
||||
if((*it_c)->getMyStayOnTableStatus() == TRUE && (*it_c)->getMyName()!="" && seatPlace!=0) {
|
||||
int playerStars=getPlayerRating(QString::fromUtf8((*it_c)->getMyName().c_str()));
|
||||
for(int i=1;i<=5;i++)
|
||||
{
|
||||
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)+"'>☆</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)+"'>★</a>");
|
||||
}
|
||||
|
||||
@@ -192,7 +181,8 @@ for (seatPlace=0,it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c, seatPl
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatarLabel::refreshTooltips() {
|
||||
void MyAvatarLabel::refreshTooltips()
|
||||
{
|
||||
boost::shared_ptr<Game> currentGame = myW->myStartWindow->getSession()->getCurrentGame();
|
||||
PlayerListConstIterator it_c;
|
||||
int seatPlace;
|
||||
@@ -200,22 +190,19 @@ void MyAvatarLabel::refreshTooltips() {
|
||||
for (seatPlace=0,it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c, seatPlace++) {
|
||||
if((*it_c)->getMyStayOnTableStatus() == TRUE || (*it_c)->getMyActiveStatus()) {
|
||||
bool computerPlayer = false;
|
||||
if((*it_c)->getMyType() == PLAYER_TYPE_COMPUTER) { computerPlayer = true; }
|
||||
if(!computerPlayer && getPlayerTip(QString::fromUtf8((*it_c)->getMyName().c_str()))!="")
|
||||
{
|
||||
if((*it_c)->getMyType() == PLAYER_TYPE_COMPUTER) {
|
||||
computerPlayer = true;
|
||||
}
|
||||
if(!computerPlayer && getPlayerTip(QString::fromUtf8((*it_c)->getMyName().c_str()))!="") {
|
||||
myW->playerTipLabelArray[(*it_c)->getMyID()]->setText(QString("<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->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()]->setToolTip("");
|
||||
myW->playerAvatarLabelArray[(*it_c)->getMyID()]->setToolTip("");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
myW->playerTipLabelArray[(*it_c)->getMyID()]->setText("");
|
||||
myW->playerTipLabelArray[(*it_c)->getMyID()]->setToolTip("");
|
||||
myW->playerAvatarLabelArray[(*it_c)->getMyID()]->setToolTip("");
|
||||
@@ -235,8 +222,7 @@ QStringList playerInfo;
|
||||
QString result="0";
|
||||
for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) {
|
||||
playerInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive);
|
||||
if(playerInfo.at(0)==playerName)
|
||||
{
|
||||
if(playerInfo.at(0)==playerName) {
|
||||
result=playerInfo.at(2);
|
||||
break;
|
||||
}
|
||||
@@ -272,29 +258,22 @@ std::list<std::string> result;
|
||||
std::list<std::string>::iterator iterator;
|
||||
for(iterator = tipsList.begin(); iterator != tipsList.end(); ++iterator) {
|
||||
playerInfo=QString::fromUtf8(iterator->c_str()).split("(!#$%)", QString::KeepEmptyParts, Qt::CaseSensitive);
|
||||
if(QString::fromUtf8(playerName.c_str())==playerInfo.at(0))
|
||||
{
|
||||
if(QString::fromUtf8(playerName.c_str())==playerInfo.at(0)) {
|
||||
result.push_back(playerName+separator+QString::fromUtf8(tip.c_str()).toUtf8().constData()+separator+playerInfo.at(2).toStdString()+separator);
|
||||
found=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
myW->getMyConfig()->writeConfigStringList("PlayerTooltips", result);
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
refreshTooltips();
|
||||
@@ -316,7 +295,8 @@ void MyAvatarLabel::setVoteOnKickContextMenuEnabled(bool b)
|
||||
action_VoteForKick->setEnabled(b);
|
||||
}
|
||||
|
||||
void MyAvatarLabel::setPixmap ( const QPixmap &pix, const bool trans) {
|
||||
void MyAvatarLabel::setPixmap ( const QPixmap &pix, const bool trans)
|
||||
{
|
||||
|
||||
myPixmap = pix.scaled(50,50, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
transparent = trans;
|
||||
@@ -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));
|
||||
QPainter painter(&resultAvatar);
|
||||
int showCountryFlags = myW->getMyConfig()->readConfigInt("ShowCountryFlagInAvatar");
|
||||
if(showCountryFlags && !countryString.isEmpty())
|
||||
{
|
||||
if(seatPlace<=2||seatPlace>=8)
|
||||
{
|
||||
if(showCountryFlags && !countryString.isEmpty()) {
|
||||
if(seatPlace<=2||seatPlace>=8) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -347,7 +324,8 @@ void MyAvatarLabel::setPixmapAndCountry ( const QPixmap &pix,QString countryStri
|
||||
|
||||
}
|
||||
|
||||
void MyAvatarLabel::paintEvent(QPaintEvent*) {
|
||||
void MyAvatarLabel::paintEvent(QPaintEvent*)
|
||||
{
|
||||
|
||||
QPainter painter(this);
|
||||
if(transparent)
|
||||
@@ -358,7 +336,8 @@ void MyAvatarLabel::paintEvent(QPaintEvent*) {
|
||||
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>::iterator it1;
|
||||
@@ -372,7 +351,8 @@ bool MyAvatarLabel::playerIsOnIgnoreList(QString playerName) {
|
||||
}
|
||||
|
||||
|
||||
void MyAvatarLabel::putPlayerOnIgnoreList() {
|
||||
void MyAvatarLabel::putPlayerOnIgnoreList()
|
||||
{
|
||||
|
||||
QStringList list;
|
||||
PlayerListConstIterator it_c;
|
||||
@@ -396,7 +376,8 @@ void MyAvatarLabel::putPlayerOnIgnoreList() {
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatarLabel::reportBadAvatar() {
|
||||
void MyAvatarLabel::reportBadAvatar()
|
||||
{
|
||||
|
||||
boost::shared_ptr<Game> currentGame = myW->getSession()->getCurrentGame();
|
||||
int j=0;
|
||||
@@ -425,7 +406,8 @@ void MyAvatarLabel::reportBadAvatar() {
|
||||
}
|
||||
|
||||
|
||||
void MyAvatarLabel::startEditTip() {
|
||||
void MyAvatarLabel::startEditTip()
|
||||
{
|
||||
boost::shared_ptr<Game> currentGame = myW->getSession()->getCurrentGame();
|
||||
int j=0;
|
||||
PlayerListConstIterator it_c;
|
||||
|
||||
@@ -27,8 +27,12 @@ public:
|
||||
MyAvatarLabel(QGroupBox*);
|
||||
~MyAvatarLabel();
|
||||
|
||||
void setMyW(gameTableImpl* theValue) { myW = theValue; }
|
||||
void setMyId ( int theValue ) { myId = theValue; }
|
||||
void setMyW(gameTableImpl* theValue) {
|
||||
myW = theValue;
|
||||
}
|
||||
void setMyId ( int theValue ) {
|
||||
myId = theValue;
|
||||
}
|
||||
void contextMenuEvent ( QContextMenuEvent * event );
|
||||
QString getPlayerTip(QString);
|
||||
int getPlayerRating(QString);
|
||||
@@ -39,10 +43,14 @@ public slots:
|
||||
void sendTriggerVoteOnKickSignal();
|
||||
void setEnabledContextMenu(bool);
|
||||
void setVoteOnKickContextMenuEnabled(bool);
|
||||
void setVoteRunning ( bool theValue ) { voteRunning = theValue; }
|
||||
void setVoteRunning ( bool theValue ) {
|
||||
voteRunning = theValue;
|
||||
}
|
||||
void setPixmap ( const QPixmap &, const bool = FALSE);
|
||||
void setPixmapAndCountry ( const QPixmap &, QString country, int seatPlace, const bool = FALSE);
|
||||
void setPixmapPath ( const QString theValue) { myPath = theValue; }
|
||||
void setPixmapPath ( const QString theValue) {
|
||||
myPath = theValue;
|
||||
}
|
||||
void paintEvent(QPaintEvent*);
|
||||
void putPlayerOnIgnoreList();
|
||||
bool playerIsOnIgnoreList(QString playerName);
|
||||
|
||||
@@ -43,13 +43,20 @@ MyCardsPixmapLabel::~MyCardsPixmapLabel()
|
||||
{
|
||||
}
|
||||
|
||||
void MyCardsPixmapLabel::startFadeOut(int speed) {
|
||||
void MyCardsPixmapLabel::startFadeOut(int speed)
|
||||
{
|
||||
|
||||
frameOpacity = 1.0;
|
||||
|
||||
if(speed <= 4) { opacityRaiseInterval = 0.01; }
|
||||
if(speed > 4 && speed <= 7) { opacityRaiseInterval = 0.02; }
|
||||
if(speed > 7 && speed <= 10) { opacityRaiseInterval = 0.04; }
|
||||
if(speed <= 4) {
|
||||
opacityRaiseInterval = 0.01;
|
||||
}
|
||||
if(speed > 4 && speed <= 7) {
|
||||
opacityRaiseInterval = 0.02;
|
||||
}
|
||||
if(speed > 7 && speed <= 10) {
|
||||
opacityRaiseInterval = 0.04;
|
||||
}
|
||||
|
||||
if(speed != 11) {
|
||||
fadeOutAction = TRUE;
|
||||
@@ -59,7 +66,8 @@ void MyCardsPixmapLabel::startFadeOut(int speed) {
|
||||
|
||||
}
|
||||
|
||||
void MyCardsPixmapLabel::stopFadeOut() {
|
||||
void MyCardsPixmapLabel::stopFadeOut()
|
||||
{
|
||||
|
||||
fadeOutTimer->stop();
|
||||
fadeOutAction = FALSE;
|
||||
@@ -69,13 +77,13 @@ void MyCardsPixmapLabel::stopFadeOut() {
|
||||
|
||||
|
||||
|
||||
void MyCardsPixmapLabel::nextFadeOutFrame() {
|
||||
void MyCardsPixmapLabel::nextFadeOutFrame()
|
||||
{
|
||||
|
||||
if (frameOpacity > 0.25) {
|
||||
frameOpacity -= opacityRaiseInterval;
|
||||
update();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
fadeOutTimer->stop();
|
||||
// fadeOutAction = FALSE;
|
||||
@@ -83,7 +91,8 @@ void MyCardsPixmapLabel::nextFadeOutFrame() {
|
||||
|
||||
}
|
||||
|
||||
void MyCardsPixmapLabel::startFlipCards(int speed, const QPixmap &frontPix, const QPixmap &flipsidePix) {
|
||||
void MyCardsPixmapLabel::startFlipCards(int speed, const QPixmap &frontPix, const QPixmap &flipsidePix)
|
||||
{
|
||||
|
||||
stopFadeOut();
|
||||
|
||||
@@ -98,10 +107,18 @@ void MyCardsPixmapLabel::startFlipCards(int speed, const QPixmap &frontPix, cons
|
||||
front = frontPix.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);;
|
||||
flipside = flipsidePix.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);;
|
||||
|
||||
if(speed <= 4) { flipCardsScaleIntervall = 0.1; }
|
||||
if(speed > 4 && speed <= 6) { flipCardsScaleIntervall = 0.20; }
|
||||
if(speed > 6 && speed <= 8) { flipCardsScaleIntervall = 0.25; }
|
||||
if(speed > 8 && speed <= 10) { flipCardsScaleIntervall = 0.5; }
|
||||
if(speed <= 4) {
|
||||
flipCardsScaleIntervall = 0.1;
|
||||
}
|
||||
if(speed > 4 && speed <= 6) {
|
||||
flipCardsScaleIntervall = 0.20;
|
||||
}
|
||||
if(speed > 6 && speed <= 8) {
|
||||
flipCardsScaleIntervall = 0.25;
|
||||
}
|
||||
if(speed > 8 && speed <= 10) {
|
||||
flipCardsScaleIntervall = 0.5;
|
||||
}
|
||||
//
|
||||
|
||||
if(speed != 11) {
|
||||
@@ -111,7 +128,8 @@ void MyCardsPixmapLabel::startFlipCards(int speed, const QPixmap &frontPix, cons
|
||||
|
||||
}
|
||||
|
||||
void MyCardsPixmapLabel::stopFlipCardsAnimation() {
|
||||
void MyCardsPixmapLabel::stopFlipCardsAnimation()
|
||||
{
|
||||
|
||||
flipCardsTimer->stop();
|
||||
flipCardsAction1 = FALSE;
|
||||
@@ -120,26 +138,24 @@ void MyCardsPixmapLabel::stopFlipCardsAnimation() {
|
||||
update();
|
||||
}
|
||||
|
||||
void MyCardsPixmapLabel::nextFlipCardsFrame() {
|
||||
void MyCardsPixmapLabel::nextFlipCardsFrame()
|
||||
{
|
||||
|
||||
if (frameFlipCardsAction1Size > 0.1 ) {
|
||||
//erst flipside verkleinern
|
||||
frameFlipCardsAction1Size -= flipCardsScaleIntervall;
|
||||
update();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if(flipCardsAction1) {
|
||||
flipCardsAction1 = FALSE;
|
||||
flipCardsAction2 = TRUE;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//dann front vergrößern
|
||||
if (frameFlipCardsAction2Size < 0.9 ) {
|
||||
|
||||
frameFlipCardsAction2Size += flipCardsScaleIntervall;
|
||||
update();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
flipCardsAction2 = FALSE;
|
||||
flipCardsTimer->stop();
|
||||
}
|
||||
@@ -148,18 +164,21 @@ void MyCardsPixmapLabel::nextFlipCardsFrame() {
|
||||
}
|
||||
}
|
||||
|
||||
void MyCardsPixmapLabel::setPixmap(const QPixmap &pic, const bool flipsideIs) {
|
||||
void MyCardsPixmapLabel::setPixmap(const QPixmap &pic, const bool flipsideIs)
|
||||
{
|
||||
|
||||
QLabel::setPixmap(pic);
|
||||
isFlipside = flipsideIs;
|
||||
}
|
||||
|
||||
void MyCardsPixmapLabel::setHiddenFrontPixmap ( const QPixmap &pic ) {
|
||||
void MyCardsPixmapLabel::setHiddenFrontPixmap ( const QPixmap &pic )
|
||||
{
|
||||
|
||||
myHiddenFront = pic.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);;
|
||||
}
|
||||
|
||||
void MyCardsPixmapLabel::paintEvent(QPaintEvent * event) {
|
||||
void MyCardsPixmapLabel::paintEvent(QPaintEvent * event)
|
||||
{
|
||||
|
||||
if (!(flipCardsAction1 || flipCardsAction2 || fadeOutAction)) {
|
||||
QLabel::paintEvent(event);
|
||||
@@ -203,19 +222,20 @@ void MyCardsPixmapLabel::paintEvent(QPaintEvent * event) {
|
||||
}
|
||||
}
|
||||
|
||||
void MyCardsPixmapLabel::fastFlipCards(bool front){
|
||||
void MyCardsPixmapLabel::fastFlipCards(bool front)
|
||||
{
|
||||
|
||||
if (front) {
|
||||
fastFlipCardsFront = TRUE;
|
||||
update();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
fastFlipCardsFront = FALSE;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void MyCardsPixmapLabel::mousePressEvent(QMouseEvent * event) {
|
||||
void MyCardsPixmapLabel::mousePressEvent(QMouseEvent * event)
|
||||
{
|
||||
|
||||
if (!mousePress && objectName().contains("pixmapLabel_card0")) {
|
||||
mousePress = TRUE;
|
||||
@@ -226,7 +246,8 @@ void MyCardsPixmapLabel::mousePressEvent(QMouseEvent * event) {
|
||||
QLabel::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void MyCardsPixmapLabel::mouseReleaseEvent(QMouseEvent * event) {
|
||||
void MyCardsPixmapLabel::mouseReleaseEvent(QMouseEvent * event)
|
||||
{
|
||||
|
||||
if (mousePress && objectName().contains("pixmapLabel_card0")) {
|
||||
mousePress = FALSE;
|
||||
|
||||
@@ -27,20 +27,32 @@ public:
|
||||
|
||||
~MyCardsPixmapLabel();
|
||||
|
||||
void setMyW ( gameTableImpl* theValue ) { myW = theValue; }
|
||||
void setMyW ( gameTableImpl* theValue ) {
|
||||
myW = theValue;
|
||||
}
|
||||
|
||||
void setIsFlipside(bool theValue){ isFlipside = theValue;}
|
||||
bool getIsFlipside() const{ return isFlipside;}
|
||||
void setIsFlipside(bool theValue) {
|
||||
isFlipside = theValue;
|
||||
}
|
||||
bool getIsFlipside() const {
|
||||
return isFlipside;
|
||||
}
|
||||
|
||||
void setFadeOutAction(bool theValue) { fadeOutAction = theValue; }
|
||||
bool getFadeOutAction() const { return fadeOutAction;}
|
||||
void setFadeOutAction(bool theValue) {
|
||||
fadeOutAction = theValue;
|
||||
}
|
||||
bool getFadeOutAction() const {
|
||||
return fadeOutAction;
|
||||
}
|
||||
|
||||
void startFadeOut(int);
|
||||
void stopFadeOut();
|
||||
void startFlipCards(int, const QPixmap & , const QPixmap &);
|
||||
void stopFlipCardsAnimation();
|
||||
|
||||
void setFlipsidePix(QPixmap p) { flipside = p; }
|
||||
void setFlipsidePix(QPixmap p) {
|
||||
flipside = p;
|
||||
}
|
||||
|
||||
void paintEvent(QPaintEvent * event);
|
||||
|
||||
@@ -63,7 +75,9 @@ public slots:
|
||||
void mousePressEvent ( QMouseEvent *);
|
||||
void mouseReleaseEvent ( QMouseEvent *);
|
||||
|
||||
void setFront ( const QPixmap& theValue ) { front = theValue; }
|
||||
void setFront ( const QPixmap& theValue ) {
|
||||
front = theValue;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -72,7 +72,8 @@ void MyChanceLabel::refreshChance(vector< vector<int> > chance)
|
||||
update();
|
||||
}
|
||||
|
||||
void MyChanceLabel::paintEvent(QPaintEvent * /*event*/) {
|
||||
void MyChanceLabel::paintEvent(QPaintEvent * /*event*/)
|
||||
{
|
||||
|
||||
QPainter painter(this);
|
||||
|
||||
@@ -95,44 +96,74 @@ void MyChanceLabel::paintEvent(QPaintEvent * /*event*/) {
|
||||
QColor possible("#"+myStyle->getChanceLabelPossibleColor());
|
||||
QColor impossible("#"+myStyle->getChanceLabelImpossibleColor());
|
||||
|
||||
if(RFChance[1] == 0) { painter.setPen(impossible); }
|
||||
else { painter.setPen(possible); }
|
||||
if(RFChance[1] == 0) {
|
||||
painter.setPen(impossible);
|
||||
} else {
|
||||
painter.setPen(possible);
|
||||
}
|
||||
painter.drawText(QRectF(QPointF(2,0), QPointF(85,13)),Qt::AlignRight,"Royal Flush");
|
||||
painter.drawText(QRectF(QPointF(196,0), QPointF(236,13)),Qt::AlignRight,QString("%1%").arg(RFChance[0]));
|
||||
if(SFChance[1] == 0) { painter.setPen(impossible); }
|
||||
else { painter.setPen(possible); }
|
||||
if(SFChance[1] == 0) {
|
||||
painter.setPen(impossible);
|
||||
} else {
|
||||
painter.setPen(possible);
|
||||
}
|
||||
painter.drawText(QRectF(QPointF(2,13), QPointF(85,26)),Qt::AlignRight,"Straight Flush");
|
||||
painter.drawText(QRectF(QPointF(196,13), QPointF(236,26)),Qt::AlignRight,QString("%1%").arg(SFChance[0]));
|
||||
if(FOAKChance[1] == 0) { painter.setPen(impossible); }
|
||||
else { painter.setPen(possible); }
|
||||
if(FOAKChance[1] == 0) {
|
||||
painter.setPen(impossible);
|
||||
} else {
|
||||
painter.setPen(possible);
|
||||
}
|
||||
painter.drawText(QRectF(QPointF(2,26), QPointF(85,39)),Qt::AlignRight,"Four of a Kind");
|
||||
painter.drawText(QRectF(QPointF(196,26), QPointF(236,39)),Qt::AlignRight,QString("%1%").arg(FOAKChance[0]));
|
||||
if(FHChance[1] == 0) { painter.setPen(impossible); }
|
||||
else { painter.setPen(possible); }
|
||||
if(FHChance[1] == 0) {
|
||||
painter.setPen(impossible);
|
||||
} else {
|
||||
painter.setPen(possible);
|
||||
}
|
||||
painter.drawText(QRectF(QPointF(2,39), QPointF(85,52)),Qt::AlignRight,"Full House");
|
||||
painter.drawText(QRectF(QPointF(196,39), QPointF(236,52)),Qt::AlignRight,QString("%1%").arg(FHChance[0]));
|
||||
if(FLChance[1] == 0) { painter.setPen(impossible); }
|
||||
else { painter.setPen(possible); }
|
||||
if(FLChance[1] == 0) {
|
||||
painter.setPen(impossible);
|
||||
} else {
|
||||
painter.setPen(possible);
|
||||
}
|
||||
painter.drawText(QRectF(QPointF(2,52), QPointF(85,65)),Qt::AlignRight,"Flush");
|
||||
painter.drawText(QRectF(QPointF(196,52), QPointF(236,65)),Qt::AlignRight,QString("%1%").arg(FLChance[0]));
|
||||
if(STRChance[1] == 0) { painter.setPen(impossible); }
|
||||
else { painter.setPen(possible); }
|
||||
if(STRChance[1] == 0) {
|
||||
painter.setPen(impossible);
|
||||
} else {
|
||||
painter.setPen(possible);
|
||||
}
|
||||
painter.drawText(QRectF(QPointF(2,65), QPointF(85,78)),Qt::AlignRight,"Straight");
|
||||
painter.drawText(QRectF(QPointF(196,65), QPointF(236,78)),Qt::AlignRight,QString("%1%").arg(STRChance[0]));
|
||||
if(TOAKChance[1] == 0) { painter.setPen(impossible); }
|
||||
else { painter.setPen(possible); }
|
||||
if(TOAKChance[1] == 0) {
|
||||
painter.setPen(impossible);
|
||||
} else {
|
||||
painter.setPen(possible);
|
||||
}
|
||||
painter.drawText(QRectF(QPointF(2,78), QPointF(85,91)),Qt::AlignRight,"Three of a Kind");
|
||||
painter.drawText(QRectF(QPointF(196,78), QPointF(236,91)),Qt::AlignRight,QString("%1%").arg(TOAKChance[0]));
|
||||
if(TPChance[1] == 0) { painter.setPen(impossible); }
|
||||
else { painter.setPen(possible); }
|
||||
if(TPChance[1] == 0) {
|
||||
painter.setPen(impossible);
|
||||
} else {
|
||||
painter.setPen(possible);
|
||||
}
|
||||
painter.drawText(QRectF(QPointF(2,91), QPointF(85,104)),Qt::AlignRight,"Two Pairs");
|
||||
painter.drawText(QRectF(QPointF(196,91), QPointF(236,104)),Qt::AlignRight,QString("%1%").arg(TPChance[0]));
|
||||
if(OPChance[1] == 0) { painter.setPen(impossible); }
|
||||
else { painter.setPen(possible); }
|
||||
if(OPChance[1] == 0) {
|
||||
painter.setPen(impossible);
|
||||
} else {
|
||||
painter.setPen(possible);
|
||||
}
|
||||
painter.drawText(QRectF(QPointF(2,104), QPointF(85,117)),Qt::AlignRight,"One Pair");
|
||||
painter.drawText(QRectF(QPointF(196,104), QPointF(236,117)),Qt::AlignRight,QString("%1%").arg(OPChance[0]));
|
||||
if(HCChance[1] == 0) { painter.setPen(impossible); }
|
||||
else { painter.setPen(possible); }
|
||||
if(HCChance[1] == 0) {
|
||||
painter.setPen(impossible);
|
||||
} else {
|
||||
painter.setPen(possible);
|
||||
}
|
||||
painter.drawText(QRectF(QPointF(2,117), QPointF(85,130)),Qt::AlignRight,"Highest Card");
|
||||
painter.drawText(QRectF(QPointF(196,117), QPointF(236,130)),Qt::AlignRight,QString("%1%").arg(HCChance[0]));
|
||||
|
||||
|
||||
@@ -28,8 +28,12 @@ public:
|
||||
|
||||
~MyChanceLabel();
|
||||
|
||||
void setMyW ( gameTableImpl* theValue ) { myW = theValue; }
|
||||
void setMyStyle ( GameTableStyleReader* theValue ) { myStyle = theValue; }
|
||||
void setMyW ( gameTableImpl* theValue ) {
|
||||
myW = theValue;
|
||||
}
|
||||
void setMyStyle ( GameTableStyleReader* theValue ) {
|
||||
myStyle = theValue;
|
||||
}
|
||||
void paintEvent(QPaintEvent * event);
|
||||
void refreshChance(std::vector< std::vector<int> >);
|
||||
void resetChance();
|
||||
|
||||
@@ -25,18 +25,32 @@ MyLeftTabWidget::~MyLeftTabWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void MyLeftTabWidget::startBlinkChatTab() { /*chatBlinkTimer->start(500);*/ }
|
||||
void MyLeftTabWidget::stopBlinkChatTab() { /*chatBlinkTimer->stop();*/ }
|
||||
void MyLeftTabWidget::showDefaultChatTab() { /*myTabBar->setTabTextColor(1, QColor(240,240,240));*/ }
|
||||
void MyLeftTabWidget::disableTab(int tabIndex, bool yesNo) { myTabBar->setTabEnabled(tabIndex, !yesNo); }
|
||||
void MyLeftTabWidget::startBlinkChatTab()
|
||||
{
|
||||
/*chatBlinkTimer->start(500);*/
|
||||
}
|
||||
void MyLeftTabWidget::stopBlinkChatTab()
|
||||
{
|
||||
/*chatBlinkTimer->stop();*/
|
||||
}
|
||||
void MyLeftTabWidget::showDefaultChatTab()
|
||||
{
|
||||
/*myTabBar->setTabTextColor(1, QColor(240,240,240));*/
|
||||
}
|
||||
void MyLeftTabWidget::disableTab(int tabIndex, bool yesNo)
|
||||
{
|
||||
myTabBar->setTabEnabled(tabIndex, !yesNo);
|
||||
}
|
||||
|
||||
void MyLeftTabWidget::blinkChatTab() {
|
||||
void MyLeftTabWidget::blinkChatTab()
|
||||
{
|
||||
//TODO doesnt work while stylesheet is set :(
|
||||
// if(myTabBar->tabTextColor(1).red() == 240) myTabBar->setTabTextColor(1, QColor(113,162,0));
|
||||
// else myTabBar->setTabTextColor(1, QColor(240,240,240));
|
||||
}
|
||||
|
||||
void MyLeftTabWidget::paintEvent(QPaintEvent * event) {
|
||||
void MyLeftTabWidget::paintEvent(QPaintEvent * event)
|
||||
{
|
||||
|
||||
QTabWidget::paintEvent(event);
|
||||
|
||||
|
||||
@@ -35,7 +35,9 @@ public slots:
|
||||
|
||||
void blinkChatTab();
|
||||
|
||||
QTabBar* getMyTabBar() const { return myTabBar; }
|
||||
QTabBar* getMyTabBar() const {
|
||||
return myTabBar;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ MyMenuBar::MyMenuBar(QMainWindow* parent)
|
||||
#endif
|
||||
}
|
||||
|
||||
void MyMenuBar::paintEvent(QPaintEvent *e) {
|
||||
void MyMenuBar::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
|
||||
QMenuBar::paintEvent(e);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ MyNameLabel::~MyNameLabel()
|
||||
{
|
||||
}
|
||||
|
||||
void MyNameLabel::setText ( const QString &t, bool trans, bool guest, bool computerplayer) {
|
||||
void MyNameLabel::setText ( const QString &t, bool trans, bool guest, bool computerplayer)
|
||||
{
|
||||
|
||||
QString text;
|
||||
QColor transColor;
|
||||
@@ -35,8 +36,7 @@ void MyNameLabel::setText ( const QString &t, bool trans, bool guest, bool compu
|
||||
|
||||
if(trans) {
|
||||
this->setStyleSheet("QLabel { "+ myW->getMyGameTableStyle()->getFont2String() +" font-size: "+myW->getMyGameTableStyle()->getPlayerNameLabelFontSize()+"px; font-weight: bold; color: rgba("+red+", "+green+", "+blue+", 80); }");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this->setStyleSheet("QLabel { "+ myW->getMyGameTableStyle()->getFont2String() +" font-size: "+myW->getMyGameTableStyle()->getPlayerNameLabelFontSize()+"px; font-weight: bold; color: #"+myW->getMyGameTableStyle()->getPlayerNickTextColor()+"; }");
|
||||
}
|
||||
|
||||
@@ -49,18 +49,17 @@ void MyNameLabel::setText ( const QString &t, bool trans, bool guest, bool compu
|
||||
|
||||
if(trans) {
|
||||
text = "<a style='color: rgba("+red+", "+green+", "+blue+", 80);' href='"+linkString+"'>"+t+"</a>";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
text = "<a style='color: #"+myW->getMyGameTableStyle()->getPlayerNickTextColor()+";' href='"+linkString+"'>"+t+"</a>";
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this->setTextFormat(Qt::PlainText);
|
||||
text = t;
|
||||
}
|
||||
} else {
|
||||
text = t;
|
||||
}
|
||||
else { text = t; }
|
||||
|
||||
QLabel::setText(text);
|
||||
|
||||
|
||||
@@ -26,7 +26,9 @@ public:
|
||||
MyNameLabel(QGroupBox*);
|
||||
~MyNameLabel();
|
||||
|
||||
void setMyW(gameTableImpl* theValue) { myW = theValue; }
|
||||
void setMyW(gameTableImpl* theValue) {
|
||||
myW = theValue;
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ MyRightTabWidget::~MyRightTabWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void MyRightTabWidget::paintEvent(QPaintEvent * event) {
|
||||
void MyRightTabWidget::paintEvent(QPaintEvent * event)
|
||||
{
|
||||
|
||||
QTabWidget::paintEvent(event);
|
||||
|
||||
|
||||
@@ -26,7 +26,9 @@ public:
|
||||
|
||||
void paintEvent(QPaintEvent * event);
|
||||
|
||||
QTabBar* getMyTabBar() const { return myTabBar; }
|
||||
QTabBar* getMyTabBar() const {
|
||||
return myTabBar;
|
||||
}
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -25,7 +25,8 @@ MySetLabel::~MySetLabel()
|
||||
{
|
||||
}
|
||||
|
||||
void MySetLabel::paintEvent(QPaintEvent * event) {
|
||||
void MySetLabel::paintEvent(QPaintEvent * event)
|
||||
{
|
||||
|
||||
QLabel::paintEvent(event);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user