Compare commits
95
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29259f1f29 | ||
|
|
1ff513e09a | ||
|
|
b03d39d141 | ||
|
|
99de54cdf5 | ||
|
|
d2849449ce | ||
|
|
f31127e695 | ||
|
|
03602cd37f | ||
|
|
a5c8aefeb2 | ||
|
|
4e888e2cfe | ||
|
|
c96955e719 | ||
|
|
ef1ccfdbd7 | ||
|
|
cedf5f7218 | ||
|
|
ad80896fae | ||
|
|
20793e24a1 | ||
|
|
382b533488 | ||
|
|
7c538fc436 | ||
|
|
add886ebee | ||
|
|
f9a2ebebb4 | ||
|
|
21b8088ecf | ||
|
|
09281f3179 | ||
|
|
f5688e01b0 | ||
|
|
f920d5f1c8 | ||
|
|
008d703de1 | ||
|
|
0a8b6d597f | ||
|
|
3813664b94 | ||
|
|
ad8c9cabfb | ||
|
|
678da490d4 | ||
|
|
8e5b09ac62 | ||
|
|
2ca2e941a6 | ||
|
|
b3c81c770f | ||
|
|
65e10c71b0 | ||
|
|
94d87ed33e | ||
|
|
8a9efbb77a | ||
|
|
981073ee78 | ||
|
|
17ec0024e9 | ||
|
|
0b4d0e334c | ||
|
|
ce2638317d | ||
|
|
1c5e8792aa | ||
|
|
8fb973344b | ||
|
|
f8474c02f7 | ||
|
|
f3f31519d4 | ||
|
|
6bf732f219 | ||
|
|
0ed986399f | ||
|
|
94ea0e6c2f | ||
|
|
19f95f6204 | ||
|
|
16c7200028 | ||
|
|
d0cc76ffc3 | ||
|
|
1b63c39f31 | ||
|
|
2358eaa5aa | ||
|
|
3b459ac57c | ||
|
|
3bd5286521 | ||
|
|
f64a6275d4 | ||
|
|
a6c7d62fb0 | ||
|
|
41ac0c7fe5 | ||
|
|
89a40325dc | ||
|
|
6b63097853 | ||
|
|
6ae765baac | ||
|
|
a4843369ee | ||
|
|
413d61e61c | ||
|
|
8f7014af12 | ||
|
|
5dab4c743c | ||
|
|
102955d6ce | ||
|
|
65eea1d6ec | ||
|
|
2b372d0019 | ||
|
|
612751044d | ||
|
|
ed84e7dfad | ||
|
|
002eea3ccb | ||
|
|
6bd0808427 | ||
|
|
4682b51e40 | ||
|
|
35f0521bbd | ||
|
|
159fd1e094 | ||
|
|
2a88775cca | ||
|
|
e73a95d08e | ||
|
|
1b5cf1bfb8 | ||
|
|
1abc9dc452 | ||
|
|
21003da510 | ||
|
|
70d6743c39 | ||
|
|
24acd01e90 | ||
|
|
8f5813416d | ||
|
|
417d9a5bd2 | ||
|
|
55174a71a7 | ||
|
|
724d30e61f | ||
|
|
b6763bcfe8 | ||
|
|
6092b3c306 | ||
|
|
c57a20482a | ||
|
|
98ce4bd637 | ||
|
|
1c3edbaaaa | ||
|
|
1f9c066cbb | ||
|
|
cd085bf8be | ||
|
|
cf280f0478 | ||
|
|
935ec2ad92 | ||
|
|
f6fb0650e3 | ||
|
|
b30ea65998 | ||
|
|
3ec764396a | ||
|
|
4faf428fb3 |
+21
@@ -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
|
||||||
|
.vscode/
|
||||||
@@ -1,3 +1,13 @@
|
|||||||
|
2017-09-01 version 1.1.2
|
||||||
|
- PokerTH is now fully compatible with c++11 compilation mode
|
||||||
|
- Upgraded to websockets 0.7
|
||||||
|
- BUGFIX: SQL errors are saved to server log (partly #324)
|
||||||
|
- BUGFIX: Players deliberately preventing start of play (#304)
|
||||||
|
- BUGFIX: Rating feature didn't work for special usernames (#319)
|
||||||
|
- BUGFIX: Ignore feature only works after restart (#320)
|
||||||
|
- BUGFIX: Shorten too long usernames on the table gui (#326)
|
||||||
|
- BUGFIX: "accidentally call" blocker now for working for FKey presses (#330)
|
||||||
|
|
||||||
2014-01-10 version 1.1.1
|
2014-01-10 version 1.1.1
|
||||||
- BUGFIX: Fixed crash when the first action in the first game times out (#258)
|
- BUGFIX: Fixed crash when the first action in the first game times out (#258)
|
||||||
- BUGFIX: Properly refresh the game table graphics after changing settings (#253)
|
- BUGFIX: Properly refresh the game table graphics after changing settings (#253)
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ Linux:
|
|||||||
- libgsasl version >= 1.4 --> http://www.gnu.org/software/gsasl/
|
- libgsasl version >= 1.4 --> http://www.gnu.org/software/gsasl/
|
||||||
- libboost_thread, libboost_filesystem, libboost_datetime, libboost_program_options,
|
- libboost_thread, libboost_filesystem, libboost_datetime, libboost_program_options,
|
||||||
libboost_iostreams, libboost_asio, libboost_regex, libboost_random, libboost_uuid
|
libboost_iostreams, libboost_asio, libboost_regex, libboost_random, libboost_uuid
|
||||||
(version >= 1.44, latest always recommended) --> http://www.boost.org/
|
(version >= 1.49, latest always recommended) --> http://www.boost.org/
|
||||||
- libSDL_mixer, libSDL --> http://www.libsdl.org/
|
- libSDL_mixer, libSDL --> http://www.libsdl.org/
|
||||||
- libSQLite3 --> http://sqlite.org/
|
- libSQLite3 --> http://sqlite.org/
|
||||||
- libtinyxml > 2.0 --> http://www.sourceforge.net/projects/tinyxml
|
- 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/
|
- For the server: libircclient 1.3 --> http://www.sourceforge.net/projects/libircclient/
|
||||||
|
|
||||||
Windows:
|
Windows:
|
||||||
@@ -28,7 +28,7 @@ Basic Installation
|
|||||||
Linux:
|
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.
|
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"
|
You can set this variable typing: "export QTDIR=/usr/qt/4"
|
||||||
|
|
||||||
2. Type "make" to compile the package.
|
2. Type "make" to compile the package.
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
* shall include the source code for the parts of OpenSSL used as well *
|
* shall include the source code for the parts of OpenSSL used as well *
|
||||||
* as that of the covered work. *
|
* as that of the covered work. *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
syntax = "proto2";
|
||||||
|
|
||||||
option java_package = "de.chatcleaner.protocol";
|
option java_package = "de.chatcleaner.protocol";
|
||||||
option java_outer_classname = "ProtoBuf";
|
option java_outer_classname = "ProtoBuf";
|
||||||
|
|||||||
+2
-2
@@ -41,13 +41,13 @@ unix : !mac {
|
|||||||
|
|
||||||
QMAKE_LIBDIR += lib $${PREFIX}/lib /opt/gsasl/lib
|
QMAKE_LIBDIR += lib $${PREFIX}/lib /opt/gsasl/lib
|
||||||
INCLUDEPATH += $${PREFIX}/include
|
INCLUDEPATH += $${PREFIX}/include
|
||||||
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system(qmake -query QT_INSTALL_LIBS)
|
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
|
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
|
||||||
BOOST_SYS = boost_system boost_system-mt
|
BOOST_SYS = boost_system boost_system-mt
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system(qmake -query QT_INSTALL_LIBS)
|
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
# to override the default '/usr' pass PREFIX
|
# to override the default '/usr' pass PREFIX
|
||||||
# variable to qmake.
|
# variable to qmake.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
# QMake pro-file for the PokerTH dedicated server
|
||||||
|
|
||||||
|
isEmpty( PREFIX ){
|
||||||
|
PREFIX =/usr
|
||||||
|
}
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
CODECFORSRC = UTF-8
|
||||||
|
|
||||||
|
CONFIG += thread console embed_manifest_exe exceptions rtti stl warn_on
|
||||||
|
|
||||||
|
UI_DIR = uics
|
||||||
|
TARGET = bin/dealer_random_test
|
||||||
|
MOC_DIR = mocs
|
||||||
|
OBJECTS_DIR = obj
|
||||||
|
DEFINES += PREFIX=\"$${PREFIX}\"
|
||||||
|
QT -= core gui
|
||||||
|
#PRECOMPILED_HEADER = src/pch_lib.h
|
||||||
|
|
||||||
|
INCLUDEPATH += . \
|
||||||
|
src
|
||||||
|
DEPENDPATH += . \
|
||||||
|
src
|
||||||
|
|
||||||
|
# Input
|
||||||
|
SOURCES += \
|
||||||
|
src/dealer_random_test.cpp
|
||||||
|
|
||||||
|
unix : !mac {
|
||||||
|
|
||||||
|
##### My release static build options
|
||||||
|
#QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections
|
||||||
|
#QMAKE_LFLAGS += -Wl,--gc-sections
|
||||||
|
|
||||||
|
QMAKE_LIBDIR += lib $${PREFIX}/lib /opt/gsasl/lib
|
||||||
|
INCLUDEPATH += $${PREFIX}/include
|
||||||
|
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
|
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
|
||||||
|
BOOST_SYS = boost_system boost_system-mt
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
|
# to override the default '/usr' pass PREFIX
|
||||||
|
# variable to qmake.
|
||||||
|
#
|
||||||
|
for(dir, LIB_DIRS){
|
||||||
|
exists($$dir){
|
||||||
|
for(lib, BOOST_PROGRAM_OPTIONS):exists($${dir}/lib$${lib}.so*) {
|
||||||
|
message("Found $$lib")
|
||||||
|
BOOST_PROGRAM_OPTIONS = -l$$lib
|
||||||
|
}
|
||||||
|
for(lib, BOOST_PROGRAM_OPTIONS):exists($${dir}/lib$${lib}.a) {
|
||||||
|
message("Found $$lib")
|
||||||
|
BOOST_PROGRAM_OPTIONS = -l$$lib
|
||||||
|
}
|
||||||
|
for(lib, BOOST_SYS):exists($${dir}/lib$${lib}.so*) {
|
||||||
|
message("Found $$lib")
|
||||||
|
BOOST_SYS = -l$$lib
|
||||||
|
}
|
||||||
|
for(lib, BOOST_SYS):exists($${dir}/lib$${lib}.a) {
|
||||||
|
message("Found $$lib")
|
||||||
|
BOOST_SYS = -l$$lib
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BOOST_LIBS = $$BOOST_PROGRAM_OPTIONS $$BOOST_SYS
|
||||||
|
!count(BOOST_LIBS, 2){
|
||||||
|
error("Unable to find boost libraries in PREFIX=$${PREFIX}")
|
||||||
|
}
|
||||||
|
|
||||||
|
UNAME = $$system(uname -s)
|
||||||
|
BSD = $$find(UNAME, "BSD")
|
||||||
|
kFreeBSD = $$find(UNAME, "kFreeBSD")
|
||||||
|
|
||||||
|
LIBS += $$BOOST_LIBS
|
||||||
|
LIBS += -lprotobuf -lgsasl -lgcrypt -lidn -lboost_thread -lboost_system -lboost_random
|
||||||
|
|
||||||
|
#### INSTALL ####
|
||||||
|
|
||||||
|
binary.path += $${PREFIX}/bin/
|
||||||
|
binary.files += dealer_random_test
|
||||||
|
|
||||||
|
INSTALLS += binary
|
||||||
|
}
|
||||||
|
|
||||||
@@ -42,14 +42,14 @@ unix : !mac {
|
|||||||
|
|
||||||
QMAKE_LIBDIR += lib $${PREFIX}/lib /opt/gsasl/lib
|
QMAKE_LIBDIR += lib $${PREFIX}/lib /opt/gsasl/lib
|
||||||
INCLUDEPATH += $${PREFIX}/include
|
INCLUDEPATH += $${PREFIX}/include
|
||||||
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system(qmake -query QT_INSTALL_LIBS)
|
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
BOOST_THREAD = boost_thread boost_thread-mt
|
BOOST_THREAD = boost_thread boost_thread-mt
|
||||||
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
|
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
|
||||||
BOOST_SYS = boost_system boost_system-mt
|
BOOST_SYS = boost_system boost_system-mt
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system(qmake -query QT_INSTALL_LIBS)
|
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
# to override the default '/usr' pass PREFIX
|
# to override the default '/usr' pass PREFIX
|
||||||
# variable to qmake.
|
# variable to qmake.
|
||||||
#
|
#
|
||||||
|
|||||||
+2
-2
@@ -9,8 +9,8 @@
|
|||||||
# of binary-size if you leave Qt out.
|
# of binary-size if you leave Qt out.
|
||||||
# (see http://trolltech.com/developer/downloads/qt/mac)
|
# (see http://trolltech.com/developer/downloads/qt/mac)
|
||||||
|
|
||||||
QT_FW_PATH="/Developer/Qt5/5/clang_64/lib"
|
QT_FW_PATH="/Users/$USER/Qt/5.9/clang_64/lib"
|
||||||
QT_PLUGIN_PATH="/Developer/Qt5/5/clang_64/plugins"
|
QT_PLUGIN_PATH="/Users/$USER/Qt/5.9/clang_64/plugins"
|
||||||
SDL_FW_PATH="/Library/Frameworks"
|
SDL_FW_PATH="/Library/Frameworks"
|
||||||
APPLICATION="./pokerth.app"
|
APPLICATION="./pokerth.app"
|
||||||
BINARY="$APPLICATION/Contents/MacOs/pokerth"
|
BINARY="$APPLICATION/Contents/MacOs/pokerth"
|
||||||
|
|||||||
Executable → Regular
+10
-3
@@ -1,10 +1,17 @@
|
|||||||
# QMake pro-file for PokerTH
|
# QMake pro-file for PokerTH
|
||||||
|
|
||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
SUBDIRS = pokerth_protocol.pro pokerth_db.pro pokerth_lib.pro pokerth_game.pro
|
SUBDIRS = pokerth_protocol.pro pokerth_db.pro pokerth_lib.pro
|
||||||
!mac:!gui_800x480:!client {
|
official_server {
|
||||||
SUBDIRS += pokerth_server.pro chatcleaner.pro
|
SUBDIRS += pokerth_dbofficial.pro
|
||||||
}
|
}
|
||||||
|
client: {
|
||||||
|
SUBDIRS += pokerth_game.pro
|
||||||
|
}
|
||||||
|
!mac:!gui_800x480:!client:!qml-client {
|
||||||
|
SUBDIRS += pokerth_server.pro chatcleaner.pro
|
||||||
|
}
|
||||||
|
|
||||||
CONFIG += ordered
|
CONFIG += ordered
|
||||||
|
|
||||||
OTHER_FILES += \
|
OTHER_FILES += \
|
||||||
|
|||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
syntax = "proto2";
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* PokerTH - The open source texas holdem engine *
|
* PokerTH - The open source texas holdem engine *
|
||||||
* Copyright (C) 2006-2013 Felix Hammer, Florian Thauer, Lothar May *
|
* Copyright (C) 2006-2013 Felix Hammer, Florian Thauer, Lothar May *
|
||||||
@@ -701,7 +702,7 @@ message ReportGameAckMessage {
|
|||||||
|
|
||||||
message ErrorMessage {
|
message ErrorMessage {
|
||||||
enum ErrorReason {
|
enum ErrorReason {
|
||||||
reserved = 0;
|
custReserved = 0;
|
||||||
initVersionNotSupported = 1;
|
initVersionNotSupported = 1;
|
||||||
initServerFull = 2;
|
initServerFull = 2;
|
||||||
initAuthFailure = 3;
|
initAuthFailure = 3;
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# QMake pro-file for PokerTH
|
||||||
|
|
||||||
|
!c++11 {
|
||||||
|
system( $$QMAKE_CXX -dumpversion | grep -e "^6.[0-9]" > /dev/null ) {
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 5) | equals(QT_MAJOR_VERSION, 5) {
|
||||||
|
CONFIG += c++11
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
equals(QT_MAJOR_VERSION, 4) : greaterThan(QT_MINOR_VERSION, 7) {
|
||||||
|
CONFIG += "c++11"
|
||||||
|
QMAKE_CXXFLAGS += "-std=gnu++11"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
error (QT must be greater and 4.8+)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c++11 {
|
||||||
|
!system( $$QMAKE_CXX -dumpversion | grep -e "^6.[0-9]" > /dev/null ) {
|
||||||
|
equals(QT_MAJOR_VERSION, 4) : greaterThan(QT_MINOR_VERSION, 7) {
|
||||||
|
QMAKE_CXXFLAGS += "-std=gnu++11"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-1
@@ -17,6 +17,9 @@ DEFINES += ENABLE_IPV6 TIXML_USE_STL
|
|||||||
QT -= core gui
|
QT -= core gui
|
||||||
#PRECOMPILED_HEADER = src/pch_lib.h
|
#PRECOMPILED_HEADER = src/pch_lib.h
|
||||||
|
|
||||||
|
# Check for c++11
|
||||||
|
include(pokerth_common.pro)
|
||||||
|
|
||||||
INCLUDEPATH += . \
|
INCLUDEPATH += . \
|
||||||
src
|
src
|
||||||
|
|
||||||
@@ -57,7 +60,7 @@ mac{
|
|||||||
CONFIG += x86_64
|
CONFIG += x86_64
|
||||||
CONFIG -= x86
|
CONFIG -= x86
|
||||||
CONFIG -= ppc
|
CONFIG -= ppc
|
||||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
|
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12
|
||||||
QMAKE_CXXFLAGS -= -std=gnu++0x
|
QMAKE_CXXFLAGS -= -std=gnu++0x
|
||||||
|
|
||||||
# for universal-compilation on PPC-Mac uncomment the following line
|
# for universal-compilation on PPC-Mac uncomment the following line
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
# Check for c++11
|
||||||
|
include(pokerth_common.pro)
|
||||||
|
|
||||||
|
# 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/asyncdbplayerlastgames.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/asyncdbplayerlastgames.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
|
||||||
|
}
|
||||||
+50
-17
@@ -26,6 +26,9 @@ DEFINES += ENABLE_IPV6 TIXML_USE_STL BOOST_FILESYSTEM_DEPRECATED
|
|||||||
DEFINES += PREFIX=\"$${PREFIX}\"
|
DEFINES += PREFIX=\"$${PREFIX}\"
|
||||||
TARGET = pokerth
|
TARGET = pokerth
|
||||||
|
|
||||||
|
# Check for c++11
|
||||||
|
include(pokerth_common.pro)
|
||||||
|
|
||||||
# PRECOMPILED_HEADER = src/pch_game.h
|
# PRECOMPILED_HEADER = src/pch_game.h
|
||||||
|
|
||||||
android{
|
android{
|
||||||
@@ -408,7 +411,8 @@ unix:!mac {
|
|||||||
LIBPATH += $${PREFIX}/lib /opt/gsasl/lib
|
LIBPATH += $${PREFIX}/lib /opt/gsasl/lib
|
||||||
LIB_DIRS = $${PREFIX}/lib \
|
LIB_DIRS = $${PREFIX}/lib \
|
||||||
$${PREFIX}/lib64 \
|
$${PREFIX}/lib64 \
|
||||||
$$system(qmake -query QT_INSTALL_LIBS)
|
$${PREFIX}/lib/x86_64-linux-gnu \
|
||||||
|
$$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
}
|
}
|
||||||
android{
|
android{
|
||||||
LIBPATH += $${PREFIX}/lib/armv7
|
LIBPATH += $${PREFIX}/lib/armv7
|
||||||
@@ -426,8 +430,10 @@ unix:!mac {
|
|||||||
boost_system-mt
|
boost_system-mt
|
||||||
BOOST_RANDOM = boost_random \
|
BOOST_RANDOM = boost_random \
|
||||||
boost_random-mt
|
boost_random-mt
|
||||||
|
BOOST_CHRONO = boost_chrono \
|
||||||
|
boost_chrono-mt
|
||||||
|
|
||||||
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system(qmake -query QT_INSTALL_LIBS)
|
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
# to override the default '/usr' pass PREFIX
|
# to override the default '/usr' pass PREFIX
|
||||||
# variable to qmake.
|
# variable to qmake.
|
||||||
for(dir, LIB_DIRS):exists($$dir) {
|
for(dir, LIB_DIRS):exists($$dir) {
|
||||||
@@ -481,15 +487,37 @@ unix:!mac {
|
|||||||
message("Found $$lib")
|
message("Found $$lib")
|
||||||
BOOST_SYS = -l$$lib
|
BOOST_SYS = -l$$lib
|
||||||
}
|
}
|
||||||
|
!c++11 {
|
||||||
|
for(lib, BOOST_CHRONO):exists($${dir}/lib$${lib}.so*) {
|
||||||
|
message("Found $$lib")
|
||||||
|
BOOST_CHRONO = -l$$lib
|
||||||
|
}
|
||||||
|
for(lib, BOOST_CHRONO):exists($${dir}/lib$${lib}.a) {
|
||||||
|
message("Found $$lib")
|
||||||
|
BOOST_CHRONO = -l$$lib
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
!android{
|
!android{
|
||||||
BOOST_LIBS = $$BOOST_THREAD \
|
c++11 {
|
||||||
|
BOOST_LIBS = $$BOOST_THREAD \
|
||||||
$$BOOST_FS \
|
$$BOOST_FS \
|
||||||
$$BOOST_IOSTREAMS \
|
$$BOOST_IOSTREAMS \
|
||||||
$$BOOST_REGEX \
|
$$BOOST_REGEX \
|
||||||
$$BOOST_RANDOM \
|
$$BOOST_RANDOM \
|
||||||
$$BOOST_SYS
|
$$BOOST_SYS
|
||||||
!count(BOOST_LIBS, 6):error("Unable to find boost libraries in PREFIX=$${PREFIX}")
|
!count(BOOST_LIBS, 6):error("Unable to find boost libraries in PREFIX=$${PREFIX}")
|
||||||
|
}
|
||||||
|
!c++11 {
|
||||||
|
BOOST_LIBS = $$BOOST_THREAD \
|
||||||
|
$$BOOST_FS \
|
||||||
|
$$BOOST_IOSTREAMS \
|
||||||
|
$$BOOST_REGEX \
|
||||||
|
$$BOOST_RANDOM \
|
||||||
|
$$$$BOOST_SYS \
|
||||||
|
$$BOOST_CHRONO
|
||||||
|
!count(BOOST_LIBS, 7):error("Unable to find boost libraries in PREFIX=$${PREFIX}")
|
||||||
|
}
|
||||||
if($$system(sdl-config --version)):error("sdl-config not found in PATH - libSDL_mixer, libSDL are required!")
|
if($$system(sdl-config --version)):error("sdl-config not found in PATH - libSDL_mixer, libSDL are required!")
|
||||||
UNAME = $$system(uname -s)
|
UNAME = $$system(uname -s)
|
||||||
BSD = $$find(UNAME, "BSD")
|
BSD = $$find(UNAME, "BSD")
|
||||||
@@ -548,7 +576,7 @@ mac {
|
|||||||
CONFIG += x86_64
|
CONFIG += x86_64
|
||||||
CONFIG -= x86
|
CONFIG -= x86
|
||||||
CONFIG -= ppc
|
CONFIG -= ppc
|
||||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
|
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12
|
||||||
QMAKE_CXXFLAGS -= -std=gnu++0x
|
QMAKE_CXXFLAGS -= -std=gnu++0x
|
||||||
|
|
||||||
# workaround for problems with boost_filesystem exceptions
|
# workaround for problems with boost_filesystem exceptions
|
||||||
@@ -560,19 +588,18 @@ mac {
|
|||||||
LIBPATH += lib
|
LIBPATH += lib
|
||||||
|
|
||||||
# QT dynamic linked framework (see also mac_post_make.sh)
|
# QT dynamic linked framework (see also mac_post_make.sh)
|
||||||
|
LIBS += -F /Library/Frameworks
|
||||||
LIBS += -framework \
|
LIBS += -framework \
|
||||||
QtCore
|
QtCore
|
||||||
LIBS += -framework \
|
LIBS += -framework \
|
||||||
QtGui
|
QtGui
|
||||||
|
LIBS += -framework \
|
||||||
# SDL and SDL_mixer come as frameworks
|
SDL
|
||||||
LIBS += -framework \
|
LIBS += -framework \
|
||||||
SDL
|
SDL_mixer
|
||||||
LIBS += -framework \
|
|
||||||
SDL_mixer
|
|
||||||
|
|
||||||
# make sure you have an x86_64 version of boost
|
# make sure you have an x86_64 version of boost
|
||||||
LIBS += /usr/local/lib/libboost_thread.a
|
LIBS += /usr/local/lib/libboost_thread-mt.a
|
||||||
LIBS += /usr/local/lib/libboost_filesystem.a
|
LIBS += /usr/local/lib/libboost_filesystem.a
|
||||||
LIBS += /usr/local/lib/libboost_regex.a
|
LIBS += /usr/local/lib/libboost_regex.a
|
||||||
LIBS += /usr/local/lib/libboost_random.a
|
LIBS += /usr/local/lib/libboost_random.a
|
||||||
@@ -588,20 +615,26 @@ mac {
|
|||||||
-lprotobuf \
|
-lprotobuf \
|
||||||
-lz \
|
-lz \
|
||||||
-framework \
|
-framework \
|
||||||
Carbon
|
Cocoa
|
||||||
|
|
||||||
# set the application icon
|
# set the application icon
|
||||||
RC_FILE = pokerth.icns
|
RC_FILE = pokerth.icns
|
||||||
LIBPATH += /Developer/SDKs/MacOSX10.6.sdk/usr/lib
|
|
||||||
INCLUDEPATH += /Developer/SDKs/MacOSX10.6.sdk/usr/include/
|
LIBPATH += /usr/local/lib
|
||||||
INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers
|
LIBPATH += /usr/local/opt/openssl/lib
|
||||||
INCLUDEPATH += /Library/Frameworks/SDL_mixer.framework/Headers
|
LIBPATH += /usr/local/opt/tinyxml/lib
|
||||||
|
LIBPATH += /usr/local/opt/protobuf/lib
|
||||||
INCLUDEPATH += /usr/local/include
|
INCLUDEPATH += /usr/local/include
|
||||||
|
INCLUDEPATH += /usr/local/opt/openssl/include
|
||||||
|
INCLUDEPATH += /usr/local/opt/tinyxml/include
|
||||||
|
INCLUDEPATH += /usr/local/opt/protobuf/include
|
||||||
|
INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers
|
||||||
|
INCLUDEPATH += /Library/Frameworks/SDL_mixer.framework/Headers
|
||||||
}
|
}
|
||||||
OTHER_FILES += docs/infomessage-id-desc.txt
|
OTHER_FILES += docs/infomessage-id-desc.txt
|
||||||
official_server {
|
official_server {
|
||||||
LIBPATH += pkth_stat/daemon_lib/lib
|
LIBPATH += pkth_stat/daemon_lib/lib
|
||||||
LIBS += -lpokerth_closed \
|
LIBS += -lpokerth_dbofficial \
|
||||||
-lmysqlpp
|
-lmysqlpp
|
||||||
DEFINES += POKERTH_OFFICIAL_SERVER
|
DEFINES += POKERTH_OFFICIAL_SERVER
|
||||||
}
|
}
|
||||||
|
|||||||
+50
-7
@@ -17,6 +17,9 @@ DEFINES += ENABLE_IPV6 TIXML_USE_STL BOOST_FILESYSTEM_DEPRECATED
|
|||||||
QT -= core gui
|
QT -= core gui
|
||||||
#PRECOMPILED_HEADER = src/pch_lib.h
|
#PRECOMPILED_HEADER = src/pch_lib.h
|
||||||
|
|
||||||
|
# Check for c++11
|
||||||
|
include(pokerth_common.pro)
|
||||||
|
|
||||||
INCLUDEPATH += . \
|
INCLUDEPATH += . \
|
||||||
src \
|
src \
|
||||||
src/engine \
|
src/engine \
|
||||||
@@ -226,9 +229,49 @@ android|android_test{
|
|||||||
SOURCES += src/engine/local_engine/tools_android.cpp
|
SOURCES += src/engine/local_engine/tools_android.cpp
|
||||||
}
|
}
|
||||||
|
|
||||||
official_server{
|
official_server:!win32:!gui_800x480:!client:{
|
||||||
INCLUDEPATH += pkth_stat/daemon_lib/src
|
# INCLUDEPATH += pkth_stat/daemon_lib/src # note: relict from former official/closed db build
|
||||||
DEFINES += POKERTH_OFFICIAL_SERVER
|
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{
|
win32{
|
||||||
@@ -251,17 +294,17 @@ mac{
|
|||||||
CONFIG += x86_64
|
CONFIG += x86_64
|
||||||
CONFIG -= x86
|
CONFIG -= x86
|
||||||
CONFIG -= ppc
|
CONFIG -= ppc
|
||||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
|
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12
|
||||||
QMAKE_CXXFLAGS -= -std=gnu++0x
|
QMAKE_CXXFLAGS -= -std=gnu++0x
|
||||||
|
|
||||||
# for universal-compilation on PPC-Mac uncomment the following line
|
# for universal-compilation on PPC-Mac uncomment the following line
|
||||||
# on Intel-Mac you have to comment this line out or build will fail.
|
# on Intel-Mac you have to comment this line out or build will fail.
|
||||||
# QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk/
|
# QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk/
|
||||||
|
LIBPATH += /usr/local/opt/openssl/lib
|
||||||
INCLUDEPATH += /Developer/SDKs/MacOSX10.6.sdk/usr/include/
|
INCLUDEPATH += /usr/local/opt/openssl/include
|
||||||
INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers
|
|
||||||
INCLUDEPATH += /Library/Frameworks/SDL_mixer.framework/Headers
|
|
||||||
INCLUDEPATH += /usr/local/include
|
INCLUDEPATH += /usr/local/include
|
||||||
|
INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers
|
||||||
|
INCLUDEPATH += /Library/Frameworks/SDL_mixer.framework/Headers
|
||||||
}
|
}
|
||||||
|
|
||||||
android{
|
android{
|
||||||
|
|||||||
+14
-1
@@ -17,6 +17,9 @@ QT -= core \
|
|||||||
gui
|
gui
|
||||||
# PRECOMPILED_HEADER = src/pch_lib.h
|
# PRECOMPILED_HEADER = src/pch_lib.h
|
||||||
|
|
||||||
|
# Check for c++11
|
||||||
|
include(pokerth_common.pro)
|
||||||
|
|
||||||
INCLUDEPATH += . \
|
INCLUDEPATH += . \
|
||||||
src
|
src
|
||||||
DEPENDPATH += . \
|
DEPENDPATH += . \
|
||||||
@@ -31,19 +34,29 @@ SOURCES += src/third_party/protobuf/pokerth.pb.cc \
|
|||||||
win32 {
|
win32 {
|
||||||
DEFINES += CURL_STATICLIB
|
DEFINES += CURL_STATICLIB
|
||||||
DEFINES += _WIN32_WINNT=0x0501
|
DEFINES += _WIN32_WINNT=0x0501
|
||||||
|
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
unix : !mac {
|
unix : !mac {
|
||||||
INCLUDEPATH += $${PREFIX}/include
|
INCLUDEPATH += $${PREFIX}/include
|
||||||
system(protoc pokerth.proto --cpp_out=src/third_party/protobuf)
|
system(protoc pokerth.proto --cpp_out=src/third_party/protobuf)
|
||||||
system(protoc chatcleaner.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)
|
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 {
|
mac {
|
||||||
# make it x86_64 only
|
# make it x86_64 only
|
||||||
CONFIG += x86_64
|
CONFIG += x86_64
|
||||||
CONFIG -= x86
|
CONFIG -= x86
|
||||||
CONFIG -= ppc
|
CONFIG -= ppc
|
||||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
|
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12
|
||||||
|
|
||||||
# for universal-compilation on PPC-Mac uncomment the following line
|
# for universal-compilation on PPC-Mac uncomment the following line
|
||||||
# on Intel-Mac you have to comment this line out or build will fail.
|
# on Intel-Mac you have to comment this line out or build will fail.
|
||||||
|
|||||||
+32
-8
@@ -19,6 +19,9 @@ DEFINES += PREFIX=\"$${PREFIX}\"
|
|||||||
QT -= core gui
|
QT -= core gui
|
||||||
#PRECOMPILED_HEADER = src/pch_lib.h
|
#PRECOMPILED_HEADER = src/pch_lib.h
|
||||||
|
|
||||||
|
# Check for c++11
|
||||||
|
include(pokerth_common.pro)
|
||||||
|
|
||||||
INCLUDEPATH += . \
|
INCLUDEPATH += . \
|
||||||
src \
|
src \
|
||||||
src/engine \
|
src/engine \
|
||||||
@@ -175,7 +178,9 @@ unix : !mac {
|
|||||||
|
|
||||||
LIBPATH += lib $${PREFIX}/lib /opt/gsasl/lib
|
LIBPATH += lib $${PREFIX}/lib /opt/gsasl/lib
|
||||||
INCLUDEPATH += $${PREFIX}/include
|
INCLUDEPATH += $${PREFIX}/include
|
||||||
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system(qmake -query QT_INSTALL_LIBS)
|
# see issue https://github.com/pokerth/pokerth/issues/282
|
||||||
|
INCLUDEPATH += $${PREFIX}/include/libircclient
|
||||||
|
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
BOOST_FS = boost_filesystem boost_filesystem-mt
|
BOOST_FS = boost_filesystem boost_filesystem-mt
|
||||||
BOOST_THREAD = boost_thread boost_thread-mt
|
BOOST_THREAD = boost_thread boost_thread-mt
|
||||||
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
|
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
|
||||||
@@ -183,9 +188,10 @@ unix : !mac {
|
|||||||
BOOST_SYS = boost_system boost_system-mt
|
BOOST_SYS = boost_system boost_system-mt
|
||||||
BOOST_REGEX = boost_regex boost_regex-mt
|
BOOST_REGEX = boost_regex boost_regex-mt
|
||||||
BOOST_RANDOM = boost_random boost_random-mt
|
BOOST_RANDOM = boost_random boost_random-mt
|
||||||
|
BOOST_CHRONO = boost_chrono boost_chrono-mt
|
||||||
|
|
||||||
#
|
#
|
||||||
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system(qmake -query QT_INSTALL_LIBS)
|
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||||
# to override the default '/usr' pass PREFIX
|
# to override the default '/usr' pass PREFIX
|
||||||
# variable to qmake.
|
# variable to qmake.
|
||||||
#
|
#
|
||||||
@@ -247,11 +253,29 @@ unix : !mac {
|
|||||||
message("Found $$lib")
|
message("Found $$lib")
|
||||||
BOOST_SYS = -l$$lib
|
BOOST_SYS = -l$$lib
|
||||||
}
|
}
|
||||||
|
!c++11 {
|
||||||
|
for(lib, BOOST_CHRONO):exists($${dir}/lib$${lib}.so*) {
|
||||||
|
message("Found $$lib")
|
||||||
|
BOOST_CHRONO = -l$$lib
|
||||||
|
}
|
||||||
|
for(lib, BOOST_CHRONO):exists($${dir}/lib$${lib}.a) {
|
||||||
|
message("Found $$lib")
|
||||||
|
BOOST_CHRONO = -l$$lib
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BOOST_LIBS = $$BOOST_THREAD $$BOOST_FS $$BOOST_PROGRAM_OPTIONS $$BOOST_IOSTREAMS $$BOOST_REGEX $$BOOST_RANDOM $$BOOST_SYS
|
c++11 {
|
||||||
!count(BOOST_LIBS, 7){
|
BOOST_LIBS = $$BOOST_THREAD $$BOOST_FS $$BOOST_PROGRAM_OPTIONS $$BOOST_IOSTREAMS $$BOOST_REGEX $$BOOST_RANDOM $$BOOST_SYS
|
||||||
error("Unable to find boost libraries in PREFIX=$${PREFIX}")
|
!count(BOOST_LIBS, 7){
|
||||||
|
error("Unable to find boost libraries in PREFIX=$${PREFIX}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
!c++11 {
|
||||||
|
BOOST_LIBS = $$BOOST_THREAD $$BOOST_FS $$BOOST_PROGRAM_OPTIONS $$BOOST_IOSTREAMS $$BOOST_REGEX $$BOOST_RANDOM $$BOOST_SYS $$BOOST_CHRONO
|
||||||
|
!count(BOOST_LIBS, 8){
|
||||||
|
error("Unable to find boost libraries in PREFIX=$${PREFIX}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UNAME = $$system(uname -s)
|
UNAME = $$system(uname -s)
|
||||||
@@ -286,7 +310,7 @@ mac {
|
|||||||
CONFIG += x86_64
|
CONFIG += x86_64
|
||||||
CONFIG -= x86
|
CONFIG -= x86
|
||||||
CONFIG -= ppc
|
CONFIG -= ppc
|
||||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
|
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12
|
||||||
QMAKE_CXXFLAGS -= -std=gnu++0x
|
QMAKE_CXXFLAGS -= -std=gnu++0x
|
||||||
|
|
||||||
# workaround for problems with boost_filesystem exceptions
|
# workaround for problems with boost_filesystem exceptions
|
||||||
@@ -298,7 +322,7 @@ mac {
|
|||||||
|
|
||||||
LIBPATH += lib
|
LIBPATH += lib
|
||||||
# make sure you have an x86_64 version of boost
|
# make sure you have an x86_64 version of boost
|
||||||
LIBS += /usr/local/lib/libboost_thread.a
|
LIBS += /usr/local/lib/libboost_thread-mt.a
|
||||||
LIBS += /usr/local/lib/libboost_filesystem.a
|
LIBS += /usr/local/lib/libboost_filesystem.a
|
||||||
LIBS += /usr/local/lib/libboost_regex.a
|
LIBS += /usr/local/lib/libboost_regex.a
|
||||||
LIBS += /usr/local/lib/libboost_random.a
|
LIBS += /usr/local/lib/libboost_random.a
|
||||||
@@ -320,7 +344,7 @@ mac {
|
|||||||
|
|
||||||
official_server {
|
official_server {
|
||||||
LIBPATH += pkth_stat/daemon_lib/lib
|
LIBPATH += pkth_stat/daemon_lib/lib
|
||||||
LIBS += -lpokerth_closed -lmysqlpp
|
LIBS += -lpokerth_dbofficial -lmysqlpp
|
||||||
DEFINES += POKERTH_OFFICIAL_SERVER
|
DEFINES += POKERTH_OFFICIAL_SERVER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,11 +39,13 @@ class BadWordCheck: public QObject
|
|||||||
public:
|
public:
|
||||||
BadWordCheck();
|
BadWordCheck();
|
||||||
|
|
||||||
void setBadWords(QStringList bw) {
|
void setBadWords(QStringList bw)
|
||||||
|
{
|
||||||
badWords = bw;
|
badWords = bw;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBadWordsException(QStringList bwe) {
|
void setBadWordsException(QStringList bwe)
|
||||||
|
{
|
||||||
badWordsException = bwe;
|
badWordsException = bwe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ class CapsFloodCheck: public QObject
|
|||||||
public:
|
public:
|
||||||
CapsFloodCheck();
|
CapsFloodCheck();
|
||||||
|
|
||||||
void setCapsNumberToTrigger(int n) {
|
void setCapsNumberToTrigger(int n)
|
||||||
|
{
|
||||||
capsNumberToTrigger = n;
|
capsNumberToTrigger = n;
|
||||||
}
|
}
|
||||||
bool run(QString);
|
bool run(QString);
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ public:
|
|||||||
|
|
||||||
~CleanerConfig();
|
~CleanerConfig();
|
||||||
|
|
||||||
std::string getConfigFileName() const {
|
std::string getConfigFileName() const
|
||||||
|
{
|
||||||
return configFileName;
|
return configFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ class LetterRepeatingCheck: public QObject
|
|||||||
public:
|
public:
|
||||||
LetterRepeatingCheck();
|
LetterRepeatingCheck();
|
||||||
|
|
||||||
void setLetterNumberToTrigger(int n) {
|
void setLetterNumberToTrigger(int n)
|
||||||
|
{
|
||||||
letterNumberToTrigger = n;
|
letterNumberToTrigger = n;
|
||||||
}
|
}
|
||||||
bool run(QString);
|
bool run(QString);
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ public:
|
|||||||
TextFloodCheck();
|
TextFloodCheck();
|
||||||
~TextFloodCheck();
|
~TextFloodCheck();
|
||||||
|
|
||||||
void setTextFloodLevelToTrigger(int level) {
|
void setTextFloodLevelToTrigger(int level)
|
||||||
|
{
|
||||||
textFloodLevelToTrigger = level;
|
textFloodLevelToTrigger = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,10 +39,12 @@ class UrlCheck: public QObject
|
|||||||
public:
|
public:
|
||||||
UrlCheck();
|
UrlCheck();
|
||||||
|
|
||||||
void setUrlStrings(QStringList us) {
|
void setUrlStrings(QStringList us)
|
||||||
|
{
|
||||||
urlStrings = us;
|
urlStrings = us;
|
||||||
}
|
}
|
||||||
void setUrlExceptionStrings(QStringList ues) {
|
void setUrlExceptionStrings(QStringList ues)
|
||||||
|
{
|
||||||
urlExceptionStrings = ues;
|
urlExceptionStrings = ues;
|
||||||
}
|
}
|
||||||
bool run(QString);
|
bool run(QString);
|
||||||
|
|||||||
@@ -311,6 +311,9 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
|
|||||||
configList.push_back(ConfigInfo("DBServerDatabaseName", CONFIG_TYPE_STRING, "pokerth"));
|
configList.push_back(ConfigInfo("DBServerDatabaseName", CONFIG_TYPE_STRING, "pokerth"));
|
||||||
configList.push_back(ConfigInfo("DBServerEncryptionKey", CONFIG_TYPE_STRING, ""));
|
configList.push_back(ConfigInfo("DBServerEncryptionKey", CONFIG_TYPE_STRING, ""));
|
||||||
configList.push_back(ConfigInfo("GameNameBadWordList", CONFIG_TYPE_STRING_LIST, "Regex"));
|
configList.push_back(ConfigInfo("GameNameBadWordList", CONFIG_TYPE_STRING_LIST, "Regex"));
|
||||||
|
configList.push_back(ConfigInfo("ServerRestrictGuestLogin", CONFIG_TYPE_INT, "0"));
|
||||||
|
configList.push_back(ConfigInfo("ServerLimitRankNum", CONFIG_TYPE_INT, "4"));
|
||||||
|
configList.push_back(ConfigInfo("ServerLimitRankPeriod", CONFIG_TYPE_INT, "60"));
|
||||||
|
|
||||||
//fill tempList firstTime
|
//fill tempList firstTime
|
||||||
configBufferList = configList;
|
configBufferList = configList;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ using namespace std;
|
|||||||
using namespace boost::filesystem;
|
using namespace boost::filesystem;
|
||||||
|
|
||||||
struct AvatarFileState {
|
struct AvatarFileState {
|
||||||
ifstream inputStream;
|
std::ifstream inputStream;
|
||||||
};
|
};
|
||||||
|
|
||||||
AvatarManager::AvatarManager(bool useExternalServer, const std::string &externalServerAddress,
|
AvatarManager::AvatarManager(bool useExternalServer, const std::string &externalServerAddress,
|
||||||
@@ -363,7 +363,7 @@ AvatarManager::StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFil
|
|||||||
path tmpPath(cacheDir);
|
path tmpPath(cacheDir);
|
||||||
tmpPath /= (md5buf.ToString() + ext);
|
tmpPath /= (md5buf.ToString() + ext);
|
||||||
string fileName(tmpPath.file_string());
|
string fileName(tmpPath.file_string());
|
||||||
ofstream o(fileName.c_str(), ios_base::out | ios_base::binary | ios_base::trunc);
|
std::ofstream o(fileName.c_str(), ios_base::out | ios_base::binary | ios_base::trunc);
|
||||||
if (!o.fail()) {
|
if (!o.fail()) {
|
||||||
o.write((const char *)data, size);
|
o.write((const char *)data, size);
|
||||||
o.close();
|
o.close();
|
||||||
|
|||||||
@@ -291,22 +291,33 @@ CryptHelper::AES128Encrypt(const unsigned char *keyData, unsigned keySize, const
|
|||||||
outCipher.resize(cipherSize);
|
outCipher.resize(cipherSize);
|
||||||
|
|
||||||
#ifdef HAVE_OPENSSL
|
#ifdef HAVE_OPENSSL
|
||||||
EVP_CIPHER_CTX encryptCtx;
|
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
EVP_CIPHER_CTX_init(&encryptCtx);
|
EVP_CIPHER_CTX *encryptCtx = EVP_CIPHER_CTX_new();
|
||||||
|
#else
|
||||||
|
EVP_CIPHER_CTX _encryptCtx;
|
||||||
|
EVP_CIPHER_CTX *encryptCtx;
|
||||||
|
encryptCtx = &_encryptCtx;
|
||||||
|
#endif // OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
|
|
||||||
|
EVP_CIPHER_CTX_init(encryptCtx);
|
||||||
int outCipherSize = cipherSize;
|
int outCipherSize = cipherSize;
|
||||||
|
|
||||||
int success = EVP_EncryptInit(&encryptCtx, EVP_aes_128_cbc(), key, iv);
|
int success = EVP_EncryptInit(encryptCtx, EVP_aes_128_cbc(), key, iv);
|
||||||
EVP_CIPHER_CTX_set_padding(&encryptCtx, 0);
|
EVP_CIPHER_CTX_set_padding(encryptCtx, 0);
|
||||||
if (success) {
|
if (success) {
|
||||||
success = EVP_EncryptUpdate(&encryptCtx, &outCipher[0], &outCipherSize, paddedPlainStr, paddedPlainSize);
|
success = EVP_EncryptUpdate(encryptCtx, &outCipher[0], &outCipherSize, paddedPlainStr, paddedPlainSize);
|
||||||
|
|
||||||
if (success && outCipherSize) {
|
if (success && outCipherSize) {
|
||||||
// Since padding is off, this will not modify the cipher. However, parameters need to be set.
|
// Since padding is off, this will not modify the cipher. However, parameters need to be set.
|
||||||
EVP_EncryptFinal(&encryptCtx, &outCipher[0], &outCipherSize);
|
EVP_EncryptFinal(encryptCtx, &outCipher[0], &outCipherSize);
|
||||||
retVal = true;
|
retVal = true;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
outCipher.clear();
|
outCipher.clear();
|
||||||
|
|
||||||
|
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
|
EVP_CIPHER_CTX_free(encryptCtx);
|
||||||
|
#endif // OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
#else
|
#else
|
||||||
gcry_cipher_hd_t hd;
|
gcry_cipher_hd_t hd;
|
||||||
gcry_error_t err = gcry_cipher_open(&hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC, 0);
|
gcry_error_t err = gcry_cipher_open(&hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC, 0);
|
||||||
@@ -338,22 +349,33 @@ CryptHelper::AES128Decrypt(const unsigned char *keyData, unsigned keySize, const
|
|||||||
BytesToKey(keyData, keySize, key, iv);
|
BytesToKey(keyData, keySize, key, iv);
|
||||||
outPlain.resize(cipherSize);
|
outPlain.resize(cipherSize);
|
||||||
#ifdef HAVE_OPENSSL
|
#ifdef HAVE_OPENSSL
|
||||||
EVP_CIPHER_CTX decryptCtx;
|
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
EVP_CIPHER_CTX_init(&decryptCtx);
|
EVP_CIPHER_CTX *decryptCtx = EVP_CIPHER_CTX_new();
|
||||||
|
#else
|
||||||
|
EVP_CIPHER_CTX _decryptCtx;
|
||||||
|
EVP_CIPHER_CTX *decryptCtx;
|
||||||
|
decryptCtx = &_decryptCtx;
|
||||||
|
#endif // OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
|
|
||||||
|
EVP_CIPHER_CTX_init(decryptCtx);
|
||||||
int outPlainSize = cipherSize;
|
int outPlainSize = cipherSize;
|
||||||
|
|
||||||
int success = EVP_DecryptInit(&decryptCtx, EVP_aes_128_cbc(), key, iv);
|
int success = EVP_DecryptInit(decryptCtx, EVP_aes_128_cbc(), key, iv);
|
||||||
EVP_CIPHER_CTX_set_padding(&decryptCtx, 0);
|
EVP_CIPHER_CTX_set_padding(decryptCtx, 0);
|
||||||
if (success) {
|
if (success) {
|
||||||
success = EVP_DecryptUpdate(&decryptCtx, (unsigned char *)&outPlain[0], &outPlainSize, cipher, cipherSize);
|
success = EVP_DecryptUpdate(decryptCtx, (unsigned char *)&outPlain[0], &outPlainSize, cipher, cipherSize);
|
||||||
|
|
||||||
if (success && outPlainSize) {
|
if (success && outPlainSize) {
|
||||||
// Since padding is off, this will not modify the plain text. However, parameters need to be set.
|
// Since padding is off, this will not modify the plain text. However, parameters need to be set.
|
||||||
EVP_DecryptFinal(&decryptCtx, (unsigned char *)outPlain.c_str(), &outPlainSize);
|
EVP_DecryptFinal(decryptCtx, (unsigned char *)outPlain.c_str(), &outPlainSize);
|
||||||
retVal = true;
|
retVal = true;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
outPlain.clear();
|
outPlain.clear();
|
||||||
|
|
||||||
|
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
|
EVP_CIPHER_CTX_free(decryptCtx);
|
||||||
|
#endif // OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||||
#else
|
#else
|
||||||
gcry_cipher_hd_t hd;
|
gcry_cipher_hd_t hd;
|
||||||
gcry_error_t err = gcry_cipher_open(&hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC, 0);
|
gcry_error_t err = gcry_cipher_open(&hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC, 0);
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ void
|
|||||||
internal_log_err(const string &msg)
|
internal_log_err(const string &msg)
|
||||||
{
|
{
|
||||||
if (!g_logFile.empty()) {
|
if (!g_logFile.empty()) {
|
||||||
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
std::ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
||||||
if (!o.fail()) {
|
if (!o.fail()) {
|
||||||
o << second_clock::local_time() << " ERR: " << msg;
|
o << second_clock::local_time() << " ERR: " << msg;
|
||||||
o.flush();
|
o.flush();
|
||||||
@@ -80,7 +80,7 @@ internal_log_msg(const std::string &msg)
|
|||||||
{
|
{
|
||||||
if (g_logLevel) {
|
if (g_logLevel) {
|
||||||
if (!g_logFile.empty()) {
|
if (!g_logFile.empty()) {
|
||||||
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
std::ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
||||||
if (!o.fail())
|
if (!o.fail())
|
||||||
o << second_clock::local_time() << " MSG: " << msg;
|
o << second_clock::local_time() << " MSG: " << msg;
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ internal_log_level(const std::string &msg, int logLevel)
|
|||||||
{
|
{
|
||||||
if (g_logLevel >= logLevel) {
|
if (g_logLevel >= logLevel) {
|
||||||
if (!g_logFile.empty()) {
|
if (!g_logFile.empty()) {
|
||||||
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
std::ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
||||||
if (!o.fail())
|
if (!o.fail())
|
||||||
o << second_clock::local_time() << " OUT: " << msg;
|
o << second_clock::local_time() << " OUT: " << msg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ class ThreadStarter
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ThreadStarter(Thread &thread) : m_thread(thread) {}
|
ThreadStarter(Thread &thread) : m_thread(thread) {}
|
||||||
void operator()() {
|
void operator()()
|
||||||
|
{
|
||||||
m_thread.MainWrapper();
|
m_thread.MainWrapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,10 +43,12 @@ public:
|
|||||||
PokerTHException(const char *sourcefile, int sourceline, int errorId, int osErrorCode);
|
PokerTHException(const char *sourcefile, int sourceline, int errorId, int osErrorCode);
|
||||||
virtual ~PokerTHException() throw();
|
virtual ~PokerTHException() throw();
|
||||||
|
|
||||||
int GetErrorId() const {
|
int GetErrorId() const
|
||||||
|
{
|
||||||
return m_errorId;
|
return m_errorId;
|
||||||
}
|
}
|
||||||
int GetOsErrorCode() const {
|
int GetOsErrorCode() const
|
||||||
|
{
|
||||||
return m_osErrorCode;
|
return m_osErrorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,11 @@ ServerDBGeneric::SetGamePlayerPlace(unsigned /*requestId*/, DB_id /*playerId*/,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ServerDBGeneric::SetPlayerLastGames(unsigned /*requestId*/, DB_id /*playerId*/, std::vector<long> /*last_games*/, std::string /*playerIp*/)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ServerDBGeneric::EndGame(unsigned /*requestId*/)
|
ServerDBGeneric::EndGame(unsigned /*requestId*/)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
typedef unsigned DB_id;
|
typedef unsigned DB_id;
|
||||||
#define DB_ID_INVALID 0
|
#define DB_ID_INVALID 0
|
||||||
@@ -45,6 +46,8 @@ struct DBPlayerData {
|
|||||||
std::string secret;
|
std::string secret;
|
||||||
std::string country;
|
std::string country;
|
||||||
std::string last_login;
|
std::string last_login;
|
||||||
|
std::string last_games;
|
||||||
|
std::string last_ip;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public:
|
|||||||
|
|
||||||
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName);
|
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName);
|
||||||
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place);
|
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place);
|
||||||
|
virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> last_games, std::string playerIp);
|
||||||
virtual void EndGame(unsigned requestId);
|
virtual void EndGame(unsigned requestId);
|
||||||
|
|
||||||
virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId);
|
virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId);
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
#include <db/serverdbcallback.h>
|
#include <db/serverdbcallback.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
typedef std::list<DB_id> db_list;
|
typedef std::list<DB_id> db_list;
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ public:
|
|||||||
|
|
||||||
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName) = 0;
|
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName) = 0;
|
||||||
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place) = 0;
|
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place) = 0;
|
||||||
|
virtual void SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> last_games, std::string playerIp) = 0;
|
||||||
virtual void EndGame(unsigned requestId) = 0;
|
virtual void EndGame(unsigned requestId) = 0;
|
||||||
|
|
||||||
virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId) = 0;
|
virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId) = 0;
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ public:
|
|||||||
|
|
||||||
virtual void AsyncCreateGame(unsigned /*requestId*/, const std::string &/*gameName*/) {}
|
virtual void AsyncCreateGame(unsigned /*requestId*/, const std::string &/*gameName*/) {}
|
||||||
virtual void SetGamePlayerPlace(unsigned /*requestId*/, DB_id /*playerId*/, unsigned /*place*/) {}
|
virtual void SetGamePlayerPlace(unsigned /*requestId*/, DB_id /*playerId*/, unsigned /*place*/) {}
|
||||||
|
virtual void SetPlayerLastGames(unsigned /*requestId*/, DB_id /*playerId*/, std::vector<long> /*last_games*/, std::string /*playerIp*/) {}
|
||||||
virtual void EndGame(unsigned /*requestId*/) {}
|
virtual void EndGame(unsigned /*requestId*/) {}
|
||||||
|
|
||||||
virtual void AsyncReportAvatar(unsigned /*requestId*/, unsigned /*replyId*/, DB_id /*reportedPlayerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/, DB_id * /*byPlayerId*/) {}
|
virtual void AsyncReportAvatar(unsigned /*requestId*/, unsigned /*replyId*/, DB_id /*reportedPlayerId*/, const std::string &/*avatarHash*/, const std::string &/*avatarType*/, DB_id * /*byPlayerId*/) {}
|
||||||
|
|||||||
@@ -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."));
|
||||||
|
}
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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> ¶ms)
|
||||||
|
: 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][7];
|
||||||
|
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]);
|
||||||
|
mysqlpp::String last_games(result[0][5]);
|
||||||
|
mysqlpp::String last_ip(result[0][6]);
|
||||||
|
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);
|
||||||
|
if (!last_games.is_null())
|
||||||
|
last_games.to_string(tmpData->last_games);
|
||||||
|
if (!last_ip.is_null())
|
||||||
|
last_ip.to_string(tmpData->last_ip);
|
||||||
|
|
||||||
|
service.post(boost::bind(&ServerDBCallback::PlayerLoginSuccess, &cb, GetId(), tmpData));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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()));
|
||||||
|
}
|
||||||
@@ -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> ¶ms);
|
||||||
|
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
|
||||||
@@ -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> ¶ms)
|
||||||
|
: 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()));
|
||||||
|
}
|
||||||
@@ -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> ¶ms);
|
||||||
|
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
|
||||||
@@ -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> ¶ms)
|
||||||
|
: 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));
|
||||||
|
}
|
||||||
@@ -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> ¶ms);
|
||||||
|
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
|
||||||
@@ -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> ¶ms)
|
||||||
|
: 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()));
|
||||||
|
}
|
||||||
@@ -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> ¶ms);
|
||||||
|
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
|
||||||
@@ -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> ¶ms)
|
||||||
|
: 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).
|
||||||
|
}
|
||||||
@@ -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> ¶ms);
|
||||||
|
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
|
||||||
@@ -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> ¶ms)
|
||||||
|
: 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."));
|
||||||
|
}
|
||||||
@@ -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> ¶ms);
|
||||||
|
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
|
||||||
@@ -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> ¶ms)
|
||||||
|
: 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."));
|
||||||
|
}
|
||||||
@@ -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> ¶ms);
|
||||||
|
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
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* PokerTH - The open source texas holdem engine *
|
||||||
|
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||||
|
* *
|
||||||
|
* This program is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU Affero General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU Affero General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU Affero General Public License *
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* Additional permission under GNU AGPL version 3 section 7 *
|
||||||
|
* *
|
||||||
|
* If you modify this program, or any covered work, by linking or *
|
||||||
|
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||||
|
* modified version of that library), containing parts covered by the *
|
||||||
|
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||||
|
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||||
|
* permission to convey the resulting work. *
|
||||||
|
* Corresponding Source for a non-source form of such a combination *
|
||||||
|
* shall include the source code for the parts of OpenSSL used as well *
|
||||||
|
* as that of the covered work. *
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <dbofficial/asyncdbplayerlastgames.h>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
AsyncDBPlayerLastGames::AsyncDBPlayerLastGames(unsigned queryId, const string &preparedName, const list<string> ¶ms)
|
||||||
|
: SingleAsyncDBQuery(queryId, preparedName, params)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AsyncDBPlayerLastGames::~AsyncDBPlayerLastGames()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AsyncDBPlayerLastGames::HandleResult(mysqlpp::Query &/*query*/, DBIdManager &/*idManager*/, mysqlpp::StoreQueryResult &/*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||||
|
{
|
||||||
|
// This query does not produce a result.
|
||||||
|
HandleError(service, cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AsyncDBPlayerLastGames::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AsyncDBPlayerLastGames::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* PokerTH - The open source texas holdem engine *
|
||||||
|
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||||
|
* *
|
||||||
|
* This program is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU Affero General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU Affero General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU Affero General Public License *
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* Additional permission under GNU AGPL version 3 section 7 *
|
||||||
|
* *
|
||||||
|
* If you modify this program, or any covered work, by linking or *
|
||||||
|
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||||
|
* modified version of that library), containing parts covered by the *
|
||||||
|
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||||
|
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||||
|
* permission to convey the resulting work. *
|
||||||
|
* Corresponding Source for a non-source form of such a combination *
|
||||||
|
* shall include the source code for the parts of OpenSSL used as well *
|
||||||
|
* as that of the covered work. *
|
||||||
|
*****************************************************************************/
|
||||||
|
/* Async database update to block a player. */
|
||||||
|
|
||||||
|
#ifndef _ASYNCDBPLAYERLASTGAMES_H_
|
||||||
|
#define _ASYNCDBPLAYERLASTGAMES_H_
|
||||||
|
|
||||||
|
#include <dbofficial/singleasyncdbquery.h>
|
||||||
|
|
||||||
|
|
||||||
|
class AsyncDBPlayerLastGames : public SingleAsyncDBQuery
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AsyncDBPlayerLastGames(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||||
|
virtual ~AsyncDBPlayerLastGames();
|
||||||
|
|
||||||
|
virtual void Init(DBIdManager& /*idManager*/) {}
|
||||||
|
|
||||||
|
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||||
|
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||||
|
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||||
|
|
||||||
|
virtual bool RequiresResultSet() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -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()
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -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> ¶ms) const = 0;
|
||||||
|
virtual void SetParams(const std::list<std::string> ¶ms) = 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
|
||||||
@@ -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> ¶ms)
|
||||||
|
: 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));
|
||||||
|
}
|
||||||
@@ -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> ¶ms);
|
||||||
|
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
|
||||||
@@ -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> ¶ms)
|
||||||
|
: 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));
|
||||||
|
}
|
||||||
@@ -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> ¶ms);
|
||||||
|
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
|
||||||
@@ -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> ¶ms)
|
||||||
|
: 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).
|
||||||
|
}
|
||||||
@@ -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> ¶ms);
|
||||||
|
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
|
||||||
@@ -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> ¶ms) const
|
||||||
|
{
|
||||||
|
(*m_currentQuery)->GetParams(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CompositeAsyncDBQuery::SetParams(const std::list<std::string> ¶ms)
|
||||||
|
{
|
||||||
|
(*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;
|
||||||
|
}
|
||||||
@@ -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> ¶ms) const;
|
||||||
|
virtual void SetParams(const std::list<std::string> ¶ms);
|
||||||
|
|
||||||
|
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
|
||||||
@@ -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. *
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#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_PLAYER_COL_LASTGAMES "last_games"
|
||||||
|
#define DB_TABLE_PLAYER_COL_LASTIP "last_ip"
|
||||||
|
|
||||||
|
#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
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -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_
|
||||||
@@ -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()
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -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));
|
||||||
|
}
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,603 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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/asyncdbplayerlastgames.h>
|
||||||
|
#include <dbofficial/compositeasyncdbquery.h>
|
||||||
|
#include <dbofficial/db_table_defs.h>
|
||||||
|
#include <ctime>
|
||||||
|
#include <sstream>
|
||||||
|
#include <mysql++.h>
|
||||||
|
|
||||||
|
#include <core/loghelper.h> // @TODO: remove in productive
|
||||||
|
|
||||||
|
#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"
|
||||||
|
#define QUERY_PLAYER_LASTGAMES_PREPARE "player_lastgames_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::SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> last_games, std::string playerIp)
|
||||||
|
{
|
||||||
|
LOG_ERROR("ServerDBThread::SetPlayerLastGames() entered.");
|
||||||
|
|
||||||
|
std::ostringstream oss;
|
||||||
|
std::copy(last_games.begin(), last_games.end(), std::ostream_iterator<int>(oss, ","));
|
||||||
|
std::string last_gamesFieldValue( oss.str() );
|
||||||
|
list<string> params;
|
||||||
|
ostringstream paramStream;
|
||||||
|
params.push_back(last_gamesFieldValue);
|
||||||
|
params.push_back(playerIp);
|
||||||
|
paramStream << playerId;
|
||||||
|
params.push_back(paramStream.str());
|
||||||
|
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||||
|
new AsyncDBPlayerLastGames(
|
||||||
|
requestId,
|
||||||
|
QUERY_PLAYER_LASTGAMES_PREPARE,
|
||||||
|
params));
|
||||||
|
{
|
||||||
|
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||||
|
m_asyncQueue.push(asyncQuery);
|
||||||
|
}
|
||||||
|
LOG_ERROR("Query posted.");
|
||||||
|
m_semaphore.post();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
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_LASTGAMES ", " DB_TABLE_PLAYER_COL_LASTIP ", " DB_TABLE_PLAYER_COL_ACTIVE " FROM " DB_TABLE_PLAYER " WHERE " DB_TABLE_PLAYER_COL_USERNAME " = ?";
|
||||||
|
|
||||||
|
mysqlpp::Query prepareAvatarBlacklist = m_connData->conn.query();
|
||||||
|
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 " = ?";
|
||||||
|
mysqlpp::Query preparePlayerLastGames = m_connData->conn.query();
|
||||||
|
preparePlayerLastGames
|
||||||
|
<< "PREPARE " QUERY_PLAYER_LASTGAMES_PREPARE " FROM " << mysqlpp::quote
|
||||||
|
<< "UPDATE " DB_TABLE_PLAYER " SET " DB_TABLE_PLAYER_COL_LASTGAMES " = ?, " DB_TABLE_PLAYER_COL_LASTIP " = ? WHERE " DB_TABLE_PLAYER_COL_ID " = ?";
|
||||||
|
if (!prepareNick.exec() || !prepareAvatarBlacklist.exec() || !prepareLogin.exec() || !prepareCreateGame.exec()
|
||||||
|
|| !prepareEndGame.exec() || !prepareRelation.exec() || !prepareScore.exec() || !prepareReportAvatar.exec()
|
||||||
|
|| !prepareReportGame.exec() || !prepareAdminPlayer.exec() || !prepareBlockPlayer.exec() || !preparePlayerLastGames.exec()) {
|
||||||
|
string tmpError = string(prepareNick.error()) + prepareAvatarBlacklist.error() + prepareLogin.error() + prepareCreateGame.error() +
|
||||||
|
prepareEndGame.error() + prepareRelation.error() + prepareScore.error() + prepareReportAvatar.error() +
|
||||||
|
prepareReportGame.error() + prepareAdminPlayer.error() + prepareBlockPlayer.error() + preparePlayerLastGames.error();
|
||||||
|
m_connData->conn.disconnect();
|
||||||
|
m_ioService->post(boost::bind(&ServerDBCallback::ConnectFailed, &m_callback, tmpError));
|
||||||
|
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()) {
|
||||||
|
string tmpError = paramQuery.error();
|
||||||
|
m_connData->conn.disconnect();
|
||||||
|
m_ioService->post(boost::bind(&ServerDBCallback::QueryError, &m_callback, tmpError));
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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 SetPlayerLastGames(unsigned requestId, DB_id playerId, std::vector<long> last_games, std::string playerIp);
|
||||||
|
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
|
||||||
@@ -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> ¶ms)
|
||||||
|
: 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> ¶ms) const
|
||||||
|
{
|
||||||
|
params = m_params;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SingleAsyncDBQuery::SetParams(const std::list<std::string> ¶ms)
|
||||||
|
{
|
||||||
|
m_params = params;
|
||||||
|
}
|
||||||
@@ -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> ¶ms);
|
||||||
|
virtual ~SingleAsyncDBQuery();
|
||||||
|
|
||||||
|
unsigned GetId() const;
|
||||||
|
virtual std::string GetPreparedName() const;
|
||||||
|
virtual void GetParams(std::list<std::string> ¶ms) const;
|
||||||
|
virtual void SetParams(const std::list<std::string> ¶ms);
|
||||||
|
|
||||||
|
virtual bool Next()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
const unsigned m_id;
|
||||||
|
std::string m_preparedName;
|
||||||
|
std::list<std::string> m_params;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* PokerTH - The open source texas holdem engine *
|
||||||
|
* Copyright (C) 2006-2012 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. *
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
// Connectivity test program for PokerTH
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <boost/program_options.hpp>
|
||||||
|
#include <boost/thread.hpp>
|
||||||
|
#include <boost/nondet_random.hpp>
|
||||||
|
#include <boost/random/uniform_int.hpp>
|
||||||
|
#include <boost/random/variate_generator.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
namespace po = boost::program_options;
|
||||||
|
boost::thread_specific_ptr<boost::random_device> g_rand_state;
|
||||||
|
|
||||||
|
struct nondet_rng : std::unary_function<unsigned, unsigned> {
|
||||||
|
boost::random_device &_state;
|
||||||
|
unsigned operator()(unsigned i)
|
||||||
|
{
|
||||||
|
boost::uniform_int<> rng(0, i - 1);
|
||||||
|
return rng(_state);
|
||||||
|
}
|
||||||
|
nondet_rng(boost::random_device &state) : _state(state) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Check command line options.
|
||||||
|
po::options_description desc("Allowed options");
|
||||||
|
desc.add_options()
|
||||||
|
("help,h", "produce help message")
|
||||||
|
("num,n", po::value<int>(), "set num of deals")
|
||||||
|
;
|
||||||
|
|
||||||
|
po::variables_map vm;
|
||||||
|
po::store(po::parse_command_line(argc, argv, desc), vm);
|
||||||
|
po::notify(vm);
|
||||||
|
|
||||||
|
if (vm.count("help")) {
|
||||||
|
cout << desc << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (!vm.count("num")) {
|
||||||
|
cout << "Missing option!" << endl << desc << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int num = vm["num"].as<int>();
|
||||||
|
const int NumCards = 52;
|
||||||
|
|
||||||
|
for(int i=0; i<num;i++){
|
||||||
|
// shuffle cards
|
||||||
|
int cardsArray[NumCards] = {
|
||||||
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||||
|
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
||||||
|
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
|
||||||
|
30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
|
||||||
|
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
|
||||||
|
50, 51
|
||||||
|
};
|
||||||
|
if (!g_rand_state.get()) {
|
||||||
|
g_rand_state.reset(new boost::random_device);
|
||||||
|
}
|
||||||
|
nondet_rng rand(*g_rand_state);
|
||||||
|
random_shuffle(&cardsArray[0], &cardsArray[NumCards], rand);
|
||||||
|
|
||||||
|
ostringstream oss("");
|
||||||
|
for (int temp = 0; temp < NumCards; temp++){
|
||||||
|
if(temp > 0) cout << ",";
|
||||||
|
cout << cardsArray[temp];
|
||||||
|
}
|
||||||
|
cout << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (...) {
|
||||||
|
cout << "Exception caught" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
virtual void collectSets() =0;
|
virtual void collectSets() =0;
|
||||||
virtual void collectPot() =0;
|
virtual void collectPot() =0;
|
||||||
|
|
||||||
virtual void distributePot(unsigned) =0;
|
virtual void distributePot(unsigned) =0;
|
||||||
virtual void determinePlayerNeedToShowCards() =0;
|
virtual void determinePlayerNeedToShowCards() =0;
|
||||||
|
|
||||||
virtual std::list<unsigned> getWinners() const =0;
|
virtual std::list<unsigned> getWinners() const =0;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
virtual ~EngineFactory();
|
virtual ~EngineFactory();
|
||||||
|
|
||||||
virtual boost::shared_ptr<HandInterface> createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) =0;
|
virtual boost::shared_ptr<HandInterface> createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC) =0;
|
||||||
virtual boost::shared_ptr<BoardInterface> createBoard() =0;
|
virtual boost::shared_ptr<BoardInterface> createBoard() =0;
|
||||||
virtual boost::shared_ptr<PlayerInterface> createPlayer(int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, bool sotS, int mB) =0;
|
virtual boost::shared_ptr<PlayerInterface> createPlayer(int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, bool sotS, int mB) =0;
|
||||||
virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface *hi, unsigned dP, int sB) =0;
|
virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface *hi, unsigned dP, int sB) =0;
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -77,7 +77,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
|||||||
throw LocalException(__FILE__, __LINE__, ERR_DEALER_NOT_FOUND);
|
throw LocalException(__FILE__, __LINE__, ERR_DEALER_NOT_FOUND);
|
||||||
|
|
||||||
// create board
|
// create board
|
||||||
currentBoard = myFactory->createBoard();
|
currentBoard = myFactory->createBoard();
|
||||||
|
|
||||||
// create player lists
|
// create player lists
|
||||||
seatsList.reset(new std::list<boost::shared_ptr<PlayerInterface> >);
|
seatsList.reset(new std::list<boost::shared_ptr<PlayerInterface> >);
|
||||||
|
|||||||
+32
-16
@@ -63,60 +63,76 @@ public:
|
|||||||
boost::shared_ptr<HandInterface> getCurrentHand();
|
boost::shared_ptr<HandInterface> getCurrentHand();
|
||||||
const boost::shared_ptr<HandInterface> getCurrentHand() const;
|
const boost::shared_ptr<HandInterface> getCurrentHand() const;
|
||||||
|
|
||||||
PlayerList getSeatsList() const {
|
PlayerList getSeatsList() const
|
||||||
|
{
|
||||||
return seatsList;
|
return seatsList;
|
||||||
}
|
}
|
||||||
PlayerList getActivePlayerList() const {
|
PlayerList getActivePlayerList() const
|
||||||
|
{
|
||||||
return activePlayerList;
|
return activePlayerList;
|
||||||
}
|
}
|
||||||
PlayerList getRunningPlayerList() const {
|
PlayerList getRunningPlayerList() const
|
||||||
|
{
|
||||||
return runningPlayerList;
|
return runningPlayerList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStartQuantityPlayers(int theValue) {
|
void setStartQuantityPlayers(int theValue)
|
||||||
|
{
|
||||||
startQuantityPlayers = theValue;
|
startQuantityPlayers = theValue;
|
||||||
}
|
}
|
||||||
int getStartQuantityPlayers() const {
|
int getStartQuantityPlayers() const
|
||||||
|
{
|
||||||
return startQuantityPlayers;
|
return startQuantityPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStartSmallBlind(int theValue) {
|
void setStartSmallBlind(int theValue)
|
||||||
|
{
|
||||||
startSmallBlind = theValue;
|
startSmallBlind = theValue;
|
||||||
}
|
}
|
||||||
int getStartSmallBlind() const {
|
int getStartSmallBlind() const
|
||||||
|
{
|
||||||
return startSmallBlind;
|
return startSmallBlind;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStartCash(int theValue) {
|
void setStartCash(int theValue)
|
||||||
|
{
|
||||||
startCash = theValue;
|
startCash = theValue;
|
||||||
}
|
}
|
||||||
int getStartCash() const {
|
int getStartCash() const
|
||||||
|
{
|
||||||
return startCash;
|
return startCash;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getMyGameID() const {
|
int getMyGameID() const
|
||||||
|
{
|
||||||
return myGameID;
|
return myGameID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCurrentSmallBlind(int theValue) {
|
void setCurrentSmallBlind(int theValue)
|
||||||
|
{
|
||||||
currentSmallBlind = theValue;
|
currentSmallBlind = theValue;
|
||||||
}
|
}
|
||||||
int getCurrentSmallBlind() const {
|
int getCurrentSmallBlind() const
|
||||||
|
{
|
||||||
return currentSmallBlind;
|
return currentSmallBlind;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCurrentHandID(int theValue) {
|
void setCurrentHandID(int theValue)
|
||||||
|
{
|
||||||
currentHandID = theValue;
|
currentHandID = theValue;
|
||||||
}
|
}
|
||||||
int getCurrentHandID() const {
|
int getCurrentHandID() const
|
||||||
|
{
|
||||||
return currentHandID;
|
return currentHandID;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned getDealerPosition() const {
|
unsigned getDealerPosition() const
|
||||||
|
{
|
||||||
return dealerPosition;
|
return dealerPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void replaceDealer(unsigned oldDealer, unsigned newDealer) {
|
void replaceDealer(unsigned oldDealer, unsigned newDealer)
|
||||||
|
{
|
||||||
if (dealerPosition == oldDealer)
|
if (dealerPosition == oldDealer)
|
||||||
dealerPosition = newDealer;
|
dealerPosition = newDealer;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ int CardsValue::holeCardsClass(int one, int two)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch((one-1)%13+2) {
|
switch((one-1)%13+2) {
|
||||||
//Ass
|
//Ass
|
||||||
case 14: {
|
case 14: {
|
||||||
if((one-1)/13 == (two-1)/13) {
|
if((one-1)/13 == (two-1)/13) {
|
||||||
switch((one-1)%13-(two-1)%13) {
|
switch((one-1)%13-(two-1)%13) {
|
||||||
@@ -756,7 +756,7 @@ std::string CardsValue::determineHandName(int myCardsValueInt, PlayerList active
|
|||||||
std::string handName;
|
std::string handName;
|
||||||
|
|
||||||
switch(myCardsValueInt/100000000) {
|
switch(myCardsValueInt/100000000) {
|
||||||
// Royal Flush
|
// Royal Flush
|
||||||
case 9: {
|
case 9: {
|
||||||
|
|
||||||
handName = *cardStringIt_c;
|
handName = *cardStringIt_c;
|
||||||
@@ -1161,8 +1161,8 @@ std::string CardsValue::determineHandName(int myCardsValueInt, PlayerList active
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default: {
|
||||||
{}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return handName;
|
return handName;
|
||||||
@@ -1191,11 +1191,11 @@ std::list<std::string> CardsValue::translateCardsValueCode(int cardsValueCode)
|
|||||||
|
|
||||||
switch (firstPart) {
|
switch (firstPart) {
|
||||||
|
|
||||||
// Royal Flush
|
// Royal Flush
|
||||||
case 9:
|
case 9:
|
||||||
cardString.push_back("Royal Flush");
|
cardString.push_back("Royal Flush");
|
||||||
break;
|
break;
|
||||||
// Straight Flush
|
// Straight Flush
|
||||||
case 8: {
|
case 8: {
|
||||||
cardString.push_back("Straight Flush, ");
|
cardString.push_back("Straight Flush, ");
|
||||||
switch(secondPart) {
|
switch(secondPart) {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
LocalBeRo::LocalBeRo(HandInterface* hi, unsigned dP, int sB, GameState gS)
|
LocalBeRo::LocalBeRo(HandInterface* hi, unsigned dP, int sB, GameState gS)
|
||||||
: BeRoInterface(), myHand(hi), myBeRoID(gS), dealerPosition(dP), smallBlindPosition(0), smallBlindPositionId(0), bigBlindPositionId(0), smallBlind(sB), highestSet(0), minimumRaise(2*sB), fullBetRule(false), firstRun(true), firstRunGui(true), firstRound(true), firstHeadsUpRound(true), currentPlayersTurnId(0), firstRoundLastPlayersTurnId(0), logBoardCardsDone(false)
|
: BeRoInterface(), myHand(hi), myBeRoID(gS), dealerPosition(dP), smallBlindPosition(0), smallBlindPositionId(0), bigBlindPositionId(0), smallBlind(sB), highestSet(0), minimumRaise(2*sB), fullBetRule(false), firstRun(true), firstRunGui(true), firstRound(true), firstHeadsUpRound(true), currentPlayersTurnId(0), firstRoundLastPlayersTurnId(0), logBoardCardsDone(false)
|
||||||
{
|
{
|
||||||
currentPlayersTurnIt = myHand->getRunningPlayerList()->begin();
|
currentPlayersTurnIt = myHand->getRunningPlayerList()->begin();
|
||||||
lastPlayersTurnIt = myHand->getRunningPlayerList()->begin();
|
lastPlayersTurnIt = myHand->getRunningPlayerList()->begin();
|
||||||
|
|||||||
@@ -44,28 +44,34 @@ public:
|
|||||||
LocalBeRo(HandInterface* hi, unsigned dP, int sB, GameState gS);
|
LocalBeRo(HandInterface* hi, unsigned dP, int sB, GameState gS);
|
||||||
~LocalBeRo();
|
~LocalBeRo();
|
||||||
|
|
||||||
GameState getMyBeRoID() const {
|
GameState getMyBeRoID() const
|
||||||
|
{
|
||||||
return myBeRoID;
|
return myBeRoID;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getHighestCardsValue() const;
|
int getHighestCardsValue() const;
|
||||||
void setHighestCardsValue(int /*theValue*/) { }
|
void setHighestCardsValue(int /*theValue*/) { }
|
||||||
|
|
||||||
void setMinimumRaise ( int theValue ) {
|
void setMinimumRaise ( int theValue )
|
||||||
|
{
|
||||||
minimumRaise = theValue;
|
minimumRaise = theValue;
|
||||||
}
|
}
|
||||||
int getMinimumRaise() const {
|
int getMinimumRaise() const
|
||||||
|
{
|
||||||
return minimumRaise;
|
return minimumRaise;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFullBetRule ( bool theValue ) {
|
void setFullBetRule ( bool theValue )
|
||||||
|
{
|
||||||
fullBetRule = theValue;
|
fullBetRule = theValue;
|
||||||
}
|
}
|
||||||
bool getFullBetRule() const {
|
bool getFullBetRule() const
|
||||||
|
{
|
||||||
return fullBetRule;
|
return fullBetRule;
|
||||||
}
|
}
|
||||||
|
|
||||||
void skipFirstRunGui() {
|
void skipFirstRunGui()
|
||||||
|
{
|
||||||
firstRunGui = false;
|
firstRunGui = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,89 +83,113 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
HandInterface* getMyHand() const {
|
HandInterface* getMyHand() const
|
||||||
|
{
|
||||||
return myHand;
|
return myHand;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned getDealerPosition() const {
|
unsigned getDealerPosition() const
|
||||||
|
{
|
||||||
return dealerPosition;
|
return dealerPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCurrentPlayersTurnId(unsigned theValue) {
|
void setCurrentPlayersTurnId(unsigned theValue)
|
||||||
|
{
|
||||||
currentPlayersTurnId = theValue;
|
currentPlayersTurnId = theValue;
|
||||||
}
|
}
|
||||||
unsigned getCurrentPlayersTurnId() const {
|
unsigned getCurrentPlayersTurnId() const
|
||||||
|
{
|
||||||
return currentPlayersTurnId;
|
return currentPlayersTurnId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFirstRoundLastPlayersTurnId(unsigned theValue) {
|
void setFirstRoundLastPlayersTurnId(unsigned theValue)
|
||||||
|
{
|
||||||
firstRoundLastPlayersTurnId = theValue;
|
firstRoundLastPlayersTurnId = theValue;
|
||||||
}
|
}
|
||||||
unsigned getFirstRoundLastPlayersTurnId() const {
|
unsigned getFirstRoundLastPlayersTurnId() const
|
||||||
|
{
|
||||||
return firstRoundLastPlayersTurnId;
|
return firstRoundLastPlayersTurnId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCurrentPlayersTurnIt(PlayerListIterator theValue) {
|
void setCurrentPlayersTurnIt(PlayerListIterator theValue)
|
||||||
|
{
|
||||||
currentPlayersTurnIt = theValue;
|
currentPlayersTurnIt = theValue;
|
||||||
}
|
}
|
||||||
PlayerListIterator getCurrentPlayersTurnIt() const {
|
PlayerListIterator getCurrentPlayersTurnIt() const
|
||||||
|
{
|
||||||
return currentPlayersTurnIt;
|
return currentPlayersTurnIt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLastPlayersTurnIt(PlayerListIterator theValue) {
|
void setLastPlayersTurnIt(PlayerListIterator theValue)
|
||||||
|
{
|
||||||
lastPlayersTurnIt = theValue;
|
lastPlayersTurnIt = theValue;
|
||||||
}
|
}
|
||||||
PlayerListIterator getLastPlayersTurnIt() const {
|
PlayerListIterator getLastPlayersTurnIt() const
|
||||||
|
{
|
||||||
return lastPlayersTurnIt;
|
return lastPlayersTurnIt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setHighestSet(int theValue) {
|
void setHighestSet(int theValue)
|
||||||
|
{
|
||||||
highestSet = theValue;
|
highestSet = theValue;
|
||||||
}
|
}
|
||||||
int getHighestSet() const {
|
int getHighestSet() const
|
||||||
|
{
|
||||||
return highestSet;
|
return highestSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFirstRun(bool theValue) {
|
void setFirstRun(bool theValue)
|
||||||
|
{
|
||||||
firstRun = theValue;
|
firstRun = theValue;
|
||||||
}
|
}
|
||||||
bool getFirstRun() const {
|
bool getFirstRun() const
|
||||||
|
{
|
||||||
return firstRun;
|
return firstRun;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFirstRound(bool theValue) {
|
void setFirstRound(bool theValue)
|
||||||
|
{
|
||||||
firstRound = theValue;
|
firstRound = theValue;
|
||||||
}
|
}
|
||||||
bool getFirstRound() const {
|
bool getFirstRound() const
|
||||||
|
{
|
||||||
return firstRound;
|
return firstRound;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSmallBlindPositionId(unsigned theValue) {
|
void setSmallBlindPositionId(unsigned theValue)
|
||||||
|
{
|
||||||
smallBlindPositionId = theValue;
|
smallBlindPositionId = theValue;
|
||||||
}
|
}
|
||||||
unsigned getSmallBlindPositionId() const {
|
unsigned getSmallBlindPositionId() const
|
||||||
|
{
|
||||||
return smallBlindPositionId;
|
return smallBlindPositionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBigBlindPositionId(unsigned theValue) {
|
void setBigBlindPositionId(unsigned theValue)
|
||||||
|
{
|
||||||
bigBlindPositionId = theValue;
|
bigBlindPositionId = theValue;
|
||||||
}
|
}
|
||||||
unsigned getBigBlindPositionId() const {
|
unsigned getBigBlindPositionId() const
|
||||||
|
{
|
||||||
return bigBlindPositionId;
|
return bigBlindPositionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void setSmallBlindPosition(int theValue) {
|
void setSmallBlindPosition(int theValue)
|
||||||
|
{
|
||||||
smallBlindPosition = theValue;
|
smallBlindPosition = theValue;
|
||||||
}
|
}
|
||||||
int getSmallBlindPosition() const {
|
int getSmallBlindPosition() const
|
||||||
|
{
|
||||||
return smallBlindPosition;
|
return smallBlindPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSmallBlind(int theValue) {
|
void setSmallBlind(int theValue)
|
||||||
|
{
|
||||||
smallBlind = theValue;
|
smallBlind = theValue;
|
||||||
}
|
}
|
||||||
int getSmallBlind() const {
|
int getSmallBlind() const
|
||||||
|
{
|
||||||
return smallBlind;
|
return smallBlind;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +201,7 @@ private:
|
|||||||
HandInterface* myHand;
|
HandInterface* myHand;
|
||||||
|
|
||||||
const GameState myBeRoID;
|
const GameState myBeRoID;
|
||||||
unsigned dealerPosition;
|
unsigned dealerPosition;
|
||||||
int smallBlindPosition;
|
int smallBlindPosition;
|
||||||
|
|
||||||
unsigned smallBlindPositionId;
|
unsigned smallBlindPositionId;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ void LocalBeRoPostRiver::postRiverRun()
|
|||||||
getMyHand()->getBoard()->determinePlayerNeedToShowCards();
|
getMyHand()->getBoard()->determinePlayerNeedToShowCards();
|
||||||
|
|
||||||
// Pot-Verteilung
|
// Pot-Verteilung
|
||||||
getMyHand()->getBoard()->distributePot(getDealerPosition());
|
getMyHand()->getBoard()->distributePot(getDealerPosition());
|
||||||
|
|
||||||
//Pot auf 0 setzen
|
//Pot auf 0 setzen
|
||||||
getMyHand()->getBoard()->setPot(0);
|
getMyHand()->getBoard()->setPot(0);
|
||||||
|
|||||||
@@ -44,10 +44,12 @@ public:
|
|||||||
LocalBeRoPostRiver(HandInterface*, int, int);
|
LocalBeRoPostRiver(HandInterface*, int, int);
|
||||||
~LocalBeRoPostRiver();
|
~LocalBeRoPostRiver();
|
||||||
|
|
||||||
void setHighestCardsValue(int theValue) {
|
void setHighestCardsValue(int theValue)
|
||||||
|
{
|
||||||
highestCardsValue = theValue;
|
highestCardsValue = theValue;
|
||||||
}
|
}
|
||||||
int getHighestCardsValue() const {
|
int getHighestCardsValue() const
|
||||||
|
{
|
||||||
return highestCardsValue;
|
return highestCardsValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,57 +45,69 @@ class HandInterface;
|
|||||||
class LocalBoard : public BoardInterface
|
class LocalBoard : public BoardInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LocalBoard();
|
LocalBoard();
|
||||||
~LocalBoard();
|
~LocalBoard();
|
||||||
|
|
||||||
void setPlayerLists(PlayerList, PlayerList, PlayerList);
|
void setPlayerLists(PlayerList, PlayerList, PlayerList);
|
||||||
|
|
||||||
void setMyCards(int* theValue) {
|
void setMyCards(int* theValue)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i<5; i++) myCards[i] = theValue[i];
|
for(i=0; i<5; i++) myCards[i] = theValue[i];
|
||||||
}
|
}
|
||||||
void getMyCards(int* theValue) {
|
void getMyCards(int* theValue)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i<5; i++) theValue[i] = myCards[i];
|
for(i=0; i<5; i++) theValue[i] = myCards[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAllInCondition(bool theValue) {
|
void setAllInCondition(bool theValue)
|
||||||
|
{
|
||||||
allInCondition = theValue;
|
allInCondition = theValue;
|
||||||
}
|
}
|
||||||
void setLastActionPlayerID(unsigned theValue) {
|
void setLastActionPlayerID(unsigned theValue)
|
||||||
|
{
|
||||||
lastActionPlayerID = theValue;
|
lastActionPlayerID = theValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getPot() const {
|
int getPot() const
|
||||||
|
{
|
||||||
return pot;
|
return pot;
|
||||||
}
|
}
|
||||||
void setPot(int theValue) {
|
void setPot(int theValue)
|
||||||
|
{
|
||||||
pot = theValue;
|
pot = theValue;
|
||||||
}
|
}
|
||||||
int getSets() const {
|
int getSets() const
|
||||||
|
{
|
||||||
return sets;
|
return sets;
|
||||||
}
|
}
|
||||||
void setSets(int theValue) {
|
void setSets(int theValue)
|
||||||
|
{
|
||||||
sets = theValue;
|
sets = theValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void collectSets() ;
|
void collectSets() ;
|
||||||
void collectPot() ;
|
void collectPot() ;
|
||||||
|
|
||||||
void distributePot(unsigned dealerPosition);
|
void distributePot(unsigned dealerPosition);
|
||||||
void determinePlayerNeedToShowCards();
|
void determinePlayerNeedToShowCards();
|
||||||
|
|
||||||
std::list<unsigned> getWinners() const {
|
std::list<unsigned> getWinners() const
|
||||||
|
{
|
||||||
return winners;
|
return winners;
|
||||||
}
|
}
|
||||||
void setWinners(const std::list<unsigned> &w) {
|
void setWinners(const std::list<unsigned> &w)
|
||||||
|
{
|
||||||
winners = w;
|
winners = w;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<unsigned> getPlayerNeedToShowCards() const {
|
std::list<unsigned> getPlayerNeedToShowCards() const
|
||||||
|
{
|
||||||
return playerNeedToShowCards;
|
return playerNeedToShowCards;
|
||||||
}
|
}
|
||||||
void setPlayerNeedToShowCards(const std::list<unsigned> &p) {
|
void setPlayerNeedToShowCards(const std::list<unsigned> &p)
|
||||||
|
{
|
||||||
playerNeedToShowCards = p;
|
playerNeedToShowCards = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ LocalEngineFactory::createHand(boost::shared_ptr<EngineFactory> f, GuiInterface
|
|||||||
boost::shared_ptr<BoardInterface>
|
boost::shared_ptr<BoardInterface>
|
||||||
LocalEngineFactory::createBoard()
|
LocalEngineFactory::createBoard()
|
||||||
{
|
{
|
||||||
return boost::shared_ptr<BoardInterface>(new LocalBoard());
|
return boost::shared_ptr<BoardInterface>(new LocalBoard());
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<PlayerInterface>
|
boost::shared_ptr<PlayerInterface>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public:
|
|||||||
~LocalEngineFactory();
|
~LocalEngineFactory();
|
||||||
|
|
||||||
virtual boost::shared_ptr<HandInterface> createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC);
|
virtual boost::shared_ptr<HandInterface> createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC);
|
||||||
virtual boost::shared_ptr<BoardInterface> createBoard();
|
virtual boost::shared_ptr<BoardInterface> createBoard();
|
||||||
virtual boost::shared_ptr<PlayerInterface> createPlayer(int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, bool sotS, int mB);
|
virtual boost::shared_ptr<PlayerInterface> createPlayer(int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, bool sotS, int mB);
|
||||||
virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface *hi, unsigned dP, int sB);
|
virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface *hi, unsigned dP, int sB);
|
||||||
|
|
||||||
|
|||||||
@@ -362,8 +362,8 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
|
|||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default: {
|
||||||
{}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,8 +696,8 @@ void LocalHand::switchRounds()
|
|||||||
myGui->postRiverAnimation1();
|
myGui->postRiverAnimation1();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default: {
|
||||||
{}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,111 +51,142 @@ public:
|
|||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
PlayerList getSeatsList() const {
|
PlayerList getSeatsList() const
|
||||||
|
{
|
||||||
return seatsList;
|
return seatsList;
|
||||||
}
|
}
|
||||||
PlayerList getActivePlayerList() const {
|
PlayerList getActivePlayerList() const
|
||||||
|
{
|
||||||
return activePlayerList;
|
return activePlayerList;
|
||||||
}
|
}
|
||||||
PlayerList getRunningPlayerList() const {
|
PlayerList getRunningPlayerList() const
|
||||||
|
{
|
||||||
return runningPlayerList;
|
return runningPlayerList;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<BoardInterface> getBoard() const {
|
boost::shared_ptr<BoardInterface> getBoard() const
|
||||||
|
{
|
||||||
return myBoard;
|
return myBoard;
|
||||||
}
|
}
|
||||||
boost::shared_ptr<BeRoInterface> getPreflop() const {
|
boost::shared_ptr<BeRoInterface> getPreflop() const
|
||||||
|
{
|
||||||
return myBeRo[GAME_STATE_PREFLOP];
|
return myBeRo[GAME_STATE_PREFLOP];
|
||||||
}
|
}
|
||||||
boost::shared_ptr<BeRoInterface> getFlop() const {
|
boost::shared_ptr<BeRoInterface> getFlop() const
|
||||||
|
{
|
||||||
return myBeRo[GAME_STATE_FLOP];
|
return myBeRo[GAME_STATE_FLOP];
|
||||||
}
|
}
|
||||||
boost::shared_ptr<BeRoInterface> getTurn() const {
|
boost::shared_ptr<BeRoInterface> getTurn() const
|
||||||
|
{
|
||||||
return myBeRo[GAME_STATE_TURN];
|
return myBeRo[GAME_STATE_TURN];
|
||||||
}
|
}
|
||||||
boost::shared_ptr<BeRoInterface> getRiver() const {
|
boost::shared_ptr<BeRoInterface> getRiver() const
|
||||||
|
{
|
||||||
return myBeRo[GAME_STATE_RIVER];
|
return myBeRo[GAME_STATE_RIVER];
|
||||||
}
|
}
|
||||||
GuiInterface* getGuiInterface() const {
|
GuiInterface* getGuiInterface() const
|
||||||
|
{
|
||||||
return myGui;
|
return myGui;
|
||||||
}
|
}
|
||||||
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const {
|
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const
|
||||||
|
{
|
||||||
return myBeRo[currentRound];
|
return myBeRo[currentRound];
|
||||||
}
|
}
|
||||||
|
|
||||||
Log* getLog() const {
|
Log* getLog() const
|
||||||
|
{
|
||||||
return myLog;
|
return myLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyID(int theValue) {
|
void setMyID(int theValue)
|
||||||
|
{
|
||||||
myID = theValue;
|
myID = theValue;
|
||||||
}
|
}
|
||||||
int getMyID() const {
|
int getMyID() const
|
||||||
|
{
|
||||||
return myID;
|
return myID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStartQuantityPlayers(int theValue) {
|
void setStartQuantityPlayers(int theValue)
|
||||||
|
{
|
||||||
startQuantityPlayers = theValue;
|
startQuantityPlayers = theValue;
|
||||||
}
|
}
|
||||||
int getStartQuantityPlayers() const {
|
int getStartQuantityPlayers() const
|
||||||
|
{
|
||||||
return startQuantityPlayers;
|
return startQuantityPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCurrentRound(GameState theValue) {
|
void setCurrentRound(GameState theValue)
|
||||||
|
{
|
||||||
currentRound = theValue;
|
currentRound = theValue;
|
||||||
if(myLog) myLog->setCurrentRound(currentRound);
|
if(myLog) myLog->setCurrentRound(currentRound);
|
||||||
}
|
}
|
||||||
GameState getCurrentRound() const {
|
GameState getCurrentRound() const
|
||||||
|
{
|
||||||
return currentRound;
|
return currentRound;
|
||||||
}
|
}
|
||||||
GameState getRoundBeforePostRiver() const {
|
GameState getRoundBeforePostRiver() const
|
||||||
|
{
|
||||||
return roundBeforePostRiver;
|
return roundBeforePostRiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDealerPosition(int theValue) {
|
void setDealerPosition(int theValue)
|
||||||
|
{
|
||||||
dealerPosition = theValue;
|
dealerPosition = theValue;
|
||||||
}
|
}
|
||||||
int getDealerPosition() const {
|
int getDealerPosition() const
|
||||||
|
{
|
||||||
return dealerPosition;
|
return dealerPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSmallBlind(int theValue) {
|
void setSmallBlind(int theValue)
|
||||||
|
{
|
||||||
smallBlind = theValue;
|
smallBlind = theValue;
|
||||||
}
|
}
|
||||||
int getSmallBlind() const {
|
int getSmallBlind() const
|
||||||
|
{
|
||||||
return smallBlind;
|
return smallBlind;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAllInCondition(bool theValue) {
|
void setAllInCondition(bool theValue)
|
||||||
|
{
|
||||||
allInCondition = theValue;
|
allInCondition = theValue;
|
||||||
}
|
}
|
||||||
bool getAllInCondition() const {
|
bool getAllInCondition() const
|
||||||
|
{
|
||||||
return allInCondition;
|
return allInCondition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStartCash(int theValue) {
|
void setStartCash(int theValue)
|
||||||
|
{
|
||||||
startCash = theValue;
|
startCash = theValue;
|
||||||
}
|
}
|
||||||
int getStartCash() const {
|
int getStartCash() const
|
||||||
|
{
|
||||||
return startCash;
|
return startCash;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPreviousPlayerID(int theValue) {
|
void setPreviousPlayerID(int theValue)
|
||||||
|
{
|
||||||
previousPlayerID = theValue;
|
previousPlayerID = theValue;
|
||||||
}
|
}
|
||||||
int getPreviousPlayerID() const {
|
int getPreviousPlayerID() const
|
||||||
|
{
|
||||||
return previousPlayerID;
|
return previousPlayerID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLastActionPlayerID ( unsigned theValue );
|
void setLastActionPlayerID ( unsigned theValue );
|
||||||
unsigned getLastActionPlayerID() const {
|
unsigned getLastActionPlayerID() const
|
||||||
|
{
|
||||||
return lastActionPlayerID;
|
return lastActionPlayerID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCardsShown(bool theValue) {
|
void setCardsShown(bool theValue)
|
||||||
|
{
|
||||||
cardsShown = theValue;
|
cardsShown = theValue;
|
||||||
}
|
}
|
||||||
bool getCardsShown() const {
|
bool getCardsShown() const
|
||||||
|
{
|
||||||
return cardsShown;
|
return cardsShown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1066,8 +1066,8 @@ void LocalPlayer::action()
|
|||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default: {
|
||||||
{}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// cout << currentHand->getCurrentBeRo()->getMinimumRaise() << endl;
|
// cout << currentHand->getCurrentBeRo()->getMinimumRaise() << endl;
|
||||||
@@ -1365,8 +1365,8 @@ void LocalPlayer::preflopEngine()
|
|||||||
|
|
||||||
if(DEBUG_MODE) {
|
if(DEBUG_MODE) {
|
||||||
switch(myUniqueID) {
|
switch(myUniqueID) {
|
||||||
case 0:
|
case 0: {
|
||||||
{}
|
}
|
||||||
break;
|
break;
|
||||||
case 1: {
|
case 1: {
|
||||||
// player 1
|
// player 1
|
||||||
@@ -1494,8 +1494,8 @@ void LocalPlayer::preflopEngine()
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default: {
|
||||||
{}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1926,8 +1926,8 @@ void LocalPlayer::flopEngine()
|
|||||||
myAction = PLAYER_ACTION_CHECK;
|
myAction = PLAYER_ACTION_CHECK;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default: {
|
||||||
{}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2696,8 +2696,8 @@ void LocalPlayer::turnEngine()
|
|||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default: {
|
||||||
{}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3206,8 +3206,8 @@ void LocalPlayer::riverEngine()
|
|||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default: {
|
||||||
{}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3227,9 +3227,9 @@ void LocalPlayer::evaluation(int bet, int raise)
|
|||||||
int highestSet = currentHand->getCurrentBeRo()->getHighestSet();
|
int highestSet = currentHand->getCurrentBeRo()->getHighestSet();
|
||||||
|
|
||||||
switch(myAction) {
|
switch(myAction) {
|
||||||
// none
|
// none
|
||||||
case 0:
|
case 0: {
|
||||||
{}
|
}
|
||||||
break;
|
break;
|
||||||
// fold
|
// fold
|
||||||
case 1: {
|
case 1: {
|
||||||
@@ -3337,8 +3337,8 @@ void LocalPlayer::evaluation(int bet, int raise)
|
|||||||
case 6: {
|
case 6: {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default: {
|
||||||
{}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentHand->getCurrentBeRo()->setHighestSet(highestSet);
|
currentHand->getCurrentBeRo()->setHighestSet(highestSet);
|
||||||
|
|||||||
@@ -50,129 +50,163 @@ public:
|
|||||||
|
|
||||||
void setHand(HandInterface *);
|
void setHand(HandInterface *);
|
||||||
|
|
||||||
int getMyID() const {
|
int getMyID() const
|
||||||
|
{
|
||||||
return myID;
|
return myID;
|
||||||
}
|
}
|
||||||
unsigned getMyUniqueID() const {
|
unsigned getMyUniqueID() const
|
||||||
|
{
|
||||||
return myUniqueID;
|
return myUniqueID;
|
||||||
}
|
}
|
||||||
void setMyUniqueID(unsigned newId) {
|
void setMyUniqueID(unsigned newId)
|
||||||
|
{
|
||||||
myUniqueID = newId;
|
myUniqueID = newId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyGuid(const std::string &theValue) {
|
void setMyGuid(const std::string &theValue)
|
||||||
|
{
|
||||||
myGuid = theValue;
|
myGuid = theValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getMyGuid() const {
|
std::string getMyGuid() const
|
||||||
|
{
|
||||||
return myGuid;
|
return myGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerType getMyType() const {
|
PlayerType getMyType() const
|
||||||
|
{
|
||||||
return myType;
|
return myType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyDude(int theValue) {
|
void setMyDude(int theValue)
|
||||||
|
{
|
||||||
myDude = theValue;
|
myDude = theValue;
|
||||||
}
|
}
|
||||||
int getMyDude() const {
|
int getMyDude() const
|
||||||
|
{
|
||||||
return myDude;
|
return myDude;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyDude4(int theValue) {
|
void setMyDude4(int theValue)
|
||||||
|
{
|
||||||
myDude4 = theValue;
|
myDude4 = theValue;
|
||||||
}
|
}
|
||||||
int getMyDude4() const {
|
int getMyDude4() const
|
||||||
|
{
|
||||||
return myDude4;
|
return myDude4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyName(const std::string& theValue) {
|
void setMyName(const std::string& theValue)
|
||||||
|
{
|
||||||
myName = theValue;
|
myName = theValue;
|
||||||
}
|
}
|
||||||
std::string getMyName() const {
|
std::string getMyName() const
|
||||||
|
{
|
||||||
return myName;
|
return myName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyAvatar(const std::string& theValue) {
|
void setMyAvatar(const std::string& theValue)
|
||||||
|
{
|
||||||
myAvatar = theValue;
|
myAvatar = theValue;
|
||||||
}
|
}
|
||||||
std::string getMyAvatar() const {
|
std::string getMyAvatar() const
|
||||||
|
{
|
||||||
return myAvatar;
|
return myAvatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyCash(int theValue) {
|
void setMyCash(int theValue)
|
||||||
|
{
|
||||||
myCash = theValue;
|
myCash = theValue;
|
||||||
}
|
}
|
||||||
int getMyCash() const {
|
int getMyCash() const
|
||||||
|
{
|
||||||
return myCash;
|
return myCash;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMySet(int theValue) {
|
void setMySet(int theValue)
|
||||||
|
{
|
||||||
myLastRelativeSet = theValue;
|
myLastRelativeSet = theValue;
|
||||||
mySet += theValue;
|
mySet += theValue;
|
||||||
myCash -= theValue;
|
myCash -= theValue;
|
||||||
}
|
}
|
||||||
void setMySetAbsolute(int theValue) {
|
void setMySetAbsolute(int theValue)
|
||||||
|
{
|
||||||
mySet = theValue;
|
mySet = theValue;
|
||||||
}
|
}
|
||||||
void setMySetNull() {
|
void setMySetNull()
|
||||||
|
{
|
||||||
mySet = 0;
|
mySet = 0;
|
||||||
myLastRelativeSet = 0;
|
myLastRelativeSet = 0;
|
||||||
}
|
}
|
||||||
int getMySet() const {
|
int getMySet() const
|
||||||
|
{
|
||||||
return mySet;
|
return mySet;
|
||||||
}
|
}
|
||||||
int getMyLastRelativeSet() const {
|
int getMyLastRelativeSet() const
|
||||||
|
{
|
||||||
return myLastRelativeSet;
|
return myLastRelativeSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyAction(PlayerAction theValue, bool human = 0) {
|
void setMyAction(PlayerAction theValue, bool human = 0)
|
||||||
|
{
|
||||||
myAction = theValue;
|
myAction = theValue;
|
||||||
// logging for seat 0
|
// logging for seat 0
|
||||||
if(myAction && human) currentHand->getGuiInterface()->logPlayerActionMsg(myName, myAction, myLastRelativeSet);
|
if(myAction && human) currentHand->getGuiInterface()->logPlayerActionMsg(myName, myAction, myLastRelativeSet);
|
||||||
}
|
}
|
||||||
PlayerAction getMyAction() const {
|
PlayerAction getMyAction() const
|
||||||
|
{
|
||||||
return myAction;
|
return myAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyButton(int theValue) {
|
void setMyButton(int theValue)
|
||||||
|
{
|
||||||
myButton = theValue;
|
myButton = theValue;
|
||||||
}
|
}
|
||||||
int getMyButton() const {
|
int getMyButton() const
|
||||||
|
{
|
||||||
return myButton;
|
return myButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyActiveStatus(bool theValue) {
|
void setMyActiveStatus(bool theValue)
|
||||||
|
{
|
||||||
myActiveStatus = theValue;
|
myActiveStatus = theValue;
|
||||||
}
|
}
|
||||||
bool getMyActiveStatus() const {
|
bool getMyActiveStatus() const
|
||||||
|
{
|
||||||
return myActiveStatus;
|
return myActiveStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyStayOnTableStatus(bool theValue) {
|
void setMyStayOnTableStatus(bool theValue)
|
||||||
|
{
|
||||||
myStayOnTableStatus = theValue;
|
myStayOnTableStatus = theValue;
|
||||||
}
|
}
|
||||||
bool getMyStayOnTableStatus() const {
|
bool getMyStayOnTableStatus() const
|
||||||
|
{
|
||||||
return myStayOnTableStatus;
|
return myStayOnTableStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyCards(int* theValue) {
|
void setMyCards(int* theValue)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i<2; i++) myCards[i] = theValue[i];
|
for(i=0; i<2; i++) myCards[i] = theValue[i];
|
||||||
}
|
}
|
||||||
void getMyCards(int* theValue) const {
|
void getMyCards(int* theValue) const
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i<2; i++) theValue[i] = myCards[i];
|
for(i=0; i<2; i++) theValue[i] = myCards[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyTurn(bool theValue) {
|
void setMyTurn(bool theValue)
|
||||||
|
{
|
||||||
myTurn = theValue;
|
myTurn = theValue;
|
||||||
}
|
}
|
||||||
bool getMyTurn() const {
|
bool getMyTurn() const
|
||||||
|
{
|
||||||
return myTurn;
|
return myTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyCardsFlip(bool theValue, int state) {
|
void setMyCardsFlip(bool theValue, int state)
|
||||||
|
{
|
||||||
myCardsFlip = theValue;
|
myCardsFlip = theValue;
|
||||||
// log flipping cards
|
// log flipping cards
|
||||||
if(myCardsFlip) {
|
if(myCardsFlip) {
|
||||||
@@ -191,66 +225,81 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool getMyCardsFlip() const {
|
bool getMyCardsFlip() const
|
||||||
|
{
|
||||||
return myCardsFlip;
|
return myCardsFlip;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyCardsValueInt(int theValue) {
|
void setMyCardsValueInt(int theValue)
|
||||||
|
{
|
||||||
myCardsValueInt = theValue;
|
myCardsValueInt = theValue;
|
||||||
}
|
}
|
||||||
int getMyCardsValueInt() const {
|
int getMyCardsValueInt() const
|
||||||
|
{
|
||||||
return myCardsValueInt;
|
return myCardsValueInt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLogHoleCardsDone(bool theValue) {
|
void setLogHoleCardsDone(bool theValue)
|
||||||
|
{
|
||||||
logHoleCardsDone = theValue;
|
logHoleCardsDone = theValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getLogHoleCardsDone() const {
|
bool getLogHoleCardsDone() const
|
||||||
|
{
|
||||||
return logHoleCardsDone;
|
return logHoleCardsDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyBestHandPosition(int* theValue) {
|
void setMyBestHandPosition(int* theValue)
|
||||||
|
{
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
myBestHandPosition[i] = theValue[i];
|
myBestHandPosition[i] = theValue[i];
|
||||||
}
|
}
|
||||||
void getMyBestHandPosition(int* theValue) const {
|
void getMyBestHandPosition(int* theValue) const
|
||||||
|
{
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
theValue[i] = myBestHandPosition[i];
|
theValue[i] = myBestHandPosition[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyRoundStartCash(int theValue) {
|
void setMyRoundStartCash(int theValue)
|
||||||
|
{
|
||||||
myRoundStartCash = theValue;
|
myRoundStartCash = theValue;
|
||||||
}
|
}
|
||||||
int getMyRoundStartCash() const {
|
int getMyRoundStartCash() const
|
||||||
|
{
|
||||||
return myRoundStartCash;
|
return myRoundStartCash;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLastMoneyWon ( int theValue ) {
|
void setLastMoneyWon ( int theValue )
|
||||||
|
{
|
||||||
lastMoneyWon = theValue;
|
lastMoneyWon = theValue;
|
||||||
}
|
}
|
||||||
int getLastMoneyWon() const {
|
int getLastMoneyWon() const
|
||||||
|
{
|
||||||
return lastMoneyWon;
|
return lastMoneyWon;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyAverageSets(int theValue) {
|
void setMyAverageSets(int theValue)
|
||||||
|
{
|
||||||
myAverageSets[0] = myAverageSets[1];
|
myAverageSets[0] = myAverageSets[1];
|
||||||
myAverageSets[1] = myAverageSets[2];
|
myAverageSets[1] = myAverageSets[2];
|
||||||
myAverageSets[2] = myAverageSets[3];
|
myAverageSets[2] = myAverageSets[3];
|
||||||
myAverageSets[3] = theValue;
|
myAverageSets[3] = theValue;
|
||||||
}
|
}
|
||||||
int getMyAverageSets() const {
|
int getMyAverageSets() const
|
||||||
|
{
|
||||||
return (myAverageSets[0]+myAverageSets[1]+myAverageSets[2]+myAverageSets[3])/4;
|
return (myAverageSets[0]+myAverageSets[1]+myAverageSets[2]+myAverageSets[3])/4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMyAggressive(bool theValue) {
|
void setMyAggressive(bool theValue)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0; i<6; i++) {
|
for(i=0; i<6; i++) {
|
||||||
myAggressive[i] = myAggressive[i+1];
|
myAggressive[i] = myAggressive[i+1];
|
||||||
}
|
}
|
||||||
myAggressive[6] = theValue;
|
myAggressive[6] = theValue;
|
||||||
}
|
}
|
||||||
int getMyAggressive() const {
|
int getMyAggressive() const
|
||||||
|
{
|
||||||
int i, sum = 0;
|
int i, sum = 0;
|
||||||
for(i=0; i<7; i++) {
|
for(i=0; i<7; i++) {
|
||||||
sum += myAggressive[i];
|
sum += myAggressive[i];
|
||||||
@@ -258,17 +307,21 @@ public:
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSBluff ( int theValue ) {
|
void setSBluff ( int theValue )
|
||||||
|
{
|
||||||
sBluff = theValue;
|
sBluff = theValue;
|
||||||
}
|
}
|
||||||
int getSBluff() const {
|
int getSBluff() const
|
||||||
|
{
|
||||||
return sBluff;
|
return sBluff;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSBluffStatus ( bool theValue ) {
|
void setSBluffStatus ( bool theValue )
|
||||||
|
{
|
||||||
sBluffStatus = theValue;
|
sBluffStatus = theValue;
|
||||||
}
|
}
|
||||||
bool getSBluffStatus() const {
|
bool getSBluffStatus() const
|
||||||
|
{
|
||||||
return sBluffStatus;
|
return sBluffStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ boost::thread_specific_ptr<boost::random_device> g_rand_state;
|
|||||||
|
|
||||||
struct nondet_rng : std::unary_function<unsigned, unsigned> {
|
struct nondet_rng : std::unary_function<unsigned, unsigned> {
|
||||||
boost::random_device &_state;
|
boost::random_device &_state;
|
||||||
unsigned operator()(unsigned i) {
|
unsigned operator()(unsigned i)
|
||||||
|
{
|
||||||
boost::uniform_int<> rng(0, i - 1);
|
boost::uniform_int<> rng(0, i - 1);
|
||||||
return rng(_state);
|
return rng(_state);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ boost::thread_specific_ptr<boost::mt19937> g_rand_state;
|
|||||||
|
|
||||||
struct det_rng : std::unary_function<unsigned, unsigned> {
|
struct det_rng : std::unary_function<unsigned, unsigned> {
|
||||||
boost::mt19937 &_state;
|
boost::mt19937 &_state;
|
||||||
unsigned operator()(unsigned i) {
|
unsigned operator()(unsigned i)
|
||||||
|
{
|
||||||
boost::uniform_int<> rng(0, i - 1);
|
boost::uniform_int<> rng(0, i - 1);
|
||||||
return rng(_state);
|
return rng(_state);
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -66,11 +66,13 @@ public:
|
|||||||
void logAfterGame();
|
void logAfterGame();
|
||||||
// void closeLogDbAtExit();
|
// void closeLogDbAtExit();
|
||||||
|
|
||||||
void setCurrentRound(GameState theValue) {
|
void setCurrentRound(GameState theValue)
|
||||||
|
{
|
||||||
currentRound = theValue;
|
currentRound = theValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getMySqliteLogFileName() {
|
std::string getMySqliteLogFileName()
|
||||||
|
{
|
||||||
return mySqliteLogFileName.directory_string();
|
return mySqliteLogFileName.directory_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
ClientBoard::ClientBoard()
|
ClientBoard::ClientBoard()
|
||||||
: pot(0), sets(0), allInCondition(false), lastActionPlayerID(0)
|
: pot(0), sets(0), allInCondition(false), lastActionPlayerID(0)
|
||||||
{
|
{
|
||||||
myCards[0] = myCards[1] = myCards[2] = myCards[3] = myCards[4] = 0;
|
myCards[0] = myCards[1] = myCards[2] = myCards[3] = myCards[4] = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class HandInterface;
|
|||||||
class ClientBoard : public BoardInterface
|
class ClientBoard : public BoardInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ClientBoard();
|
ClientBoard();
|
||||||
~ClientBoard();
|
~ClientBoard();
|
||||||
|
|
||||||
void setPlayerLists(PlayerList, PlayerList, PlayerList);
|
void setPlayerLists(PlayerList, PlayerList, PlayerList);
|
||||||
@@ -63,7 +63,7 @@ public:
|
|||||||
void collectSets();
|
void collectSets();
|
||||||
void collectPot();
|
void collectPot();
|
||||||
|
|
||||||
void distributePot(unsigned);
|
void distributePot(unsigned);
|
||||||
void determinePlayerNeedToShowCards();
|
void determinePlayerNeedToShowCards();
|
||||||
|
|
||||||
std::list<unsigned> getWinners() const;
|
std::list<unsigned> getWinners() const;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ ClientEngineFactory::createHand(boost::shared_ptr<EngineFactory> f, GuiInterface
|
|||||||
boost::shared_ptr<BoardInterface>
|
boost::shared_ptr<BoardInterface>
|
||||||
ClientEngineFactory::createBoard()
|
ClientEngineFactory::createBoard()
|
||||||
{
|
{
|
||||||
return boost::shared_ptr<BoardInterface>(new ClientBoard());
|
return boost::shared_ptr<BoardInterface>(new ClientBoard());
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<PlayerInterface>
|
boost::shared_ptr<PlayerInterface>
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public:
|
|||||||
~ClientEngineFactory();
|
~ClientEngineFactory();
|
||||||
|
|
||||||
virtual boost::shared_ptr<HandInterface> createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC);
|
virtual boost::shared_ptr<HandInterface> createHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost::shared_ptr<BoardInterface> b, Log *l, PlayerList sl, PlayerList apl, PlayerList rpl, int id, int sP, int dP, int sB,int sC);
|
||||||
virtual boost::shared_ptr<BoardInterface> createBoard();
|
virtual boost::shared_ptr<BoardInterface> createBoard();
|
||||||
virtual boost::shared_ptr<PlayerInterface> createPlayer(int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, bool sotS, int mB);
|
virtual boost::shared_ptr<PlayerInterface> createPlayer(int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, bool sotS, int mB);
|
||||||
virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface *hi, unsigned dP, int sB);
|
virtual std::vector<boost::shared_ptr<BeRoInterface> > createBeRo(HandInterface *hi, unsigned dP, int sB);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ public:
|
|||||||
GuiInterface* getGuiInterface() const;
|
GuiInterface* getGuiInterface() const;
|
||||||
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const;
|
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const;
|
||||||
|
|
||||||
Log* getLog() const {
|
Log* getLog() const
|
||||||
|
{
|
||||||
return myLog;
|
return myLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,8 @@ public:
|
|||||||
bool checkIfINeedToShowCards();
|
bool checkIfINeedToShowCards();
|
||||||
|
|
||||||
void markRemoteAction() {}
|
void markRemoteAction() {}
|
||||||
unsigned getTimeSecSinceLastRemoteAction() const {
|
unsigned getTimeSecSinceLastRemoteAction() const
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@
|
|||||||
#define POKERTH_VERSION ((POKERTH_VERSION_MAJOR << 8) | POKERTH_VERSION_MINOR)
|
#define POKERTH_VERSION ((POKERTH_VERSION_MAJOR << 8) | POKERTH_VERSION_MINOR)
|
||||||
|
|
||||||
#define POKERTH_BETA_REVISION 0
|
#define POKERTH_BETA_REVISION 0
|
||||||
#define POKERTH_BETA_RELEASE_STRING "1.1.1"
|
#define POKERTH_BETA_RELEASE_STRING "1.1.2"
|
||||||
|
|
||||||
#define SQLITE_LOG_VERSION 1
|
#define SQLITE_LOG_VERSION 1
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user