Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a333185525 | ||
|
|
7d116d7294 | ||
|
|
0cd9ba6f99 | ||
|
|
99ad7ffd71 | ||
|
|
9b36c9863c | ||
|
|
20793e24a1 | ||
|
|
382b533488 | ||
|
|
7c538fc436 | ||
|
|
add886ebee | ||
|
|
f9a2ebebb4 | ||
|
|
21b8088ecf | ||
|
|
09281f3179 | ||
|
|
f5688e01b0 | ||
|
|
f920d5f1c8 | ||
|
|
008d703de1 | ||
|
|
0a8b6d597f | ||
|
|
3813664b94 | ||
|
|
ad8c9cabfb | ||
|
|
678da490d4 | ||
|
|
8e5b09ac62 |
+5
-4
@@ -8,14 +8,15 @@ Makefile.pokerth_protocol
|
|||||||
Makefile.pokerth_server
|
Makefile.pokerth_server
|
||||||
Makefile.pokerth_dbofficial
|
Makefile.pokerth_dbofficial
|
||||||
bin/
|
bin/
|
||||||
chatcleaner
|
/chatcleaner
|
||||||
lib/
|
lib/
|
||||||
mocs/
|
mocs/
|
||||||
obj/
|
obj/
|
||||||
pokerth
|
/pokerth
|
||||||
qrc_pokerth.cpp
|
qrc_pokerth.cpp
|
||||||
uics/
|
uics/
|
||||||
make.sh
|
make.sh
|
||||||
gitpush_serverstuff_stable
|
gitpush_serverstuff_stable
|
||||||
pokerth_server
|
.vscode/
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
* shall include the source code for the parts of OpenSSL used as well *
|
* shall include the source code for the parts of OpenSSL used as well *
|
||||||
* as that of the covered work. *
|
* as that of the covered work. *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
syntax = "proto2";
|
||||||
|
|
||||||
option java_package = "de.chatcleaner.protocol";
|
option java_package = "de.chatcleaner.protocol";
|
||||||
option java_outer_classname = "ProtoBuf";
|
option java_outer_classname = "ProtoBuf";
|
||||||
|
|||||||
+2
-2
@@ -41,13 +41,13 @@ unix : !mac {
|
|||||||
|
|
||||||
QMAKE_LIBDIR += lib $${PREFIX}/lib /opt/gsasl/lib
|
QMAKE_LIBDIR += lib $${PREFIX}/lib /opt/gsasl/lib
|
||||||
INCLUDEPATH += $${PREFIX}/include
|
INCLUDEPATH += $${PREFIX}/include
|
||||||
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system(qmake -query QT_INSTALL_LIBS)
|
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
|
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
|
||||||
BOOST_SYS = boost_system boost_system-mt
|
BOOST_SYS = boost_system boost_system-mt
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system(qmake -query QT_INSTALL_LIBS)
|
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
# to override the default '/usr' pass PREFIX
|
# to override the default '/usr' pass PREFIX
|
||||||
# variable to qmake.
|
# variable to qmake.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -42,14 +42,14 @@ unix : !mac {
|
|||||||
|
|
||||||
QMAKE_LIBDIR += lib $${PREFIX}/lib /opt/gsasl/lib
|
QMAKE_LIBDIR += lib $${PREFIX}/lib /opt/gsasl/lib
|
||||||
INCLUDEPATH += $${PREFIX}/include
|
INCLUDEPATH += $${PREFIX}/include
|
||||||
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system(qmake -query QT_INSTALL_LIBS)
|
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
BOOST_THREAD = boost_thread boost_thread-mt
|
BOOST_THREAD = boost_thread boost_thread-mt
|
||||||
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
|
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
|
||||||
BOOST_SYS = boost_system boost_system-mt
|
BOOST_SYS = boost_system boost_system-mt
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system(qmake -query QT_INSTALL_LIBS)
|
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
# to override the default '/usr' pass PREFIX
|
# to override the default '/usr' pass PREFIX
|
||||||
# variable to qmake.
|
# variable to qmake.
|
||||||
#
|
#
|
||||||
|
|||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
syntax = "proto2";
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* PokerTH - The open source texas holdem engine *
|
* PokerTH - The open source texas holdem engine *
|
||||||
* Copyright (C) 2006-2013 Felix Hammer, Florian Thauer, Lothar May *
|
* Copyright (C) 2006-2013 Felix Hammer, Florian Thauer, Lothar May *
|
||||||
@@ -701,7 +702,7 @@ message ReportGameAckMessage {
|
|||||||
|
|
||||||
message ErrorMessage {
|
message ErrorMessage {
|
||||||
enum ErrorReason {
|
enum ErrorReason {
|
||||||
reserved = 0;
|
custReserved = 0;
|
||||||
initVersionNotSupported = 1;
|
initVersionNotSupported = 1;
|
||||||
initServerFull = 2;
|
initServerFull = 2;
|
||||||
initAuthFailure = 3;
|
initAuthFailure = 3;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ HEADERS += src/dbofficial/asyncdbauth.h \
|
|||||||
src/dbofficial/asyncdbavatarblacklist.h \
|
src/dbofficial/asyncdbavatarblacklist.h \
|
||||||
src/dbofficial/asyncdbadminplayers.h \
|
src/dbofficial/asyncdbadminplayers.h \
|
||||||
src/dbofficial/asyncdbblockplayer.h \
|
src/dbofficial/asyncdbblockplayer.h \
|
||||||
|
src/dbofficial/asyncdbplayerlastgames.h \
|
||||||
src/dbofficial/dbidmanager.h
|
src/dbofficial/dbidmanager.h
|
||||||
SOURCES += src/dbofficial/asyncdbauth.cpp \
|
SOURCES += src/dbofficial/asyncdbauth.cpp \
|
||||||
src/dbofficial/asyncdbcreategame.cpp \
|
src/dbofficial/asyncdbcreategame.cpp \
|
||||||
@@ -60,6 +61,7 @@ SOURCES += src/dbofficial/asyncdbauth.cpp \
|
|||||||
src/dbofficial/asyncdbavatarblacklist.cpp \
|
src/dbofficial/asyncdbavatarblacklist.cpp \
|
||||||
src/dbofficial/asyncdbadminplayers.cpp \
|
src/dbofficial/asyncdbadminplayers.cpp \
|
||||||
src/dbofficial/asyncdbblockplayer.cpp \
|
src/dbofficial/asyncdbblockplayer.cpp \
|
||||||
|
src/dbofficial/asyncdbplayerlastgames.cpp \
|
||||||
src/dbofficial/dbidmanager.cpp
|
src/dbofficial/dbidmanager.cpp
|
||||||
win32 {
|
win32 {
|
||||||
DEFINES += _WIN32_WINNT=0x0501
|
DEFINES += _WIN32_WINNT=0x0501
|
||||||
|
|||||||
+2
-2
@@ -412,7 +412,7 @@ unix:!mac {
|
|||||||
LIB_DIRS = $${PREFIX}/lib \
|
LIB_DIRS = $${PREFIX}/lib \
|
||||||
$${PREFIX}/lib64 \
|
$${PREFIX}/lib64 \
|
||||||
$${PREFIX}/lib/x86_64-linux-gnu \
|
$${PREFIX}/lib/x86_64-linux-gnu \
|
||||||
$$system(qmake -query QT_INSTALL_LIBS)
|
$$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
}
|
}
|
||||||
android{
|
android{
|
||||||
LIBPATH += $${PREFIX}/lib/armv7
|
LIBPATH += $${PREFIX}/lib/armv7
|
||||||
@@ -433,7 +433,7 @@ unix:!mac {
|
|||||||
BOOST_CHRONO = boost_chrono \
|
BOOST_CHRONO = boost_chrono \
|
||||||
boost_chrono-mt
|
boost_chrono-mt
|
||||||
|
|
||||||
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system(qmake -query QT_INSTALL_LIBS)
|
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
# to override the default '/usr' pass PREFIX
|
# to override the default '/usr' pass PREFIX
|
||||||
# variable to qmake.
|
# variable to qmake.
|
||||||
for(dir, LIB_DIRS):exists($$dir) {
|
for(dir, LIB_DIRS):exists($$dir) {
|
||||||
|
|||||||
+2
-2
@@ -180,7 +180,7 @@ unix : !mac {
|
|||||||
INCLUDEPATH += $${PREFIX}/include
|
INCLUDEPATH += $${PREFIX}/include
|
||||||
# see issue https://github.com/pokerth/pokerth/issues/282
|
# see issue https://github.com/pokerth/pokerth/issues/282
|
||||||
INCLUDEPATH += $${PREFIX}/include/libircclient
|
INCLUDEPATH += $${PREFIX}/include/libircclient
|
||||||
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system(qmake -query QT_INSTALL_LIBS)
|
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
BOOST_FS = boost_filesystem boost_filesystem-mt
|
BOOST_FS = boost_filesystem boost_filesystem-mt
|
||||||
BOOST_THREAD = boost_thread boost_thread-mt
|
BOOST_THREAD = boost_thread boost_thread-mt
|
||||||
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
|
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
|
||||||
@@ -191,7 +191,7 @@ unix : !mac {
|
|||||||
BOOST_CHRONO = boost_chrono boost_chrono-mt
|
BOOST_CHRONO = boost_chrono boost_chrono-mt
|
||||||
|
|
||||||
#
|
#
|
||||||
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system(qmake -query QT_INSTALL_LIBS)
|
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
# to override the default '/usr' pass PREFIX
|
# to override the default '/usr' pass PREFIX
|
||||||
# variable to qmake.
|
# variable to qmake.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -312,6 +312,8 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
|
|||||||
configList.push_back(ConfigInfo("DBServerEncryptionKey", CONFIG_TYPE_STRING, ""));
|
configList.push_back(ConfigInfo("DBServerEncryptionKey", CONFIG_TYPE_STRING, ""));
|
||||||
configList.push_back(ConfigInfo("GameNameBadWordList", CONFIG_TYPE_STRING_LIST, "Regex"));
|
configList.push_back(ConfigInfo("GameNameBadWordList", CONFIG_TYPE_STRING_LIST, "Regex"));
|
||||||
configList.push_back(ConfigInfo("ServerRestrictGuestLogin", CONFIG_TYPE_INT, "0"));
|
configList.push_back(ConfigInfo("ServerRestrictGuestLogin", CONFIG_TYPE_INT, "0"));
|
||||||
|
configList.push_back(ConfigInfo("ServerLimitRankNum", CONFIG_TYPE_INT, "4"));
|
||||||
|
configList.push_back(ConfigInfo("ServerLimitRankPeriod", CONFIG_TYPE_INT, "60"));
|
||||||
|
|
||||||
//fill tempList firstTime
|
//fill tempList firstTime
|
||||||
configBufferList = configList;
|
configBufferList = configList;
|
||||||
|
|||||||
@@ -291,22 +291,33 @@ CryptHelper::AES128Encrypt(const unsigned char *keyData, unsigned keySize, const
|
|||||||
outCipher.resize(cipherSize);
|
outCipher.resize(cipherSize);
|
||||||
|
|
||||||
#ifdef HAVE_OPENSSL
|
#ifdef HAVE_OPENSSL
|
||||||
EVP_CIPHER_CTX encryptCtx;
|
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
EVP_CIPHER_CTX_init(&encryptCtx);
|
EVP_CIPHER_CTX *encryptCtx = EVP_CIPHER_CTX_new();
|
||||||
|
#else
|
||||||
|
EVP_CIPHER_CTX _encryptCtx;
|
||||||
|
EVP_CIPHER_CTX *encryptCtx;
|
||||||
|
encryptCtx = &_encryptCtx;
|
||||||
|
#endif // OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
|
|
||||||
|
EVP_CIPHER_CTX_init(encryptCtx);
|
||||||
int outCipherSize = cipherSize;
|
int outCipherSize = cipherSize;
|
||||||
|
|
||||||
int success = EVP_EncryptInit(&encryptCtx, EVP_aes_128_cbc(), key, iv);
|
int success = EVP_EncryptInit(encryptCtx, EVP_aes_128_cbc(), key, iv);
|
||||||
EVP_CIPHER_CTX_set_padding(&encryptCtx, 0);
|
EVP_CIPHER_CTX_set_padding(encryptCtx, 0);
|
||||||
if (success) {
|
if (success) {
|
||||||
success = EVP_EncryptUpdate(&encryptCtx, &outCipher[0], &outCipherSize, paddedPlainStr, paddedPlainSize);
|
success = EVP_EncryptUpdate(encryptCtx, &outCipher[0], &outCipherSize, paddedPlainStr, paddedPlainSize);
|
||||||
|
|
||||||
if (success && outCipherSize) {
|
if (success && outCipherSize) {
|
||||||
// Since padding is off, this will not modify the cipher. However, parameters need to be set.
|
// Since padding is off, this will not modify the cipher. However, parameters need to be set.
|
||||||
EVP_EncryptFinal(&encryptCtx, &outCipher[0], &outCipherSize);
|
EVP_EncryptFinal(encryptCtx, &outCipher[0], &outCipherSize);
|
||||||
retVal = true;
|
retVal = true;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
outCipher.clear();
|
outCipher.clear();
|
||||||
|
|
||||||
|
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
|
EVP_CIPHER_CTX_free(encryptCtx);
|
||||||
|
#endif // OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
#else
|
#else
|
||||||
gcry_cipher_hd_t hd;
|
gcry_cipher_hd_t hd;
|
||||||
gcry_error_t err = gcry_cipher_open(&hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC, 0);
|
gcry_error_t err = gcry_cipher_open(&hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC, 0);
|
||||||
@@ -338,22 +349,33 @@ CryptHelper::AES128Decrypt(const unsigned char *keyData, unsigned keySize, const
|
|||||||
BytesToKey(keyData, keySize, key, iv);
|
BytesToKey(keyData, keySize, key, iv);
|
||||||
outPlain.resize(cipherSize);
|
outPlain.resize(cipherSize);
|
||||||
#ifdef HAVE_OPENSSL
|
#ifdef HAVE_OPENSSL
|
||||||
EVP_CIPHER_CTX decryptCtx;
|
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
EVP_CIPHER_CTX_init(&decryptCtx);
|
EVP_CIPHER_CTX *decryptCtx = EVP_CIPHER_CTX_new();
|
||||||
|
#else
|
||||||
|
EVP_CIPHER_CTX _decryptCtx;
|
||||||
|
EVP_CIPHER_CTX *decryptCtx;
|
||||||
|
decryptCtx = &_decryptCtx;
|
||||||
|
#endif // OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
|
|
||||||
|
EVP_CIPHER_CTX_init(decryptCtx);
|
||||||
int outPlainSize = cipherSize;
|
int outPlainSize = cipherSize;
|
||||||
|
|
||||||
int success = EVP_DecryptInit(&decryptCtx, EVP_aes_128_cbc(), key, iv);
|
int success = EVP_DecryptInit(decryptCtx, EVP_aes_128_cbc(), key, iv);
|
||||||
EVP_CIPHER_CTX_set_padding(&decryptCtx, 0);
|
EVP_CIPHER_CTX_set_padding(decryptCtx, 0);
|
||||||
if (success) {
|
if (success) {
|
||||||
success = EVP_DecryptUpdate(&decryptCtx, (unsigned char *)&outPlain[0], &outPlainSize, cipher, cipherSize);
|
success = EVP_DecryptUpdate(decryptCtx, (unsigned char *)&outPlain[0], &outPlainSize, cipher, cipherSize);
|
||||||
|
|
||||||
if (success && outPlainSize) {
|
if (success && outPlainSize) {
|
||||||
// Since padding is off, this will not modify the plain text. However, parameters need to be set.
|
// Since padding is off, this will not modify the plain text. However, parameters need to be set.
|
||||||
EVP_DecryptFinal(&decryptCtx, (unsigned char *)outPlain.c_str(), &outPlainSize);
|
EVP_DecryptFinal(decryptCtx, (unsigned char *)outPlain.c_str(), &outPlainSize);
|
||||||
retVal = true;
|
retVal = true;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
outPlain.clear();
|
outPlain.clear();
|
||||||
|
|
||||||
|
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
|
EVP_CIPHER_CTX_free(decryptCtx);
|
||||||
|
#endif // OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
#else
|
#else
|
||||||
gcry_cipher_hd_t hd;
|
gcry_cipher_hd_t hd;
|
||||||
gcry_error_t err = gcry_cipher_open(&hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC, 0);
|
gcry_error_t err = gcry_cipher_open(&hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC, 0);
|
||||||
|
|||||||
@@ -93,6 +93,11 @@ ServerDBGeneric::SetGamePlayerPlace(unsigned /*requestId*/, DB_id /*playerId*/,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ServerDBGeneric::SetPlayerLastGames(unsigned /*requestId*/, DB_id /*playerId*/, std::vector<long> /*last_games*/, std::string /*playerIp*/)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerDBGeneric::EndGame(unsigned /*requestId*/)
|
ServerDBGeneric::EndGame(unsigned /*requestId*/)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
typedef unsigned DB_id;
|
typedef unsigned DB_id;
|
||||||
#define DB_ID_INVALID 0
|
#define DB_ID_INVALID 0
|
||||||
@@ -45,6 +46,8 @@ struct DBPlayerData {
|
|||||||
std::string secret;
|
std::string secret;
|
||||||
std::string country;
|
std::string country;
|
||||||
std::string last_login;
|
std::string last_login;
|
||||||
|
std::string last_games;
|
||||||
|
std::string last_ip;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public:
|
|||||||
|
|
||||||
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName);
|
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName);
|
||||||
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place);
|
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place);
|
||||||
|
virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> last_games, std::string playerIp);
|
||||||
virtual void EndGame(unsigned requestId);
|
virtual void EndGame(unsigned requestId);
|
||||||
|
|
||||||
virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId);
|
virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId);
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include <db/serverdbcallback.h>
|
#include <db/serverdbcallback.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
typedef std::list<DB_id> db_list;
|
typedef std::list<DB_id> db_list;
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ public:
|
|||||||
|
|
||||||
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName) = 0;
|
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName) = 0;
|
||||||
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place) = 0;
|
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place) = 0;
|
||||||
|
virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> last_games, std::string playerIp) = 0;
|
||||||
virtual void EndGame(unsigned requestId) = 0;
|
virtual void EndGame(unsigned requestId) = 0;
|
||||||
|
|
||||||
virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId) = 0;
|
virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId) = 0;
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ public:
|
|||||||
|
|
||||||
virtual void AsyncCreateGame(unsigned /*requestId*/, const std::string &/*gameName*/) {}
|
virtual void AsyncCreateGame(unsigned /*requestId*/, const std::string &/*gameName*/) {}
|
||||||
virtual void SetGamePlayerPlace(unsigned /*requestId*/, DB_id /*playerId*/, unsigned /*place*/) {}
|
virtual void SetGamePlayerPlace(unsigned /*requestId*/, DB_id /*playerId*/, unsigned /*place*/) {}
|
||||||
|
virtual void SetPlayerLastGames(unsigned /*requestId*/, DB_id /*playerId*/, std::vector<long> /*last_games*/, std::string /*playerIp*/) {}
|
||||||
virtual void EndGame(unsigned /*requestId*/) {}
|
virtual void EndGame(unsigned /*requestId*/) {}
|
||||||
|
|
||||||
virtual void AsyncReportAvatar(unsigned /*requestId*/, unsigned /*replyId*/, DB_id /*reportedPlayerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/, DB_id * /*byPlayerId*/) {}
|
virtual void AsyncReportAvatar(unsigned /*requestId*/, unsigned /*replyId*/, DB_id /*reportedPlayerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/, DB_id * /*byPlayerId*/) {}
|
||||||
|
|||||||
@@ -52,19 +52,25 @@ AsyncDBAuth::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/,
|
|||||||
service.post(boost::bind(&ServerDBCallback::PlayerLoginFailed, &cb, GetId()));
|
service.post(boost::bind(&ServerDBCallback::PlayerLoginFailed, &cb, GetId()));
|
||||||
} else {
|
} else {
|
||||||
int blocked = result[0][2];
|
int blocked = result[0][2];
|
||||||
int active = result[0][5];
|
int active = result[0][7];
|
||||||
if ((active != 1) || (blocked != 0)) {
|
if ((active != 1) || (blocked != 0)) {
|
||||||
service.post(boost::bind(&ServerDBCallback::PlayerLoginBlocked, &cb, GetId()));
|
service.post(boost::bind(&ServerDBCallback::PlayerLoginBlocked, &cb, GetId()));
|
||||||
} else {
|
} else {
|
||||||
mysqlpp::String secret(result[0][1]);
|
mysqlpp::String secret(result[0][1]);
|
||||||
mysqlpp::String country(result[0][3]);
|
mysqlpp::String country(result[0][3]);
|
||||||
mysqlpp::String last_login(result[0][4]);
|
mysqlpp::String last_login(result[0][4]);
|
||||||
|
mysqlpp::String last_games(result[0][5]);
|
||||||
|
mysqlpp::String last_ip(result[0][6]);
|
||||||
boost::shared_ptr<DBPlayerData> tmpData(new DBPlayerData);
|
boost::shared_ptr<DBPlayerData> tmpData(new DBPlayerData);
|
||||||
tmpData->id = result[0][0];
|
tmpData->id = result[0][0];
|
||||||
secret.to_string(tmpData->secret);
|
secret.to_string(tmpData->secret);
|
||||||
if (!country.is_null())
|
if (!country.is_null())
|
||||||
country.to_string(tmpData->country);
|
country.to_string(tmpData->country);
|
||||||
last_login.to_string(tmpData->last_login);
|
last_login.to_string(tmpData->last_login);
|
||||||
|
if (!last_games.is_null())
|
||||||
|
last_games.to_string(tmpData->last_games);
|
||||||
|
if (!last_ip.is_null())
|
||||||
|
last_ip.to_string(tmpData->last_ip);
|
||||||
|
|
||||||
service.post(boost::bind(&ServerDBCallback::PlayerLoginSuccess, &cb, GetId(), tmpData));
|
service.post(boost::bind(&ServerDBCallback::PlayerLoginSuccess, &cb, GetId(), tmpData));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* PokerTH - The open source texas holdem engine *
|
||||||
|
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||||
|
* *
|
||||||
|
* This program is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU Affero General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU Affero General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU Affero General Public License *
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* Additional permission under GNU AGPL version 3 section 7 *
|
||||||
|
* *
|
||||||
|
* If you modify this program, or any covered work, by linking or *
|
||||||
|
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||||
|
* modified version of that library), containing parts covered by the *
|
||||||
|
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||||
|
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||||
|
* permission to convey the resulting work. *
|
||||||
|
* Corresponding Source for a non-source form of such a combination *
|
||||||
|
* shall include the source code for the parts of OpenSSL used as well *
|
||||||
|
* as that of the covered work. *
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <dbofficial/asyncdbplayerlastgames.h>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
AsyncDBPlayerLastGames::AsyncDBPlayerLastGames(unsigned queryId, const string &preparedName, const list<string> ¶ms)
|
||||||
|
: SingleAsyncDBQuery(queryId, preparedName, params)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AsyncDBPlayerLastGames::~AsyncDBPlayerLastGames()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AsyncDBPlayerLastGames::HandleResult(mysqlpp::Query &/*query*/, DBIdManager &/*idManager*/, mysqlpp::StoreQueryResult &/*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||||
|
{
|
||||||
|
// This query does not produce a result.
|
||||||
|
HandleError(service, cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AsyncDBPlayerLastGames::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AsyncDBPlayerLastGames::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* PokerTH - The open source texas holdem engine *
|
||||||
|
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||||
|
* *
|
||||||
|
* This program is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU Affero General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU Affero General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU Affero General Public License *
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* Additional permission under GNU AGPL version 3 section 7 *
|
||||||
|
* *
|
||||||
|
* If you modify this program, or any covered work, by linking or *
|
||||||
|
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||||
|
* modified version of that library), containing parts covered by the *
|
||||||
|
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||||
|
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||||
|
* permission to convey the resulting work. *
|
||||||
|
* Corresponding Source for a non-source form of such a combination *
|
||||||
|
* shall include the source code for the parts of OpenSSL used as well *
|
||||||
|
* as that of the covered work. *
|
||||||
|
*****************************************************************************/
|
||||||
|
/* Async database update to block a player. */
|
||||||
|
|
||||||
|
#ifndef _ASYNCDBPLAYERLASTGAMES_H_
|
||||||
|
#define _ASYNCDBPLAYERLASTGAMES_H_
|
||||||
|
|
||||||
|
#include <dbofficial/singleasyncdbquery.h>
|
||||||
|
|
||||||
|
|
||||||
|
class AsyncDBPlayerLastGames : public SingleAsyncDBQuery
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AsyncDBPlayerLastGames(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||||
|
virtual ~AsyncDBPlayerLastGames();
|
||||||
|
|
||||||
|
virtual void Init(DBIdManager& /*idManager*/) {}
|
||||||
|
|
||||||
|
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||||
|
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||||
|
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||||
|
|
||||||
|
virtual bool RequiresResultSet() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -42,6 +42,8 @@
|
|||||||
#define DB_TABLE_PLAYER_COL_ACTIVE "active"
|
#define DB_TABLE_PLAYER_COL_ACTIVE "active"
|
||||||
#define DB_TABLE_PLAYER_COL_AVATARHASH "avatar_hash"
|
#define DB_TABLE_PLAYER_COL_AVATARHASH "avatar_hash"
|
||||||
#define DB_TABLE_PLAYER_COL_AVATARTYPE "avatar_mime"
|
#define DB_TABLE_PLAYER_COL_AVATARTYPE "avatar_mime"
|
||||||
|
#define DB_TABLE_PLAYER_COL_LASTGAMES "last_games"
|
||||||
|
#define DB_TABLE_PLAYER_COL_LASTIP "last_ip"
|
||||||
|
|
||||||
#define DB_TABLE_GAME "game"
|
#define DB_TABLE_GAME "game"
|
||||||
#define DB_TABLE_GAME_COL_ID "idgame"
|
#define DB_TABLE_GAME_COL_ID "idgame"
|
||||||
|
|||||||
@@ -41,12 +41,15 @@
|
|||||||
#include <dbofficial/asyncdbreportgame.h>
|
#include <dbofficial/asyncdbreportgame.h>
|
||||||
#include <dbofficial/asyncdbadminplayers.h>
|
#include <dbofficial/asyncdbadminplayers.h>
|
||||||
#include <dbofficial/asyncdbblockplayer.h>
|
#include <dbofficial/asyncdbblockplayer.h>
|
||||||
|
#include <dbofficial/asyncdbplayerlastgames.h>
|
||||||
#include <dbofficial/compositeasyncdbquery.h>
|
#include <dbofficial/compositeasyncdbquery.h>
|
||||||
#include <dbofficial/db_table_defs.h>
|
#include <dbofficial/db_table_defs.h>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <mysql++.h>
|
#include <mysql++.h>
|
||||||
|
|
||||||
|
#include <core/loghelper.h> // @TODO: remove in productive
|
||||||
|
|
||||||
#define QUERY_NICK_PREPARE "nick_template"
|
#define QUERY_NICK_PREPARE "nick_template"
|
||||||
#define QUERY_LOGIN_PREPARE "login_template"
|
#define QUERY_LOGIN_PREPARE "login_template"
|
||||||
#define QUERY_AVATAR_BLACKLIST_PREPARE "avatar_blacklist_template"
|
#define QUERY_AVATAR_BLACKLIST_PREPARE "avatar_blacklist_template"
|
||||||
@@ -58,6 +61,7 @@
|
|||||||
#define QUERY_REPORT_GAME_PREPARE "report_game_template"
|
#define QUERY_REPORT_GAME_PREPARE "report_game_template"
|
||||||
#define QUERY_ADMIN_PLAYER_PREPARE "admin_player_template"
|
#define QUERY_ADMIN_PLAYER_PREPARE "admin_player_template"
|
||||||
#define QUERY_BLOCK_PLAYER_PREPARE "block_player_template"
|
#define QUERY_BLOCK_PLAYER_PREPARE "block_player_template"
|
||||||
|
#define QUERY_PLAYER_LASTGAMES_PREPARE "player_lastgames_template"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -230,6 +234,33 @@ ServerDBThread::SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned
|
|||||||
m_semaphore.post();
|
m_semaphore.post();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ServerDBThread::SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> last_games, std::string playerIp)
|
||||||
|
{
|
||||||
|
LOG_ERROR("ServerDBThread::SetPlayerLastGames() entered.");
|
||||||
|
|
||||||
|
std::ostringstream oss;
|
||||||
|
std::copy(last_games.begin(), last_games.end(), std::ostream_iterator<int>(oss, ","));
|
||||||
|
std::string last_gamesFieldValue( oss.str() );
|
||||||
|
list<string> params;
|
||||||
|
ostringstream paramStream;
|
||||||
|
params.push_back(last_gamesFieldValue);
|
||||||
|
params.push_back(playerIp);
|
||||||
|
paramStream << playerId;
|
||||||
|
params.push_back(paramStream.str());
|
||||||
|
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||||
|
new AsyncDBPlayerLastGames(
|
||||||
|
requestId,
|
||||||
|
QUERY_PLAYER_LASTGAMES_PREPARE,
|
||||||
|
params));
|
||||||
|
{
|
||||||
|
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||||
|
m_asyncQueue.push(asyncQuery);
|
||||||
|
}
|
||||||
|
LOG_ERROR("Query posted.");
|
||||||
|
m_semaphore.post();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerDBThread::EndGame(unsigned requestId)
|
ServerDBThread::EndGame(unsigned requestId)
|
||||||
{
|
{
|
||||||
@@ -432,7 +463,7 @@ ServerDBThread::EstablishDBConnection()
|
|||||||
*/
|
*/
|
||||||
prepareNick
|
prepareNick
|
||||||
<< "PREPARE " QUERY_NICK_PREPARE " FROM " << mysqlpp::quote
|
<< "PREPARE " QUERY_NICK_PREPARE " FROM " << mysqlpp::quote
|
||||||
<< "SELECT " DB_TABLE_PLAYER_COL_ID ", AES_DECRYPT(" DB_TABLE_PLAYER_COL_PASSWORD ", ?), " DB_TABLE_PLAYER_COL_VALID ", TRIM(" DB_TABLE_PLAYER_COL_COUNTRY "), " DB_TABLE_PLAYER_COL_LASTLOGIN ", " DB_TABLE_PLAYER_COL_ACTIVE " FROM " DB_TABLE_PLAYER " WHERE " DB_TABLE_PLAYER_COL_USERNAME " = ?";
|
<< "SELECT " DB_TABLE_PLAYER_COL_ID ", AES_DECRYPT(" DB_TABLE_PLAYER_COL_PASSWORD ", ?), " DB_TABLE_PLAYER_COL_VALID ", TRIM(" DB_TABLE_PLAYER_COL_COUNTRY "), " DB_TABLE_PLAYER_COL_LASTLOGIN ", " DB_TABLE_PLAYER_COL_LASTGAMES ", " DB_TABLE_PLAYER_COL_LASTIP ", " DB_TABLE_PLAYER_COL_ACTIVE " FROM " DB_TABLE_PLAYER " WHERE " DB_TABLE_PLAYER_COL_USERNAME " = ?";
|
||||||
|
|
||||||
mysqlpp::Query prepareAvatarBlacklist = m_connData->conn.query();
|
mysqlpp::Query prepareAvatarBlacklist = m_connData->conn.query();
|
||||||
prepareAvatarBlacklist
|
prepareAvatarBlacklist
|
||||||
@@ -479,12 +510,16 @@ ServerDBThread::EstablishDBConnection()
|
|||||||
prepareBlockPlayer
|
prepareBlockPlayer
|
||||||
<< "PREPARE " QUERY_BLOCK_PLAYER_PREPARE " FROM " << mysqlpp::quote
|
<< "PREPARE " QUERY_BLOCK_PLAYER_PREPARE " FROM " << mysqlpp::quote
|
||||||
<< "UPDATE " DB_TABLE_PLAYER " SET " DB_TABLE_PLAYER_COL_VALID " = ?, " DB_TABLE_PLAYER_COL_ACTIVE " = ? WHERE " DB_TABLE_PLAYER_COL_ID " = ?";
|
<< "UPDATE " DB_TABLE_PLAYER " SET " DB_TABLE_PLAYER_COL_VALID " = ?, " DB_TABLE_PLAYER_COL_ACTIVE " = ? WHERE " DB_TABLE_PLAYER_COL_ID " = ?";
|
||||||
|
mysqlpp::Query preparePlayerLastGames = m_connData->conn.query();
|
||||||
|
preparePlayerLastGames
|
||||||
|
<< "PREPARE " QUERY_PLAYER_LASTGAMES_PREPARE " FROM " << mysqlpp::quote
|
||||||
|
<< "UPDATE " DB_TABLE_PLAYER " SET " DB_TABLE_PLAYER_COL_LASTGAMES " = ?, " DB_TABLE_PLAYER_COL_LASTIP " = ? WHERE " DB_TABLE_PLAYER_COL_ID " = ?";
|
||||||
if (!prepareNick.exec() || !prepareAvatarBlacklist.exec() || !prepareLogin.exec() || !prepareCreateGame.exec()
|
if (!prepareNick.exec() || !prepareAvatarBlacklist.exec() || !prepareLogin.exec() || !prepareCreateGame.exec()
|
||||||
|| !prepareEndGame.exec() || !prepareRelation.exec() || !prepareScore.exec() || !prepareReportAvatar.exec()
|
|| !prepareEndGame.exec() || !prepareRelation.exec() || !prepareScore.exec() || !prepareReportAvatar.exec()
|
||||||
|| !prepareReportGame.exec() || !prepareAdminPlayer.exec() || !prepareBlockPlayer.exec()) {
|
|| !prepareReportGame.exec() || !prepareAdminPlayer.exec() || !prepareBlockPlayer.exec() || !preparePlayerLastGames.exec()) {
|
||||||
string tmpError = string(prepareNick.error()) + prepareAvatarBlacklist.error() + prepareLogin.error() + prepareCreateGame.error() +
|
string tmpError = string(prepareNick.error()) + prepareAvatarBlacklist.error() + prepareLogin.error() + prepareCreateGame.error() +
|
||||||
prepareEndGame.error() + prepareRelation.error() + prepareScore.error() + prepareReportAvatar.error() +
|
prepareEndGame.error() + prepareRelation.error() + prepareScore.error() + prepareReportAvatar.error() +
|
||||||
prepareReportGame.error() + prepareAdminPlayer.error() + prepareBlockPlayer.error();
|
prepareReportGame.error() + prepareAdminPlayer.error() + prepareBlockPlayer.error() + preparePlayerLastGames.error();
|
||||||
m_connData->conn.disconnect();
|
m_connData->conn.disconnect();
|
||||||
m_ioService->post(boost::bind(&ServerDBCallback::ConnectFailed, &m_callback, tmpError));
|
m_ioService->post(boost::bind(&ServerDBCallback::ConnectFailed, &m_callback, tmpError));
|
||||||
m_permanentError = true;
|
m_permanentError = true;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
#include <dbofficial/dbidmanager.h>
|
#include <dbofficial/dbidmanager.h>
|
||||||
#include <core/thread.h>
|
#include <core/thread.h>
|
||||||
|
|
||||||
|
|
||||||
struct DBConnectionData;
|
struct DBConnectionData;
|
||||||
class AsyncDBQuery;
|
class AsyncDBQuery;
|
||||||
|
|
||||||
@@ -66,6 +67,7 @@ public:
|
|||||||
|
|
||||||
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName);
|
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName);
|
||||||
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place);
|
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place);
|
||||||
|
virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> last_games, std::string playerIp);
|
||||||
virtual void EndGame(unsigned requestId);
|
virtual void EndGame(unsigned requestId);
|
||||||
|
|
||||||
virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId);
|
virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId);
|
||||||
|
|||||||
@@ -2222,13 +2222,13 @@ p, li { white-space: pre-wrap; }
|
|||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>600</width>
|
<width>600</width>
|
||||||
<height>94</height>
|
<height>114</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>600</width>
|
<width>600</width>
|
||||||
<height>94</height>
|
<height>114</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
@@ -2631,6 +2631,13 @@ p, li { white-space: pre-wrap; }
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0" colspan="5">
|
||||||
|
<widget class="QLabel" name="label_WinningCombination">
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -2530,6 +2530,7 @@ void gameTableImpl::postRiverRunAnimation2()
|
|||||||
|
|
||||||
if(nonfoldPlayersCounter!=1) {
|
if(nonfoldPlayersCounter!=1) {
|
||||||
|
|
||||||
|
label_WinningCombination->setText(CardsValue::determineHandName(currentGame->getCurrentHand()->getCurrentBeRo()->getHighestCardsValue(), activePlayerList).c_str());
|
||||||
if(!flipHolecardsAllInAlreadyDone) {
|
if(!flipHolecardsAllInAlreadyDone) {
|
||||||
|
|
||||||
for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) {
|
for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) {
|
||||||
@@ -3017,6 +3018,8 @@ void gameTableImpl::nextRoundCleanGui()
|
|||||||
resetMyButtonsCheckStateMemory();
|
resetMyButtonsCheckStateMemory();
|
||||||
clearMyButtons();
|
clearMyButtons();
|
||||||
pushButton_showMyCards->hide();
|
pushButton_showMyCards->hide();
|
||||||
|
label_WinningCombination->clear();
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gameTableImpl::stopTimer()
|
void gameTableImpl::stopTimer()
|
||||||
@@ -3859,7 +3862,7 @@ void gameTableImpl::triggerVoteOnKick(int id)
|
|||||||
int playerCount = static_cast<int>(seatList->size());
|
int playerCount = static_cast<int>(seatList->size());
|
||||||
if (id < playerCount) {
|
if (id < playerCount) {
|
||||||
PlayerListIterator pos = seatList->begin();
|
PlayerListIterator pos = seatList->begin();
|
||||||
advance(pos, id);
|
std::advance(pos, id);
|
||||||
myStartWindow->getSession()->startVoteKickPlayer((*pos)->getMyUniqueID());
|
myStartWindow->getSession()->startVoteKickPlayer((*pos)->getMyUniqueID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4117,6 +4120,7 @@ void gameTableImpl::refreshGameTableStyle()
|
|||||||
myGameTableStyle->setBigFontBoardStyle(textLabel_handLabel);
|
myGameTableStyle->setBigFontBoardStyle(textLabel_handLabel);
|
||||||
myGameTableStyle->setBigFontBoardStyle(label_Pot);
|
myGameTableStyle->setBigFontBoardStyle(label_Pot);
|
||||||
#endif
|
#endif
|
||||||
|
myGameTableStyle->setBigFontBoardStyle(label_WinningCombination);
|
||||||
myGameTableStyle->setCardHolderStyle(label_CardHolder0,0);
|
myGameTableStyle->setCardHolderStyle(label_CardHolder0,0);
|
||||||
myGameTableStyle->setCardHolderStyle(label_CardHolder1,0);
|
myGameTableStyle->setCardHolderStyle(label_CardHolder1,0);
|
||||||
myGameTableStyle->setCardHolderStyle(label_CardHolder2,0);
|
myGameTableStyle->setCardHolderStyle(label_CardHolder2,0);
|
||||||
|
|||||||
@@ -2745,13 +2745,13 @@ p, li { white-space: pre-wrap; }
|
|||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>390</width>
|
<width>390</width>
|
||||||
<height>82</height>
|
<height>102</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>390</width>
|
<width>390</width>
|
||||||
<height>82</height>
|
<height>102</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
@@ -3039,6 +3039,13 @@ p, li { white-space: pre-wrap; }
|
|||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_WinningCombination">
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ AsioReceiveBuffer::ScanPackets(boost::shared_ptr<SessionData> session)
|
|||||||
size_t packetSize = ntohl(nativeVal);
|
size_t packetSize = ntohl(nativeVal);
|
||||||
if (packetSize > MAX_PACKET_SIZE) {
|
if (packetSize > MAX_PACKET_SIZE) {
|
||||||
recvBufUsed = 0;
|
recvBufUsed = 0;
|
||||||
LOG_ERROR("Session " << session->GetId() << " - Invalid packet size: " << packetSize);
|
LOG_ERROR(session->GetClientAddr() << "Session " << session->GetId() << " - Invalid packet size: " << packetSize);
|
||||||
} else if (recvBufUsed >= packetSize + NET_HEADER_SIZE) {
|
} else if (recvBufUsed >= packetSize + NET_HEADER_SIZE) {
|
||||||
try {
|
try {
|
||||||
tmpPacket = NetPacket::Create(&recvBuf[NET_HEADER_SIZE], packetSize);
|
tmpPacket = NetPacket::Create(&recvBuf[NET_HEADER_SIZE], packetSize);
|
||||||
@@ -118,7 +118,7 @@ AsioReceiveBuffer::ScanPackets(boost::shared_ptr<SessionData> session)
|
|||||||
} catch (const exception &e) {
|
} catch (const exception &e) {
|
||||||
// Reset buffer on error.
|
// Reset buffer on error.
|
||||||
recvBufUsed = 0;
|
recvBufUsed = 0;
|
||||||
LOG_ERROR("Session " << session->GetId() << " - " << e.what());
|
LOG_ERROR(session->GetClientAddr() << "Session " << session->GetId() << " - " << e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ AsioReceiveBuffer::ScanPackets(boost::shared_ptr<SessionData> session)
|
|||||||
if (validator.IsValidPacket(*tmpPacket)) {
|
if (validator.IsValidPacket(*tmpPacket)) {
|
||||||
receivedPackets.push_back(tmpPacket);
|
receivedPackets.push_back(tmpPacket);
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR("Session " << session->GetId() << " - Invalid packet: " << tmpPacket->GetMsg()->messagetype());
|
LOG_ERROR(session->GetClientAddr() << "Session " << session->GetId() << " - Invalid packet: " << tmpPacket->GetMsg()->messagetype());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dataAvailable = false;
|
dataAvailable = false;
|
||||||
|
|||||||
@@ -993,8 +993,11 @@ ClientThread::CreateContextSession()
|
|||||||
newSock.reset(new boost::asio::ip::tcp::socket(*m_ioService, tcp::v6()));
|
newSock.reset(new boost::asio::ip::tcp::socket(*m_ioService, tcp::v6()));
|
||||||
else
|
else
|
||||||
newSock.reset(new boost::asio::ip::tcp::socket(*m_ioService, tcp::v4()));
|
newSock.reset(new boost::asio::ip::tcp::socket(*m_ioService, tcp::v4()));
|
||||||
boost::asio::socket_base::non_blocking_io command(true);
|
|
||||||
newSock->io_control(command);
|
// Deprecated non_blocking_io command
|
||||||
|
/*boost::asio::socket_base::non_blocking_io command(true);
|
||||||
|
newSock->io_control(command);*/
|
||||||
|
newSock->non_blocking(true);
|
||||||
newSock->set_option(tcp::no_delay(true));
|
newSock->set_option(tcp::no_delay(true));
|
||||||
newSock->set_option(boost::asio::socket_base::keep_alive(true));
|
newSock->set_option(boost::asio::socket_base::keep_alive(true));
|
||||||
|
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ NetPacket::GameErrorToNetError(int gameErrorReason)
|
|||||||
retVal = ErrorMessage::sessionTimeout;
|
retVal = ErrorMessage::sessionTimeout;
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
retVal = ErrorMessage::reserved;
|
retVal = ErrorMessage::custReserved;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
|
|||||||
@@ -293,11 +293,13 @@ ServerGame::TimerVoteKick(const boost::system::error_code &ec)
|
|||||||
PlayerDataList
|
PlayerDataList
|
||||||
ServerGame::InternalStartGame()
|
ServerGame::InternalStartGame()
|
||||||
{
|
{
|
||||||
|
LOG_ERROR("InternalStartGame() entered.");
|
||||||
// Initialize the game.
|
// Initialize the game.
|
||||||
PlayerDataList playerData(GetFullPlayerDataList());
|
PlayerDataList playerData(GetFullPlayerDataList());
|
||||||
|
|
||||||
if (playerData.size() >= 2) {
|
if (playerData.size() >= 2) {
|
||||||
// Set DB Backend.
|
// Set DB Backend.
|
||||||
|
// @TODO: check for wec or bbc game with bbcbot as creator
|
||||||
if (GetGameData().gameType == GAME_TYPE_RANKING)
|
if (GetGameData().gameType == GAME_TYPE_RANKING)
|
||||||
m_database = GetLobbyThread().GetDatabase();
|
m_database = GetLobbyThread().GetDatabase();
|
||||||
else
|
else
|
||||||
@@ -346,6 +348,12 @@ ServerGame::InternalStartGame()
|
|||||||
|
|
||||||
GetDatabase().AsyncCreateGame(GetId(), GetName());
|
GetDatabase().AsyncCreateGame(GetId(), GetName());
|
||||||
InitRankingMap(playerData);
|
InitRankingMap(playerData);
|
||||||
|
|
||||||
|
// @TODO: here to save last_games with mysql per player
|
||||||
|
|
||||||
|
if (GetGameData().gameType == GAME_TYPE_RANKING)
|
||||||
|
StoreLastGames(playerData);
|
||||||
|
|
||||||
}
|
}
|
||||||
return playerData;
|
return playerData;
|
||||||
}
|
}
|
||||||
@@ -442,6 +450,26 @@ ServerGame::StoreAndResetRanking()
|
|||||||
m_rankingMap.clear();
|
m_rankingMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ServerGame::StoreLastGames(const PlayerDataList &playerDataList)
|
||||||
|
{
|
||||||
|
// Store players lastgames in database.
|
||||||
|
PlayerDataList::const_iterator i = playerDataList.begin();
|
||||||
|
PlayerDataList::const_iterator end = playerDataList.end();
|
||||||
|
while (i != end) {
|
||||||
|
boost::shared_ptr<PlayerData> tmpPlayer(*i);
|
||||||
|
// tmpPlayer->GetUniqueId()
|
||||||
|
tmpPlayer->AddPlayerLastGame((long)time(NULL));
|
||||||
|
LOG_ERROR("TimeStamp stored: " << tmpPlayer->GetPlayerLastGames().back());
|
||||||
|
std::vector<long> last_games = tmpPlayer->GetPlayerLastGames();
|
||||||
|
LOG_ERROR("Ready for storing vector for player " << tmpPlayer->GetDBId() << " - lastGameTs " << last_games.back());
|
||||||
|
if(tmpPlayer->GetDBId() != DB_ID_INVALID){
|
||||||
|
GetDatabase().SetPlayerLastGames(GetId(), tmpPlayer->GetDBId(), last_games, GetSessionManager().GetSessionByUniquePlayerId(tmpPlayer->GetUniqueId())->GetClientAddr());
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerGame::RemoveAutoLeavePlayers()
|
ServerGame::RemoveAutoLeavePlayers()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,8 +62,10 @@
|
|||||||
#include <boost/uuid/uuid.hpp>
|
#include <boost/uuid/uuid.hpp>
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <gsasl.h>
|
#include <gsasl.h>
|
||||||
|
#include <ctime>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#define SERVER_MAX_NUM_LOBBY_SESSIONS 512 // Maximum number of idle users in lobby.
|
#define SERVER_MAX_NUM_LOBBY_SESSIONS 1536 // Maximum number of idle users in lobby.
|
||||||
#define SERVER_MAX_NUM_TOTAL_SESSIONS 2000 // Total maximum of sessions, fitting a 2048 handle limit
|
#define SERVER_MAX_NUM_TOTAL_SESSIONS 2000 // Total maximum of sessions, fitting a 2048 handle limit
|
||||||
|
|
||||||
#define SERVER_SAVE_STATISTICS_INTERVAL_SEC 60
|
#define SERVER_SAVE_STATISTICS_INTERVAL_SEC 60
|
||||||
@@ -303,7 +305,8 @@ ServerLobbyThread::AddConnection(boost::shared_ptr<SessionData> sessionData)
|
|||||||
// Create a new session.
|
// Create a new session.
|
||||||
m_sessionManager.AddSession(sessionData);
|
m_sessionManager.AddSession(sessionData);
|
||||||
|
|
||||||
LOG_VERBOSE("Accepted connection - session #" << sessionData->GetId() << ".");
|
LOG_VERBOSE(sessionData->GetRemoteIPAddressFromSocket() << " Accepted connection - session #" << sessionData->GetId() << ".");
|
||||||
|
LOG_ERROR(sessionData->GetRemoteIPAddressFromSocket() << " Accepted connection - session #" << sessionData->GetId() << ".");
|
||||||
|
|
||||||
sessionData->StartTimerInitTimeout(SERVER_INIT_SESSION_TIMEOUT_SEC);
|
sessionData->StartTimerInitTimeout(SERVER_INIT_SESSION_TIMEOUT_SEC);
|
||||||
sessionData->StartTimerGlobalTimeout(SERVER_SESSION_FORCED_TIMEOUT_SEC);
|
sessionData->StartTimerGlobalTimeout(SERVER_SESSION_FORCED_TIMEOUT_SEC);
|
||||||
@@ -1347,7 +1350,7 @@ ServerLobbyThread::HandleNetPacketRetrieveAvatar(boost::shared_ptr<SessionData>
|
|||||||
void
|
void
|
||||||
ServerLobbyThread::HandleNetPacketCreateGame(boost::shared_ptr<SessionData> session, const JoinNewGameMessage &newGame)
|
ServerLobbyThread::HandleNetPacketCreateGame(boost::shared_ptr<SessionData> session, const JoinNewGameMessage &newGame)
|
||||||
{
|
{
|
||||||
LOG_VERBOSE("Creating new game, initiated by session #" << session->GetId() << ".");
|
LOG_ERROR("Creating new game, initiated by session #" << session->GetId() << ".");
|
||||||
|
|
||||||
string password;
|
string password;
|
||||||
if (newGame.has_password())
|
if (newGame.has_password())
|
||||||
@@ -1377,6 +1380,10 @@ ServerLobbyThread::HandleNetPacketCreateGame(boost::shared_ptr<SessionData> sess
|
|||||||
SendJoinGameFailed(session, gameId, NTF_NET_JOIN_GUEST_FORBIDDEN);
|
SendJoinGameFailed(session, gameId, NTF_NET_JOIN_GUEST_FORBIDDEN);
|
||||||
} else if (!ServerGame::CheckSettings(tmpData, password, GetServerMode())) {
|
} else if (!ServerGame::CheckSettings(tmpData, password, GetServerMode())) {
|
||||||
SendJoinGameFailed(session, gameId, NTF_NET_JOIN_INVALID_SETTINGS);
|
SendJoinGameFailed(session, gameId, NTF_NET_JOIN_INVALID_SETTINGS);
|
||||||
|
} else if (!session->GetPlayerData()->IsPlayerAllowedToJoinCreateLimitRank(m_serverConfig.readConfigString("ServerLimitRankNum"), m_serverConfig.readConfigString("ServerLimitRankPeriod"))
|
||||||
|
&& tmpData.gameType == GAME_TYPE_RANKING ) {
|
||||||
|
LOG_ERROR("not allowed due to ranklimit");
|
||||||
|
SendJoinGameFailed(session, gameId, NTF_NET_JOIN_IP_BLOCKED);
|
||||||
} else {
|
} else {
|
||||||
boost::shared_ptr<ServerGame> game(
|
boost::shared_ptr<ServerGame> game(
|
||||||
new ServerGame(
|
new ServerGame(
|
||||||
@@ -1418,6 +1425,7 @@ ServerLobbyThread::HandleNetPacketJoinGame(boost::shared_ptr<SessionData> sessio
|
|||||||
MoveSessionToGame(game, session, joinGame.autoleave(), true);
|
MoveSessionToGame(game, session, joinGame.autoleave(), true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
LOG_ERROR("JoinGame pre validation");
|
||||||
// As guest, you are only allowed to join normal games.
|
// As guest, you are only allowed to join normal games.
|
||||||
if (session->GetPlayerData()->GetRights() == PLAYER_RIGHTS_GUEST
|
if (session->GetPlayerData()->GetRights() == PLAYER_RIGHTS_GUEST
|
||||||
&& tmpData.gameType != GAME_TYPE_NORMAL) {
|
&& tmpData.gameType != GAME_TYPE_NORMAL) {
|
||||||
@@ -1427,14 +1435,14 @@ ServerLobbyThread::HandleNetPacketJoinGame(boost::shared_ptr<SessionData> sessio
|
|||||||
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_NOT_INVITED);
|
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_NOT_INVITED);
|
||||||
} else if (!game->CheckPassword(password)) {
|
} else if (!game->CheckPassword(password)) {
|
||||||
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_INVALID_PASSWORD);
|
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_INVALID_PASSWORD);
|
||||||
} else if (tmpData.gameType == GAME_TYPE_RANKING
|
} else if (tmpData.gameType == GAME_TYPE_RANKING && !session->GetPlayerData()->IsPlayerAllowedToJoinCreateLimitRank(m_serverConfig.readConfigString("ServerLimitRankNum"), m_serverConfig.readConfigString("ServerLimitRankPeriod"))) {
|
||||||
&& !joinGame.spectateonly()
|
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED);
|
||||||
|
} else if (tmpData.gameType == GAME_TYPE_RANKING && !joinGame.spectateonly()
|
||||||
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR
|
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR
|
||||||
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4V6
|
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4V6
|
||||||
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4
|
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4
|
||||||
&& game->IsClientAddressConnected(session->GetClientAddr())) {
|
&& game->IsClientAddressConnected(session->GetClientAddr())) {
|
||||||
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED);
|
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MoveSessionToGame(game, session, joinGame.autoleave(), false);
|
MoveSessionToGame(game, session, joinGame.autoleave(), false);
|
||||||
}
|
}
|
||||||
@@ -1803,6 +1811,18 @@ ServerLobbyThread::UserValid(unsigned playerId, const DBPlayerData &dbPlayerData
|
|||||||
if (tmpSession && tmpSession->GetPlayerData()) {
|
if (tmpSession && tmpSession->GetPlayerData()) {
|
||||||
tmpSession->GetPlayerData()->SetDBId(dbPlayerData.id);
|
tmpSession->GetPlayerData()->SetDBId(dbPlayerData.id);
|
||||||
tmpSession->GetPlayerData()->SetCountry(dbPlayerData.country);
|
tmpSession->GetPlayerData()->SetCountry(dbPlayerData.country);
|
||||||
|
if(dbPlayerData.last_games.length() > 0){
|
||||||
|
LOG_ERROR("last_games from db = " << dbPlayerData.last_games);
|
||||||
|
vector<string> last_games;
|
||||||
|
boost::split(last_games, dbPlayerData.last_games, boost::is_any_of(","));
|
||||||
|
for (unsigned int i = 0; i < last_games.size(); i++){
|
||||||
|
if(last_games[i].length() > 0)
|
||||||
|
tmpSession->GetPlayerData()->AddPlayerLastGame(stol(last_games[i]));
|
||||||
|
}
|
||||||
|
LOG_ERROR("last_games last from vector after db = " << tmpSession->GetPlayerData()->GetPlayerLastGames().back());
|
||||||
|
}else{
|
||||||
|
LOG_ERROR("no lastGames from db");
|
||||||
|
}
|
||||||
this->AuthChallenge(tmpSession, dbPlayerData.secret);
|
this->AuthChallenge(tmpSession, dbPlayerData.secret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,8 @@
|
|||||||
#include <net/serverexception.h>
|
#include <net/serverexception.h>
|
||||||
#include <net/socket_msg.h>
|
#include <net/socket_msg.h>
|
||||||
|
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define SERVER_MAX_GUEST_USERS_LOBBY 50 // LG: Maximum number of guests users in lobby allowed
|
#define SERVER_MAX_GUEST_USERS_LOBBY 50 // LG: Maximum number of guests users in lobby allowed
|
||||||
|
|||||||
@@ -122,8 +122,10 @@ protected:
|
|||||||
const boost::system::error_code &error)
|
const boost::system::error_code &error)
|
||||||
{
|
{
|
||||||
if (!error) {
|
if (!error) {
|
||||||
boost::asio::socket_base::non_blocking_io command(true);
|
// Deprecated non_blocking_io command
|
||||||
acceptedSocket->io_control(command);
|
/*boost::asio::socket_base::non_blocking_io command(true);
|
||||||
|
newSock->io_control(command);*/
|
||||||
|
acceptedSocket->non_blocking(true);
|
||||||
acceptedSocket->set_option(typename P::no_delay(true));
|
acceptedSocket->set_option(typename P::no_delay(true));
|
||||||
acceptedSocket->set_option(boost::asio::socket_base::keep_alive(true));
|
acceptedSocket->set_option(boost::asio::socket_base::keep_alive(true));
|
||||||
boost::shared_ptr<SessionData> sessionData(new SessionData(acceptedSocket, m_lobbyThread->GetNextSessionId(), m_lobbyThread->GetSessionDataCallback(), *m_ioService));
|
boost::shared_ptr<SessionData> sessionData(new SessionData(acceptedSocket, m_lobbyThread->GetNextSessionId(), m_lobbyThread->GetSessionDataCallback(), *m_ioService));
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ protected:
|
|||||||
void SetPlayerPlace(unsigned playerId, int place);
|
void SetPlayerPlace(unsigned playerId, int place);
|
||||||
void ReplaceRankingPlayer(unsigned oldPlayerId, unsigned newPlayerId);
|
void ReplaceRankingPlayer(unsigned oldPlayerId, unsigned newPlayerId);
|
||||||
void StoreAndResetRanking();
|
void StoreAndResetRanking();
|
||||||
|
void StoreLastGames(const PlayerDataList &playerDataList);
|
||||||
void RemoveAutoLeavePlayers();
|
void RemoveAutoLeavePlayers();
|
||||||
void InternalEndGame();
|
void InternalEndGame();
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ typedef unsigned SessionId;
|
|||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
#include <boost/enable_shared_from_this.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <net/socket_helper.h>
|
#include <net/socket_helper.h>
|
||||||
#include <net/sessiondatacallback.h>
|
#include <net/sessiondatacallback.h>
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ public:
|
|||||||
bool IsPlayerConnected(unsigned uniqueId) const;
|
bool IsPlayerConnected(unsigned uniqueId) const;
|
||||||
bool IsClientAddressConnected(const std::string &clientAddress) const;
|
bool IsClientAddressConnected(const std::string &clientAddress) const;
|
||||||
bool IsGuestAllowedToConnect(const std::string &clientAddress) const;
|
bool IsGuestAllowedToConnect(const std::string &clientAddress) const;
|
||||||
|
bool IsPlayerAllowedToJoinCreateLimitRank(const std::string &playerName) const;
|
||||||
|
bool IsPlayerAllowedToJoinCreateLimitRank(unsigned uniqueId) const;
|
||||||
|
|
||||||
void ForEach(boost::function<void (boost::shared_ptr<SessionData>)> func);
|
void ForEach(boost::function<void (boost::shared_ptr<SessionData>)> func);
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
* as that of the covered work. *
|
* as that of the covered work. *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#include <playerdata.h>
|
#include <playerdata.h>
|
||||||
|
#include <ctime>
|
||||||
|
#include <core/loghelper.h> // @TODO: remove in productive
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -242,3 +244,59 @@ PlayerData::operator<(const PlayerData &other) const
|
|||||||
return m_number < other.GetNumber();
|
return m_number < other.GetNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlayerData::SetPlayerLastGames(std::vector<long> last_games)
|
||||||
|
{
|
||||||
|
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||||
|
m_last_games.clear();
|
||||||
|
m_last_games = last_games;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlayerData::AddPlayerLastGame(long lastGame)
|
||||||
|
{
|
||||||
|
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||||
|
|
||||||
|
m_last_games.push_back(lastGame);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<long>
|
||||||
|
PlayerData::GetPlayerLastGames()
|
||||||
|
{
|
||||||
|
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||||
|
return m_last_games;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
PlayerData::IsPlayerAllowedToJoinCreateLimitRank(std::string num, std::string period)
|
||||||
|
{
|
||||||
|
bool retVal = false;
|
||||||
|
LOG_ERROR("checking IsPlayerAllowedToJoinCreateLimitRank() ");
|
||||||
|
LOG_ERROR("num = " << num << " period " << period);
|
||||||
|
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||||
|
|
||||||
|
long then = (long)time(NULL) - (long)(stoi(period) * 60);
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
int i=0;
|
||||||
|
for(std::vector<long>::iterator timeStamp = m_last_games.begin(); timeStamp != m_last_games.end(); ++timeStamp) {
|
||||||
|
LOG_ERROR("timeStamp " << *timeStamp);
|
||||||
|
time_t ts = (time_t)*timeStamp;
|
||||||
|
LOG_ERROR("comparing ts " << (long)ts << " with " << then);
|
||||||
|
if((long)ts > then){
|
||||||
|
LOG_ERROR("counting timeStamp in time " << ctime(&ts));
|
||||||
|
count++;
|
||||||
|
}else{
|
||||||
|
LOG_ERROR("erasing overdued timestamp " << ctime(&ts));
|
||||||
|
timeStamp = m_last_games.erase(timeStamp); // erase overdued entries
|
||||||
|
if( timeStamp == m_last_games.end())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count < stoi(num))
|
||||||
|
retVal = true;
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|||||||
@@ -116,6 +116,12 @@ public:
|
|||||||
int GetStartCash() const;
|
int GetStartCash() const;
|
||||||
void SetStartCash(int cash);
|
void SetStartCash(int cash);
|
||||||
|
|
||||||
|
// @TODO: last_games here
|
||||||
|
void AddPlayerLastGame(long last_games);
|
||||||
|
void SetPlayerLastGames(std::vector<long> last_games);
|
||||||
|
std::vector<long> GetPlayerLastGames();
|
||||||
|
bool IsPlayerAllowedToJoinCreateLimitRank(std::string num, std::string period);
|
||||||
|
|
||||||
bool operator<(const PlayerData &other) const;
|
bool operator<(const PlayerData &other) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -135,6 +141,8 @@ private:
|
|||||||
bool m_isGameAdmin;
|
bool m_isGameAdmin;
|
||||||
boost::shared_ptr<AvatarFile> m_netAvatarFile;
|
boost::shared_ptr<AvatarFile> m_netAvatarFile;
|
||||||
|
|
||||||
|
std::vector<long> m_last_games;
|
||||||
|
|
||||||
mutable boost::mutex m_dataMutex;
|
mutable boost::mutex m_dataMutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ int main( int argc, char **argv )
|
|||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
a.setApplicationName("PokerTH");
|
a.setApplicationName("PokerTH");
|
||||||
#else
|
#else
|
||||||
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
SharedTools::QtSingleApplication a( "PokerTH", argc, argv );
|
SharedTools::QtSingleApplication a( "PokerTH", argc, argv );
|
||||||
if (a.sendMessage("Wake up!")) {
|
if (a.sendMessage("Wake up!")) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
+1
-1
@@ -23806,7 +23806,7 @@ bool ErrorMessage_ErrorReason_IsValid(int value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
const ErrorMessage_ErrorReason ErrorMessage::reserved;
|
const ErrorMessage_ErrorReason ErrorMessage::custReserved;
|
||||||
const ErrorMessage_ErrorReason ErrorMessage::initVersionNotSupported;
|
const ErrorMessage_ErrorReason ErrorMessage::initVersionNotSupported;
|
||||||
const ErrorMessage_ErrorReason ErrorMessage::initServerFull;
|
const ErrorMessage_ErrorReason ErrorMessage::initServerFull;
|
||||||
const ErrorMessage_ErrorReason ErrorMessage::initAuthFailure;
|
const ErrorMessage_ErrorReason ErrorMessage::initAuthFailure;
|
||||||
|
|||||||
+3
-3
@@ -345,7 +345,7 @@ const ReportGameAckMessage_ReportGameResult ReportGameAckMessage_ReportGameResul
|
|||||||
const int ReportGameAckMessage_ReportGameResult_ReportGameResult_ARRAYSIZE = ReportGameAckMessage_ReportGameResult_ReportGameResult_MAX + 1;
|
const int ReportGameAckMessage_ReportGameResult_ReportGameResult_ARRAYSIZE = ReportGameAckMessage_ReportGameResult_ReportGameResult_MAX + 1;
|
||||||
|
|
||||||
enum ErrorMessage_ErrorReason {
|
enum ErrorMessage_ErrorReason {
|
||||||
ErrorMessage_ErrorReason_reserved = 0,
|
ErrorMessage_ErrorReason_custReserved = 0,
|
||||||
ErrorMessage_ErrorReason_initVersionNotSupported = 1,
|
ErrorMessage_ErrorReason_initVersionNotSupported = 1,
|
||||||
ErrorMessage_ErrorReason_initServerFull = 2,
|
ErrorMessage_ErrorReason_initServerFull = 2,
|
||||||
ErrorMessage_ErrorReason_initAuthFailure = 3,
|
ErrorMessage_ErrorReason_initAuthFailure = 3,
|
||||||
@@ -362,7 +362,7 @@ enum ErrorMessage_ErrorReason {
|
|||||||
ErrorMessage_ErrorReason_sessionTimeout = 14
|
ErrorMessage_ErrorReason_sessionTimeout = 14
|
||||||
};
|
};
|
||||||
bool ErrorMessage_ErrorReason_IsValid(int value);
|
bool ErrorMessage_ErrorReason_IsValid(int value);
|
||||||
const ErrorMessage_ErrorReason ErrorMessage_ErrorReason_ErrorReason_MIN = ErrorMessage_ErrorReason_reserved;
|
const ErrorMessage_ErrorReason ErrorMessage_ErrorReason_ErrorReason_MIN = ErrorMessage_ErrorReason_custReserved;
|
||||||
const ErrorMessage_ErrorReason ErrorMessage_ErrorReason_ErrorReason_MAX = ErrorMessage_ErrorReason_sessionTimeout;
|
const ErrorMessage_ErrorReason ErrorMessage_ErrorReason_ErrorReason_MAX = ErrorMessage_ErrorReason_sessionTimeout;
|
||||||
const int ErrorMessage_ErrorReason_ErrorReason_ARRAYSIZE = ErrorMessage_ErrorReason_ErrorReason_MAX + 1;
|
const int ErrorMessage_ErrorReason_ErrorReason_ARRAYSIZE = ErrorMessage_ErrorReason_ErrorReason_MAX + 1;
|
||||||
|
|
||||||
@@ -10416,7 +10416,7 @@ class ErrorMessage : public ::google::protobuf::MessageLite {
|
|||||||
// nested types ----------------------------------------------------
|
// nested types ----------------------------------------------------
|
||||||
|
|
||||||
typedef ErrorMessage_ErrorReason ErrorReason;
|
typedef ErrorMessage_ErrorReason ErrorReason;
|
||||||
static const ErrorReason reserved = ErrorMessage_ErrorReason_reserved;
|
static const ErrorReason custReserved = ErrorMessage_ErrorReason_custReserved;
|
||||||
static const ErrorReason initVersionNotSupported = ErrorMessage_ErrorReason_initVersionNotSupported;
|
static const ErrorReason initVersionNotSupported = ErrorMessage_ErrorReason_initVersionNotSupported;
|
||||||
static const ErrorReason initServerFull = ErrorMessage_ErrorReason_initServerFull;
|
static const ErrorReason initServerFull = ErrorMessage_ErrorReason_initServerFull;
|
||||||
static const ErrorReason initAuthFailure = ErrorMessage_ErrorReason_initAuthFailure;
|
static const ErrorReason initAuthFailure = ErrorMessage_ErrorReason_initAuthFailure;
|
||||||
|
|||||||
@@ -48996,9 +48996,9 @@ public final class ProtoBuf {
|
|||||||
public enum ErrorReason
|
public enum ErrorReason
|
||||||
implements com.google.protobuf.Internal.EnumLite {
|
implements com.google.protobuf.Internal.EnumLite {
|
||||||
/**
|
/**
|
||||||
* <code>reserved = 0;</code>
|
* <code>custReserved = 0;</code>
|
||||||
*/
|
*/
|
||||||
reserved(0, 0),
|
custReserved(0, 0),
|
||||||
/**
|
/**
|
||||||
* <code>initVersionNotSupported = 1;</code>
|
* <code>initVersionNotSupported = 1;</code>
|
||||||
*/
|
*/
|
||||||
@@ -49058,9 +49058,9 @@ public final class ProtoBuf {
|
|||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>reserved = 0;</code>
|
* <code>custReserved = 0;</code>
|
||||||
*/
|
*/
|
||||||
public static final int reserved_VALUE = 0;
|
public static final int custReserved_VALUE = 0;
|
||||||
/**
|
/**
|
||||||
* <code>initVersionNotSupported = 1;</code>
|
* <code>initVersionNotSupported = 1;</code>
|
||||||
*/
|
*/
|
||||||
@@ -49123,7 +49123,7 @@ public final class ProtoBuf {
|
|||||||
|
|
||||||
public static ErrorReason valueOf(int value) {
|
public static ErrorReason valueOf(int value) {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 0: return reserved;
|
case 0: return custReserved;
|
||||||
case 1: return initVersionNotSupported;
|
case 1: return initVersionNotSupported;
|
||||||
case 2: return initServerFull;
|
case 2: return initServerFull;
|
||||||
case 3: return initAuthFailure;
|
case 3: return initAuthFailure;
|
||||||
@@ -49180,7 +49180,7 @@ public final class ProtoBuf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initFields() {
|
private void initFields() {
|
||||||
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.reserved;
|
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.custReserved;
|
||||||
}
|
}
|
||||||
private byte memoizedIsInitialized = -1;
|
private byte memoizedIsInitialized = -1;
|
||||||
public final boolean isInitialized() {
|
public final boolean isInitialized() {
|
||||||
@@ -49309,7 +49309,7 @@ public final class ProtoBuf {
|
|||||||
|
|
||||||
public Builder clear() {
|
public Builder clear() {
|
||||||
super.clear();
|
super.clear();
|
||||||
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.reserved;
|
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.custReserved;
|
||||||
bitField0_ = (bitField0_ & ~0x00000001);
|
bitField0_ = (bitField0_ & ~0x00000001);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -49379,7 +49379,7 @@ public final class ProtoBuf {
|
|||||||
}
|
}
|
||||||
private int bitField0_;
|
private int bitField0_;
|
||||||
|
|
||||||
private de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.reserved;
|
private de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.custReserved;
|
||||||
/**
|
/**
|
||||||
* <code>required .ErrorMessage.ErrorReason errorReason = 1;</code>
|
* <code>required .ErrorMessage.ErrorReason errorReason = 1;</code>
|
||||||
*/
|
*/
|
||||||
@@ -49409,7 +49409,7 @@ public final class ProtoBuf {
|
|||||||
*/
|
*/
|
||||||
public Builder clearErrorReason() {
|
public Builder clearErrorReason() {
|
||||||
bitField0_ = (bitField0_ & ~0x00000001);
|
bitField0_ = (bitField0_ & ~0x00000001);
|
||||||
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.reserved;
|
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.custReserved;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -17,17 +17,17 @@
|
|||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui/qt/styles/carddeckstylereader.cpp" line="201"/>
|
<location filename="../src/gui/qt/styles/carddeckstylereader.cpp" line="201"/>
|
||||||
<source>Some cards pictures are missing, please contact style maintainer for this issue.</source>
|
<source>Some cards pictures are missing, please contact style maintainer for this issue.</source>
|
||||||
<translation>Certaines images des cartes sont manquantes, veuillez contacter l'auteur pour qu'il corrige ce problème.</translation>
|
<translation>Certaines images de cartes sont manquantes, veuillez contacter le mainteneur du style pour qu'il corrige ce problème.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui/qt/styles/carddeckstylereader.cpp" line="204"/>
|
<location filename="../src/gui/qt/styles/carddeckstylereader.cpp" line="204"/>
|
||||||
<source>Some style fields are missing, please contact style maintainer for this issue.</source>
|
<source>Some style fields are missing, please contact style maintainer for this issue.</source>
|
||||||
<translation>Certains champs sont manquants, veuillez contacter l'auteur pour lui demander de corriger ce problème.</translation>
|
<translation>Certains champs sont manquants, veuillez contacter le mainteneur du style pour qu'il corrige ce problème.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui/qt/styles/carddeckstylereader.cpp" line="207"/>
|
<location filename="../src/gui/qt/styles/carddeckstylereader.cpp" line="207"/>
|
||||||
<source>This style is outdated, please contact style maintainer for this issue.</source>
|
<source>This style is outdated, please contact style maintainer for this issue.</source>
|
||||||
<translation>Ce style est obsolète, veuillez contacter l'auteur pour lui demander de le mettre à jour.</translation>
|
<translation>Ce style est obsolète, veuillez contacter le mainteneur du style pour ce problème.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui/qt/styles/carddeckstylereader.cpp" line="224"/>
|
<location filename="../src/gui/qt/styles/carddeckstylereader.cpp" line="224"/>
|
||||||
@@ -8991,7 +8991,7 @@ Veuillez choisir un nom différent.</translation>
|
|||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui/qt/gui_800x480/tabs_800x480.ui" line="503"/>
|
<location filename="../src/gui/qt/gui_800x480/tabs_800x480.ui" line="503"/>
|
||||||
<source>Chance</source>
|
<source>Chance</source>
|
||||||
<translation>Chance</translation>
|
<translation>Probabilité</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui/qt/gui_800x480/tabs_800x480.ui" line="608"/>
|
<location filename="../src/gui/qt/gui_800x480/tabs_800x480.ui" line="608"/>
|
||||||
|
|||||||
+1
-1
@@ -48,7 +48,7 @@ unix : !mac {
|
|||||||
#QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections
|
#QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections
|
||||||
#QMAKE_LFLAGS += -Wl,--gc-sections
|
#QMAKE_LFLAGS += -Wl,--gc-sections
|
||||||
|
|
||||||
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system(qmake -query QT_INSTALL_LIBS)
|
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
BOOST_FS = boost_filesystem boost_filesystem-mt
|
BOOST_FS = boost_filesystem boost_filesystem-mt
|
||||||
BOOST_IOSTREAMS = boost_iostreams boost_iostreams-mt
|
BOOST_IOSTREAMS = boost_iostreams boost_iostreams-mt
|
||||||
BOOST_SYSTEM = boost_system boost_system-mt
|
BOOST_SYSTEM = boost_system boost_system-mt
|
||||||
|
|||||||
Reference in New Issue
Block a user