Merge pull request #1 from pokerth/stable

Stable
This commit is contained in:
albmed
2017-02-04 22:24:03 +01:00
committed by GitHub
66 changed files with 13982 additions and 4897 deletions
+21
View File
@@ -0,0 +1,21 @@
# exclude changes done by make process
Makefile
Makefile.chatcleaner
Makefile.pokerth_db
Makefile.pokerth_game
Makefile.pokerth_lib
Makefile.pokerth_protocol
Makefile.pokerth_server
Makefile.pokerth_dbofficial
bin/
chatcleaner
lib/
mocs/
obj/
pokerth
qrc_pokerth.cpp
uics/
make.sh
gitpush_serverstuff_stable
pokerth_server
+2 -2
View File
@@ -15,7 +15,7 @@ Linux:
- libSDL_mixer, libSDL --> http://www.libsdl.org/
- libSQLite3 --> http://sqlite.org/
- libtinyxml > 2.0 --> http://www.sourceforge.net/projects/tinyxml
- protoc >= 2.3.0 (during build), libprotobuf >= 2.3.0 -> http://code.google.com/p/protobuf/downloads/list
- protoc >= 2.3.0 (during build), libprotobuf >= 2.3.0 -> https://github.com/google/protobuf
- For the server: libircclient 1.3 --> http://www.sourceforge.net/projects/libircclient/
Windows:
@@ -28,7 +28,7 @@ Basic Installation
Linux:
1. Type "cd path/to/the/sources". Then do for example "/usr/qt/4/bin/qmake pokerth.pro" to configure the makefile for your system.
Pay attention that the QTDIR environment varialbe points to Qt4 not Qt3. For example QTDIR=/usr/qt/4.
Pay attention that the QTDIR environment variable points to Qt4 not Qt3. For example QTDIR=/usr/qt/4.
You can set this variable typing: "export QTDIR=/usr/qt/4"
2. Type "make" to compile the package.
+10 -3
View File
@@ -1,10 +1,17 @@
# QMake pro-file for PokerTH
TEMPLATE = subdirs
SUBDIRS = pokerth_protocol.pro pokerth_db.pro pokerth_lib.pro pokerth_game.pro
!mac:!gui_800x480:!client {
SUBDIRS += pokerth_server.pro chatcleaner.pro
SUBDIRS = pokerth_protocol.pro pokerth_db.pro pokerth_lib.pro
official_server {
SUBDIRS += pokerth_dbofficial.pro
}
client: {
SUBDIRS += pokerth_game.pro
}
!mac:!gui_800x480:!client:!qml-client {
SUBDIRS += pokerth_server.pro chatcleaner.pro
}
CONFIG += ordered
OTHER_FILES += \
+92
View File
@@ -0,0 +1,92 @@
# QMake pro-file for PokerTH official server DB backend
TEMPLATE = lib
CODECFORSRC = UTF-8
CONFIG += staticlib \
thread \
exceptions \
rtti \
stl \
warn_on
UI_DIR = uics
TARGET = lib/pokerth_dbofficial
MOC_DIR = mocs
OBJECTS_DIR = obj
QT -= core \
gui
# PRECOMPILED_HEADER = dbofficial/pch_lib.h
INCLUDEPATH += . \
./src
DEPENDPATH += . \
./src
# Input
HEADERS += src/dbofficial/asyncdbauth.h \
src/dbofficial/asyncdbcreategame.h \
src/dbofficial/asyncdbgameplace.h \
src/dbofficial/asyncdbupdatescore.h \
src/dbofficial/asyncdbquery.h \
src/dbofficial/serverdbthread.h \
src/dbofficial/serverdbfactoryinternal.h \
src/dbofficial/compositeasyncdbquery.h \
src/dbofficial/singleasyncdbquery.h \
src/dbofficial/querycontext.h \
src/dbofficial/asyncdbendgame.h \
src/dbofficial/db_table_defs.h \
src/dbofficial/asyncdblogin.h \
src/dbofficial/asyncdbreportavatar.h \
src/dbofficial/asyncdbreportgame.h \
src/dbofficial/asyncdbavatarblacklist.h \
src/dbofficial/asyncdbadminplayers.h \
src/dbofficial/asyncdbblockplayer.h \
src/dbofficial/dbidmanager.h
SOURCES += src/dbofficial/asyncdbauth.cpp \
src/dbofficial/asyncdbcreategame.cpp \
src/dbofficial/asyncdbgameplace.cpp \
src/dbofficial/asyncdbupdatescore.cpp \
src/dbofficial/asyncdbquery.cpp \
src/dbofficial/serverdbthread.cpp \
src/dbofficial/serverdbfactoryinternal.cpp \
src/dbofficial/singleasyncdbquery.cpp \
src/dbofficial/compositeasyncdbquery.cpp \
src/dbofficial/querycontext.cpp \
src/dbofficial/asyncdbendgame.cpp \
src/dbofficial/asyncdblogin.cpp \
src/dbofficial/asyncdbreportavatar.cpp \
src/dbofficial/asyncdbreportgame.cpp \
src/dbofficial/asyncdbavatarblacklist.cpp \
src/dbofficial/asyncdbadminplayers.cpp \
src/dbofficial/asyncdbblockplayer.cpp \
src/dbofficial/dbidmanager.cpp
win32 {
DEFINES += _WIN32_WINNT=0x0501
INCLUDEPATH += ../../../boost/ \
../../../GnuTLS/include \
../../../curl/include \
../../../mysql/include \
../../../mysql++/lib \
../../../zlib
}
!win32 {
# #### My release static build options
# QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections
INCLUDEPATH += /usr/include \
/usr/include/mysql \
/usr/include/mysql++
INCLUDEPATH += /opt/boost/include
}
mac {
# make it universal
CONFIG += x86
CONFIG -= ppc
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
# for universal-compilation on PPC-Mac uncomment the following line
# on Intel-Mac you have to comment this line out or build will fail.
# QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk/
INCLUDEPATH += /Developer/SDKs/MacOSX10.5.sdk/usr/include/
INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers
INCLUDEPATH += /Library/Frameworks/SDL_mixer.framework/Headers
INCLUDEPATH += /opt/local/include/mysql++ \
/opt/local/include/mysql5/mysql
}
+2 -1
View File
@@ -408,6 +408,7 @@ unix:!mac {
LIBPATH += $${PREFIX}/lib /opt/gsasl/lib
LIB_DIRS = $${PREFIX}/lib \
$${PREFIX}/lib64 \
$${PREFIX}/lib/x86_64-linux-gnu \
$$system(qmake -query QT_INSTALL_LIBS)
}
android{
@@ -601,7 +602,7 @@ mac {
OTHER_FILES += docs/infomessage-id-desc.txt
official_server {
LIBPATH += pkth_stat/daemon_lib/lib
LIBS += -lpokerth_closed \
LIBS += -lpokerth_dbofficial \
-lmysqlpp
DEFINES += POKERTH_OFFICIAL_SERVER
}
+42 -2
View File
@@ -226,9 +226,49 @@ android|android_test{
SOURCES += src/engine/local_engine/tools_android.cpp
}
official_server{
INCLUDEPATH += pkth_stat/daemon_lib/src
official_server:!win32:!gui_800x480:!client:{
# INCLUDEPATH += pkth_stat/daemon_lib/src # note: relict from former official/closed db build
DEFINES += POKERTH_OFFICIAL_SERVER
HEADERS += src/dbofficial/asyncdbauth.h \
src/dbofficial/asyncdbcreategame.h \
src/dbofficial/asyncdbgameplace.h \
src/dbofficial/asyncdbupdatescore.h \
src/dbofficial/asyncdbquery.h \
src/dbofficial/serverdbthread.h \
src/dbofficial/serverdbfactoryinternal.h \
src/dbofficial/compositeasyncdbquery.h \
src/dbofficial/singleasyncdbquery.h \
src/dbofficial/querycontext.h \
src/dbofficial/asyncdbendgame.h \
src/dbofficial/db_table_defs.h \
src/dbofficial/asyncdblogin.h \
src/dbofficial/asyncdbreportavatar.h \
src/dbofficial/asyncdbreportgame.h \
src/dbofficial/asyncdbavatarblacklist.h \
src/dbofficial/asyncdbadminplayers.h \
src/dbofficial/asyncdbblockplayer.h \
src/dbofficial/dbidmanager.h
SOURCES += src/dbofficial/asyncdbauth.cpp \
src/dbofficial/asyncdbcreategame.cpp \
src/dbofficial/asyncdbgameplace.cpp \
src/dbofficial/asyncdbupdatescore.cpp \
src/dbofficial/asyncdbquery.cpp \
src/dbofficial/serverdbthread.cpp \
src/dbofficial/serverdbfactoryinternal.cpp \
src/dbofficial/singleasyncdbquery.cpp \
src/dbofficial/compositeasyncdbquery.cpp \
src/dbofficial/querycontext.cpp \
src/dbofficial/asyncdbendgame.cpp \
src/dbofficial/asyncdblogin.cpp \
src/dbofficial/asyncdbreportavatar.cpp \
src/dbofficial/asyncdbreportgame.cpp \
src/dbofficial/asyncdbavatarblacklist.cpp \
src/dbofficial/asyncdbadminplayers.cpp \
src/dbofficial/asyncdbblockplayer.cpp \
src/dbofficial/dbidmanager.cpp
INCLUDEPATH += /usr/include \
/usr/include/mysql \
/usr/include/mysql++
}
win32{
+6
View File
@@ -37,6 +37,12 @@ unix : !mac {
system(protoc pokerth.proto --cpp_out=src/third_party/protobuf)
system(protoc chatcleaner.proto --cpp_out=src/third_party/protobuf)
system(protoc pokerth.proto --java_out=tests/src)
android {
system(wine protoc.exe pokerth.proto --cpp_out=src/third_party/protobuf)
system(wine protoc.exe chatcleaner.proto --cpp_out=src/third_party/protobuf)
system(wine protoc.exe pokerth.proto --java_out=tests/src)
}
}
mac {
# make it x86_64 only
+3 -1
View File
@@ -175,6 +175,8 @@ unix : !mac {
LIBPATH += lib $${PREFIX}/lib /opt/gsasl/lib
INCLUDEPATH += $${PREFIX}/include
# see issue https://github.com/pokerth/pokerth/issues/282
INCLUDEPATH += $${PREFIX}/include/libircclient
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system(qmake -query QT_INSTALL_LIBS)
BOOST_FS = boost_filesystem boost_filesystem-mt
BOOST_THREAD = boost_thread boost_thread-mt
@@ -320,7 +322,7 @@ mac {
official_server {
LIBPATH += pkth_stat/daemon_lib/lib
LIBS += -lpokerth_closed -lmysqlpp
LIBS += -lpokerth_dbofficial -lmysqlpp
DEFINES += POKERTH_OFFICIAL_SERVER
}
+1
View File
@@ -311,6 +311,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
configList.push_back(ConfigInfo("DBServerDatabaseName", CONFIG_TYPE_STRING, "pokerth"));
configList.push_back(ConfigInfo("DBServerEncryptionKey", CONFIG_TYPE_STRING, ""));
configList.push_back(ConfigInfo("GameNameBadWordList", CONFIG_TYPE_STRING_LIST, "Regex"));
configList.push_back(ConfigInfo("ServerRestrictGuestLogin", CONFIG_TYPE_INT, "0"));
//fill tempList firstTime
configBufferList = configList;
+2 -2
View File
@@ -61,7 +61,7 @@ using namespace std;
using namespace boost::filesystem;
struct AvatarFileState {
ifstream inputStream;
std::ifstream inputStream;
};
AvatarManager::AvatarManager(bool useExternalServer, const std::string &externalServerAddress,
@@ -363,7 +363,7 @@ AvatarManager::StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFil
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);
std::ofstream o(fileName.c_str(), ios_base::out | ios_base::binary | ios_base::trunc);
if (!o.fail()) {
o.write((const char *)data, size);
o.close();
+3 -3
View File
@@ -67,7 +67,7 @@ void
internal_log_err(const string &msg)
{
if (!g_logFile.empty()) {
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
std::ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
if (!o.fail()) {
o << second_clock::local_time() << " ERR: " << msg;
o.flush();
@@ -80,7 +80,7 @@ internal_log_msg(const std::string &msg)
{
if (g_logLevel) {
if (!g_logFile.empty()) {
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
std::ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
if (!o.fail())
o << second_clock::local_time() << " MSG: " << msg;
}
@@ -92,7 +92,7 @@ internal_log_level(const std::string &msg, int logLevel)
{
if (g_logLevel >= logLevel) {
if (!g_logFile.empty()) {
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
std::ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
if (!o.fail())
o << second_clock::local_time() << " OUT: " << msg;
}
+76
View File
@@ -0,0 +1,76 @@
/*****************************************************************************
* 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/asyncdbadminplayers.h>
#include <dbofficial/dbidmanager.h>
using namespace std;
AsyncDBAdminPlayers::AsyncDBAdminPlayers(unsigned queryId, const string &preparedName)
: SingleAsyncDBQuery(queryId, preparedName, list<string>())
{
}
AsyncDBAdminPlayers::~AsyncDBAdminPlayers()
{
}
void
AsyncDBAdminPlayers::Init(DBIdManager& /*idManager*/)
{
}
void
AsyncDBAdminPlayers::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb)
{
list<DB_id> adminPlayers;
for (size_t i = 0; i < result.num_rows(); ++i) {
if (!result[i].empty()) {
adminPlayers.push_back(result[i][0]);
}
}
service.post(boost::bind(&ServerDBCallback::PlayerAdminList, &cb, GetId(), adminPlayers));
}
void
AsyncDBAdminPlayers::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
{
// This query should always produce a result.
HandleError(service, cb);
}
void
AsyncDBAdminPlayers::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
{
service.post(boost::bind(&ServerDBCallback::QueryError, &cb, "AsyncDBAdminPlayers: Failure."));
}
+57
View File
@@ -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 query for all admin players. */
#ifndef _ASYNCDBADMINPLAYERS_H_
#define _ASYNCDBADMINPLAYERS_H_
#include <dbofficial/singleasyncdbquery.h>
class AsyncDBAdminPlayers : public SingleAsyncDBQuery
{
public:
AsyncDBAdminPlayers(unsigned queryId, const std::string &preparedName);
virtual ~AsyncDBAdminPlayers();
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 true;
}
};
#endif
+84
View File
@@ -0,0 +1,84 @@
/*****************************************************************************
* 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 <boost/bind.hpp>
#include <dbofficial/asyncdbauth.h>
using namespace std;
AsyncDBAuth::AsyncDBAuth(unsigned queryId, const string &preparedName, const list<string> &params)
: SingleAsyncDBQuery(queryId, preparedName, params)
{
}
AsyncDBAuth::~AsyncDBAuth()
{
}
void
AsyncDBAuth::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb)
{
if (result.num_rows() != 1) {
service.post(boost::bind(&ServerDBCallback::PlayerLoginFailed, &cb, GetId()));
} else {
int blocked = result[0][2];
int active = result[0][5];
if ((active != 1) || (blocked != 0)) {
service.post(boost::bind(&ServerDBCallback::PlayerLoginBlocked, &cb, GetId()));
} else {
mysqlpp::String secret(result[0][1]);
mysqlpp::String country(result[0][3]);
mysqlpp::String last_login(result[0][4]);
boost::shared_ptr<DBPlayerData> tmpData(new DBPlayerData);
tmpData->id = result[0][0];
secret.to_string(tmpData->secret);
if (!country.is_null())
country.to_string(tmpData->country);
last_login.to_string(tmpData->last_login);
service.post(boost::bind(&ServerDBCallback::PlayerLoginSuccess, &cb, GetId(), tmpData));
}
}
}
void
AsyncDBAuth::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
{
HandleError(service, cb);
}
void
AsyncDBAuth::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
{
service.post(boost::bind(&ServerDBCallback::PlayerLoginFailed, &cb, GetId()));
}
+57
View File
@@ -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 auth query. */
#ifndef _ASYNCDBAUTH_H_
#define _ASYNCDBAUTH_H_
#include <dbofficial/singleasyncdbquery.h>
class AsyncDBAuth : public SingleAsyncDBQuery
{
public:
AsyncDBAuth(unsigned queryId, const std::string &preparedName, const std::list<std::string> &params);
virtual ~AsyncDBAuth();
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 true;
}
};
#endif
+68
View File
@@ -0,0 +1,68 @@
/*****************************************************************************
* 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 <boost/bind.hpp>
#include <dbofficial/asyncdbavatarblacklist.h>
using namespace std;
AsyncDBAvatarBlacklist::AsyncDBAvatarBlacklist(unsigned queryId, const string &preparedName, const list<string> &params)
: SingleAsyncDBQuery(queryId, preparedName, params)
{
}
AsyncDBAvatarBlacklist::~AsyncDBAvatarBlacklist()
{
}
void
AsyncDBAvatarBlacklist::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb)
{
if (result.num_rows() == 0)
service.post(boost::bind(&ServerDBCallback::AvatarIsOK, &cb, GetId()));
else
service.post(boost::bind(&ServerDBCallback::AvatarIsBlacklisted, &cb, GetId()));
}
void
AsyncDBAvatarBlacklist::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
{
HandleError(service, cb);
}
void
AsyncDBAvatarBlacklist::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
{
// If query failed: Avatar is blacklisted.
service.post(boost::bind(&ServerDBCallback::AvatarIsBlacklisted, &cb, GetId()));
}
+57
View File
@@ -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 avatar blacklist query. */
#ifndef _ASYNCDBAVATARBLACKLIST_H_
#define _ASYNCDBAVATARBLACKLIST_H_
#include <dbofficial/singleasyncdbquery.h>
class AsyncDBAvatarBlacklist : public SingleAsyncDBQuery
{
public:
AsyncDBAvatarBlacklist(unsigned queryId, const std::string &preparedName, const std::list<std::string> &params);
virtual ~AsyncDBAvatarBlacklist();
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 true;
}
};
#endif
+71
View File
@@ -0,0 +1,71 @@
/*****************************************************************************
* 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 <boost/bind.hpp>
#include <dbofficial/asyncdbblockplayer.h>
#include <dbofficial/dbidmanager.h>
using namespace std;
AsyncDBBlockPlayer::AsyncDBBlockPlayer(unsigned queryId, unsigned replyId, const string &preparedName, const list<string> &params)
: SingleAsyncDBQuery(queryId, preparedName, params), m_replyId(replyId)
{
}
AsyncDBBlockPlayer::~AsyncDBBlockPlayer()
{
}
void
AsyncDBBlockPlayer::Init(DBIdManager &/*idManager*/)
{
}
void
AsyncDBBlockPlayer::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
AsyncDBBlockPlayer::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager &/*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
{
service.post(boost::bind(&ServerDBCallback::BlockPlayerSuccess, &cb, GetId(), m_replyId));
}
void
AsyncDBBlockPlayer::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
{
service.post(boost::bind(&ServerDBCallback::BlockPlayerFailed, &cb, GetId(), m_replyId));
}
+60
View File
@@ -0,0 +1,60 @@
/*****************************************************************************
* 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 _ASYNCDBBLOCKPLAYER_H_
#define _ASYNCDBBLOCKPLAYER_H_
#include <dbofficial/singleasyncdbquery.h>
class AsyncDBBlockPlayer : public SingleAsyncDBQuery
{
public:
AsyncDBBlockPlayer(unsigned queryId, unsigned replyId, const std::string &preparedName, const std::list<std::string> &params);
virtual ~AsyncDBBlockPlayer();
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;
}
private:
unsigned m_replyId;
};
#endif
+76
View File
@@ -0,0 +1,76 @@
/*****************************************************************************
* 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 <boost/bind.hpp>
#include <dbofficial/asyncdbcreategame.h>
#include <dbofficial/dbidmanager.h>
using namespace std;
AsyncDBCreateGame::AsyncDBCreateGame(unsigned queryId, const string &preparedName, const list<string> &params)
: SingleAsyncDBQuery(queryId, preparedName, params)
{
}
AsyncDBCreateGame::~AsyncDBCreateGame()
{
}
void
AsyncDBCreateGame::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
AsyncDBCreateGame::HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb)
{
query.reset();
query
<< "SELECT LAST_INSERT_ID()";
mysqlpp::StoreQueryResult tmpResult = query.store();
DB_id insertId = tmpResult[0][0];
if (!tmpResult || tmpResult.num_rows() != 1 || insertId == 0) {
service.post(boost::bind(&ServerDBCallback::CreateGameFailed, &cb, GetId()));
} else {
service.post(boost::bind(&ServerDBCallback::CreateGameSuccess, &cb, GetId()));
idManager.AddGameId(GetId(), insertId);
}
}
void
AsyncDBCreateGame::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
{
service.post(boost::bind(&ServerDBCallback::CreateGameFailed, &cb, GetId()));
}
+57
View File
@@ -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 create game query. */
#ifndef _ASYNCDBCREATEGAME_H_
#define _ASYNCDBCREATEGAME_H_
#include <dbofficial/singleasyncdbquery.h>
class AsyncDBCreateGame : public SingleAsyncDBQuery
{
public:
AsyncDBCreateGame(unsigned queryId, const std::string &preparedName, const std::list<std::string> &params);
virtual ~AsyncDBCreateGame();
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
+77
View File
@@ -0,0 +1,77 @@
/*****************************************************************************
* 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/asyncdbendgame.h>
#include <dbofficial/dbidmanager.h>
using namespace std;
AsyncDBEndGame::AsyncDBEndGame(unsigned queryId, const string &preparedName, const std::list<std::string> &params)
: SingleAsyncDBQuery(queryId, preparedName, params)
{
}
AsyncDBEndGame::~AsyncDBEndGame()
{
}
void
AsyncDBEndGame::Init(DBIdManager& idManager)
{
std::list<std::string> params;
GetParams(params);
ostringstream paramStream;
paramStream << idManager.GetGameDBId(GetId());
// Add game id as last parameter (where-clause).
params.push_back(paramStream.str());
SetParams(params);
}
void
AsyncDBEndGame::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
AsyncDBEndGame::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
{
// Nothing to do.
}
void
AsyncDBEndGame::HandleError(boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
{
// Ignore errors for now (as nothing important is done).
}
+57
View File
@@ -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 end game query. */
#ifndef _ASYNCDBENDGAME_H_
#define _ASYNCDBENDGAME_H_
#include <dbofficial/singleasyncdbquery.h>
class AsyncDBEndGame : public SingleAsyncDBQuery
{
public:
AsyncDBEndGame(unsigned queryId, const std::string &preparedName, const std::list<std::string> &params);
virtual ~AsyncDBEndGame();
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
+78
View File
@@ -0,0 +1,78 @@
/*****************************************************************************
* 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 <boost/bind.hpp>
#include <dbofficial/asyncdbgameplace.h>
#include <dbofficial/dbidmanager.h>
using namespace std;
AsyncDBGamePlace::AsyncDBGamePlace(unsigned queryId, const string &preparedName, const list<string> &params)
: SingleAsyncDBQuery(queryId, preparedName, params)
{
}
AsyncDBGamePlace::~AsyncDBGamePlace()
{
}
void
AsyncDBGamePlace::Init(DBIdManager& idManager)
{
std::list<std::string> params;
GetParams(params);
ostringstream paramStream;
paramStream << idManager.GetGameDBId(GetId());
// Add game id as first parameter (according to the order in insert).
params.push_front(paramStream.str());
SetParams(params);
}
void
AsyncDBGamePlace::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
AsyncDBGamePlace::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
{
// No action required.
}
void
AsyncDBGamePlace::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
{
service.post(boost::bind(&ServerDBCallback::QueryError, &cb, "AsyncDBGamePlace: Failure."));
}
+57
View File
@@ -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 set place query. */
#ifndef _ASYNCDBGAMEPLACE_H_
#define _ASYNCDBGAMEPLACE_H_
#include <dbofficial/singleasyncdbquery.h>
class AsyncDBGamePlace : public SingleAsyncDBQuery
{
public:
AsyncDBGamePlace(unsigned queryId, const std::string &preparedName, const std::list<std::string> &params);
virtual ~AsyncDBGamePlace();
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
+65
View File
@@ -0,0 +1,65 @@
/*****************************************************************************
* 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 <boost/bind.hpp>
#include <dbofficial/asyncdblogin.h>
using namespace std;
AsyncDBLogin::AsyncDBLogin(unsigned queryId, const string &preparedName, const list<string> &params)
: SingleAsyncDBQuery(queryId, preparedName, params)
{
}
AsyncDBLogin::~AsyncDBLogin()
{
}
void
AsyncDBLogin::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
AsyncDBLogin::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
{
// No action required.
}
void
AsyncDBLogin::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
{
service.post(boost::bind(&ServerDBCallback::QueryError, &cb, "AsyncDBLogin: Failure."));
}
+57
View File
@@ -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 login query. */
#ifndef _ASYNCDBLOGIN_H_
#define _ASYNCDBLOGIN_H_
#include <dbofficial/singleasyncdbquery.h>
class AsyncDBLogin : public SingleAsyncDBQuery
{
public:
AsyncDBLogin(unsigned queryId, const std::string &preparedName, const std::list<std::string> &params);
virtual ~AsyncDBLogin();
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
+40
View File
@@ -0,0 +1,40 @@
/*****************************************************************************
* 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/asyncdbquery.h>
using namespace std;
AsyncDBQuery::~AsyncDBQuery()
{
}
+61
View File
@@ -0,0 +1,61 @@
/*****************************************************************************
* 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 query. */
#ifndef _ASYNCDBQUERY_H_
#define _ASYNCDBQUERY_H_
#include <boost/asio.hpp>
#include <list>
#include <mysql++.h>
#include <db/serverdbcallback.h>
class DBIdManager;
class AsyncDBQuery
{
public:
virtual ~AsyncDBQuery();
virtual void Init(DBIdManager& idManager) = 0;
virtual std::string GetPreparedName() const = 0;
virtual void GetParams(std::list<std::string> &params) const = 0;
virtual void SetParams(const std::list<std::string> &params) = 0;
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb) = 0;
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb) = 0;
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb) = 0;
virtual bool RequiresResultSet() const = 0;
virtual bool Next() = 0;
};
#endif
+65
View File
@@ -0,0 +1,65 @@
/*****************************************************************************
* 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 <boost/bind.hpp>
#include <dbofficial/asyncdbreportavatar.h>
using namespace std;
AsyncDBReportAvatar::AsyncDBReportAvatar(unsigned queryId, unsigned replyId, const string &preparedName, const list<string> &params)
: SingleAsyncDBQuery(queryId, preparedName, params), m_replyId(replyId)
{
}
AsyncDBReportAvatar::~AsyncDBReportAvatar()
{
}
void
AsyncDBReportAvatar::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
AsyncDBReportAvatar::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
{
service.post(boost::bind(&ServerDBCallback::ReportAvatarSuccess, &cb, GetId(), m_replyId));
}
void
AsyncDBReportAvatar::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
{
service.post(boost::bind(&ServerDBCallback::ReportAvatarFailed, &cb, GetId(), m_replyId));
}
+60
View File
@@ -0,0 +1,60 @@
/*****************************************************************************
* 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 report inappropriate avatar query. */
#ifndef _ASYNCDBREPORTAVATAR_H_
#define _ASYNCDBREPORTAVATAR_H_
#include <dbofficial/singleasyncdbquery.h>
class AsyncDBReportAvatar : public SingleAsyncDBQuery
{
public:
AsyncDBReportAvatar(unsigned queryId, unsigned replyId, const std::string &preparedName, const std::list<std::string> &params);
virtual ~AsyncDBReportAvatar();
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;
}
private:
unsigned m_replyId;
};
#endif
+83
View File
@@ -0,0 +1,83 @@
/*****************************************************************************
* 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 <boost/bind.hpp>
#include <dbofficial/asyncdbreportgame.h>
#include <dbofficial/dbidmanager.h>
using namespace std;
AsyncDBReportGame::AsyncDBReportGame(unsigned queryId, unsigned replyId, unsigned gameId, const string &preparedName, const list<string> &params)
: SingleAsyncDBQuery(queryId, preparedName, params), m_replyId(replyId), m_gameId(gameId)
{
}
AsyncDBReportGame::~AsyncDBReportGame()
{
}
void
AsyncDBReportGame::Init(DBIdManager& idManager)
{
std::list<std::string> params;
GetParams(params);
ostringstream paramStream;
unsigned tmpGameId = idManager.GetGameDBId(m_gameId);
if (tmpGameId) {
paramStream << idManager.GetGameDBId(m_gameId);
// Add game id as last parameter (where-clause).
params.push_back(paramStream.str());
} else {
params.push_back("NULL");
}
SetParams(params);
}
void
AsyncDBReportGame::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
AsyncDBReportGame::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
{
service.post(boost::bind(&ServerDBCallback::ReportGameSuccess, &cb, GetId(), m_replyId));
}
void
AsyncDBReportGame::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
{
service.post(boost::bind(&ServerDBCallback::ReportGameFailed, &cb, GetId(), m_replyId));
}
+61
View File
@@ -0,0 +1,61 @@
/*****************************************************************************
* 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 report inappropriate avatar query. */
#ifndef _ASYNCDBREPORTGAME_H_
#define _ASYNCDBREPORTGAME_H_
#include <dbofficial/singleasyncdbquery.h>
class AsyncDBReportGame : public SingleAsyncDBQuery
{
public:
AsyncDBReportGame(unsigned queryId, unsigned replyId, unsigned gameId, const std::string &preparedName, const std::list<std::string> &params);
virtual ~AsyncDBReportGame();
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;
}
private:
unsigned m_replyId;
unsigned m_gameId;
};
#endif
+80
View File
@@ -0,0 +1,80 @@
/*****************************************************************************
* 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/asyncdbupdatescore.h>
#include <dbofficial/dbidmanager.h>
using namespace std;
AsyncDBUpdateScore::AsyncDBUpdateScore(unsigned queryId, const string &preparedName, const std::list<std::string> &params)
: SingleAsyncDBQuery(queryId, preparedName, params)
{
}
AsyncDBUpdateScore::~AsyncDBUpdateScore()
{
}
void
AsyncDBUpdateScore::Init(DBIdManager& idManager)
{
std::list<std::string> params;
GetParams(params);
ostringstream paramStream;
paramStream << idManager.GetGameDBId(GetId());
// Add game id as first parameter (param for stored procedure).
params.push_front(paramStream.str());
SetParams(params);
// Ensure that "update score" is only called once for a game.
// This game id cannot be used any more, without re-init.
idManager.RemoveGameId(GetId());
}
void
AsyncDBUpdateScore::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
AsyncDBUpdateScore::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& idManager, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
{
idManager.RemoveGameId(GetId());
}
void
AsyncDBUpdateScore::HandleError(boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
{
// Ignore errors for now (as nothing important is done).
}
+57
View File
@@ -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 query to update the score. */
#ifndef _ASYNCDBUPDATESCORE_H_
#define _ASYNCDBUPDATESCORE_H_
#include <dbofficial/singleasyncdbquery.h>
class AsyncDBUpdateScore : public SingleAsyncDBQuery
{
public:
AsyncDBUpdateScore(unsigned queryId, const std::string &preparedName, const std::list<std::string> &params);
virtual ~AsyncDBUpdateScore();
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
+120
View File
@@ -0,0 +1,120 @@
/*****************************************************************************
* 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/compositeasyncdbquery.h>
using namespace std;
CompositeAsyncDBQuery::CompositeAsyncDBQuery(const AsyncQueryList &queries)
: m_list(queries), m_errorFlag(false), m_lastGameDBId(0)
{
m_currentQuery = m_list.begin();
}
CompositeAsyncDBQuery::~CompositeAsyncDBQuery()
{
}
void
CompositeAsyncDBQuery::Init(DBIdManager& idManager)
{
(*m_currentQuery)->Init(idManager);
}
std::string
CompositeAsyncDBQuery::GetPreparedName() const
{
return (*m_currentQuery)->GetPreparedName();
}
void
CompositeAsyncDBQuery::GetParams(std::list<std::string> &params) const
{
(*m_currentQuery)->GetParams(params);
}
void
CompositeAsyncDBQuery::SetParams(const std::list<std::string> &params)
{
(*m_currentQuery)->SetParams(params);
}
void
CompositeAsyncDBQuery::HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb)
{
(*m_currentQuery)->HandleResult(query, idManager, result, service, cb);
}
void
CompositeAsyncDBQuery::HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb)
{
(*m_currentQuery)->HandleNoResult(query, idManager, service, cb);
}
void
CompositeAsyncDBQuery::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
{
(*m_currentQuery)->HandleError(service, cb);
m_errorFlag = true;
}
bool
CompositeAsyncDBQuery::RequiresResultSet() const
{
return (*m_currentQuery)->RequiresResultSet();
}
bool
CompositeAsyncDBQuery::Next()
{
bool retVal = false;
AsyncQueryList::iterator pos = m_currentQuery;
++pos;
if (!m_errorFlag && pos != m_list.end()) {
m_currentQuery = pos;
retVal = true;
}
return retVal;
}
unsigned
CompositeAsyncDBQuery::GetLastGameDBId() const
{
return m_lastGameDBId;
}
void
CompositeAsyncDBQuery::SetLastGameDBId(unsigned id)
{
m_lastGameDBId = id;
}
+72
View File
@@ -0,0 +1,72 @@
/*****************************************************************************
* 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. *
*****************************************************************************/
/* Composite async database query. */
#ifndef _COMPOSITEASYNCDBQUERY_H_
#define _COMPOSITEASYNCDBQUERY_H_
#include <dbofficial/asyncdbquery.h>
#include <dbofficial/querycontext.h>
class CompositeAsyncDBQuery : public AsyncDBQuery, public QueryContext
{
public:
typedef std::list<boost::shared_ptr<AsyncDBQuery> > AsyncQueryList;
// Note: This list must contain at least one query.
CompositeAsyncDBQuery(const AsyncQueryList &queries);
virtual ~CompositeAsyncDBQuery();
virtual void Init(DBIdManager& idManager);
virtual std::string GetPreparedName() const;
virtual void GetParams(std::list<std::string> &params) const;
virtual void SetParams(const std::list<std::string> &params);
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);
// One error will cancel the rest of the composite query.
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
virtual bool RequiresResultSet() const;
virtual bool Next();
virtual unsigned GetLastGameDBId() const;
virtual void SetLastGameDBId(unsigned id);
private:
AsyncQueryList m_list;
AsyncQueryList::iterator m_currentQuery;
bool m_errorFlag;
unsigned m_lastGameDBId;
};
#endif
+78
View File
@@ -0,0 +1,78 @@
/*****************************************************************************
* 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. *
*****************************************************************************/
#ifndef _DB_TABLE_DEFS_H_
#define _DB_TABLE_DEFS_H_
#define DB_TABLE_PLAYER "player"
#define DB_TABLE_PLAYER_COL_ID "player_id"
#define DB_TABLE_PLAYER_COL_USERNAME "username"
#define DB_TABLE_PLAYER_COL_PASSWORD "password"
#define DB_TABLE_PLAYER_COL_VALID "blocked"
#define DB_TABLE_PLAYER_COL_COUNTRY "country_iso"
#define DB_TABLE_PLAYER_COL_LASTLOGIN "last_login"
#define DB_TABLE_PLAYER_COL_ACTIVE "active"
#define DB_TABLE_PLAYER_COL_AVATARHASH "avatar_hash"
#define DB_TABLE_PLAYER_COL_AVATARTYPE "avatar_mime"
#define DB_TABLE_GAME "game"
#define DB_TABLE_GAME_COL_ID "idgame"
#define DB_TABLE_GAME_COL_NAME "name"
#define DB_TABLE_GAME_COL_STARTTIME "start_time"
#define DB_TABLE_GAME_COL_ENDTIME "end_time"
#define DB_TABLE_GAMEPLAYER "game_has_player"
#define DB_TABLE_GAMEPLAYER_COL_GAMEID "game_idgame"
#define DB_TABLE_GAMEPLAYER_COL_PLAYERID "player_idplayer"
#define DB_TABLE_GAMEPLAYER_COL_PLACE "place"
#define DB_TABLE_REP_AVATAR "reported_avatar"
#define DB_TABLE_REP_AVATAR_COL_PLAYERID "idplayer"
#define DB_TABLE_REP_AVATAR_COL_AVATARHASH "avatar_hash"
#define DB_TABLE_REP_AVATAR_COL_AVATARTYPE "avatar_type"
#define DB_TABLE_REP_AVATAR_COL_BY_PLAYERID "by_idplayer"
#define DB_TABLE_REP_AVATAR_COL_TIMESTAMP "timestamp"
#define DB_TABLE_REP_GAME "reported_gamename"
#define DB_TABLE_REP_GAME_COL_CREATOR "game_creator_idplayer"
#define DB_TABLE_REP_GAME_COL_GAMEID "game_idgame"
#define DB_TABLE_REP_GAME_COL_GAMENAME "game_name"
#define DB_TABLE_REP_GAME_COL_BY_PLAYERID "by_idplayer"
#define DB_TABLE_REP_GAME_COL_TIMESTAMP "timestamp"
#define DB_TABLE_AVATAR_BLACKLIST "avatar_blacklist"
#define DB_TABLE_AVATAR_BLACKLIST_COL_ID "id"
#define DB_TABLE_AVATAR_BLACKLIST_COL_AVATAR_HASH "avatar_hash"
#define DB_TABLE_ADMIN_PLAYER "admin_player"
#define DB_TABLE_ADMIN_PLAYER_COL_PLAYERID "admin_idplayer"
#endif // DB_TABLE_DEFS_H
+61
View File
@@ -0,0 +1,61 @@
/*****************************************************************************
* 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/dbidmanager.h>
void
DBIdManager::AddGameId(unsigned gameId, DB_id databaseId)
{
boost::mutex::scoped_lock lock(m_gameIdMapMutex);
m_gameIdMap[gameId] = databaseId;
}
void
DBIdManager::RemoveGameId(unsigned gameId)
{
boost::mutex::scoped_lock lock(m_gameIdMapMutex);
m_gameIdMap.erase(gameId);
}
DB_id
DBIdManager::GetGameDBId(unsigned gameId) const
{
DB_id retVal = DB_ID_INVALID;
boost::mutex::scoped_lock lock(m_gameIdMapMutex);
DBMap::const_iterator pos = m_gameIdMap.find(gameId);
if (pos != m_gameIdMap.end()) {
retVal = pos->second;
}
return retVal;
}
+56
View File
@@ -0,0 +1,56 @@
/*****************************************************************************
* 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. *
*****************************************************************************/
/* Manager for database internal ids */
#ifndef _DBIDMANAGER_H_
#define _DBIDMANAGER_H_
#include <db/dbdefs.h>
#include <boost/thread.hpp>
#include <map>
class DBIdManager
{
public:
void AddGameId(unsigned gameId, DB_id databaseId);
void RemoveGameId(unsigned gameId);
DB_id GetGameDBId(unsigned gameId) const;
protected:
typedef std::map<unsigned, DB_id> DBMap;
private:
DBMap m_gameIdMap;
mutable boost::mutex m_gameIdMapMutex;
};
#endif // _DBIDMANAGER_H_
+36
View File
@@ -0,0 +1,36 @@
/*****************************************************************************
* 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/querycontext.h>
QueryContext::~QueryContext()
{
}
+45
View File
@@ -0,0 +1,45 @@
/*****************************************************************************
* 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. *
*****************************************************************************/
/* Interface for a query context */
#ifndef _QUERYCONTEXT_H_
#define _QUERYCONTEXT_H_
class QueryContext
{
public:
virtual ~QueryContext();
virtual unsigned GetLastGameDBId() const = 0;
virtual void SetLastGameDBId(unsigned id) = 0;
};
#endif // QUERYCONTEXT_H
@@ -0,0 +1,48 @@
/*****************************************************************************
* 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/serverdbfactoryinternal.h>
#include <dbofficial/serverdbthread.h>
ServerDBFactoryInternal::ServerDBFactoryInternal()
{
}
ServerDBFactoryInternal::~ServerDBFactoryInternal()
{
}
boost::shared_ptr<ServerDBInterface>
ServerDBFactoryInternal::CreateServerDBObject(ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService)
{
return boost::shared_ptr<ServerDBInterface>(new ServerDBThread(cb, ioService));
}
+53
View File
@@ -0,0 +1,53 @@
/*****************************************************************************
* 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. *
*****************************************************************************/
/* Server database factory for closed source db objects. */
#ifndef _SERVERDBFACTORYINTERNAL_H_
#define _SERVERDBFACTORYINTERNAL_H_
#include <boost/asio.hpp>
#include <boost/shared_ptr.hpp>
#include <db/serverdbinterface.h>
#include <db/serverdbcallback.h>
class ServerDBFactoryInternal
{
public:
ServerDBFactoryInternal();
virtual ~ServerDBFactoryInternal();
virtual boost::shared_ptr<ServerDBInterface> CreateServerDBObject(
ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService);
};
typedef ServerDBFactoryInternal DBFactory;
#endif
+567
View File
@@ -0,0 +1,567 @@
/*****************************************************************************
* 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/serverdbthread.h>
#include <dbofficial/asyncdbauth.h>
#include <dbofficial/asyncdblogin.h>
#include <dbofficial/asyncdbavatarblacklist.h>
#include <dbofficial/asyncdbcreategame.h>
#include <dbofficial/asyncdbendgame.h>
#include <dbofficial/asyncdbgameplace.h>
#include <dbofficial/asyncdbupdatescore.h>
#include <dbofficial/asyncdbreportavatar.h>
#include <dbofficial/asyncdbreportgame.h>
#include <dbofficial/asyncdbadminplayers.h>
#include <dbofficial/asyncdbblockplayer.h>
#include <dbofficial/compositeasyncdbquery.h>
#include <dbofficial/db_table_defs.h>
#include <ctime>
#include <sstream>
#include <mysql++.h>
#define QUERY_NICK_PREPARE "nick_template"
#define QUERY_LOGIN_PREPARE "login_template"
#define QUERY_AVATAR_BLACKLIST_PREPARE "avatar_blacklist_template"
#define QUERY_CREATE_GAME_PREPARE "create_game_template"
#define QUERY_END_GAME_PREPARE "end_game_template"
#define QUERY_GAME_PLAYER_PREPARE "game_player_template"
#define QUERY_UPDATE_SCORE_PREPARE "update_score_template"
#define QUERY_REPORT_AVATAR_PREPARE "report_avatar_template"
#define QUERY_REPORT_GAME_PREPARE "report_game_template"
#define QUERY_ADMIN_PLAYER_PREPARE "admin_player_template"
#define QUERY_BLOCK_PLAYER_PREPARE "block_player_template"
using namespace std;
struct DBConnectionData {
DBConnectionData() : conn(false) {}
string host;
string user;
string pwd;
string database;
string encryptionKey;
mysqlpp::Connection conn;
};
ServerDBThread::ServerDBThread(ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService)
: m_ioService(ioService), m_semaphore(0), m_callback(cb), m_isConnected(false), m_permanentError(false), m_previouslyConnected(false)
{
m_connData.reset(new DBConnectionData);
}
ServerDBThread::~ServerDBThread()
{
}
void
ServerDBThread::SignalTermination()
{
Thread::SignalTermination();
m_semaphore.post();
}
void
ServerDBThread::Init(const string &host, const string &user, const string &pwd,
const string &database, const string &encryptionKey)
{
m_connData->host = host;
m_connData->user = user;
m_connData->pwd = pwd;
m_connData->database = database;
m_connData->encryptionKey = encryptionKey;
}
void
ServerDBThread::Start()
{
Run();
}
void
ServerDBThread::Stop()
{
SignalTermination();
this->Join(THREAD_WAIT_INFINITE);
}
void
ServerDBThread::AsyncPlayerLogin(unsigned requestId, const string &playerName)
{
if (IsConnected()) {
list<string> params;
params.push_back(m_connData->encryptionKey);
params.push_back(playerName);
boost::shared_ptr<AsyncDBQuery> asyncQuery(
new AsyncDBAuth(
requestId,
QUERY_NICK_PREPARE,
params));
{
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
m_asyncQueue.push(asyncQuery);
}
m_semaphore.post();
} else {
// If not connected to database, login fails.
m_ioService->post(boost::bind(&ServerDBCallback::PlayerLoginFailed, &m_callback, requestId));
}
}
void
ServerDBThread::AsyncCheckAvatarBlacklist(unsigned requestId, const std::string &avatarHash)
{
if (IsConnected()) {
list<string> params;
params.push_back(avatarHash);
boost::shared_ptr<AsyncDBQuery> asyncQuery(
new AsyncDBAvatarBlacklist(
requestId,
QUERY_AVATAR_BLACKLIST_PREPARE,
params));
{
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
m_asyncQueue.push(asyncQuery);
}
m_semaphore.post();
} else {
// If not connected to database, all avatars are blacklisted.
m_ioService->post(boost::bind(&ServerDBCallback::AvatarIsBlacklisted, &m_callback, requestId));
}
}
void
ServerDBThread::PlayerPostLogin(DB_id playerId, const std::string &avatarHash, const std::string &avatarType)
{
list<string> params;
params.push_back(mysqlpp::DateTime(time(NULL)));
params.push_back(avatarHash);
params.push_back(avatarType);
ostringstream paramStream;
paramStream << playerId;
params.push_back(paramStream.str());
boost::shared_ptr<AsyncDBQuery> asyncQuery(
new AsyncDBLogin(
playerId,
QUERY_LOGIN_PREPARE,
params));
{
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
m_asyncQueue.push(asyncQuery);
}
m_semaphore.post();
}
void
ServerDBThread::PlayerLogout(DB_id /*playerId*/)
{
}
void
ServerDBThread::AsyncCreateGame(unsigned requestId, const string &gameName)
{
list<string> params;
params.push_back(gameName);
params.push_back(mysqlpp::DateTime(time(NULL)));
boost::shared_ptr<AsyncDBQuery> asyncQuery(
new AsyncDBCreateGame(
requestId,
QUERY_CREATE_GAME_PREPARE,
params));
{
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
m_asyncQueue.push(asyncQuery);
}
m_semaphore.post();
}
void
ServerDBThread::SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place)
{
// The game id param is added later (during init of the async op), because it may be unknown.
list<string> params;
ostringstream paramStream;
paramStream << playerId;
params.push_back(paramStream.str());
paramStream.str("");
paramStream << place;
params.push_back(paramStream.str());
boost::shared_ptr<AsyncDBQuery> asyncQuery(
new AsyncDBGamePlace(
requestId,
QUERY_GAME_PLAYER_PREPARE,
params));
{
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
m_asyncQueue.push(asyncQuery);
}
m_semaphore.post();
}
void
ServerDBThread::EndGame(unsigned requestId)
{
// Set the end time of the game.
{
list<string> params;
params.push_back(mysqlpp::DateTime(time(NULL)));
boost::shared_ptr<AsyncDBQuery> asyncQuery(
new AsyncDBEndGame(
requestId,
QUERY_END_GAME_PREPARE,
params));
{
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
m_asyncQueue.push(asyncQuery);
}
m_semaphore.post();
}
// Update the player scores.
{
list<string> params;
boost::shared_ptr<AsyncDBQuery> asyncQuery(
new AsyncDBUpdateScore(
requestId,
QUERY_UPDATE_SCORE_PREPARE,
params));
{
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
m_asyncQueue.push(asyncQuery);
}
m_semaphore.post();
}
}
void
ServerDBThread::AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId)
{
list<string> params;
ostringstream paramStream;
paramStream << reportedPlayerId;
params.push_back(paramStream.str());
params.push_back(avatarHash);
params.push_back(avatarType);
if (byPlayerId) {
paramStream.str("");
paramStream << *byPlayerId;
params.push_back(paramStream.str());
} else {
params.push_back("NULL");
}
params.push_back(mysqlpp::DateTime(time(NULL)));
boost::shared_ptr<AsyncDBQuery> asyncQuery(
new AsyncDBReportAvatar(
requestId,
replyId,
QUERY_REPORT_AVATAR_PREPARE,
params));
{
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
m_asyncQueue.push(asyncQuery);
}
m_semaphore.post();
}
void
ServerDBThread::AsyncReportGame(unsigned requestId, unsigned replyId, DB_id *creatorPlayerId, unsigned gameId, const std::string &gameName, DB_id *byPlayerId)
{
list<string> params;
ostringstream paramStream;
if (creatorPlayerId) {
paramStream << *creatorPlayerId;
params.push_back(paramStream.str());
} else {
params.push_back("NULL");
}
params.push_back(gameName);
if (byPlayerId) {
paramStream.str("");
paramStream << *byPlayerId;
params.push_back(paramStream.str());
} else {
params.push_back("NULL");
}
params.push_back(mysqlpp::DateTime(time(NULL)));
boost::shared_ptr<AsyncDBQuery> asyncQuery(
new AsyncDBReportGame(
requestId,
replyId,
gameId,
QUERY_REPORT_GAME_PREPARE,
params));
{
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
m_asyncQueue.push(asyncQuery);
}
m_semaphore.post();
}
void
ServerDBThread::AsyncQueryAdminPlayers(unsigned requestId)
{
boost::shared_ptr<AsyncDBQuery> asyncQuery(
new AsyncDBAdminPlayers(
requestId,
QUERY_ADMIN_PLAYER_PREPARE));
{
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
m_asyncQueue.push(asyncQuery);
}
m_semaphore.post();
}
void
ServerDBThread::AsyncBlockPlayer(unsigned requestId, unsigned replyId, DB_id playerId, int valid, int active)
{
list<string> params;
ostringstream paramStream;
paramStream << valid;
params.push_back(paramStream.str());
paramStream.str("");
paramStream << active;
params.push_back(paramStream.str());
paramStream.str("");
paramStream << playerId;
params.push_back(paramStream.str());
boost::shared_ptr<AsyncDBQuery> asyncQuery(
new AsyncDBBlockPlayer(
requestId,
replyId,
QUERY_BLOCK_PLAYER_PREPARE,
params));
{
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
m_asyncQueue.push(asyncQuery);
}
m_semaphore.post();
}
bool
ServerDBThread::IsConnected() const
{
boost::mutex::scoped_lock lock(m_isConnectedMutex);
return m_isConnected;
}
void
ServerDBThread::Main()
{
while (!ShouldTerminate() && !HasPermanentError()) {
if (HasDBConnection()) {
SetConnected(true);
m_semaphore.wait();
HandleNextQuery();
} else {
SetConnected(false);
EstablishDBConnection();
}
}
m_connData->conn.disconnect();
}
bool
ServerDBThread::HasPermanentError() const
{
return m_permanentError;
}
bool
ServerDBThread::HasDBConnection() const
{
return m_connData->conn.connected();
}
void
ServerDBThread::EstablishDBConnection()
{
m_connData->conn.set_option(new mysqlpp::SetCharsetNameOption("utf8"));
if (!m_connData->conn.connect(
m_connData->database.c_str(), m_connData->host.c_str(), m_connData->user.c_str(), m_connData->pwd.c_str())) {
m_ioService->post(boost::bind(&ServerDBCallback::ConnectFailed, &m_callback, m_connData->conn.error()));
if (!m_previouslyConnected)
m_permanentError = true;
else
Msleep(250);
} else {
mysqlpp::Query prepareNick = m_connData->conn.query();
/*
prepareNick
<< "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 BINARY " DB_TABLE_PLAYER_COL_USERNAME " = ?";
*/
prepareNick
<< "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 " = ?";
mysqlpp::Query prepareAvatarBlacklist = m_connData->conn.query();
prepareAvatarBlacklist
<< "PREPARE " QUERY_AVATAR_BLACKLIST_PREPARE " FROM " << mysqlpp::quote
<< "SELECT " DB_TABLE_AVATAR_BLACKLIST_COL_ID " FROM " DB_TABLE_AVATAR_BLACKLIST " WHERE BINARY " DB_TABLE_AVATAR_BLACKLIST_COL_AVATAR_HASH " = ?";
mysqlpp::Query prepareLogin = m_connData->conn.query();
prepareLogin
<< "PREPARE " QUERY_LOGIN_PREPARE " FROM " << mysqlpp::quote
<< "UPDATE " DB_TABLE_PLAYER " SET " DB_TABLE_PLAYER_COL_LASTLOGIN " = ?, " DB_TABLE_PLAYER_COL_AVATARHASH " = ?, " DB_TABLE_PLAYER_COL_AVATARTYPE " = ? WHERE " DB_TABLE_PLAYER_COL_ID " = ?";
mysqlpp::Query prepareCreateGame = m_connData->conn.query();
prepareCreateGame
<< "PREPARE " QUERY_CREATE_GAME_PREPARE " FROM " << mysqlpp::quote
<< "INSERT INTO " DB_TABLE_GAME " (" DB_TABLE_GAME_COL_NAME ", " DB_TABLE_GAME_COL_STARTTIME ") VALUES (?, ?)";
mysqlpp::Query prepareEndGame = m_connData->conn.query();
prepareEndGame
<< "PREPARE " QUERY_END_GAME_PREPARE " FROM " << mysqlpp::quote
<< "UPDATE " DB_TABLE_GAME " SET "DB_TABLE_GAME_COL_ENDTIME " = ? WHERE " DB_TABLE_GAME_COL_ID " = ?";
mysqlpp::Query prepareRelation = m_connData->conn.query();
prepareRelation
<< "PREPARE " QUERY_GAME_PLAYER_PREPARE " FROM " << mysqlpp::quote
<< "INSERT INTO " DB_TABLE_GAMEPLAYER " (" DB_TABLE_GAMEPLAYER_COL_GAMEID ", " DB_TABLE_GAMEPLAYER_COL_PLAYERID ", " DB_TABLE_GAMEPLAYER_COL_PLACE ") VALUES (?, ?, ?)";
mysqlpp::Query prepareScore = m_connData->conn.query();
prepareScore
<< "PREPARE " QUERY_UPDATE_SCORE_PREPARE " FROM " << mysqlpp::quote
<< "CALL updatePointsForGame(?)";
mysqlpp::Query prepareReportAvatar = m_connData->conn.query();
prepareReportAvatar
<< "PREPARE " QUERY_REPORT_AVATAR_PREPARE " FROM " << mysqlpp::quote
<< "INSERT INTO " DB_TABLE_REP_AVATAR " (" DB_TABLE_REP_AVATAR_COL_PLAYERID ", " DB_TABLE_REP_AVATAR_COL_AVATARHASH ", " DB_TABLE_REP_AVATAR_COL_AVATARTYPE ", " DB_TABLE_REP_AVATAR_COL_BY_PLAYERID ", " DB_TABLE_REP_AVATAR_COL_TIMESTAMP ") VALUES (?, ?, ?, ?, ?)";
mysqlpp::Query prepareReportGame = m_connData->conn.query();
prepareReportGame
<< "PREPARE " QUERY_REPORT_GAME_PREPARE " FROM " << mysqlpp::quote
<< "INSERT INTO " DB_TABLE_REP_GAME " (" DB_TABLE_REP_GAME_COL_CREATOR ", " DB_TABLE_REP_GAME_COL_GAMENAME ", " DB_TABLE_REP_GAME_COL_BY_PLAYERID ", " DB_TABLE_REP_GAME_COL_TIMESTAMP ", " DB_TABLE_REP_GAME_COL_GAMEID ") VALUES (?, ?, ?, ?, ?)";
mysqlpp::Query prepareAdminPlayer = m_connData->conn.query();
prepareAdminPlayer
<< "PREPARE " QUERY_ADMIN_PLAYER_PREPARE " FROM " << mysqlpp::quote
<< "SELECT " DB_TABLE_ADMIN_PLAYER_COL_PLAYERID " FROM " DB_TABLE_ADMIN_PLAYER;
mysqlpp::Query prepareBlockPlayer = m_connData->conn.query();
prepareBlockPlayer
<< "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 " = ?";
if (!prepareNick.exec() || !prepareAvatarBlacklist.exec() || !prepareLogin.exec() || !prepareCreateGame.exec()
|| !prepareEndGame.exec() || !prepareRelation.exec() || !prepareScore.exec() || !prepareReportAvatar.exec()
|| !prepareReportGame.exec() || !prepareAdminPlayer.exec() || !prepareBlockPlayer.exec()) {
m_connData->conn.disconnect();
m_ioService->post(boost::bind(&ServerDBCallback::ConnectFailed, &m_callback,
string(prepareNick.error()) + prepareAvatarBlacklist.error() + prepareLogin.error() + prepareCreateGame.error()
+ prepareEndGame.error() + prepareRelation.error() + prepareScore.error() + prepareReportAvatar.error()
+ prepareReportGame.error() + prepareAdminPlayer.error() + prepareBlockPlayer.error()));
m_permanentError = true;
} else {
m_ioService->post(boost::bind(&ServerDBCallback::ConnectSuccess, &m_callback));
m_previouslyConnected = true;
}
}
}
void
ServerDBThread::HandleNextQuery()
{
boost::shared_ptr<AsyncDBQuery> nextQuery;
{
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
if (!m_asyncQueue.empty()) {
nextQuery = m_asyncQueue.front();
m_asyncQueue.pop();
}
}
if (nextQuery) {
do {
nextQuery->Init(m_dbIdManager);
mysqlpp::Query executeQuery = m_connData->conn.query();
executeQuery << "EXECUTE " << nextQuery->GetPreparedName();
list<string> paramList;
nextQuery->GetParams(paramList);
if (!paramList.empty()) {
executeQuery << " using ";
mysqlpp::Query paramQuery = m_connData->conn.query();
paramQuery << "SET ";
unsigned counter = 1;
list<string>::iterator i = paramList.begin();
list<string>::iterator end = paramList.end();
while (i != end) {
if (counter > 1) {
paramQuery << ", ";
executeQuery << ", ";
}
paramQuery << "@param" << counter << " = ";
if (*i == "NULL") {
paramQuery << "NULL";
} else {
paramQuery << "_utf8" << mysqlpp::quote << *i;
}
executeQuery << "@param" << counter;
++counter;
++i;
}
if (!paramQuery.exec()) {
m_connData->conn.disconnect();
m_ioService->post(boost::bind(&ServerDBCallback::QueryError, &m_callback, paramQuery.error()));
break;
}
}
if (nextQuery->RequiresResultSet()) {
mysqlpp::StoreQueryResult res = executeQuery.store();
if (res)
nextQuery->HandleResult(executeQuery, m_dbIdManager, res, *m_ioService, m_callback);
else
nextQuery->HandleError(*m_ioService, m_callback);
} else {
if (executeQuery.exec())
nextQuery->HandleNoResult(executeQuery, m_dbIdManager, *m_ioService, m_callback);
else
nextQuery->HandleError(*m_ioService, m_callback);
}
} while (nextQuery->Next()); // Consider composite queries.
}
}
void
ServerDBThread::SetConnected(bool isConnected)
{
boost::mutex::scoped_lock lock(m_isConnectedMutex);
m_isConnected = isConnected;
}
+107
View File
@@ -0,0 +1,107 @@
/*****************************************************************************
* 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. *
*****************************************************************************/
/* Server database thread. */
#ifndef _SERVERDBTHREAD_H_
#define _SERVERDBTHREAD_H_
#include <boost/asio.hpp>
#include <boost/interprocess/sync/interprocess_semaphore.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <queue>
#include <db/serverdbinterface.h>
#include <db/serverdbcallback.h>
#include <dbofficial/dbidmanager.h>
#include <core/thread.h>
struct DBConnectionData;
class AsyncDBQuery;
class ServerDBThread : public ServerDBInterface, public Thread, public boost::enable_shared_from_this<ServerDBThread>
{
public:
ServerDBThread(ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService);
virtual ~ServerDBThread();
virtual void SignalTermination();
virtual void Init(const std::string &host, const std::string &user, const std::string &pwd,
const std::string &database, const std::string &encryptionKey);
virtual void Start();
virtual void Stop();
virtual void AsyncPlayerLogin(unsigned requestId, const std::string &playerName);
virtual void AsyncCheckAvatarBlacklist(unsigned requestId, const std::string &avatarHash);
virtual void PlayerPostLogin(DB_id playerId, const std::string &avatarHash, const std::string &avatarType);
virtual void PlayerLogout(DB_id playerId);
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName);
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place);
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 AsyncReportGame(unsigned requestId, unsigned replyId, DB_id *creatorPlayerId, unsigned gameId, const std::string &gameName, DB_id *byPlayerId);
virtual void AsyncQueryAdminPlayers(unsigned requestId);
virtual void AsyncBlockPlayer(unsigned requestId, unsigned replyId, DB_id playerId, int valid, int active);
bool IsConnected() const;
protected:
typedef std::queue<boost::shared_ptr<AsyncDBQuery> > AsyncDBQueryQueue;
// Main function of the thread.
virtual void Main();
bool HasPermanentError() const;
bool HasDBConnection() const;
void EstablishDBConnection();
void HandleNextQuery();
void SetConnected(bool isConnected);
private:
boost::shared_ptr<boost::asio::io_service> m_ioService;
boost::interprocess::interprocess_semaphore m_semaphore;
ServerDBCallback &m_callback;
boost::shared_ptr<DBConnectionData> m_connData;
mutable boost::mutex m_asyncQueueMutex;
AsyncDBQueryQueue m_asyncQueue;
DBIdManager m_dbIdManager;
mutable boost::mutex m_isConnectedMutex;
bool m_isConnected;
bool m_permanentError;
bool m_previouslyConnected;
};
#endif
+69
View File
@@ -0,0 +1,69 @@
/*****************************************************************************
* 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/singleasyncdbquery.h>
using namespace std;
SingleAsyncDBQuery::SingleAsyncDBQuery(unsigned queryId, const string &preparedName, const list<string> &params)
: m_id(queryId), m_preparedName(preparedName), m_params(params)
{
}
SingleAsyncDBQuery::~SingleAsyncDBQuery()
{
}
unsigned
SingleAsyncDBQuery::GetId() const
{
return m_id;
}
std::string
SingleAsyncDBQuery::GetPreparedName() const
{
return m_preparedName;
}
void
SingleAsyncDBQuery::GetParams(std::list<std::string> &params) const
{
params = m_params;
}
void
SingleAsyncDBQuery::SetParams(const std::list<std::string> &params)
{
m_params = params;
}
+61
View File
@@ -0,0 +1,61 @@
/*****************************************************************************
* 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. *
*****************************************************************************/
/* Single (non-composite) async database query. */
#ifndef _SINGLEASYNCDBQUERY_H_
#define _SINGLEASYNCDBQUERY_H_
#include <dbofficial/asyncdbquery.h>
class SingleAsyncDBQuery : public AsyncDBQuery
{
public:
SingleAsyncDBQuery(unsigned queryId, const std::string &preparedName, const std::list<std::string> &params);
virtual ~SingleAsyncDBQuery();
unsigned GetId() const;
virtual std::string GetPreparedName() const;
virtual void GetParams(std::list<std::string> &params) const;
virtual void SetParams(const std::list<std::string> &params);
virtual bool Next()
{
return false;
}
private:
const unsigned m_id;
std::string m_preparedName;
std::list<std::string> m_params;
};
#endif
+2 -2
View File
@@ -302,8 +302,8 @@ ClientStateReadingServerList::Enter(boost::shared_ptr<ClientThread> client)
// Unzip the file using zlib.
try {
ifstream inFile(zippedServerListPath.directory_string().c_str(), ios_base::in | ios_base::binary);
ofstream outFile(xmlServerListPath.directory_string().c_str(), ios_base::out | ios_base::trunc);
std::ifstream inFile(zippedServerListPath.directory_string().c_str(), ios_base::in | ios_base::binary);
std::ofstream outFile(xmlServerListPath.directory_string().c_str(), ios_base::out | ios_base::trunc);
boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
in.push(boost::iostreams::zlib_decompressor());
in.push(inFile);
+2 -2
View File
@@ -1604,7 +1604,7 @@ void
ClientThread::ReadSessionGuidFromFile()
{
string guidFileName(GetContext().GetCacheDir() + TEMP_GUID_FILENAME);
ifstream guidStream(guidFileName.c_str(), ios::in | ios::binary);
std::ifstream guidStream(guidFileName.c_str(), ios::in | ios::binary);
if (guidStream.good()) {
std::vector<char> tmpGuid(CLIENT_GUID_SIZE);
guidStream.read(&tmpGuid[0], CLIENT_GUID_SIZE);
@@ -1616,7 +1616,7 @@ void
ClientThread::WriteSessionGuidToFile() const
{
string guidFileName(GetContext().GetCacheDir() + TEMP_GUID_FILENAME);
ofstream guidStream(guidFileName.c_str(), ios::out | ios::trunc | ios::binary);
std::ofstream guidStream(guidFileName.c_str(), ios::out | ios::trunc | ios::binary);
if (guidStream.good()) {
guidStream.write(GetContext().GetSessionGuid().c_str(), GetContext().GetSessionGuid().size());
}
+1 -1
View File
@@ -96,7 +96,7 @@ DownloaderThread::Main()
// Previous download was finished.
if (m_curDownloadData) {
path filepath(m_curDownloadData->filename);
ifstream instream(filepath.file_string().c_str(), ios_base::in | ios_base::binary);
std::ifstream instream(filepath.file_string().c_str(), ios_base::in | ios_base::binary);
// Find out file size.
// Not fully portable, but works on win/linux/mac.
instream.seekg(0, ios_base::beg);
+8
View File
@@ -32,14 +32,22 @@
#include <net/socket_helper.h>
#include <net/ircthread.h>
#include <net/socket_msg.h>
#ifdef _WIN32
#include <libircclient/libircclient.h>
#else
#include <libircclient.h>
#endif
// We need to do the following to handle different versions of libircclient.
// Sadly, libircclient doesn't have actual definitions for its versions in its headers.
// However, we can use a definition that appeared in the same version we need
// to check for. Hacky, but hey, it works.
#ifdef LIBIRC_OPTION_SSL_NO_VERIFY
#ifdef _WIN32
#include <libircclient/libirc_rfcnumeric.h>
#else
#include <libirc_rfcnumeric.h>
#endif
#endif
#include <boost/algorithm/string/predicate.hpp>
+23
View File
@@ -457,6 +457,7 @@ ServerGame::InternalEndGame()
{
StoreAndResetRanking();
m_game.reset();
m_numJoinsPerPlayer.clear();
}
void
@@ -1164,3 +1165,25 @@ ServerGame::GetNextGameNum()
return m_gameNum++;
}
void
ServerGame::AddPlayerToNumJoinsPerPlayer(const std::string &playerName)
{
NumJoinsPerPlayerMap::iterator pos = m_numJoinsPerPlayer.find(playerName);
if (pos != m_numJoinsPerPlayer.end())
{
pos->second++;
} else {
m_numJoinsPerPlayer[playerName] = 1;
}
}
int
ServerGame::GetNumJoinsPerPlayer(const std::string &playerName)
{
int num = 0;
NumJoinsPerPlayerMap::const_iterator pos = m_numJoinsPerPlayer.find(playerName);
if (pos != m_numJoinsPerPlayer.end()) {
num = pos->second;
}
return num;
}
+7 -2
View File
@@ -84,6 +84,8 @@ using namespace std;
#define SERVER_LOOP_DELAY_MSEC 50
#define SERVER_MAX_NUM_SPECTATORS_PER_GAME 100
#define GAME_MAX_NUM_JOINS_PER_PLAYER 6
// Helper functions
static void SendPlayerAction(ServerGame &server, boost::shared_ptr<PlayerInterface> player)
@@ -537,10 +539,13 @@ ServerGameStateInit::HandleNewPlayer(boost::shared_ptr<ServerGame> server, boost
{
if (session && session->GetPlayerData()) {
const GameData &tmpGameData = server->GetGameData();
// Check the number of players.
if (server->GetCurNumberOfPlayers() >= tmpGameData.maxNumberOfPlayers) {
// Check the number of players and number of joins per player
if (server->GetCurNumberOfPlayers() >= tmpGameData.maxNumberOfPlayers || server->GetNumJoinsPerPlayer(session->GetPlayerData()->GetName()) > GAME_MAX_NUM_JOINS_PER_PLAYER) {
server->MoveSessionToLobby(session, NTF_NET_REMOVED_GAME_FULL);
} else {
// add player to NumJoinsPerPlayerMap
server->AddPlayerToNumJoinsPerPlayer(session->GetPlayerData()->GetName());
AcceptNewSession(server, session, false);
+14 -3
View File
@@ -41,7 +41,7 @@
#include <net/net_helper.h>
#include <db/serverdbinterface.h>
#ifdef POKERTH_OFFICIAL_SERVER
#include <dbclosed/serverdbfactoryinternal.h>
#include <dbofficial/serverdbfactoryinternal.h>
#else
#include <db/serverdbfactorygeneric.h>
#endif
@@ -395,8 +395,9 @@ ServerLobbyThread::CloseSession(boost::shared_ptr<SessionData> session)
m_sessionManager.RemoveSession(session->GetId());
m_gameSessionManager.RemoveSession(session->GetId());
if (session->GetPlayerData())
if (session->GetPlayerData()) {
NotifyPlayerLeftLobby(session->GetPlayerData()->GetUniqueId());
}
// Update stats (if needed).
UpdateStatisticsNumberOfPlayers();
@@ -1047,6 +1048,8 @@ ServerLobbyThread::HandleNetPacketInit(boost::shared_ptr<SessionData> session, c
MD5Buf avatarMD5;
bool noAuth = false;
bool validGuest = false;
// productive: if (initMessage.login() == InitMessage::guestLogin) {
// debug: if (initMessage.login() == InitMessage::unauthenticatedLogin) {
if (initMessage.login() == InitMessage::guestLogin) {
playerName = initMessage.nickname();
// Verify guest player name.
@@ -1057,7 +1060,15 @@ ServerLobbyThread::HandleNetPacketInit(boost::shared_ptr<SessionData> session, c
validGuest = true;
noAuth = true;
}
// check if a guest session in lobby with same ip is already connected and
// if number of lobby guests >= SERVER_MAX_GUEST_USERS_LOBBY
if(m_serverConfig.readConfigInt("ServerRestrictGuestLogin") != 0
&& !m_sessionManager.IsGuestAllowedToConnect(session->GetClientAddr())) {
SessionError(session, ERR_NET_SERVER_FULL);
return;
}
}
if (!validGuest) {
SessionError(session, ERR_NET_INVALID_PLAYER_NAME);
return;
@@ -1393,6 +1404,7 @@ ServerLobbyThread::HandleNetPacketJoinGame(boost::shared_ptr<SessionData> sessio
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4
&& game->IsClientAddressConnected(session->GetClientAddr())) {
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED);
} else {
MoveSessionToGame(game, session, joinGame.autoleave(), false);
}
@@ -2365,4 +2377,3 @@ ServerLobbyThread::GetRejoinGameIdForPlayer(const std::string &playerName, const
}
return retGameId;
}
+30
View File
@@ -36,6 +36,7 @@
using namespace std;
#define SERVER_MAX_GUEST_USERS_LOBBY 50 // LG: Maximum number of guests users in lobby allowed
SessionManager::SessionManager()
{
@@ -247,6 +248,35 @@ SessionManager::IsClientAddressConnected(const std::string &clientAddress) const
return retVal;
}
bool
SessionManager::IsGuestAllowedToConnect(const std::string &clientAddress) const
{
bool retVal = true;
boost::recursive_mutex::scoped_lock lock(m_sessionMapMutex);
SessionMap::const_iterator i = m_sessionMap.begin();
SessionMap::const_iterator end = m_sessionMap.end();
int num = 0;
while (i != end) {
boost::shared_ptr<PlayerData> tmpPlayer(i->second->GetPlayerData());
if (tmpPlayer && tmpPlayer->GetRights() == PLAYER_RIGHTS_GUEST) {
num++;
if (i->second->GetClientAddr() == clientAddress) {
// guest has same ip as another guest in lobby or
retVal = false;
break;
}
}
++i;
}
// Check if number of players in lobby exceeds max
if (num >= SERVER_MAX_GUEST_USERS_LOBBY) retVal = false;
return retVal;
}
void
SessionManager::ForEach(boost::function<void (boost::shared_ptr<SessionData>)> func)
{
+7
View File
@@ -125,6 +125,9 @@ public:
void KickPlayer(unsigned playerId);
void AddPlayerToNumJoinsPerPlayer(const std::string &playerName);
int GetNumJoinsPerPlayer(const std::string &playerName);
protected:
struct RankingData {
@@ -191,6 +194,8 @@ protected:
SessionManager &GetSessionManager();
ServerDBInterface &GetDatabase();
typedef std::map<std::string, int> NumJoinsPerPlayerMap;
private:
ServerGame(const ServerGame &other);
@@ -251,6 +256,8 @@ private:
friend class ServerGameStateHand;
friend class ServerGameStateWaitPlayerAction;
friend class ServerGameStateWaitNextHand;
NumJoinsPerPlayerMap m_numJoinsPerPlayer;
};
#endif
+1
View File
@@ -64,6 +64,7 @@ public:
bool IsPlayerConnected(const std::string &playerName) const;
bool IsPlayerConnected(unsigned uniqueId) const;
bool IsClientAddressConnected(const std::string &clientAddress) const;
bool IsGuestAllowedToConnect(const std::string &clientAddress) const;
void ForEach(boost::function<void (boost::shared_ptr<SessionData>)> func);
+1 -1
View File
@@ -161,7 +161,7 @@ main(int argc, char *argv[])
pidFile = tmpPidPath.directory_string();
}
{
ofstream pidStream(pidFile.c_str(), ios_base::out | ios_base::trunc);
std::ofstream pidStream(pidFile.c_str(), ios_base::out | ios_base::trunc);
if (!pidStream.fail())
pidStream << getpid();
else
File diff suppressed because it is too large Load Diff
+178 -72
View File
@@ -8,12 +8,12 @@
#include <google/protobuf/stubs/common.h>
#if GOOGLE_PROTOBUF_VERSION < 2005000
#if GOOGLE_PROTOBUF_VERSION < 2006000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#if 2006001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
@@ -82,6 +82,14 @@ class CleanerInitMessage : public ::google::protobuf::MessageLite {
return *this;
}
inline const ::std::string& unknown_fields() const {
return _unknown_fields_;
}
inline ::std::string* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const CleanerInitMessage& default_instance();
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
@@ -110,13 +118,13 @@ class CleanerInitMessage : public ::google::protobuf::MessageLite {
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
void DiscardUnknownFields();
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::std::string GetTypeName() const;
// nested types ----------------------------------------------------
@@ -149,12 +157,12 @@ class CleanerInitMessage : public ::google::protobuf::MessageLite {
inline void set_has_clientsecret();
inline void clear_has_clientsecret();
::std::string _unknown_fields_;
::google::protobuf::uint32 _has_bits_[1];
mutable int _cached_size_;
::std::string* clientsecret_;
::google::protobuf::uint32 requestedversion_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
friend void protobuf_AddDesc_chatcleaner_2eproto_impl();
#else
@@ -180,6 +188,14 @@ class CleanerInitAckMessage : public ::google::protobuf::MessageLite {
return *this;
}
inline const ::std::string& unknown_fields() const {
return _unknown_fields_;
}
inline ::std::string* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const CleanerInitAckMessage& default_instance();
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
@@ -208,13 +224,13 @@ class CleanerInitAckMessage : public ::google::protobuf::MessageLite {
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
void DiscardUnknownFields();
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::std::string GetTypeName() const;
// nested types ----------------------------------------------------
@@ -247,12 +263,12 @@ class CleanerInitAckMessage : public ::google::protobuf::MessageLite {
inline void set_has_serversecret();
inline void clear_has_serversecret();
::std::string _unknown_fields_;
::google::protobuf::uint32 _has_bits_[1];
mutable int _cached_size_;
::std::string* serversecret_;
::google::protobuf::uint32 serverversion_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
friend void protobuf_AddDesc_chatcleaner_2eproto_impl();
#else
@@ -278,6 +294,14 @@ class CleanerChatRequestMessage : public ::google::protobuf::MessageLite {
return *this;
}
inline const ::std::string& unknown_fields() const {
return _unknown_fields_;
}
inline ::std::string* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const CleanerChatRequestMessage& default_instance();
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
@@ -306,13 +330,13 @@ class CleanerChatRequestMessage : public ::google::protobuf::MessageLite {
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
void DiscardUnknownFields();
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::std::string GetTypeName() const;
// nested types ----------------------------------------------------
@@ -386,16 +410,16 @@ class CleanerChatRequestMessage : public ::google::protobuf::MessageLite {
inline void set_has_chatmessage();
inline void clear_has_chatmessage();
::std::string _unknown_fields_;
::google::protobuf::uint32 _has_bits_[1];
mutable int _cached_size_;
::google::protobuf::uint32 requestid_;
int cleanerchattype_;
::google::protobuf::uint32 gameid_;
::google::protobuf::uint32 playerid_;
::std::string* playername_;
::std::string* chatmessage_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(6 + 31) / 32];
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
friend void protobuf_AddDesc_chatcleaner_2eproto_impl();
#else
@@ -421,6 +445,14 @@ class CleanerChatReplyMessage : public ::google::protobuf::MessageLite {
return *this;
}
inline const ::std::string& unknown_fields() const {
return _unknown_fields_;
}
inline ::std::string* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const CleanerChatReplyMessage& default_instance();
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
@@ -449,13 +481,13 @@ class CleanerChatReplyMessage : public ::google::protobuf::MessageLite {
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
void DiscardUnknownFields();
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::std::string GetTypeName() const;
// nested types ----------------------------------------------------
@@ -540,16 +572,16 @@ class CleanerChatReplyMessage : public ::google::protobuf::MessageLite {
inline void set_has_cleanertext();
inline void clear_has_cleanertext();
::std::string _unknown_fields_;
::google::protobuf::uint32 _has_bits_[1];
mutable int _cached_size_;
::google::protobuf::uint32 requestid_;
int cleanerchattype_;
::google::protobuf::uint32 gameid_;
::google::protobuf::uint32 playerid_;
::std::string* cleanertext_;
int cleaneractiontype_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(6 + 31) / 32];
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
friend void protobuf_AddDesc_chatcleaner_2eproto_impl();
#else
@@ -575,6 +607,14 @@ class ChatCleanerMessage : public ::google::protobuf::MessageLite {
return *this;
}
inline const ::std::string& unknown_fields() const {
return _unknown_fields_;
}
inline ::std::string* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ChatCleanerMessage& default_instance();
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
@@ -603,13 +643,13 @@ class ChatCleanerMessage : public ::google::protobuf::MessageLite {
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
void DiscardUnknownFields();
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::std::string GetTypeName() const;
// nested types ----------------------------------------------------
@@ -687,15 +727,15 @@ class ChatCleanerMessage : public ::google::protobuf::MessageLite {
inline void set_has_cleanerchatreplymessage();
inline void clear_has_cleanerchatreplymessage();
::std::string _unknown_fields_;
::google::protobuf::uint32 _has_bits_[1];
mutable int _cached_size_;
::CleanerInitMessage* cleanerinitmessage_;
::CleanerInitAckMessage* cleanerinitackmessage_;
::CleanerChatRequestMessage* cleanerchatrequestmessage_;
::CleanerChatReplyMessage* cleanerchatreplymessage_;
int messagetype_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(5 + 31) / 32];
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
friend void protobuf_AddDesc_chatcleaner_2eproto_impl();
#else
@@ -729,11 +769,13 @@ inline void CleanerInitMessage::clear_requestedversion() {
clear_has_requestedversion();
}
inline ::google::protobuf::uint32 CleanerInitMessage::requestedversion() const {
// @@protoc_insertion_point(field_get:CleanerInitMessage.requestedVersion)
return requestedversion_;
}
inline void CleanerInitMessage::set_requestedversion(::google::protobuf::uint32 value) {
set_has_requestedversion();
requestedversion_ = value;
// @@protoc_insertion_point(field_set:CleanerInitMessage.requestedVersion)
}
// required string clientSecret = 2;
@@ -747,54 +789,59 @@ inline void CleanerInitMessage::clear_has_clientsecret() {
_has_bits_[0] &= ~0x00000002u;
}
inline void CleanerInitMessage::clear_clientsecret() {
if (clientsecret_ != &::google::protobuf::internal::kEmptyString) {
if (clientsecret_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
clientsecret_->clear();
}
clear_has_clientsecret();
}
inline const ::std::string& CleanerInitMessage::clientsecret() const {
// @@protoc_insertion_point(field_get:CleanerInitMessage.clientSecret)
return *clientsecret_;
}
inline void CleanerInitMessage::set_clientsecret(const ::std::string& value) {
set_has_clientsecret();
if (clientsecret_ == &::google::protobuf::internal::kEmptyString) {
if (clientsecret_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
clientsecret_ = new ::std::string;
}
clientsecret_->assign(value);
// @@protoc_insertion_point(field_set:CleanerInitMessage.clientSecret)
}
inline void CleanerInitMessage::set_clientsecret(const char* value) {
set_has_clientsecret();
if (clientsecret_ == &::google::protobuf::internal::kEmptyString) {
if (clientsecret_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
clientsecret_ = new ::std::string;
}
clientsecret_->assign(value);
// @@protoc_insertion_point(field_set_char:CleanerInitMessage.clientSecret)
}
inline void CleanerInitMessage::set_clientsecret(const char* value, size_t size) {
set_has_clientsecret();
if (clientsecret_ == &::google::protobuf::internal::kEmptyString) {
if (clientsecret_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
clientsecret_ = new ::std::string;
}
clientsecret_->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:CleanerInitMessage.clientSecret)
}
inline ::std::string* CleanerInitMessage::mutable_clientsecret() {
set_has_clientsecret();
if (clientsecret_ == &::google::protobuf::internal::kEmptyString) {
if (clientsecret_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
clientsecret_ = new ::std::string;
}
// @@protoc_insertion_point(field_mutable:CleanerInitMessage.clientSecret)
return clientsecret_;
}
inline ::std::string* CleanerInitMessage::release_clientsecret() {
clear_has_clientsecret();
if (clientsecret_ == &::google::protobuf::internal::kEmptyString) {
if (clientsecret_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
return NULL;
} else {
::std::string* temp = clientsecret_;
clientsecret_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
clientsecret_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
return temp;
}
}
inline void CleanerInitMessage::set_allocated_clientsecret(::std::string* clientsecret) {
if (clientsecret_ != &::google::protobuf::internal::kEmptyString) {
if (clientsecret_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
delete clientsecret_;
}
if (clientsecret) {
@@ -802,8 +849,9 @@ inline void CleanerInitMessage::set_allocated_clientsecret(::std::string* client
clientsecret_ = clientsecret;
} else {
clear_has_clientsecret();
clientsecret_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
clientsecret_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
// @@protoc_insertion_point(field_set_allocated:CleanerInitMessage.clientSecret)
}
// -------------------------------------------------------------------
@@ -825,11 +873,13 @@ inline void CleanerInitAckMessage::clear_serverversion() {
clear_has_serverversion();
}
inline ::google::protobuf::uint32 CleanerInitAckMessage::serverversion() const {
// @@protoc_insertion_point(field_get:CleanerInitAckMessage.serverVersion)
return serverversion_;
}
inline void CleanerInitAckMessage::set_serverversion(::google::protobuf::uint32 value) {
set_has_serverversion();
serverversion_ = value;
// @@protoc_insertion_point(field_set:CleanerInitAckMessage.serverVersion)
}
// required string serverSecret = 2;
@@ -843,54 +893,59 @@ inline void CleanerInitAckMessage::clear_has_serversecret() {
_has_bits_[0] &= ~0x00000002u;
}
inline void CleanerInitAckMessage::clear_serversecret() {
if (serversecret_ != &::google::protobuf::internal::kEmptyString) {
if (serversecret_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
serversecret_->clear();
}
clear_has_serversecret();
}
inline const ::std::string& CleanerInitAckMessage::serversecret() const {
// @@protoc_insertion_point(field_get:CleanerInitAckMessage.serverSecret)
return *serversecret_;
}
inline void CleanerInitAckMessage::set_serversecret(const ::std::string& value) {
set_has_serversecret();
if (serversecret_ == &::google::protobuf::internal::kEmptyString) {
if (serversecret_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
serversecret_ = new ::std::string;
}
serversecret_->assign(value);
// @@protoc_insertion_point(field_set:CleanerInitAckMessage.serverSecret)
}
inline void CleanerInitAckMessage::set_serversecret(const char* value) {
set_has_serversecret();
if (serversecret_ == &::google::protobuf::internal::kEmptyString) {
if (serversecret_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
serversecret_ = new ::std::string;
}
serversecret_->assign(value);
// @@protoc_insertion_point(field_set_char:CleanerInitAckMessage.serverSecret)
}
inline void CleanerInitAckMessage::set_serversecret(const char* value, size_t size) {
set_has_serversecret();
if (serversecret_ == &::google::protobuf::internal::kEmptyString) {
if (serversecret_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
serversecret_ = new ::std::string;
}
serversecret_->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:CleanerInitAckMessage.serverSecret)
}
inline ::std::string* CleanerInitAckMessage::mutable_serversecret() {
set_has_serversecret();
if (serversecret_ == &::google::protobuf::internal::kEmptyString) {
if (serversecret_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
serversecret_ = new ::std::string;
}
// @@protoc_insertion_point(field_mutable:CleanerInitAckMessage.serverSecret)
return serversecret_;
}
inline ::std::string* CleanerInitAckMessage::release_serversecret() {
clear_has_serversecret();
if (serversecret_ == &::google::protobuf::internal::kEmptyString) {
if (serversecret_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
return NULL;
} else {
::std::string* temp = serversecret_;
serversecret_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
serversecret_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
return temp;
}
}
inline void CleanerInitAckMessage::set_allocated_serversecret(::std::string* serversecret) {
if (serversecret_ != &::google::protobuf::internal::kEmptyString) {
if (serversecret_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
delete serversecret_;
}
if (serversecret) {
@@ -898,8 +953,9 @@ inline void CleanerInitAckMessage::set_allocated_serversecret(::std::string* ser
serversecret_ = serversecret;
} else {
clear_has_serversecret();
serversecret_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
serversecret_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
// @@protoc_insertion_point(field_set_allocated:CleanerInitAckMessage.serverSecret)
}
// -------------------------------------------------------------------
@@ -921,11 +977,13 @@ inline void CleanerChatRequestMessage::clear_requestid() {
clear_has_requestid();
}
inline ::google::protobuf::uint32 CleanerChatRequestMessage::requestid() const {
// @@protoc_insertion_point(field_get:CleanerChatRequestMessage.requestId)
return requestid_;
}
inline void CleanerChatRequestMessage::set_requestid(::google::protobuf::uint32 value) {
set_has_requestid();
requestid_ = value;
// @@protoc_insertion_point(field_set:CleanerChatRequestMessage.requestId)
}
// required .CleanerChatType cleanerChatType = 2;
@@ -943,12 +1001,14 @@ inline void CleanerChatRequestMessage::clear_cleanerchattype() {
clear_has_cleanerchattype();
}
inline ::CleanerChatType CleanerChatRequestMessage::cleanerchattype() const {
// @@protoc_insertion_point(field_get:CleanerChatRequestMessage.cleanerChatType)
return static_cast< ::CleanerChatType >(cleanerchattype_);
}
inline void CleanerChatRequestMessage::set_cleanerchattype(::CleanerChatType value) {
assert(::CleanerChatType_IsValid(value));
set_has_cleanerchattype();
cleanerchattype_ = value;
// @@protoc_insertion_point(field_set:CleanerChatRequestMessage.cleanerChatType)
}
// optional uint32 gameId = 3 [default = 0];
@@ -966,11 +1026,13 @@ inline void CleanerChatRequestMessage::clear_gameid() {
clear_has_gameid();
}
inline ::google::protobuf::uint32 CleanerChatRequestMessage::gameid() const {
// @@protoc_insertion_point(field_get:CleanerChatRequestMessage.gameId)
return gameid_;
}
inline void CleanerChatRequestMessage::set_gameid(::google::protobuf::uint32 value) {
set_has_gameid();
gameid_ = value;
// @@protoc_insertion_point(field_set:CleanerChatRequestMessage.gameId)
}
// required uint32 playerId = 4;
@@ -988,11 +1050,13 @@ inline void CleanerChatRequestMessage::clear_playerid() {
clear_has_playerid();
}
inline ::google::protobuf::uint32 CleanerChatRequestMessage::playerid() const {
// @@protoc_insertion_point(field_get:CleanerChatRequestMessage.playerId)
return playerid_;
}
inline void CleanerChatRequestMessage::set_playerid(::google::protobuf::uint32 value) {
set_has_playerid();
playerid_ = value;
// @@protoc_insertion_point(field_set:CleanerChatRequestMessage.playerId)
}
// required string playerName = 5;
@@ -1006,54 +1070,59 @@ inline void CleanerChatRequestMessage::clear_has_playername() {
_has_bits_[0] &= ~0x00000010u;
}
inline void CleanerChatRequestMessage::clear_playername() {
if (playername_ != &::google::protobuf::internal::kEmptyString) {
if (playername_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
playername_->clear();
}
clear_has_playername();
}
inline const ::std::string& CleanerChatRequestMessage::playername() const {
// @@protoc_insertion_point(field_get:CleanerChatRequestMessage.playerName)
return *playername_;
}
inline void CleanerChatRequestMessage::set_playername(const ::std::string& value) {
set_has_playername();
if (playername_ == &::google::protobuf::internal::kEmptyString) {
if (playername_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
playername_ = new ::std::string;
}
playername_->assign(value);
// @@protoc_insertion_point(field_set:CleanerChatRequestMessage.playerName)
}
inline void CleanerChatRequestMessage::set_playername(const char* value) {
set_has_playername();
if (playername_ == &::google::protobuf::internal::kEmptyString) {
if (playername_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
playername_ = new ::std::string;
}
playername_->assign(value);
// @@protoc_insertion_point(field_set_char:CleanerChatRequestMessage.playerName)
}
inline void CleanerChatRequestMessage::set_playername(const char* value, size_t size) {
set_has_playername();
if (playername_ == &::google::protobuf::internal::kEmptyString) {
if (playername_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
playername_ = new ::std::string;
}
playername_->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:CleanerChatRequestMessage.playerName)
}
inline ::std::string* CleanerChatRequestMessage::mutable_playername() {
set_has_playername();
if (playername_ == &::google::protobuf::internal::kEmptyString) {
if (playername_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
playername_ = new ::std::string;
}
// @@protoc_insertion_point(field_mutable:CleanerChatRequestMessage.playerName)
return playername_;
}
inline ::std::string* CleanerChatRequestMessage::release_playername() {
clear_has_playername();
if (playername_ == &::google::protobuf::internal::kEmptyString) {
if (playername_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
return NULL;
} else {
::std::string* temp = playername_;
playername_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
playername_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
return temp;
}
}
inline void CleanerChatRequestMessage::set_allocated_playername(::std::string* playername) {
if (playername_ != &::google::protobuf::internal::kEmptyString) {
if (playername_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
delete playername_;
}
if (playername) {
@@ -1061,8 +1130,9 @@ inline void CleanerChatRequestMessage::set_allocated_playername(::std::string* p
playername_ = playername;
} else {
clear_has_playername();
playername_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
playername_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
// @@protoc_insertion_point(field_set_allocated:CleanerChatRequestMessage.playerName)
}
// required string chatMessage = 6;
@@ -1076,54 +1146,59 @@ inline void CleanerChatRequestMessage::clear_has_chatmessage() {
_has_bits_[0] &= ~0x00000020u;
}
inline void CleanerChatRequestMessage::clear_chatmessage() {
if (chatmessage_ != &::google::protobuf::internal::kEmptyString) {
if (chatmessage_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
chatmessage_->clear();
}
clear_has_chatmessage();
}
inline const ::std::string& CleanerChatRequestMessage::chatmessage() const {
// @@protoc_insertion_point(field_get:CleanerChatRequestMessage.chatMessage)
return *chatmessage_;
}
inline void CleanerChatRequestMessage::set_chatmessage(const ::std::string& value) {
set_has_chatmessage();
if (chatmessage_ == &::google::protobuf::internal::kEmptyString) {
if (chatmessage_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
chatmessage_ = new ::std::string;
}
chatmessage_->assign(value);
// @@protoc_insertion_point(field_set:CleanerChatRequestMessage.chatMessage)
}
inline void CleanerChatRequestMessage::set_chatmessage(const char* value) {
set_has_chatmessage();
if (chatmessage_ == &::google::protobuf::internal::kEmptyString) {
if (chatmessage_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
chatmessage_ = new ::std::string;
}
chatmessage_->assign(value);
// @@protoc_insertion_point(field_set_char:CleanerChatRequestMessage.chatMessage)
}
inline void CleanerChatRequestMessage::set_chatmessage(const char* value, size_t size) {
set_has_chatmessage();
if (chatmessage_ == &::google::protobuf::internal::kEmptyString) {
if (chatmessage_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
chatmessage_ = new ::std::string;
}
chatmessage_->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:CleanerChatRequestMessage.chatMessage)
}
inline ::std::string* CleanerChatRequestMessage::mutable_chatmessage() {
set_has_chatmessage();
if (chatmessage_ == &::google::protobuf::internal::kEmptyString) {
if (chatmessage_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
chatmessage_ = new ::std::string;
}
// @@protoc_insertion_point(field_mutable:CleanerChatRequestMessage.chatMessage)
return chatmessage_;
}
inline ::std::string* CleanerChatRequestMessage::release_chatmessage() {
clear_has_chatmessage();
if (chatmessage_ == &::google::protobuf::internal::kEmptyString) {
if (chatmessage_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
return NULL;
} else {
::std::string* temp = chatmessage_;
chatmessage_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
chatmessage_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
return temp;
}
}
inline void CleanerChatRequestMessage::set_allocated_chatmessage(::std::string* chatmessage) {
if (chatmessage_ != &::google::protobuf::internal::kEmptyString) {
if (chatmessage_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
delete chatmessage_;
}
if (chatmessage) {
@@ -1131,8 +1206,9 @@ inline void CleanerChatRequestMessage::set_allocated_chatmessage(::std::string*
chatmessage_ = chatmessage;
} else {
clear_has_chatmessage();
chatmessage_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
chatmessage_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
// @@protoc_insertion_point(field_set_allocated:CleanerChatRequestMessage.chatMessage)
}
// -------------------------------------------------------------------
@@ -1154,11 +1230,13 @@ inline void CleanerChatReplyMessage::clear_requestid() {
clear_has_requestid();
}
inline ::google::protobuf::uint32 CleanerChatReplyMessage::requestid() const {
// @@protoc_insertion_point(field_get:CleanerChatReplyMessage.requestId)
return requestid_;
}
inline void CleanerChatReplyMessage::set_requestid(::google::protobuf::uint32 value) {
set_has_requestid();
requestid_ = value;
// @@protoc_insertion_point(field_set:CleanerChatReplyMessage.requestId)
}
// required .CleanerChatType cleanerChatType = 2;
@@ -1176,12 +1254,14 @@ inline void CleanerChatReplyMessage::clear_cleanerchattype() {
clear_has_cleanerchattype();
}
inline ::CleanerChatType CleanerChatReplyMessage::cleanerchattype() const {
// @@protoc_insertion_point(field_get:CleanerChatReplyMessage.cleanerChatType)
return static_cast< ::CleanerChatType >(cleanerchattype_);
}
inline void CleanerChatReplyMessage::set_cleanerchattype(::CleanerChatType value) {
assert(::CleanerChatType_IsValid(value));
set_has_cleanerchattype();
cleanerchattype_ = value;
// @@protoc_insertion_point(field_set:CleanerChatReplyMessage.cleanerChatType)
}
// optional uint32 gameId = 3 [default = 0];
@@ -1199,11 +1279,13 @@ inline void CleanerChatReplyMessage::clear_gameid() {
clear_has_gameid();
}
inline ::google::protobuf::uint32 CleanerChatReplyMessage::gameid() const {
// @@protoc_insertion_point(field_get:CleanerChatReplyMessage.gameId)
return gameid_;
}
inline void CleanerChatReplyMessage::set_gameid(::google::protobuf::uint32 value) {
set_has_gameid();
gameid_ = value;
// @@protoc_insertion_point(field_set:CleanerChatReplyMessage.gameId)
}
// required uint32 playerId = 4;
@@ -1221,11 +1303,13 @@ inline void CleanerChatReplyMessage::clear_playerid() {
clear_has_playerid();
}
inline ::google::protobuf::uint32 CleanerChatReplyMessage::playerid() const {
// @@protoc_insertion_point(field_get:CleanerChatReplyMessage.playerId)
return playerid_;
}
inline void CleanerChatReplyMessage::set_playerid(::google::protobuf::uint32 value) {
set_has_playerid();
playerid_ = value;
// @@protoc_insertion_point(field_set:CleanerChatReplyMessage.playerId)
}
// required .CleanerChatReplyMessage.CleanerActionType cleanerActionType = 5;
@@ -1243,12 +1327,14 @@ inline void CleanerChatReplyMessage::clear_cleaneractiontype() {
clear_has_cleaneractiontype();
}
inline ::CleanerChatReplyMessage_CleanerActionType CleanerChatReplyMessage::cleaneractiontype() const {
// @@protoc_insertion_point(field_get:CleanerChatReplyMessage.cleanerActionType)
return static_cast< ::CleanerChatReplyMessage_CleanerActionType >(cleaneractiontype_);
}
inline void CleanerChatReplyMessage::set_cleaneractiontype(::CleanerChatReplyMessage_CleanerActionType value) {
assert(::CleanerChatReplyMessage_CleanerActionType_IsValid(value));
set_has_cleaneractiontype();
cleaneractiontype_ = value;
// @@protoc_insertion_point(field_set:CleanerChatReplyMessage.cleanerActionType)
}
// optional string cleanerText = 6 [default = ""];
@@ -1262,54 +1348,59 @@ inline void CleanerChatReplyMessage::clear_has_cleanertext() {
_has_bits_[0] &= ~0x00000020u;
}
inline void CleanerChatReplyMessage::clear_cleanertext() {
if (cleanertext_ != &::google::protobuf::internal::kEmptyString) {
if (cleanertext_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
cleanertext_->clear();
}
clear_has_cleanertext();
}
inline const ::std::string& CleanerChatReplyMessage::cleanertext() const {
// @@protoc_insertion_point(field_get:CleanerChatReplyMessage.cleanerText)
return *cleanertext_;
}
inline void CleanerChatReplyMessage::set_cleanertext(const ::std::string& value) {
set_has_cleanertext();
if (cleanertext_ == &::google::protobuf::internal::kEmptyString) {
if (cleanertext_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
cleanertext_ = new ::std::string;
}
cleanertext_->assign(value);
// @@protoc_insertion_point(field_set:CleanerChatReplyMessage.cleanerText)
}
inline void CleanerChatReplyMessage::set_cleanertext(const char* value) {
set_has_cleanertext();
if (cleanertext_ == &::google::protobuf::internal::kEmptyString) {
if (cleanertext_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
cleanertext_ = new ::std::string;
}
cleanertext_->assign(value);
// @@protoc_insertion_point(field_set_char:CleanerChatReplyMessage.cleanerText)
}
inline void CleanerChatReplyMessage::set_cleanertext(const char* value, size_t size) {
set_has_cleanertext();
if (cleanertext_ == &::google::protobuf::internal::kEmptyString) {
if (cleanertext_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
cleanertext_ = new ::std::string;
}
cleanertext_->assign(reinterpret_cast<const char*>(value), size);
// @@protoc_insertion_point(field_set_pointer:CleanerChatReplyMessage.cleanerText)
}
inline ::std::string* CleanerChatReplyMessage::mutable_cleanertext() {
set_has_cleanertext();
if (cleanertext_ == &::google::protobuf::internal::kEmptyString) {
if (cleanertext_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
cleanertext_ = new ::std::string;
}
// @@protoc_insertion_point(field_mutable:CleanerChatReplyMessage.cleanerText)
return cleanertext_;
}
inline ::std::string* CleanerChatReplyMessage::release_cleanertext() {
clear_has_cleanertext();
if (cleanertext_ == &::google::protobuf::internal::kEmptyString) {
if (cleanertext_ == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
return NULL;
} else {
::std::string* temp = cleanertext_;
cleanertext_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
cleanertext_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
return temp;
}
}
inline void CleanerChatReplyMessage::set_allocated_cleanertext(::std::string* cleanertext) {
if (cleanertext_ != &::google::protobuf::internal::kEmptyString) {
if (cleanertext_ != &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {
delete cleanertext_;
}
if (cleanertext) {
@@ -1317,8 +1408,9 @@ inline void CleanerChatReplyMessage::set_allocated_cleanertext(::std::string* cl
cleanertext_ = cleanertext;
} else {
clear_has_cleanertext();
cleanertext_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
cleanertext_ = const_cast< ::std::string*>(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
// @@protoc_insertion_point(field_set_allocated:CleanerChatReplyMessage.cleanerText)
}
// -------------------------------------------------------------------
@@ -1340,12 +1432,14 @@ inline void ChatCleanerMessage::clear_messagetype() {
clear_has_messagetype();
}
inline ::ChatCleanerMessage_ChatCleanerMessageType ChatCleanerMessage::messagetype() const {
// @@protoc_insertion_point(field_get:ChatCleanerMessage.messageType)
return static_cast< ::ChatCleanerMessage_ChatCleanerMessageType >(messagetype_);
}
inline void ChatCleanerMessage::set_messagetype(::ChatCleanerMessage_ChatCleanerMessageType value) {
assert(::ChatCleanerMessage_ChatCleanerMessageType_IsValid(value));
set_has_messagetype();
messagetype_ = value;
// @@protoc_insertion_point(field_set:ChatCleanerMessage.messageType)
}
// optional .CleanerInitMessage cleanerInitMessage = 2;
@@ -1363,6 +1457,7 @@ inline void ChatCleanerMessage::clear_cleanerinitmessage() {
clear_has_cleanerinitmessage();
}
inline const ::CleanerInitMessage& ChatCleanerMessage::cleanerinitmessage() const {
// @@protoc_insertion_point(field_get:ChatCleanerMessage.cleanerInitMessage)
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
return cleanerinitmessage_ != NULL ? *cleanerinitmessage_ : *default_instance().cleanerinitmessage_;
#else
@@ -1372,6 +1467,7 @@ inline const ::CleanerInitMessage& ChatCleanerMessage::cleanerinitmessage() cons
inline ::CleanerInitMessage* ChatCleanerMessage::mutable_cleanerinitmessage() {
set_has_cleanerinitmessage();
if (cleanerinitmessage_ == NULL) cleanerinitmessage_ = new ::CleanerInitMessage;
// @@protoc_insertion_point(field_mutable:ChatCleanerMessage.cleanerInitMessage)
return cleanerinitmessage_;
}
inline ::CleanerInitMessage* ChatCleanerMessage::release_cleanerinitmessage() {
@@ -1388,6 +1484,7 @@ inline void ChatCleanerMessage::set_allocated_cleanerinitmessage(::CleanerInitMe
} else {
clear_has_cleanerinitmessage();
}
// @@protoc_insertion_point(field_set_allocated:ChatCleanerMessage.cleanerInitMessage)
}
// optional .CleanerInitAckMessage cleanerInitAckMessage = 3;
@@ -1405,6 +1502,7 @@ inline void ChatCleanerMessage::clear_cleanerinitackmessage() {
clear_has_cleanerinitackmessage();
}
inline const ::CleanerInitAckMessage& ChatCleanerMessage::cleanerinitackmessage() const {
// @@protoc_insertion_point(field_get:ChatCleanerMessage.cleanerInitAckMessage)
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
return cleanerinitackmessage_ != NULL ? *cleanerinitackmessage_ : *default_instance().cleanerinitackmessage_;
#else
@@ -1414,6 +1512,7 @@ inline const ::CleanerInitAckMessage& ChatCleanerMessage::cleanerinitackmessage(
inline ::CleanerInitAckMessage* ChatCleanerMessage::mutable_cleanerinitackmessage() {
set_has_cleanerinitackmessage();
if (cleanerinitackmessage_ == NULL) cleanerinitackmessage_ = new ::CleanerInitAckMessage;
// @@protoc_insertion_point(field_mutable:ChatCleanerMessage.cleanerInitAckMessage)
return cleanerinitackmessage_;
}
inline ::CleanerInitAckMessage* ChatCleanerMessage::release_cleanerinitackmessage() {
@@ -1430,6 +1529,7 @@ inline void ChatCleanerMessage::set_allocated_cleanerinitackmessage(::CleanerIni
} else {
clear_has_cleanerinitackmessage();
}
// @@protoc_insertion_point(field_set_allocated:ChatCleanerMessage.cleanerInitAckMessage)
}
// optional .CleanerChatRequestMessage cleanerChatRequestMessage = 4;
@@ -1447,6 +1547,7 @@ inline void ChatCleanerMessage::clear_cleanerchatrequestmessage() {
clear_has_cleanerchatrequestmessage();
}
inline const ::CleanerChatRequestMessage& ChatCleanerMessage::cleanerchatrequestmessage() const {
// @@protoc_insertion_point(field_get:ChatCleanerMessage.cleanerChatRequestMessage)
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
return cleanerchatrequestmessage_ != NULL ? *cleanerchatrequestmessage_ : *default_instance().cleanerchatrequestmessage_;
#else
@@ -1456,6 +1557,7 @@ inline const ::CleanerChatRequestMessage& ChatCleanerMessage::cleanerchatrequest
inline ::CleanerChatRequestMessage* ChatCleanerMessage::mutable_cleanerchatrequestmessage() {
set_has_cleanerchatrequestmessage();
if (cleanerchatrequestmessage_ == NULL) cleanerchatrequestmessage_ = new ::CleanerChatRequestMessage;
// @@protoc_insertion_point(field_mutable:ChatCleanerMessage.cleanerChatRequestMessage)
return cleanerchatrequestmessage_;
}
inline ::CleanerChatRequestMessage* ChatCleanerMessage::release_cleanerchatrequestmessage() {
@@ -1472,6 +1574,7 @@ inline void ChatCleanerMessage::set_allocated_cleanerchatrequestmessage(::Cleane
} else {
clear_has_cleanerchatrequestmessage();
}
// @@protoc_insertion_point(field_set_allocated:ChatCleanerMessage.cleanerChatRequestMessage)
}
// optional .CleanerChatReplyMessage cleanerChatReplyMessage = 5;
@@ -1489,6 +1592,7 @@ inline void ChatCleanerMessage::clear_cleanerchatreplymessage() {
clear_has_cleanerchatreplymessage();
}
inline const ::CleanerChatReplyMessage& ChatCleanerMessage::cleanerchatreplymessage() const {
// @@protoc_insertion_point(field_get:ChatCleanerMessage.cleanerChatReplyMessage)
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
return cleanerchatreplymessage_ != NULL ? *cleanerchatreplymessage_ : *default_instance().cleanerchatreplymessage_;
#else
@@ -1498,6 +1602,7 @@ inline const ::CleanerChatReplyMessage& ChatCleanerMessage::cleanerchatreplymess
inline ::CleanerChatReplyMessage* ChatCleanerMessage::mutable_cleanerchatreplymessage() {
set_has_cleanerchatreplymessage();
if (cleanerchatreplymessage_ == NULL) cleanerchatreplymessage_ = new ::CleanerChatReplyMessage;
// @@protoc_insertion_point(field_mutable:ChatCleanerMessage.cleanerChatReplyMessage)
return cleanerchatreplymessage_;
}
inline ::CleanerChatReplyMessage* ChatCleanerMessage::release_cleanerchatreplymessage() {
@@ -1514,6 +1619,7 @@ inline void ChatCleanerMessage::set_allocated_cleanerchatreplymessage(::CleanerC
} else {
clear_has_cleanerchatreplymessage();
}
// @@protoc_insertion_point(field_set_allocated:ChatCleanerMessage.cleanerChatReplyMessage)
}
+4939 -2102
View File
File diff suppressed because it is too large Load Diff
+2265 -653
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -44,6 +44,10 @@ static PProcessIdToSessionId pProcessIdToSessionId = 0;
#include <unistd.h>
#endif
// @FIXME: bugfix for strange new compiler error on ubuntu 16.04 = QDataStream ds has initializer but incomplete type
// not sure if that collides on other systems:
#include <QDataStream>
namespace SharedTools {
static const char ack[] = "ack";
+2 -2
View File
@@ -59,8 +59,8 @@ main(int argc, char *argv[])
return 2;
}
try {
ifstream inFile(inputFilePath.directory_string().c_str(), ios_base::in);
ofstream outFile(outputFilePath.directory_string().c_str(), ios_base::out | ios_base::binary);
std::ifstream inFile(inputFilePath.directory_string().c_str(), ios_base::in);
std::ofstream outFile(outputFilePath.directory_string().c_str(), ios_base::out | ios_base::binary);
boost::iostreams::filtering_streambuf<boost::iostreams::output> out;
out.push(boost::iostreams::zlib_compressor());
out.push(outFile);
File diff suppressed because it is too large Load Diff