Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa3445d938 | ||
|
|
9b40ad445b | ||
|
|
8f3e4006e3 | ||
|
|
20252a02e0 | ||
|
|
add886ebee | ||
|
|
f9a2ebebb4 | ||
|
|
21b8088ecf | ||
|
|
09281f3179 | ||
|
|
f5688e01b0 | ||
|
|
f920d5f1c8 | ||
|
|
008d703de1 | ||
|
|
0a8b6d597f | ||
|
|
3813664b94 | ||
|
|
ad8c9cabfb | ||
|
|
678da490d4 | ||
|
|
8e5b09ac62 | ||
|
|
2ca2e941a6 | ||
|
|
b3c81c770f | ||
|
|
65e10c71b0 | ||
|
|
94d87ed33e | ||
|
|
8a9efbb77a | ||
|
|
981073ee78 | ||
|
|
17ec0024e9 | ||
|
|
0b4d0e334c | ||
|
|
ce2638317d | ||
|
|
1c5e8792aa | ||
|
|
8fb973344b | ||
|
|
f8474c02f7 | ||
|
|
f3f31519d4 | ||
|
|
6bf732f219 | ||
|
|
0ed986399f | ||
|
|
94ea0e6c2f | ||
|
|
19f95f6204 | ||
|
|
16c7200028 | ||
|
|
d0cc76ffc3 | ||
|
|
1b63c39f31 | ||
|
|
2358eaa5aa | ||
|
|
3b459ac57c | ||
|
|
3bd5286521 | ||
|
|
f64a6275d4 | ||
|
|
a6c7d62fb0 | ||
|
|
41ac0c7fe5 | ||
|
|
89a40325dc | ||
|
|
6b63097853 | ||
|
|
6ae765baac | ||
|
|
a4843369ee | ||
|
|
413d61e61c | ||
|
|
8f7014af12 | ||
|
|
5dab4c743c | ||
|
|
102955d6ce | ||
|
|
65eea1d6ec | ||
|
|
2b372d0019 | ||
|
|
612751044d | ||
|
|
ed84e7dfad | ||
|
|
002eea3ccb | ||
|
|
6bd0808427 | ||
|
|
4682b51e40 | ||
|
|
35f0521bbd | ||
|
|
159fd1e094 | ||
|
|
2a88775cca | ||
|
|
e73a95d08e | ||
|
|
1b5cf1bfb8 | ||
|
|
1abc9dc452 | ||
|
|
21003da510 | ||
|
|
70d6743c39 | ||
|
|
24acd01e90 | ||
|
|
8f5813416d | ||
|
|
417d9a5bd2 | ||
|
|
55174a71a7 | ||
|
|
724d30e61f | ||
|
|
b6763bcfe8 | ||
|
|
6092b3c306 | ||
|
|
c57a20482a | ||
|
|
98ce4bd637 | ||
|
|
1c3edbaaaa | ||
|
|
1f9c066cbb | ||
|
|
cd085bf8be | ||
|
|
cf280f0478 | ||
|
|
935ec2ad92 | ||
|
|
f6fb0650e3 | ||
|
|
b30ea65998 | ||
|
|
3ec764396a | ||
|
|
4faf428fb3 |
+25
@@ -0,0 +1,25 @@
|
||||
# exclude changes done by make process
|
||||
Makefile
|
||||
Makefile.chatcleaner
|
||||
Makefile.pokerth_db
|
||||
Makefile.pokerth_game
|
||||
Makefile.pokerth_lib
|
||||
Makefile.pokerth_protocol
|
||||
Makefile.pokerth_server
|
||||
Makefile.pokerth_dbofficial
|
||||
bin/
|
||||
chatcleaner
|
||||
lib/
|
||||
mocs/
|
||||
obj/
|
||||
pokerth
|
||||
qrc_pokerth.cpp
|
||||
uics/
|
||||
make.sh
|
||||
gitpush_serverstuff_stable
|
||||
pokerth_server
|
||||
.vscode
|
||||
.qmake.stash
|
||||
pokerth.ap*
|
||||
*.DS_STORE
|
||||
.gitignore.save
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<manifest package="org.qtproject.example" android:versionName="1.1" xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="1">
|
||||
<application android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="PokerTH" android:icon="@drawable/icon">
|
||||
<activity android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="PokerTH" android:screenOrientation="landscape" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation">
|
||||
<activity android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="PokerTH" android:screenOrientation="landscape" android:configChanges="orientation|uiMode|screenLayout|locale|fontScale|keyboard|keyboardHidden|navigation">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
@@ -31,7 +31,7 @@
|
||||
<!-- Splash screen -->
|
||||
</activity>
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19"/>
|
||||
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28"/>
|
||||
<supports-screens android:smallScreens="true" android:anyDensity="true" android:largeScreens="true" android:normalScreens="true"/>
|
||||
<!-- %%INSERT_PERMISSIONS -->
|
||||
<!-- %%INSERT_FEATURES -->
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
2017-09-01 version 1.1.2
|
||||
- PokerTH is now fully compatible with c++11 compilation mode
|
||||
- Upgraded to websockets 0.7
|
||||
- BUGFIX: SQL errors are saved to server log (partly #324)
|
||||
- BUGFIX: Players deliberately preventing start of play (#304)
|
||||
- BUGFIX: Rating feature didn't work for special usernames (#319)
|
||||
- BUGFIX: Ignore feature only works after restart (#320)
|
||||
- BUGFIX: Shorten too long usernames on the table gui (#326)
|
||||
- BUGFIX: "accidentally call" blocker now for working for FKey presses (#330)
|
||||
|
||||
2014-01-10 version 1.1.1
|
||||
- BUGFIX: Fixed crash when the first action in the first game times out (#258)
|
||||
- BUGFIX: Properly refresh the game table graphics after changing settings (#253)
|
||||
|
||||
@@ -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 -> http://code.google.com/p/protobuf/downloads/list
|
||||
- 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 varialbe 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
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"description": "This file is generated by qmake to be read by androiddeployqt and should not be modified by hand.",
|
||||
"qt": "/home/min/Dokumente/Qt5.13.0/5.13.0/android_armv7",
|
||||
"sdk": "/home/min/Dokumente/Android",
|
||||
"sdkBuildToolsRevision": "",
|
||||
"ndk": "/home/min/Dokumente/Android/android-ndk-r13b",
|
||||
"toolchain-prefix": "arm-linux-androideabi",
|
||||
"tool-prefix": "arm-linux-androideabi",
|
||||
"toolchain-version": "4.9",
|
||||
"ndk-host": "linux-x86_64",
|
||||
"target-architecture": "armeabi-v7a",
|
||||
"qml-root-path": "/home/min/Dokumente/pokerth",
|
||||
"stdcpp-path": "/home/min/Dokumente/Android/android-ndk-r13b/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_shared.so",
|
||||
"useLLVM": false,
|
||||
"application-binary": "/home/min/Dokumente/pokerth/libpokerth.so"
|
||||
}
|
||||
@@ -28,6 +28,7 @@
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
syntax = "proto2";
|
||||
|
||||
option java_package = "de.chatcleaner.protocol";
|
||||
option java_outer_classname = "ProtoBuf";
|
||||
|
||||
+2
-2
@@ -41,13 +41,13 @@ unix : !mac {
|
||||
|
||||
QMAKE_LIBDIR += lib $${PREFIX}/lib /opt/gsasl/lib
|
||||
INCLUDEPATH += $${PREFIX}/include
|
||||
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system(qmake -query QT_INSTALL_LIBS)
|
||||
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
|
||||
BOOST_SYS = boost_system boost_system-mt
|
||||
|
||||
|
||||
#
|
||||
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system(qmake -query QT_INSTALL_LIBS)
|
||||
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||
# to override the default '/usr' pass PREFIX
|
||||
# variable to qmake.
|
||||
#
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH dedicated server *
|
||||
* Copyright (C) 2014 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. *
|
||||
*****************************************************************************/
|
||||
package gameserver
|
||||
|
||||
import (
|
||||
"code.google.com/p/goprotobuf/proto"
|
||||
"container/list"
|
||||
"log"
|
||||
"pokerth"
|
||||
)
|
||||
|
||||
type Lobby struct {
|
||||
receiver chan SessionLobbyMessage
|
||||
sessions *list.List
|
||||
}
|
||||
|
||||
func NewLobby() *Lobby {
|
||||
return &Lobby{make(chan SessionLobbyMessage, RECV_LOBBY_NUM_PACKET_BUF), list.New()}
|
||||
}
|
||||
|
||||
func (l *Lobby) GetReceiver() chan SessionLobbyMessage {
|
||||
return l.receiver
|
||||
}
|
||||
|
||||
func (l *Lobby) AddSession(session *Session) {
|
||||
log.Print("New session")
|
||||
l.sessions.PushBack(session)
|
||||
announce := &pokerth.PokerTHMessage{
|
||||
MessageType: pokerth.PokerTHMessage_PokerTHMessageType.Enum(pokerth.PokerTHMessage_Type_AnnounceMessage),
|
||||
AnnounceMessage: &pokerth.AnnounceMessage{
|
||||
ProtocolVersion: &pokerth.AnnounceMessage_Version{
|
||||
MajorVersion: proto.Uint32(NET_VERSION_MAJOR),
|
||||
MinorVersion: proto.Uint32(NET_VERSION_MINOR),
|
||||
},
|
||||
LatestGameVersion: &pokerth.AnnounceMessage_Version{
|
||||
MajorVersion: proto.Uint32(POKERTH_VERSION_MAJOR),
|
||||
MinorVersion: proto.Uint32(POKERTH_VERSION_MINOR),
|
||||
},
|
||||
LatestBetaRevision: proto.Uint32(0),
|
||||
ServerType: pokerth.AnnounceMessage_ServerType.Enum(pokerth.AnnounceMessage_serverTypeInternetAuth),
|
||||
NumPlayersOnServer: proto.Uint32(0),
|
||||
},
|
||||
}
|
||||
session.sender <- announce
|
||||
}
|
||||
|
||||
func (l *Lobby) Run() {
|
||||
var lobbyMsg SessionLobbyMessage
|
||||
for {
|
||||
select {
|
||||
case lobbyMsg = <-l.receiver:
|
||||
log.Printf("Lobby packet %d", lobbyMsg.packet.GetMessageType())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH dedicated server *
|
||||
* Copyright (C) 2014 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. *
|
||||
*****************************************************************************/
|
||||
package gameserver
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"pokerth"
|
||||
)
|
||||
|
||||
const NET_HEADER_SIZE uint32 = 4
|
||||
|
||||
type PacketSerializer interface {
|
||||
ReadPacket(buf []byte, num uint32) (uint32, *pokerth.PokerTHMessage)
|
||||
WritePacket(buf []byte, packet *pokerth.PokerTHMessage) uint32
|
||||
}
|
||||
|
||||
func readPacketRaw(buf []byte, num uint32) (uint32, *pokerth.PokerTHMessage) {
|
||||
packet := &pokerth.PokerTHMessage{}
|
||||
err := packet.Unmarshal(buf[0:num])
|
||||
if err != nil {
|
||||
packet = nil
|
||||
}
|
||||
return num, packet
|
||||
}
|
||||
|
||||
func readPacketWithHeader(buf []byte, num uint32) (uint32, *pokerth.PokerTHMessage) {
|
||||
var bytesScanned uint32 = 0
|
||||
var packetSize uint32 = 0
|
||||
packet := &pokerth.PokerTHMessage{}
|
||||
if num >= NET_HEADER_SIZE {
|
||||
packetSize = binary.BigEndian.Uint32(buf[0:NET_HEADER_SIZE])
|
||||
if packetSize <= 0 {
|
||||
bytesScanned = NET_HEADER_SIZE
|
||||
} else if num >= NET_HEADER_SIZE+packetSize {
|
||||
bytesScanned, packet = readPacketRaw(buf[NET_HEADER_SIZE:], NET_HEADER_SIZE+packetSize)
|
||||
}
|
||||
}
|
||||
return bytesScanned, packet
|
||||
}
|
||||
|
||||
func writePacketGeneric(buf []byte, packet *pokerth.PokerTHMessage, headerSize uint32) uint32 {
|
||||
var bytesWritten uint32 = 0
|
||||
num, err := packet.MarshalTo(buf[headerSize:])
|
||||
if err == nil {
|
||||
if headerSize > 0 {
|
||||
binary.BigEndian.PutUint32(buf[0:headerSize], uint32(num))
|
||||
bytesWritten = uint32(num) + headerSize
|
||||
} else {
|
||||
bytesWritten = uint32(num)
|
||||
}
|
||||
}
|
||||
return bytesWritten
|
||||
}
|
||||
|
||||
type RawPacketSerializer struct {
|
||||
}
|
||||
|
||||
func (RawPacketSerializer) ReadPacket(buf []byte, num uint32) (uint32, *pokerth.PokerTHMessage) {
|
||||
return readPacketRaw(buf, num)
|
||||
}
|
||||
|
||||
func (RawPacketSerializer) WritePacket(buf []byte, packet *pokerth.PokerTHMessage) uint32 {
|
||||
return writePacketGeneric(buf, packet, 0)
|
||||
}
|
||||
|
||||
type HeaderPacketSerializer struct {
|
||||
}
|
||||
|
||||
func (HeaderPacketSerializer) ReadPacket(buf []byte, num uint32) (uint32, *pokerth.PokerTHMessage) {
|
||||
return readPacketWithHeader(buf, num)
|
||||
}
|
||||
|
||||
func (HeaderPacketSerializer) WritePacket(buf []byte, packet *pokerth.PokerTHMessage) uint32 {
|
||||
return writePacketGeneric(buf, packet, NET_HEADER_SIZE)
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH dedicated server *
|
||||
* Copyright (C) 2014 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. *
|
||||
*****************************************************************************/
|
||||
package gameserver
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net"
|
||||
"pokerth"
|
||||
)
|
||||
|
||||
const POKERTH_VERSION_MAJOR = 1
|
||||
const POKERTH_VERSION_MINOR = 11
|
||||
|
||||
const NET_VERSION_MAJOR = 5
|
||||
const NET_VERSION_MINOR = 1
|
||||
|
||||
const MAX_PACKET_SIZE uint32 = 384
|
||||
const RECV_BUF_SIZE uint32 = 4 * MAX_PACKET_SIZE
|
||||
const SEND_BUF_SIZE uint32 = 2 * MAX_PACKET_SIZE
|
||||
const SEND_NUM_PACKET_BUF = 2048
|
||||
const RECV_DISPATCHER_NUM_PACKET_BUF = 2048
|
||||
const RECV_LOBBY_NUM_PACKET_BUF = 2048
|
||||
|
||||
type Session struct {
|
||||
id uint32
|
||||
PacketSerializer
|
||||
Connection net.Conn
|
||||
sender chan *pokerth.PokerTHMessage
|
||||
receiver chan SessionPokerTHMessage
|
||||
}
|
||||
|
||||
type SessionPokerTHMessage struct {
|
||||
session *Session
|
||||
packet *pokerth.PokerTHMessage
|
||||
}
|
||||
|
||||
type SessionAuthMessage struct {
|
||||
session *Session
|
||||
packet *pokerth.AuthMessage
|
||||
}
|
||||
|
||||
type SessionLobbyMessage struct {
|
||||
session *Session
|
||||
packet *pokerth.LobbyMessage
|
||||
}
|
||||
|
||||
type SessionGameMessage struct {
|
||||
session *Session
|
||||
packet *pokerth.GameMessage
|
||||
}
|
||||
|
||||
func NewSession(id uint32, serializer PacketSerializer, conn net.Conn, receiver chan SessionPokerTHMessage) *Session {
|
||||
return &Session{id, serializer, conn, make(chan *pokerth.PokerTHMessage, SEND_NUM_PACKET_BUF), receiver}
|
||||
}
|
||||
|
||||
func (s *Session) Run() {
|
||||
// run sender as separate goroutine
|
||||
go s.handleSend()
|
||||
s.handleReceive()
|
||||
}
|
||||
|
||||
func (s *Session) handleReceive() {
|
||||
// close connection on exit
|
||||
defer s.Connection.Close()
|
||||
|
||||
var buf [RECV_BUF_SIZE]byte
|
||||
var bufPos uint32 = 0
|
||||
for {
|
||||
// read upto RECV_BUF_SIZE bytes
|
||||
num, err := s.Connection.Read(buf[bufPos:])
|
||||
bufPos += uint32(num)
|
||||
if err != nil {
|
||||
log.Printf("Read error: %s\n", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
bytesScanned, packet := s.ReadPacket(buf[0:bufPos], bufPos)
|
||||
|
||||
if bytesScanned > 0 {
|
||||
if packet == nil {
|
||||
log.Print("Invalid packet")
|
||||
} else {
|
||||
log.Printf("Packet in: %d\n", packet.GetMessageType())
|
||||
s.receiver <- SessionPokerTHMessage{s, packet}
|
||||
remainingBytes := bufPos - bytesScanned
|
||||
if remainingBytes > 0 {
|
||||
copy(buf[0:], buf[bytesScanned:remainingBytes])
|
||||
bufPos = remainingBytes
|
||||
} else {
|
||||
bufPos = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Session) handleSend() {
|
||||
var buf [RECV_BUF_SIZE]byte
|
||||
var packet *pokerth.PokerTHMessage
|
||||
for {
|
||||
select {
|
||||
case packet = <-s.sender:
|
||||
packetSize := s.WritePacket(buf[0:RECV_BUF_SIZE], packet)
|
||||
if packetSize > 0 {
|
||||
var bufStart uint32 = 0
|
||||
for bufStart < packetSize {
|
||||
num, err := s.Connection.Write(buf[bufStart:packetSize])
|
||||
if err != nil {
|
||||
log.Printf("Write error: %s\n", err.Error())
|
||||
return
|
||||
}
|
||||
bufStart += uint32(num)
|
||||
}
|
||||
log.Printf("Packet out: %d, size: %d\n", packet.GetMessageType(), packetSize)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -42,14 +42,14 @@ unix : !mac {
|
||||
|
||||
QMAKE_LIBDIR += lib $${PREFIX}/lib /opt/gsasl/lib
|
||||
INCLUDEPATH += $${PREFIX}/include
|
||||
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system(qmake -query QT_INSTALL_LIBS)
|
||||
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||
BOOST_THREAD = boost_thread boost_thread-mt
|
||||
BOOST_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 -query QT_INSTALL_LIBS)
|
||||
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||
# to override the default '/usr' pass PREFIX
|
||||
# variable to qmake.
|
||||
#
|
||||
|
||||
+63
-5
@@ -9,12 +9,13 @@
|
||||
# of binary-size if you leave Qt out.
|
||||
# (see http://trolltech.com/developer/downloads/qt/mac)
|
||||
|
||||
QT_FW_PATH="/Developer/Qt5/5/clang_64/lib"
|
||||
QT_PLUGIN_PATH="/Developer/Qt5/5/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
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright 2014 PokerTH GbR <webmaster@pokerth.net> -->
|
||||
<application>
|
||||
<id type="desktop">pokerth.desktop</id>
|
||||
<metadata_license>CC-BY-3.0</metadata_license>
|
||||
<project_license>AGPL-3.0</project_license>
|
||||
<name>PokerTH</name>
|
||||
<summary>Poker game with single- and multiplayer support</summary>
|
||||
<description>
|
||||
<p>PokerTH is a poker game for the popular Texas Hold'em Poker variant. You can play singleplayer games with up to 9 computer-opponents or meet other PokerTH players around the world via internet games. Also multiplayer games in your LAN are possible with the network game mode. If you like to change the look and feel of the PokerTH gametable or the card deck just visit the styles gallery and choose your favourite style. To compare your poker skills with the other PokerTH players you can check your game results and rankings on our website.</p>
|
||||
</description>
|
||||
<screenshots>
|
||||
<screenshot type="default" width="624" height="351">http://www.pokerth.net/pokerth_appdata_table1.png</screenshot>
|
||||
<screenshot width="624" height="351">http://www.pokerth.net/pokerth_appdata_table2.png</screenshot>
|
||||
</screenshots>
|
||||
<url type="homepage">http://www.pokerth.net</url>
|
||||
<updatecontact>webmaster@pokerth.net</updatecontact>
|
||||
</application>
|
||||
Executable → Regular
+10
-3
@@ -1,10 +1,17 @@
|
||||
# QMake pro-file for PokerTH
|
||||
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = pokerth_protocol.pro pokerth_db.pro pokerth_lib.pro pokerth_game.pro
|
||||
!mac:!gui_800x480:!client {
|
||||
SUBDIRS += pokerth_server.pro chatcleaner.pro
|
||||
SUBDIRS = pokerth_protocol.pro pokerth_db.pro pokerth_lib.pro
|
||||
official_server {
|
||||
SUBDIRS += pokerth_dbofficial.pro
|
||||
}
|
||||
client: {
|
||||
SUBDIRS += pokerth_game.pro
|
||||
}
|
||||
!mac:!gui_800x480:!client:!qml-client {
|
||||
SUBDIRS += pokerth_server.pro chatcleaner.pro
|
||||
}
|
||||
|
||||
CONFIG += ordered
|
||||
|
||||
OTHER_FILES += \
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.9.1, 2019-08-10T02:50:36. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{305266b5-7802-47a6-9864-ddd965ca89a2}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<value type="int">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||
<value type="QString" key="language">Cpp</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||
<value type="QString" key="language">QmlJS</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
||||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey"/>
|
||||
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 5.13.0 for Android ARMv7</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Qt 5.13.0 for Android ARMv7</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{548474b4-3c43-4596-9405-a81c8aa43ccd}</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/min/Dokumente/pokerth</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments">'CONFIG+=client gui_800x480' 'PREFIX+=/home/min/Dokumente/Android/cmoss/bin/droid'</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Erstellen</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Bereinigen</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deployment auf Android-Gerät</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.AndroidDeployQtStep</value>
|
||||
<value type="bool" key="UninstallPreviousPackage">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deployment</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deployment auf Android-Gerät</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.AndroidDeployConfiguration2</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
|
||||
<value type="QString">cpu-cycles</value>
|
||||
</valuelist>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
|
||||
<value type="int" key="Analyzer.Perf.Frequency">250</value>
|
||||
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
|
||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||
<value type="int" key="Analyzer.Perf.StackSize">4096</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
|
||||
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
|
||||
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
|
||||
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||
<value type="int">0</value>
|
||||
<value type="int">1</value>
|
||||
<value type="int">2</value>
|
||||
<value type="int">3</value>
|
||||
<value type="int">4</value>
|
||||
<value type="int">5</value>
|
||||
<value type="int">6</value>
|
||||
<value type="int">7</value>
|
||||
<value type="int">8</value>
|
||||
<value type="int">9</value>
|
||||
<value type="int">10</value>
|
||||
<value type="int">11</value>
|
||||
<value type="int">12</value>
|
||||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<value type="QString" key="Android.AmStartArgsKey"></value>
|
||||
<valuelist type="QVariantList" key="Android.PostStartShellCmdListKey"/>
|
||||
<valuelist type="QVariantList" key="Android.PreStartShellCmdListKey"/>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">0</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">pokerth_game</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">pokerth_game</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.AndroidRunConfiguration:/home/min/Dokumente/pokerth/pokerth_game.pro</value>
|
||||
<value type="QString" key="RunConfiguration.Arguments"></value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="int">1</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
<value type="int">21</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>Version</variable>
|
||||
<value type="int">21</value>
|
||||
</data>
|
||||
</qtcreator>
|
||||
+305
-347
@@ -1,6 +1,7 @@
|
||||
syntax = "proto2";
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2014 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* Copyright (C) 2006-2013 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 *
|
||||
@@ -145,22 +146,22 @@ message AnnounceMessage {
|
||||
required uint32 numPlayersOnServer = 5;
|
||||
}
|
||||
|
||||
message AuthClientRequestMessage {
|
||||
// buildId contains a constant build id (specific for Windows/Linux/Mac builds)
|
||||
message InitMessage {
|
||||
required AnnounceMessage.Version requestedVersion = 1;
|
||||
// buildId contains a constant build id (specific for Windows/Linux/Mac builds)
|
||||
required uint32 buildId = 2;
|
||||
optional bytes myLastSessionId = 3;
|
||||
optional string authServerPassword = 4;
|
||||
enum LoginType {
|
||||
guestLogin = 0;
|
||||
authenticatedLogin = 1;
|
||||
unauthenticatedLogin = 2;
|
||||
}
|
||||
required LoginType login = 3;
|
||||
optional string authServerPassword = 4;
|
||||
required LoginType login = 5;
|
||||
// Only used for guest login or unauthenticated login.
|
||||
optional string nickName = 5;
|
||||
optional string nickName = 6;
|
||||
// Authenticated login data is according to SCRAM SHA-1
|
||||
optional bytes clientUserData = 6;
|
||||
optional bytes myLastSessionId = 7;
|
||||
optional bytes clientUserData = 7;
|
||||
// Ignored for guest login.
|
||||
optional bytes avatarHash = 8;
|
||||
}
|
||||
@@ -177,7 +178,7 @@ message AuthServerVerificationMessage {
|
||||
required bytes serverVerification = 1;
|
||||
}
|
||||
|
||||
message InitDoneMessage {
|
||||
message InitAckMessage {
|
||||
required bytes yourSessionId = 1;
|
||||
required uint32 yourPlayerId = 2;
|
||||
optional bytes yourAvatarHash = 3;
|
||||
@@ -277,49 +278,32 @@ message PlayerInfoReplyMessage {
|
||||
optional PlayerInfoData playerInfoData = 2;
|
||||
}
|
||||
|
||||
// The following request is used optionally to reduce server traffic.
|
||||
// The following request will not be confirmed by the server. It is used,
|
||||
// optionally, to reduce server traffic. The server might ignore it.
|
||||
message SubscriptionRequestMessage {
|
||||
required uint32 requestId = 1;
|
||||
enum SubscriptionAction {
|
||||
unsubscribeGameList = 1;
|
||||
resubscribeGameList = 2;
|
||||
}
|
||||
required SubscriptionAction subscriptionAction = 2;
|
||||
required SubscriptionAction subscriptionAction = 1;
|
||||
}
|
||||
|
||||
message SubscriptionReplyMessage {
|
||||
required uint32 requestId = 1;
|
||||
required bool ack = 2;
|
||||
}
|
||||
|
||||
message CreateGameMessage {
|
||||
required uint32 requestId = 1;
|
||||
required NetGameInfo gameInfo = 2;
|
||||
optional string password = 3;
|
||||
optional bool autoLeave = 4;
|
||||
}
|
||||
|
||||
message CreateGameFailedMessage {
|
||||
required uint32 requestId = 1;
|
||||
enum CreateGameFailureReason {
|
||||
notAllowedAsGuest = 1;
|
||||
gameNameInUse = 2;
|
||||
badGameName = 3;
|
||||
invalidSettings = 4;
|
||||
}
|
||||
required CreateGameFailureReason createGameFailureReason = 2;
|
||||
}
|
||||
|
||||
message JoinGameMessage {
|
||||
message JoinExistingGameMessage {
|
||||
required uint32 gameId = 1;
|
||||
optional string password = 2;
|
||||
optional bool autoLeave = 3 [default = false];
|
||||
optional bool spectateOnly = 4 [default = false];
|
||||
}
|
||||
|
||||
message RejoinGameMessage {
|
||||
message JoinNewGameMessage {
|
||||
required NetGameInfo gameInfo = 1;
|
||||
optional string password = 2;
|
||||
optional bool autoLeave = 3;
|
||||
}
|
||||
|
||||
message RejoinExistingGameMessage {
|
||||
required uint32 gameId = 1;
|
||||
optional bool autoLeave = 2 [default = false];
|
||||
optional bool autoLeave = 2;
|
||||
}
|
||||
|
||||
message JoinGameAckMessage {
|
||||
@@ -330,50 +314,59 @@ message JoinGameAckMessage {
|
||||
}
|
||||
|
||||
message JoinGameFailedMessage {
|
||||
required uint32 gameId = 1;
|
||||
enum JoinGameFailureReason {
|
||||
invalidGame = 1;
|
||||
gameIsFull = 2;
|
||||
gameIsRunning = 3;
|
||||
notAllowedAsGuest = 4;
|
||||
invalidPassword = 5;
|
||||
invalidPassword = 4;
|
||||
notAllowedAsGuest = 5;
|
||||
notInvited = 6;
|
||||
ipAddressBlocked = 7;
|
||||
rejoinFailed = 8;
|
||||
noSpectatorsAllowed = 9;
|
||||
gameNameInUse = 7;
|
||||
badGameName = 8;
|
||||
invalidSettings = 9;
|
||||
ipAddressBlocked = 10;
|
||||
rejoinFailed = 11;
|
||||
noSpectatorsAllowed = 12;
|
||||
}
|
||||
required uint32 gameId = 1;
|
||||
required JoinGameFailureReason joinGameFailureReason = 2;
|
||||
}
|
||||
|
||||
message GamePlayerJoinedMessage {
|
||||
required uint32 playerId = 1;
|
||||
required bool isGameAdmin = 2;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 playerId = 2;
|
||||
required bool isGameAdmin = 3;
|
||||
}
|
||||
|
||||
message GamePlayerLeftMessage {
|
||||
required uint32 playerId = 1;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 playerId = 2;
|
||||
enum GamePlayerLeftReason {
|
||||
leftOnRequest = 0;
|
||||
leftKicked = 1;
|
||||
leftError = 2;
|
||||
}
|
||||
required GamePlayerLeftReason gamePlayerLeftReason = 2;
|
||||
required GamePlayerLeftReason gamePlayerLeftReason = 3;
|
||||
}
|
||||
|
||||
message GameSpectatorJoinedMessage {
|
||||
required uint32 playerId = 1;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 playerId = 2;
|
||||
}
|
||||
|
||||
message GameSpectatorLeftMessage {
|
||||
required uint32 playerId = 1;
|
||||
required GamePlayerLeftMessage.GamePlayerLeftReason gameSpectatorLeftReason = 2;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 playerId = 2;
|
||||
required GamePlayerLeftMessage.GamePlayerLeftReason gameSpectatorLeftReason = 3;
|
||||
}
|
||||
|
||||
message GameAdminChangedMessage {
|
||||
required uint32 newAdminPlayerId = 1;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 newAdminPlayerId = 2;
|
||||
}
|
||||
|
||||
message RemovedFromGameMessage {
|
||||
required uint32 gameId = 1;
|
||||
enum RemovedFromGameReason {
|
||||
removedOnRequest = 0; // No error, client wished to leave.
|
||||
kickedFromGame = 1;
|
||||
@@ -383,14 +376,16 @@ message RemovedFromGameMessage {
|
||||
removedStartFailed = 5;
|
||||
gameClosed = 6;
|
||||
}
|
||||
required RemovedFromGameReason removedFromGameReason = 1;
|
||||
required RemovedFromGameReason removedFromGameReason = 2;
|
||||
}
|
||||
|
||||
message KickPlayerRequestMessage {
|
||||
required uint32 playerId = 1;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 playerId = 2;
|
||||
}
|
||||
|
||||
message LeaveGameRequestMessage {
|
||||
required uint32 gameId = 1;
|
||||
}
|
||||
|
||||
message InvitePlayerToGameMessage {
|
||||
@@ -420,109 +415,124 @@ message RejectInvNotifyMessage {
|
||||
}
|
||||
|
||||
message StartEventMessage {
|
||||
required uint32 gameId = 1;
|
||||
enum StartEventType {
|
||||
startEvent = 0;
|
||||
rejoinEvent = 1;
|
||||
}
|
||||
required StartEventType startEventType = 1;
|
||||
optional bool fillWithComputerPlayers = 2;
|
||||
required StartEventType startEventType = 2;
|
||||
optional bool fillWithComputerPlayers = 3;
|
||||
}
|
||||
|
||||
message StartEventAckMessage {
|
||||
required uint32 gameId = 1;
|
||||
}
|
||||
|
||||
message GameStartInitialMessage {
|
||||
required uint32 startDealerPlayerId = 1;
|
||||
repeated uint32 playerSeats = 2 [packed = true];
|
||||
required uint32 gameId = 1;
|
||||
required uint32 startDealerPlayerId = 2;
|
||||
repeated uint32 playerSeats = 3 [packed = true];
|
||||
}
|
||||
|
||||
message GameStartRejoinMessage {
|
||||
required uint32 startDealerPlayerId = 1;
|
||||
required uint32 handNum = 2;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 startDealerPlayerId = 2;
|
||||
required uint32 handNum = 3;
|
||||
message RejoinPlayerData {
|
||||
required uint32 playerId = 1;
|
||||
required uint32 playerMoney = 2;
|
||||
}
|
||||
repeated RejoinPlayerData rejoinPlayerData = 3;
|
||||
repeated RejoinPlayerData rejoinPlayerData = 4;
|
||||
}
|
||||
|
||||
message HandStartMessage {
|
||||
required uint32 gameId = 1;
|
||||
message PlainCards {
|
||||
required uint32 plainCard1 = 1;
|
||||
required uint32 plainCard2 = 2;
|
||||
}
|
||||
optional PlainCards plainCards = 1;
|
||||
optional bytes encryptedCards = 2;
|
||||
required uint32 smallBlind = 3;
|
||||
repeated NetPlayerState seatStates = 4;
|
||||
optional uint32 dealerPlayerId = 5;
|
||||
optional PlainCards plainCards = 2;
|
||||
optional bytes encryptedCards = 3;
|
||||
required uint32 smallBlind = 4;
|
||||
repeated NetPlayerState seatStates = 5;
|
||||
optional uint32 dealerPlayerId = 6;
|
||||
}
|
||||
|
||||
message PlayersTurnMessage {
|
||||
required uint32 playerId = 1;
|
||||
required NetGameState gameState = 2;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 playerId = 2;
|
||||
required NetGameState gameState = 3;
|
||||
}
|
||||
|
||||
message MyActionRequestMessage {
|
||||
required uint32 handNum = 1;
|
||||
required NetGameState gameState = 2;
|
||||
required NetPlayerAction myAction = 3;
|
||||
required uint32 myRelativeBet = 4;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 handNum = 2;
|
||||
required NetGameState gameState = 3;
|
||||
required NetPlayerAction myAction = 4;
|
||||
required uint32 myRelativeBet = 5;
|
||||
}
|
||||
|
||||
message YourActionRejectedMessage {
|
||||
required NetGameState gameState = 1;
|
||||
required NetPlayerAction yourAction = 2;
|
||||
required uint32 yourRelativeBet = 3;
|
||||
required uint32 gameId = 1;
|
||||
required NetGameState gameState = 2;
|
||||
required NetPlayerAction yourAction = 3;
|
||||
required uint32 yourRelativeBet = 4;
|
||||
enum RejectionReason {
|
||||
rejectedInvalidGameState = 1;
|
||||
rejectedNotYourTurn = 2;
|
||||
rejectedActionNotAllowed = 3;
|
||||
}
|
||||
required RejectionReason rejectionReason = 4;
|
||||
required RejectionReason rejectionReason = 5;
|
||||
}
|
||||
|
||||
message PlayersActionDoneMessage {
|
||||
required uint32 playerId = 1;
|
||||
required NetGameState gameState = 2;
|
||||
required NetPlayerAction playerAction = 3;
|
||||
required uint32 totalPlayerBet = 4;
|
||||
required uint32 playerMoney = 5;
|
||||
required uint32 highestSet = 6;
|
||||
required uint32 minimumRaise = 7;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 playerId = 2;
|
||||
required NetGameState gameState = 3;
|
||||
required NetPlayerAction playerAction = 4;
|
||||
required uint32 totalPlayerBet = 5;
|
||||
required uint32 playerMoney = 6;
|
||||
required uint32 highestSet = 7;
|
||||
required uint32 minimumRaise = 8;
|
||||
}
|
||||
|
||||
message DealFlopCardsMessage {
|
||||
required uint32 flopCard1 = 1;
|
||||
required uint32 flopCard2 = 2;
|
||||
required uint32 flopCard3 = 3;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 flopCard1 = 2;
|
||||
required uint32 flopCard2 = 3;
|
||||
required uint32 flopCard3 = 4;
|
||||
}
|
||||
|
||||
message DealTurnCardMessage {
|
||||
required uint32 turnCard = 1;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 turnCard = 2;
|
||||
}
|
||||
|
||||
message DealRiverCardMessage {
|
||||
required uint32 riverCard = 1;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 riverCard = 2;
|
||||
}
|
||||
|
||||
message AllInShowCardsMessage {
|
||||
required uint32 gameId = 1;
|
||||
message PlayerAllIn {
|
||||
required uint32 playerId = 1;
|
||||
required uint32 allInCard1 = 2;
|
||||
required uint32 allInCard2 = 3;
|
||||
}
|
||||
repeated PlayerAllIn playersAllIn = 1;
|
||||
repeated PlayerAllIn playersAllIn = 2;
|
||||
}
|
||||
|
||||
message EndOfHandShowCardsMessage {
|
||||
repeated PlayerResult playerResults = 1;
|
||||
required uint32 gameId = 1;
|
||||
repeated PlayerResult playerResults = 2;
|
||||
}
|
||||
|
||||
message EndOfHandHideCardsMessage {
|
||||
required uint32 playerId = 1;
|
||||
required uint32 moneyWon = 2;
|
||||
required uint32 playerMoney = 3;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 playerId = 2;
|
||||
required uint32 moneyWon = 3;
|
||||
required uint32 playerMoney = 4;
|
||||
}
|
||||
|
||||
message ShowMyCardsRequestMessage {
|
||||
@@ -533,7 +543,8 @@ message AfterHandShowCardsMessage {
|
||||
}
|
||||
|
||||
message EndOfGameMessage {
|
||||
required uint32 winnerPlayerId = 1;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 winnerPlayerId = 2;
|
||||
}
|
||||
|
||||
message PlayerIdChangedMessage {
|
||||
@@ -542,11 +553,13 @@ message PlayerIdChangedMessage {
|
||||
}
|
||||
|
||||
message AskKickPlayerMessage {
|
||||
required uint32 playerId = 1;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 playerId = 2;
|
||||
}
|
||||
|
||||
message AskKickDeniedMessage {
|
||||
required uint32 playerId = 1;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 playerId = 2;
|
||||
enum KickDeniedReason {
|
||||
kickDeniedInvalidGameState = 0;
|
||||
kickDeniedNotPossible = 1;
|
||||
@@ -554,51 +567,56 @@ message AskKickDeniedMessage {
|
||||
kickDeniedAlreadyInProgress = 3;
|
||||
kickDeniedInvalidPlayerId = 4;
|
||||
}
|
||||
required KickDeniedReason kickDeniedReason = 2;
|
||||
required KickDeniedReason kickDeniedReason = 3;
|
||||
}
|
||||
|
||||
message StartKickPetitionMessage {
|
||||
required uint32 petitionId = 1;
|
||||
required uint32 proposingPlayerId = 2;
|
||||
required uint32 kickPlayerId = 3;
|
||||
required uint32 kickTimeoutSec = 4;
|
||||
required uint32 numVotesNeededToKick = 5;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 petitionId = 2;
|
||||
required uint32 proposingPlayerId = 3;
|
||||
required uint32 kickPlayerId = 4;
|
||||
required uint32 kickTimeoutSec = 5;
|
||||
required uint32 numVotesNeededToKick = 6;
|
||||
}
|
||||
|
||||
message VoteKickRequestMessage {
|
||||
required uint32 petitionId = 1;
|
||||
required bool voteKick = 2;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 petitionId = 2;
|
||||
required bool voteKick = 3;
|
||||
}
|
||||
|
||||
message VoteKickReplyMessage {
|
||||
required uint32 petitionId = 1;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 petitionId = 2;
|
||||
enum VoteKickReplyType {
|
||||
voteKickAck = 0;
|
||||
voteKickDeniedInvalid = 1;
|
||||
voteKickDeniedAlreadyVoted = 2;
|
||||
}
|
||||
required VoteKickReplyType voteKickReplyType = 2;
|
||||
required VoteKickReplyType voteKickReplyType = 3;
|
||||
}
|
||||
|
||||
message KickPetitionUpdateMessage {
|
||||
required uint32 petitionId = 1;
|
||||
required uint32 numVotesAgainstKicking = 2;
|
||||
required uint32 numVotesInFavourOfKicking = 3;
|
||||
required uint32 numVotesNeededToKick = 4;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 petitionId = 2;
|
||||
required uint32 numVotesAgainstKicking = 3;
|
||||
required uint32 numVotesInFavourOfKicking = 4;
|
||||
required uint32 numVotesNeededToKick = 5;
|
||||
}
|
||||
|
||||
message EndKickPetitionMessage {
|
||||
required uint32 petitionId = 1;
|
||||
required uint32 numVotesAgainstKicking = 2;
|
||||
required uint32 numVotesInFavourOfKicking = 3;
|
||||
required uint32 resultPlayerKicked = 4;
|
||||
required uint32 gameId = 1;
|
||||
required uint32 petitionId = 2;
|
||||
required uint32 numVotesAgainstKicking = 3;
|
||||
required uint32 numVotesInFavourOfKicking = 4;
|
||||
required uint32 resultPlayerKicked = 5;
|
||||
enum PetitionEndReason {
|
||||
petitionEndEnoughVotes = 0;
|
||||
petitionEndTooFewPlayers = 1;
|
||||
petitionEndPlayerLeft = 2;
|
||||
petitionEndTimeout = 3;
|
||||
}
|
||||
required PetitionEndReason petitionEndReason = 5;
|
||||
required PetitionEndReason petitionEndReason = 6;
|
||||
}
|
||||
|
||||
message StatisticsMessage {
|
||||
@@ -613,20 +631,23 @@ message StatisticsMessage {
|
||||
}
|
||||
|
||||
message ChatRequestMessage {
|
||||
optional uint32 targetGameId = 1;
|
||||
optional uint32 targetPlayerId = 2;
|
||||
required string chatText = 3;
|
||||
}
|
||||
|
||||
message ChatMessage {
|
||||
optional uint32 playerId = 1;
|
||||
optional uint32 gameId = 1;
|
||||
optional uint32 playerId = 2;
|
||||
enum ChatType {
|
||||
chatTypeStandard = 0;
|
||||
chatTypeBot = 1;
|
||||
chatTypeBroadcast = 2;
|
||||
chatTypePrivate = 3;
|
||||
chatTypeLobby = 0;
|
||||
chatTypeGame = 1;
|
||||
chatTypeBot = 2;
|
||||
chatTypeBroadcast = 3;
|
||||
chatTypePrivate = 4;
|
||||
}
|
||||
required ChatType chatType = 2;
|
||||
required string chatText = 3;
|
||||
required ChatType chatType = 3;
|
||||
required string chatText = 4;
|
||||
}
|
||||
|
||||
message ChatRejectMessage {
|
||||
@@ -681,7 +702,7 @@ message ReportGameAckMessage {
|
||||
|
||||
message ErrorMessage {
|
||||
enum ErrorReason {
|
||||
reserved = 0;
|
||||
custReserved = 0;
|
||||
initVersionNotSupported = 1;
|
||||
initServerFull = 2;
|
||||
initAuthFailure = 3;
|
||||
@@ -729,236 +750,173 @@ message AdminBanPlayerAckMessage {
|
||||
required AdminBanPlayerResult banPlayerResult = 2;
|
||||
}
|
||||
|
||||
message AuthMessage {
|
||||
enum AuthMessageType {
|
||||
Type_AuthClientRequestMessage = 1;
|
||||
Type_AuthServerChallengeMessage = 2;
|
||||
Type_AuthClientResponseMessage = 3;
|
||||
Type_AuthServerVerificationMessage = 4;
|
||||
Type_ErrorMessage = 1024;
|
||||
}
|
||||
required AuthMessageType messageType = 1;
|
||||
// The main message type (it is prefixed by 4 bytes length of the message).
|
||||
|
||||
optional AuthClientRequestMessage authClientRequestMessage = 2;
|
||||
optional AuthServerChallengeMessage authServerChallengeMessage = 3;
|
||||
optional AuthClientResponseMessage authClientResponseMessage = 4;
|
||||
optional AuthServerVerificationMessage authServerVerificationMessage = 5;
|
||||
optional ErrorMessage errorMessage = 1025;
|
||||
}
|
||||
|
||||
message LobbyMessage {
|
||||
enum LobbyMessageType {
|
||||
Type_InitDoneMessage = 1;
|
||||
Type_AvatarRequestMessage = 2;
|
||||
Type_AvatarHeaderMessage = 3;
|
||||
Type_AvatarDataMessage = 4;
|
||||
Type_AvatarEndMessage = 5;
|
||||
Type_UnknownAvatarMessage = 6;
|
||||
Type_PlayerListMessage = 7;
|
||||
Type_GameListNewMessage = 8;
|
||||
Type_GameListUpdateMessage = 9;
|
||||
Type_GameListPlayerJoinedMessage = 10;
|
||||
Type_GameListPlayerLeftMessage = 11;
|
||||
Type_GameListSpectatorJoinedMessage = 12;
|
||||
Type_GameListSpectatorLeftMessage = 13;
|
||||
Type_GameListAdminChangedMessage = 14;
|
||||
Type_PlayerInfoRequestMessage = 15;
|
||||
Type_PlayerInfoReplyMessage = 16;
|
||||
Type_SubscriptionRequestMessage = 17;
|
||||
Type_SubscriptionReplyMessage = 18;
|
||||
Type_CreateGameMessage = 19;
|
||||
Type_CreateGameFailedMessage = 20;
|
||||
Type_JoinGameMessage = 21;
|
||||
Type_RejoinGameMessage = 22;
|
||||
Type_JoinGameAckMessage = 23;
|
||||
Type_JoinGameFailedMessage = 24;
|
||||
Type_InviteNotifyMessage = 25;
|
||||
Type_RejectGameInvitationMessage = 26;
|
||||
Type_RejectInvNotifyMessage = 27;
|
||||
Type_StatisticsMessage = 28;
|
||||
Type_ChatRequestMessage = 29;
|
||||
Type_ChatMessage = 30;
|
||||
Type_ChatRejectMessage = 31;
|
||||
Type_DialogMessage = 32;
|
||||
Type_TimeoutWarningMessage = 33;
|
||||
Type_ResetTimeoutMessage = 34;
|
||||
Type_ReportAvatarMessage = 35;
|
||||
Type_ReportAvatarAckMessage = 36;
|
||||
Type_ReportGameMessage = 37;
|
||||
Type_ReportGameAckMessage = 38;
|
||||
Type_AdminRemoveGameMessage = 39;
|
||||
Type_AdminRemoveGameAckMessage = 40;
|
||||
Type_AdminBanPlayerMessage = 41;
|
||||
Type_AdminBanPlayerAckMessage = 42;
|
||||
Type_ErrorMessage = 1024;
|
||||
}
|
||||
required LobbyMessageType messageType = 1;
|
||||
|
||||
optional InitDoneMessage initDoneMessage = 2;
|
||||
optional AvatarRequestMessage avatarRequestMessage = 3;
|
||||
optional AvatarHeaderMessage avatarHeaderMessage = 4;
|
||||
optional AvatarDataMessage avatarDataMessage = 5;
|
||||
optional AvatarEndMessage avatarEndMessage = 6;
|
||||
optional UnknownAvatarMessage unknownAvatarMessage = 7;
|
||||
optional PlayerListMessage playerListMessage = 8;
|
||||
optional GameListNewMessage gameListNewMessage = 9;
|
||||
optional GameListUpdateMessage gameListUpdateMessage = 10;
|
||||
optional GameListPlayerJoinedMessage gameListPlayerJoinedMessage = 11;
|
||||
optional GameListPlayerLeftMessage gameListPlayerLeftMessage = 12;
|
||||
optional GameListSpectatorJoinedMessage gameListSpectatorJoinedMessage = 13;
|
||||
optional GameListSpectatorLeftMessage gameListSpectatorLeftMessage = 14;
|
||||
optional GameListAdminChangedMessage gameListAdminChangedMessage = 15;
|
||||
optional PlayerInfoRequestMessage playerInfoRequestMessage = 16;
|
||||
optional PlayerInfoReplyMessage playerInfoReplyMessage = 17;
|
||||
optional SubscriptionRequestMessage subscriptionRequestMessage = 18;
|
||||
optional SubscriptionReplyMessage subscriptionReplyMessage = 19;
|
||||
optional CreateGameMessage createGameMessage = 20;
|
||||
optional CreateGameFailedMessage createGameFailedMessage = 21;
|
||||
optional JoinGameMessage joinGameMessage = 22;
|
||||
optional RejoinGameMessage rejoinGameMessage = 23;
|
||||
optional JoinGameAckMessage joinGameAckMessage = 24;
|
||||
optional JoinGameFailedMessage joinGameFailedMessage = 25;
|
||||
optional InviteNotifyMessage inviteNotifyMessage = 26;
|
||||
optional RejectGameInvitationMessage rejectGameInvitationMessage = 27;
|
||||
optional RejectInvNotifyMessage rejectInvNotifyMessage = 28;
|
||||
optional StatisticsMessage statisticsMessage = 29;
|
||||
optional ChatRequestMessage chatRequestMessage = 30;
|
||||
optional ChatMessage chatMessage = 31;
|
||||
optional ChatRejectMessage chatRejectMessage = 32;
|
||||
optional DialogMessage dialogMessage = 33;
|
||||
optional TimeoutWarningMessage timeoutWarningMessage = 34;
|
||||
optional ResetTimeoutMessage resetTimeoutMessage = 35;
|
||||
optional ReportAvatarMessage reportAvatarMessage = 36;
|
||||
optional ReportAvatarAckMessage reportAvatarAckMessage = 37;
|
||||
optional ReportGameMessage reportGameMessage = 38;
|
||||
optional ReportGameAckMessage reportGameAckMessage = 39;
|
||||
optional AdminRemoveGameMessage adminRemoveGameMessage = 40;
|
||||
optional AdminRemoveGameAckMessage adminRemoveGameAckMessage = 41;
|
||||
optional AdminBanPlayerMessage adminBanPlayerMessage = 42;
|
||||
optional AdminBanPlayerAckMessage adminBanPlayerAckMessage = 43;
|
||||
optional ErrorMessage errorMessage = 1025;
|
||||
}
|
||||
|
||||
message GameManagementMessage {
|
||||
enum GameManagementMessageType {
|
||||
Type_GamePlayerJoinedMessage = 1;
|
||||
Type_GamePlayerLeftMessage = 2;
|
||||
Type_GameSpectatorJoinedMessage = 3;
|
||||
Type_GameSpectatorLeftMessage = 4;
|
||||
Type_GameAdminChangedMessage = 5;
|
||||
Type_RemovedFromGameMessage = 6;
|
||||
Type_KickPlayerRequestMessage = 7;
|
||||
Type_LeaveGameRequestMessage = 8;
|
||||
Type_InvitePlayerToGameMessage = 9;
|
||||
Type_StartEventMessage = 10;
|
||||
Type_StartEventAckMessage = 11;
|
||||
Type_GameStartInitialMessage = 12;
|
||||
Type_GameStartRejoinMessage = 13;
|
||||
Type_EndOfGameMessage = 14;
|
||||
Type_PlayerIdChangedMessage = 15;
|
||||
Type_AskKickPlayerMessage = 16;
|
||||
Type_AskKickDeniedMessage = 17;
|
||||
Type_StartKickPetitionMessage = 18;
|
||||
Type_VoteKickRequestMessage = 19;
|
||||
Type_VoteKickReplyMessage = 20;
|
||||
Type_KickPetitionUpdateMessage = 21;
|
||||
Type_EndKickPetitionMessage = 22;
|
||||
Type_ChatRequestMessage = 23;
|
||||
Type_ChatMessage = 24;
|
||||
Type_ChatRejectMessage = 25;
|
||||
Type_TimeoutWarningMessage = 26;
|
||||
Type_ResetTimeoutMessage = 27;
|
||||
Type_ErrorMessage = 1024;
|
||||
}
|
||||
required GameManagementMessageType messageType = 1;
|
||||
|
||||
optional GamePlayerJoinedMessage gamePlayerJoinedMessage = 2;
|
||||
optional GamePlayerLeftMessage gamePlayerLeftMessage = 3;
|
||||
optional GameSpectatorJoinedMessage gameSpectatorJoinedMessage = 4;
|
||||
optional GameSpectatorLeftMessage gameSpectatorLeftMessage = 5;
|
||||
optional GameAdminChangedMessage gameAdminChangedMessage = 6;
|
||||
optional RemovedFromGameMessage removedFromGameMessage = 7;
|
||||
optional KickPlayerRequestMessage kickPlayerRequestMessage = 8;
|
||||
optional LeaveGameRequestMessage leaveGameRequestMessage = 9;
|
||||
optional InvitePlayerToGameMessage invitePlayerToGameMessage = 10;
|
||||
optional StartEventMessage startEventMessage = 11;
|
||||
optional StartEventAckMessage startEventAckMessage = 12;
|
||||
optional GameStartInitialMessage gameStartInitialMessage = 13;
|
||||
optional GameStartRejoinMessage gameStartRejoinMessage = 14;
|
||||
optional EndOfGameMessage endOfGameMessage = 15;
|
||||
optional PlayerIdChangedMessage playerIdChangedMessage = 16;
|
||||
optional AskKickPlayerMessage askKickPlayerMessage = 17;
|
||||
optional AskKickDeniedMessage askKickDeniedMessage = 18;
|
||||
optional StartKickPetitionMessage startKickPetitionMessage = 19;
|
||||
optional VoteKickRequestMessage voteKickRequestMessage = 20;
|
||||
optional VoteKickReplyMessage voteKickReplyMessage = 21;
|
||||
optional KickPetitionUpdateMessage kickPetitionUpdateMessage = 22;
|
||||
optional EndKickPetitionMessage endKickPetitionMessage = 23;
|
||||
optional ChatRequestMessage chatRequestMessage = 24;
|
||||
optional ChatMessage chatMessage = 25;
|
||||
optional ChatRejectMessage chatRejectMessage = 26;
|
||||
optional TimeoutWarningMessage timeoutWarningMessage = 27;
|
||||
optional ResetTimeoutMessage resetTimeoutMessage = 28;
|
||||
optional ErrorMessage errorMessage = 1025;
|
||||
}
|
||||
|
||||
message GameEngineMessage {
|
||||
enum GameEngineMessageType {
|
||||
Type_HandStartMessage = 1;
|
||||
Type_PlayersTurnMessage = 2;
|
||||
Type_MyActionRequestMessage = 3;
|
||||
Type_YourActionRejectedMessage = 4;
|
||||
Type_PlayersActionDoneMessage = 5;
|
||||
Type_DealFlopCardsMessage = 6;
|
||||
Type_DealTurnCardMessage = 7;
|
||||
Type_DealRiverCardMessage = 8;
|
||||
Type_AllInShowCardsMessage = 9;
|
||||
Type_EndOfHandShowCardsMessage = 10;
|
||||
Type_EndOfHandHideCardsMessage = 11;
|
||||
Type_ShowMyCardsRequestMessage = 12;
|
||||
Type_AfterHandShowCardsMessage = 13;
|
||||
}
|
||||
required GameEngineMessageType messageType = 1;
|
||||
|
||||
optional HandStartMessage handStartMessage = 2;
|
||||
optional PlayersTurnMessage playersTurnMessage = 3;
|
||||
optional MyActionRequestMessage myActionRequestMessage = 4;
|
||||
optional YourActionRejectedMessage yourActionRejectedMessage = 5;
|
||||
optional PlayersActionDoneMessage playersActionDoneMessage = 6;
|
||||
optional DealFlopCardsMessage dealFlopCardsMessage = 7;
|
||||
optional DealTurnCardMessage dealTurnCardMessage = 8;
|
||||
optional DealRiverCardMessage dealRiverCardMessage = 9;
|
||||
optional AllInShowCardsMessage allInShowCardsMessage = 10;
|
||||
optional EndOfHandShowCardsMessage endOfHandShowCardsMessage = 11;
|
||||
optional EndOfHandHideCardsMessage endOfHandHideCardsMessage = 12;
|
||||
optional ShowMyCardsRequestMessage showMyCardsRequestMessage = 13;
|
||||
optional AfterHandShowCardsMessage afterHandShowCardsMessage = 14;
|
||||
}
|
||||
|
||||
message GameMessage {
|
||||
enum GameMessageType {
|
||||
Type_GameManagementMessage = 1;
|
||||
Type_GameEngineMessage = 2;
|
||||
}
|
||||
required GameMessageType messageType = 1;
|
||||
required uint32 gameId = 2;
|
||||
|
||||
optional GameManagementMessage gameManagementMessage = 3;
|
||||
optional GameEngineMessage gameEngineMessage = 4;
|
||||
}
|
||||
|
||||
// The main message type (with TCP, it is prefixed by 4 bytes length of the message).
|
||||
message PokerTHMessage {
|
||||
enum PokerTHMessageType {
|
||||
Type_AnnounceMessage = 1;
|
||||
Type_AuthMessage = 2;
|
||||
Type_LobbyMessage = 3;
|
||||
Type_GameMessage = 4;
|
||||
Type_InitMessage = 2;
|
||||
Type_AuthServerChallengeMessage = 3;
|
||||
Type_AuthClientResponseMessage = 4;
|
||||
Type_AuthServerVerificationMessage = 5;
|
||||
Type_InitAckMessage = 6;
|
||||
Type_AvatarRequestMessage = 7;
|
||||
Type_AvatarHeaderMessage = 8;
|
||||
Type_AvatarDataMessage = 9;
|
||||
Type_AvatarEndMessage = 10;
|
||||
Type_UnknownAvatarMessage = 11;
|
||||
Type_PlayerListMessage = 12;
|
||||
Type_GameListNewMessage = 13;
|
||||
Type_GameListUpdateMessage = 14;
|
||||
Type_GameListPlayerJoinedMessage = 15;
|
||||
Type_GameListPlayerLeftMessage = 16;
|
||||
Type_GameListAdminChangedMessage = 17;
|
||||
Type_PlayerInfoRequestMessage = 18;
|
||||
Type_PlayerInfoReplyMessage = 19;
|
||||
Type_SubscriptionRequestMessage = 20;
|
||||
Type_JoinExistingGameMessage = 21;
|
||||
Type_JoinNewGameMessage = 22;
|
||||
Type_RejoinExistingGameMessage = 23;
|
||||
Type_JoinGameAckMessage = 24;
|
||||
Type_JoinGameFailedMessage = 25;
|
||||
Type_GamePlayerJoinedMessage = 26;
|
||||
Type_GamePlayerLeftMessage = 27;
|
||||
Type_GameAdminChangedMessage = 28;
|
||||
Type_RemovedFromGameMessage = 29;
|
||||
Type_KickPlayerRequestMessage = 30;
|
||||
Type_LeaveGameRequestMessage = 31;
|
||||
Type_InvitePlayerToGameMessage = 32;
|
||||
Type_InviteNotifyMessage = 33;
|
||||
Type_RejectGameInvitationMessage = 34;
|
||||
Type_RejectInvNotifyMessage = 35;
|
||||
Type_StartEventMessage = 36;
|
||||
Type_StartEventAckMessage = 37;
|
||||
Type_GameStartInitialMessage = 38;
|
||||
Type_GameStartRejoinMessage = 39;
|
||||
Type_HandStartMessage = 40;
|
||||
Type_PlayersTurnMessage = 41;
|
||||
Type_MyActionRequestMessage = 42;
|
||||
Type_YourActionRejectedMessage = 43;
|
||||
Type_PlayersActionDoneMessage = 44;
|
||||
Type_DealFlopCardsMessage = 45;
|
||||
Type_DealTurnCardMessage = 46;
|
||||
Type_DealRiverCardMessage = 47;
|
||||
Type_AllInShowCardsMessage = 48;
|
||||
Type_EndOfHandShowCardsMessage = 49;
|
||||
Type_EndOfHandHideCardsMessage = 50;
|
||||
Type_ShowMyCardsRequestMessage = 51;
|
||||
Type_AfterHandShowCardsMessage = 52;
|
||||
Type_EndOfGameMessage = 53;
|
||||
Type_PlayerIdChangedMessage = 54;
|
||||
Type_AskKickPlayerMessage = 55;
|
||||
Type_AskKickDeniedMessage = 56;
|
||||
Type_StartKickPetitionMessage = 57;
|
||||
Type_VoteKickRequestMessage = 58;
|
||||
Type_VoteKickReplyMessage = 59;
|
||||
Type_KickPetitionUpdateMessage = 60;
|
||||
Type_EndKickPetitionMessage = 61;
|
||||
Type_StatisticsMessage = 62;
|
||||
Type_ChatRequestMessage = 63;
|
||||
Type_ChatMessage = 64;
|
||||
Type_ChatRejectMessage = 65;
|
||||
Type_DialogMessage = 66;
|
||||
Type_TimeoutWarningMessage = 67;
|
||||
Type_ResetTimeoutMessage = 68;
|
||||
Type_ReportAvatarMessage = 69;
|
||||
Type_ReportAvatarAckMessage = 70;
|
||||
Type_ReportGameMessage = 71;
|
||||
Type_ReportGameAckMessage = 72;
|
||||
Type_ErrorMessage = 73;
|
||||
Type_AdminRemoveGameMessage = 74;
|
||||
Type_AdminRemoveGameAckMessage = 75;
|
||||
Type_AdminBanPlayerMessage = 76;
|
||||
Type_AdminBanPlayerAckMessage = 77;
|
||||
Type_GameListSpectatorJoinedMessage = 78;
|
||||
Type_GameListSpectatorLeftMessage = 79;
|
||||
Type_GameSpectatorJoinedMessage = 80;
|
||||
Type_GameSpectatorLeftMessage = 81;
|
||||
}
|
||||
required PokerTHMessageType messageType = 1;
|
||||
|
||||
optional AnnounceMessage announceMessage = 2;
|
||||
optional AuthMessage authMessage = 3;
|
||||
optional LobbyMessage lobbyMessage = 4;
|
||||
optional GameMessage gameMessage = 5;
|
||||
optional InitMessage initMessage = 3;
|
||||
optional AuthServerChallengeMessage authServerChallengeMessage = 4;
|
||||
optional AuthClientResponseMessage authClientResponseMessage = 5;
|
||||
optional AuthServerVerificationMessage authServerVerificationMessage = 6;
|
||||
optional InitAckMessage initAckMessage = 7;
|
||||
optional AvatarRequestMessage avatarRequestMessage = 8;
|
||||
optional AvatarHeaderMessage avatarHeaderMessage = 9;
|
||||
optional AvatarDataMessage avatarDataMessage = 10;
|
||||
optional AvatarEndMessage avatarEndMessage = 11;
|
||||
optional UnknownAvatarMessage unknownAvatarMessage = 12;
|
||||
optional PlayerListMessage playerListMessage = 13;
|
||||
optional GameListNewMessage gameListNewMessage = 14;
|
||||
optional GameListUpdateMessage gameListUpdateMessage = 15;
|
||||
optional GameListPlayerJoinedMessage gameListPlayerJoinedMessage = 16;
|
||||
optional GameListPlayerLeftMessage gameListPlayerLeftMessage = 17;
|
||||
optional GameListAdminChangedMessage gameListAdminChangedMessage = 18;
|
||||
optional PlayerInfoRequestMessage playerInfoRequestMessage = 19;
|
||||
optional PlayerInfoReplyMessage playerInfoReplyMessage = 20;
|
||||
optional SubscriptionRequestMessage subscriptionRequestMessage = 21;
|
||||
optional JoinExistingGameMessage joinExistingGameMessage = 22;
|
||||
optional JoinNewGameMessage joinNewGameMessage = 23;
|
||||
optional RejoinExistingGameMessage rejoinExistingGameMessage = 24;
|
||||
optional JoinGameAckMessage joinGameAckMessage = 25;
|
||||
optional JoinGameFailedMessage joinGameFailedMessage = 26;
|
||||
optional GamePlayerJoinedMessage gamePlayerJoinedMessage = 27;
|
||||
optional GamePlayerLeftMessage gamePlayerLeftMessage = 28;
|
||||
optional GameAdminChangedMessage gameAdminChangedMessage = 29;
|
||||
optional RemovedFromGameMessage removedFromGameMessage = 30;
|
||||
optional KickPlayerRequestMessage kickPlayerRequestMessage = 31;
|
||||
optional LeaveGameRequestMessage leaveGameRequestMessage = 32;
|
||||
optional InvitePlayerToGameMessage invitePlayerToGameMessage = 33;
|
||||
optional InviteNotifyMessage inviteNotifyMessage = 34;
|
||||
optional RejectGameInvitationMessage rejectGameInvitationMessage = 35;
|
||||
optional RejectInvNotifyMessage rejectInvNotifyMessage = 36;
|
||||
optional StartEventMessage startEventMessage = 37;
|
||||
optional StartEventAckMessage startEventAckMessage = 38;
|
||||
optional GameStartInitialMessage gameStartInitialMessage = 39;
|
||||
optional GameStartRejoinMessage gameStartRejoinMessage = 40;
|
||||
optional HandStartMessage handStartMessage = 41;
|
||||
optional PlayersTurnMessage playersTurnMessage = 42;
|
||||
optional MyActionRequestMessage myActionRequestMessage = 43;
|
||||
optional YourActionRejectedMessage yourActionRejectedMessage = 44;
|
||||
optional PlayersActionDoneMessage playersActionDoneMessage = 45;
|
||||
optional DealFlopCardsMessage dealFlopCardsMessage = 46;
|
||||
optional DealTurnCardMessage dealTurnCardMessage = 47;
|
||||
optional DealRiverCardMessage dealRiverCardMessage = 48;
|
||||
optional AllInShowCardsMessage allInShowCardsMessage = 49;
|
||||
optional EndOfHandShowCardsMessage endOfHandShowCardsMessage = 50;
|
||||
optional EndOfHandHideCardsMessage endOfHandHideCardsMessage = 51;
|
||||
optional ShowMyCardsRequestMessage showMyCardsRequestMessage = 52;
|
||||
optional AfterHandShowCardsMessage afterHandShowCardsMessage = 53;
|
||||
optional EndOfGameMessage endOfGameMessage = 54;
|
||||
optional PlayerIdChangedMessage playerIdChangedMessage = 55;
|
||||
optional AskKickPlayerMessage askKickPlayerMessage = 56;
|
||||
optional AskKickDeniedMessage askKickDeniedMessage = 57;
|
||||
optional StartKickPetitionMessage startKickPetitionMessage = 58;
|
||||
optional VoteKickRequestMessage voteKickRequestMessage = 59;
|
||||
optional VoteKickReplyMessage voteKickReplyMessage = 60;
|
||||
optional KickPetitionUpdateMessage kickPetitionUpdateMessage = 61;
|
||||
optional EndKickPetitionMessage endKickPetitionMessage = 62;
|
||||
optional StatisticsMessage statisticsMessage = 63;
|
||||
optional ChatRequestMessage chatRequestMessage = 64;
|
||||
optional ChatMessage chatMessage = 65;
|
||||
optional ChatRejectMessage chatRejectMessage = 66;
|
||||
optional DialogMessage dialogMessage = 67;
|
||||
optional TimeoutWarningMessage timeoutWarningMessage = 68;
|
||||
optional ResetTimeoutMessage resetTimeoutMessage = 69;
|
||||
optional ReportAvatarMessage reportAvatarMessage = 70;
|
||||
optional ReportAvatarAckMessage reportAvatarAckMessage = 71;
|
||||
optional ReportGameMessage reportGameMessage = 72;
|
||||
optional ReportGameAckMessage reportGameAckMessage = 73;
|
||||
optional ErrorMessage errorMessage = 74;
|
||||
optional AdminRemoveGameMessage adminRemoveGameMessage = 75;
|
||||
optional AdminRemoveGameAckMessage adminRemoveGameAckMessage = 76;
|
||||
optional AdminBanPlayerMessage adminBanPlayerMessage = 77;
|
||||
optional AdminBanPlayerAckMessage adminBanPlayerAckMessage = 78;
|
||||
optional GameListSpectatorJoinedMessage gameListSpectatorJoinedMessage = 79;
|
||||
optional GameListSpectatorLeftMessage gameListSpectatorLeftMessage = 80;
|
||||
optional GameSpectatorJoinedMessage gameSpectatorJoinedMessage = 81;
|
||||
optional GameSpectatorLeftMessage gameSpectatorLeftMessage = 82;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# QMake pro-file for PokerTH
|
||||
|
||||
!c++11 {
|
||||
system( $$QMAKE_CXX -dumpversion | grep -e "^6.[0-9]" > /dev/null ) {
|
||||
greaterThan(QT_MAJOR_VERSION, 5) | equals(QT_MAJOR_VERSION, 5) {
|
||||
CONFIG += c++11
|
||||
}
|
||||
else {
|
||||
equals(QT_MAJOR_VERSION, 4) : greaterThan(QT_MINOR_VERSION, 7) {
|
||||
CONFIG += "c++11"
|
||||
QMAKE_CXXFLAGS += "-std=gnu++11"
|
||||
}
|
||||
else {
|
||||
error (QT must be greater and 4.8+)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c++11 {
|
||||
!system( $$QMAKE_CXX -dumpversion | grep -e "^6.[0-9]" > /dev/null ) {
|
||||
equals(QT_MAJOR_VERSION, 4) : greaterThan(QT_MINOR_VERSION, 7) {
|
||||
QMAKE_CXXFLAGS += "-std=gnu++11"
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -17,6 +17,9 @@ DEFINES += ENABLE_IPV6 TIXML_USE_STL
|
||||
QT -= core gui
|
||||
#PRECOMPILED_HEADER = src/pch_lib.h
|
||||
|
||||
# Check for c++11
|
||||
include(pokerth_common.pro)
|
||||
|
||||
INCLUDEPATH += . \
|
||||
src
|
||||
|
||||
@@ -57,7 +60,7 @@ mac{
|
||||
CONFIG += x86_64
|
||||
CONFIG -= x86
|
||||
CONFIG -= ppc
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
|
||||
QMAKE_CXXFLAGS -= -std=gnu++0x
|
||||
|
||||
# for universal-compilation on PPC-Mac uncomment the following line
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
# QMake pro-file for PokerTH official server DB backend
|
||||
TEMPLATE = lib
|
||||
CODECFORSRC = UTF-8
|
||||
CONFIG += staticlib \
|
||||
thread \
|
||||
exceptions \
|
||||
rtti \
|
||||
stl \
|
||||
warn_on
|
||||
UI_DIR = uics
|
||||
TARGET = lib/pokerth_dbofficial
|
||||
MOC_DIR = mocs
|
||||
OBJECTS_DIR = obj
|
||||
QT -= core \
|
||||
gui
|
||||
|
||||
# Check for c++11
|
||||
include(pokerth_common.pro)
|
||||
|
||||
# PRECOMPILED_HEADER = dbofficial/pch_lib.h
|
||||
INCLUDEPATH += . \
|
||||
./src
|
||||
DEPENDPATH += . \
|
||||
./src
|
||||
|
||||
# Input
|
||||
HEADERS += src/dbofficial/asyncdbauth.h \
|
||||
src/dbofficial/asyncdbcreategame.h \
|
||||
src/dbofficial/asyncdbgameplace.h \
|
||||
src/dbofficial/asyncdbupdatescore.h \
|
||||
src/dbofficial/asyncdbquery.h \
|
||||
src/dbofficial/serverdbthread.h \
|
||||
src/dbofficial/serverdbfactoryinternal.h \
|
||||
src/dbofficial/compositeasyncdbquery.h \
|
||||
src/dbofficial/singleasyncdbquery.h \
|
||||
src/dbofficial/querycontext.h \
|
||||
src/dbofficial/asyncdbendgame.h \
|
||||
src/dbofficial/db_table_defs.h \
|
||||
src/dbofficial/asyncdblogin.h \
|
||||
src/dbofficial/asyncdbreportavatar.h \
|
||||
src/dbofficial/asyncdbreportgame.h \
|
||||
src/dbofficial/asyncdbavatarblacklist.h \
|
||||
src/dbofficial/asyncdbadminplayers.h \
|
||||
src/dbofficial/asyncdbblockplayer.h \
|
||||
src/dbofficial/dbidmanager.h
|
||||
SOURCES += src/dbofficial/asyncdbauth.cpp \
|
||||
src/dbofficial/asyncdbcreategame.cpp \
|
||||
src/dbofficial/asyncdbgameplace.cpp \
|
||||
src/dbofficial/asyncdbupdatescore.cpp \
|
||||
src/dbofficial/asyncdbquery.cpp \
|
||||
src/dbofficial/serverdbthread.cpp \
|
||||
src/dbofficial/serverdbfactoryinternal.cpp \
|
||||
src/dbofficial/singleasyncdbquery.cpp \
|
||||
src/dbofficial/compositeasyncdbquery.cpp \
|
||||
src/dbofficial/querycontext.cpp \
|
||||
src/dbofficial/asyncdbendgame.cpp \
|
||||
src/dbofficial/asyncdblogin.cpp \
|
||||
src/dbofficial/asyncdbreportavatar.cpp \
|
||||
src/dbofficial/asyncdbreportgame.cpp \
|
||||
src/dbofficial/asyncdbavatarblacklist.cpp \
|
||||
src/dbofficial/asyncdbadminplayers.cpp \
|
||||
src/dbofficial/asyncdbblockplayer.cpp \
|
||||
src/dbofficial/dbidmanager.cpp
|
||||
win32 {
|
||||
DEFINES += _WIN32_WINNT=0x0501
|
||||
INCLUDEPATH += ../../../boost/ \
|
||||
../../../GnuTLS/include \
|
||||
../../../curl/include \
|
||||
../../../mysql/include \
|
||||
../../../mysql++/lib \
|
||||
../../../zlib
|
||||
}
|
||||
!win32 {
|
||||
# #### My release static build options
|
||||
# QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections
|
||||
INCLUDEPATH += /usr/include \
|
||||
/usr/include/mysql \
|
||||
/usr/include/mysql++
|
||||
INCLUDEPATH += /opt/boost/include
|
||||
}
|
||||
mac {
|
||||
# make it universal
|
||||
CONFIG += x86
|
||||
CONFIG -= ppc
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
|
||||
|
||||
# for universal-compilation on PPC-Mac uncomment the following line
|
||||
# on Intel-Mac you have to comment this line out or build will fail.
|
||||
# QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk/
|
||||
INCLUDEPATH += /Developer/SDKs/MacOSX10.5.sdk/usr/include/
|
||||
INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers
|
||||
INCLUDEPATH += /Library/Frameworks/SDL_mixer.framework/Headers
|
||||
INCLUDEPATH += /opt/local/include/mysql++ \
|
||||
/opt/local/include/mysql5/mysql
|
||||
}
|
||||
+58
-36
@@ -26,6 +26,9 @@ DEFINES += ENABLE_IPV6 TIXML_USE_STL BOOST_FILESYSTEM_DEPRECATED
|
||||
DEFINES += PREFIX=\"$${PREFIX}\"
|
||||
TARGET = pokerth
|
||||
|
||||
# Check for c++11
|
||||
include(pokerth_common.pro)
|
||||
|
||||
# PRECOMPILED_HEADER = src/pch_game.h
|
||||
|
||||
android{
|
||||
@@ -408,7 +411,8 @@ unix:!mac {
|
||||
LIBPATH += $${PREFIX}/lib /opt/gsasl/lib
|
||||
LIB_DIRS = $${PREFIX}/lib \
|
||||
$${PREFIX}/lib64 \
|
||||
$$system(qmake -query QT_INSTALL_LIBS)
|
||||
$${PREFIX}/lib/x86_64-linux-gnu \
|
||||
$$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||
}
|
||||
android{
|
||||
LIBPATH += $${PREFIX}/lib/armv7
|
||||
@@ -422,14 +426,14 @@ unix:!mac {
|
||||
boost_iostreams-mt
|
||||
BOOST_REGEX = boost_regex \
|
||||
boost_regex-mt
|
||||
BOOST_CHRONO = boost_chrono \
|
||||
boost_chrono-mt
|
||||
BOOST_SYS = boost_system \
|
||||
boost_system-mt
|
||||
BOOST_RANDOM = boost_random \
|
||||
boost_random-mt
|
||||
BOOST_CHRONO = boost_chrono \
|
||||
boost_chrono-mt
|
||||
|
||||
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system(qmake -query QT_INSTALL_LIBS)
|
||||
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||
# to override the default '/usr' pass PREFIX
|
||||
# variable to qmake.
|
||||
for(dir, LIB_DIRS):exists($$dir) {
|
||||
@@ -465,14 +469,6 @@ unix:!mac {
|
||||
message("Found $$lib")
|
||||
BOOST_REGEX = -l$$lib
|
||||
}
|
||||
for(lib, BOOST_CHRONO):exists($${dir}/lib$${lib}.so*) {
|
||||
message("Found $$lib")
|
||||
BOOST_CHRONO = -l$$lib
|
||||
}
|
||||
for(lib, BOOST_CHRONO):exists($${dir}/lib$${lib}.a) {
|
||||
message("Found $$lib")
|
||||
BOOST_CHRONO = -l$$lib
|
||||
}
|
||||
!android{
|
||||
for(lib, BOOST_RANDOM):exists($${dir}/lib$${lib}.so*) {
|
||||
message("Found $$lib")
|
||||
@@ -491,16 +487,37 @@ unix:!mac {
|
||||
message("Found $$lib")
|
||||
BOOST_SYS = -l$$lib
|
||||
}
|
||||
!c++11 {
|
||||
for(lib, BOOST_CHRONO):exists($${dir}/lib$${lib}.so*) {
|
||||
message("Found $$lib")
|
||||
BOOST_CHRONO = -l$$lib
|
||||
}
|
||||
for(lib, BOOST_CHRONO):exists($${dir}/lib$${lib}.a) {
|
||||
message("Found $$lib")
|
||||
BOOST_CHRONO = -l$$lib
|
||||
}
|
||||
}
|
||||
}
|
||||
!android{
|
||||
BOOST_LIBS = $$BOOST_THREAD \
|
||||
c++11 {
|
||||
BOOST_LIBS = $$BOOST_THREAD \
|
||||
$$BOOST_FS \
|
||||
$$BOOST_IOSTREAMS \
|
||||
$$BOOST_REGEX \
|
||||
$$BOOST_CHRONO \
|
||||
$$BOOST_RANDOM \
|
||||
$$BOOST_SYS
|
||||
!count(BOOST_LIBS, 7):error("Unable to find boost libraries in PREFIX=$${PREFIX}")
|
||||
!count(BOOST_LIBS, 6):error("Unable to find boost libraries in PREFIX=$${PREFIX}")
|
||||
}
|
||||
!c++11 {
|
||||
BOOST_LIBS = $$BOOST_THREAD \
|
||||
$$BOOST_FS \
|
||||
$$BOOST_IOSTREAMS \
|
||||
$$BOOST_REGEX \
|
||||
$$BOOST_RANDOM \
|
||||
$$$$BOOST_SYS \
|
||||
$$BOOST_CHRONO
|
||||
!count(BOOST_LIBS, 7):error("Unable to find boost libraries in PREFIX=$${PREFIX}")
|
||||
}
|
||||
if($$system(sdl-config --version)):error("sdl-config not found in PATH - libSDL_mixer, libSDL are required!")
|
||||
UNAME = $$system(uname -s)
|
||||
BSD = $$find(UNAME, "BSD")
|
||||
@@ -520,9 +537,8 @@ unix:!mac {
|
||||
$$BOOST_FS \
|
||||
$$BOOST_IOSTREAMS \
|
||||
$$BOOST_REGEX \
|
||||
$$BOOST_CHRONO \
|
||||
$$BOOST_SYS
|
||||
!count(BOOST_LIBS, 5):error("Unable to find boost libraries in PREFIX=$${PREFIX}/armv5")
|
||||
!count(BOOST_LIBS, 5):error("Unable to find boost libraries in PREFIX=$${PREFIX}/armv7")
|
||||
LIBS += -ltinyxml
|
||||
LIBS += $$BOOST_LIBS
|
||||
LIBS += -lgsasl -lidn
|
||||
@@ -560,7 +576,7 @@ mac {
|
||||
CONFIG += x86_64
|
||||
CONFIG -= x86
|
||||
CONFIG -= ppc
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
|
||||
QMAKE_CXXFLAGS -= -std=gnu++0x
|
||||
|
||||
# workaround for problems with boost_filesystem exceptions
|
||||
@@ -571,23 +587,22 @@ mac {
|
||||
# QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk/
|
||||
LIBPATH += lib
|
||||
|
||||
# QT dynamic linked framework (see also mac_post_make.sh)
|
||||
LIBS += -framework \
|
||||
QtCore
|
||||
LIBS += -framework \
|
||||
QtGui
|
||||
|
||||
# SDL and SDL_mixer come as frameworks
|
||||
LIBS += -framework \
|
||||
SDL
|
||||
LIBS += -framework \
|
||||
SDL_mixer
|
||||
# QT dynamic linked framework (see also mac_post_make.sh)
|
||||
LIBS += -F /Library/Frameworks
|
||||
# LIBS += -framework \
|
||||
# QtCore
|
||||
# LIBS += -framework \
|
||||
# QtGui
|
||||
LIBS += -framework \
|
||||
SDL
|
||||
LIBS += -framework \
|
||||
SDL_mixer
|
||||
|
||||
# make sure you have an x86_64 version of boost
|
||||
LIBS += /usr/local/lib/libboost_thread.a
|
||||
LIBS += /usr/local/lib/libboost_thread-mt.a
|
||||
LIBS += /usr/local/lib/libboost_filesystem.a
|
||||
LIBS += /usr/local/lib/libboost_regex.a
|
||||
LIBS += /usr/local/lib/libboost_chrono.a
|
||||
LIBS += /usr/local/lib/libboost_random.a
|
||||
LIBS += /usr/local/lib/libboost_system.a
|
||||
LIBS += /usr/local/lib/libboost_iostreams.a
|
||||
@@ -601,20 +616,26 @@ mac {
|
||||
-lprotobuf \
|
||||
-lz \
|
||||
-framework \
|
||||
Carbon
|
||||
Cocoa
|
||||
|
||||
# set the application icon
|
||||
RC_FILE = pokerth.icns
|
||||
LIBPATH += /Developer/SDKs/MacOSX10.6.sdk/usr/lib
|
||||
INCLUDEPATH += /Developer/SDKs/MacOSX10.6.sdk/usr/include/
|
||||
INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers
|
||||
INCLUDEPATH += /Library/Frameworks/SDL_mixer.framework/Headers
|
||||
|
||||
LIBPATH += /usr/local/lib
|
||||
LIBPATH += /usr/local/opt/openssl/lib
|
||||
LIBPATH += /usr/local/opt/tinyxml/lib
|
||||
LIBPATH += /usr/local/opt/protobuf/lib
|
||||
INCLUDEPATH += /usr/local/include
|
||||
INCLUDEPATH += /usr/local/opt/openssl/include
|
||||
INCLUDEPATH += /usr/local/opt/tinyxml/include
|
||||
INCLUDEPATH += /usr/local/opt/protobuf/include
|
||||
INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers
|
||||
INCLUDEPATH += /Library/Frameworks/SDL_mixer.framework/Headers
|
||||
}
|
||||
OTHER_FILES += docs/infomessage-id-desc.txt
|
||||
official_server {
|
||||
LIBPATH += pkth_stat/daemon_lib/lib
|
||||
LIBS += -lpokerth_closed \
|
||||
LIBS += -lpokerth_dbofficial \
|
||||
-lmysqlpp
|
||||
DEFINES += POKERTH_OFFICIAL_SERVER
|
||||
}
|
||||
@@ -652,6 +673,7 @@ android{
|
||||
DEFINES += TIXML_USE_STL
|
||||
# sqlite3 is included directly.
|
||||
INCLUDEPATH += src/third_party/sqlite3
|
||||
INCLUDEPATH += /home/min/Dokumente/Android/android-ndk-r13b/platforms/android-19/arch-arm/usr/include
|
||||
|
||||
# sound system switches
|
||||
!android_api8 {
|
||||
|
||||
+56
-24
@@ -17,6 +17,9 @@ DEFINES += ENABLE_IPV6 TIXML_USE_STL BOOST_FILESYSTEM_DEPRECATED
|
||||
QT -= core gui
|
||||
#PRECOMPILED_HEADER = src/pch_lib.h
|
||||
|
||||
# Check for c++11
|
||||
include(pokerth_common.pro)
|
||||
|
||||
INCLUDEPATH += . \
|
||||
src \
|
||||
src/engine \
|
||||
@@ -28,7 +31,7 @@ INCLUDEPATH += . \
|
||||
src/engine/network_engine \
|
||||
src/config \
|
||||
src/core \
|
||||
src/third_party/websocketpp
|
||||
src/third_party/websocketpp
|
||||
|
||||
DEPENDPATH += . \
|
||||
src \
|
||||
@@ -71,6 +74,7 @@ HEADERS += \
|
||||
src/net/clientthread.h \
|
||||
src/net/genericsocket.h \
|
||||
src/net/netpacket.h \
|
||||
src/net/netpacketvalidator.h \
|
||||
src/net/senderhelper.h \
|
||||
src/net/sendercallback.h \
|
||||
src/net/serverexception.h \
|
||||
@@ -137,14 +141,7 @@ HEADERS += \
|
||||
src/net/servermanagerfactory.h \
|
||||
src/net/uploadcallback.h \
|
||||
src/net/websocket_defs.h \
|
||||
src/net/websocketdata.h \
|
||||
src/net/validation/lobbymessagevalidator.h \
|
||||
src/net/validation/authmessagevalidator.h \
|
||||
src/net/validation/gamemessagevalidator.h \
|
||||
src/net/validation/gameenginemessagevalidator.h \
|
||||
src/net/validation/gamemanagementmessagevalidator.h \
|
||||
src/net/validation/pokerthmessagevalidator.h \
|
||||
src/net/validation/validationhelper.h
|
||||
src/net/websocketdata.h
|
||||
|
||||
SOURCES += \
|
||||
src/engine/game.cpp \
|
||||
@@ -189,6 +186,7 @@ SOURCES += \
|
||||
src/net/common/downloadhelper.cpp \
|
||||
src/net/common/downloaderthread.cpp \
|
||||
src/net/common/netpacket.cpp \
|
||||
src/net/common/netpacketvalidator.cpp \
|
||||
src/net/common/senderhelper.cpp \
|
||||
src/net/common/sendercallback.cpp \
|
||||
src/net/common/serverexception.cpp \
|
||||
@@ -197,7 +195,6 @@ SOURCES += \
|
||||
src/net/common/servergame.cpp \
|
||||
src/net/common/servergamestate.cpp \
|
||||
src/net/common/serverlobbythread.cpp \
|
||||
src/net/common/serverdelaytime.cpp \
|
||||
src/net/common/serverbanmanager.cpp \
|
||||
src/net/common/servercallback.cpp \
|
||||
src/net/common/serveradminbot.cpp \
|
||||
@@ -223,13 +220,7 @@ SOURCES += \
|
||||
src/net/common/receivebuffer.cpp \
|
||||
src/net/common/asioreceivebuffer.cpp \
|
||||
src/net/common/webreceivebuffer.cpp \
|
||||
src/net/common/uploadcallback.cpp \
|
||||
src/net/common/validation/authmessagevalidator.cpp \
|
||||
src/net/common/validation/gamemessagevalidator.cpp \
|
||||
src/net/common/validation/lobbymessagevalidator.cpp \
|
||||
src/net/common/validation/pokerthmessagevalidator.cpp \
|
||||
src/net/common/validation/gameenginemessagevalidator.cpp \
|
||||
src/net/common/validation/gamemanagementmessagevalidator.cpp
|
||||
src/net/common/uploadcallback.cpp
|
||||
|
||||
!android:!android_test{
|
||||
SOURCES += src/engine/local_engine/tools.cpp
|
||||
@@ -238,9 +229,49 @@ android|android_test{
|
||||
SOURCES += src/engine/local_engine/tools_android.cpp
|
||||
}
|
||||
|
||||
official_server{
|
||||
INCLUDEPATH += pkth_stat/daemon_lib/src
|
||||
official_server:!win32:!gui_800x480:!client:{
|
||||
# INCLUDEPATH += pkth_stat/daemon_lib/src # note: relict from former official/closed db build
|
||||
DEFINES += POKERTH_OFFICIAL_SERVER
|
||||
HEADERS += src/dbofficial/asyncdbauth.h \
|
||||
src/dbofficial/asyncdbcreategame.h \
|
||||
src/dbofficial/asyncdbgameplace.h \
|
||||
src/dbofficial/asyncdbupdatescore.h \
|
||||
src/dbofficial/asyncdbquery.h \
|
||||
src/dbofficial/serverdbthread.h \
|
||||
src/dbofficial/serverdbfactoryinternal.h \
|
||||
src/dbofficial/compositeasyncdbquery.h \
|
||||
src/dbofficial/singleasyncdbquery.h \
|
||||
src/dbofficial/querycontext.h \
|
||||
src/dbofficial/asyncdbendgame.h \
|
||||
src/dbofficial/db_table_defs.h \
|
||||
src/dbofficial/asyncdblogin.h \
|
||||
src/dbofficial/asyncdbreportavatar.h \
|
||||
src/dbofficial/asyncdbreportgame.h \
|
||||
src/dbofficial/asyncdbavatarblacklist.h \
|
||||
src/dbofficial/asyncdbadminplayers.h \
|
||||
src/dbofficial/asyncdbblockplayer.h \
|
||||
src/dbofficial/dbidmanager.h
|
||||
SOURCES += src/dbofficial/asyncdbauth.cpp \
|
||||
src/dbofficial/asyncdbcreategame.cpp \
|
||||
src/dbofficial/asyncdbgameplace.cpp \
|
||||
src/dbofficial/asyncdbupdatescore.cpp \
|
||||
src/dbofficial/asyncdbquery.cpp \
|
||||
src/dbofficial/serverdbthread.cpp \
|
||||
src/dbofficial/serverdbfactoryinternal.cpp \
|
||||
src/dbofficial/singleasyncdbquery.cpp \
|
||||
src/dbofficial/compositeasyncdbquery.cpp \
|
||||
src/dbofficial/querycontext.cpp \
|
||||
src/dbofficial/asyncdbendgame.cpp \
|
||||
src/dbofficial/asyncdblogin.cpp \
|
||||
src/dbofficial/asyncdbreportavatar.cpp \
|
||||
src/dbofficial/asyncdbreportgame.cpp \
|
||||
src/dbofficial/asyncdbavatarblacklist.cpp \
|
||||
src/dbofficial/asyncdbadminplayers.cpp \
|
||||
src/dbofficial/asyncdbblockplayer.cpp \
|
||||
src/dbofficial/dbidmanager.cpp
|
||||
INCLUDEPATH += /usr/include \
|
||||
/usr/include/mysql \
|
||||
/usr/include/mysql++
|
||||
}
|
||||
|
||||
win32{
|
||||
@@ -263,17 +294,17 @@ mac{
|
||||
CONFIG += x86_64
|
||||
CONFIG -= x86
|
||||
CONFIG -= ppc
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
|
||||
QMAKE_CXXFLAGS -= -std=gnu++0x
|
||||
|
||||
# for universal-compilation on PPC-Mac uncomment the following line
|
||||
# on Intel-Mac you have to comment this line out or build will fail.
|
||||
# QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk/
|
||||
|
||||
INCLUDEPATH += /Developer/SDKs/MacOSX10.6.sdk/usr/include/
|
||||
INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers
|
||||
INCLUDEPATH += /Library/Frameworks/SDL_mixer.framework/Headers
|
||||
LIBPATH += /usr/local/opt/openssl/lib
|
||||
INCLUDEPATH += /usr/local/opt/openssl/include
|
||||
INCLUDEPATH += /usr/local/include
|
||||
INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers
|
||||
INCLUDEPATH += /Library/Frameworks/SDL_mixer.framework/Headers
|
||||
}
|
||||
|
||||
android{
|
||||
@@ -281,6 +312,7 @@ android{
|
||||
DEFINES += BOOST_FILESYSTEM_VERSION=3
|
||||
# sqlite3 is included directly.
|
||||
INCLUDEPATH += src/third_party/sqlite3
|
||||
INCLUDEPATH += /home/min/Dokumente/Android/android-ndk-r13b/platforms/android-19/arch-arm/usr/include
|
||||
SOURCES += src/third_party/sqlite3/sqlite3.c
|
||||
}
|
||||
|
||||
|
||||
+24
-8
@@ -17,6 +17,9 @@ QT -= core \
|
||||
gui
|
||||
# PRECOMPILED_HEADER = src/pch_lib.h
|
||||
|
||||
# Check for c++11
|
||||
include(pokerth_common.pro)
|
||||
|
||||
INCLUDEPATH += . \
|
||||
src
|
||||
DEPENDPATH += . \
|
||||
@@ -31,19 +34,32 @@ SOURCES += src/third_party/protobuf/pokerth.pb.cc \
|
||||
win32 {
|
||||
DEFINES += CURL_STATICLIB
|
||||
DEFINES += _WIN32_WINNT=0x0501
|
||||
}
|
||||
unix : !mac {
|
||||
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)
|
||||
}
|
||||
unix : !mac {
|
||||
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)
|
||||
|
||||
android {
|
||||
system(wine protoc.exe pokerth.proto --cpp_out=src/third_party/protobuf)
|
||||
system(wine protoc.exe chatcleaner.proto --cpp_out=src/third_party/protobuf)
|
||||
system(wine protoc.exe pokerth.proto --java_out=tests/src)
|
||||
}
|
||||
}
|
||||
mac {
|
||||
# make it x86_64 only
|
||||
CONFIG += x86_64
|
||||
CONFIG -= x86
|
||||
CONFIG -= ppc
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
|
||||
# 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.
|
||||
|
||||
+32
-19
@@ -19,6 +19,9 @@ DEFINES += PREFIX=\"$${PREFIX}\"
|
||||
QT -= core gui
|
||||
#PRECOMPILED_HEADER = src/pch_lib.h
|
||||
|
||||
# Check for c++11
|
||||
include(pokerth_common.pro)
|
||||
|
||||
INCLUDEPATH += . \
|
||||
src \
|
||||
src/engine \
|
||||
@@ -70,7 +73,6 @@ HEADERS += \
|
||||
src/net/senderhelper.h \
|
||||
src/net/serveraccepthelper.h \
|
||||
src/net/serverlobbythread.h \
|
||||
src/net/serverdelaytime.h \
|
||||
src/net/socket_helper.h \
|
||||
src/net/socket_msg.h \
|
||||
src/net/socket_startup.h \
|
||||
@@ -176,18 +178,20 @@ unix : !mac {
|
||||
|
||||
LIBPATH += lib $${PREFIX}/lib /opt/gsasl/lib
|
||||
INCLUDEPATH += $${PREFIX}/include
|
||||
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system(qmake -query QT_INSTALL_LIBS)
|
||||
# see issue https://github.com/pokerth/pokerth/issues/282
|
||||
INCLUDEPATH += $${PREFIX}/include/libircclient
|
||||
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||
BOOST_FS = boost_filesystem boost_filesystem-mt
|
||||
BOOST_THREAD = boost_thread boost_thread-mt
|
||||
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
|
||||
BOOST_IOSTREAMS = boost_iostreams boost_iostreams-mt
|
||||
BOOST_CHRONO = boost_chrono boost_chrono-mt
|
||||
BOOST_SYS = boost_system boost_system-mt
|
||||
BOOST_REGEX = boost_regex boost_regex-mt
|
||||
BOOST_RANDOM = boost_random boost_random-mt
|
||||
BOOST_CHRONO = boost_chrono boost_chrono-mt
|
||||
|
||||
#
|
||||
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system(qmake -query QT_INSTALL_LIBS)
|
||||
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
|
||||
# to override the default '/usr' pass PREFIX
|
||||
# variable to qmake.
|
||||
#
|
||||
@@ -233,14 +237,6 @@ unix : !mac {
|
||||
message("Found $$lib")
|
||||
BOOST_REGEX = -l$$lib
|
||||
}
|
||||
for(lib, BOOST_CHRONO):exists($${dir}/lib$${lib}.so*) {
|
||||
message("Found $$lib")
|
||||
BOOST_CHRONO = -l$$lib
|
||||
}
|
||||
for(lib, BOOST_CHRONO):exists($${dir}/lib$${lib}.a) {
|
||||
message("Found $$lib")
|
||||
BOOST_CHRONO = -l$$lib
|
||||
}
|
||||
for(lib, BOOST_RANDOM):exists($${dir}/lib$${lib}.so*) {
|
||||
message("Found $$lib")
|
||||
BOOST_RANDOM = -l$$lib
|
||||
@@ -257,11 +253,29 @@ unix : !mac {
|
||||
message("Found $$lib")
|
||||
BOOST_SYS = -l$$lib
|
||||
}
|
||||
!c++11 {
|
||||
for(lib, BOOST_CHRONO):exists($${dir}/lib$${lib}.so*) {
|
||||
message("Found $$lib")
|
||||
BOOST_CHRONO = -l$$lib
|
||||
}
|
||||
for(lib, BOOST_CHRONO):exists($${dir}/lib$${lib}.a) {
|
||||
message("Found $$lib")
|
||||
BOOST_CHRONO = -l$$lib
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BOOST_LIBS = $$BOOST_THREAD $$BOOST_FS $$BOOST_PROGRAM_OPTIONS $$BOOST_IOSTREAMS $$BOOST_REGEX $$BOOST_CHRONO $$BOOST_RANDOM $$BOOST_SYS
|
||||
!count(BOOST_LIBS, 8){
|
||||
error("Unable to find boost libraries in PREFIX=$${PREFIX}")
|
||||
c++11 {
|
||||
BOOST_LIBS = $$BOOST_THREAD $$BOOST_FS $$BOOST_PROGRAM_OPTIONS $$BOOST_IOSTREAMS $$BOOST_REGEX $$BOOST_RANDOM $$BOOST_SYS
|
||||
!count(BOOST_LIBS, 7){
|
||||
error("Unable to find boost libraries in PREFIX=$${PREFIX}")
|
||||
}
|
||||
}
|
||||
!c++11 {
|
||||
BOOST_LIBS = $$BOOST_THREAD $$BOOST_FS $$BOOST_PROGRAM_OPTIONS $$BOOST_IOSTREAMS $$BOOST_REGEX $$BOOST_RANDOM $$BOOST_SYS $$BOOST_CHRONO
|
||||
!count(BOOST_LIBS, 8){
|
||||
error("Unable to find boost libraries in PREFIX=$${PREFIX}")
|
||||
}
|
||||
}
|
||||
|
||||
UNAME = $$system(uname -s)
|
||||
@@ -296,7 +310,7 @@ mac {
|
||||
CONFIG += x86_64
|
||||
CONFIG -= x86
|
||||
CONFIG -= ppc
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
|
||||
QMAKE_CXXFLAGS -= -std=gnu++0x
|
||||
|
||||
# workaround for problems with boost_filesystem exceptions
|
||||
@@ -308,10 +322,9 @@ mac {
|
||||
|
||||
LIBPATH += lib
|
||||
# make sure you have an x86_64 version of boost
|
||||
LIBS += /usr/local/lib/libboost_thread.a
|
||||
LIBS += /usr/local/lib/libboost_thread-mt.a
|
||||
LIBS += /usr/local/lib/libboost_filesystem.a
|
||||
LIBS += /usr/local/lib/libboost_regex.a
|
||||
LIBS += /usr/local/lib/libboost_chrono.a
|
||||
LIBS += /usr/local/lib/libboost_random.a
|
||||
LIBS += /usr/local/lib/libboost_system.a
|
||||
LIBS += /usr/local/lib/libboost_iostreams.a
|
||||
@@ -331,7 +344,7 @@ mac {
|
||||
|
||||
official_server {
|
||||
LIBPATH += pkth_stat/daemon_lib/lib
|
||||
LIBS += -lpokerth_closed -lmysqlpp
|
||||
LIBS += -lpokerth_dbofficial -lmysqlpp
|
||||
DEFINES += POKERTH_OFFICIAL_SERVER
|
||||
}
|
||||
|
||||
|
||||
Executable
BIN
Binary file not shown.
@@ -39,11 +39,13 @@ class BadWordCheck: public QObject
|
||||
public:
|
||||
BadWordCheck();
|
||||
|
||||
void setBadWords(QStringList bw) {
|
||||
void setBadWords(QStringList bw)
|
||||
{
|
||||
badWords = bw;
|
||||
}
|
||||
|
||||
void setBadWordsException(QStringList bwe) {
|
||||
void setBadWordsException(QStringList bwe)
|
||||
{
|
||||
badWordsException = bwe;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ class CapsFloodCheck: public QObject
|
||||
public:
|
||||
CapsFloodCheck();
|
||||
|
||||
void setCapsNumberToTrigger(int n) {
|
||||
void setCapsNumberToTrigger(int n)
|
||||
{
|
||||
capsNumberToTrigger = n;
|
||||
}
|
||||
bool run(QString);
|
||||
|
||||
@@ -46,7 +46,8 @@ public:
|
||||
|
||||
~CleanerConfig();
|
||||
|
||||
std::string getConfigFileName() const {
|
||||
std::string getConfigFileName() const
|
||||
{
|
||||
return configFileName;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ class LetterRepeatingCheck: public QObject
|
||||
public:
|
||||
LetterRepeatingCheck();
|
||||
|
||||
void setLetterNumberToTrigger(int n) {
|
||||
void setLetterNumberToTrigger(int n)
|
||||
{
|
||||
letterNumberToTrigger = n;
|
||||
}
|
||||
bool run(QString);
|
||||
|
||||
@@ -45,7 +45,8 @@ public:
|
||||
TextFloodCheck();
|
||||
~TextFloodCheck();
|
||||
|
||||
void setTextFloodLevelToTrigger(int level) {
|
||||
void setTextFloodLevelToTrigger(int level)
|
||||
{
|
||||
textFloodLevelToTrigger = level;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,10 +39,12 @@ class UrlCheck: public QObject
|
||||
public:
|
||||
UrlCheck();
|
||||
|
||||
void setUrlStrings(QStringList us) {
|
||||
void setUrlStrings(QStringList us)
|
||||
{
|
||||
urlStrings = us;
|
||||
}
|
||||
void setUrlExceptionStrings(QStringList ues) {
|
||||
void setUrlExceptionStrings(QStringList ues)
|
||||
{
|
||||
urlExceptionStrings = ues;
|
||||
}
|
||||
bool run(QString);
|
||||
|
||||
@@ -311,6 +311,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
|
||||
configList.push_back(ConfigInfo("DBServerDatabaseName", CONFIG_TYPE_STRING, "pokerth"));
|
||||
configList.push_back(ConfigInfo("DBServerEncryptionKey", CONFIG_TYPE_STRING, ""));
|
||||
configList.push_back(ConfigInfo("GameNameBadWordList", CONFIG_TYPE_STRING_LIST, "Regex"));
|
||||
configList.push_back(ConfigInfo("ServerRestrictGuestLogin", CONFIG_TYPE_INT, "0"));
|
||||
|
||||
//fill tempList firstTime
|
||||
configBufferList = configList;
|
||||
|
||||
@@ -61,7 +61,7 @@ using namespace std;
|
||||
using namespace boost::filesystem;
|
||||
|
||||
struct AvatarFileState {
|
||||
ifstream inputStream;
|
||||
std::ifstream inputStream;
|
||||
};
|
||||
|
||||
AvatarManager::AvatarManager(bool useExternalServer, const std::string &externalServerAddress,
|
||||
@@ -195,17 +195,13 @@ AvatarManager::AvatarFileToNetPackets(const string &fileName, unsigned requestId
|
||||
AvatarFileType fileType;
|
||||
boost::shared_ptr<AvatarFileState> tmpState = OpenAvatarFileForChunkRead(fileName, fileSize, fileType);
|
||||
if (tmpState.get() && fileSize && fileType != AVATAR_FILE_TYPE_UNKNOWN) {
|
||||
{
|
||||
boost::shared_ptr<NetPacket> avatarHeader(new NetPacket);
|
||||
avatarHeader->GetMsg()->set_messagetype(PokerTHMessage::Type_LobbyMessage);
|
||||
LobbyMessage *netLobby = avatarHeader->GetMsg()->mutable_lobbymessage();
|
||||
netLobby->set_messagetype(LobbyMessage::Type_AvatarHeaderMessage);
|
||||
AvatarHeaderMessage *netHeader = netLobby->mutable_avatarheadermessage();
|
||||
netHeader->set_requestid(requestId);
|
||||
netHeader->set_avatartype(static_cast<NetAvatarType>(fileType));
|
||||
netHeader->set_avatarsize(fileSize);
|
||||
packets.push_back(avatarHeader);
|
||||
}
|
||||
boost::shared_ptr<NetPacket> avatarHeader(new NetPacket);
|
||||
avatarHeader->GetMsg()->set_messagetype(PokerTHMessage::Type_AvatarHeaderMessage);
|
||||
AvatarHeaderMessage *netHeader = avatarHeader->GetMsg()->mutable_avatarheadermessage();
|
||||
netHeader->set_requestid(requestId);
|
||||
netHeader->set_avatartype(static_cast<NetAvatarType>(fileType));
|
||||
netHeader->set_avatarsize(fileSize);
|
||||
packets.push_back(avatarHeader);
|
||||
|
||||
unsigned numBytes = 0;
|
||||
unsigned totalBytesRead = 0;
|
||||
@@ -216,10 +212,8 @@ AvatarManager::AvatarFileToNetPackets(const string &fileName, unsigned requestId
|
||||
totalBytesRead += numBytes;
|
||||
|
||||
boost::shared_ptr<NetPacket> avatarFile(new NetPacket);
|
||||
avatarFile->GetMsg()->set_messagetype(PokerTHMessage::Type_LobbyMessage);
|
||||
LobbyMessage *netLobby = avatarFile->GetMsg()->mutable_lobbymessage();
|
||||
netLobby->set_messagetype(LobbyMessage::Type_AvatarDataMessage);
|
||||
AvatarDataMessage *netFile = netLobby->mutable_avatardatamessage();
|
||||
avatarFile->GetMsg()->set_messagetype(PokerTHMessage::Type_AvatarDataMessage);
|
||||
AvatarDataMessage *netFile = avatarFile->GetMsg()->mutable_avatardatamessage();
|
||||
netFile->set_requestid(requestId);
|
||||
netFile->set_avatarblock((const char *)&tmpData[0], numBytes);
|
||||
packets.push_back(avatarFile);
|
||||
@@ -230,10 +224,8 @@ AvatarManager::AvatarFileToNetPackets(const string &fileName, unsigned requestId
|
||||
retVal = ERR_NET_WRONG_AVATAR_SIZE;
|
||||
else {
|
||||
boost::shared_ptr<NetPacket> avatarEnd(new NetPacket);
|
||||
avatarEnd->GetMsg()->set_messagetype(PokerTHMessage::Type_LobbyMessage);
|
||||
LobbyMessage *netLobby = avatarEnd->GetMsg()->mutable_lobbymessage();
|
||||
netLobby->set_messagetype(LobbyMessage::Type_AvatarEndMessage);
|
||||
AvatarEndMessage *netEnd = netLobby->mutable_avatarendmessage();
|
||||
avatarEnd->GetMsg()->set_messagetype(PokerTHMessage::Type_AvatarEndMessage);
|
||||
AvatarEndMessage *netEnd = avatarEnd->GetMsg()->mutable_avatarendmessage();
|
||||
netEnd->set_requestid(requestId);
|
||||
packets.push_back(avatarEnd);
|
||||
retVal = 0;
|
||||
@@ -371,7 +363,7 @@ AvatarManager::StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFil
|
||||
path tmpPath(cacheDir);
|
||||
tmpPath /= (md5buf.ToString() + ext);
|
||||
string fileName(tmpPath.file_string());
|
||||
ofstream o(fileName.c_str(), ios_base::out | ios_base::binary | ios_base::trunc);
|
||||
std::ofstream o(fileName.c_str(), ios_base::out | ios_base::binary | ios_base::trunc);
|
||||
if (!o.fail()) {
|
||||
o.write((const char *)data, size);
|
||||
o.close();
|
||||
|
||||
@@ -291,22 +291,33 @@ CryptHelper::AES128Encrypt(const unsigned char *keyData, unsigned keySize, const
|
||||
outCipher.resize(cipherSize);
|
||||
|
||||
#ifdef HAVE_OPENSSL
|
||||
EVP_CIPHER_CTX encryptCtx;
|
||||
EVP_CIPHER_CTX_init(&encryptCtx);
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||
EVP_CIPHER_CTX *encryptCtx = EVP_CIPHER_CTX_new();
|
||||
#else
|
||||
EVP_CIPHER_CTX _encryptCtx;
|
||||
EVP_CIPHER_CTX *encryptCtx;
|
||||
encryptCtx = &_encryptCtx;
|
||||
#endif // OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||
|
||||
EVP_CIPHER_CTX_init(encryptCtx);
|
||||
int outCipherSize = cipherSize;
|
||||
|
||||
int success = EVP_EncryptInit(&encryptCtx, EVP_aes_128_cbc(), key, iv);
|
||||
EVP_CIPHER_CTX_set_padding(&encryptCtx, 0);
|
||||
int success = EVP_EncryptInit(encryptCtx, EVP_aes_128_cbc(), key, iv);
|
||||
EVP_CIPHER_CTX_set_padding(encryptCtx, 0);
|
||||
if (success) {
|
||||
success = EVP_EncryptUpdate(&encryptCtx, &outCipher[0], &outCipherSize, paddedPlainStr, paddedPlainSize);
|
||||
success = EVP_EncryptUpdate(encryptCtx, &outCipher[0], &outCipherSize, paddedPlainStr, paddedPlainSize);
|
||||
|
||||
if (success && outCipherSize) {
|
||||
// Since padding is off, this will not modify the cipher. However, parameters need to be set.
|
||||
EVP_EncryptFinal(&encryptCtx, &outCipher[0], &outCipherSize);
|
||||
EVP_EncryptFinal(encryptCtx, &outCipher[0], &outCipherSize);
|
||||
retVal = true;
|
||||
}
|
||||
} else
|
||||
outCipher.clear();
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||
EVP_CIPHER_CTX_free(encryptCtx);
|
||||
#endif // OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||
#else
|
||||
gcry_cipher_hd_t hd;
|
||||
gcry_error_t err = gcry_cipher_open(&hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC, 0);
|
||||
@@ -338,22 +349,33 @@ CryptHelper::AES128Decrypt(const unsigned char *keyData, unsigned keySize, const
|
||||
BytesToKey(keyData, keySize, key, iv);
|
||||
outPlain.resize(cipherSize);
|
||||
#ifdef HAVE_OPENSSL
|
||||
EVP_CIPHER_CTX decryptCtx;
|
||||
EVP_CIPHER_CTX_init(&decryptCtx);
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||
EVP_CIPHER_CTX *decryptCtx = EVP_CIPHER_CTX_new();
|
||||
#else
|
||||
EVP_CIPHER_CTX _decryptCtx;
|
||||
EVP_CIPHER_CTX *decryptCtx;
|
||||
decryptCtx = &_decryptCtx;
|
||||
#endif // OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||
|
||||
EVP_CIPHER_CTX_init(decryptCtx);
|
||||
int outPlainSize = cipherSize;
|
||||
|
||||
int success = EVP_DecryptInit(&decryptCtx, EVP_aes_128_cbc(), key, iv);
|
||||
EVP_CIPHER_CTX_set_padding(&decryptCtx, 0);
|
||||
int success = EVP_DecryptInit(decryptCtx, EVP_aes_128_cbc(), key, iv);
|
||||
EVP_CIPHER_CTX_set_padding(decryptCtx, 0);
|
||||
if (success) {
|
||||
success = EVP_DecryptUpdate(&decryptCtx, (unsigned char *)&outPlain[0], &outPlainSize, cipher, cipherSize);
|
||||
success = EVP_DecryptUpdate(decryptCtx, (unsigned char *)&outPlain[0], &outPlainSize, cipher, cipherSize);
|
||||
|
||||
if (success && outPlainSize) {
|
||||
// Since padding is off, this will not modify the plain text. However, parameters need to be set.
|
||||
EVP_DecryptFinal(&decryptCtx, (unsigned char *)outPlain.c_str(), &outPlainSize);
|
||||
EVP_DecryptFinal(decryptCtx, (unsigned char *)outPlain.c_str(), &outPlainSize);
|
||||
retVal = true;
|
||||
}
|
||||
} else
|
||||
outPlain.clear();
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||
EVP_CIPHER_CTX_free(decryptCtx);
|
||||
#endif // OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||
#else
|
||||
gcry_cipher_hd_t hd;
|
||||
gcry_error_t err = gcry_cipher_open(&hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CBC, 0);
|
||||
|
||||
@@ -67,7 +67,7 @@ void
|
||||
internal_log_err(const string &msg)
|
||||
{
|
||||
if (!g_logFile.empty()) {
|
||||
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
||||
std::ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
||||
if (!o.fail()) {
|
||||
o << second_clock::local_time() << " ERR: " << msg;
|
||||
o.flush();
|
||||
@@ -80,7 +80,7 @@ internal_log_msg(const std::string &msg)
|
||||
{
|
||||
if (g_logLevel) {
|
||||
if (!g_logFile.empty()) {
|
||||
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
||||
std::ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
||||
if (!o.fail())
|
||||
o << second_clock::local_time() << " MSG: " << msg;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ internal_log_level(const std::string &msg, int logLevel)
|
||||
{
|
||||
if (g_logLevel >= logLevel) {
|
||||
if (!g_logFile.empty()) {
|
||||
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
||||
std::ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
||||
if (!o.fail())
|
||||
o << second_clock::local_time() << " OUT: " << msg;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ class ThreadStarter
|
||||
{
|
||||
public:
|
||||
ThreadStarter(Thread &thread) : m_thread(thread) {}
|
||||
void operator()() {
|
||||
void operator()()
|
||||
{
|
||||
m_thread.MainWrapper();
|
||||
}
|
||||
|
||||
|
||||
@@ -43,10 +43,12 @@ public:
|
||||
PokerTHException(const char *sourcefile, int sourceline, int errorId, int osErrorCode);
|
||||
virtual ~PokerTHException() throw();
|
||||
|
||||
int GetErrorId() const {
|
||||
int GetErrorId() const
|
||||
{
|
||||
return m_errorId;
|
||||
}
|
||||
int GetOsErrorCode() const {
|
||||
int GetOsErrorCode() const
|
||||
{
|
||||
return m_osErrorCode;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/asyncdbadminplayers.h>
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBAdminPlayers::AsyncDBAdminPlayers(unsigned queryId, const string &preparedName)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, list<string>())
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBAdminPlayers::~AsyncDBAdminPlayers()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBAdminPlayers::Init(DBIdManager& /*idManager*/)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBAdminPlayers::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
list<DB_id> adminPlayers;
|
||||
for (size_t i = 0; i < result.num_rows(); ++i) {
|
||||
if (!result[i].empty()) {
|
||||
adminPlayers.push_back(result[i][0]);
|
||||
}
|
||||
}
|
||||
service.post(boost::bind(&ServerDBCallback::PlayerAdminList, &cb, GetId(), adminPlayers));
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBAdminPlayers::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query should always produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBAdminPlayers::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::QueryError, &cb, "AsyncDBAdminPlayers: Failure."));
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database query for all admin players. */
|
||||
|
||||
#ifndef _ASYNCDBADMINPLAYERS_H_
|
||||
#define _ASYNCDBADMINPLAYERS_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBAdminPlayers : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBAdminPlayers(unsigned queryId, const std::string &preparedName);
|
||||
virtual ~AsyncDBAdminPlayers();
|
||||
|
||||
virtual void Init(DBIdManager& idManager);
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
+37
-36
@@ -1,6 +1,6 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* 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 *
|
||||
@@ -29,55 +29,56 @@
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <net/validation/gamemessagevalidator.h>
|
||||
#include <net/validation/gamemanagementmessagevalidator.h>
|
||||
#include <net/validation/gameenginemessagevalidator.h>
|
||||
#include <net/validation/validationhelper.h>
|
||||
#include <boost/mem_fn.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <dbofficial/asyncdbauth.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
GameMessageValidator::GameMessageValidator()
|
||||
|
||||
AsyncDBAuth::AsyncDBAuth(unsigned queryId, const string &preparedName, const list<string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params)
|
||||
{
|
||||
m_validationMap.insert(make_pair(GameMessage_GameMessageType_Type_GameManagementMessage, boost::bind(boost::mem_fn(&GameMessageValidator::ValidateGameManagementMessage), this, _1)));
|
||||
m_validationMap.insert(make_pair(GameMessage_GameMessageType_Type_GameEngineMessage, boost::bind(boost::mem_fn(&GameMessageValidator::ValidateGameEngineMessage), this, _1)));
|
||||
m_managementValidator.reset(new GameManagementMessageValidator);
|
||||
m_engineValidator.reset(new GameEngineMessageValidator);
|
||||
}
|
||||
|
||||
bool
|
||||
GameMessageValidator::IsValidMessage(const GameMessage &msg) const
|
||||
AsyncDBAuth::~AsyncDBAuth()
|
||||
{
|
||||
// Default: Invalid packet.
|
||||
bool retVal = false;
|
||||
if (msg.gameid() != 0) {
|
||||
ValidateFunctorMap::const_iterator pos = m_validationMap.find(msg.messagetype());
|
||||
if (pos != m_validationMap.end()) {
|
||||
// Call validation functor.
|
||||
retVal = pos->second(msg);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBAuth::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
if (result.num_rows() != 1) {
|
||||
service.post(boost::bind(&ServerDBCallback::PlayerLoginFailed, &cb, GetId()));
|
||||
} else {
|
||||
int blocked = result[0][2];
|
||||
int active = result[0][5];
|
||||
if ((active != 1) || (blocked != 0)) {
|
||||
service.post(boost::bind(&ServerDBCallback::PlayerLoginBlocked, &cb, GetId()));
|
||||
} else {
|
||||
mysqlpp::String secret(result[0][1]);
|
||||
mysqlpp::String country(result[0][3]);
|
||||
mysqlpp::String last_login(result[0][4]);
|
||||
boost::shared_ptr<DBPlayerData> tmpData(new DBPlayerData);
|
||||
tmpData->id = result[0][0];
|
||||
secret.to_string(tmpData->secret);
|
||||
if (!country.is_null())
|
||||
country.to_string(tmpData->country);
|
||||
last_login.to_string(tmpData->last_login);
|
||||
|
||||
service.post(boost::bind(&ServerDBCallback::PlayerLoginSuccess, &cb, GetId(), tmpData));
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
bool
|
||||
GameMessageValidator::ValidateGameManagementMessage(const GameMessage &msg)
|
||||
void
|
||||
AsyncDBAuth::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
bool retVal = false;
|
||||
if (msg.has_gamemanagementmessage()) {
|
||||
retVal = m_managementValidator->IsValidMessage(msg.gamemanagementmessage());
|
||||
}
|
||||
return retVal;
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
bool
|
||||
GameMessageValidator::ValidateGameEngineMessage(const GameMessage &msg)
|
||||
void
|
||||
AsyncDBAuth::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
bool retVal = false;
|
||||
if (msg.has_gameenginemessage()) {
|
||||
retVal = m_engineValidator->IsValidMessage(msg.gameenginemessage());
|
||||
}
|
||||
return retVal;
|
||||
service.post(boost::bind(&ServerDBCallback::PlayerLoginFailed, &cb, GetId()));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database auth query. */
|
||||
|
||||
#ifndef _ASYNCDBAUTH_H_
|
||||
#define _ASYNCDBAUTH_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBAuth : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBAuth(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBAuth();
|
||||
|
||||
virtual void Init(DBIdManager& /*idManager*/) {}
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH dedicated server *
|
||||
* Copyright (C) 2014 Lothar May *
|
||||
* 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 *
|
||||
@@ -28,51 +28,41 @@
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
package main
|
||||
|
||||
import (
|
||||
"code.google.com/p/go.net/websocket"
|
||||
"gameserver"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
)
|
||||
#include <boost/bind.hpp>
|
||||
#include <dbofficial/asyncdbavatarblacklist.h>
|
||||
|
||||
var lobby *gameserver.Lobby
|
||||
var dispatcher *gameserver.Dispatcher
|
||||
|
||||
func main() {
|
||||
lobby = gameserver.NewLobby()
|
||||
dispatcher = gameserver.NewDispatcher(nil, lobby.GetReceiver())
|
||||
go lobby.Run()
|
||||
go dispatcher.Run()
|
||||
using namespace std;
|
||||
|
||||
listener, err := net.Listen("tcp", ":7234")
|
||||
if err != nil {
|
||||
log.Fatalf("Listen error: %s", err.Error())
|
||||
}
|
||||
go acceptSockets(listener)
|
||||
|
||||
server := websocket.Server{Handler: handleWebsocketConn}
|
||||
http.Handle("/pokerthwebsocket", server)
|
||||
http.ListenAndServe(":7233", nil)
|
||||
AsyncDBAvatarBlacklist::AsyncDBAvatarBlacklist(unsigned queryId, const string &preparedName, const list<string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params)
|
||||
{
|
||||
}
|
||||
|
||||
func acceptSockets(listener net.Listener) {
|
||||
for {
|
||||
conn, err := listener.Accept()
|
||||
if err != nil {
|
||||
log.Fatalf("Accept error: %s\n", err.Error())
|
||||
}
|
||||
s := gameserver.NewSession(dispatcher.GetNextSessionId(), gameserver.HeaderPacketSerializer{}, conn, dispatcher.GetReceiver())
|
||||
lobby.AddSession(s)
|
||||
go s.Run()
|
||||
}
|
||||
AsyncDBAvatarBlacklist::~AsyncDBAvatarBlacklist()
|
||||
{
|
||||
}
|
||||
|
||||
func handleWebsocketConn(ws *websocket.Conn) {
|
||||
ws.PayloadType = websocket.BinaryFrame
|
||||
s := gameserver.NewSession(dispatcher.GetNextSessionId(), gameserver.RawPacketSerializer{}, ws, dispatcher.GetReceiver())
|
||||
lobby.AddSession(s)
|
||||
s.Run()
|
||||
void
|
||||
AsyncDBAvatarBlacklist::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
if (result.num_rows() == 0)
|
||||
service.post(boost::bind(&ServerDBCallback::AvatarIsOK, &cb, GetId()));
|
||||
else
|
||||
service.post(boost::bind(&ServerDBCallback::AvatarIsBlacklisted, &cb, GetId()));
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBAvatarBlacklist::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBAvatarBlacklist::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// If query failed: Avatar is blacklisted.
|
||||
service.post(boost::bind(&ServerDBCallback::AvatarIsBlacklisted, &cb, GetId()));
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database avatar blacklist query. */
|
||||
|
||||
#ifndef _ASYNCDBAVATARBLACKLIST_H_
|
||||
#define _ASYNCDBAVATARBLACKLIST_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBAvatarBlacklist : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBAvatarBlacklist(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBAvatarBlacklist();
|
||||
|
||||
virtual void Init(DBIdManager& /*idManager*/) {}
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,71 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <dbofficial/asyncdbblockplayer.h>
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBBlockPlayer::AsyncDBBlockPlayer(unsigned queryId, unsigned replyId, const string &preparedName, const list<string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params), m_replyId(replyId)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBBlockPlayer::~AsyncDBBlockPlayer()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBBlockPlayer::Init(DBIdManager &/*idManager*/)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBBlockPlayer::HandleResult(mysqlpp::Query &/*query*/, DBIdManager &/*idManager*/, mysqlpp::StoreQueryResult &/*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query does not produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBBlockPlayer::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager &/*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::BlockPlayerSuccess, &cb, GetId(), m_replyId));
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBBlockPlayer::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::BlockPlayerFailed, &cb, GetId(), m_replyId));
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database update to block a player. */
|
||||
|
||||
#ifndef _ASYNCDBBLOCKPLAYER_H_
|
||||
#define _ASYNCDBBLOCKPLAYER_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBBlockPlayer : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBBlockPlayer(unsigned queryId, unsigned replyId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBBlockPlayer();
|
||||
|
||||
virtual void Init(DBIdManager& idManager);
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned m_replyId;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,76 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <dbofficial/asyncdbcreategame.h>
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBCreateGame::AsyncDBCreateGame(unsigned queryId, const string &preparedName, const list<string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBCreateGame::~AsyncDBCreateGame()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBCreateGame::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query does not produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBCreateGame::HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
query.reset();
|
||||
query
|
||||
<< "SELECT LAST_INSERT_ID()";
|
||||
mysqlpp::StoreQueryResult tmpResult = query.store();
|
||||
DB_id insertId = tmpResult[0][0];
|
||||
if (!tmpResult || tmpResult.num_rows() != 1 || insertId == 0) {
|
||||
service.post(boost::bind(&ServerDBCallback::CreateGameFailed, &cb, GetId()));
|
||||
} else {
|
||||
service.post(boost::bind(&ServerDBCallback::CreateGameSuccess, &cb, GetId()));
|
||||
idManager.AddGameId(GetId(), insertId);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBCreateGame::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::CreateGameFailed, &cb, GetId()));
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database create game query. */
|
||||
|
||||
#ifndef _ASYNCDBCREATEGAME_H_
|
||||
#define _ASYNCDBCREATEGAME_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBCreateGame : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBCreateGame(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBCreateGame();
|
||||
|
||||
virtual void Init(DBIdManager& /*idManager*/) {}
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,77 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/asyncdbendgame.h>
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBEndGame::AsyncDBEndGame(unsigned queryId, const string &preparedName, const std::list<std::string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBEndGame::~AsyncDBEndGame()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBEndGame::Init(DBIdManager& idManager)
|
||||
{
|
||||
std::list<std::string> params;
|
||||
GetParams(params);
|
||||
ostringstream paramStream;
|
||||
paramStream << idManager.GetGameDBId(GetId());
|
||||
// Add game id as last parameter (where-clause).
|
||||
params.push_back(paramStream.str());
|
||||
SetParams(params);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBEndGame::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query does not produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBEndGame::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
|
||||
{
|
||||
// Nothing to do.
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBEndGame::HandleError(boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
|
||||
{
|
||||
// Ignore errors for now (as nothing important is done).
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database end game query. */
|
||||
|
||||
#ifndef _ASYNCDBENDGAME_H_
|
||||
#define _ASYNCDBENDGAME_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBEndGame : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBEndGame(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBEndGame();
|
||||
|
||||
virtual void Init(DBIdManager& idManager);
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH dedicated server *
|
||||
* Copyright (C) 2014 Lothar May *
|
||||
* 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 *
|
||||
@@ -28,47 +28,51 @@
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
package gameserver
|
||||
|
||||
import (
|
||||
"log"
|
||||
"pokerth"
|
||||
"sync/atomic"
|
||||
)
|
||||
#include <boost/bind.hpp>
|
||||
#include <dbofficial/asyncdbgameplace.h>
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
|
||||
type Dispatcher struct {
|
||||
receiver chan SessionPokerTHMessage
|
||||
authChan chan SessionAuthMessage
|
||||
lobbyChan chan SessionLobbyMessage
|
||||
lastSessionId uint32
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBGamePlace::AsyncDBGamePlace(unsigned queryId, const string &preparedName, const list<string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params)
|
||||
{
|
||||
}
|
||||
|
||||
func NewDispatcher(authChan chan SessionAuthMessage, lobbyChan chan SessionLobbyMessage) *Dispatcher {
|
||||
return &Dispatcher{make(chan SessionPokerTHMessage, RECV_DISPATCHER_NUM_PACKET_BUF), authChan, lobbyChan, 0}
|
||||
AsyncDBGamePlace::~AsyncDBGamePlace()
|
||||
{
|
||||
}
|
||||
|
||||
func (d *Dispatcher) GetReceiver() chan SessionPokerTHMessage {
|
||||
return d.receiver
|
||||
void
|
||||
AsyncDBGamePlace::Init(DBIdManager& idManager)
|
||||
{
|
||||
std::list<std::string> params;
|
||||
GetParams(params);
|
||||
ostringstream paramStream;
|
||||
paramStream << idManager.GetGameDBId(GetId());
|
||||
// Add game id as first parameter (according to the order in insert).
|
||||
params.push_front(paramStream.str());
|
||||
SetParams(params);
|
||||
}
|
||||
|
||||
func (d *Dispatcher) GetNextSessionId() uint32 {
|
||||
return atomic.AddUint32(&d.lastSessionId, 1)
|
||||
void
|
||||
AsyncDBGamePlace::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query does not produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
func (d *Dispatcher) Run() {
|
||||
var sessionMsg SessionPokerTHMessage
|
||||
for {
|
||||
select {
|
||||
case sessionMsg = <-d.receiver:
|
||||
log.Printf("Packet in dispatcher session %d type %d", sessionMsg.session.id, sessionMsg.packet.GetMessageType())
|
||||
switch sessionMsg.packet.GetMessageType() {
|
||||
case pokerth.PokerTHMessage_Type_AuthMessage:
|
||||
d.authChan <- SessionAuthMessage{sessionMsg.session, sessionMsg.packet.GetAuthMessage()}
|
||||
case pokerth.PokerTHMessage_Type_LobbyMessage:
|
||||
d.lobbyChan <- SessionLobbyMessage{sessionMsg.session, sessionMsg.packet.GetLobbyMessage()}
|
||||
default:
|
||||
log.Print("Unknown packet type")
|
||||
}
|
||||
}
|
||||
}
|
||||
void
|
||||
AsyncDBGamePlace::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
|
||||
{
|
||||
// No action required.
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBGamePlace::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::QueryError, &cb, "AsyncDBGamePlace: Failure."));
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database set place query. */
|
||||
|
||||
#ifndef _ASYNCDBGAMEPLACE_H_
|
||||
#define _ASYNCDBGAMEPLACE_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBGamePlace : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBGamePlace(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBGamePlace();
|
||||
|
||||
virtual void Init(DBIdManager& idManager);
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,65 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <dbofficial/asyncdblogin.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBLogin::AsyncDBLogin(unsigned queryId, const string &preparedName, const list<string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBLogin::~AsyncDBLogin()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBLogin::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query does not produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBLogin::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
|
||||
{
|
||||
// No action required.
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBLogin::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::QueryError, &cb, "AsyncDBLogin: Failure."));
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database login query. */
|
||||
|
||||
#ifndef _ASYNCDBLOGIN_H_
|
||||
#define _ASYNCDBLOGIN_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBLogin : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBLogin(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBLogin();
|
||||
|
||||
virtual void Init(DBIdManager& /*idManager*/) {}
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/asyncdbquery.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBQuery::~AsyncDBQuery()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database query. */
|
||||
|
||||
#ifndef _ASYNCDBQUERY_H_
|
||||
#define _ASYNCDBQUERY_H_
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <list>
|
||||
#include <mysql++.h>
|
||||
#include <db/serverdbcallback.h>
|
||||
|
||||
class DBIdManager;
|
||||
|
||||
class AsyncDBQuery
|
||||
{
|
||||
public:
|
||||
virtual ~AsyncDBQuery();
|
||||
|
||||
virtual void Init(DBIdManager& idManager) = 0;
|
||||
|
||||
virtual std::string GetPreparedName() const = 0;
|
||||
virtual void GetParams(std::list<std::string> ¶ms) const = 0;
|
||||
virtual void SetParams(const std::list<std::string> ¶ms) = 0;
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb) = 0;
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb) = 0;
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb) = 0;
|
||||
virtual bool RequiresResultSet() const = 0;
|
||||
virtual bool Next() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,65 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <dbofficial/asyncdbreportavatar.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBReportAvatar::AsyncDBReportAvatar(unsigned queryId, unsigned replyId, const string &preparedName, const list<string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params), m_replyId(replyId)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBReportAvatar::~AsyncDBReportAvatar()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBReportAvatar::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query does not produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBReportAvatar::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::ReportAvatarSuccess, &cb, GetId(), m_replyId));
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBReportAvatar::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::ReportAvatarFailed, &cb, GetId(), m_replyId));
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database report inappropriate avatar query. */
|
||||
|
||||
#ifndef _ASYNCDBREPORTAVATAR_H_
|
||||
#define _ASYNCDBREPORTAVATAR_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBReportAvatar : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBReportAvatar(unsigned queryId, unsigned replyId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBReportAvatar();
|
||||
|
||||
virtual void Init(DBIdManager& /*idManager*/) {}
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned m_replyId;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,83 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <dbofficial/asyncdbreportgame.h>
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBReportGame::AsyncDBReportGame(unsigned queryId, unsigned replyId, unsigned gameId, const string &preparedName, const list<string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params), m_replyId(replyId), m_gameId(gameId)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBReportGame::~AsyncDBReportGame()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBReportGame::Init(DBIdManager& idManager)
|
||||
{
|
||||
std::list<std::string> params;
|
||||
GetParams(params);
|
||||
ostringstream paramStream;
|
||||
unsigned tmpGameId = idManager.GetGameDBId(m_gameId);
|
||||
if (tmpGameId) {
|
||||
paramStream << idManager.GetGameDBId(m_gameId);
|
||||
// Add game id as last parameter (where-clause).
|
||||
params.push_back(paramStream.str());
|
||||
} else {
|
||||
params.push_back("NULL");
|
||||
}
|
||||
SetParams(params);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBReportGame::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query does not produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBReportGame::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::ReportGameSuccess, &cb, GetId(), m_replyId));
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBReportGame::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::ReportGameFailed, &cb, GetId(), m_replyId));
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database report inappropriate avatar query. */
|
||||
|
||||
#ifndef _ASYNCDBREPORTGAME_H_
|
||||
#define _ASYNCDBREPORTGAME_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBReportGame : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBReportGame(unsigned queryId, unsigned replyId, unsigned gameId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBReportGame();
|
||||
|
||||
virtual void Init(DBIdManager& idManager);
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned m_replyId;
|
||||
unsigned m_gameId;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,80 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/asyncdbupdatescore.h>
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBUpdateScore::AsyncDBUpdateScore(unsigned queryId, const string &preparedName, const std::list<std::string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBUpdateScore::~AsyncDBUpdateScore()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBUpdateScore::Init(DBIdManager& idManager)
|
||||
{
|
||||
std::list<std::string> params;
|
||||
GetParams(params);
|
||||
ostringstream paramStream;
|
||||
paramStream << idManager.GetGameDBId(GetId());
|
||||
// Add game id as first parameter (param for stored procedure).
|
||||
params.push_front(paramStream.str());
|
||||
SetParams(params);
|
||||
// Ensure that "update score" is only called once for a game.
|
||||
// This game id cannot be used any more, without re-init.
|
||||
idManager.RemoveGameId(GetId());
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBUpdateScore::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query does not produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBUpdateScore::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& idManager, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
|
||||
{
|
||||
idManager.RemoveGameId(GetId());
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBUpdateScore::HandleError(boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
|
||||
{
|
||||
// Ignore errors for now (as nothing important is done).
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database query to update the score. */
|
||||
|
||||
#ifndef _ASYNCDBUPDATESCORE_H_
|
||||
#define _ASYNCDBUPDATESCORE_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBUpdateScore : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBUpdateScore(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBUpdateScore();
|
||||
|
||||
virtual void Init(DBIdManager& idManager);
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,120 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/compositeasyncdbquery.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
CompositeAsyncDBQuery::CompositeAsyncDBQuery(const AsyncQueryList &queries)
|
||||
: m_list(queries), m_errorFlag(false), m_lastGameDBId(0)
|
||||
{
|
||||
m_currentQuery = m_list.begin();
|
||||
}
|
||||
|
||||
CompositeAsyncDBQuery::~CompositeAsyncDBQuery()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CompositeAsyncDBQuery::Init(DBIdManager& idManager)
|
||||
{
|
||||
(*m_currentQuery)->Init(idManager);
|
||||
}
|
||||
|
||||
std::string
|
||||
CompositeAsyncDBQuery::GetPreparedName() const
|
||||
{
|
||||
return (*m_currentQuery)->GetPreparedName();
|
||||
}
|
||||
|
||||
void
|
||||
CompositeAsyncDBQuery::GetParams(std::list<std::string> ¶ms) const
|
||||
{
|
||||
(*m_currentQuery)->GetParams(params);
|
||||
}
|
||||
|
||||
void
|
||||
CompositeAsyncDBQuery::SetParams(const std::list<std::string> ¶ms)
|
||||
{
|
||||
(*m_currentQuery)->SetParams(params);
|
||||
}
|
||||
|
||||
void
|
||||
CompositeAsyncDBQuery::HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
(*m_currentQuery)->HandleResult(query, idManager, result, service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
CompositeAsyncDBQuery::HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
(*m_currentQuery)->HandleNoResult(query, idManager, service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
CompositeAsyncDBQuery::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
(*m_currentQuery)->HandleError(service, cb);
|
||||
m_errorFlag = true;
|
||||
}
|
||||
|
||||
bool
|
||||
CompositeAsyncDBQuery::RequiresResultSet() const
|
||||
{
|
||||
return (*m_currentQuery)->RequiresResultSet();
|
||||
}
|
||||
|
||||
bool
|
||||
CompositeAsyncDBQuery::Next()
|
||||
{
|
||||
bool retVal = false;
|
||||
AsyncQueryList::iterator pos = m_currentQuery;
|
||||
++pos;
|
||||
if (!m_errorFlag && pos != m_list.end()) {
|
||||
m_currentQuery = pos;
|
||||
retVal = true;
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
unsigned
|
||||
CompositeAsyncDBQuery::GetLastGameDBId() const
|
||||
{
|
||||
return m_lastGameDBId;
|
||||
}
|
||||
|
||||
void
|
||||
CompositeAsyncDBQuery::SetLastGameDBId(unsigned id)
|
||||
{
|
||||
m_lastGameDBId = id;
|
||||
}
|
||||
+30
-33
@@ -1,6 +1,6 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* 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 *
|
||||
@@ -28,48 +28,45 @@
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* PokerTH network packet validation. */
|
||||
/* Composite async database query. */
|
||||
|
||||
#ifndef _POKERTHMESSAGEVALIDATOR_H_
|
||||
#define _POKERTHMESSAGEVALIDATOR_H_
|
||||
#ifndef _COMPOSITEASYNCDBQUERY_H_
|
||||
#define _COMPOSITEASYNCDBQUERY_H_
|
||||
|
||||
#include <map>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <dbofficial/asyncdbquery.h>
|
||||
#include <dbofficial/querycontext.h>
|
||||
|
||||
class PokerTHMessage;
|
||||
class AuthMessageValidator;
|
||||
class LobbyMessageValidator;
|
||||
class GameMessageValidator;
|
||||
|
||||
#define VALIDATE_IS_UINT16(__val) ((__val) <= 65535)
|
||||
#define VALIDATE_STRING_SIZE(__str, __minsize, __maxsize) ((__str).size() >= (__minsize) && (__str).size() <= (__maxsize))
|
||||
#define VALIDATE_UINT_RANGE(__val, __minval, __maxval) ((__val) >= (__minval) && (__val) <= (__maxval))
|
||||
#define VALIDATE_UINT_UPPER(__val, __maxval) ((__val) <= (__maxval))
|
||||
#define VALIDATE_LIST_SIZE(__l, __minsize, __maxsize) ((__l).size() >= (__minsize) && (__l).size() <= (__maxsize))
|
||||
|
||||
class PokerTHMessageValidator
|
||||
class CompositeAsyncDBQuery : public AsyncDBQuery, public QueryContext
|
||||
{
|
||||
public:
|
||||
PokerTHMessageValidator();
|
||||
typedef std::list<boost::shared_ptr<AsyncDBQuery> > AsyncQueryList;
|
||||
// Note: This list must contain at least one query.
|
||||
CompositeAsyncDBQuery(const AsyncQueryList &queries);
|
||||
virtual ~CompositeAsyncDBQuery();
|
||||
|
||||
bool IsValidMessage(const PokerTHMessage &msg) const;
|
||||
virtual void Init(DBIdManager& idManager);
|
||||
|
||||
protected:
|
||||
static bool ValidateAnnounceMessage(const PokerTHMessage &msg);
|
||||
bool ValidateAuthMessage(const PokerTHMessage &msg);
|
||||
bool ValidateLobbyMessage(const PokerTHMessage &msg);
|
||||
bool ValidateGameMessage(const PokerTHMessage &msg);
|
||||
virtual std::string GetPreparedName() const;
|
||||
virtual void GetParams(std::list<std::string> ¶ms) const;
|
||||
virtual void SetParams(const std::list<std::string> ¶ms);
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
// One error will cancel the rest of the composite query.
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const;
|
||||
virtual bool Next();
|
||||
|
||||
virtual unsigned GetLastGameDBId() const;
|
||||
virtual void SetLastGameDBId(unsigned id);
|
||||
|
||||
typedef boost::function<bool (const PokerTHMessage &)> ValidateFunctor;
|
||||
typedef std::map<int, ValidateFunctor> ValidateFunctorMap;
|
||||
private:
|
||||
|
||||
ValidateFunctorMap m_validationMap;
|
||||
boost::shared_ptr<AuthMessageValidator> m_authValidator;
|
||||
boost::shared_ptr<LobbyMessageValidator> m_lobbyValidator;
|
||||
boost::shared_ptr<GameMessageValidator> m_gameValidator;
|
||||
AsyncQueryList m_list;
|
||||
AsyncQueryList::iterator m_currentQuery;
|
||||
bool m_errorFlag;
|
||||
unsigned m_lastGameDBId;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* 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 *
|
||||
@@ -28,44 +28,51 @@
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* PokerTH game engine message validation. */
|
||||
|
||||
#ifndef _GAMEENGINEMESSAGEVALIDATOR_H_
|
||||
#define _GAMEENGINEMESSAGEVALIDATOR_H_
|
||||
#ifndef _DB_TABLE_DEFS_H_
|
||||
#define _DB_TABLE_DEFS_H_
|
||||
|
||||
#include <map>
|
||||
#include <boost/function.hpp>
|
||||
#define DB_TABLE_PLAYER "player"
|
||||
#define DB_TABLE_PLAYER_COL_ID "player_id"
|
||||
#define DB_TABLE_PLAYER_COL_USERNAME "username"
|
||||
#define DB_TABLE_PLAYER_COL_PASSWORD "password"
|
||||
#define DB_TABLE_PLAYER_COL_VALID "blocked"
|
||||
#define DB_TABLE_PLAYER_COL_COUNTRY "country_iso"
|
||||
#define DB_TABLE_PLAYER_COL_LASTLOGIN "last_login"
|
||||
#define DB_TABLE_PLAYER_COL_ACTIVE "active"
|
||||
#define DB_TABLE_PLAYER_COL_AVATARHASH "avatar_hash"
|
||||
#define DB_TABLE_PLAYER_COL_AVATARTYPE "avatar_mime"
|
||||
|
||||
class GameEngineMessage;
|
||||
#define DB_TABLE_GAME "game"
|
||||
#define DB_TABLE_GAME_COL_ID "idgame"
|
||||
#define DB_TABLE_GAME_COL_NAME "name"
|
||||
#define DB_TABLE_GAME_COL_STARTTIME "start_time"
|
||||
#define DB_TABLE_GAME_COL_ENDTIME "end_time"
|
||||
|
||||
class GameEngineMessageValidator
|
||||
{
|
||||
public:
|
||||
GameEngineMessageValidator();
|
||||
#define DB_TABLE_GAMEPLAYER "game_has_player"
|
||||
#define DB_TABLE_GAMEPLAYER_COL_GAMEID "game_idgame"
|
||||
#define DB_TABLE_GAMEPLAYER_COL_PLAYERID "player_idplayer"
|
||||
#define DB_TABLE_GAMEPLAYER_COL_PLACE "place"
|
||||
|
||||
bool IsValidMessage(const GameEngineMessage &msg) const;
|
||||
#define DB_TABLE_REP_AVATAR "reported_avatar"
|
||||
#define DB_TABLE_REP_AVATAR_COL_PLAYERID "idplayer"
|
||||
#define DB_TABLE_REP_AVATAR_COL_AVATARHASH "avatar_hash"
|
||||
#define DB_TABLE_REP_AVATAR_COL_AVATARTYPE "avatar_type"
|
||||
#define DB_TABLE_REP_AVATAR_COL_BY_PLAYERID "by_idplayer"
|
||||
#define DB_TABLE_REP_AVATAR_COL_TIMESTAMP "timestamp"
|
||||
|
||||
protected:
|
||||
static bool ValidateHandStartMessage(const GameEngineMessage &msg);
|
||||
static bool ValidatePlayersTurnMessage(const GameEngineMessage &msg);
|
||||
static bool ValidateMyActionRequestMessage(const GameEngineMessage &msg);
|
||||
static bool ValidateYourActionRejectedMessage(const GameEngineMessage &msg);
|
||||
static bool ValidatePlayersActionDoneMessage(const GameEngineMessage &msg);
|
||||
static bool ValidateDealFlopCardsMessage(const GameEngineMessage &msg);
|
||||
static bool ValidateDealTurnCardMessage(const GameEngineMessage &msg);
|
||||
static bool ValidateDealRiverCardMessage(const GameEngineMessage &msg);
|
||||
static bool ValidateAllInShowCardsMessage(const GameEngineMessage &msg);
|
||||
static bool ValidateEndOfHandShowCardsMessage(const GameEngineMessage &msg);
|
||||
static bool ValidateEndOfHandHideCardsMessage(const GameEngineMessage &msg);
|
||||
static bool ValidateShowMyCardsRequestMessage(const GameEngineMessage &msg);
|
||||
static bool ValidateAfterHandShowCardsMessage(const GameEngineMessage &msg);
|
||||
#define DB_TABLE_REP_GAME "reported_gamename"
|
||||
#define DB_TABLE_REP_GAME_COL_CREATOR "game_creator_idplayer"
|
||||
#define DB_TABLE_REP_GAME_COL_GAMEID "game_idgame"
|
||||
#define DB_TABLE_REP_GAME_COL_GAMENAME "game_name"
|
||||
#define DB_TABLE_REP_GAME_COL_BY_PLAYERID "by_idplayer"
|
||||
#define DB_TABLE_REP_GAME_COL_TIMESTAMP "timestamp"
|
||||
|
||||
typedef boost::function<bool (const GameEngineMessage &)> ValidateFunctor;
|
||||
typedef std::map<int, ValidateFunctor> ValidateFunctorMap;
|
||||
private:
|
||||
#define DB_TABLE_AVATAR_BLACKLIST "avatar_blacklist"
|
||||
#define DB_TABLE_AVATAR_BLACKLIST_COL_ID "id"
|
||||
#define DB_TABLE_AVATAR_BLACKLIST_COL_AVATAR_HASH "avatar_hash"
|
||||
|
||||
ValidateFunctorMap m_validationMap;
|
||||
};
|
||||
|
||||
#endif
|
||||
#define DB_TABLE_ADMIN_PLAYER "admin_player"
|
||||
#define DB_TABLE_ADMIN_PLAYER_COL_PLAYERID "admin_idplayer"
|
||||
|
||||
#endif // DB_TABLE_DEFS_H
|
||||
@@ -1,6 +1,6 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* 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 *
|
||||
@@ -28,31 +28,34 @@
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* PokerTH network packet validation helpers. */
|
||||
|
||||
#ifndef _VALIDATIONHELPER_H_
|
||||
#define _VALIDATIONHELPER_H_
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
|
||||
#include <net/netpacket.h>
|
||||
|
||||
#define VALIDATE_IS_UINT16(__val) ((__val) <= 65535)
|
||||
#define VALIDATE_STRING_SIZE(__str, __minsize, __maxsize) ((__str).size() >= (__minsize) && (__str).size() <= (__maxsize))
|
||||
#define VALIDATE_UINT_RANGE(__val, __minval, __maxval) ((__val) >= (__minval) && (__val) <= (__maxval))
|
||||
#define VALIDATE_UINT_UPPER(__val, __maxval) ((__val) <= (__maxval))
|
||||
#define VALIDATE_LIST_SIZE(__l, __minsize, __maxsize) ((__l).size() >= (__minsize) && (__l).size() <= (__maxsize))
|
||||
|
||||
inline bool
|
||||
ValidateListIntRange(const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > &l, ::google::protobuf::uint32 minval, ::google::protobuf::uint32 maxval)
|
||||
void
|
||||
DBIdManager::AddGameId(unsigned gameId, DB_id databaseId)
|
||||
{
|
||||
bool retVal = true;
|
||||
for (int i = 0; i < l.size(); i++) {
|
||||
if (!VALIDATE_UINT_RANGE(l.Get(i), minval, maxval)) {
|
||||
retVal = false;
|
||||
break;
|
||||
}
|
||||
boost::mutex::scoped_lock lock(m_gameIdMapMutex);
|
||||
m_gameIdMap[gameId] = databaseId;
|
||||
}
|
||||
|
||||
void
|
||||
DBIdManager::RemoveGameId(unsigned gameId)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_gameIdMapMutex);
|
||||
m_gameIdMap.erase(gameId);
|
||||
}
|
||||
|
||||
DB_id
|
||||
DBIdManager::GetGameDBId(unsigned gameId) const
|
||||
{
|
||||
DB_id retVal = DB_ID_INVALID;
|
||||
|
||||
boost::mutex::scoped_lock lock(m_gameIdMapMutex);
|
||||
DBMap::const_iterator pos = m_gameIdMap.find(gameId);
|
||||
if (pos != m_gameIdMap.end()) {
|
||||
retVal = pos->second;
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* 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 *
|
||||
@@ -28,35 +28,29 @@
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* PokerTH authentication message validation. */
|
||||
/* Manager for database internal ids */
|
||||
|
||||
#ifndef _AUTHMESSAGEVALIDATOR_H_
|
||||
#define _AUTHMESSAGEVALIDATOR_H_
|
||||
#ifndef _DBIDMANAGER_H_
|
||||
#define _DBIDMANAGER_H_
|
||||
|
||||
#include <db/dbdefs.h>
|
||||
#include <boost/thread.hpp>
|
||||
#include <map>
|
||||
#include <boost/function.hpp>
|
||||
|
||||
class AuthMessage;
|
||||
|
||||
class AuthMessageValidator
|
||||
class DBIdManager
|
||||
{
|
||||
public:
|
||||
AuthMessageValidator();
|
||||
void AddGameId(unsigned gameId, DB_id databaseId);
|
||||
void RemoveGameId(unsigned gameId);
|
||||
|
||||
bool IsValidMessage(const AuthMessage &msg) const;
|
||||
DB_id GetGameDBId(unsigned gameId) const;
|
||||
|
||||
protected:
|
||||
static bool ValidateAuthClientRequestMessage(const AuthMessage &msg);
|
||||
static bool ValidateAuthServerChallengeMessage(const AuthMessage &msg);
|
||||
static bool ValidateAuthClientResponseMessage(const AuthMessage &msg);
|
||||
static bool ValidateAuthServerVerificationMessage(const AuthMessage &msg);
|
||||
typedef std::map<unsigned, DB_id> DBMap;
|
||||
|
||||
typedef boost::function<bool (const AuthMessage &)> ValidateFunctor;
|
||||
typedef std::map<int, ValidateFunctor> ValidateFunctorMap;
|
||||
private:
|
||||
|
||||
ValidateFunctorMap m_validationMap;
|
||||
DBMap m_gameIdMap;
|
||||
mutable boost::mutex m_gameIdMapMutex;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // _DBIDMANAGER_H_
|
||||
@@ -0,0 +1,36 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/querycontext.h>
|
||||
|
||||
QueryContext::~QueryContext()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Interface for a query context */
|
||||
|
||||
#ifndef _QUERYCONTEXT_H_
|
||||
#define _QUERYCONTEXT_H_
|
||||
|
||||
class QueryContext
|
||||
{
|
||||
public:
|
||||
virtual ~QueryContext();
|
||||
|
||||
virtual unsigned GetLastGameDBId() const = 0;
|
||||
virtual void SetLastGameDBId(unsigned id) = 0;
|
||||
};
|
||||
|
||||
#endif // QUERYCONTEXT_H
|
||||
@@ -0,0 +1,48 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/serverdbfactoryinternal.h>
|
||||
#include <dbofficial/serverdbthread.h>
|
||||
|
||||
|
||||
ServerDBFactoryInternal::ServerDBFactoryInternal()
|
||||
{
|
||||
}
|
||||
|
||||
ServerDBFactoryInternal::~ServerDBFactoryInternal()
|
||||
{
|
||||
}
|
||||
|
||||
boost::shared_ptr<ServerDBInterface>
|
||||
ServerDBFactoryInternal::CreateServerDBObject(ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService)
|
||||
{
|
||||
return boost::shared_ptr<ServerDBInterface>(new ServerDBThread(cb, ioService));
|
||||
}
|
||||
+14
-26
@@ -1,6 +1,6 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* 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 *
|
||||
@@ -28,38 +28,26 @@
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* PokerTH game message validation. */
|
||||
/* Server database factory for closed source db objects. */
|
||||
|
||||
#ifndef _GAMEMESSAGEVALIDATOR_H_
|
||||
#define _GAMEMESSAGEVALIDATOR_H_
|
||||
#ifndef _SERVERDBFACTORYINTERNAL_H_
|
||||
#define _SERVERDBFACTORYINTERNAL_H_
|
||||
|
||||
#include <map>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <db/serverdbinterface.h>
|
||||
#include <db/serverdbcallback.h>
|
||||
|
||||
class GameMessage;
|
||||
class GameManagementMessageValidator;
|
||||
class GameEngineMessageValidator;
|
||||
|
||||
class GameMessageValidator
|
||||
class ServerDBFactoryInternal
|
||||
{
|
||||
public:
|
||||
GameMessageValidator();
|
||||
ServerDBFactoryInternal();
|
||||
virtual ~ServerDBFactoryInternal();
|
||||
|
||||
bool IsValidMessage(const GameMessage &msg) const;
|
||||
|
||||
protected:
|
||||
bool ValidateGameManagementMessage(const GameMessage &msg);
|
||||
bool ValidateGameEngineMessage(const GameMessage &msg);
|
||||
|
||||
typedef boost::function<bool (const GameMessage &)> ValidateFunctor;
|
||||
typedef std::map<int, ValidateFunctor> ValidateFunctorMap;
|
||||
private:
|
||||
|
||||
ValidateFunctorMap m_validationMap;
|
||||
boost::shared_ptr<GameManagementMessageValidator> m_managementValidator;
|
||||
boost::shared_ptr<GameEngineMessageValidator> m_engineValidator;
|
||||
virtual boost::shared_ptr<ServerDBInterface> CreateServerDBObject(
|
||||
ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService);
|
||||
};
|
||||
|
||||
#endif
|
||||
typedef ServerDBFactoryInternal DBFactory;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,568 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/serverdbthread.h>
|
||||
#include <dbofficial/asyncdbauth.h>
|
||||
#include <dbofficial/asyncdblogin.h>
|
||||
#include <dbofficial/asyncdbavatarblacklist.h>
|
||||
#include <dbofficial/asyncdbcreategame.h>
|
||||
#include <dbofficial/asyncdbendgame.h>
|
||||
#include <dbofficial/asyncdbgameplace.h>
|
||||
#include <dbofficial/asyncdbupdatescore.h>
|
||||
#include <dbofficial/asyncdbreportavatar.h>
|
||||
#include <dbofficial/asyncdbreportgame.h>
|
||||
#include <dbofficial/asyncdbadminplayers.h>
|
||||
#include <dbofficial/asyncdbblockplayer.h>
|
||||
#include <dbofficial/compositeasyncdbquery.h>
|
||||
#include <dbofficial/db_table_defs.h>
|
||||
#include <ctime>
|
||||
#include <sstream>
|
||||
#include <mysql++.h>
|
||||
|
||||
#define QUERY_NICK_PREPARE "nick_template"
|
||||
#define QUERY_LOGIN_PREPARE "login_template"
|
||||
#define QUERY_AVATAR_BLACKLIST_PREPARE "avatar_blacklist_template"
|
||||
#define QUERY_CREATE_GAME_PREPARE "create_game_template"
|
||||
#define QUERY_END_GAME_PREPARE "end_game_template"
|
||||
#define QUERY_GAME_PLAYER_PREPARE "game_player_template"
|
||||
#define QUERY_UPDATE_SCORE_PREPARE "update_score_template"
|
||||
#define QUERY_REPORT_AVATAR_PREPARE "report_avatar_template"
|
||||
#define QUERY_REPORT_GAME_PREPARE "report_game_template"
|
||||
#define QUERY_ADMIN_PLAYER_PREPARE "admin_player_template"
|
||||
#define QUERY_BLOCK_PLAYER_PREPARE "block_player_template"
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct DBConnectionData {
|
||||
DBConnectionData() : conn(false) {}
|
||||
string host;
|
||||
string user;
|
||||
string pwd;
|
||||
string database;
|
||||
string encryptionKey;
|
||||
mysqlpp::Connection conn;
|
||||
};
|
||||
|
||||
ServerDBThread::ServerDBThread(ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService)
|
||||
: m_ioService(ioService), m_semaphore(0), m_callback(cb), m_isConnected(false), m_permanentError(false), m_previouslyConnected(false)
|
||||
{
|
||||
m_connData.reset(new DBConnectionData);
|
||||
}
|
||||
|
||||
ServerDBThread::~ServerDBThread()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::SignalTermination()
|
||||
{
|
||||
Thread::SignalTermination();
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::Init(const string &host, const string &user, const string &pwd,
|
||||
const string &database, const string &encryptionKey)
|
||||
{
|
||||
m_connData->host = host;
|
||||
m_connData->user = user;
|
||||
m_connData->pwd = pwd;
|
||||
m_connData->database = database;
|
||||
m_connData->encryptionKey = encryptionKey;
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::Start()
|
||||
{
|
||||
Run();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::Stop()
|
||||
{
|
||||
SignalTermination();
|
||||
this->Join(THREAD_WAIT_INFINITE);
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::AsyncPlayerLogin(unsigned requestId, const string &playerName)
|
||||
{
|
||||
if (IsConnected()) {
|
||||
list<string> params;
|
||||
params.push_back(m_connData->encryptionKey);
|
||||
params.push_back(playerName);
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBAuth(
|
||||
requestId,
|
||||
QUERY_NICK_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
} else {
|
||||
// If not connected to database, login fails.
|
||||
m_ioService->post(boost::bind(&ServerDBCallback::PlayerLoginFailed, &m_callback, requestId));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::AsyncCheckAvatarBlacklist(unsigned requestId, const std::string &avatarHash)
|
||||
{
|
||||
if (IsConnected()) {
|
||||
list<string> params;
|
||||
params.push_back(avatarHash);
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBAvatarBlacklist(
|
||||
requestId,
|
||||
QUERY_AVATAR_BLACKLIST_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
} else {
|
||||
// If not connected to database, all avatars are blacklisted.
|
||||
m_ioService->post(boost::bind(&ServerDBCallback::AvatarIsBlacklisted, &m_callback, requestId));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::PlayerPostLogin(DB_id playerId, const std::string &avatarHash, const std::string &avatarType)
|
||||
{
|
||||
list<string> params;
|
||||
params.push_back(mysqlpp::DateTime(time(NULL)));
|
||||
params.push_back(avatarHash);
|
||||
params.push_back(avatarType);
|
||||
ostringstream paramStream;
|
||||
paramStream << playerId;
|
||||
params.push_back(paramStream.str());
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBLogin(
|
||||
playerId,
|
||||
QUERY_LOGIN_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::PlayerLogout(DB_id /*playerId*/)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::AsyncCreateGame(unsigned requestId, const string &gameName)
|
||||
{
|
||||
list<string> params;
|
||||
params.push_back(gameName);
|
||||
params.push_back(mysqlpp::DateTime(time(NULL)));
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBCreateGame(
|
||||
requestId,
|
||||
QUERY_CREATE_GAME_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place)
|
||||
{
|
||||
// The game id param is added later (during init of the async op), because it may be unknown.
|
||||
list<string> params;
|
||||
ostringstream paramStream;
|
||||
paramStream << playerId;
|
||||
params.push_back(paramStream.str());
|
||||
paramStream.str("");
|
||||
paramStream << place;
|
||||
params.push_back(paramStream.str());
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBGamePlace(
|
||||
requestId,
|
||||
QUERY_GAME_PLAYER_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::EndGame(unsigned requestId)
|
||||
{
|
||||
// Set the end time of the game.
|
||||
{
|
||||
list<string> params;
|
||||
params.push_back(mysqlpp::DateTime(time(NULL)));
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBEndGame(
|
||||
requestId,
|
||||
QUERY_END_GAME_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
}
|
||||
// Update the player scores.
|
||||
{
|
||||
list<string> params;
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBUpdateScore(
|
||||
requestId,
|
||||
QUERY_UPDATE_SCORE_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId)
|
||||
{
|
||||
list<string> params;
|
||||
ostringstream paramStream;
|
||||
paramStream << reportedPlayerId;
|
||||
params.push_back(paramStream.str());
|
||||
params.push_back(avatarHash);
|
||||
params.push_back(avatarType);
|
||||
if (byPlayerId) {
|
||||
paramStream.str("");
|
||||
paramStream << *byPlayerId;
|
||||
params.push_back(paramStream.str());
|
||||
} else {
|
||||
params.push_back("NULL");
|
||||
}
|
||||
params.push_back(mysqlpp::DateTime(time(NULL)));
|
||||
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBReportAvatar(
|
||||
requestId,
|
||||
replyId,
|
||||
QUERY_REPORT_AVATAR_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::AsyncReportGame(unsigned requestId, unsigned replyId, DB_id *creatorPlayerId, unsigned gameId, const std::string &gameName, DB_id *byPlayerId)
|
||||
{
|
||||
list<string> params;
|
||||
ostringstream paramStream;
|
||||
if (creatorPlayerId) {
|
||||
paramStream << *creatorPlayerId;
|
||||
params.push_back(paramStream.str());
|
||||
} else {
|
||||
params.push_back("NULL");
|
||||
}
|
||||
params.push_back(gameName);
|
||||
if (byPlayerId) {
|
||||
paramStream.str("");
|
||||
paramStream << *byPlayerId;
|
||||
params.push_back(paramStream.str());
|
||||
} else {
|
||||
params.push_back("NULL");
|
||||
}
|
||||
params.push_back(mysqlpp::DateTime(time(NULL)));
|
||||
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBReportGame(
|
||||
requestId,
|
||||
replyId,
|
||||
gameId,
|
||||
QUERY_REPORT_GAME_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::AsyncQueryAdminPlayers(unsigned requestId)
|
||||
{
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBAdminPlayers(
|
||||
requestId,
|
||||
QUERY_ADMIN_PLAYER_PREPARE));
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::AsyncBlockPlayer(unsigned requestId, unsigned replyId, DB_id playerId, int valid, int active)
|
||||
{
|
||||
list<string> params;
|
||||
ostringstream paramStream;
|
||||
paramStream << valid;
|
||||
params.push_back(paramStream.str());
|
||||
paramStream.str("");
|
||||
paramStream << active;
|
||||
params.push_back(paramStream.str());
|
||||
paramStream.str("");
|
||||
paramStream << playerId;
|
||||
params.push_back(paramStream.str());
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBBlockPlayer(
|
||||
requestId,
|
||||
replyId,
|
||||
QUERY_BLOCK_PLAYER_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
bool
|
||||
ServerDBThread::IsConnected() const
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_isConnectedMutex);
|
||||
return m_isConnected;
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::Main()
|
||||
{
|
||||
while (!ShouldTerminate() && !HasPermanentError()) {
|
||||
if (HasDBConnection()) {
|
||||
SetConnected(true);
|
||||
m_semaphore.wait();
|
||||
HandleNextQuery();
|
||||
} else {
|
||||
SetConnected(false);
|
||||
EstablishDBConnection();
|
||||
}
|
||||
}
|
||||
m_connData->conn.disconnect();
|
||||
}
|
||||
|
||||
bool
|
||||
ServerDBThread::HasPermanentError() const
|
||||
{
|
||||
return m_permanentError;
|
||||
}
|
||||
|
||||
bool
|
||||
ServerDBThread::HasDBConnection() const
|
||||
{
|
||||
return m_connData->conn.connected();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::EstablishDBConnection()
|
||||
{
|
||||
m_connData->conn.set_option(new mysqlpp::SetCharsetNameOption("utf8"));
|
||||
if (!m_connData->conn.connect(
|
||||
m_connData->database.c_str(), m_connData->host.c_str(), m_connData->user.c_str(), m_connData->pwd.c_str())) {
|
||||
m_ioService->post(boost::bind(&ServerDBCallback::ConnectFailed, &m_callback, m_connData->conn.error()));
|
||||
if (!m_previouslyConnected)
|
||||
m_permanentError = true;
|
||||
else
|
||||
Msleep(250);
|
||||
} else {
|
||||
mysqlpp::Query prepareNick = m_connData->conn.query();
|
||||
/*
|
||||
prepareNick
|
||||
<< "PREPARE " QUERY_NICK_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "SELECT " DB_TABLE_PLAYER_COL_ID ", AES_DECRYPT(" DB_TABLE_PLAYER_COL_PASSWORD ", ?), " DB_TABLE_PLAYER_COL_VALID ", TRIM(" DB_TABLE_PLAYER_COL_COUNTRY "), " DB_TABLE_PLAYER_COL_LASTLOGIN ", " DB_TABLE_PLAYER_COL_ACTIVE " FROM " DB_TABLE_PLAYER " WHERE BINARY " DB_TABLE_PLAYER_COL_USERNAME " = ?";
|
||||
*/
|
||||
prepareNick
|
||||
<< "PREPARE " QUERY_NICK_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "SELECT " DB_TABLE_PLAYER_COL_ID ", AES_DECRYPT(" DB_TABLE_PLAYER_COL_PASSWORD ", ?), " DB_TABLE_PLAYER_COL_VALID ", TRIM(" DB_TABLE_PLAYER_COL_COUNTRY "), " DB_TABLE_PLAYER_COL_LASTLOGIN ", " DB_TABLE_PLAYER_COL_ACTIVE " FROM " DB_TABLE_PLAYER " WHERE " DB_TABLE_PLAYER_COL_USERNAME " = ?";
|
||||
|
||||
mysqlpp::Query prepareAvatarBlacklist = m_connData->conn.query();
|
||||
prepareAvatarBlacklist
|
||||
<< "PREPARE " QUERY_AVATAR_BLACKLIST_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "SELECT " DB_TABLE_AVATAR_BLACKLIST_COL_ID " FROM " DB_TABLE_AVATAR_BLACKLIST " WHERE BINARY " DB_TABLE_AVATAR_BLACKLIST_COL_AVATAR_HASH " = ?";
|
||||
|
||||
mysqlpp::Query prepareLogin = m_connData->conn.query();
|
||||
prepareLogin
|
||||
<< "PREPARE " QUERY_LOGIN_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "UPDATE " DB_TABLE_PLAYER " SET " DB_TABLE_PLAYER_COL_LASTLOGIN " = ?, " DB_TABLE_PLAYER_COL_AVATARHASH " = ?, " DB_TABLE_PLAYER_COL_AVATARTYPE " = ? WHERE " DB_TABLE_PLAYER_COL_ID " = ?";
|
||||
mysqlpp::Query prepareCreateGame = m_connData->conn.query();
|
||||
prepareCreateGame
|
||||
<< "PREPARE " QUERY_CREATE_GAME_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "INSERT INTO " DB_TABLE_GAME " (" DB_TABLE_GAME_COL_NAME ", " DB_TABLE_GAME_COL_STARTTIME ") VALUES (?, ?)";
|
||||
mysqlpp::Query prepareEndGame = m_connData->conn.query();
|
||||
prepareEndGame
|
||||
<< "PREPARE " QUERY_END_GAME_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "UPDATE " DB_TABLE_GAME " SET "DB_TABLE_GAME_COL_ENDTIME " = ? WHERE " DB_TABLE_GAME_COL_ID " = ?";
|
||||
mysqlpp::Query prepareRelation = m_connData->conn.query();
|
||||
prepareRelation
|
||||
<< "PREPARE " QUERY_GAME_PLAYER_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "INSERT INTO " DB_TABLE_GAMEPLAYER " (" DB_TABLE_GAMEPLAYER_COL_GAMEID ", " DB_TABLE_GAMEPLAYER_COL_PLAYERID ", " DB_TABLE_GAMEPLAYER_COL_PLACE ") VALUES (?, ?, ?)";
|
||||
mysqlpp::Query prepareScore = m_connData->conn.query();
|
||||
prepareScore
|
||||
<< "PREPARE " QUERY_UPDATE_SCORE_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "CALL updatePointsForGame(?)";
|
||||
|
||||
mysqlpp::Query prepareReportAvatar = m_connData->conn.query();
|
||||
prepareReportAvatar
|
||||
<< "PREPARE " QUERY_REPORT_AVATAR_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "INSERT INTO " DB_TABLE_REP_AVATAR " (" DB_TABLE_REP_AVATAR_COL_PLAYERID ", " DB_TABLE_REP_AVATAR_COL_AVATARHASH ", " DB_TABLE_REP_AVATAR_COL_AVATARTYPE ", " DB_TABLE_REP_AVATAR_COL_BY_PLAYERID ", " DB_TABLE_REP_AVATAR_COL_TIMESTAMP ") VALUES (?, ?, ?, ?, ?)";
|
||||
|
||||
mysqlpp::Query prepareReportGame = m_connData->conn.query();
|
||||
prepareReportGame
|
||||
<< "PREPARE " QUERY_REPORT_GAME_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "INSERT INTO " DB_TABLE_REP_GAME " (" DB_TABLE_REP_GAME_COL_CREATOR ", " DB_TABLE_REP_GAME_COL_GAMENAME ", " DB_TABLE_REP_GAME_COL_BY_PLAYERID ", " DB_TABLE_REP_GAME_COL_TIMESTAMP ", " DB_TABLE_REP_GAME_COL_GAMEID ") VALUES (?, ?, ?, ?, ?)";
|
||||
|
||||
mysqlpp::Query prepareAdminPlayer = m_connData->conn.query();
|
||||
prepareAdminPlayer
|
||||
<< "PREPARE " QUERY_ADMIN_PLAYER_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "SELECT " DB_TABLE_ADMIN_PLAYER_COL_PLAYERID " FROM " DB_TABLE_ADMIN_PLAYER;
|
||||
|
||||
mysqlpp::Query prepareBlockPlayer = m_connData->conn.query();
|
||||
prepareBlockPlayer
|
||||
<< "PREPARE " QUERY_BLOCK_PLAYER_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "UPDATE " DB_TABLE_PLAYER " SET " DB_TABLE_PLAYER_COL_VALID " = ?, " DB_TABLE_PLAYER_COL_ACTIVE " = ? WHERE " DB_TABLE_PLAYER_COL_ID " = ?";
|
||||
if (!prepareNick.exec() || !prepareAvatarBlacklist.exec() || !prepareLogin.exec() || !prepareCreateGame.exec()
|
||||
|| !prepareEndGame.exec() || !prepareRelation.exec() || !prepareScore.exec() || !prepareReportAvatar.exec()
|
||||
|| !prepareReportGame.exec() || !prepareAdminPlayer.exec() || !prepareBlockPlayer.exec()) {
|
||||
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();
|
||||
m_connData->conn.disconnect();
|
||||
m_ioService->post(boost::bind(&ServerDBCallback::ConnectFailed, &m_callback, tmpError));
|
||||
m_permanentError = true;
|
||||
} else {
|
||||
m_ioService->post(boost::bind(&ServerDBCallback::ConnectSuccess, &m_callback));
|
||||
m_previouslyConnected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::HandleNextQuery()
|
||||
{
|
||||
boost::shared_ptr<AsyncDBQuery> nextQuery;
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
if (!m_asyncQueue.empty()) {
|
||||
nextQuery = m_asyncQueue.front();
|
||||
m_asyncQueue.pop();
|
||||
}
|
||||
}
|
||||
if (nextQuery) {
|
||||
do {
|
||||
nextQuery->Init(m_dbIdManager);
|
||||
mysqlpp::Query executeQuery = m_connData->conn.query();
|
||||
executeQuery << "EXECUTE " << nextQuery->GetPreparedName();
|
||||
|
||||
list<string> paramList;
|
||||
nextQuery->GetParams(paramList);
|
||||
if (!paramList.empty()) {
|
||||
executeQuery << " using ";
|
||||
mysqlpp::Query paramQuery = m_connData->conn.query();
|
||||
paramQuery << "SET ";
|
||||
unsigned counter = 1;
|
||||
list<string>::iterator i = paramList.begin();
|
||||
list<string>::iterator end = paramList.end();
|
||||
while (i != end) {
|
||||
if (counter > 1) {
|
||||
paramQuery << ", ";
|
||||
executeQuery << ", ";
|
||||
}
|
||||
paramQuery << "@param" << counter << " = ";
|
||||
if (*i == "NULL") {
|
||||
paramQuery << "NULL";
|
||||
} else {
|
||||
paramQuery << "_utf8" << mysqlpp::quote << *i;
|
||||
}
|
||||
executeQuery << "@param" << counter;
|
||||
++counter;
|
||||
++i;
|
||||
}
|
||||
if (!paramQuery.exec()) {
|
||||
string tmpError = paramQuery.error();
|
||||
m_connData->conn.disconnect();
|
||||
m_ioService->post(boost::bind(&ServerDBCallback::QueryError, &m_callback, tmpError));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nextQuery->RequiresResultSet()) {
|
||||
mysqlpp::StoreQueryResult res = executeQuery.store();
|
||||
if (res)
|
||||
nextQuery->HandleResult(executeQuery, m_dbIdManager, res, *m_ioService, m_callback);
|
||||
else
|
||||
nextQuery->HandleError(*m_ioService, m_callback);
|
||||
} else {
|
||||
if (executeQuery.exec())
|
||||
nextQuery->HandleNoResult(executeQuery, m_dbIdManager, *m_ioService, m_callback);
|
||||
else
|
||||
nextQuery->HandleError(*m_ioService, m_callback);
|
||||
}
|
||||
} while (nextQuery->Next()); // Consider composite queries.
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::SetConnected(bool isConnected)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_isConnectedMutex);
|
||||
m_isConnected = isConnected;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Server database thread. */
|
||||
|
||||
#ifndef _SERVERDBTHREAD_H_
|
||||
#define _SERVERDBTHREAD_H_
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/interprocess/sync/interprocess_semaphore.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <queue>
|
||||
#include <db/serverdbinterface.h>
|
||||
#include <db/serverdbcallback.h>
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
#include <core/thread.h>
|
||||
|
||||
struct DBConnectionData;
|
||||
class AsyncDBQuery;
|
||||
|
||||
class ServerDBThread : public ServerDBInterface, public Thread, public boost::enable_shared_from_this<ServerDBThread>
|
||||
{
|
||||
public:
|
||||
ServerDBThread(ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService);
|
||||
virtual ~ServerDBThread();
|
||||
|
||||
virtual void SignalTermination();
|
||||
|
||||
virtual void Init(const std::string &host, const std::string &user, const std::string &pwd,
|
||||
const std::string &database, const std::string &encryptionKey);
|
||||
|
||||
virtual void Start();
|
||||
virtual void Stop();
|
||||
|
||||
virtual void AsyncPlayerLogin(unsigned requestId, const std::string &playerName);
|
||||
virtual void AsyncCheckAvatarBlacklist(unsigned requestId, const std::string &avatarHash);
|
||||
virtual void PlayerPostLogin(DB_id playerId, const std::string &avatarHash, const std::string &avatarType);
|
||||
virtual void PlayerLogout(DB_id playerId);
|
||||
|
||||
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName);
|
||||
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place);
|
||||
virtual void EndGame(unsigned requestId);
|
||||
|
||||
virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId);
|
||||
virtual void AsyncReportGame(unsigned requestId, unsigned replyId, DB_id *creatorPlayerId, unsigned gameId, const std::string &gameName, DB_id *byPlayerId);
|
||||
|
||||
virtual void AsyncQueryAdminPlayers(unsigned requestId);
|
||||
virtual void AsyncBlockPlayer(unsigned requestId, unsigned replyId, DB_id playerId, int valid, int active);
|
||||
|
||||
bool IsConnected() const;
|
||||
|
||||
protected:
|
||||
typedef std::queue<boost::shared_ptr<AsyncDBQuery> > AsyncDBQueryQueue;
|
||||
|
||||
// Main function of the thread.
|
||||
virtual void Main();
|
||||
|
||||
bool HasPermanentError() const;
|
||||
bool HasDBConnection() const;
|
||||
void EstablishDBConnection();
|
||||
void HandleNextQuery();
|
||||
|
||||
void SetConnected(bool isConnected);
|
||||
private:
|
||||
|
||||
boost::shared_ptr<boost::asio::io_service> m_ioService;
|
||||
boost::interprocess::interprocess_semaphore m_semaphore;
|
||||
ServerDBCallback &m_callback;
|
||||
boost::shared_ptr<DBConnectionData> m_connData;
|
||||
mutable boost::mutex m_asyncQueueMutex;
|
||||
AsyncDBQueryQueue m_asyncQueue;
|
||||
DBIdManager m_dbIdManager;
|
||||
|
||||
mutable boost::mutex m_isConnectedMutex;
|
||||
bool m_isConnected;
|
||||
bool m_permanentError;
|
||||
bool m_previouslyConnected;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
SingleAsyncDBQuery::SingleAsyncDBQuery(unsigned queryId, const string &preparedName, const list<string> ¶ms)
|
||||
: m_id(queryId), m_preparedName(preparedName), m_params(params)
|
||||
{
|
||||
}
|
||||
|
||||
SingleAsyncDBQuery::~SingleAsyncDBQuery()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned
|
||||
SingleAsyncDBQuery::GetId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
std::string
|
||||
SingleAsyncDBQuery::GetPreparedName() const
|
||||
{
|
||||
return m_preparedName;
|
||||
}
|
||||
|
||||
void
|
||||
SingleAsyncDBQuery::GetParams(std::list<std::string> ¶ms) const
|
||||
{
|
||||
params = m_params;
|
||||
}
|
||||
|
||||
void
|
||||
SingleAsyncDBQuery::SetParams(const std::list<std::string> ¶ms)
|
||||
{
|
||||
m_params = params;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Single (non-composite) async database query. */
|
||||
|
||||
#ifndef _SINGLEASYNCDBQUERY_H_
|
||||
#define _SINGLEASYNCDBQUERY_H_
|
||||
|
||||
#include <dbofficial/asyncdbquery.h>
|
||||
|
||||
class SingleAsyncDBQuery : public AsyncDBQuery
|
||||
{
|
||||
public:
|
||||
SingleAsyncDBQuery(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~SingleAsyncDBQuery();
|
||||
|
||||
unsigned GetId() const;
|
||||
virtual std::string GetPreparedName() const;
|
||||
virtual void GetParams(std::list<std::string> ¶ms) const;
|
||||
virtual void SetParams(const std::list<std::string> ¶ms);
|
||||
|
||||
virtual bool Next()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
const unsigned m_id;
|
||||
std::string m_preparedName;
|
||||
std::list<std::string> m_params;
|
||||
};
|
||||
|
||||
#endif
|
||||
+5
-7
@@ -56,10 +56,10 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||
|
||||
dealerPosition = startData.startDealerPlayerId;
|
||||
|
||||
// debug mode
|
||||
if(myLog) {
|
||||
myLog->debugMode_getStartSmallBlind(&startSmallBlind,¤tSmallBlind);
|
||||
myLog->debugMode_getStartDealerPosition(&dealerPosition);
|
||||
if(DEBUG_MODE) {
|
||||
startSmallBlind = 10;
|
||||
currentSmallBlind = startSmallBlind;
|
||||
dealerPosition = 4;
|
||||
}
|
||||
|
||||
int i;
|
||||
@@ -109,9 +109,6 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||
++player_i;
|
||||
}
|
||||
|
||||
// debug mode
|
||||
if(myLog) myLog->debugMode_getPlayerStartCash(&myStartCash, i);
|
||||
|
||||
// create player objects
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer = myFactory->createPlayer(i, uniqueId, type, myName, myAvatarFile, myStartCash, startQuantityPlayers > i, myStayOnTableStatus, 0);
|
||||
tmpPlayer->setIsSessionActive(true);
|
||||
@@ -215,6 +212,7 @@ void Game::startHand()
|
||||
|
||||
// log new hand
|
||||
myGui->logNewGameHandMsg(myGameID, currentHandID);
|
||||
myGui->flushLogAtGame(myGameID);
|
||||
|
||||
currentHand->start();
|
||||
}
|
||||
|
||||
+32
-16
@@ -63,60 +63,76 @@ public:
|
||||
boost::shared_ptr<HandInterface> getCurrentHand();
|
||||
const boost::shared_ptr<HandInterface> getCurrentHand() const;
|
||||
|
||||
PlayerList getSeatsList() const {
|
||||
PlayerList getSeatsList() const
|
||||
{
|
||||
return seatsList;
|
||||
}
|
||||
PlayerList getActivePlayerList() const {
|
||||
PlayerList getActivePlayerList() const
|
||||
{
|
||||
return activePlayerList;
|
||||
}
|
||||
PlayerList getRunningPlayerList() const {
|
||||
PlayerList getRunningPlayerList() const
|
||||
{
|
||||
return runningPlayerList;
|
||||
}
|
||||
|
||||
void setStartQuantityPlayers(int theValue) {
|
||||
void setStartQuantityPlayers(int theValue)
|
||||
{
|
||||
startQuantityPlayers = theValue;
|
||||
}
|
||||
int getStartQuantityPlayers() const {
|
||||
int getStartQuantityPlayers() const
|
||||
{
|
||||
return startQuantityPlayers;
|
||||
}
|
||||
|
||||
void setStartSmallBlind(int theValue) {
|
||||
void setStartSmallBlind(int theValue)
|
||||
{
|
||||
startSmallBlind = theValue;
|
||||
}
|
||||
int getStartSmallBlind() const {
|
||||
int getStartSmallBlind() const
|
||||
{
|
||||
return startSmallBlind;
|
||||
}
|
||||
|
||||
void setStartCash(int theValue) {
|
||||
void setStartCash(int theValue)
|
||||
{
|
||||
startCash = theValue;
|
||||
}
|
||||
int getStartCash() const {
|
||||
int getStartCash() const
|
||||
{
|
||||
return startCash;
|
||||
}
|
||||
|
||||
int getMyGameID() const {
|
||||
int getMyGameID() const
|
||||
{
|
||||
return myGameID;
|
||||
}
|
||||
|
||||
void setCurrentSmallBlind(int theValue) {
|
||||
void setCurrentSmallBlind(int theValue)
|
||||
{
|
||||
currentSmallBlind = theValue;
|
||||
}
|
||||
int getCurrentSmallBlind() const {
|
||||
int getCurrentSmallBlind() const
|
||||
{
|
||||
return currentSmallBlind;
|
||||
}
|
||||
|
||||
void setCurrentHandID(int theValue) {
|
||||
void setCurrentHandID(int theValue)
|
||||
{
|
||||
currentHandID = theValue;
|
||||
}
|
||||
int getCurrentHandID() const {
|
||||
int getCurrentHandID() const
|
||||
{
|
||||
return currentHandID;
|
||||
}
|
||||
|
||||
unsigned getDealerPosition() const {
|
||||
unsigned getDealerPosition() const
|
||||
{
|
||||
return dealerPosition;
|
||||
}
|
||||
|
||||
void replaceDealer(unsigned oldDealer, unsigned newDealer) {
|
||||
void replaceDealer(unsigned oldDealer, unsigned newDealer)
|
||||
{
|
||||
if (dealerPosition == oldDealer)
|
||||
dealerPosition = newDealer;
|
||||
}
|
||||
|
||||
@@ -1054,9 +1054,17 @@ vector< vector<int> > ArrayData::getHandChancePreflop(int handCode)
|
||||
|
||||
int check = -1;
|
||||
|
||||
int i;
|
||||
|
||||
vector< vector<int> > chance(2);
|
||||
chance[0].assign(10,0);
|
||||
chance[1].assign(10,0);
|
||||
|
||||
chance[0].resize(10);
|
||||
chance[1].resize(10);
|
||||
|
||||
for(i=0; i<10; i++) {
|
||||
chance[0][i] = 0;
|
||||
chance[1][i] = 0;
|
||||
}
|
||||
|
||||
for (unsigned val = 0; val < NUM_HAND_CHANCE_PREFLOP; val++) {
|
||||
if(handCode == handChancePreflop[val].hand) {
|
||||
|
||||
@@ -65,7 +65,7 @@ int CardsValue::holeCardsClass(int one, int two)
|
||||
}
|
||||
}
|
||||
switch((one-1)%13+2) {
|
||||
//Ass
|
||||
//Ass
|
||||
case 14: {
|
||||
if((one-1)/13 == (two-1)/13) {
|
||||
switch((one-1)%13-(two-1)%13) {
|
||||
@@ -221,313 +221,450 @@ int CardsValue::holeCardsClass(int one, int two)
|
||||
|
||||
}
|
||||
|
||||
int CardsValue::holeCardsToIntCode(int holeCards[2])
|
||||
int CardsValue::holeCardsToIntCode(int* cards)
|
||||
{
|
||||
|
||||
// Code der HoleCards ermitteln
|
||||
if(holeCards[0]%13 == holeCards[1]%13) {
|
||||
return ((holeCards[0]%13)*1000 + (holeCards[0]%13)*10);
|
||||
if(cards[0]%13 == cards[1]%13) {
|
||||
return ((cards[0]%13)*1000 + (cards[0]%13)*10);
|
||||
} else {
|
||||
if(holeCards[0]%13 < holeCards[1]%13) {
|
||||
if(holeCards[0]/13 == holeCards[1]/13) {
|
||||
return ((holeCards[0]%13)*1000 + (holeCards[1]%13)*10 + 1);
|
||||
if(cards[0]%13 < cards[1]%13) {
|
||||
if(cards[0]/13 == cards[1]/13) {
|
||||
return ((cards[0]%13)*1000 + (cards[1]%13)*10 + 1);
|
||||
} else {
|
||||
return ((holeCards[0]%13)*1000 + (holeCards[1]%13)*10);
|
||||
return ((cards[0]%13)*1000 + (cards[1]%13)*10);
|
||||
}
|
||||
} else {
|
||||
if(holeCards[0]/13 == holeCards[1]/13) {
|
||||
return ((holeCards[1]%13)*1000 + (holeCards[0]%13)*10 + 1);
|
||||
if(cards[0]/13 == cards[1]/13) {
|
||||
return ((cards[1]%13)*1000 + (cards[0]%13)*10 + 1);
|
||||
} else {
|
||||
return ((holeCards[1]%13)*1000 + (holeCards[0]%13)*10);
|
||||
return ((cards[1]%13)*1000 + (cards[0]%13)*10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static const int straight[10] = { 7936, 3968, 1984, 992, 496, 248, 124, 62, 31, 4111 };
|
||||
|
||||
int CardsValue::cardsValueShort(int cards[4])
|
||||
/* DO NOT USE, THIS MAY LEAK MEMORY
|
||||
int* CardsValue::intCodeToHoleCards(int code)
|
||||
{
|
||||
|
||||
int color_idx;
|
||||
int card_idx;
|
||||
// one possibility !!!
|
||||
|
||||
// Royal Flush, Straight Flush, Flush
|
||||
for(color_idx=0; color_idx<4; color_idx++) { // check all colors
|
||||
if(bitcount(cards[color_idx])>=5) { // check if at least 5 cards of one color
|
||||
if((cards[color_idx] & straight[0]) == straight[0]) // check for Royal Flush
|
||||
return 9;
|
||||
else { // check for Straight Flush
|
||||
for(card_idx=1; card_idx<10; card_idx++) {
|
||||
if((cards[color_idx] & straight[card_idx]) == straight[card_idx]) {
|
||||
return 8; // Straight Flush
|
||||
int* cards = new int[2];
|
||||
|
||||
cards[0] = code/1000;
|
||||
cards[1] = (code-cards[0]*1000)/10;
|
||||
|
||||
if(cards[0]==cards[1]) {
|
||||
cards[1] +=13;
|
||||
} else {
|
||||
if(code%10 == 0) cards[1] +=13;
|
||||
}
|
||||
|
||||
return cards;
|
||||
|
||||
}*/
|
||||
|
||||
int CardsValue::cardsValue(int* cards, int* position)
|
||||
{
|
||||
|
||||
int array[7][3];
|
||||
int j1, j2, j3, j4, j5, k1, k2, ktemp[3];
|
||||
|
||||
// Kartenwerte umwandeln (z.B. [ 11 (Karo K�ig) -> 0 11 ] oder [ 31 (Pik 7) -> 2 5 ] )
|
||||
for(j1=0; j1<7; j1++) {
|
||||
array[j1][0] = cards[j1]/13;
|
||||
array[j1][1] = cards[j1]%13;
|
||||
array[j1][2] = j1;
|
||||
}
|
||||
|
||||
// Karten nach Farben sortieren: Kreuz - Pik - Herz - Karo
|
||||
for(k1=0; k1<7; k1++) {
|
||||
for(k2=k1+1; k2<7; k2++) {
|
||||
if(array[k1][0]<array[k2][0]) {
|
||||
ktemp[0] = array[k1][0];
|
||||
ktemp[1] = array[k1][1];
|
||||
ktemp[2] = array[k1][2];
|
||||
array[k1][0] = array[k2][0];
|
||||
array[k1][1] = array[k2][1];
|
||||
array[k1][2] = array[k2][2];
|
||||
array[k2][0] = ktemp[0];
|
||||
array[k2][1] = ktemp[1];
|
||||
array[k2][2] = ktemp[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Karten innerhalb der Farben nach der Gr�e sortieren: Ass - K�ig - Dame - ... - 4 - 3 - 2
|
||||
for(k1=0; k1<7; k1++) {
|
||||
for(k2=k1+1; k2<7; k2++) {
|
||||
if(array[k1][0]==array[k2][0] && array[k1][1]<array[k2][1]) {
|
||||
ktemp[0] = array[k1][0];
|
||||
ktemp[1] = array[k1][1];
|
||||
ktemp[2] = array[k1][2];
|
||||
array[k1][0] = array[k2][0];
|
||||
array[k1][1] = array[k2][1];
|
||||
array[k1][2] = array[k2][2];
|
||||
array[k2][0] = ktemp[0];
|
||||
array[k2][1] = ktemp[1];
|
||||
array[k2][2] = ktemp[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Karten auf Bl�ter testen. Klasseneinteilung absteigend: 9 - Royal Flush, 8 - Straight Flush, ... 2 - Zwei Paare, 1 - Ein Paar, 0 - Nischt
|
||||
|
||||
// auf Royal Flush (Klasse 9) und Straight Flush (Klasse 8) testen
|
||||
for(j1=0; j1<3; j1++) {
|
||||
// 5 Karten gleiche Farbe ?
|
||||
if(array[j1][0] == array[j1+1][0] && array[j1][0] == array[j1+2][0] && array[j1][0] == array[j1+3][0] && array[j1][0] == array[j1+4][0]) {
|
||||
// zus�zlich in Stra�nform ?
|
||||
if(array[j1][1]-1 == array[j1+1][1] && array[j1+1][1]-1 == array[j1+2][1] && array[j1+2][1]-1 == array[j1+3][1] && array[j1+3][1]-1 == array[j1+4][1]) {
|
||||
// mit Ass an der Spitze ?
|
||||
if(array[j1][1] == 12) {
|
||||
// Royal Flush (9*100000000)
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
for(j2=0; j2<5; j2++) {
|
||||
position[j2] = array[j1+j2][2];
|
||||
}
|
||||
}
|
||||
return 900000000;
|
||||
}
|
||||
// sonst nur Straight Flush (8*100000000 + (h�hste Straight-Karte)*1000000)
|
||||
else {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
for(j2=0; j2<5; j2++) {
|
||||
position[j2] = array[j1+j2][2];
|
||||
}
|
||||
}
|
||||
return 800000000+array[j1][1]*1000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Straight Flush Ausnahme: 5-4-3-2-A
|
||||
for(j1=0; j1<3; j1++) {
|
||||
// 5 Karten gleiche Farbe ?
|
||||
if(array[j1][0] == array[j1+1][0] && array[j1][0] == array[j1+2][0] && array[j1][0] == array[j1+3][0] && array[j1][0] == array[j1+4][0]) {
|
||||
for(j2=j1+1; j2<4; j2++) {
|
||||
if(array[j1][1]-9==array[j2][1] && array[j2][1]-1==array[j2+1][1] && array[j2+1][1]-1==array[j2+2][1] && array[j2+2][1]-1==array[j2+3][1] && array[j1][0]==array[j2+2][0] && array[j1][0]==array[j2+3][0]) {
|
||||
// Straight Flush mit 5 als höchste Karte -> 8*100000000+3*1000000
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
position[0] = array[j1][2];
|
||||
for(j3=0; j3<4; j3++) {
|
||||
position[j3+1] = array[j2+j3][2];
|
||||
}
|
||||
}
|
||||
return 800000000+3*1000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// auf Flush (Klasse 5) testen
|
||||
for(j1=0; j1<3; j1++) {
|
||||
if(array[j1][0] == array[j1+1][0] && array[j1][0] == array[j1+2][0] && array[j1][0] == array[j1+3][0] && array[j1][0] == array[j1+4][0]) {
|
||||
// Flush -> 5*10000000 + h�ste Flush Karten mit absteigender Wertung
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
for(j2=0; j2<5; j2++) {
|
||||
position[j2] = array[j1+j2][2];
|
||||
}
|
||||
}
|
||||
return 500000000+array[j1][1]*1000000+array[j1+1][1]*10000+array[j1+2][1]*100+array[j1+3][1]*10+array[j1+4][1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Karten fr den Vierling-, Full-House-, Drilling- und Paartest umsortieren
|
||||
for(k1=0; k1<7; k1++) {
|
||||
for(k2=k1+1; k2<7; k2++) {
|
||||
if(array[k1][1]<array[k2][1]) {
|
||||
ktemp[0] = array[k1][0];
|
||||
ktemp[1] = array[k1][1];
|
||||
ktemp[2] = array[k1][2];
|
||||
array[k1][0] = array[k2][0];
|
||||
array[k1][1] = array[k2][1];
|
||||
array[k1][2] = array[k2][2];
|
||||
array[k2][0] = ktemp[0];
|
||||
array[k2][1] = ktemp[1];
|
||||
array[k2][2] = ktemp[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// nach Position sortieren: erst board, dann hole cards
|
||||
for(k1=0; k1<7; k1++) {
|
||||
for(k2=k1+1; k2<7; k2++) {
|
||||
if(array[k1][1]==array[k2][1] && array[k1][2]<array[k2][2]) {
|
||||
ktemp[0] = array[k1][0];
|
||||
ktemp[1] = array[k1][1];
|
||||
ktemp[2] = array[k1][2];
|
||||
array[k1][0] = array[k2][0];
|
||||
array[k1][1] = array[k2][1];
|
||||
array[k1][2] = array[k2][2];
|
||||
array[k2][0] = ktemp[0];
|
||||
array[k2][1] = ktemp[1];
|
||||
array[k2][2] = ktemp[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// auf Vierling (Klasse 7) testen
|
||||
for(j1=0; j1<4; j1++) {
|
||||
if(array[j1][1] == array[j1+1][1] && array[j1][1] == array[j1+2][1] && array[j1][1] == array[j1+3][1]) {
|
||||
// Position des Kickers ermitteln und der Blattwertung als dritte Gewichtung hinzuaddieren
|
||||
if(j1==0) {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
for(j2=0; j2<5; j2++) {
|
||||
position[j2] = array[j2][2];
|
||||
}
|
||||
}
|
||||
return 700000000+array[j1][1]*1000000+array[j1+4][1]*10000;
|
||||
} else {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
for(j2=0; j2<4; j2++) {
|
||||
position[j2] = array[j1+j2][2];
|
||||
}
|
||||
position[4] = array[0][2];
|
||||
}
|
||||
return 700000000+array[j1][1]*1000000+array[0][1]*10000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hilfsvariablen fr die Full-House-Paar- und -Drilling-Zuordnung
|
||||
int drei, zwei;
|
||||
|
||||
// auf Straight (Klasse 4) und Full House (Klasse 6) testen
|
||||
for(j1=0; j1<7; j1++) {
|
||||
for(j2=j1+1; j2<7; j2++) {
|
||||
for(j3=j2+1; j3<7; j3++) {
|
||||
for(j4=j3+1; j4<7; j4++) {
|
||||
for(j5=j4+1; j5<7; j5++) {
|
||||
// Straight
|
||||
if(array[j1][1]-1 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1] && array[j4][1]-1 == array[j5][1]) {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
position[0] = array[j1][2];
|
||||
position[1] = array[j2][2];
|
||||
position[2] = array[j3][2];
|
||||
position[3] = array[j4][2];
|
||||
position[4] = array[j5][2];
|
||||
}
|
||||
return 400000000+array[j1][1]*1000000;
|
||||
}
|
||||
// Full House
|
||||
if((array[j1][1] == array[j2][1] && array[j1][1] == array[j3][1] && array[j4][1] == array[j5][1]) || (array[j3][1] == array[j4][1] && array[j3][1] == array[j5][1] && array[j1][1] == array[j2][1])) {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
position[0] = array[j1][2];
|
||||
position[1] = array[j2][2];
|
||||
position[2] = array[j3][2];
|
||||
position[3] = array[j4][2];
|
||||
position[4] = array[j5][2];
|
||||
}
|
||||
// Paar und Drilling des Full House ermitteln ermitteln
|
||||
if(array[j3][1]==array[j1][1]) {
|
||||
drei = array[j1][1];
|
||||
zwei = array[j4][1];
|
||||
} else {
|
||||
drei = array[j4][1];
|
||||
zwei = array[j1][1];
|
||||
}
|
||||
return 600000000+drei*1000000+zwei*10000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 5; // Flush
|
||||
}
|
||||
}
|
||||
|
||||
int AND = cards[0] & cards[1] & cards[2] & cards[3];
|
||||
|
||||
// Four of a Kind
|
||||
if(AND) {
|
||||
return 7;
|
||||
}
|
||||
|
||||
int OR = cards[0] | cards[1] | cards[2] | cards[3];
|
||||
|
||||
// Straight
|
||||
for(card_idx=0; card_idx<10; card_idx++) {
|
||||
if((OR & straight[card_idx]) == straight[card_idx]) {
|
||||
return 4;
|
||||
// auf Straight-Spezialfall ( 5 4 3 2 A ) testen
|
||||
for(j1=0; j1<7; j1++) {
|
||||
for(j2=j1+1; j2<7; j2++) {
|
||||
for(j3=j2+1; j3<7; j3++) {
|
||||
for(j4=j3+1; j4<7; j4++) {
|
||||
for(j5=j4+1; j5<7; j5++) {
|
||||
if(array[j1][1]-9 == array[j2][1] && array[j2][1]-1 == array[j3][1] && array[j3][1]-1 == array[j4][1] && array[j4][1]-1 == array[j5][1]) {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
position[0] = array[j1][2];
|
||||
position[1] = array[j2][2];
|
||||
position[2] = array[j3][2];
|
||||
position[3] = array[j4][2];
|
||||
position[4] = array[j5][2];
|
||||
}
|
||||
return 400000000+array[j2][1]*1000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int color_1_idx, color_2_idx, color_3_idx, color_4_idx, color_5_idx;
|
||||
int temp;
|
||||
|
||||
// Full House, Three of a Kind
|
||||
for(color_1_idx=0; color_1_idx<2; color_1_idx++) {
|
||||
for(color_2_idx=color_1_idx+1; color_2_idx<3; color_2_idx++) {
|
||||
for(color_3_idx=color_2_idx+1; color_3_idx<4; color_3_idx++) {
|
||||
temp = cards[color_1_idx] & cards[color_2_idx] & cards[color_3_idx];
|
||||
if(bitcount(temp) == 2) { // two times Three of a Kind
|
||||
return 6; // Full House
|
||||
// auf Drilling (Klasse 3) testen
|
||||
for(j1=0; j1<5; j1++) {
|
||||
if(array[j1][1] == array[j1+1][1] && array[j1][1] == array[j1+2][1]) {
|
||||
// Kicker ermitteln
|
||||
if(j1==0) {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
for(j2=0; j2<5; j2++) {
|
||||
position[j2] = array[j2][2];
|
||||
}
|
||||
}
|
||||
return 300000000+array[j1][1]*1000000+array[j1+3][1]*10000+array[j1+4][1]*100;
|
||||
} else {
|
||||
if(j1==1) {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
for(j2=0; j2<5; j2++) {
|
||||
position[j2] = array[j2][2];
|
||||
}
|
||||
}
|
||||
return 300000000+array[j1][1]*1000000+array[j1-1][1]*10000+array[j1+3][1]*100;
|
||||
} else {
|
||||
if(temp) {
|
||||
for(color_4_idx=0; color_4_idx<3; color_4_idx++) {
|
||||
for(color_5_idx=color_4_idx+1; color_5_idx<4; color_5_idx++) {
|
||||
if(~temp & cards[color_4_idx] & cards[color_5_idx]) { // search for additional pair
|
||||
return 6; // Full House
|
||||
}
|
||||
}
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
for(j2=0; j2<3; j2++) {
|
||||
position[j2] = array[j1+j2][2];
|
||||
}
|
||||
return 3; // Three of a Kind
|
||||
position[3] = array[0][2];
|
||||
position[4] = array[1][2];
|
||||
}
|
||||
return 300000000+array[j1][1]*1000000+array[0][1]*10000+array[1][1]*100;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Two Pairs, Two of a Kind
|
||||
for(color_1_idx=0; color_1_idx<3; color_1_idx++) {
|
||||
for(color_2_idx=color_1_idx+1; color_2_idx<4; color_2_idx++) {
|
||||
temp = cards[color_1_idx] & cards[color_2_idx];
|
||||
if(bitcount(temp) >= 2) { // at least two times Two of a Kind
|
||||
return 2; // Two Pairs
|
||||
} else {
|
||||
if(temp) { // search for second pair
|
||||
for(color_3_idx=0; color_3_idx<3; color_3_idx++) {
|
||||
for(color_4_idx=color_3_idx+1; color_4_idx<4; color_4_idx++) {
|
||||
if(~temp & cards[color_3_idx] & cards[color_4_idx]) {
|
||||
return 2; // Two Pairs
|
||||
}
|
||||
// auf Zwei Paare (Klasse 2) testen
|
||||
for(j1=0; j1<4; j1++) {
|
||||
for(j2=j1+2; j2<6; j2++) {
|
||||
if(array[j1][1] == array[j1+1][1] && array[j2][1] == array[j2+1][1]) {
|
||||
// Kicker ermitteln
|
||||
if(j1==0) {
|
||||
if(j2==2) {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
position[0] = array[j1][2];
|
||||
position[1] = array[j1+1][2];
|
||||
position[2] = array[j2][2];
|
||||
position[3] = array[j2+1][2];
|
||||
position[4] = array[j2+2][2];
|
||||
}
|
||||
return 200000000+array[j1][1]*1000000+array[j2][1]*10000+array[j2+2][1]*100;
|
||||
} else {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
position[0] = array[j1][2];
|
||||
position[1] = array[j1+1][2];
|
||||
position[2] = array[j2][2];
|
||||
position[3] = array[j2+1][2];
|
||||
position[4] = array[j1+2][2];
|
||||
}
|
||||
return 200000000+array[j1][1]*1000000+array[j2][1]*10000+array[j1+2][1]*100;
|
||||
}
|
||||
return 1; // Two of a Kind
|
||||
} else {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
position[0] = array[j1][2];
|
||||
position[1] = array[j1+1][2];
|
||||
position[2] = array[j2][2];
|
||||
position[3] = array[j2+1][2];
|
||||
position[4] = array[0][2];
|
||||
}
|
||||
return 200000000+array[j1][1]*1000000+array[j2][1]*10000+array[0][1]*100;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0; // High Card
|
||||
}
|
||||
|
||||
int CardsValue::cardsValue(int cards[4], int bestHand[4])
|
||||
{
|
||||
int color_1_idx;
|
||||
int card_idx;
|
||||
KickerValue kickerValue1;
|
||||
|
||||
// Royal Flush, Straight Flush, Flush
|
||||
for(color_1_idx=0; color_1_idx<4; color_1_idx++) { // check all colors
|
||||
if(bitcount(cards[color_1_idx])>=5) { // check if at least 5 cards of one color
|
||||
if((cards[color_1_idx] & straight[0]) == straight[0]) { // check for Royal Flush
|
||||
if(bestHand) bestHand[color_1_idx] = straight[0];
|
||||
return 900000000; // Royal Flush
|
||||
} else {
|
||||
for(card_idx=1; card_idx<10; card_idx++) {
|
||||
if((cards[color_1_idx] & straight[card_idx]) == straight[card_idx]) { // check for Straight Flush
|
||||
if(bestHand) bestHand[color_1_idx] = straight[card_idx];
|
||||
return (800000000+(12-card_idx)*1000000); // Straight Flush
|
||||
// auf Paar (Klasse 1) testen
|
||||
for(j1=0; j1<6; j1++) {
|
||||
if(array[j1][1] == array[j1+1][1]) {
|
||||
// Kicker ermitteln
|
||||
if(j1==0) {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
for(j2=0; j2<5; j2++) {
|
||||
position[j2] = array[j2][2];
|
||||
}
|
||||
}
|
||||
return 100000000+array[j1][1]*1000000+array[j1+2][1]*10000+array[j1+3][1]*100+array[j1+4][1];
|
||||
}
|
||||
// Flush
|
||||
kickerValue1 = determineKickerValue(cards[color_1_idx],0,4);
|
||||
if(bestHand) bestHand[color_1_idx] = kickerValue1.select;
|
||||
return 500000000 + kickerValue1.factorValue;
|
||||
}
|
||||
}
|
||||
|
||||
int AND = cards[0] & cards[1] & cards[2] & cards[3];
|
||||
int OR = cards[0] | cards[1] | cards[2] | cards[3];
|
||||
int temp1;
|
||||
KickerValue kickerValue2;
|
||||
|
||||
// Four of a Kind
|
||||
if(AND) {
|
||||
kickerValue1 = determineKickerValue(AND,0,0);
|
||||
kickerValue2 = determineKickerValue(OR & ~AND,1,1);
|
||||
if(bestHand) {
|
||||
temp1 = kickerValue2.select;
|
||||
for(color_1_idx=3; color_1_idx>=0; color_1_idx--) {
|
||||
bestHand[color_1_idx] = (cards[color_1_idx] & (kickerValue1.select | temp1));
|
||||
if(bestHand[color_1_idx] & temp1) temp1 = 0;
|
||||
}
|
||||
}
|
||||
return 700000000 + kickerValue1.factorValue + kickerValue2.factorValue;
|
||||
}
|
||||
|
||||
// Straight
|
||||
for(card_idx=0; card_idx<10; card_idx++) {
|
||||
if((OR & straight[card_idx]) == straight[card_idx]) {
|
||||
if(bestHand) {
|
||||
temp1 = straight[card_idx];
|
||||
for(color_1_idx=3; color_1_idx>=0; color_1_idx--) {
|
||||
bestHand[color_1_idx] += (temp1 & cards[color_1_idx]);
|
||||
temp1 &= ~bestHand[color_1_idx];
|
||||
if(j1==1) {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
for(j2=0; j2<5; j2++) {
|
||||
position[j2] = array[j2][2];
|
||||
}
|
||||
}
|
||||
return 100000000+array[j1][1]*1000000+array[j1-1][1]*10000+array[j1+2][1]*100+array[j1+3][1];
|
||||
}
|
||||
return 400000000 + (12-card_idx)*1000000;
|
||||
}
|
||||
}
|
||||
|
||||
int color_2_idx, color_3_idx;
|
||||
|
||||
// Full House, Three of a Kind
|
||||
temp1 = 0;
|
||||
for(color_1_idx=0; color_1_idx<2; color_1_idx++) {
|
||||
for(color_2_idx=color_1_idx+1; color_2_idx<3; color_2_idx++) {
|
||||
for(color_3_idx=color_2_idx+1; color_3_idx<4; color_3_idx++) {
|
||||
temp1 |= cards[color_1_idx] & cards[color_2_idx] & cards[color_3_idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(temp1) {
|
||||
if(bitcount(temp1) == 2) {
|
||||
// two times Three of a Kind
|
||||
if(bestHand) {
|
||||
kickerValue1 = determineKickerValue(temp1,0,0);
|
||||
kickerValue2 = determineKickerValue(kickerValue1.remain,1,1);
|
||||
int temp2 = 0;
|
||||
for(color_1_idx=3; color_1_idx>=0; color_1_idx--) {
|
||||
if(temp2<2) bestHand[color_1_idx] += (cards[color_1_idx] & (kickerValue1.select | kickerValue2.select));
|
||||
else bestHand[color_1_idx] += (cards[color_1_idx] & kickerValue1.select);
|
||||
if(cards[color_1_idx] & kickerValue2.select) temp2++;
|
||||
if(j1==2) {
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
for(j2=0; j2<5; j2++) {
|
||||
position[j2] = array[j2][2];
|
||||
}
|
||||
}
|
||||
}
|
||||
return 600000000 + determineKickerValue(temp1,0,1).factorValue;
|
||||
} else {
|
||||
// one times Three of a Kind
|
||||
int temp2 = temp1;
|
||||
temp1 = 0;
|
||||
// check for additional pair
|
||||
for(color_1_idx=0; color_1_idx<3; color_1_idx++) {
|
||||
for(color_2_idx=color_1_idx+1; color_2_idx<4; color_2_idx++) {
|
||||
temp1 |= cards[color_1_idx] & cards[color_2_idx];
|
||||
}
|
||||
}
|
||||
temp1 &= ~temp2; // remove Three of a Kind from found pairs
|
||||
if(temp1) {
|
||||
// with additional pair
|
||||
kickerValue1 = determineKickerValue(temp2,0,0);
|
||||
kickerValue2 = determineKickerValue(temp1,1,1);
|
||||
if(bestHand) {
|
||||
for(color_1_idx=3; color_1_idx>=0; color_1_idx--) bestHand[color_1_idx] = (cards[color_1_idx] & (kickerValue1.select | kickerValue2.select));
|
||||
}
|
||||
return 600000000 + kickerValue1.factorValue + kickerValue2.factorValue; // Full House
|
||||
return 100000000+array[j1][1]*1000000+array[j1-2][1]*10000+array[j1-1][1]*100+array[j1+2][1];
|
||||
} else {
|
||||
// without addition pair
|
||||
kickerValue1 = determineKickerValue(temp2,0,0);
|
||||
kickerValue2 = determineKickerValue(OR & ~temp2,1,2);
|
||||
if(bestHand) {
|
||||
for(color_1_idx=3; color_1_idx>=0; color_1_idx--) bestHand[color_1_idx] = (cards[color_1_idx] & (kickerValue1.select | kickerValue2.select));
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
for(j2=0; j2<2; j2++) {
|
||||
position[j2] = array[j1+j2][2];
|
||||
}
|
||||
position[2] = array[0][2];
|
||||
position[3] = array[1][2];
|
||||
position[4] = array[2][2];
|
||||
}
|
||||
return 300000000 + kickerValue1.factorValue + kickerValue2.factorValue; // Three of a Kind
|
||||
return 100000000+array[j1][1]*1000000+array[0][1]*10000+array[1][1]*100+array[2][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Two Pairs, Two of a Kind
|
||||
temp1 = 0;
|
||||
for(color_1_idx=0; color_1_idx<3; color_1_idx++) {
|
||||
for(color_2_idx=color_1_idx+1; color_2_idx<4; color_2_idx++) {
|
||||
temp1 |= (cards[color_1_idx] & cards[color_2_idx]);
|
||||
// Highest Card (Klasse 0) + Kicker
|
||||
if(position) {
|
||||
// Position-Array fuellen
|
||||
for(j2=0; j2<5; j2++) {
|
||||
position[j2] = array[j2][2];
|
||||
}
|
||||
}
|
||||
if(temp1) {
|
||||
if(bitcount(temp1) >= 2) { // at least two times Two of a Kind
|
||||
kickerValue1 = determineKickerValue(temp1,0,1);
|
||||
kickerValue2 = determineKickerValue(OR & ~kickerValue1.select,2,2);
|
||||
if(bestHand) {
|
||||
temp1 = (kickerValue1.select | kickerValue2.select);
|
||||
for(color_1_idx=3; color_1_idx>=0; color_1_idx--) {
|
||||
bestHand[color_1_idx] += (cards[color_1_idx] & temp1);
|
||||
if(bestHand[color_1_idx] & kickerValue2.select) temp1 &= ~kickerValue2.select;
|
||||
}
|
||||
}
|
||||
return 200000000 + kickerValue1.factorValue + kickerValue2.factorValue; // Two Pairs
|
||||
} else {
|
||||
kickerValue1 = determineKickerValue(temp1,0,0);
|
||||
kickerValue2 = determineKickerValue(OR & ~temp1,1,3);
|
||||
if(bestHand) {
|
||||
for(color_1_idx=3; color_1_idx>=0; color_1_idx--) {
|
||||
bestHand[color_1_idx] += (cards[color_1_idx] & (kickerValue1.select | kickerValue2.select));
|
||||
}
|
||||
}
|
||||
return 100000000 + kickerValue1.factorValue + kickerValue2.factorValue; // Two of a Kind
|
||||
}
|
||||
}
|
||||
|
||||
// High Card
|
||||
kickerValue1 = determineKickerValue(OR,0,4);
|
||||
if(bestHand) {
|
||||
for(color_1_idx=3; color_1_idx>=0; color_1_idx--) {
|
||||
bestHand[color_1_idx] += (cards[color_1_idx] & kickerValue1.select);
|
||||
}
|
||||
}
|
||||
return kickerValue1.factorValue;
|
||||
|
||||
return array[0][1]*1000000+array[1][1]*10000+array[2][1]*100+array[3][1]*10+array[4][1];
|
||||
}
|
||||
|
||||
static const int factor_kicker_short[4] = {1000000,10000,100,1};
|
||||
static const int factor_kicker_long[5] = {1000000,10000,100,10,1};
|
||||
|
||||
KickerValue CardsValue::determineKickerValue(int testValue, int factorPointerStart, int factorPointerEnd)
|
||||
std::vector< std::vector<int> > CardsValue::calcCardsChance(GameState beRoID, int* playerCards, int* boardCards)
|
||||
{
|
||||
KickerValue kickerValue;
|
||||
kickerValue.factorValue = 0;
|
||||
kickerValue.remain = testValue;
|
||||
kickerValue.select = 0;
|
||||
int compareValue = 4096;
|
||||
int factorPointer = factorPointerStart;
|
||||
for(int card_idx=0; (factorPointer<=factorPointerEnd) & (card_idx<13); card_idx++) {
|
||||
if(kickerValue.remain >= compareValue) {
|
||||
if(factorPointerEnd - factorPointerStart==4) kickerValue.factorValue += (12-card_idx)*factor_kicker_long[factorPointer];
|
||||
else kickerValue.factorValue += (12-card_idx)*factor_kicker_short[factorPointer];
|
||||
kickerValue.remain &= ~compareValue;
|
||||
factorPointer++;
|
||||
}
|
||||
compareValue >>= 1;
|
||||
}
|
||||
kickerValue.select = testValue & ~kickerValue.remain;
|
||||
return kickerValue;
|
||||
}
|
||||
int i,j;
|
||||
|
||||
std::vector< std::vector<int> > CardsValue::calcCardsChance(GameState beRoID, int playerCards[2], int boardCards[5])
|
||||
{
|
||||
std::vector< std::vector<int> > chance(2);
|
||||
chance[0].assign(10,0);
|
||||
chance[1].assign(10,0);
|
||||
|
||||
int cards[4] = { 0,0,0,0 };
|
||||
chance[0].resize(10);
|
||||
chance[1].resize(10);
|
||||
|
||||
for(i=0; i<10; i++) {
|
||||
chance[0][i] = 0;
|
||||
chance[1][i] = 0;
|
||||
}
|
||||
|
||||
int cards[7];
|
||||
int sum = 0;
|
||||
|
||||
int card_idx_1;
|
||||
for(card_idx_1=0; card_idx_1<2; card_idx_1++) cards[playerCards[card_idx_1]/13] |= (1 << (playerCards[card_idx_1]%13));
|
||||
cards[0] = playerCards[0];
|
||||
cards[1] = playerCards[1];
|
||||
for(i=0; i<5; i++) cards[i+2] = boardCards[i];
|
||||
|
||||
switch(beRoID) {
|
||||
case GAME_STATE_PREFLOP: {
|
||||
@@ -538,60 +675,50 @@ std::vector< std::vector<int> > CardsValue::calcCardsChance(GameState beRoID, in
|
||||
break;
|
||||
case GAME_STATE_FLOP: {
|
||||
|
||||
for(card_idx_1=0; card_idx_1<3; card_idx_1++) cards[boardCards[card_idx_1]/13] |= (1 << (boardCards[card_idx_1]%13));
|
||||
|
||||
for(card_idx_1=0; card_idx_1<51; card_idx_1++) {
|
||||
if((cards[card_idx_1/13] & (1 << (card_idx_1%13))) == 0) {
|
||||
cards[card_idx_1/13] |= (1 << (card_idx_1%13));
|
||||
for(int card_idx_2=card_idx_1+1; card_idx_2<52; card_idx_2++) {
|
||||
if((cards[card_idx_2/13] & (1 << (card_idx_2%13))) == 0) {
|
||||
cards[card_idx_2/13] |= (1 << (card_idx_2%13));
|
||||
(chance[0][cardsValueShort(cards)])++;
|
||||
for(i=0; i<51; i++) {
|
||||
if(i!=cards[0] && i!=cards[1] && i!=cards[2] && i!=cards[3] && i!=cards[4]) {
|
||||
for(j=i+1; j<52; j++) {
|
||||
if(j!=cards[0] && j!=cards[1] && j!=cards[2] && j!=cards[3] && j!=cards[4]) {
|
||||
cards[5] = i;
|
||||
cards[6] = j;
|
||||
(chance[0][cardsValue(cards,0)/100000000])++;
|
||||
sum++;
|
||||
cards[card_idx_2/13] &= ~(1 << (card_idx_2%13));
|
||||
}
|
||||
}
|
||||
cards[card_idx_1/13] &= ~(1 << (card_idx_1%13));
|
||||
}
|
||||
}
|
||||
for(i=0; i<10; i++) {
|
||||
if(chance[0][i] > 0) chance[1][i] = 1;
|
||||
chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case GAME_STATE_TURN: {
|
||||
|
||||
for(card_idx_1=0; card_idx_1<4; card_idx_1++) cards[boardCards[card_idx_1]/13] |= (1 << (boardCards[card_idx_1]%13));
|
||||
|
||||
for(card_idx_1=0; card_idx_1<52; card_idx_1++) {
|
||||
if((cards[card_idx_1/13] & (1 << (card_idx_1%13))) == 0) {
|
||||
cards[card_idx_1/13] |= (1 << (card_idx_1%13));
|
||||
(chance[0][cardsValueShort(cards)])++;
|
||||
for(i=0; i<52; i++) {
|
||||
if(i!=cards[0] && i!=cards[1] && i!=cards[2] && i!=cards[3] && i!=cards[4] && i!=cards[5]) {
|
||||
cards[6] = i;
|
||||
(chance[0][cardsValue(cards,0)/100000000])++;
|
||||
sum++;
|
||||
cards[card_idx_1/13] &= ~(1 << (card_idx_1%13));
|
||||
}
|
||||
}
|
||||
for(i=0; i<10; i++) {
|
||||
if(chance[0][i] > 0) chance[1][i] = 1;
|
||||
chance[0][i] = (int)(((double)chance[0][i]/(double)sum)*100.0+0.5);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case GAME_STATE_RIVER: {
|
||||
|
||||
for(card_idx_1=0; card_idx_1<5; card_idx_1++) cards[boardCards[card_idx_1]/13] |= (1 << (boardCards[card_idx_1]%13));
|
||||
|
||||
chance[0][cardsValueShort(cards)] = 1;
|
||||
sum = 1;
|
||||
|
||||
chance[0][cardsValue(cards,0)/100000000] = 100;
|
||||
chance[1][cardsValue(cards,0)/100000000] = 1;
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
}
|
||||
}
|
||||
|
||||
if(beRoID>GAME_STATE_PREFLOP) {
|
||||
for(int hand_idx=0; hand_idx<10; hand_idx++) {
|
||||
if(chance[0][hand_idx] > 0) chance[1][hand_idx] = 1;
|
||||
chance[0][hand_idx] = (int)(((double)chance[0][hand_idx]/(double)sum)*100.0+0.5);
|
||||
}
|
||||
}
|
||||
|
||||
return chance;
|
||||
}
|
||||
|
||||
@@ -629,7 +756,7 @@ std::string CardsValue::determineHandName(int myCardsValueInt, PlayerList active
|
||||
std::string handName;
|
||||
|
||||
switch(myCardsValueInt/100000000) {
|
||||
// Royal Flush
|
||||
// Royal Flush
|
||||
case 9: {
|
||||
|
||||
handName = *cardStringIt_c;
|
||||
@@ -1034,8 +1161,8 @@ std::string CardsValue::determineHandName(int myCardsValueInt, PlayerList active
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{}
|
||||
default: {
|
||||
}
|
||||
}
|
||||
|
||||
return handName;
|
||||
@@ -1064,11 +1191,11 @@ std::list<std::string> CardsValue::translateCardsValueCode(int cardsValueCode)
|
||||
|
||||
switch (firstPart) {
|
||||
|
||||
// Royal Flush
|
||||
// Royal Flush
|
||||
case 9:
|
||||
cardString.push_back("Royal Flush");
|
||||
break;
|
||||
// Straight Flush
|
||||
// Straight Flush
|
||||
case 8: {
|
||||
cardString.push_back("Straight Flush, ");
|
||||
switch(secondPart) {
|
||||
@@ -2193,44 +2320,6 @@ std::list<std::string> CardsValue::translateCardsValueCode(int cardsValueCode)
|
||||
|
||||
}
|
||||
|
||||
int CardsValue::bitcount(int in)
|
||||
{
|
||||
int count=0 ;
|
||||
while (in) {
|
||||
count++ ;
|
||||
in &= (in - 1) ;
|
||||
|
||||
}
|
||||
return count ;
|
||||
}
|
||||
|
||||
int
|
||||
CardsValue::bestHandToPosition(int bestHand[4], int cardArray[7], int position[5])
|
||||
{
|
||||
|
||||
for(int card_idx=0; card_idx<5; card_idx++) position[card_idx] = -1;
|
||||
|
||||
int position_ctr = 0;
|
||||
for(int color_idx=0; color_idx<4; color_idx++) {
|
||||
for(int card_idx_1=0; card_idx_1<13; card_idx_1++) {
|
||||
if(bestHand[color_idx] & (1<<card_idx_1)) {
|
||||
for(int card_idx_2=0; card_idx_2<7; card_idx_2++) {
|
||||
if(cardArray[card_idx_2] == color_idx*13+card_idx_1) {
|
||||
if(position_ctr<5) {
|
||||
position[position_ctr] = card_idx_2;
|
||||
position_ctr++;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(position_ctr!=5) return 0;
|
||||
else return 1;
|
||||
}
|
||||
|
||||
|
||||
//int** CardsValue::showdown(GameState beRoID, int** playerCards, int playerCount) {
|
||||
//
|
||||
|
||||
@@ -38,28 +38,18 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
struct KickerValue {
|
||||
int factorValue;
|
||||
int select;
|
||||
int remain;
|
||||
};
|
||||
|
||||
class CardsValue
|
||||
{
|
||||
public:
|
||||
static int holeCardsClass(int, int);
|
||||
static int cardsValueShort(int[4]);
|
||||
static int cardsValue(int[4], int[4] = 0);
|
||||
static KickerValue determineKickerValue(int, int, int);
|
||||
static int cardsValue(int*, int*);
|
||||
static std::string determineHandName(int myCardsValueInt, PlayerList activePlayerList);
|
||||
static std::list<std::string> translateCardsValueCode(int cardsValueCode);
|
||||
|
||||
static int holeCardsToIntCode(int[2]);
|
||||
static int holeCardsToIntCode(int*);
|
||||
static int* intCodeToHoleCards(int);
|
||||
|
||||
static std::vector< std::vector<int> > calcCardsChance(GameState, int[2], int[5]);
|
||||
|
||||
static int bitcount(int in);
|
||||
static int bestHandToPosition(int bestHand[4], int cardArray[7], int position[5]);
|
||||
static std::vector< std::vector<int> > calcCardsChance(GameState, int*, int*);
|
||||
//static int** showdown(GameState, int**, int);
|
||||
|
||||
};
|
||||
|
||||
@@ -147,26 +147,26 @@ void LocalBeRo::run()
|
||||
//log the turned cards
|
||||
if(!logBoardCardsDone) {
|
||||
|
||||
int boardCards[5];
|
||||
int tempBoardCardsArray[5];
|
||||
|
||||
myHand->getBoard()->getMyCards(boardCards);
|
||||
myHand->getBoard()->getMyCards(tempBoardCardsArray);
|
||||
|
||||
switch(myBeRoID) {
|
||||
case GAME_STATE_FLOP:
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, boardCards[0], boardCards[1], boardCards[2]);
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2]);
|
||||
break;
|
||||
case GAME_STATE_TURN:
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, boardCards[0], boardCards[1], boardCards[2], boardCards[3]);
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3]);
|
||||
break;
|
||||
case GAME_STATE_RIVER:
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, boardCards[0], boardCards[1], boardCards[2], boardCards[3], boardCards[4]);
|
||||
myHand->getGuiInterface()->logDealBoardCardsMsg(myBeRoID, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3], tempBoardCardsArray[4]);
|
||||
|
||||
break;
|
||||
default: {
|
||||
LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR - wrong myBeRoID");
|
||||
}
|
||||
}
|
||||
if(myHand->getLog()) myHand->getLog()->logBoardCards(boardCards);
|
||||
if(myHand->getLog()) myHand->getLog()->logBoardCards(tempBoardCardsArray);
|
||||
logBoardCardsDone = true;
|
||||
|
||||
}
|
||||
|
||||
@@ -44,28 +44,34 @@ public:
|
||||
LocalBeRo(HandInterface* hi, unsigned dP, int sB, GameState gS);
|
||||
~LocalBeRo();
|
||||
|
||||
GameState getMyBeRoID() const {
|
||||
GameState getMyBeRoID() const
|
||||
{
|
||||
return myBeRoID;
|
||||
}
|
||||
|
||||
int getHighestCardsValue() const;
|
||||
void setHighestCardsValue(int /*theValue*/) { }
|
||||
|
||||
void setMinimumRaise ( int theValue ) {
|
||||
void setMinimumRaise ( int theValue )
|
||||
{
|
||||
minimumRaise = theValue;
|
||||
}
|
||||
int getMinimumRaise() const {
|
||||
int getMinimumRaise() const
|
||||
{
|
||||
return minimumRaise;
|
||||
}
|
||||
|
||||
void setFullBetRule ( bool theValue ) {
|
||||
void setFullBetRule ( bool theValue )
|
||||
{
|
||||
fullBetRule = theValue;
|
||||
}
|
||||
bool getFullBetRule() const {
|
||||
bool getFullBetRule() const
|
||||
{
|
||||
return fullBetRule;
|
||||
}
|
||||
|
||||
void skipFirstRunGui() {
|
||||
void skipFirstRunGui()
|
||||
{
|
||||
firstRunGui = false;
|
||||
}
|
||||
|
||||
@@ -77,89 +83,113 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
HandInterface* getMyHand() const {
|
||||
HandInterface* getMyHand() const
|
||||
{
|
||||
return myHand;
|
||||
}
|
||||
|
||||
unsigned getDealerPosition() const {
|
||||
unsigned getDealerPosition() const
|
||||
{
|
||||
return dealerPosition;
|
||||
}
|
||||
|
||||
void setCurrentPlayersTurnId(unsigned theValue) {
|
||||
void setCurrentPlayersTurnId(unsigned theValue)
|
||||
{
|
||||
currentPlayersTurnId = theValue;
|
||||
}
|
||||
unsigned getCurrentPlayersTurnId() const {
|
||||
unsigned getCurrentPlayersTurnId() const
|
||||
{
|
||||
return currentPlayersTurnId;
|
||||
}
|
||||
|
||||
void setFirstRoundLastPlayersTurnId(unsigned theValue) {
|
||||
void setFirstRoundLastPlayersTurnId(unsigned theValue)
|
||||
{
|
||||
firstRoundLastPlayersTurnId = theValue;
|
||||
}
|
||||
unsigned getFirstRoundLastPlayersTurnId() const {
|
||||
unsigned getFirstRoundLastPlayersTurnId() const
|
||||
{
|
||||
return firstRoundLastPlayersTurnId;
|
||||
}
|
||||
|
||||
void setCurrentPlayersTurnIt(PlayerListIterator theValue) {
|
||||
void setCurrentPlayersTurnIt(PlayerListIterator theValue)
|
||||
{
|
||||
currentPlayersTurnIt = theValue;
|
||||
}
|
||||
PlayerListIterator getCurrentPlayersTurnIt() const {
|
||||
PlayerListIterator getCurrentPlayersTurnIt() const
|
||||
{
|
||||
return currentPlayersTurnIt;
|
||||
}
|
||||
|
||||
void setLastPlayersTurnIt(PlayerListIterator theValue) {
|
||||
void setLastPlayersTurnIt(PlayerListIterator theValue)
|
||||
{
|
||||
lastPlayersTurnIt = theValue;
|
||||
}
|
||||
PlayerListIterator getLastPlayersTurnIt() const {
|
||||
PlayerListIterator getLastPlayersTurnIt() const
|
||||
{
|
||||
return lastPlayersTurnIt;
|
||||
}
|
||||
|
||||
void setHighestSet(int theValue) {
|
||||
void setHighestSet(int theValue)
|
||||
{
|
||||
highestSet = theValue;
|
||||
}
|
||||
int getHighestSet() const {
|
||||
int getHighestSet() const
|
||||
{
|
||||
return highestSet;
|
||||
}
|
||||
|
||||
void setFirstRun(bool theValue) {
|
||||
void setFirstRun(bool theValue)
|
||||
{
|
||||
firstRun = theValue;
|
||||
}
|
||||
bool getFirstRun() const {
|
||||
bool getFirstRun() const
|
||||
{
|
||||
return firstRun;
|
||||
}
|
||||
|
||||
void setFirstRound(bool theValue) {
|
||||
void setFirstRound(bool theValue)
|
||||
{
|
||||
firstRound = theValue;
|
||||
}
|
||||
bool getFirstRound() const {
|
||||
bool getFirstRound() const
|
||||
{
|
||||
return firstRound;
|
||||
}
|
||||
|
||||
void setSmallBlindPositionId(unsigned theValue) {
|
||||
void setSmallBlindPositionId(unsigned theValue)
|
||||
{
|
||||
smallBlindPositionId = theValue;
|
||||
}
|
||||
unsigned getSmallBlindPositionId() const {
|
||||
unsigned getSmallBlindPositionId() const
|
||||
{
|
||||
return smallBlindPositionId;
|
||||
}
|
||||
|
||||
void setBigBlindPositionId(unsigned theValue) {
|
||||
void setBigBlindPositionId(unsigned theValue)
|
||||
{
|
||||
bigBlindPositionId = theValue;
|
||||
}
|
||||
unsigned getBigBlindPositionId() const {
|
||||
unsigned getBigBlindPositionId() const
|
||||
{
|
||||
return bigBlindPositionId;
|
||||
}
|
||||
|
||||
|
||||
void setSmallBlindPosition(int theValue) {
|
||||
void setSmallBlindPosition(int theValue)
|
||||
{
|
||||
smallBlindPosition = theValue;
|
||||
}
|
||||
int getSmallBlindPosition() const {
|
||||
int getSmallBlindPosition() const
|
||||
{
|
||||
return smallBlindPosition;
|
||||
}
|
||||
|
||||
void setSmallBlind(int theValue) {
|
||||
void setSmallBlind(int theValue)
|
||||
{
|
||||
smallBlind = theValue;
|
||||
}
|
||||
int getSmallBlind() const {
|
||||
int getSmallBlind() const
|
||||
{
|
||||
return smallBlind;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,10 +44,12 @@ public:
|
||||
LocalBeRoPostRiver(HandInterface*, int, int);
|
||||
~LocalBeRoPostRiver();
|
||||
|
||||
void setHighestCardsValue(int theValue) {
|
||||
void setHighestCardsValue(int theValue)
|
||||
{
|
||||
highestCardsValue = theValue;
|
||||
}
|
||||
int getHighestCardsValue() const {
|
||||
int getHighestCardsValue() const
|
||||
{
|
||||
return highestCardsValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ void LocalBoard::distributePot(unsigned dealerPosition)
|
||||
// determine the number of level winners
|
||||
winnerCount = potLevel.size()-2;
|
||||
if (!winnerCount) {
|
||||
LOG_ERROR(__FILE__ << " (" << __LINE__ << "): distributePot-ERROR: no winner found");
|
||||
throw LocalException(__FILE__, __LINE__, ERR_NO_WINNER);
|
||||
}
|
||||
|
||||
// check if this is the final pot level for at least one winner
|
||||
@@ -161,7 +161,7 @@ void LocalBoard::distributePot(unsigned dealerPosition)
|
||||
if(finalPot) break;
|
||||
}
|
||||
|
||||
if(finalPot && winnerCount>0) {
|
||||
if(finalPot) {
|
||||
// distribute the pot level sum to level winners
|
||||
mod = (potLevel[1])%winnerCount;
|
||||
// pot level sum divisible by winnerCount
|
||||
@@ -175,13 +175,13 @@ void LocalBoard::distributePot(unsigned dealerPosition)
|
||||
}
|
||||
}
|
||||
if(it == seatsList->end()) {
|
||||
LOG_ERROR(__FILE__ << " (" << __LINE__ << "): distributePot-ERROR: seat not found");
|
||||
} else {
|
||||
(*it)->setMyCash( (*it)->getMyCash() + ((potLevel[1])/winnerCount));
|
||||
// filling winners vector
|
||||
winners.push_back((*it)->getMyUniqueID());
|
||||
(*it)->setLastMoneyWon( (*it)->getLastMoneyWon() + (potLevel[1])/winnerCount );
|
||||
throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND);
|
||||
}
|
||||
(*it)->setMyCash( (*it)->getMyCash() + ((potLevel[1])/winnerCount));
|
||||
|
||||
// filling winners vector
|
||||
winners.push_back((*it)->getMyUniqueID());
|
||||
(*it)->setLastMoneyWon( (*it)->getLastMoneyWon() + (potLevel[1])/winnerCount );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -196,8 +196,7 @@ void LocalBoard::distributePot(unsigned dealerPosition)
|
||||
}
|
||||
}
|
||||
if(it == seatsList->end()) {
|
||||
it = seatsList->begin();
|
||||
LOG_ERROR(__FILE__ << " (" << __LINE__ << "): distributePot-ERROR: dealer position not found");
|
||||
throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND);
|
||||
}
|
||||
|
||||
for(j=0; j<winnerCount; j++) {
|
||||
@@ -217,18 +216,16 @@ void LocalBoard::distributePot(unsigned dealerPosition)
|
||||
|
||||
}
|
||||
|
||||
if(winnerHit) {
|
||||
if(j<mod) {
|
||||
(*it)->setMyCash( (*it)->getMyCash() + (int)((potLevel[1])/winnerCount) + 1);
|
||||
// filling winners vector
|
||||
winners.push_back((*it)->getMyUniqueID());
|
||||
(*it)->setLastMoneyWon( (*it)->getLastMoneyWon() + ((potLevel[1])/winnerCount) + 1 );
|
||||
} else {
|
||||
(*it)->setMyCash( (*it)->getMyCash() + (int)((potLevel[1])/winnerCount));
|
||||
// filling winners vector
|
||||
winners.push_back((*it)->getMyUniqueID());
|
||||
(*it)->setLastMoneyWon( (*it)->getLastMoneyWon() + (potLevel[1])/winnerCount );
|
||||
}
|
||||
if(j<mod) {
|
||||
(*it)->setMyCash( (*it)->getMyCash() + (int)((potLevel[1])/winnerCount) + 1);
|
||||
// filling winners vector
|
||||
winners.push_back((*it)->getMyUniqueID());
|
||||
(*it)->setLastMoneyWon( (*it)->getLastMoneyWon() + ((potLevel[1])/winnerCount) + 1 );
|
||||
} else {
|
||||
(*it)->setMyCash( (*it)->getMyCash() + (int)((potLevel[1])/winnerCount));
|
||||
// filling winners vector
|
||||
winners.push_back((*it)->getMyUniqueID());
|
||||
(*it)->setLastMoneyWon( (*it)->getLastMoneyWon() + (potLevel[1])/winnerCount );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,32 +50,40 @@ public:
|
||||
|
||||
void setPlayerLists(PlayerList, PlayerList, PlayerList);
|
||||
|
||||
void setMyCards(int* theValue) {
|
||||
void setMyCards(int* theValue)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<5; i++) myCards[i] = theValue[i];
|
||||
}
|
||||
void getMyCards(int* theValue) {
|
||||
void getMyCards(int* theValue)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<5; i++) theValue[i] = myCards[i];
|
||||
}
|
||||
|
||||
void setAllInCondition(bool theValue) {
|
||||
void setAllInCondition(bool theValue)
|
||||
{
|
||||
allInCondition = theValue;
|
||||
}
|
||||
void setLastActionPlayerID(unsigned theValue) {
|
||||
void setLastActionPlayerID(unsigned theValue)
|
||||
{
|
||||
lastActionPlayerID = theValue;
|
||||
}
|
||||
|
||||
int getPot() const {
|
||||
int getPot() const
|
||||
{
|
||||
return pot;
|
||||
}
|
||||
void setPot(int theValue) {
|
||||
void setPot(int theValue)
|
||||
{
|
||||
pot = theValue;
|
||||
}
|
||||
int getSets() const {
|
||||
int getSets() const
|
||||
{
|
||||
return sets;
|
||||
}
|
||||
void setSets(int theValue) {
|
||||
void setSets(int theValue)
|
||||
{
|
||||
sets = theValue;
|
||||
}
|
||||
|
||||
@@ -85,17 +93,21 @@ public:
|
||||
void distributePot(unsigned dealerPosition);
|
||||
void determinePlayerNeedToShowCards();
|
||||
|
||||
std::list<unsigned> getWinners() const {
|
||||
std::list<unsigned> getWinners() const
|
||||
{
|
||||
return winners;
|
||||
}
|
||||
void setWinners(const std::list<unsigned> &w) {
|
||||
void setWinners(const std::list<unsigned> &w)
|
||||
{
|
||||
winners = w;
|
||||
}
|
||||
|
||||
std::list<unsigned> getPlayerNeedToShowCards() const {
|
||||
std::list<unsigned> getPlayerNeedToShowCards() const
|
||||
{
|
||||
return playerNeedToShowCards;
|
||||
}
|
||||
void setPlayerNeedToShowCards(const std::list<unsigned> &p) {
|
||||
void setPlayerNeedToShowCards(const std::list<unsigned> &p)
|
||||
{
|
||||
playerNeedToShowCards = p;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,12 +53,12 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
|
||||
for(it=seatsList->begin(); it!=seatsList->end(); ++it) {
|
||||
(*it)->setHand(this);
|
||||
// set myFlipCards 0
|
||||
(*it)->setMyHoleCardsFlip(0, 0);
|
||||
(*it)->setMyCardsFlip(0, 0);
|
||||
}
|
||||
|
||||
// generate cards and assign to board and player
|
||||
const int NumCards = 52;
|
||||
int cards[NumCards] = {
|
||||
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,
|
||||
@@ -66,50 +66,40 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
|
||||
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
|
||||
50, 51
|
||||
};
|
||||
Tools::ShuffleArrayNonDeterministic(cards, NumCards);
|
||||
int boardCards[5];
|
||||
int playerHoleCards[2];
|
||||
int playerCards[7];
|
||||
Tools::ShuffleArrayNonDeterministic(cardsArray, NumCards);
|
||||
int tempBoardArray[5];
|
||||
int tempPlayerArray[2];
|
||||
int tempPlayerAndBoardArray[7];
|
||||
int bestHandPos[5];
|
||||
int sBluff;
|
||||
|
||||
// board cards
|
||||
for(i=0; i<5; i++) boardCards[i] = cards[i];
|
||||
|
||||
// debug mode
|
||||
if(myLog) myLog->debugMode_getBoardCards(boardCards,myID);
|
||||
|
||||
// prepare whole player hand
|
||||
for(i=0; i<5; i++) playerCards[i+2] = boardCards[i];
|
||||
for(i=0; i<5; i++) {
|
||||
tempBoardArray[i] = cardsArray[i];
|
||||
tempPlayerAndBoardArray[i+2] = cardsArray[i];
|
||||
}
|
||||
|
||||
k = 0;
|
||||
myBoard->setMyCards(boardCards);
|
||||
myBoard->setMyCards(tempBoardArray);
|
||||
for(it=activePlayerList->begin(); it!=activePlayerList->end(); ++it, k++) {
|
||||
|
||||
// hole cards
|
||||
for(j=0; j<2; j++) playerHoleCards[j] = cards[2*k+j+5];
|
||||
(*it)->setMyHoleCards(playerHoleCards);
|
||||
if(myLog) myLog->debugMode_getPlayerCards(playerHoleCards,myID,k); // debug mode
|
||||
(*it)->getMyBestHandPosition(bestHandPos);
|
||||
|
||||
// complete whole player hand
|
||||
for(j=0; j<2; j++) playerCards[j] = playerHoleCards[j];
|
||||
|
||||
// determine cards value
|
||||
int bestHand[4] = { 0,0,0,0 };
|
||||
int playerCardsColor[4] = { 0,0,0,0 };
|
||||
for(j=0; j<7; j++) playerCardsColor[playerCards[j]/13] |= (1 << playerCards[j]%13);
|
||||
(*it)->setMyCardsValueInt(CardsValue::cardsValue(playerCardsColor,bestHand));
|
||||
|
||||
// determine position of best 5 cards
|
||||
int bestHandPos[5];
|
||||
if(CardsValue::bestHandToPosition(bestHand,playerCards,bestHandPos)) {
|
||||
(*it)->setMyBestHandPosition(bestHandPos);
|
||||
} else {
|
||||
LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR getMyBestHandPosition");
|
||||
for(j=0; j<2; j++) {
|
||||
tempPlayerArray[j] = cardsArray[2*k+j+5];
|
||||
tempPlayerAndBoardArray[j] = cardsArray[2*k+j+5];
|
||||
}
|
||||
|
||||
// set round start cash
|
||||
(*it)->setMyCards(tempPlayerArray);
|
||||
(*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray, bestHandPos));
|
||||
(*it)->setMyBestHandPosition(bestHandPos);
|
||||
(*it)->setMyRoundStartCash((*it)->getMyCash());
|
||||
|
||||
// error-check
|
||||
for(j=0; j<5; j++) {
|
||||
if (bestHandPos[j] == -1) {
|
||||
LOG_ERROR(__FILE__ << " (" << __LINE__ << "): ERROR getMyBestHandPosition");
|
||||
}
|
||||
}
|
||||
|
||||
// set sBluff for all players --> TODO for ai-player in internet
|
||||
if((*it)->getMyID() != 0) {
|
||||
Tools::GetRand(1, 100, 1, &sBluff);
|
||||
@@ -118,8 +108,274 @@ LocalHand::LocalHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boost:
|
||||
}
|
||||
}
|
||||
|
||||
// determine dealer, small blind, big blind
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!! DEBUGGER !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //
|
||||
|
||||
if(DEBUG_MODE) {
|
||||
|
||||
//QSqlDatabase *mySqliteLogDb;
|
||||
|
||||
|
||||
|
||||
// myGui->getMyW()->getSession();
|
||||
|
||||
//QSqlDatabase * test = myGui->getMyLog()->getMySqliteLogDb();
|
||||
|
||||
// if(!mySqliteLogDb->open()) {
|
||||
// MyMessageBox::critical(0, tr("ERROR"),mySqliteLogDb->lastError().text().toUtf8().c_str(), QMessageBox::Cancel);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
int temp5Array[5];
|
||||
|
||||
switch(myID) {
|
||||
|
||||
case 1: {
|
||||
|
||||
tempBoardArray[0] = 4;
|
||||
tempBoardArray[1] = 19;
|
||||
tempBoardArray[2] = 20;
|
||||
tempBoardArray[3] = 43;
|
||||
tempBoardArray[4] = 49;
|
||||
|
||||
myBoard->setMyCards(tempBoardArray);
|
||||
|
||||
tempPlayerAndBoardArray[2] = tempBoardArray[0];
|
||||
tempPlayerAndBoardArray[3] = tempBoardArray[1];
|
||||
tempPlayerAndBoardArray[4] = tempBoardArray[2];
|
||||
tempPlayerAndBoardArray[5] = tempBoardArray[3];
|
||||
tempPlayerAndBoardArray[6] = tempBoardArray[4];
|
||||
|
||||
// player0
|
||||
it = seatsList->begin();
|
||||
|
||||
tempPlayerArray[0] = 18;
|
||||
tempPlayerArray[1] = 17;
|
||||
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
|
||||
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
|
||||
|
||||
(*it)->setMyCards(tempPlayerArray);
|
||||
(*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array));
|
||||
|
||||
(*it)->setMyBestHandPosition(temp5Array);
|
||||
|
||||
// player1
|
||||
++it;
|
||||
|
||||
tempPlayerArray[0] = 31;
|
||||
tempPlayerArray[1] = 8;
|
||||
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
|
||||
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
|
||||
|
||||
(*it)->setMyCards(tempPlayerArray);
|
||||
(*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array));
|
||||
|
||||
(*it)->setMyBestHandPosition(temp5Array);
|
||||
|
||||
// player2
|
||||
++it;
|
||||
|
||||
tempPlayerArray[0] = 26;
|
||||
tempPlayerArray[1] = 27;
|
||||
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
|
||||
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
|
||||
|
||||
(*it)->setMyCards(tempPlayerArray);
|
||||
(*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array));
|
||||
|
||||
(*it)->setMyBestHandPosition(temp5Array);
|
||||
|
||||
// player3
|
||||
++it;
|
||||
|
||||
tempPlayerArray[0] = 31;
|
||||
tempPlayerArray[1] = 30;
|
||||
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
|
||||
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
|
||||
|
||||
(*it)->setMyCards(tempPlayerArray);
|
||||
(*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array));
|
||||
|
||||
(*it)->setMyBestHandPosition(temp5Array);
|
||||
|
||||
// player4
|
||||
++it;
|
||||
|
||||
tempPlayerArray[0] = 50;
|
||||
tempPlayerArray[1] = 51;
|
||||
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
|
||||
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
|
||||
|
||||
(*it)->setMyCards(tempPlayerArray);
|
||||
(*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array));
|
||||
|
||||
(*it)->setMyBestHandPosition(temp5Array);
|
||||
|
||||
// player5
|
||||
++it;
|
||||
|
||||
tempPlayerArray[0] = 25;
|
||||
tempPlayerArray[1] = 24;
|
||||
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
|
||||
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
|
||||
|
||||
(*it)->setMyCards(tempPlayerArray);
|
||||
(*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array));
|
||||
|
||||
(*it)->setMyBestHandPosition(temp5Array);
|
||||
|
||||
// player6
|
||||
++it;
|
||||
|
||||
tempPlayerArray[0] = 38;
|
||||
tempPlayerArray[1] = 37;
|
||||
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
|
||||
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
|
||||
|
||||
(*it)->setMyCards(tempPlayerArray);
|
||||
(*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array));
|
||||
|
||||
(*it)->setMyBestHandPosition(temp5Array);
|
||||
|
||||
// player7
|
||||
++it;
|
||||
|
||||
tempPlayerArray[0] = 32;
|
||||
tempPlayerArray[1] = 33;
|
||||
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
|
||||
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
|
||||
|
||||
(*it)->setMyCards(tempPlayerArray);
|
||||
(*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array));
|
||||
|
||||
(*it)->setMyBestHandPosition(temp5Array);
|
||||
|
||||
// player8
|
||||
++it;
|
||||
|
||||
tempPlayerArray[0] = 19;
|
||||
tempPlayerArray[1] = 20;
|
||||
tempPlayerAndBoardArray[0] = tempPlayerArray[0];
|
||||
tempPlayerAndBoardArray[1] = tempPlayerArray[1];
|
||||
|
||||
(*it)->setMyCards(tempPlayerArray);
|
||||
(*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array));
|
||||
|
||||
(*it)->setMyBestHandPosition(temp5Array);
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case 2: {
|
||||
|
||||
/* tempBoardArray[0] = 48;
|
||||
tempBoardArray[1] = 21;
|
||||
tempBoardArray[2] = 4;
|
||||
tempBoardArray[3] = 9;
|
||||
tempBoardArray[4] = 0;
|
||||
|
||||
myBoard->setMyCards(tempBoardArray);
|
||||
|
||||
tempPlayerAndBoardArray[2] = tempBoardArray[0];
|
||||
tempPlayerAndBoardArray[3] = tempBoardArray[1];
|
||||
tempPlayerAndBoardArray[4] = tempBoardArray[2];
|
||||
tempPlayerAndBoardArray[5] = tempBoardArray[3];
|
||||
tempPlayerAndBoardArray[6] = tempBoardArray[4];*/
|
||||
|
||||
// player0
|
||||
it = seatsList->begin();
|
||||
|
||||
// tempPlayerArray[0] = 9;
|
||||
// tempPlayerArray[1] = 5;
|
||||
// tempPlayerAndBoardArray[0] = tempPlayerArray[0];
|
||||
// tempPlayerAndBoardArray[1] = tempPlayerArray[1];
|
||||
//
|
||||
// (*it)->setMyCards(tempPlayerArray);
|
||||
// (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array));
|
||||
//
|
||||
// (*it)->setMyBestHandPosition(temp5Array);
|
||||
|
||||
// player1
|
||||
++it;
|
||||
|
||||
// tempPlayerArray[0] = 47;
|
||||
// tempPlayerArray[1] = 22;
|
||||
// tempPlayerAndBoardArray[0] = tempPlayerArray[0];
|
||||
// tempPlayerAndBoardArray[1] = tempPlayerArray[1];
|
||||
//
|
||||
// (*it)->setMyCards(tempPlayerArray);
|
||||
// (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array));
|
||||
//
|
||||
// (*it)->setMyBestHandPosition(temp5Array);
|
||||
|
||||
// player2
|
||||
++it;
|
||||
|
||||
// tempPlayerArray[0] = 33;
|
||||
// tempPlayerArray[1] = 27;
|
||||
// tempPlayerAndBoardArray[0] = tempPlayerArray[0];
|
||||
// tempPlayerAndBoardArray[1] = tempPlayerArray[1];
|
||||
//
|
||||
// (*it)->setMyCards(tempPlayerArray);
|
||||
// (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array));
|
||||
//
|
||||
// (*it)->setMyBestHandPosition(temp5Array);
|
||||
|
||||
// player3
|
||||
++it;
|
||||
|
||||
// tempPlayerArray[0] = 38;
|
||||
// tempPlayerArray[1] = 22;
|
||||
// tempPlayerAndBoardArray[0] = tempPlayerArray[0];
|
||||
// tempPlayerAndBoardArray[1] = tempPlayerArray[1];
|
||||
//
|
||||
// (*it)->setMyCards(tempPlayerArray);
|
||||
// (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array));
|
||||
//
|
||||
// (*it)->setMyBestHandPosition(temp5Array);
|
||||
|
||||
// player4
|
||||
++it;
|
||||
|
||||
// tempPlayerArray[0] = 25;
|
||||
// tempPlayerArray[1] = 16;
|
||||
// tempPlayerAndBoardArray[0] = tempPlayerArray[0];
|
||||
// tempPlayerAndBoardArray[1] = tempPlayerArray[1];
|
||||
//
|
||||
// (*it)->setMyCards(tempPlayerArray);
|
||||
// (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array));
|
||||
//
|
||||
// (*it)->setMyBestHandPosition(temp5Array);
|
||||
|
||||
// player5
|
||||
++it;
|
||||
|
||||
// tempPlayerArray[0] = 27;
|
||||
// tempPlayerArray[1] = 10;
|
||||
// tempPlayerAndBoardArray[0] = tempPlayerArray[0];
|
||||
// tempPlayerAndBoardArray[1] = tempPlayerArray[1];
|
||||
//
|
||||
// (*it)->setMyCards(tempPlayerArray);
|
||||
// (*it)->setMyCardsValueInt(CardsValue::cardsValue(tempPlayerAndBoardArray,temp5Array));
|
||||
//
|
||||
// (*it)->setMyBestHandPosition(temp5Array);
|
||||
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
// ----------------------------------------
|
||||
|
||||
// determine dealer, SB, BB
|
||||
|
||||
assignButtons();
|
||||
|
||||
setBlinds();
|
||||
|
||||
if(myLog) myLog->logNewHandMsg(myID, dealerPosition+1, smallBlind, smallBlindPosition+1, 2*smallBlind, bigBlindPosition+1, seatsList);
|
||||
@@ -145,6 +401,7 @@ void LocalHand::start()
|
||||
} else {
|
||||
LOG_ERROR(__FILE__ << " (" << __LINE__ << "): Log Error: cannot find sBID or bBID");
|
||||
}
|
||||
myGui->flushLogAtHand();
|
||||
|
||||
// deal cards
|
||||
myGui->dealHoleCards();
|
||||
@@ -159,19 +416,20 @@ void LocalHand::start()
|
||||
void LocalHand::assignButtons()
|
||||
{
|
||||
|
||||
PlayerListIterator seatIt;
|
||||
size_t i;
|
||||
PlayerListIterator it;
|
||||
|
||||
// delete all buttons
|
||||
for (seatIt=seatsList->begin(); seatIt!=seatsList->end(); ++seatIt) {
|
||||
(*seatIt)->setMyButton(BUTTON_NONE);
|
||||
for (it=seatsList->begin(); it!=seatsList->end(); ++it) {
|
||||
(*it)->setMyButton(BUTTON_NONE);
|
||||
}
|
||||
|
||||
// assign dealer button
|
||||
seatIt = getSeatIt(dealerPosition);
|
||||
if(seatIt == seatsList->end()) {
|
||||
it = getSeatIt(dealerPosition);
|
||||
if(it == seatsList->end()) {
|
||||
throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND);
|
||||
}
|
||||
(*seatIt)->setMyButton(BUTTON_DEALER);
|
||||
(*it)->setMyButton(BUTTON_DEALER);
|
||||
|
||||
|
||||
// assign Small Blind next to dealer. ATTENTION: in heads up it is big blind
|
||||
@@ -182,40 +440,40 @@ void LocalHand::assignButtons()
|
||||
throw LocalException(__FILE__, __LINE__, ERR_SEAT_NOT_FOUND);
|
||||
}
|
||||
|
||||
for(size_t i=0; i<seatsList->size(); i++) {
|
||||
for(i=0; i<seatsList->size(); i++) {
|
||||
|
||||
++dealerPositionIt;
|
||||
if(dealerPositionIt == seatsList->end()) dealerPositionIt = seatsList->begin();
|
||||
|
||||
PlayerListIterator activePlayerIt = getActivePlayerIt( (*dealerPositionIt)->getMyUniqueID() );
|
||||
if(activePlayerIt != activePlayerList->end() ) {
|
||||
it = getActivePlayerIt( (*dealerPositionIt)->getMyUniqueID() );
|
||||
if(it != activePlayerList->end() ) {
|
||||
nextActivePlayerFound = true;
|
||||
if(activePlayerList->size() > 2) {
|
||||
//small blind normal
|
||||
(*activePlayerIt)->setMyButton(2);
|
||||
smallBlindPosition = (*activePlayerIt)->getMyUniqueID();
|
||||
(*it)->setMyButton(2);
|
||||
smallBlindPosition = (*it)->getMyUniqueID();
|
||||
} else {
|
||||
//big blind in heads up
|
||||
(*activePlayerIt)->setMyButton(3);
|
||||
bigBlindPosition = (*activePlayerIt)->getMyUniqueID();
|
||||
(*it)->setMyButton(3);
|
||||
bigBlindPosition = (*it)->getMyUniqueID();
|
||||
// lastPlayerAction for showing cards
|
||||
}
|
||||
|
||||
// first player after dealer have to show his cards first (in showdown)
|
||||
lastActionPlayerID = (*activePlayerIt)->getMyUniqueID();
|
||||
lastActionPlayerID = (*it)->getMyUniqueID();
|
||||
myBoard->setLastActionPlayerID(lastActionPlayerID);
|
||||
|
||||
++activePlayerIt;
|
||||
if(activePlayerIt == activePlayerList->end()) activePlayerIt = activePlayerList->begin();
|
||||
++it;
|
||||
if(it == activePlayerList->end()) it = activePlayerList->begin();
|
||||
|
||||
if(activePlayerList->size() > 2) {
|
||||
//big blind normal
|
||||
(*activePlayerIt)->setMyButton(3);
|
||||
bigBlindPosition = (*activePlayerIt)->getMyUniqueID();
|
||||
(*it)->setMyButton(3);
|
||||
bigBlindPosition = (*it)->getMyUniqueID();
|
||||
} else {
|
||||
//small blind in heads up
|
||||
(*activePlayerIt)->setMyButton(2);
|
||||
smallBlindPosition = (*activePlayerIt)->getMyUniqueID();
|
||||
(*it)->setMyButton(2);
|
||||
smallBlindPosition = (*it)->getMyUniqueID();
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -395,11 +653,11 @@ void LocalHand::switchRounds()
|
||||
|
||||
//log board cards for allin
|
||||
if(currentRound >= GAME_STATE_FLOP) {
|
||||
int boardCards[5];
|
||||
int tempBoardCardsArray[5];
|
||||
|
||||
myBoard->getMyCards(boardCards);
|
||||
myGui->logDealBoardCardsMsg(currentRound, boardCards[0], boardCards[1], boardCards[2], boardCards[3], boardCards[4]);
|
||||
if(myLog) myLog->logBoardCards(boardCards);
|
||||
myBoard->getMyCards(tempBoardCardsArray);
|
||||
myGui->logDealBoardCardsMsg(currentRound, tempBoardCardsArray[0], tempBoardCardsArray[1], tempBoardCardsArray[2], tempBoardCardsArray[3], tempBoardCardsArray[4]);
|
||||
if(myLog) myLog->logBoardCards(tempBoardCardsArray);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -438,8 +696,8 @@ void LocalHand::switchRounds()
|
||||
myGui->postRiverAnimation1();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{}
|
||||
default: {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -51,111 +51,142 @@ public:
|
||||
|
||||
void start();
|
||||
|
||||
PlayerList getSeatsList() const {
|
||||
PlayerList getSeatsList() const
|
||||
{
|
||||
return seatsList;
|
||||
}
|
||||
PlayerList getActivePlayerList() const {
|
||||
PlayerList getActivePlayerList() const
|
||||
{
|
||||
return activePlayerList;
|
||||
}
|
||||
PlayerList getRunningPlayerList() const {
|
||||
PlayerList getRunningPlayerList() const
|
||||
{
|
||||
return runningPlayerList;
|
||||
}
|
||||
|
||||
boost::shared_ptr<BoardInterface> getBoard() const {
|
||||
boost::shared_ptr<BoardInterface> getBoard() const
|
||||
{
|
||||
return myBoard;
|
||||
}
|
||||
boost::shared_ptr<BeRoInterface> getPreflop() const {
|
||||
boost::shared_ptr<BeRoInterface> getPreflop() const
|
||||
{
|
||||
return myBeRo[GAME_STATE_PREFLOP];
|
||||
}
|
||||
boost::shared_ptr<BeRoInterface> getFlop() const {
|
||||
boost::shared_ptr<BeRoInterface> getFlop() const
|
||||
{
|
||||
return myBeRo[GAME_STATE_FLOP];
|
||||
}
|
||||
boost::shared_ptr<BeRoInterface> getTurn() const {
|
||||
boost::shared_ptr<BeRoInterface> getTurn() const
|
||||
{
|
||||
return myBeRo[GAME_STATE_TURN];
|
||||
}
|
||||
boost::shared_ptr<BeRoInterface> getRiver() const {
|
||||
boost::shared_ptr<BeRoInterface> getRiver() const
|
||||
{
|
||||
return myBeRo[GAME_STATE_RIVER];
|
||||
}
|
||||
GuiInterface* getGuiInterface() const {
|
||||
GuiInterface* getGuiInterface() const
|
||||
{
|
||||
return myGui;
|
||||
}
|
||||
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const {
|
||||
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const
|
||||
{
|
||||
return myBeRo[currentRound];
|
||||
}
|
||||
|
||||
Log* getLog() const {
|
||||
Log* getLog() const
|
||||
{
|
||||
return myLog;
|
||||
}
|
||||
|
||||
void setMyID(int theValue) {
|
||||
void setMyID(int theValue)
|
||||
{
|
||||
myID = theValue;
|
||||
}
|
||||
int getMyID() const {
|
||||
int getMyID() const
|
||||
{
|
||||
return myID;
|
||||
}
|
||||
|
||||
void setStartQuantityPlayers(int theValue) {
|
||||
void setStartQuantityPlayers(int theValue)
|
||||
{
|
||||
startQuantityPlayers = theValue;
|
||||
}
|
||||
int getStartQuantityPlayers() const {
|
||||
int getStartQuantityPlayers() const
|
||||
{
|
||||
return startQuantityPlayers;
|
||||
}
|
||||
|
||||
void setCurrentRound(GameState theValue) {
|
||||
void setCurrentRound(GameState theValue)
|
||||
{
|
||||
currentRound = theValue;
|
||||
if(myLog) myLog->setCurrentRound(currentRound);
|
||||
}
|
||||
GameState getCurrentRound() const {
|
||||
GameState getCurrentRound() const
|
||||
{
|
||||
return currentRound;
|
||||
}
|
||||
GameState getRoundBeforePostRiver() const {
|
||||
GameState getRoundBeforePostRiver() const
|
||||
{
|
||||
return roundBeforePostRiver;
|
||||
}
|
||||
|
||||
void setDealerPosition(int theValue) {
|
||||
void setDealerPosition(int theValue)
|
||||
{
|
||||
dealerPosition = theValue;
|
||||
}
|
||||
int getDealerPosition() const {
|
||||
int getDealerPosition() const
|
||||
{
|
||||
return dealerPosition;
|
||||
}
|
||||
|
||||
void setSmallBlind(int theValue) {
|
||||
void setSmallBlind(int theValue)
|
||||
{
|
||||
smallBlind = theValue;
|
||||
}
|
||||
int getSmallBlind() const {
|
||||
int getSmallBlind() const
|
||||
{
|
||||
return smallBlind;
|
||||
}
|
||||
|
||||
void setAllInCondition(bool theValue) {
|
||||
void setAllInCondition(bool theValue)
|
||||
{
|
||||
allInCondition = theValue;
|
||||
}
|
||||
bool getAllInCondition() const {
|
||||
bool getAllInCondition() const
|
||||
{
|
||||
return allInCondition;
|
||||
}
|
||||
|
||||
void setStartCash(int theValue) {
|
||||
void setStartCash(int theValue)
|
||||
{
|
||||
startCash = theValue;
|
||||
}
|
||||
int getStartCash() const {
|
||||
int getStartCash() const
|
||||
{
|
||||
return startCash;
|
||||
}
|
||||
|
||||
void setPreviousPlayerID(int theValue) {
|
||||
void setPreviousPlayerID(int theValue)
|
||||
{
|
||||
previousPlayerID = theValue;
|
||||
}
|
||||
int getPreviousPlayerID() const {
|
||||
int getPreviousPlayerID() const
|
||||
{
|
||||
return previousPlayerID;
|
||||
}
|
||||
|
||||
void setLastActionPlayerID ( unsigned theValue );
|
||||
unsigned getLastActionPlayerID() const {
|
||||
unsigned getLastActionPlayerID() const
|
||||
{
|
||||
return lastActionPlayerID;
|
||||
}
|
||||
|
||||
void setCardsShown(bool theValue) {
|
||||
void setCardsShown(bool theValue)
|
||||
{
|
||||
cardsShown = theValue;
|
||||
}
|
||||
bool getCardsShown() const {
|
||||
bool getCardsShown() const
|
||||
{
|
||||
return cardsShown;
|
||||
}
|
||||
|
||||
|
||||
+1945
-744
File diff suppressed because it is too large
Load Diff
@@ -48,210 +48,258 @@ public:
|
||||
|
||||
~LocalPlayer();
|
||||
|
||||
void setHand(HandInterface *theValue) {
|
||||
currentHand = theValue;
|
||||
}
|
||||
int getMyID() const {
|
||||
void setHand(HandInterface *);
|
||||
|
||||
int getMyID() const
|
||||
{
|
||||
return myID;
|
||||
}
|
||||
unsigned getMyUniqueID() const {
|
||||
unsigned getMyUniqueID() const
|
||||
{
|
||||
return myUniqueID;
|
||||
}
|
||||
void setMyUniqueID(unsigned newId) {
|
||||
void setMyUniqueID(unsigned newId)
|
||||
{
|
||||
myUniqueID = newId;
|
||||
}
|
||||
|
||||
void setMyGuid(const std::string &theValue) {
|
||||
void setMyGuid(const std::string &theValue)
|
||||
{
|
||||
myGuid = theValue;
|
||||
}
|
||||
|
||||
std::string getMyGuid() const {
|
||||
std::string getMyGuid() const
|
||||
{
|
||||
return myGuid;
|
||||
}
|
||||
|
||||
PlayerType getMyType() const {
|
||||
PlayerType getMyType() const
|
||||
{
|
||||
return myType;
|
||||
}
|
||||
|
||||
void setMyDude(int theValue) {
|
||||
void setMyDude(int theValue)
|
||||
{
|
||||
myDude = theValue;
|
||||
}
|
||||
int getMyDude() const {
|
||||
int getMyDude() const
|
||||
{
|
||||
return myDude;
|
||||
}
|
||||
|
||||
void setMyDude4(int theValue) {
|
||||
void setMyDude4(int theValue)
|
||||
{
|
||||
myDude4 = theValue;
|
||||
}
|
||||
int getMyDude4() const {
|
||||
int getMyDude4() const
|
||||
{
|
||||
return myDude4;
|
||||
}
|
||||
|
||||
void setMyName(const std::string& theValue) {
|
||||
void setMyName(const std::string& theValue)
|
||||
{
|
||||
myName = theValue;
|
||||
}
|
||||
std::string getMyName() const {
|
||||
std::string getMyName() const
|
||||
{
|
||||
return myName;
|
||||
}
|
||||
|
||||
void setMyAvatar(const std::string& theValue) {
|
||||
void setMyAvatar(const std::string& theValue)
|
||||
{
|
||||
myAvatar = theValue;
|
||||
}
|
||||
std::string getMyAvatar() const {
|
||||
std::string getMyAvatar() const
|
||||
{
|
||||
return myAvatar;
|
||||
}
|
||||
|
||||
void setMyCash(int theValue) {
|
||||
void setMyCash(int theValue)
|
||||
{
|
||||
myCash = theValue;
|
||||
}
|
||||
int getMyCash() const {
|
||||
int getMyCash() const
|
||||
{
|
||||
return myCash;
|
||||
}
|
||||
|
||||
void setMySet(int theValue) {
|
||||
void setMySet(int theValue)
|
||||
{
|
||||
myLastRelativeSet = theValue;
|
||||
mySet += theValue;
|
||||
myCash -= theValue;
|
||||
}
|
||||
void setMySetAbsolute(int theValue) {
|
||||
void setMySetAbsolute(int theValue)
|
||||
{
|
||||
mySet = theValue;
|
||||
}
|
||||
void setMySetNull() {
|
||||
void setMySetNull()
|
||||
{
|
||||
mySet = 0;
|
||||
myLastRelativeSet = 0;
|
||||
}
|
||||
int getMySet() const {
|
||||
int getMySet() const
|
||||
{
|
||||
return mySet;
|
||||
}
|
||||
int getMyLastRelativeSet() const {
|
||||
int getMyLastRelativeSet() const
|
||||
{
|
||||
return myLastRelativeSet;
|
||||
}
|
||||
|
||||
void setMyAction(PlayerAction theValue, bool human = 0) {
|
||||
void setMyAction(PlayerAction theValue, bool human = 0)
|
||||
{
|
||||
myAction = theValue;
|
||||
// logging for seat 0
|
||||
if(myAction && human) currentHand->getGuiInterface()->logPlayerActionMsg(myName, myAction, myLastRelativeSet);
|
||||
}
|
||||
PlayerAction getMyAction() const {
|
||||
PlayerAction getMyAction() const
|
||||
{
|
||||
return myAction;
|
||||
}
|
||||
|
||||
void setMyButton(int theValue) {
|
||||
void setMyButton(int theValue)
|
||||
{
|
||||
myButton = theValue;
|
||||
}
|
||||
int getMyButton() const {
|
||||
int getMyButton() const
|
||||
{
|
||||
return myButton;
|
||||
}
|
||||
|
||||
void setMyActiveStatus(bool theValue) {
|
||||
void setMyActiveStatus(bool theValue)
|
||||
{
|
||||
myActiveStatus = theValue;
|
||||
}
|
||||
bool getMyActiveStatus() const {
|
||||
bool getMyActiveStatus() const
|
||||
{
|
||||
return myActiveStatus;
|
||||
}
|
||||
|
||||
void setMyStayOnTableStatus(bool theValue) {
|
||||
void setMyStayOnTableStatus(bool theValue)
|
||||
{
|
||||
myStayOnTableStatus = theValue;
|
||||
}
|
||||
bool getMyStayOnTableStatus() const {
|
||||
bool getMyStayOnTableStatus() const
|
||||
{
|
||||
return myStayOnTableStatus;
|
||||
}
|
||||
|
||||
void setMyHoleCards(int* theValue) {
|
||||
void setMyCards(int* theValue)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<2; i++) myHoleCards[i] = theValue[i];
|
||||
for(i=0; i<2; i++) myCards[i] = theValue[i];
|
||||
}
|
||||
void getMyHoleCards(int* theValue) const {
|
||||
void getMyCards(int* theValue) const
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<2; i++) theValue[i] = myHoleCards[i];
|
||||
for(i=0; i<2; i++) theValue[i] = myCards[i];
|
||||
}
|
||||
|
||||
void setMyTurn(bool theValue) {
|
||||
void setMyTurn(bool theValue)
|
||||
{
|
||||
myTurn = theValue;
|
||||
}
|
||||
bool getMyTurn() const {
|
||||
bool getMyTurn() const
|
||||
{
|
||||
return myTurn;
|
||||
}
|
||||
|
||||
void setMyHoleCardsFlip(bool theValue, int state) {
|
||||
myHoleCardsFlip = theValue;
|
||||
void setMyCardsFlip(bool theValue, int state)
|
||||
{
|
||||
myCardsFlip = theValue;
|
||||
// log flipping cards
|
||||
if(myHoleCardsFlip) {
|
||||
if(myCardsFlip) {
|
||||
switch(state) {
|
||||
case 1:
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myHoleCards[0], myHoleCards[1], myCardsValueInt);
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1], myCardsValueInt);
|
||||
break;
|
||||
case 2:
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myHoleCards[0], myHoleCards[1]);
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1]);
|
||||
break;
|
||||
case 3:
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myHoleCards[0], myHoleCards[1], myCardsValueInt, "has");
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1], myCardsValueInt, "has");
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool getMyHoleCardsFlip() const {
|
||||
return myHoleCardsFlip;
|
||||
bool getMyCardsFlip() const
|
||||
{
|
||||
return myCardsFlip;
|
||||
}
|
||||
|
||||
void setMyCardsValueInt(int theValue) {
|
||||
void setMyCardsValueInt(int theValue)
|
||||
{
|
||||
myCardsValueInt = theValue;
|
||||
}
|
||||
int getMyCardsValueInt() const {
|
||||
int getMyCardsValueInt() const
|
||||
{
|
||||
return myCardsValueInt;
|
||||
}
|
||||
|
||||
void setLogHoleCardsDone(bool theValue) {
|
||||
void setLogHoleCardsDone(bool theValue)
|
||||
{
|
||||
logHoleCardsDone = theValue;
|
||||
}
|
||||
|
||||
bool getLogHoleCardsDone() const {
|
||||
bool getLogHoleCardsDone() const
|
||||
{
|
||||
return logHoleCardsDone;
|
||||
}
|
||||
|
||||
void setMyBestHandPosition(int* theValue) {
|
||||
void setMyBestHandPosition(int* theValue)
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
myBestHandPosition[i] = theValue[i];
|
||||
}
|
||||
void getMyBestHandPosition(int* theValue) const {
|
||||
void getMyBestHandPosition(int* theValue) const
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
theValue[i] = myBestHandPosition[i];
|
||||
}
|
||||
|
||||
void setMyRoundStartCash(int theValue) {
|
||||
void setMyRoundStartCash(int theValue)
|
||||
{
|
||||
myRoundStartCash = theValue;
|
||||
}
|
||||
int getMyRoundStartCash() const {
|
||||
int getMyRoundStartCash() const
|
||||
{
|
||||
return myRoundStartCash;
|
||||
}
|
||||
|
||||
void setLastMoneyWon ( int theValue ) {
|
||||
void setLastMoneyWon ( int theValue )
|
||||
{
|
||||
lastMoneyWon = theValue;
|
||||
}
|
||||
int getLastMoneyWon() const {
|
||||
int getLastMoneyWon() const
|
||||
{
|
||||
return lastMoneyWon;
|
||||
}
|
||||
|
||||
void setMyAverageSets(int theValue) {
|
||||
void setMyAverageSets(int theValue)
|
||||
{
|
||||
myAverageSets[0] = myAverageSets[1];
|
||||
myAverageSets[1] = myAverageSets[2];
|
||||
myAverageSets[2] = myAverageSets[3];
|
||||
myAverageSets[3] = theValue;
|
||||
}
|
||||
int getMyAverageSets() const {
|
||||
int getMyAverageSets() const
|
||||
{
|
||||
return (myAverageSets[0]+myAverageSets[1]+myAverageSets[2]+myAverageSets[3])/4;
|
||||
}
|
||||
|
||||
void setMyAggressive(bool theValue) {
|
||||
void setMyAggressive(bool theValue)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<6; i++) {
|
||||
myAggressive[i] = myAggressive[i+1];
|
||||
}
|
||||
myAggressive[6] = theValue;
|
||||
}
|
||||
int getMyAggressive() const {
|
||||
int getMyAggressive() const
|
||||
{
|
||||
int i, sum = 0;
|
||||
for(i=0; i<7; i++) {
|
||||
sum += myAggressive[i];
|
||||
@@ -259,17 +307,21 @@ public:
|
||||
return sum;
|
||||
}
|
||||
|
||||
void setSBluff ( int theValue ) {
|
||||
void setSBluff ( int theValue )
|
||||
{
|
||||
sBluff = theValue;
|
||||
}
|
||||
int getSBluff() const {
|
||||
int getSBluff() const
|
||||
{
|
||||
return sBluff;
|
||||
}
|
||||
|
||||
void setSBluffStatus ( bool theValue ) {
|
||||
void setSBluffStatus ( bool theValue )
|
||||
{
|
||||
sBluffStatus = theValue;
|
||||
}
|
||||
bool getSBluffStatus() const {
|
||||
bool getSBluffStatus() const
|
||||
{
|
||||
return sBluffStatus;
|
||||
}
|
||||
|
||||
@@ -282,10 +334,10 @@ public:
|
||||
void turnEngine();
|
||||
void riverEngine();
|
||||
|
||||
// void preflopEngine3();
|
||||
// void flopEngine3();
|
||||
// void turnEngine3();
|
||||
// void riverEngine3();
|
||||
void preflopEngine3();
|
||||
void flopEngine3();
|
||||
void turnEngine3();
|
||||
void riverEngine3();
|
||||
|
||||
int flopCardsValue(int*);
|
||||
int turnCardsValue(int*);
|
||||
@@ -329,7 +381,7 @@ private:
|
||||
int myNiveau[3];
|
||||
bool logHoleCardsDone;
|
||||
|
||||
int myHoleCards[2];
|
||||
int myCards[2];
|
||||
int myCash;
|
||||
int mySet;
|
||||
int myLastRelativeSet;
|
||||
@@ -338,7 +390,7 @@ private:
|
||||
bool myActiveStatus; // 0 = inactive, 1 = active
|
||||
bool myStayOnTableStatus; // 0 = left, 1 = stay
|
||||
bool myTurn; // 0 = no, 1 = yes
|
||||
bool myHoleCardsFlip; // 0 = cards are not fliped, 1 = cards are already flipped,
|
||||
bool myCardsFlip; // 0 = cards are not fliped, 1 = cards are already flipped,
|
||||
int myRoundStartCash;
|
||||
int lastMoneyWon;
|
||||
|
||||
|
||||
@@ -51,7 +51,8 @@ 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) {
|
||||
unsigned operator()(unsigned i)
|
||||
{
|
||||
boost::uniform_int<> rng(0, i - 1);
|
||||
return rng(_state);
|
||||
}
|
||||
@@ -82,3 +83,4 @@ void Tools::GetRand(int minValue, int maxValue, unsigned count, int *out)
|
||||
*startPtr++ = gen();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,8 @@ boost::thread_specific_ptr<boost::mt19937> g_rand_state;
|
||||
|
||||
struct det_rng : std::unary_function<unsigned, unsigned> {
|
||||
boost::mt19937 &_state;
|
||||
unsigned operator()(unsigned i) {
|
||||
unsigned operator()(unsigned i)
|
||||
{
|
||||
boost::uniform_int<> rng(0, i - 1);
|
||||
return rng(_state);
|
||||
}
|
||||
|
||||
+392
-510
File diff suppressed because it is too large
Load Diff
+4
-14
@@ -66,21 +66,13 @@ public:
|
||||
void logAfterGame();
|
||||
// void closeLogDbAtExit();
|
||||
|
||||
void debugMode_getStartSmallBlind(int* startSmallBlind, int* currentSmallBlind);
|
||||
void debugMode_getStartDealerPosition(unsigned* dealerPosition);
|
||||
void debugMode_getBoardCards(int* tempBoardArray, int handID);
|
||||
void debugMode_getPlayerCards(int* tempPlayerArray, int handID, int seatID);
|
||||
void debugMode_getPlayerStartCash(int* startCash, int seatID);
|
||||
void debugMode_getPlayerAction(PlayerAction* playerAction, int* bet, int* raise, GameState gameState, int handID, int seatID, int mySet);
|
||||
bool getDebugMode() {
|
||||
return debug_mode;
|
||||
}
|
||||
|
||||
void setCurrentRound(GameState theValue) {
|
||||
void setCurrentRound(GameState theValue)
|
||||
{
|
||||
currentRound = theValue;
|
||||
}
|
||||
|
||||
std::string getMySqliteLogFileName() {
|
||||
std::string getMySqliteLogFileName()
|
||||
{
|
||||
return mySqliteLogFileName.directory_string();
|
||||
}
|
||||
|
||||
@@ -95,8 +87,6 @@ private:
|
||||
int currentHandID;
|
||||
GameState currentRound;
|
||||
std::string sql;
|
||||
|
||||
bool debug_mode;
|
||||
};
|
||||
|
||||
#endif // LOG_H
|
||||
|
||||
@@ -44,7 +44,7 @@ ClientHand::ClientHand(boost::shared_ptr<EngineFactory> f, GuiInterface *g, boos
|
||||
for(it=seatsList->begin(); it!=seatsList->end(); ++it) {
|
||||
(*it)->setHand(this);
|
||||
// myFlipCards auf 0 setzen
|
||||
(*it)->setMyHoleCardsFlip(0, 0);
|
||||
(*it)->setMyCardsFlip(0, 0);
|
||||
}
|
||||
|
||||
// roundStartCashArray fuellen
|
||||
|
||||
@@ -63,7 +63,8 @@ public:
|
||||
GuiInterface* getGuiInterface() const;
|
||||
boost::shared_ptr<BeRoInterface> getCurrentBeRo() const;
|
||||
|
||||
Log* getLog() const {
|
||||
Log* getLog() const
|
||||
{
|
||||
return myLog;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,12 +38,12 @@ using namespace std;
|
||||
ClientPlayer::ClientPlayer(ConfigFile *c, int id, unsigned uniqueId, PlayerType type, std::string name, std::string avatar, int sC, bool aS, bool sotS, int mB)
|
||||
: PlayerInterface(), myConfig(c), currentHand(0), myID(id), myUniqueID(uniqueId), myType(type),
|
||||
myName(name), myAvatar(avatar), myDude(0), myDude4(0), myCardsValueInt(0), myOdds(-1.0), logHoleCardsDone(false), myCash(sC), mySet(0), myLastRelativeSet(0),
|
||||
myAction(PLAYER_ACTION_NONE), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(sotS), myTurn(false), myHoleCardsFlip(false), myRoundStartCash(0),
|
||||
myAction(PLAYER_ACTION_NONE), myButton(mB), myActiveStatus(aS), myStayOnTableStatus(sotS), myTurn(false), myCardsFlip(false), myRoundStartCash(0),
|
||||
lastMoneyWon(0), sBluff(0), sBluffStatus(false), m_isSessionActive(false), m_isKicked(false), m_isMuted(false)
|
||||
{
|
||||
myBestHandPosition[0] = myBestHandPosition[1] = myBestHandPosition[2] = myBestHandPosition[3] = myBestHandPosition[4] = 0;
|
||||
myNiveau[0] = myNiveau[1] = myNiveau[2] = 0;
|
||||
myHoleCards[0] = myHoleCards[1] = 0;
|
||||
myCards[0] = myCards[1] = 0;
|
||||
myAverageSets[0] = myAverageSets[1] = myAverageSets[2] = myAverageSets[3] = 0;
|
||||
myAggressive[0] = myAggressive[1] = myAggressive[2] = myAggressive[3] = myAggressive[4] = myAggressive[5] = myAggressive[6] = false;
|
||||
}
|
||||
@@ -264,19 +264,19 @@ ClientPlayer::getMyStayOnTableStatus() const
|
||||
}
|
||||
|
||||
void
|
||||
ClientPlayer::setMyHoleCards(int* theValue)
|
||||
ClientPlayer::setMyCards(int* theValue)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
for (int i = 0; i < 2; i++)
|
||||
myHoleCards[i] = theValue[i];
|
||||
myCards[i] = theValue[i];
|
||||
}
|
||||
|
||||
void
|
||||
ClientPlayer::getMyHoleCards(int* theValue) const
|
||||
ClientPlayer::getMyCards(int* theValue) const
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
for (int i = 0; i < 2; i++)
|
||||
theValue[i] = myHoleCards[i];
|
||||
theValue[i] = myCards[i];
|
||||
}
|
||||
|
||||
void
|
||||
@@ -294,21 +294,21 @@ ClientPlayer::getMyTurn() const
|
||||
}
|
||||
|
||||
void
|
||||
ClientPlayer::setMyHoleCardsFlip(bool theValue, int state)
|
||||
ClientPlayer::setMyCardsFlip(bool theValue, int state)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
myHoleCardsFlip = theValue;
|
||||
myCardsFlip = theValue;
|
||||
// log flipping cards
|
||||
if (myHoleCardsFlip) {
|
||||
if (myCardsFlip) {
|
||||
switch(state) {
|
||||
case 1:
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myHoleCards[0], myHoleCards[1], myCardsValueInt);
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1], myCardsValueInt);
|
||||
break;
|
||||
case 2:
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myHoleCards[0], myHoleCards[1]);
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1]);
|
||||
break;
|
||||
case 3:
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myHoleCards[0], myHoleCards[1], myCardsValueInt, "has");
|
||||
currentHand->getGuiInterface()->logFlipHoleCardsMsg(myName, myCards[0], myCards[1], myCardsValueInt, "has");
|
||||
break;
|
||||
default:
|
||||
;
|
||||
@@ -317,10 +317,10 @@ ClientPlayer::setMyHoleCardsFlip(bool theValue, int state)
|
||||
}
|
||||
|
||||
bool
|
||||
ClientPlayer::getMyHoleCardsFlip() const
|
||||
ClientPlayer::getMyCardsFlip() const
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
return myHoleCardsFlip;
|
||||
return myCardsFlip;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -89,14 +89,14 @@ public:
|
||||
void setMyStayOnTableStatus(bool theValue);
|
||||
bool getMyStayOnTableStatus() const;
|
||||
|
||||
void setMyHoleCards(int* theValue);
|
||||
void getMyHoleCards(int* theValue) const;
|
||||
void setMyCards(int* theValue);
|
||||
void getMyCards(int* theValue) const;
|
||||
|
||||
void setMyTurn(bool theValue);
|
||||
bool getMyTurn() const;
|
||||
|
||||
void setMyHoleCardsFlip(bool theValue, int state);
|
||||
bool getMyHoleCardsFlip() const;
|
||||
void setMyCardsFlip(bool theValue, int state);
|
||||
bool getMyCardsFlip() const;
|
||||
|
||||
void setMyCardsValueInt(int theValue);
|
||||
int getMyCardsValueInt() const;
|
||||
@@ -156,7 +156,8 @@ public:
|
||||
bool checkIfINeedToShowCards();
|
||||
|
||||
void markRemoteAction() {}
|
||||
unsigned getTimeSecSinceLastRemoteAction() const {
|
||||
unsigned getTimeSecSinceLastRemoteAction() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -184,7 +185,7 @@ private:
|
||||
int myNiveau[3];
|
||||
bool logHoleCardsDone;
|
||||
|
||||
int myHoleCards[2];
|
||||
int myCards[2];
|
||||
int myCash;
|
||||
int mySet;
|
||||
int myLastRelativeSet;
|
||||
@@ -193,7 +194,7 @@ private:
|
||||
bool myActiveStatus; // 0 = inactive, 1 = active
|
||||
bool myStayOnTableStatus; // 0 = left, 1 = stay
|
||||
bool myTurn; // 0 = no, 1 = yes
|
||||
bool myHoleCardsFlip; // 0 = cards are not fliped, 1 = cards are already flipped,
|
||||
bool myCardsFlip; // 0 = cards are not fliped, 1 = cards are already flipped,
|
||||
int myRoundStartCash;
|
||||
int lastMoneyWon;
|
||||
|
||||
|
||||
@@ -87,14 +87,14 @@ public:
|
||||
virtual void setMyStayOnTableStatus(bool theValue) =0;
|
||||
virtual bool getMyStayOnTableStatus() const =0;
|
||||
|
||||
virtual void setMyHoleCards(int* theValue) =0;
|
||||
virtual void getMyHoleCards(int* theValue) const =0;
|
||||
virtual void setMyCards(int* theValue) =0;
|
||||
virtual void getMyCards(int* theValue) const =0;
|
||||
|
||||
virtual void setMyTurn(bool theValue) =0;
|
||||
virtual bool getMyTurn() const =0;
|
||||
|
||||
virtual void setMyHoleCardsFlip(bool theValue, int state) =0;
|
||||
virtual bool getMyHoleCardsFlip() const =0;
|
||||
virtual void setMyCardsFlip(bool theValue, int state) =0;
|
||||
virtual bool getMyCardsFlip() const =0;
|
||||
|
||||
virtual void setMyCardsValueInt(int theValue) =0;
|
||||
virtual int getMyCardsValueInt() const =0;
|
||||
|
||||
+6
-3
@@ -37,12 +37,16 @@
|
||||
#define MIN_GUI_SPEED 1
|
||||
#define MAX_GUI_SPEED 11
|
||||
|
||||
#define DEBUG_MODE 0
|
||||
#define SQLITE_LOG 1
|
||||
#define HTML_LOG 0
|
||||
|
||||
#define POKERTH_VERSION_MAJOR 1
|
||||
#define POKERTH_VERSION_MINOR 11
|
||||
#define POKERTH_VERSION ((POKERTH_VERSION_MAJOR << 8) | POKERTH_VERSION_MINOR)
|
||||
|
||||
#define POKERTH_BETA_REVISION 0
|
||||
#define POKERTH_BETA_RELEASE_STRING "1.1.1"
|
||||
#define POKERTH_BETA_RELEASE_STRING "1.1.2"
|
||||
|
||||
#define SQLITE_LOG_VERSION 1
|
||||
|
||||
@@ -54,8 +58,7 @@
|
||||
enum ServerMode {
|
||||
SERVER_MODE_LAN,
|
||||
SERVER_MODE_INTERNET_NOAUTH,
|
||||
SERVER_MODE_INTERNET_AUTH,
|
||||
SERVER_MODE_LAN_LOCAL
|
||||
SERVER_MODE_INTERNET_AUTH
|
||||
};
|
||||
|
||||
enum ServerTransportProtocol {
|
||||
|
||||
@@ -105,6 +105,8 @@ void ServerGuiWrapper::logNewBlindsSetsMsg(int /*sbSet*/, int /*bbSet*/, std::st
|
||||
void ServerGuiWrapper::logDealBoardCardsMsg(int /*roundID*/, int /*card1*/, int /*card2*/, int /*card3*/, int /*card4*/, int /*card5*/) {}
|
||||
void ServerGuiWrapper::logFlipHoleCardsMsg(std::string /*playerName*/, int /*card1*/, int /*card2*/, int /*cardsValueInt*/, std::string /*showHas*/) {}
|
||||
void ServerGuiWrapper::logPlayerWinGame(std::string /*playerName*/, int /*gameID*/) {}
|
||||
void ServerGuiWrapper::flushLogAtGame(int /*gameID*/) {}
|
||||
void ServerGuiWrapper::flushLogAtHand() {}
|
||||
|
||||
void ServerGuiWrapper::SignalNetClientServerListAdd(unsigned serverId)
|
||||
{
|
||||
|
||||
@@ -48,10 +48,12 @@ public:
|
||||
boost::shared_ptr<Session> getSession();
|
||||
void setSession(boost::shared_ptr<Session> session);
|
||||
|
||||
gameTableImpl* getMyW() const {
|
||||
gameTableImpl* getMyW() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
guiLog* getMyGuiLog() const {
|
||||
guiLog* getMyGuiLog() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -118,6 +120,8 @@ public:
|
||||
void logDealBoardCardsMsg(int roundID, int card1, int card2, int card3, int card4 = -1, int card5 = -1) ;
|
||||
void logFlipHoleCardsMsg(std::string playerName, int card1, int card2, int cardsValueInt = -1, std::string showHas = "shows") ;
|
||||
void logPlayerWinGame(std::string playerName, int gameID);
|
||||
void flushLogAtGame(int gameID);
|
||||
void flushLogAtHand();
|
||||
|
||||
void SignalNetClientConnect(int actionID);
|
||||
void SignalNetClientGameInfo(int actionID);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user