Author SHA1 Message Date
Kai Philipp 29259f1f29 bugfix 2020-01-25 17:23:44 +01:00
Kai Philipp 1ff513e09a bugfix 2020-01-25 17:17:41 +01:00
Kai Philipp b03d39d141 bugfix 2020-01-25 17:16:54 +01:00
Kai Philipp 99de54cdf5 string output optimized 2020-01-25 17:16:09 +01:00
Kai Philipp d2849449ce bugfix 2020-01-25 17:14:13 +01:00
Kai Philipp f31127e695 bugfix 2020-01-25 17:12:08 +01:00
Kai Philipp 03602cd37f pro missing linked boost_random 2020-01-25 17:10:09 +01:00
Kai Philipp a5c8aefeb2 pro missing linked boost 2020-01-25 17:05:33 +01:00
Kai Philipp 4e888e2cfe pro file adaption 2020-01-25 16:59:22 +01:00
Kai Philipp c96955e719 pro file adaptions 2020-01-25 16:58:08 +01:00
Kai Philipp ef1ccfdbd7 bugfix 2020-01-25 16:55:54 +01:00
Kai Philipp cedf5f7218 bugfix 2020-01-25 16:53:13 +01:00
Kai Philipp ad80896fae dealer_random_test added 2020-01-25 16:50:06 +01:00
37 changed files with 58345 additions and 111119 deletions
+3 -4
View File
@@ -8,15 +8,14 @@ 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
pokerth_server
.vscode/
.project
.classpath
+86
View File
@@ -0,0 +1,86 @@
# QMake pro-file for the PokerTH dedicated server
isEmpty( PREFIX ){
PREFIX =/usr
}
TEMPLATE = app
CODECFORSRC = UTF-8
CONFIG += thread console embed_manifest_exe exceptions rtti stl warn_on
UI_DIR = uics
TARGET = bin/dealer_random_test
MOC_DIR = mocs
OBJECTS_DIR = obj
DEFINES += PREFIX=\"$${PREFIX}\"
QT -= core gui
#PRECOMPILED_HEADER = src/pch_lib.h
INCLUDEPATH += . \
src
DEPENDPATH += . \
src
# Input
SOURCES += \
src/dealer_random_test.cpp
unix : !mac {
##### My release static build options
#QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections
#QMAKE_LFLAGS += -Wl,--gc-sections
QMAKE_LIBDIR += lib $${PREFIX}/lib /opt/gsasl/lib
INCLUDEPATH += $${PREFIX}/include
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
BOOST_SYS = boost_system boost_system-mt
#
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
# to override the default '/usr' pass PREFIX
# variable to qmake.
#
for(dir, LIB_DIRS){
exists($$dir){
for(lib, BOOST_PROGRAM_OPTIONS):exists($${dir}/lib$${lib}.so*) {
message("Found $$lib")
BOOST_PROGRAM_OPTIONS = -l$$lib
}
for(lib, BOOST_PROGRAM_OPTIONS):exists($${dir}/lib$${lib}.a) {
message("Found $$lib")
BOOST_PROGRAM_OPTIONS = -l$$lib
}
for(lib, BOOST_SYS):exists($${dir}/lib$${lib}.so*) {
message("Found $$lib")
BOOST_SYS = -l$$lib
}
for(lib, BOOST_SYS):exists($${dir}/lib$${lib}.a) {
message("Found $$lib")
BOOST_SYS = -l$$lib
}
}
}
BOOST_LIBS = $$BOOST_PROGRAM_OPTIONS $$BOOST_SYS
!count(BOOST_LIBS, 2){
error("Unable to find boost libraries in PREFIX=$${PREFIX}")
}
UNAME = $$system(uname -s)
BSD = $$find(UNAME, "BSD")
kFreeBSD = $$find(UNAME, "kFreeBSD")
LIBS += $$BOOST_LIBS
LIBS += -lprotobuf -lgsasl -lgcrypt -lidn -lboost_thread -lboost_system -lboost_random
#### INSTALL ####
binary.path += $${PREFIX}/bin/
binary.files += dealer_random_test
INSTALLS += binary
}
-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;
}
+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;
}
+115
View File
@@ -0,0 +1,115 @@
/*****************************************************************************
* PokerTH - The open source texas holdem engine *
* Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* *
* Additional permission under GNU AGPL version 3 section 7 *
* *
* If you modify this program, or any covered work, by linking or *
* combining it with the OpenSSL project's OpenSSL library (or a *
* modified version of that library), containing parts covered by the *
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
* permission to convey the resulting work. *
* Corresponding Source for a non-source form of such a combination *
* shall include the source code for the parts of OpenSSL used as well *
* as that of the covered work. *
*****************************************************************************/
// Connectivity test program for PokerTH
#include <iostream>
#include <boost/program_options.hpp>
#include <boost/thread.hpp>
#include <boost/nondet_random.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/variate_generator.hpp>
using namespace std;
namespace po = boost::program_options;
boost::thread_specific_ptr<boost::random_device> g_rand_state;
struct nondet_rng : std::unary_function<unsigned, unsigned> {
boost::random_device &_state;
unsigned operator()(unsigned i)
{
boost::uniform_int<> rng(0, i - 1);
return rng(_state);
}
nondet_rng(boost::random_device &state) : _state(state) {}
};
int
main(int argc, char *argv[])
{
try {
// Check command line options.
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "produce help message")
("num,n", po::value<int>(), "set num of deals")
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if (vm.count("help")) {
cout << desc << endl;
return 1;
}
if (!vm.count("num")) {
cout << "Missing option!" << endl << desc << endl;
return 1;
}
int num = vm["num"].as<int>();
const int NumCards = 52;
for(int i=0; i<num;i++){
// shuffle cards
int cardsArray[NumCards] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
50, 51
};
if (!g_rand_state.get()) {
g_rand_state.reset(new boost::random_device);
}
nondet_rng rand(*g_rand_state);
random_shuffle(&cardsArray[0], &cardsArray[NumCards], rand);
ostringstream oss("");
for (int temp = 0; temp < NumCards; temp++){
if(temp > 0) cout << ",";
cout << cardsArray[temp];
}
cout << endl;
}
} catch (...) {
cout << "Exception caught" << endl;
return 1;
}
return 0;
}
+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();
+1 -6
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()
-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 -145
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());
}
@@ -367,8 +353,6 @@ ServerGame::InternalStartGame()
if (GetGameData().gameType == GAME_TYPE_RANKING)
StoreLastGames(playerData);
setEntries(playerData);
}
return playerData;
@@ -508,7 +492,6 @@ ServerGame::InternalEndGame()
StoreAndResetRanking();
m_game.reset();
m_numJoinsPerPlayer.clear();
m_numEntriesPlayer.clear();
}
void
@@ -795,13 +778,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 +787,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 +1119,6 @@ ServerGame::GetStateTimer2()
return m_stateTimer2;
}
boost::asio::steady_timer &
ServerGame::GetAllowEntryTimer()
{
return m_allowEntryTimer;
}
Game &
ServerGame::GetGame()
{
@@ -1230,17 +1184,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 +1220,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);
}
//-----------------------------------------------------------------------------
+3 -11
View File
@@ -63,9 +63,8 @@
#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 +304,8 @@ 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() << ".");
LOG_ERROR("Accepted connection - session #" << sessionData->GetId() << ".");
sessionData->StartTimerInitTimeout(SERVER_INIT_SESSION_TIMEOUT_SEC);
sessionData->StartTimerGlobalTimeout(SERVER_SESSION_FORCED_TIMEOUT_SEC);
@@ -1369,13 +1368,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)) {
-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);
-17
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:
@@ -192,7 +184,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 +196,6 @@ protected:
SessionManager &GetSessionManager();
ServerDBInterface &GetDatabase();
void setEntries(const PlayerDataList &playerData);
typedef std::map<std::string, int> NumJoinsPerPlayerMap;
private:
@@ -225,9 +214,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 +247,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 +260,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;
-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,
+1297 -1606
View File
File diff suppressed because it is too large Load Diff
+1023 -1699
View File
File diff suppressed because it is too large Load Diff
+27789 -32628
View File
File diff suppressed because it is too large Load Diff
+13985 -27370
View File
File diff suppressed because it is too large Load Diff
@@ -311,10 +311,9 @@ public:
* needed.
*/
timer_ptr set_timer(long duration, timer_handler callback) {
timer_ptr new_timer(
new lib::asio::steady_timer(
*m_io_service,
lib::asio::milliseconds(duration))
timer_ptr new_timer = lib::make_shared<lib::asio::steady_timer>(
lib::ref(*m_io_service),
lib::asio::milliseconds(duration)
);
if (config::enable_multithreading) {
@@ -462,7 +461,8 @@ protected:
m_io_service = io_service;
if (config::enable_multithreading) {
m_strand.reset(new lib::asio::io_service::strand(*io_service));
m_strand = lib::make_shared<lib::asio::io_service::strand>(
lib::ref(*io_service));
}
lib::error_code ec = socket_con_type::init_asio(io_service, m_strand,
@@ -191,7 +191,8 @@ public:
m_io_service = ptr;
m_external_io_service = true;
m_acceptor.reset(new lib::asio::ip::tcp::acceptor(*m_io_service));
m_acceptor = lib::make_shared<lib::asio::ip::tcp::acceptor>(
lib::ref(*m_io_service));
m_state = READY;
ec = lib::error_code();
@@ -659,7 +660,9 @@ public:
* @since 0.3.0
*/
void start_perpetual() {
m_work.reset(new lib::asio::io_service::work(*m_io_service));
m_work = lib::make_shared<lib::asio::io_service::work>(
lib::ref(*m_io_service)
);
}
/// Clears the endpoint's perpetual flag, allowing it to exit when empty
@@ -823,7 +826,8 @@ protected:
// Create a resolver
if (!m_resolver) {
m_resolver.reset(new lib::asio::ip::tcp::resolver(*m_io_service));
m_resolver = lib::make_shared<lib::asio::ip::tcp::resolver>(
lib::ref(*m_io_service));
}
tcon->set_uri(u);
@@ -168,7 +168,8 @@ protected:
return socket::make_error_code(socket::error::invalid_state);
}
m_socket.reset(new lib::asio::ip::tcp::socket(*service));
m_socket = lib::make_shared<lib::asio::ip::tcp::socket>(
lib::ref(*service));
m_state = READY;
@@ -193,7 +193,8 @@ protected:
if (!m_context) {
return socket::make_error_code(socket::error::invalid_tls_context);
}
m_socket.reset(new socket_type(*service, *m_context));
m_socket = lib::make_shared<socket_type>(
_WEBSOCKETPP_REF(*service),lib::ref(*m_context));
m_io_service = service;
m_strand = strand;
File diff suppressed because it is too large Load Diff