Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29259f1f29 | ||
|
|
1ff513e09a | ||
|
|
b03d39d141 | ||
|
|
99de54cdf5 | ||
|
|
d2849449ce | ||
|
|
f31127e695 | ||
|
|
03602cd37f | ||
|
|
a5c8aefeb2 | ||
|
|
4e888e2cfe | ||
|
|
c96955e719 | ||
|
|
ef1ccfdbd7 | ||
|
|
cedf5f7218 | ||
|
|
ad80896fae |
+3
-4
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,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);
|
||||
|
||||
+1
-1
@@ -23806,7 +23806,7 @@ bool ErrorMessage_ErrorReason_IsValid(int value) {
|
||||
}
|
||||
|
||||
#ifndef _MSC_VER
|
||||
const ErrorMessage_ErrorReason ErrorMessage::custReserved;
|
||||
const ErrorMessage_ErrorReason ErrorMessage::reserved;
|
||||
const ErrorMessage_ErrorReason ErrorMessage::initVersionNotSupported;
|
||||
const ErrorMessage_ErrorReason ErrorMessage::initServerFull;
|
||||
const ErrorMessage_ErrorReason ErrorMessage::initAuthFailure;
|
||||
|
||||
+3
-3
@@ -345,7 +345,7 @@ const ReportGameAckMessage_ReportGameResult ReportGameAckMessage_ReportGameResul
|
||||
const int ReportGameAckMessage_ReportGameResult_ReportGameResult_ARRAYSIZE = ReportGameAckMessage_ReportGameResult_ReportGameResult_MAX + 1;
|
||||
|
||||
enum ErrorMessage_ErrorReason {
|
||||
ErrorMessage_ErrorReason_custReserved = 0,
|
||||
ErrorMessage_ErrorReason_reserved = 0,
|
||||
ErrorMessage_ErrorReason_initVersionNotSupported = 1,
|
||||
ErrorMessage_ErrorReason_initServerFull = 2,
|
||||
ErrorMessage_ErrorReason_initAuthFailure = 3,
|
||||
@@ -362,7 +362,7 @@ enum ErrorMessage_ErrorReason {
|
||||
ErrorMessage_ErrorReason_sessionTimeout = 14
|
||||
};
|
||||
bool ErrorMessage_ErrorReason_IsValid(int value);
|
||||
const ErrorMessage_ErrorReason ErrorMessage_ErrorReason_ErrorReason_MIN = ErrorMessage_ErrorReason_custReserved;
|
||||
const ErrorMessage_ErrorReason ErrorMessage_ErrorReason_ErrorReason_MIN = ErrorMessage_ErrorReason_reserved;
|
||||
const ErrorMessage_ErrorReason ErrorMessage_ErrorReason_ErrorReason_MAX = ErrorMessage_ErrorReason_sessionTimeout;
|
||||
const int ErrorMessage_ErrorReason_ErrorReason_ARRAYSIZE = ErrorMessage_ErrorReason_ErrorReason_MAX + 1;
|
||||
|
||||
@@ -10416,7 +10416,7 @@ class ErrorMessage : public ::google::protobuf::MessageLite {
|
||||
// nested types ----------------------------------------------------
|
||||
|
||||
typedef ErrorMessage_ErrorReason ErrorReason;
|
||||
static const ErrorReason custReserved = ErrorMessage_ErrorReason_custReserved;
|
||||
static const ErrorReason reserved = ErrorMessage_ErrorReason_reserved;
|
||||
static const ErrorReason initVersionNotSupported = ErrorMessage_ErrorReason_initVersionNotSupported;
|
||||
static const ErrorReason initServerFull = ErrorMessage_ErrorReason_initServerFull;
|
||||
static const ErrorReason initAuthFailure = ErrorMessage_ErrorReason_initAuthFailure;
|
||||
|
||||
@@ -48996,9 +48996,9 @@ public final class ProtoBuf {
|
||||
public enum ErrorReason
|
||||
implements com.google.protobuf.Internal.EnumLite {
|
||||
/**
|
||||
* <code>custReserved = 0;</code>
|
||||
* <code>reserved = 0;</code>
|
||||
*/
|
||||
custReserved(0, 0),
|
||||
reserved(0, 0),
|
||||
/**
|
||||
* <code>initVersionNotSupported = 1;</code>
|
||||
*/
|
||||
@@ -49058,9 +49058,9 @@ public final class ProtoBuf {
|
||||
;
|
||||
|
||||
/**
|
||||
* <code>custReserved = 0;</code>
|
||||
* <code>reserved = 0;</code>
|
||||
*/
|
||||
public static final int custReserved_VALUE = 0;
|
||||
public static final int reserved_VALUE = 0;
|
||||
/**
|
||||
* <code>initVersionNotSupported = 1;</code>
|
||||
*/
|
||||
@@ -49123,7 +49123,7 @@ public final class ProtoBuf {
|
||||
|
||||
public static ErrorReason valueOf(int value) {
|
||||
switch (value) {
|
||||
case 0: return custReserved;
|
||||
case 0: return reserved;
|
||||
case 1: return initVersionNotSupported;
|
||||
case 2: return initServerFull;
|
||||
case 3: return initAuthFailure;
|
||||
@@ -49180,7 +49180,7 @@ public final class ProtoBuf {
|
||||
}
|
||||
|
||||
private void initFields() {
|
||||
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.custReserved;
|
||||
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.reserved;
|
||||
}
|
||||
private byte memoizedIsInitialized = -1;
|
||||
public final boolean isInitialized() {
|
||||
@@ -49309,7 +49309,7 @@ public final class ProtoBuf {
|
||||
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.custReserved;
|
||||
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.reserved;
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
return this;
|
||||
}
|
||||
@@ -49379,7 +49379,7 @@ public final class ProtoBuf {
|
||||
}
|
||||
private int bitField0_;
|
||||
|
||||
private de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.custReserved;
|
||||
private de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.reserved;
|
||||
/**
|
||||
* <code>required .ErrorMessage.ErrorReason errorReason = 1;</code>
|
||||
*/
|
||||
@@ -49409,7 +49409,7 @@ public final class ProtoBuf {
|
||||
*/
|
||||
public Builder clearErrorReason() {
|
||||
bitField0_ = (bitField0_ & ~0x00000001);
|
||||
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.custReserved;
|
||||
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.reserved;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user