3 Commits
Author SHA1 Message Date
Kai Philipp 9b40ad445b missing dylib path fix 2019-07-30 17:11:26 +02:00
Kai Philipp 8f3e4006e3 missing gitignore entry 2019-07-29 07:41:12 +02:00
Kai Philipp 20252a02e0 functional build on mac os mojave 2019-07-29 07:38:58 +02:00
156 changed files with 62850 additions and 102909 deletions
+8 -5
View File
@@ -8,15 +8,18 @@ Makefile.pokerth_protocol
Makefile.pokerth_server
Makefile.pokerth_dbofficial
bin/
/chatcleaner
chatcleaner
lib/
mocs/
obj/
/pokerth
pokerth
qrc_pokerth.cpp
uics/
make.sh
gitpush_serverstuff_stable
.vscode/
.project
.classpath
pokerth_server
.vscode
.qmake.stash
pokerth.ap*
*.DS_STORE
.gitignore.save
+1 -36
View File
@@ -1,36 +1 @@
Requirements
============
To compile PokerTH you need following libs:
Linux:
- Qt version >= 4.4.3, 4.8.x recommended --> http://qtsoftware.com/
- zlib version >= 1.2.3 --> http://www.zlib.net/
- libcurl version >= 7.16 --> http://curl.haxx.se/
- libgcrypt (e.g. version 1.4.6) --> http://www.gnu.org/software/libgcrypt/
- libgsasl version >= 1.4 --> http://www.gnu.org/software/gsasl/
- libboost_thread, libboost_filesystem, libboost_datetime, libboost_program_options,
libboost_iostreams, libboost_asio, libboost_regex, libboost_random, libboost_uuid
(version >= 1.49, latest always recommended) --> http://www.boost.org/
- libSDL_mixer, libSDL --> http://www.libsdl.org/
- libSQLite3 --> http://sqlite.org/
- libtinyxml > 2.0 --> http://www.sourceforge.net/projects/tinyxml
- protoc >= 2.3.0 (during build), libprotobuf >= 2.3.0 -> https://github.com/google/protobuf
- For the server: libircclient 1.3 --> http://www.sourceforge.net/projects/libircclient/
Windows:
see docs/build_mingw_windows.txt
Basic Installation
==================
Linux:
1. Type "cd path/to/the/sources". Then do for example "/usr/qt/4/bin/qmake pokerth.pro" to configure the makefile for your system.
Pay attention that the QTDIR environment variable points to Qt4 not Qt3. For example QTDIR=/usr/qt/4.
You can set this variable typing: "export QTDIR=/usr/qt/4"
2. Type "make" to compile the package.
3. Become root (typing "su") and type "make install" to install the program binary.
see https://github.com/pokerth/pokerth/wiki/Building-PokerTH
+63 -5
View File
@@ -9,12 +9,13 @@
# of binary-size if you leave Qt out.
# (see http://trolltech.com/developer/downloads/qt/mac)
QT_FW_PATH="/Users/$USER/Qt/5.9/clang_64/lib"
QT_PLUGIN_PATH="/Users/$USER/Qt/5.9/clang_64/plugins"
QT_FW_PATH="/usr/local/Cellar/qt/5.13.0/lib"
QT_PLUGIN_PATH="/usr/local/Cellar/qt/5.13.0/plugins"
SDL_FW_PATH="/Library/Frameworks"
APPLICATION="./pokerth.app"
BINARY="$APPLICATION/Contents/MacOs/pokerth"
RESOURCES="$APPLICATION/Contents/Resources"
DYLIB_PATH="$APPLICATION/Contents/MacOs/dylibs"
# strip binary
strip $BINARY
@@ -23,18 +24,56 @@ cp -R ./data $RESOURCES/
find $RESOURCES/data -name ".svn" | xargs rm -Rf
# create framework-path
BINARY_FW_PATH="$APPLICATION/Contents/Frameworks"
mkdir $BINARY_FW_PATH
BINARY_PLUGIN_PATH="$APPLICATION/Contents/plugins"
rm -rf $BINARY_FW_PATH
rm -rf $BINARY_PLUGIN_PATH
rm -rf $DYLIB_PATH
mkdir $BINARY_FW_PATH
mkdir -p $BINARY_PLUGIN_PATH/imageformats
mkdir -p $BINARY_PLUGIN_PATH/sqldrivers
mkdir -p $BINARY_PLUGIN_PATH/platforms
mkdir -p $DYLIB_PATH
# integrate SDL-frameworks into binary
cp -R $SDL_FW_PATH/SDL.framework $BINARY_FW_PATH
cp -R $SDL_FW_PATH/SDL_mixer.framework $BINARY_FW_PATH
# integrate Qt-frameworks into binary
# integrate dylibs
cp /usr/lib/libcurl.4.dylib $DYLIB_PATH/.
cp /usr/local/Cellar/openssl/1.0.2s/lib/libcrypto.1.0.0.dylib $DYLIB_PATH/.
cp /usr/local/opt/openssl/lib/libssl.1.0.0.dylib $DYLIB_PATH/.
cp /usr/lib/libsqlite3.dylib $DYLIB_PATH/.
cp /usr/local/opt/tinyxml/lib/libtinyxml.dylib $DYLIB_PATH/.
cp /usr/local/opt/protobuf/lib/libprotobuf.18.dylib $DYLIB_PATH/.
cp /usr/lib/libz.1.dylib $DYLIB_PATH/.
chmod -R +w $DYLIB_PATH;
LIBCURL_LINK=$(otool -L $BINARY | grep libcurl | cut -d"(" -f1 | cut -f2)
LIBCRYPTO_LINK=$(otool -L $BINARY | grep libcrypto | cut -d"(" -f1 | cut -f2)
LIBSSL_LINK=$(otool -L $BINARY | grep libssl | cut -d"(" -f1 | cut -f2)
LIBTINYXML_LINK=$(otool -L $BINARY | grep libtinyxml | cut -d"(" -f1 | cut -f2)
LIBSQLITE_LINK=$(otool -L $BINARY | grep libsqlite | cut -d"(" -f1 | cut -f2)
LIBPROTOBUF_LINK=$(otool -L $BINARY | grep libprotobuf | cut -d"(" -f1 | cut -f2)
LIBZ_LINK=$(otool -L $BINARY | grep libz | cut -d"(" -f1 | cut -f2)
install_name_tool -change $LIBCURL_LINK @loader_path/dylibs/libcurl.4.dylib $BINARY
install_name_tool -change $LIBCRYPTO_LINK @loader_path/dylibs/libcrypto.1.0.0.dylib $BINARY
install_name_tool -change $LIBSSL_LINK @loader_path/dylibs/libssl.1.0.0.dylib $BINARY
install_name_tool -change $LIBTINYXML_LINK @loader_path/dylibs/libtinyxml.dylib $BINARY
install_name_tool -change $LIBSQLITE_LINK @loader_path/dylibs/libsqlite3.dylib $BINARY
install_name_tool -change $LIBPROTOBUF_LINK @loader_path/dylibs/libprotobuf.18.dylib $BINARY
install_name_tool -change $LIBSQLITE_LINK @loader_path/dylibs/libsqlite3.dylib $BINARY
install_name_tool -change $LIBZ_LINK @loader_path/dylibs/libz.1.dylib $BINARY
LIBCRYPTO_LINK=$(otool -L $DYLIB_PATH/libssl.1.0.0.dylib | grep libcrypto | cut -d"(" -f1 | cut -f2)
LIBSSL_LINK=$(otool -L $DYLIB_PATH/libssl.1.0.0.dylib | grep libssl | cut -d"(" -f1 | cut -f2)
install_name_tool -change $LIBCRYPTO_LINK @executable_path/dylibs/libcrypto.1.0.0.dylib $DYLIB_PATH/libssl.1.0.0.dylib
install_name_tool -change /usr/local/opt/openssl/lib/libssl.1.0.0.dylib @executable_path/dylibs/libssl.1.0.0.dylib $DYLIB_PATH/libssl.1.0.0.dylib
# integrate Qt-frameworks into binary
if [ "$1" != "--without-qt" ] ; then
cp $QT_PLUGIN_PATH/imageformats/libqgif.dylib $BINARY_PLUGIN_PATH/imageformats
cp $QT_PLUGIN_PATH/imageformats/libqjpeg.dylib $BINARY_PLUGIN_PATH/imageformats
@@ -46,6 +85,8 @@ if [ "$1" != "--without-qt" ] ; then
cp -R $QT_FW_PATH/QtSql.framework $BINARY_FW_PATH
cp -R $QT_FW_PATH/QtNetwork.framework $BINARY_FW_PATH
cp -R $QT_FW_PATH/QtPrintSupport.framework $BINARY_FW_PATH
cp -R /usr/local/Cellar/qt/5.13.0/lib/QtDBus.framework $BINARY_FW_PATH
chmod -R 775 $BINARY_FW_PATH
# remove debug versions
rm -f $APPLICATION/Contents/Frameworks/QtCore.framework/QtCore_debug
rm -f $APPLICATION/Contents/Frameworks/QtCore.framework/QtCore_debug.prl
@@ -65,6 +106,9 @@ if [ "$1" != "--without-qt" ] ; then
rm -f $APPLICATION/Contents/Frameworks/QtPrintSupport.framework/QtPrintSupport_debug
rm -f $APPLICATION/Contents/Frameworks/QtPrintSupport.framework/QtPrintSupport_debug.prl
rm -f $APPLICATION/Contents/Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport_debug
rm -f $APPLICATION/Contents/Frameworks/QtDBus.framework/QtDBus_debug
rm -f $APPLICATION/Contents/Frameworks/QtDBus.framework/QtDBus_debug.prl
rm -f $APPLICATION/Contents/Frameworks/QtDBus.framework/Versions/5/QtDBus_debug
# redirect binary to use integrated frameworks
QTCORE="QtCore.framework/Versions/5/QtCore"
@@ -73,18 +117,20 @@ if [ "$1" != "--without-qt" ] ; then
QTSQL="QtSql.framework/Versions/5/QtSql"
QTNETWORK="QtNetwork.framework/Versions/5/QtNetwork"
QTPRINT="QtPrintSupport.framework/Versions/5/QtPrintSupport"
QTDBUS="QtDBus.framework/Versions/5/QtDBus"
install_name_tool -id @executable_path/../Frameworks/$QTCORE $BINARY_FW_PATH/$QTCORE
install_name_tool -id @executable_path/../Frameworks/$QTGUI $BINARY_FW_PATH/$QTGUI
install_name_tool -id @executable_path/../Frameworks/$QTWIDGETS $BINARY_FW_PATH/$QTWIDGETS
install_name_tool -id @executable_path/../Frameworks/$QTSQL $BINARY_FW_PATH/$QTSQL
install_name_tool -id @executable_path/../Frameworks/$QTNETWORK $BINARY_FW_PATH/$QTNETWORK
install_name_tool -id @executable_path/../Frameworks/$QTPRINT $BINARY_FW_PATH/$QTPRINT
install_name_tool -id @executable_path/../Frameworks/$QDBUS $BINARY_FW_PATH/$QTDBUS
QTCORE_LINK=$(otool -L $BINARY | grep QtCore | cut -d"(" -f1 | cut -f2)
QTGUI_LINK=$(otool -L $BINARY | grep QtGui | cut -d"(" -f1 | cut -f2)
QTWIDGETS_LINK=$(otool -L $BINARY | grep QtWidgets | cut -d"(" -f1 | cut -f2)
QTSQL_LINK=$(otool -L $BINARY | grep QtSql | cut -d"(" -f1 | cut -f2)
QTNETWORK_LINK=$(otool -L $BINARY | grep QtNetwork | cut -d"(" -f1 | cut -f2)
QTPRINT_LINK=$(otool -L $BINARY_PLUGIN_PATH/platforms/libqcocoa.dylib | grep QtPrintSupport | cut -d"(" -f1 | cut -f2)
install_name_tool -change $QTCORE_LINK @executable_path/../Frameworks/$QTCORE $BINARY
install_name_tool -change $QTGUI_LINK @executable_path/../Frameworks/$QTGUI $BINARY
install_name_tool -change $QTWIDGETS_LINK @executable_path/../Frameworks/$QTWIDGETS $BINARY
@@ -98,10 +144,22 @@ if [ "$1" != "--without-qt" ] ; then
install_name_tool -change $QTWIDGETS_LINK @executable_path/../Frameworks/$QTWIDGETS $BINARY_PLUGIN_PATH/imageformats/libqjpeg.dylib
install_name_tool -change $QTCORE_LINK @executable_path/../Frameworks/$QTCORE $BINARY_PLUGIN_PATH/sqldrivers/libqsqlite.dylib
install_name_tool -change $QTSQL_LINK @executable_path/../Frameworks/$QTSQL $BINARY_PLUGIN_PATH/sqldrivers/libqsqlite.dylib
QTDBUS_LINK=$(otool -L $BINARY_PLUGIN_PATH/platforms/libqcocoa.dylib | grep QtDBus | cut -d"(" -f1 | cut -f2)
QTPRINT_LINK=$(otool -L $BINARY_PLUGIN_PATH/platforms/libqcocoa.dylib | grep QtPrintSupport | cut -d"(" -f1 | cut -f2)
QTZ_LINK=$(otool -L $BINARY_PLUGIN_PATH/platforms/libqcocoa.dylib | grep libz | cut -d"(" -f1 | cut -f2)
QTCORE_LINK=$(otool -L $BINARY_PLUGIN_PATH/platforms/libqcocoa.dylib | grep QtCore | cut -d"(" -f1 | cut -f2)
QTGUI_LINK=$(otool -L $BINARY_PLUGIN_PATH/platforms/libqcocoa.dylib | grep QtGui | cut -d"(" -f1 | cut -f2)
QTWIDGETS_LINK=$(otool -L $BINARY_PLUGIN_PATH/platforms/libqcocoa.dylib | grep QtWidgets | cut -d"(" -f1 | cut -f2)
install_name_tool -change $QTCORE_LINK @executable_path/../Frameworks/$QTCORE $BINARY_PLUGIN_PATH/platforms/libqcocoa.dylib
install_name_tool -change $QTGUI_LINK @executable_path/../Frameworks/$QTGUI $BINARY_PLUGIN_PATH/platforms/libqcocoa.dylib
install_name_tool -change $QTWIDGETS_LINK @executable_path/../Frameworks/$QTWIDGETS $BINARY_PLUGIN_PATH/platforms/libqcocoa.dylib
install_name_tool -change $QTPRINT_LINK @executable_path/../Frameworks/$QTPRINT $BINARY_PLUGIN_PATH/platforms/libqcocoa.dylib
install_name_tool -change $QTDBUS_LINK @executable_path/../Frameworks/$QTDBUS $BINARY_PLUGIN_PATH/platforms/libqcocoa.dylib
install_name_tool -change $QTZ_LINK @loader_path/dylibs/libz.1.dylib $BINARY_PLUGIN_PATH/platforms/libqcocoa.dylib
QTCORE_LINK=$(otool -L $BINARY_FW_PATH/$QTDBUS | grep QtCore | head -1 | cut -d"(" -f1 | cut -f2)
install_name_tool -change $QTCORE_LINK @executable_path/../Frameworks/$QTCORE $BINARY_FW_PATH/$QTDBUS
QTCORE_LINK=$(otool -L $BINARY_FW_PATH/$QTGUI | grep QtCore | head -1 | cut -d"(" -f1 | cut -f2)
install_name_tool -change $QTCORE_LINK @executable_path/../Frameworks/$QTCORE $BINARY_FW_PATH/$QTGUI
-19
View File
@@ -112,11 +112,6 @@ message NetGameInfo {
required uint32 startMoney = 13;
repeated uint32 manualBlinds = 14 [packed = true];
optional bool allowSpectators = 15 [default = true];
//new data
optional bool allowLateReg = 16 [default = false];
optional bool allowReentries = 17 [default = false];
optional uint32 numReentries = 18 [default = 0];
optional uint32 maxTimeLateReg = 19 [default = 0];
}
// Message Part containing player result.
@@ -424,7 +419,6 @@ message StartEventMessage {
enum StartEventType {
startEvent = 0;
rejoinEvent = 1;
reentryEvent = 2;
}
required StartEventType startEventType = 2;
optional bool fillWithComputerPlayers = 3;
@@ -451,17 +445,6 @@ message GameStartRejoinMessage {
repeated RejoinPlayerData rejoinPlayerData = 4;
}
message GameStartReentryMessage {
required uint32 gameId = 1;
required uint32 startDealerPlayerId = 2;
required uint32 handNum = 3;
message ReentryPlayerData {
required uint32 playerId = 1;
required uint32 playerMoney = 2;
}
repeated ReentryPlayerData reentryPlayerData = 4;
}
message HandStartMessage {
required uint32 gameId = 1;
message PlainCards {
@@ -852,7 +835,6 @@ message PokerTHMessage {
Type_GameListSpectatorLeftMessage = 79;
Type_GameSpectatorJoinedMessage = 80;
Type_GameSpectatorLeftMessage = 81;
Type_GameStartReentryMessage = 82;
}
required PokerTHMessageType messageType = 1;
@@ -937,5 +919,4 @@ message PokerTHMessage {
optional GameListSpectatorLeftMessage gameListSpectatorLeftMessage = 80;
optional GameSpectatorJoinedMessage gameSpectatorJoinedMessage = 81;
optional GameSpectatorLeftMessage gameSpectatorLeftMessage = 82;
optional GameStartReentryMessage gameStartReentryMessage = 83;
}
+1 -1
View File
@@ -60,7 +60,7 @@ mac{
CONFIG += x86_64
CONFIG -= x86
CONFIG -= ppc
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
QMAKE_CXXFLAGS -= -std=gnu++0x
# for universal-compilation on PPC-Mac uncomment the following line
-2
View File
@@ -42,7 +42,6 @@ HEADERS += src/dbofficial/asyncdbauth.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 \
@@ -61,7 +60,6 @@ SOURCES += src/dbofficial/asyncdbauth.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
+9 -8
View File
@@ -576,7 +576,7 @@ mac {
CONFIG += x86_64
CONFIG -= x86
CONFIG -= ppc
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
QMAKE_CXXFLAGS -= -std=gnu++0x
# workaround for problems with boost_filesystem exceptions
@@ -587,13 +587,14 @@ mac {
# QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk/
LIBPATH += lib
# QT dynamic linked framework (see also mac_post_make.sh)
LIBS += -F /Library/Frameworks
LIBS += -framework \
QtCore
LIBS += -framework \
QtGui
LIBS += -framework \
LIBS += -F /Library/Frameworks
# LIBS += -framework \
# QtCore
# LIBS += -framework \
# QtGui
LIBS += -framework \
SDL
LIBS += -framework \
SDL_mixer
@@ -615,7 +616,7 @@ mac {
-lprotobuf \
-lz \
-framework \
Cocoa
Cocoa
# set the application icon
RC_FILE = pokerth.icns
+1 -1
View File
@@ -294,7 +294,7 @@ mac{
CONFIG += x86_64
CONFIG -= x86
CONFIG -= ppc
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
QMAKE_CXXFLAGS -= -std=gnu++0x
# for universal-compilation on PPC-Mac uncomment the following line
+9 -6
View File
@@ -40,7 +40,7 @@ win32 {
system(protoc pokerth.proto --java_out=tests/src)
}
unix : !mac {
INCLUDEPATH += $${PREFIX}/include
INCLUDEPATH += $${PREFIX}/include
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)
@@ -52,11 +52,14 @@ unix : !mac {
}
}
mac {
# make it x86_64 only
CONFIG += x86_64
CONFIG -= x86
CONFIG -= ppc
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12
# make it x86_64 only
CONFIG += x86_64
CONFIG -= x86
CONFIG -= ppc
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
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)
# for universal-compilation on PPC-Mac uncomment the following line
# on Intel-Mac you have to comment this line out or build will fail.
+1 -1
View File
@@ -310,7 +310,7 @@ mac {
CONFIG += x86_64
CONFIG -= x86
CONFIG -= ppc
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
QMAKE_CXXFLAGS -= -std=gnu++0x
# workaround for problems with boost_filesystem exceptions
-2
View File
@@ -312,8 +312,6 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
configList.push_back(ConfigInfo("DBServerEncryptionKey", CONFIG_TYPE_STRING, ""));
configList.push_back(ConfigInfo("GameNameBadWordList", CONFIG_TYPE_STRING_LIST, "Regex"));
configList.push_back(ConfigInfo("ServerRestrictGuestLogin", CONFIG_TYPE_INT, "0"));
configList.push_back(ConfigInfo("ServerLimitRankNum", CONFIG_TYPE_INT, "4"));
configList.push_back(ConfigInfo("ServerLimitRankPeriod", CONFIG_TYPE_INT, "60"));
//fill tempList firstTime
configBufferList = configList;
+4 -5
View File
@@ -35,11 +35,10 @@
#include <core/loghelper.h>
#include <iostream>
#include <boost/date_time.hpp>
using namespace std;
using namespace boost::posix_time;
static int g_logLevel = 1;
@@ -53,20 +52,20 @@ loghelper_init(const std::string & /*logDir*/, int logLevel)
void
internal_log_err(const string &msg)
{
cerr << second_clock::local_time() << " " << msg;
cerr << msg;
}
void
internal_log_msg(const std::string &msg)
{
if (g_logLevel)
cout << second_clock::local_time() << " " << msg;
cout << msg;
}
void
internal_log_level(const std::string &msg, int logLevel)
{
if (g_logLevel >= logLevel)
cout << second_clock::local_time() << " " << msg;
cout << msg;
}
-5
View File
@@ -93,11 +93,6 @@ ServerDBGeneric::SetGamePlayerPlace(unsigned /*requestId*/, DB_id /*playerId*/,
{
}
void
ServerDBGeneric::SetPlayerLastGames(unsigned /*requestId*/, DB_id /*playerId*/, std::vector<long> /*last_games*/, std::string /*playerIp*/)
{
}
void
ServerDBGeneric::EndGame(unsigned /*requestId*/)
{
-3
View File
@@ -35,7 +35,6 @@
#include <string>
#include <ctime>
#include <vector>
typedef unsigned DB_id;
#define DB_ID_INVALID 0
@@ -46,8 +45,6 @@ struct DBPlayerData {
std::string secret;
std::string country;
std::string last_login;
std::string last_games;
std::string last_ip;
};
#endif
-1
View File
@@ -57,7 +57,6 @@ public:
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);
-2
View File
@@ -36,7 +36,6 @@
#include <db/serverdbcallback.h>
#include <string>
#include <list>
#include <vector>
typedef std::list<DB_id> db_list;
@@ -58,7 +57,6 @@ public:
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName) = 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 AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId) = 0;
-1
View File
@@ -55,7 +55,6 @@ public:
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*/) {}
+1 -7
View File
@@ -52,25 +52,19 @@ AsyncDBAuth::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/,
service.post(boost::bind(&ServerDBCallback::PlayerLoginFailed, &cb, GetId()));
} else {
int blocked = result[0][2];
int active = result[0][7];
int active = result[0][5];
if ((active != 1) || (blocked != 0)) {
service.post(boost::bind(&ServerDBCallback::PlayerLoginBlocked, &cb, GetId()));
} else {
mysqlpp::String secret(result[0][1]);
mysqlpp::String country(result[0][3]);
mysqlpp::String last_login(result[0][4]);
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));
}
-62
View File
@@ -1,62 +0,0 @@
/*****************************************************************************
* 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> &params)
: 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)
{
}
-57
View File
@@ -1,57 +0,0 @@
/*****************************************************************************
* 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> &params);
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
-2
View File
@@ -42,8 +42,6 @@
#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"
+3 -38
View File
@@ -41,15 +41,12 @@
#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"
@@ -61,7 +58,6 @@
#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;
@@ -234,33 +230,6 @@ ServerDBThread::SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned
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)
{
@@ -463,7 +432,7 @@ ServerDBThread::EstablishDBConnection()
*/
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 " = ?";
<< "SELECT " DB_TABLE_PLAYER_COL_ID ", AES_DECRYPT(" DB_TABLE_PLAYER_COL_PASSWORD ", ?), " DB_TABLE_PLAYER_COL_VALID ", TRIM(" DB_TABLE_PLAYER_COL_COUNTRY "), " DB_TABLE_PLAYER_COL_LASTLOGIN ", " DB_TABLE_PLAYER_COL_ACTIVE " FROM " DB_TABLE_PLAYER " WHERE " DB_TABLE_PLAYER_COL_USERNAME " = ?";
mysqlpp::Query prepareAvatarBlacklist = m_connData->conn.query();
prepareAvatarBlacklist
@@ -510,16 +479,12 @@ ServerDBThread::EstablishDBConnection()
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()) {
|| !prepareReportGame.exec() || !prepareAdminPlayer.exec() || !prepareBlockPlayer.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();
prepareReportGame.error() + prepareAdminPlayer.error() + prepareBlockPlayer.error();
m_connData->conn.disconnect();
m_ioService->post(boost::bind(&ServerDBCallback::ConnectFailed, &m_callback, tmpError));
m_permanentError = true;
-2
View File
@@ -42,7 +42,6 @@
#include <dbofficial/dbidmanager.h>
#include <core/thread.h>
struct DBConnectionData;
class AsyncDBQuery;
@@ -67,7 +66,6 @@ public:
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);
+1 -21
View File
@@ -33,7 +33,6 @@
#include <enginefactory.h>
#include <guiinterface.h>
#include <core/loghelper.h>
#include "log.h"
#include "localexception.h"
@@ -88,9 +87,6 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
// create player
player_i = playerDataList.begin();
player_end = playerDataList.end();
LOG_MSG("Starting game... PLAYERS:");
for(i=0; i<MAX_NUMBER_OF_PLAYERS; i++) {
string myName;
@@ -124,6 +120,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
activePlayerList->push_back(tmpPlayer);
}
(*runningPlayerList) = (*activePlayerList);
}
currentBoard->setPlayerLists(seatsList, activePlayerList, runningPlayerList);
@@ -315,20 +312,3 @@ void Game::raiseBlinds()
currentSmallBlind = min(currentSmallBlind,startQuantityPlayers*startCash/2);
}
}
boost::shared_ptr<PlayerInterface>
Game::addNewPlayer(boost::shared_ptr<PlayerData> player)
{
// TODO (albmed): We must think how:
// also add to seatList (or replace a free slot if 10 players tops)
int i = 0; // ERROR. Thik about approppiate value (probably this should be set after a seat is found)
boost::shared_ptr<PlayerInterface> tmpPlayer = myFactory->createPlayer(i, player->GetUniqueId(), player->GetType(), player->GetName(), player->GetAvatarFile(), player->GetStartCash(), startQuantityPlayers > i, PLAYER_TYPE_HUMAN, 0);
tmpPlayer->setIsSessionActive(true); // ??? Really ???
tmpPlayer->setMyGuid(player->GetGuid());
return tmpPlayer;
}
-2
View File
@@ -142,8 +142,6 @@ public:
boost::shared_ptr<PlayerInterface> getPlayerByName(const std::string &name);
boost::shared_ptr<PlayerInterface> getCurrentPlayer();
boost::shared_ptr<PlayerInterface> addNewPlayer(boost::shared_ptr<PlayerData> player);
void raiseBlinds();
private:
-5
View File
@@ -66,12 +66,7 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
50, 51
};
// Shuffle three times
Tools::ShuffleArrayNonDeterministic(cardsArray, NumCards);
Tools::ShuffleArrayNonDeterministic(cardsArray, NumCards);
Tools::ShuffleArrayNonDeterministic(cardsArray, NumCards);
int tempBoardArray[5];
int tempPlayerArray[2];
int tempPlayerAndBoardArray[7];
-6
View File
@@ -93,12 +93,6 @@ struct GameData {
int guiSpeed;
int delayBetweenHandsSec;
int playerActionTimeoutSec;
// new data
bool allowLateReg;
bool allowReentries;
int numReentries;
int maxTimeLateReg;
};
struct GameInfo {
+290 -409
View File
@@ -6,256 +6,246 @@
<rect>
<x>0</x>
<y>0</y>
<width>395</width>
<height>573</height>
<width>293</width>
<height>410</height>
</rect>
</property>
<property name="windowTitle">
<string>Create Internet Game</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>388</width>
<height>500</height>
</rect>
</property>
<property name="title">
<string>Internet Game Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_23">
<property name="text">
<string>Default game name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_gameName">
<property name="maxLength">
<number>48</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Game type:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_gameType">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Internet Game Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<property name="text">
<string>Standard</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/player_play.png</normaloff>:/gfx/player_play.png</iconset>
</property>
<widget class="QLabel" name="label_23">
<property name="text">
<string>Default game name:</string>
</property>
</widget>
</item>
<item>
<property name="text">
<string>Registered players only</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/registered.png</normaloff>:/gfx/registered.png</iconset>
</property>
<widget class="QLineEdit" name="lineEdit_gameName">
<property name="maxLength">
<number>48</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Game type:</string>
</property>
</widget>
</item>
<item>
<property name="text">
<string>Invited players only</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/list_add_user.png</normaloff>:/gfx/list_add_user.png</iconset>
</property>
<widget class="QComboBox" name="comboBox_gameType">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Standard</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/player_play.png</normaloff>:/gfx/player_play.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Registered players only</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/registered.png</normaloff>:/gfx/registered.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Invited players only</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/list_add_user.png</normaloff>:/gfx/list_add_user.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Ranking game</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/cup.png</normaloff>:/gfx/cup.png</iconset>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="checkBox_Password">
<property name="text">
<string>Password:</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/lock.png</normaloff>:/gfx/lock.png</iconset>
</property>
</widget>
</item>
<item>
<property name="text">
<string>Ranking game</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/cup.png</normaloff>:/gfx/cup.png</iconset>
</property>
<widget class="QLineEdit" name="lineEdit_Password">
<property name="enabled">
<bool>false</bool>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="checkBox_Password">
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Password:</string>
</property>
<property name="icon">
<iconset resource="resources/pokerth.qrc">
<normaloff>:/gfx/lock.png</normaloff>:/gfx/lock.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_Password">
<property name="enabled">
<bool>false</bool>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox_allowSpectators">
<property name="text">
<string>Allow spectators to watch the game</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="checkBox_allowLateReg">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Allow late registration</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="checkBox_reentries">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Allow re-entries</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_numReentries">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Maximum number of re-entries:</string>
<string>Maximum number of players:</string>
</property>
<property name="buddy">
<cstring>spinBox_quantityPlayers</cstring>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="spinBox_numReentries">
<property name="enabled">
<bool>true</bool>
</property>
<item row="5" column="1">
<widget class="QSpinBox" name="spinBox_quantityPlayers">
<property name="minimum">
<number>0</number>
<number>2</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>2</number>
<number>10</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="8" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_timeLateReg">
<property name="enabled">
<bool>true</bool>
</property>
<item row="6" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Maximum time for late registration/re-entry:</string>
<string>Start Cash:</string>
</property>
<property name="buddy">
<cstring>spinBox_quantityPlayers</cstring>
<cstring>spinBox_startCash</cstring>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>13</width>
<height>21</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="spinBox_timeLateReg">
<property name="enabled">
<bool>true</bool>
</property>
<item row="6" column="1">
<widget class="QSpinBox" name="spinBox_startCash">
<property name="suffix">
<string>min</string>
<string/>
</property>
<property name="prefix">
<string>$</string>
</property>
<property name="minimum">
<number>1000</number>
</property>
<property name="maximum">
<number>1000000</number>
</property>
<property name="singleStep">
<number>50</number>
</property>
<property name="value">
<number>2000</number>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_blinds">
<property name="title">
<string>Blinds</string>
</property>
<layout class="QGridLayout">
<property name="topMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="radioButton_useSavedBlindsSettings">
<property name="text">
<string>Use saved blinds settings</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radioButton_changeBlindsSettings">
<property name="text">
<string>Change blinds settings ...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Timeout for player action:</string>
</property>
<property name="buddy">
<cstring>spinBox_netTimeOutPlayerAction</cstring>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QSpinBox" name="spinBox_netTimeOutPlayerAction">
<property name="suffix">
<string> s</string>
</property>
<property name="minimum">
<number>5</number>
@@ -264,208 +254,99 @@
<number>60</number>
</property>
<property name="value">
<number>15</number>
<number>20</number>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Delay between hands:</string>
</property>
<property name="buddy">
<cstring>spinBox_netDelayBetweenHands</cstring>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QSpinBox" name="spinBox_netDelayBetweenHands">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="suffix">
<string> s</string>
</property>
<property name="minimum">
<number>5</number>
</property>
<property name="maximum">
<number>20</number>
</property>
<property name="value">
<number>7</number>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox_allowSpectators">
<property name="text">
<string>Allow spectators to watch the game</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="9" column="0" colspan="2">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Maximum number of players:</string>
</property>
<property name="buddy">
<cstring>spinBox_quantityPlayers</cstring>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QSpinBox" name="spinBox_quantityPlayers">
<property name="minimum">
<number>2</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Start Cash:</string>
</property>
<property name="buddy">
<cstring>spinBox_startCash</cstring>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QSpinBox" name="spinBox_startCash">
<property name="suffix">
<string/>
</property>
<property name="prefix">
<string>€</string>
</property>
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>1000000</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
<property name="value">
<number>20</number>
</property>
</widget>
</item>
<item row="12" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_blinds">
<property name="title">
<string>Blinds</string>
</property>
<layout class="QGridLayout">
<property name="topMargin">
<number>0</number>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="radioButton_useSavedBlindsSettings">
<property name="text">
<string>Use saved blinds settings</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="radioButton_changeBlindsSettings">
<property name="text">
<string>Change blinds settings ...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Timeout for player action:</string>
</property>
<property name="buddy">
<cstring>spinBox_netTimeOutPlayerAction</cstring>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QSpinBox" name="spinBox_netTimeOutPlayerAction">
<property name="suffix">
<string> s</string>
</property>
<property name="minimum">
<number>5</number>
</property>
<property name="maximum">
<number>60</number>
</property>
<property name="value">
<number>20</number>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Delay between hands:</string>
</property>
<property name="buddy">
<cstring>spinBox_netDelayBetweenHands</cstring>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QSpinBox" name="spinBox_netDelayBetweenHands">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="suffix">
<string> s</string>
</property>
<property name="minimum">
<number>5</number>
</property>
<property name="maximum">
<number>20</number>
</property>
<property name="value">
<number>7</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>10</x>
<y>540</y>
<width>381</width>
<height>25</height>
</rect>
</property>
<layout class="QHBoxLayout" name="_2">
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>115</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_createGame">
<property name="text">
<string>Create Game</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>181</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_createGame">
<property name="text">
<string>Create Game</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>lineEdit_gameName</tabstop>
@@ -68,11 +68,6 @@ createInternetGameDialogImpl::createInternetGameDialogImpl(QWidget *parent, Conf
connect( pushButton_createGame, SIGNAL( clicked() ), this, SLOT( createGame() ) );
connect( checkBox_Password, SIGNAL( toggled(bool) ), this, SLOT( clearGamePassword(bool)) );
connect( comboBox_gameType, SIGNAL(currentIndexChanged(int)), this, SLOT( gameTypeChanged() ) );
// new connections
connect(checkBox_allowLateReg, SIGNAL(toggled(bool)), this, SLOT(switchAllowReg(bool)));
connect(checkBox_reentries, SIGNAL(toggled(bool)), this, SLOT(switchReentries(bool)));
}
@@ -170,7 +165,6 @@ void createInternetGameDialogImpl::gameTypeChanged()
raiseMode->hide();
checkBox_allowSpectators->setEnabled(true);
checkBox_allowSpectators->setChecked(myConfig->readConfigInt("InternetGameAllowSpectators"));
switchLateReg(true); // allow late reg & reentries
}
break;
@@ -186,7 +180,6 @@ void createInternetGameDialogImpl::gameTypeChanged()
raiseMode->hide();
checkBox_allowSpectators->setEnabled(true);
checkBox_allowSpectators->setChecked(myConfig->readConfigInt("InternetGameAllowSpectators"));
switchLateReg(true); // allow late reg & reentries
}
break;
case GAME_TYPE_INVITE_ONLY-1: {
@@ -202,7 +195,6 @@ void createInternetGameDialogImpl::gameTypeChanged()
raiseMode->hide();
checkBox_allowSpectators->setEnabled(true);
checkBox_allowSpectators->setChecked(myConfig->readConfigInt("InternetGameAllowSpectators"));
switchLateReg(false); // don't allow late reg & reentries
}
break;
case GAME_TYPE_RANKING-1: {
@@ -219,7 +211,6 @@ void createInternetGameDialogImpl::gameTypeChanged()
raiseMode->show();
checkBox_allowSpectators->setDisabled(true);
checkBox_allowSpectators->setChecked(true);
switchLateReg(false); // don't allow late reg & reentries
}
break;
}
@@ -261,51 +252,6 @@ void createInternetGameDialogImpl::gameTypeChanged()
}
}
void createInternetGameDialogImpl::switchLateReg(bool enable) {
if (enable) {
checkBox_allowLateReg->setDisabled(false);
checkBox_allowLateReg->setChecked(true);
checkBox_reentries->setDisabled(false);
checkBox_reentries->setChecked(true);
}
else {
checkBox_allowLateReg->setDisabled(true);
checkBox_allowLateReg->setChecked(false);
checkBox_reentries->setDisabled(true);
checkBox_reentries->setChecked(false);
}
}
void createInternetGameDialogImpl::switchReentries(bool enable) {
if (enable) {
label_numReentries->setDisabled(false);
spinBox_numReentries->setDisabled(false);
label_timeLateReg->setDisabled(false);
spinBox_timeLateReg->setDisabled(false);
}
else {
label_numReentries->setDisabled(true);
spinBox_numReentries->setDisabled(true);
if (!(checkBox_allowLateReg->isEnabled() && checkBox_allowLateReg->isChecked())) {
label_timeLateReg->setDisabled(true);
spinBox_timeLateReg->setDisabled(true);
}
}
}
void createInternetGameDialogImpl::switchAllowReg(bool enable) {
if (enable) {
label_timeLateReg->setDisabled(false);
spinBox_timeLateReg->setDisabled(false);
}
else {
if (!(checkBox_reentries->isEnabled() && checkBox_reentries->isChecked())) {
label_timeLateReg->setDisabled(true);
spinBox_timeLateReg->setDisabled(true);
}
}
}
bool createInternetGameDialogImpl::eventFilter(QObject *obj, QEvent *event)
{
#ifdef ANDROID
@@ -67,13 +67,8 @@ public slots:
void gameTypeChanged();
void callChangeBlindsDialog(bool);
void switchAllowReg(bool);
void switchReentries(bool);
private:
void switchLateReg(bool);
ConfigFile *myConfig;
changeCompleteBlindsDialogImpl *myChangeCompleteBlindsDialog;
bool currentGuestMode;
@@ -352,17 +352,6 @@ void gameLobbyDialogImpl::createGame()
}
}
if (myCreateInternetGameDialog->checkBox_allowLateReg->isEnabled() && myCreateInternetGameDialog->checkBox_allowLateReg->isChecked()) {
gameData.allowLateReg = true;
gameData.maxTimeLateReg = myCreateInternetGameDialog->spinBox_timeLateReg->value();
}
if (myCreateInternetGameDialog->checkBox_reentries->isEnabled() && myCreateInternetGameDialog->checkBox_reentries->isChecked()) {
gameData.allowReentries = true;
gameData.numReentries = myCreateInternetGameDialog->spinBox_numReentries->value();
gameData.maxTimeLateReg = myCreateInternetGameDialog->spinBox_timeLateReg->value();
}
gameData.guiSpeed = myConfig->readConfigInt("GameSpeed");
gameData.delayBetweenHandsSec = myCreateInternetGameDialog->spinBox_netDelayBetweenHands->value();
gameData.playerActionTimeoutSec = myCreateInternetGameDialog->spinBox_netTimeOutPlayerAction->value();
+2 -9
View File
@@ -2222,13 +2222,13 @@ p, li { white-space: pre-wrap; }
<property name="minimumSize">
<size>
<width>600</width>
<height>114</height>
<height>94</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>114</height>
<height>94</height>
</size>
</property>
<property name="styleSheet">
@@ -2631,13 +2631,6 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item row="1" column="0" colspan="5">
<widget class="QLabel" name="label_WinningCombination">
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
+1 -10
View File
@@ -59,7 +59,7 @@
#include "carddeckstylereader.h"
#include <gamedata.h>
#include <generic/serverguiwrapper.h>
#include <core/loghelper.h>
#include <net/socket_msg.h>
#include <cmath>
@@ -81,8 +81,6 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent)
{
int i;
LOG_MSG("starting gameTableImpl");
// this->setStyle(new QPlastiqueStyle);
//for statistic development
@@ -872,8 +870,6 @@ void gameTableImpl::initGui(int speed)
//kill running Singleshots!!!
stopTimer();
LOG_MSG("starting gameTableImpl::initGui");
label_handNumber->setText(HandString+":");
label_gameNumber->setText(GameString+":");
@@ -938,7 +934,6 @@ void gameTableImpl::initGui(int speed)
#endif
LOG_MSG("ending gameTableImpl::initGui");
}
boost::shared_ptr<Session> gameTableImpl::getSession()
@@ -2535,7 +2530,6 @@ void gameTableImpl::postRiverRunAnimation2()
if(nonfoldPlayersCounter!=1) {
label_WinningCombination->setText(CardsValue::determineHandName(currentGame->getCurrentHand()->getCurrentBeRo()->getHighestCardsValue(), activePlayerList).c_str());
if(!flipHolecardsAllInAlreadyDone) {
for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) {
@@ -3023,8 +3017,6 @@ void gameTableImpl::nextRoundCleanGui()
resetMyButtonsCheckStateMemory();
clearMyButtons();
pushButton_showMyCards->hide();
label_WinningCombination->clear();
update();
}
void gameTableImpl::stopTimer()
@@ -4125,7 +4117,6 @@ void gameTableImpl::refreshGameTableStyle()
myGameTableStyle->setBigFontBoardStyle(textLabel_handLabel);
myGameTableStyle->setBigFontBoardStyle(label_Pot);
#endif
myGameTableStyle->setBigFontBoardStyle(label_WinningCombination);
myGameTableStyle->setCardHolderStyle(label_CardHolder0,0);
myGameTableStyle->setCardHolderStyle(label_CardHolder1,0);
myGameTableStyle->setCardHolderStyle(label_CardHolder2,0);
+2 -9
View File
@@ -2745,13 +2745,13 @@ p, li { white-space: pre-wrap; }
<property name="minimumSize">
<size>
<width>390</width>
<height>102</height>
<height>82</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>390</width>
<height>102</height>
<height>82</height>
</size>
</property>
<property name="styleSheet">
@@ -3039,13 +3039,6 @@ p, li { white-space: pre-wrap; }
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_WinningCombination">
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
-3
View File
@@ -39,7 +39,6 @@
#include "configfile.h"
#include "soundevents.h"
#include <net/socket_msg.h>
#include <core/loghelper.h>
using namespace std;
@@ -47,7 +46,6 @@ using namespace std;
GuiWrapper::GuiWrapper(ConfigFile *c, startWindowImpl *s) : myGuiLog(NULL), myW(NULL), myConfig(c), myStartWindow(s)
{
LOG_MSG("starting GuiWrapper");
myW = new gameTableImpl(myConfig);
myGuiLog = new guiLog(myW, myConfig);
@@ -65,7 +63,6 @@ GuiWrapper::~GuiWrapper()
void GuiWrapper::initGui(int speed)
{
LOG_MSG("starting GuiWrapper::initGui");
myW->signalInitGui(speed);
}
@@ -33,7 +33,6 @@
#include <gamedata.h>
#include <generic/serverguiwrapper.h>
#include <net/socket_msg.h>
#include <core/loghelper.h>
#include "tools.h"
#include "session.h"
#include "game.h"
@@ -73,8 +72,6 @@ startWindowImpl::startWindowImpl(ConfigFile *c, Log *l)
: myConfig(c), myLog(l), msgBoxOutdatedVersionActive(false)
{
LOG_MSG("starting startWindowImpl");
myGuiInterface.reset(new GuiWrapper(myConfig, this));
{
mySession.reset(new Session(myGuiInterface.get(), myConfig, myLog));
+3 -3
View File
@@ -105,7 +105,7 @@ AsioReceiveBuffer::ScanPackets(boost::shared_ptr<SessionData> session)
size_t packetSize = ntohl(nativeVal);
if (packetSize > MAX_PACKET_SIZE) {
recvBufUsed = 0;
LOG_ERROR(session->GetClientAddr() << "Session " << session->GetId() << " - Invalid packet size: " << packetSize);
LOG_ERROR("Session " << session->GetId() << " - Invalid packet size: " << packetSize);
} else if (recvBufUsed >= packetSize + NET_HEADER_SIZE) {
try {
tmpPacket = NetPacket::Create(&recvBuf[NET_HEADER_SIZE], packetSize);
@@ -118,7 +118,7 @@ AsioReceiveBuffer::ScanPackets(boost::shared_ptr<SessionData> session)
} catch (const exception &e) {
// Reset buffer on error.
recvBufUsed = 0;
LOG_ERROR(session->GetClientAddr() << "Session " << session->GetId() << " - " << e.what());
LOG_ERROR("Session " << session->GetId() << " - " << e.what());
}
}
}
@@ -126,7 +126,7 @@ AsioReceiveBuffer::ScanPackets(boost::shared_ptr<SessionData> session)
if (validator.IsValidPacket(*tmpPacket)) {
receivedPackets.push_back(tmpPacket);
} else {
LOG_ERROR(session->GetClientAddr() << "Session " << session->GetId() << " - Invalid packet: " << tmpPacket->GetMsg()->messagetype());
LOG_ERROR("Session " << session->GetId() << " - Invalid packet: " << tmpPacket->GetMsg()->messagetype());
}
} else {
dataAvailable = false;
-63
View File
@@ -42,8 +42,6 @@
#include <core/crypthelper.h>
#include <qttoolsinterface.h>
#include <core/loghelper.h>
#include <game.h>
#include <playerinterface.h>
@@ -1520,14 +1518,6 @@ ClientStateWaitStart::InternalHandlePacket(boost::shared_ptr<ClientThread> clien
if (!tmpPlayer)
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
tmpPlayer->SetNumber(i);
LOG_MSG("PlayerData: {playerId, name, GUID, seat, number} -> {" <<
playerId << "," <<
tmpPlayer->GetName() << "," <<
tmpPlayer->GetGuid() << "," <<
i << "," <<
tmpPlayer->GetNumber()
);
}
} else {
throw ClientException(__FILE__, __LINE__, ERR_NET_INVALID_PLAYER_COUNT, 0);
@@ -1562,54 +1552,6 @@ ClientStateWaitStart::InternalHandlePacket(boost::shared_ptr<ClientThread> clien
throw ClientException(__FILE__, __LINE__, ERR_NET_INVALID_PLAYER_COUNT, 0);
}
client->InitGame();
LOG_MSG("Game created. Let's LOG:");
// LOG seats
{
boost::shared_ptr<Game> tmpGame = client->GetGame();
PlayerListConstIterator it_c;
boost::shared_ptr<PlayerInterface> tmpPlayer;
PlayerList seatsList = tmpGame->getSeatsList();
PlayerList activePlayerList = tmpGame->getActivePlayerList();
PlayerList runningPlayerList = tmpGame->getRunningPlayerList();
LOG_MSG("\t === Player seats === ");
for (it_c=seatsList->begin(); it_c!=seatsList->end(); ++it_c) {
tmpPlayer = *it_c;
LOG_MSG("\t\t {ID, name, GUID; UID} => " <<
tmpPlayer->getMyID() << ", " <<
tmpPlayer->getMyName() << ", " <<
tmpPlayer->getMyUniqueID() << ", " <<
tmpPlayer->getMyGuid());
}
LOG_MSG("\t === Player active List === ");
for (it_c=activePlayerList->begin(); it_c!=activePlayerList->end(); ++it_c) {
tmpPlayer = *it_c;
LOG_MSG("\t\t {ID, name, GUID; UID} => " <<
tmpPlayer->getMyID() << ", " <<
tmpPlayer->getMyName() << ", " <<
tmpPlayer->getMyUniqueID() << ", " <<
tmpPlayer->getMyGuid());
}
LOG_MSG("\t === Player running List === ");
for (it_c=runningPlayerList->begin(); it_c!=runningPlayerList->end(); ++it_c) {
tmpPlayer = *it_c;
LOG_MSG("\t\t {ID, name, GUID; UID} => " <<
tmpPlayer->getMyID() << ", " <<
tmpPlayer->getMyName() << ", " <<
tmpPlayer->getMyUniqueID() << ", " <<
tmpPlayer->getMyGuid());
}
}
client->GetGame()->setCurrentHandID(tmpHandId);
// We need to remove the temporary player data objects after creating the game.
BOOST_FOREACH(unsigned tmpPlayerId, tmpPlayerList) {
@@ -1763,8 +1705,6 @@ ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client
client->GetCallback().SignalNetClientPostRiverShowCards(r.playerid());
client->GetClientLog()->logHoleCardsHandName(client->GetGame()->getActivePlayerList(), tmpPlayer, true);
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_PlayerIdChangedMessage) {
LOG_MSG("performing rejoin");
boost::shared_ptr<Game> curGame = client->GetGame();
if (curGame) {
// Perform Id change.
@@ -1772,9 +1712,6 @@ ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(idChanged.oldplayerid());
if (!tmpPlayer)
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
LOG_MSG("Player rejoins with " << tmpPlayer->getMyCash());
tmpPlayer->setMyUniqueID(idChanged.newplayerid());
// This player is now active again.
tmpPlayer->setMyStayOnTableStatus(true);
-8
View File
@@ -113,10 +113,6 @@ NetPacket::SetGameData(const GameData &inData, NetGameInfo &outData)
outData.set_endraisesmallblindvalue(inData.afterMBAlwaysRaiseValue);
outData.set_firstsmallblind(inData.firstSmallBlind);
outData.set_startmoney(inData.startMoney);
outData.set_allowlatereg(inData.allowLateReg);
outData.set_allowreentries(inData.allowReentries);
outData.set_maxtimelatereg(inData.maxTimeLateReg);
outData.set_numreentries(inData.numReentries);
BOOST_FOREACH(int manualBlind, inData.manualBlindsList) {
outData.add_manualblinds(manualBlind);
@@ -145,10 +141,6 @@ NetPacket::GetGameData(const NetGameInfo &inData, GameData &outData)
outData.firstSmallBlind = inData.firstsmallblind();
outData.afterMBAlwaysRaiseValue = inData.endraisesmallblindvalue();
outData.startMoney = inData.startmoney();
outData.allowLateReg = inData.allowlatereg();
outData.allowReentries = inData.allowreentries();
outData.numReentries = inData.numreentries();
outData.maxTimeLateReg = inData.maxtimelatereg();
for (int i = 0; i < numManualBlinds; i++) {
outData.manualBlindsList.push_back(static_cast<int>(inData.manualblinds(i)));
-17
View File
@@ -94,7 +94,6 @@ NetPacketValidator::NetPacketValidator()
m_validationMap.insert(make_pair(PokerTHMessage_PokerTHMessageType_Type_StartEventAckMessage, ValidateStartEventAckMessage));
m_validationMap.insert(make_pair(PokerTHMessage_PokerTHMessageType_Type_GameStartInitialMessage, ValidateGameStartInitialMessage));
m_validationMap.insert(make_pair(PokerTHMessage_PokerTHMessageType_Type_GameStartRejoinMessage, ValidateGameStartRejoinMessage));
m_validationMap.insert(make_pair(PokerTHMessage_PokerTHMessageType_Type_GameStartReentryMessage, ValidateGameStartReentryMessage));
m_validationMap.insert(make_pair(PokerTHMessage_PokerTHMessageType_Type_HandStartMessage, ValidateHandStartMessage));
m_validationMap.insert(make_pair(PokerTHMessage_PokerTHMessageType_Type_PlayersTurnMessage, ValidatePlayersTurnMessage));
m_validationMap.insert(make_pair(PokerTHMessage_PokerTHMessageType_Type_MyActionRequestMessage, ValidateMyActionRequestMessage));
@@ -696,22 +695,6 @@ NetPacketValidator::ValidateGameStartRejoinMessage(const NetPacket &packet)
return retVal;
}
bool
NetPacketValidator::ValidateGameStartReentryMessage(const NetPacket &packet)
{
bool retVal = false;
if (packet.GetMsg()->has_gamestartreentrymessage()) {
const GameStartReentryMessage &msg = packet.GetMsg()->gamestartreentrymessage();
if (msg.gameid() != 0
&& msg.startdealerplayerid() != 0
&& msg.handnum() != 0
&& VALIDATE_LIST_SIZE(msg.reentryplayerdata(), 2, 10)) {
retVal = true;
}
}
return retVal;
}
bool
NetPacketValidator::ValidateHandStartMessage(const NetPacket &packet)
{
+4 -5
View File
@@ -29,7 +29,6 @@
* as that of the covered work. *
*****************************************************************************/
#include <boost/bind/bind.hpp>
#include <net/serveracceptwebhelper.h>
#include <net/sessiondata.h>
#include <net/webreceivebuffer.h>
@@ -59,10 +58,10 @@ ServerAcceptWebHelper::Listen(unsigned serverPort, bool /*ipv6*/, const std::str
m_webSocketServer->init_asio(m_ioService.get());
m_webSocketServer->set_validate_handler(boost::bind(boost::mem_fn(&ServerAcceptWebHelper::validate), this, boost::placeholders::_1));
m_webSocketServer->set_open_handler(boost::bind(boost::mem_fn(&ServerAcceptWebHelper::on_open), this, boost::placeholders::_1));
m_webSocketServer->set_close_handler(boost::bind(boost::mem_fn(&ServerAcceptWebHelper::on_close), this, boost::placeholders::_1));
m_webSocketServer->set_message_handler(boost::bind(boost::mem_fn(&ServerAcceptWebHelper::on_message), this, boost::placeholders::_1,boost::placeholders:: _2));
m_webSocketServer->set_validate_handler(boost::bind(boost::mem_fn(&ServerAcceptWebHelper::validate), this, _1));
m_webSocketServer->set_open_handler(boost::bind(boost::mem_fn(&ServerAcceptWebHelper::on_open), this, _1));
m_webSocketServer->set_close_handler(boost::bind(boost::mem_fn(&ServerAcceptWebHelper::on_close), this, _1));
m_webSocketServer->set_message_handler(boost::bind(boost::mem_fn(&ServerAcceptWebHelper::on_message), this, _1, _2));
m_webSocketServer->listen(serverPort);
m_webSocketServer->start_accept();
+3 -173
View File
@@ -66,28 +66,15 @@ static bool LessThanPlayerHandStartMoney(const boost::shared_ptr<PlayerInterface
ServerGame::ServerGame(boost::shared_ptr<ServerLobbyThread> lobbyThread, u_int32_t id, const string &name, const string &pwd, const GameData &gameData,
unsigned adminPlayerId, unsigned creatorPlayerDBId, GuiInterface &gui, ConfigFile &playerConfig)
unsigned adminPlayerId, unsigned creatorPlayerDBId, GuiInterface &gui, ConfigFile &playerConfig)
: m_adminPlayerId(adminPlayerId), m_lobbyThread(lobbyThread), m_gui(gui),
m_gameData(gameData), m_curState(NULL), m_id(id), m_name(name),
m_password(pwd), m_creatorPlayerDBId(creatorPlayerDBId), m_playerConfig(playerConfig),
m_gameNum(1), m_curPetitionId(1), m_voteKickTimer(lobbyThread->GetIOService()),
m_stateTimer1(lobbyThread->GetIOService()), m_stateTimer2(lobbyThread->GetIOService()), m_allowEntryTimer(lobbyThread->GetIOService()),
m_isNameReported(false), m_isLateRegAllowed(false)
m_stateTimer1(lobbyThread->GetIOService()), m_stateTimer2(lobbyThread->GetIOService()),
m_isNameReported(false)
{
LOG_VERBOSE("Game object " << GetId() << " created.");
// TODO (albmed): Next is wrong!!
// If game is restarted without being created, m_isLateRegAllowed probably will be always false because its timer would already be cancelled in previous game and object is not created again.
// So, constructor is not called again.
// m_isLateRegAllowed should probably be set on Init() function or in ServerGameStateInit::Enter. To be checked!!
// set late reg allowed
if ((m_gameData.gameType == GAME_TYPE_NORMAL || m_gameData.gameType == GAME_TYPE_REGISTERED_ONLY) &&
(m_gameData.allowLateReg || m_gameData.allowReentries) &&
m_gameData.maxTimeLateReg > 0) m_isLateRegAllowed = true;
LOG_MSG("m_isLateRegAllowed: " << std::boolalpha << m_isLateRegAllowed);
}
ServerGame::~ServerGame()
@@ -105,7 +92,6 @@ void
ServerGame::Exit()
{
m_voteKickTimer.cancel();
m_allowEntryTimer.cancel();
SetState(ServerGameStateFinal::Instance());
}
@@ -307,13 +293,11 @@ ServerGame::TimerVoteKick(const boost::system::error_code &ec)
PlayerDataList
ServerGame::InternalStartGame()
{
LOG_ERROR("InternalStartGame() entered.");
// Initialize the game.
PlayerDataList playerData(GetFullPlayerDataList());
if (playerData.size() >= 2) {
// Set DB Backend.
// @TODO: check for wec or bbc game with bbcbot as creator
if (GetGameData().gameType == GAME_TYPE_RANKING)
m_database = GetLobbyThread().GetDatabase();
else
@@ -362,14 +346,6 @@ ServerGame::InternalStartGame()
GetDatabase().AsyncCreateGame(GetId(), GetName());
InitRankingMap(playerData);
// @TODO: here to save last_games with mysql per player
if (GetGameData().gameType == GAME_TYPE_RANKING)
StoreLastGames(playerData);
setEntries(playerData);
}
return playerData;
}
@@ -466,26 +442,6 @@ ServerGame::StoreAndResetRanking()
m_rankingMap.clear();
}
void
ServerGame::StoreLastGames(const PlayerDataList &playerDataList)
{
// Store players lastgames in database.
PlayerDataList::const_iterator i = playerDataList.begin();
PlayerDataList::const_iterator end = playerDataList.end();
while (i != end) {
boost::shared_ptr<PlayerData> tmpPlayer(*i);
// tmpPlayer->GetUniqueId()
tmpPlayer->AddPlayerLastGame((long)time(NULL));
LOG_ERROR("TimeStamp stored: " << tmpPlayer->GetPlayerLastGames().back());
std::vector<long> last_games = tmpPlayer->GetPlayerLastGames();
LOG_ERROR("Ready for storing vector for player " << tmpPlayer->GetDBId() << " - lastGameTs " << last_games.back());
if(tmpPlayer->GetDBId() != DB_ID_INVALID){
GetDatabase().SetPlayerLastGames(GetId(), tmpPlayer->GetDBId(), last_games, GetSessionManager().GetSessionByUniquePlayerId(tmpPlayer->GetUniqueId())->GetClientAddr());
}
++i;
}
}
void
ServerGame::RemoveAutoLeavePlayers()
{
@@ -508,7 +464,6 @@ ServerGame::InternalEndGame()
StoreAndResetRanking();
m_game.reset();
m_numJoinsPerPlayer.clear();
m_numEntriesPlayer.clear();
}
void
@@ -795,13 +750,6 @@ ServerGame::AddRejoinPlayer(unsigned playerId)
m_rejoinPlayerList.push_back(playerId);
}
void
ServerGame::AddReentryPlayer(unsigned playerId)
{
boost::mutex::scoped_lock lock(m_reentryPlayerListMutex);
m_reentryPlayerList.push_back(playerId);
}
PlayerIdList
ServerGame::GetAndResetRejoinPlayers()
{
@@ -811,22 +759,6 @@ ServerGame::GetAndResetRejoinPlayers()
return tmpList;
}
unsigned
ServerGame::GetNumberPlayersReentry()
{
boost::mutex::scoped_lock lock(m_rejoinPlayerListMutex);
return static_cast<unsigned>(m_rejoinPlayerList.size());
}
PlayerIdList
ServerGame::GetAndResetReentryPlayers()
{
boost::mutex::scoped_lock lock(m_reentryPlayerListMutex);
PlayerIdList tmpList(m_reentryPlayerList);
m_reentryPlayerList.clear();
return tmpList;
}
void
ServerGame::AddReactivatePlayer(unsigned playerId)
{
@@ -1159,12 +1091,6 @@ ServerGame::GetStateTimer2()
return m_stateTimer2;
}
boost::asio::steady_timer &
ServerGame::GetAllowEntryTimer()
{
return m_allowEntryTimer;
}
Game &
ServerGame::GetGame()
{
@@ -1230,17 +1156,6 @@ ServerGame::CheckSettings(const GameData &data, const string &password, ServerMo
retVal = false;
}
}
if (data.gameType == GAME_TYPE_NORMAL || data.gameType == GAME_TYPE_REGISTERED_ONLY) { // allow late reg and reentries
if (data.allowLateReg || data.allowReentries) {
if (data.maxTimeLateReg < 1 || data.maxTimeLateReg > 60) retVal = false;
if (data.allowReentries && (data.numReentries < 0 || data.numReentries > 10)) retVal = false;
}
}
else { // does not allow
if (data.allowLateReg || data.allowReentries) retVal = false;
}
return retVal;
}
@@ -1277,88 +1192,3 @@ ServerGame::GetNumJoinsPerPlayer(const std::string &playerName)
}
return num;
}
void
ServerGame::setEntries(const PlayerDataList &playerDataList) {
PlayerDataList::const_iterator i = playerDataList.begin();
PlayerDataList::const_iterator end = playerDataList.end();
while (i != end) {
boost::shared_ptr<PlayerData> tmpPlayer(*i);
m_numEntriesPlayer[tmpPlayer->GetName()] = 0;
++i;
}
{
LOG_MSG("Printting set entries:");
NumJoinsPerPlayerMap::const_iterator i = m_numEntriesPlayer.begin();
NumJoinsPerPlayerMap::const_iterator end = m_numEntriesPlayer.end();
while (i != end) {
LOG_MSG("\t{player, entries}: {" << (*i).first << ", " << (*i).second << "}");
++i;
}
}
}
bool
ServerGame::admitReentries(boost::shared_ptr<PlayerData> player) { // FIXME: maybe set a reason, to return appropiate message. eg: uint32 &reason
bool retVal = false;
const GameData &tmpGameData = GetGameData();
// uncomment to remove logs
/*if (!m_isLateRegAllowed) return retVal;
NumJoinsPerPlayerMap::iterator pos = m_numEntriesPlayer.find(player->GetName());
if (pos != m_numEntriesPlayer.end()) { // is reentry
if (!tmpGameData.allowReentries || pos->second++ >= tmpGameData.numReentries ) return retVal; // number of entries exceeded
}
else { // is late reg
if (!tmpGameData.allowLateReg) return false; // does not allow late reg
m_numEntriesPlayer[player->GetName()] = 0; // add player as new entry. Perhaps this should be set otherplace
}*/
// comment or delete to remove logs -- begin
if (!m_isLateRegAllowed) {
LOG_MSG("Late reg was not allowed or is no longer available");
return retVal;
}
NumJoinsPerPlayerMap::iterator pos = m_numEntriesPlayer.find(player->GetName());
if (pos != m_numEntriesPlayer.end()) { // is reentry
LOG_MSG("Player " << player->GetName() << " is trying to re-entry. Previous entries: " << pos->second);
if (!tmpGameData.allowReentries || pos->second++ >= tmpGameData.numReentries ) {
LOG_MSG("Number of reentries exceeded");
return retVal; // number of entries exceeded
}
else {
LOG_MSG("Allowed to re-entry");
}
}
else { // is late reg
LOG_MSG("Player " << player->GetName() << " is trying a late reg");
if (!tmpGameData.allowLateReg) {
LOG_MSG("Game does not allow late reg");
return false; // does not allow late reg
}
m_numEntriesPlayer[player->GetName()] = 0; // add player as new entry. Perhaps this should be set otherplace
}
LOG_MSG("Late reg allowed!! ");
// comment or delete to remove logs -- end
return true;
}
void
ServerGame::CancelLateReg() {
m_isLateRegAllowed = false;
LOG_MSG("Called CancelLateReg");
}
bool
ServerGame::IsLateReg() {
return m_isLateRegAllowed;
}
+4 -333
View File
@@ -92,8 +92,6 @@ using namespace boost::chrono;
#define GAME_MAX_NUM_JOINS_PER_PLAYER 6
#define TESTS_LATE_REG // (albmed) To develop set this define, to compile comment until reentry is implemented
// Helper functions
static void SendPlayerAction(ServerGame &server, boost::shared_ptr<PlayerInterface> player)
@@ -157,7 +155,7 @@ static void SendNewRoundCards(ServerGame &server, Game &curGame, int state)
}
break;
default: {
break;
//
}
}
}
@@ -229,35 +227,6 @@ SetPlayerResult(PlayerResult &playerResult, boost::shared_ptr<PlayerInterface> t
playerResult.set_playermoney(tmpPlayer->getMyCash());
}
static int
GetRandomFreeSeat(PlayerList playerList) {
// seek for a free seat
PlayerListConstIterator player_i = playerList->begin();
PlayerListConstIterator player_end = playerList->end();
std::vector<int> v(10, 0);
while (player_i != player_end) {
v[(*player_i)->getMyID()] = 1; // mark seats with player
++player_i;
}
// random seats
random_shuffle(v.begin(), v.end());
int seat = -1;
// seeks first free seat
for (int i = 0; i < v.size(); i++) {
if (v[i] == 0) {
seat = i;
break;
}
}
return seat;
}
//-----------------------------------------------------------------------------
ServerGameState::~ServerGameState()
@@ -856,14 +825,6 @@ ServerGameStateStartGame::TimerTimeout(const boost::system::error_code &ec, boos
}
}
void
ServerGameStateStartGame::TimerAllowLateRegTimeout(const boost::system::error_code &ec, boost::shared_ptr<ServerGame> server)
{
if (!ec && &server->GetState() != &ServerGameStateFinal::Instance()) {
server->CancelLateReg();
}
}
void
ServerGameStateStartGame::DoStart(boost::shared_ptr<ServerGame> server)
{
@@ -891,39 +852,8 @@ ServerGameStateStartGame::DoStart(boost::shared_ptr<ServerGame> server)
++player_i;
}
{
LOG_MSG(" === SENDING DO START ====");
LOG_MSG("\tPlayers: ");
player_i = tmpPlayerList.begin();
player_end = tmpPlayerList.end();
while (player_i != player_end) {
boost::shared_ptr<PlayerData> tmpPlayer = (*player_i);
LOG_MSG("\t\t {UID, name, GUID, seat}: -> {" <<
tmpPlayer->GetUniqueId() << ", " <<
tmpPlayer->GetName() << ", " <<
tmpPlayer->GetGuid() << ", " <<
tmpPlayer->GetNumber() << "}"
);
++player_i;
}
}
server->SendToAllPlayers(packet, SessionData::Game | SessionData::Spectating);
LOG_MSG("Starting timer for LateReg");
// set late reg timer (if allowed)
if (server->IsLateReg()) {
server->GetAllowEntryTimer().expires_from_now(
minutes(server->GetGameData().maxTimeLateReg));
server->GetAllowEntryTimer().async_wait(
boost::bind(
&ServerGameStateStartGame::TimerAllowLateRegTimeout, this, boost::asio::placeholders::error, server));
}
// Start the first hand.
ServerGameStateHand::StartNewHand(server);
server->SetState(ServerGameStateHand::Instance());
@@ -958,55 +888,7 @@ AbstractServerGameStateRunning::HandleNewPlayer(boost::shared_ptr<ServerGame> se
// Wait for rejoining player to confirm start of game.
server->GetLobbyThread().GetSender().Send(session, packet);
}
else if (session && session->GetPlayerData() && server->admitReentries(session->GetPlayerData())) {
const GameData tmpGameData = server->GetGameData();
if (server->GetCurNumberOfPlayers() + static_cast<int>(server->GetNumberPlayersReentry()) < tmpGameData.maxNumberOfPlayers) { // there is a seat available
#ifndef TESTS_LATE_REG
server->MoveSessionToLobby(session, NTF_NET_REMOVED_GAME_FULL);
#else
// Uncomment next line when implemented
AcceptNewSession(server, session, false); // player wants to join
server->AddReentryPlayer(session->GetPlayerData()->GetUniqueId()); // add to list of players to reentry
LOG_MSG("Late reg is allowed and there is a seat available... unfortunatelly not implemented, yet ;)");
// Send start event right away.
boost::shared_ptr<NetPacket> packet(new NetPacket);
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_StartEventMessage);
StartEventMessage *netStartEvent = packet->GetMsg()->mutable_starteventmessage();
netStartEvent->set_starteventtype(StartEventMessage::reentryEvent); // <-- set reentry event!! TODO (albmed): Fist we have to check proto NET versions. Both NET_VERSION_MAJOR & NET_VERSION_MINOR
netStartEvent->set_gameid(server->GetId());
// Wait for rejoining player to confirm start of game.
server->GetLobbyThread().GetSender().Send(session, packet);
// TODO (albmed):
// - locate seat ---> this should be done in ServerGameStateHand::StartNewHand
// - notify players and users
// - move session to server
// - set cash
// - wait for button to pass (if necessary)
// - let player play
#endif
}
else {
server->MoveSessionToLobby(session, NTF_NET_REMOVED_GAME_FULL);
}
}
else {
} else {
// Do not accept "new" sessions in this state, only rejoin is allowed.
server->MoveSessionToLobby(session, NTF_NET_REMOVED_ALREADY_RUNNING);
}
@@ -1369,81 +1251,8 @@ ServerGameStateHand::StartNewHand(boost::shared_ptr<ServerGame> server)
curGame.getCurrentHand()->getRiver()->skipFirstRunGui();
// Consider all players, even inactive.
PlayerListIterator i;
PlayerListIterator end;
{
LOG_MSG("Starting new hand. Lets LOG: ");
LOG_MSG("\tPlayer seats");
i = curGame.getSeatsList()->begin();
end = curGame.getSeatsList()->end();
while (i != end) {
boost::shared_ptr<PlayerInterface> tmpPlayer = (*i);
LOG_MSG("\t\t {ID, name, UID} -> {" <<
tmpPlayer->getMyID() << ", " <<
tmpPlayer->getMyName() << ", " <<
tmpPlayer->getMyUniqueID() << "}"
);
++i;
}
i = curGame.getActivePlayerList()->begin();
end = curGame.getActivePlayerList()->end();
LOG_MSG("\tActive players");
while (i != end) {
boost::shared_ptr<PlayerInterface> tmpPlayer = (*i);
LOG_MSG("\t\t {ID, name, UID} -> {" <<
tmpPlayer->getMyID() << ", " <<
tmpPlayer->getMyName() << ", " <<
tmpPlayer->getMyUniqueID() << "}"
);
++i;
}
i = curGame.getRunningPlayerList()->begin();
end = curGame.getRunningPlayerList()->end();
LOG_MSG("\tRunning players");
while (i != end) {
boost::shared_ptr<PlayerInterface> tmpPlayer = (*i);
LOG_MSG("\t\t {ID, name, UID} -> {" <<
tmpPlayer->getMyID() << ", " <<
tmpPlayer->getMyName() << ", " <<
tmpPlayer->getMyUniqueID() << "}"
);
++i;
}
PlayerDataList tmpPlayerList(server->GetFullPlayerDataList());
LOG_MSG("\tAll Data players");
PlayerDataList::iterator player_i = tmpPlayerList.begin();
PlayerDataList::iterator player_end = tmpPlayerList.end();
while (player_i != player_end) {
boost::shared_ptr<PlayerData> tmpPlayer = (*player_i);
LOG_MSG("\t\tPlayerData: {playerId, name, number} -> {" <<
tmpPlayer->GetUniqueId() << "," <<
tmpPlayer->GetName() << "," <<
//tmpPlayer->GetGuid() << "," <<
tmpPlayer->GetNumber() << "}"
);
++player_i;
}
}
// Consider all players, even inactive.
i = curGame.getSeatsList()->begin();
end = curGame.getSeatsList()->end();
PlayerListIterator i = curGame.getSeatsList()->begin();
PlayerListIterator end = curGame.getSeatsList()->end();
// Send cards to all players.
while (i != end) {
@@ -1608,21 +1417,6 @@ ServerGameStateHand::InitRejoiningPlayers(boost::shared_ptr<ServerGame> server)
}
}
void
ServerGameStateHand::InitReetryPlayers(boost::shared_ptr<ServerGame> server)
{
PlayerIdList reentryIdList(server->GetAndResetReentryPlayers());
PlayerIdList::iterator i = reentryIdList.begin();
PlayerIdList::iterator end = reentryIdList.end();
while (i != end) {
boost::shared_ptr<SessionData> session(server->GetSessionManager().GetSessionByUniquePlayerId(*i));
if (session && session->GetPlayerData()) {
PerformReentry(server, session);
}
++i;
}
}
void
ServerGameStateHand::InitNewSpectators(boost::shared_ptr<ServerGame> server)
{
@@ -1669,102 +1463,6 @@ ServerGameStateHand::PerformRejoin(boost::shared_ptr<ServerGame> server, boost::
}
}
void
ServerGameStateHand::PerformReentry(boost::shared_ptr<ServerGame> server, boost::shared_ptr<SessionData> session)
{
Game &curGame = server->GetGame();
// TODO (albmed):
// Create player interface
if (session) {
// check if player already played this game
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame.getPlayerByName(session->GetPlayerData()->GetName());
if (!tmpPlayer) {
// TODO: Late registration implementation is postponed
throw ServerException(__FILE__, __LINE__, ERR_NET_INTERNAL_GAME_ERROR, 0);
// tmpPlayer = curGame.addNewPlayer(session->GetPlayerData()); // TODO (albmed): Create addNewPlayer method
}
else {
// This means this is a reentry, because player already played this game
// check for id change
if (session->GetPlayerData()->GetUniqueId() != tmpPlayer->getMyUniqueID()) {
// Notify other clients about id change.
boost::shared_ptr<NetPacket> packet(new NetPacket);
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_PlayerIdChangedMessage);
PlayerIdChangedMessage *netIdChanged = packet->GetMsg()->mutable_playeridchangedmessage();
netIdChanged->set_oldplayerid(tmpPlayer->getMyUniqueID());
netIdChanged->set_newplayerid(session->GetPlayerData()->GetUniqueId());
server->SendToAllButOnePlayers(packet, session->GetId(), SessionData::Game | SessionData::Spectating | SessionData::SpectatorWaiting);
// Update the dealer, if necessary.
curGame.replaceDealer(tmpPlayer->getMyUniqueID(), session->GetPlayerData()->GetUniqueId());
// Update the ranking map.
server->ReplaceRankingPlayer(tmpPlayer->getMyUniqueID(), session->GetPlayerData()->GetUniqueId());
// Change the Id in the poker engine.
tmpPlayer->setMyUniqueID(session->GetPlayerData()->GetUniqueId());
tmpPlayer->setMyGuid(session->GetPlayerData()->GetGuid());
}
tmpPlayer->markRemoteAction();
tmpPlayer->setIsSessionActive(true);
SendGameDataReentry(server, session); // TODO (albmed): This method should be duplicated
// - to send starting game cash: server->GetGameData().startMoney
// - to make a new reentry message
}
/* int seat = GetRandomFreeSeat(curGame.getActivePlayerList()); // (albmed): if reentry, assign same seat or find a new one?
if (seat >= 0) { // ok
// seat found....
// is between dealer? TODO (albmed)
unsigned dealerPosition = curGame.getDealerPosition();
}
else throw ServerException(__FILE__, __LINE__, ERR_NET_INTERNAL_GAME_ERROR, 0); */
}
}
int
ServerGameStateHand::GetRandomFreeSeat(const PlayerList playerList) {
// seek for a free seat
PlayerListConstIterator player_i = playerList->begin();
PlayerListConstIterator player_end = playerList->end();
std::vector<int> v(10, 0);
while (player_i != player_end) {
v[(*player_i)->getMyID()] = 1; // mark seats with player
++player_i;
}
// random seats
random_shuffle(v.begin(), v.end());
int seat = -1;
// seeks first free seat
for(std::vector<int>::size_type i = 0; i != v.size(); i++) {
if (v[i] == 0) {
seat = i;
break;
}
}
return seat;
}
void
ServerGameStateHand::SendGameData(boost::shared_ptr<ServerGame> server, boost::shared_ptr<SessionData> session)
{
@@ -1791,33 +1489,6 @@ ServerGameStateHand::SendGameData(boost::shared_ptr<ServerGame> server, boost::s
server->GetLobbyThread().GetSender().Send(session, packet);
}
void
ServerGameStateHand::SendGameDataReentry(boost::shared_ptr<ServerGame> server, boost::shared_ptr<SessionData> session)
{
Game &curGame = server->GetGame();
// Send game start notification to reentry client.
boost::shared_ptr<NetPacket> packet(new NetPacket);
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_GameStartReentryMessage);
GameStartReentryMessage *netGameStart = packet->GetMsg()->mutable_gamestartreentrymessage();
netGameStart->set_gameid(server->GetId());
netGameStart->set_startdealerplayerid(curGame.getDealerPosition());
netGameStart->set_handnum(curGame.getCurrentHandID());
PlayerListIterator player_i = curGame.getSeatsList()->begin();
PlayerListIterator player_end = curGame.getSeatsList()->end();
int player_count = 0;
while (player_i != player_end && player_count < server->GetStartData().numberOfPlayers) {
boost::shared_ptr<PlayerInterface> tmpPlayer = *player_i;
GameStartReentryMessage::ReentryPlayerData *playerSlot = netGameStart->add_reentryplayerdata();
playerSlot->set_playerid(tmpPlayer->getMyUniqueID());
playerSlot->set_playermoney(server->GetGameData().startMoney);
++player_i;
++player_count;
}
server->GetLobbyThread().GetSender().Send(session, packet);
}
//-----------------------------------------------------------------------------
+10 -37
View File
@@ -62,10 +62,8 @@
#include <boost/uuid/uuid.hpp>
#include <boost/algorithm/string.hpp>
#include <gsasl.h>
#include <ctime>
#include <string>
#define SERVER_MAX_NUM_LOBBY_SESSIONS 1536 // Maximum number of idle users in lobby.
#define SERVER_MAX_NUM_LOBBY_SESSIONS 512 // Maximum number of idle users in lobby.
#define SERVER_MAX_NUM_TOTAL_SESSIONS 2000 // Total maximum of sessions, fitting a 2048 handle limit
#define SERVER_SAVE_STATISTICS_INTERVAL_SEC 60
@@ -305,8 +303,7 @@ ServerLobbyThread::AddConnection(boost::shared_ptr<SessionData> sessionData)
// Create a new session.
m_sessionManager.AddSession(sessionData);
LOG_VERBOSE(sessionData->GetRemoteIPAddressFromSocket() << " Accepted connection - session #" << sessionData->GetId() << ".");
LOG_ERROR(sessionData->GetRemoteIPAddressFromSocket() << " Accepted connection - session #" << sessionData->GetId() << ".");
LOG_VERBOSE("Accepted connection - session #" << sessionData->GetId() << ".");
sessionData->StartTimerInitTimeout(SERVER_INIT_SESSION_TIMEOUT_SEC);
sessionData->StartTimerGlobalTimeout(SERVER_SESSION_FORCED_TIMEOUT_SEC);
@@ -1350,7 +1347,7 @@ ServerLobbyThread::HandleNetPacketRetrieveAvatar(boost::shared_ptr<SessionData>
void
ServerLobbyThread::HandleNetPacketCreateGame(boost::shared_ptr<SessionData> session, const JoinNewGameMessage &newGame)
{
LOG_ERROR("Creating new game, initiated by session #" << session->GetId() << ".");
LOG_VERBOSE("Creating new game, initiated by session #" << session->GetId() << ".");
string password;
if (newGame.has_password())
@@ -1369,13 +1366,6 @@ ServerLobbyThread::HandleNetPacketCreateGame(boost::shared_ptr<SessionData> sess
boost::replace_all(gameName, "\f", " ");
unsigned gameId = GetNextGameId();
LOG_MSG ("Creating game with new params: {allowLate, allowReentries, numReentries, maxTimeLateReg} -> {" <<
std::boolalpha <<
tmpData.allowLateReg << ", " <<
tmpData.allowReentries << ", " <<
tmpData.numReentries << ", " <<
tmpData.maxTimeLateReg << "}");
if (gameName.empty() || !isprint(gameName[0])) {
SendJoinGameFailed(session, gameId, NTF_NET_JOIN_GAME_BAD_NAME);
} else if (IsGameNameInUse(gameName)) {
@@ -1387,10 +1377,6 @@ ServerLobbyThread::HandleNetPacketCreateGame(boost::shared_ptr<SessionData> sess
SendJoinGameFailed(session, gameId, NTF_NET_JOIN_GUEST_FORBIDDEN);
} else if (!ServerGame::CheckSettings(tmpData, password, GetServerMode())) {
SendJoinGameFailed(session, gameId, NTF_NET_JOIN_INVALID_SETTINGS);
} else if (!session->GetPlayerData()->IsPlayerAllowedToJoinCreateLimitRank(m_serverConfig.readConfigString("ServerLimitRankNum"), m_serverConfig.readConfigString("ServerLimitRankPeriod"))
&& tmpData.gameType == GAME_TYPE_RANKING ) {
LOG_ERROR("not allowed due to ranklimit");
SendJoinGameFailed(session, gameId, NTF_NET_JOIN_IP_BLOCKED);
} else {
boost::shared_ptr<ServerGame> game(
new ServerGame(
@@ -1432,7 +1418,6 @@ ServerLobbyThread::HandleNetPacketJoinGame(boost::shared_ptr<SessionData> sessio
MoveSessionToGame(game, session, joinGame.autoleave(), true);
}
} else {
LOG_ERROR("JoinGame pre validation");
// As guest, you are only allowed to join normal games.
if (session->GetPlayerData()->GetRights() == PLAYER_RIGHTS_GUEST
&& tmpData.gameType != GAME_TYPE_NORMAL) {
@@ -1442,14 +1427,14 @@ ServerLobbyThread::HandleNetPacketJoinGame(boost::shared_ptr<SessionData> sessio
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_NOT_INVITED);
} else if (!game->CheckPassword(password)) {
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_INVALID_PASSWORD);
} else if (tmpData.gameType == GAME_TYPE_RANKING && !session->GetPlayerData()->IsPlayerAllowedToJoinCreateLimitRank(m_serverConfig.readConfigString("ServerLimitRankNum"), m_serverConfig.readConfigString("ServerLimitRankPeriod"))) {
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED);
} else if (tmpData.gameType == GAME_TYPE_RANKING && !joinGame.spectateonly()
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4V6
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4
&& game->IsClientAddressConnected(session->GetClientAddr())) {
} else if (tmpData.gameType == GAME_TYPE_RANKING
&& !joinGame.spectateonly()
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4V6
&& session->GetClientAddr() != SERVER_ADDRESS_LOCALHOST_STR_V4
&& game->IsClientAddressConnected(session->GetClientAddr())) {
SendJoinGameFailed(session, joinGame.gameid(), NTF_NET_JOIN_IP_BLOCKED);
} else {
MoveSessionToGame(game, session, joinGame.autoleave(), false);
}
@@ -1818,18 +1803,6 @@ ServerLobbyThread::UserValid(unsigned playerId, const DBPlayerData &dbPlayerData
if (tmpSession && tmpSession->GetPlayerData()) {
tmpSession->GetPlayerData()->SetDBId(dbPlayerData.id);
tmpSession->GetPlayerData()->SetCountry(dbPlayerData.country);
if(dbPlayerData.last_games.length() > 0){
LOG_ERROR("last_games from db = " << dbPlayerData.last_games);
vector<string> last_games;
boost::split(last_games, dbPlayerData.last_games, boost::is_any_of(","));
for (unsigned int i = 0; i < last_games.size(); i++){
if(last_games[i].length() > 0)
tmpSession->GetPlayerData()->AddPlayerLastGame(stol(last_games[i]));
}
LOG_ERROR("last_games last from vector after db = " << tmpSession->GetPlayerData()->GetPlayerLastGames().back());
}else{
LOG_ERROR("no lastGames from db");
}
this->AuthChallenge(tmpSession, dbPlayerData.secret);
}
}
-2
View File
@@ -34,8 +34,6 @@
#include <net/serverexception.h>
#include <net/socket_msg.h>
#include <ctime>
using namespace std;
#define SERVER_MAX_GUEST_USERS_LOBBY 50 // LG: Maximum number of guests users in lobby allowed
-1
View File
@@ -85,7 +85,6 @@ protected:
static bool ValidateStartEventAckMessage(const NetPacket &packet);
static bool ValidateGameStartInitialMessage(const NetPacket &packet);
static bool ValidateGameStartRejoinMessage(const NetPacket &packet);
static bool ValidateGameStartReentryMessage(const NetPacket &packet);
static bool ValidateHandStartMessage(const NetPacket &packet);
static bool ValidatePlayersTurnMessage(const NetPacket &packet);
static bool ValidateMyActionRequestMessage(const NetPacket &packet);
-18
View File
@@ -111,10 +111,6 @@ public:
void AddRejoinPlayer(unsigned playerId);
PlayerIdList GetAndResetRejoinPlayers();
void AddReentryPlayer(unsigned playerId);
PlayerIdList GetAndResetReentryPlayers();
unsigned GetNumberPlayersReentry();
void AddReactivatePlayer(unsigned playerId);
PlayerIdList GetAndResetReactivatePlayers();
@@ -132,10 +128,6 @@ public:
void AddPlayerToNumJoinsPerPlayer(const std::string &playerName);
int GetNumJoinsPerPlayer(const std::string &playerName);
bool admitReentries(boost::shared_ptr<PlayerData> player);
void CancelLateReg();
bool IsLateReg();
protected:
@@ -156,7 +148,6 @@ protected:
void SetPlayerPlace(unsigned playerId, int place);
void ReplaceRankingPlayer(unsigned oldPlayerId, unsigned newPlayerId);
void StoreAndResetRanking();
void StoreLastGames(const PlayerDataList &playerDataList);
void RemoveAutoLeavePlayers();
void InternalEndGame();
@@ -192,7 +183,6 @@ protected:
boost::asio::steady_timer &GetStateTimer1();
boost::asio::steady_timer &GetStateTimer2();
boost::asio::steady_timer &GetAllowEntryTimer();
const StartData &GetStartData() const;
void SetStartData(const StartData &startData);
@@ -205,8 +195,6 @@ protected:
SessionManager &GetSessionManager();
ServerDBInterface &GetDatabase();
void setEntries(const PlayerDataList &playerData);
typedef std::map<std::string, int> NumJoinsPerPlayerMap;
private:
@@ -225,9 +213,6 @@ private:
PlayerIdList m_rejoinPlayerList;
mutable boost::mutex m_rejoinPlayerListMutex;
PlayerIdList m_reentryPlayerList;
mutable boost::mutex m_reentryPlayerListMutex;
PlayerIdList m_reactivatePlayerList;
mutable boost::mutex m_reactivatePlayerListMutex;
@@ -261,9 +246,7 @@ private:
boost::asio::steady_timer m_voteKickTimer;
boost::asio::steady_timer m_stateTimer1;
boost::asio::steady_timer m_stateTimer2;
boost::asio::steady_timer m_allowEntryTimer;
bool m_isNameReported;
bool m_isLateRegAllowed;
friend class ServerLobbyThread;
friend class AbstractServerGameStateReceiving;
@@ -276,7 +259,6 @@ private:
friend class ServerGameStateWaitNextHand;
NumJoinsPerPlayerMap m_numJoinsPerPlayer;
NumJoinsPerPlayerMap m_numEntriesPlayer;
};
#endif
-6
View File
@@ -36,7 +36,6 @@
#include <boost/asio.hpp>
#include <playerdata.h>
#include <net/sessionmanager.h>
#include <engine/engine_defs.h>
#ifdef _MSC_VER
@@ -146,7 +145,6 @@ protected:
virtual void InternalProcessPacket(boost::shared_ptr<ServerGame> server, boost::shared_ptr<SessionData> session, boost::shared_ptr<NetPacket> packet);
void TimerTimeout(const boost::system::error_code &ec, boost::shared_ptr<ServerGame> server);
void TimerAllowLateRegTimeout(const boost::system::error_code &ec, boost::shared_ptr<ServerGame> server);
void DoStart(boost::shared_ptr<ServerGame> server);
private:
@@ -193,13 +191,9 @@ protected:
static void CheckPlayerTimeouts(boost::shared_ptr<ServerGame> server);
static void ReactivatePlayers(boost::shared_ptr<ServerGame> server);
static void InitRejoiningPlayers(boost::shared_ptr<ServerGame> server);
static void InitReetryPlayers(boost::shared_ptr<ServerGame> server);
static void InitNewSpectators(boost::shared_ptr<ServerGame> server);
static void PerformRejoin(boost::shared_ptr<ServerGame> server, boost::shared_ptr<SessionData> session);
static void PerformReentry(boost::shared_ptr<ServerGame> server, boost::shared_ptr<SessionData> session);
static void SendGameData(boost::shared_ptr<ServerGame> server, boost::shared_ptr<SessionData> session);
static void SendGameDataReentry(boost::shared_ptr<ServerGame> server, boost::shared_ptr<SessionData> session);
static int GetRandomFreeSeat(const PlayerList playerList);
private:
static ServerGameStateHand s_state;
-1
View File
@@ -40,7 +40,6 @@ typedef unsigned SessionId;
#include <boost/thread.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <string>
#include <vector>
#include <net/socket_helper.h>
#include <net/sessiondatacallback.h>
-2
View File
@@ -65,8 +65,6 @@ public:
bool IsPlayerConnected(unsigned uniqueId) const;
bool IsClientAddressConnected(const std::string &clientAddress) const;
bool IsGuestAllowedToConnect(const std::string &clientAddress) const;
bool IsPlayerAllowedToJoinCreateLimitRank(const std::string &playerName) const;
bool IsPlayerAllowedToJoinCreateLimitRank(unsigned uniqueId) const;
void ForEach(boost::function<void (boost::shared_ptr<SessionData>)> func);
-58
View File
@@ -29,8 +29,6 @@
* as that of the covered work. *
*****************************************************************************/
#include <playerdata.h>
#include <ctime>
#include <core/loghelper.h> // @TODO: remove in productive
using namespace std;
@@ -244,59 +242,3 @@ PlayerData::operator<(const PlayerData &other) const
return m_number < other.GetNumber();
}
void
PlayerData::SetPlayerLastGames(std::vector<long> last_games)
{
boost::mutex::scoped_lock lock(m_dataMutex);
m_last_games.clear();
m_last_games = last_games;
}
void
PlayerData::AddPlayerLastGame(long lastGame)
{
boost::mutex::scoped_lock lock(m_dataMutex);
m_last_games.push_back(lastGame);
}
std::vector<long>
PlayerData::GetPlayerLastGames()
{
boost::mutex::scoped_lock lock(m_dataMutex);
return m_last_games;
}
bool
PlayerData::IsPlayerAllowedToJoinCreateLimitRank(std::string num, std::string period)
{
bool retVal = false;
LOG_ERROR("checking IsPlayerAllowedToJoinCreateLimitRank() ");
LOG_ERROR("num = " << num << " period " << period);
boost::mutex::scoped_lock lock(m_dataMutex);
long then = (long)time(NULL) - (long)(stoi(period) * 60);
int count = 0;
int i=0;
for(std::vector<long>::iterator timeStamp = m_last_games.begin(); timeStamp != m_last_games.end(); ++timeStamp) {
LOG_ERROR("timeStamp " << *timeStamp);
time_t ts = (time_t)*timeStamp;
LOG_ERROR("comparing ts " << (long)ts << " with " << then);
if((long)ts > then){
LOG_ERROR("counting timeStamp in time " << ctime(&ts));
count++;
}else{
LOG_ERROR("erasing overdued timestamp " << ctime(&ts));
timeStamp = m_last_games.erase(timeStamp); // erase overdued entries
if( timeStamp == m_last_games.end())
break;
}
i++;
}
if(count < stoi(num))
retVal = true;
return retVal;
}
-8
View File
@@ -116,12 +116,6 @@ public:
int GetStartCash() const;
void SetStartCash(int cash);
// @TODO: last_games here
void AddPlayerLastGame(long last_games);
void SetPlayerLastGames(std::vector<long> last_games);
std::vector<long> GetPlayerLastGames();
bool IsPlayerAllowedToJoinCreateLimitRank(std::string num, std::string period);
bool operator<(const PlayerData &other) const;
private:
@@ -141,8 +135,6 @@ private:
bool m_isGameAdmin;
boost::shared_ptr<AvatarFile> m_netAvatarFile;
std::vector<long> m_last_games;
mutable boost::mutex m_dataMutex;
};
-9
View File
@@ -41,7 +41,6 @@
#include <net/clientthread.h>
#include <core/avatarmanager.h>
#include <net/servermanagerfactory.h>
#include <core/loghelper.h>
#include <sstream>
@@ -282,14 +281,6 @@ void Session::clientCreateGame(const GameData &gameData, const string &name, con
{
if (!myNetClient)
return; // only act if client is running.
std::cout << "Creating game with new params: {allowLate, allowReentries, numReentries, maxTimeLateReg} -> {" <<
std::boolalpha <<
gameData.allowLateReg << ", " <<
gameData.allowReentries << "," <<
gameData.numReentries << ", " <<
gameData.maxTimeLateReg << "}" << std::endl;
myNetClient->SendCreateGame(
gameData,
name,
+1465 -1108
View File
File diff suppressed because it is too large Load Diff
+655 -1270
View File
File diff suppressed because it is too large Load Diff
+23635 -17795
View File
File diff suppressed because it is too large Load Diff
+8731 -20503
View File
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More