From fc435f276995961eccd7aef8fb6996ed9de7af11 Mon Sep 17 00:00:00 2001 From: doitux Date: Sat, 29 Sep 2007 00:08:19 +0000 Subject: [PATCH] exceptions & bugfixes --- pokerth_lib.pro | 5 + pokerth_server.pro | 150 +++++++++++---------- src/core/common/pokerthexception.cpp | 25 ++++ src/core/pokerthexception.h | 41 ++++++ src/engine/local_engine/localboard.cpp | 1 + src/engine/local_engine/localexception.cpp | 26 ++++ src/engine/local_engine/localexception.h | 35 +++++ src/engine/local_engine/localhand.cpp | 44 +++--- src/engine/local_engine/localplayer.cpp | 28 ++-- src/game.cpp | 4 +- src/game.h | 2 +- src/gui/qt/mainwindow.ui | 2 +- src/gui/qt/mainwindow/mainwindowimpl.cpp | 4 +- src/net/netexception.h | 12 +- src/session.cpp | 1 + 15 files changed, 260 insertions(+), 120 deletions(-) create mode 100644 src/core/common/pokerthexception.cpp create mode 100644 src/core/pokerthexception.h create mode 100644 src/engine/local_engine/localexception.cpp create mode 100644 src/engine/local_engine/localexception.h diff --git a/pokerth_lib.pro b/pokerth_lib.pro index cd67f52f..adf778a4 100644 --- a/pokerth_lib.pro +++ b/pokerth_lib.pro @@ -46,6 +46,7 @@ HEADERS += \ src/core/thread.h \ src/core/crypthelper.h \ src/core/avatarmanager.h \ + src/core/pokerthexception.h \ src/engine/boardinterface.h \ src/engine/enginefactory.h \ src/engine/handinterface.h \ @@ -70,6 +71,7 @@ HEADERS += \ src/net/socket_startup.h \ src/net/irccallback.h \ src/net/ircthread.h \ + src/net/netexception.h \ src/core/tinyxml/tinystr.h \ src/core/tinyxml/tinyxml.h \ src/core/libircclient/include/libircclient.h \ @@ -86,6 +88,7 @@ HEADERS += \ src/engine/local_engine/localberopostriver.h \ src/engine/local_engine/tools.h \ src/engine/local_engine/localbero.h \ + src/engine/local_engine/localexception.h \ src/engine/network_engine/clientboard.h \ src/engine/network_engine/clientenginefactory.h \ src/engine/network_engine/clienthand.h \ @@ -110,6 +113,7 @@ SOURCES += \ src/core/common/thread.cpp \ src/core/common/crypthelper.cpp \ src/core/common/avatarmanager.cpp \ + src/core/common/pokerthexception.cpp \ src/core/tinyxml/tinystr.cpp \ src/core/tinyxml/tinyxml.cpp \ src/core/tinyxml/tinyxmlerror.cpp \ @@ -127,6 +131,7 @@ SOURCES += \ src/engine/local_engine/localberopostriver.cpp \ src/engine/local_engine/tools.cpp \ src/engine/local_engine/localbero.cpp \ + src/engine/local_engine/localexception.cpp \ src/engine/network_engine/clientboard.cpp \ src/engine/network_engine/clientenginefactory.cpp \ src/engine/network_engine/clienthand.cpp \ diff --git a/pokerth_server.pro b/pokerth_server.pro index ad4a36ea..da911828 100644 --- a/pokerth_server.pro +++ b/pokerth_server.pro @@ -1,12 +1,12 @@ # QMake pro-file for the PokerTH dedicated server - + TEMPLATE = app CODECFORSRC = UTF-8 - + INSTALLS += TARGET TARGET.files += bin/* TARGET.path = /usr/bin/ - + INCLUDEPATH += . \ src \ src/engine \ @@ -86,77 +86,81 @@ HEADERS += \ src/gui/qttoolsinterface.h \ src/gui/qt/qttools/qttoolswrapper.h \ src/gui/qt/qttools/qthelper/qthelper.h \ - src/gui/generic/serverguiwrapper.h - + src/gui/generic/serverguiwrapper.h \ + src/core/pokerthexception.h \ + src/engine/local_engine/localexception.h + SOURCES += \ - src/pokerth_server.cpp - -win32{ - DEPENDPATH += src/net/win32/ src/core/win32 - INCLUDEPATH += ../boost/ ../OpenSSL/include - LIBPATH += ../boost/stage/lib ../OpenSSL/lib - - LIBPATH += Release/lib - #LIBPATH += Debug/lib - - LIBS += -lpokerth_lib - LIBS += -lssleay32 - LIBS += -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lole32 -luuid -luser32 -lmsimg32 -lshell32 -lkernel32 -lws2_32 -ladvapi32 - exists( ../boost/stage/lib/libboost_thread-mgw34-mt-1_34_1.a ){ - LIBS += -lboost_thread-mgw34-mt-1_34_1 - } - exists( ../boost/stage/lib/libboost_filesystem-mgw34-mt-1_34_1.a ){ - LIBS += -lboost_filesystem-mgw34-mt-1_34_1 - } -} -!win32{ - DEPENDPATH += src/net/linux/ src/core/linux - SOURCES += src/core/linux/daemon.c -} - -unix:!mac{ - exists( /usr/lib/libboost_thread-mt.so ) { - message("Found libboost_thread-mt") - LIBS += -lboost_thread-mt - } - exists( /usr/lib64/libboost_thread-mt.so ) { - message("Found libboost_thread-mt") - LIBS += -lboost_thread-mt - } - exists( /usr/lib/libboost_thread.so ) { - message("Found libboost_thread") - LIBS += -lboost_thread - } - exists( /usr/lib64/libboost_thread.so ) { - message("Found libboost_thread") - LIBS += -lboost_thread - } - - exists( /usr/lib/libboost_filesystem-mt.so ){ - message("Found libboost_filesystem-mt") - LIBS += -lboost_filesystem-mt - } - exists( /usr/lib64/libboost_filesystem-mt.so ){ - message("Found libboost_filesystem-mt") - LIBS += -lboost_filesystem-mt - } - exists( /usr/lib/libboost_filesystem.so ){ - message("Found libboost_filesystem") - LIBS += -lboost_filesystem - } - exists( /usr/lib64/libboost_filesystem.so ){ - message("Found libboost_filesystem") - LIBS += -lboost_filesystem - } - LIBPATH += lib - LIBS += -lpokerth_lib - LIBS += -lcrypto - TARGETDEPS += ./lib/libpokerth_lib.a - - ## My release static libs - #LIBS += -lcrypto -} - + src/pokerth_server.cpp \ + src/core/common/pokerthexception.cpp \ + src/engine/local_engine/localexception.cpp + +win32 { + DEPENDPATH += src/net/win32/ src/core/win32 + INCLUDEPATH += ../boost/ ../OpenSSL/include + LIBPATH += ../boost/stage/lib ../OpenSSL/lib + + LIBPATH += Release/lib + #LIBPATH += Debug/lib + + LIBS += -lpokerth_lib + LIBS += -lssleay32 + LIBS += -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lole32 -luuid -luser32 -lmsimg32 -lshell32 -lkernel32 -lws2_32 -ladvapi32 + exists( ../boost/stage/lib/libboost_thread-mgw34-mt-1_34_1.a ){ + LIBS += -lboost_thread-mgw34-mt-1_34_1 + } + exists( ../boost/stage/lib/libboost_filesystem-mgw34-mt-1_34_1.a ){ + LIBS += -lboost_filesystem-mgw34-mt-1_34_1 + } +} +!win32 { + DEPENDPATH += src/net/linux/ src/core/linux + SOURCES += src/core/linux/daemon.c +} + +unix : !mac { + exists( /usr/lib/libboost_thread-mt.so ){ + message("Found libboost_thread-mt") + LIBS += -lboost_thread-mt + } + exists( /usr/lib64/libboost_thread-mt.so ){ + message("Found libboost_thread-mt") + LIBS += -lboost_thread-mt + } + exists( /usr/lib/libboost_thread.so ){ + message("Found libboost_thread") + LIBS += -lboost_thread + } + exists( /usr/lib64/libboost_thread.so ){ + message("Found libboost_thread") + LIBS += -lboost_thread + } + + exists( /usr/lib/libboost_filesystem-mt.so ){ + message("Found libboost_filesystem-mt") + LIBS += -lboost_filesystem-mt + } + exists( /usr/lib64/libboost_filesystem-mt.so ){ + message("Found libboost_filesystem-mt") + LIBS += -lboost_filesystem-mt + } + exists( /usr/lib/libboost_filesystem.so ){ + message("Found libboost_filesystem") + LIBS += -lboost_filesystem + } + exists( /usr/lib64/libboost_filesystem.so ){ + message("Found libboost_filesystem") + LIBS += -lboost_filesystem + } + LIBPATH += lib + LIBS += -lpokerth_lib + LIBS += -lcrypto + TARGETDEPS += ./lib/libpokerth_lib.a + + ## My release static libs + #LIBS += -lcrypto + } + #CONFIG += qt thread console embed_manifest_exe warn_on release CONFIG += qt thread console embed_manifest_exe warn_on debug UI_DIR = uics diff --git a/src/core/common/pokerthexception.cpp b/src/core/common/pokerthexception.cpp new file mode 100644 index 00000000..b6dc1364 --- /dev/null +++ b/src/core/common/pokerthexception.cpp @@ -0,0 +1,25 @@ +/*************************************************************************** + * Copyright (C) 2006 by FThauer FHammer * + * f.thauer@web.de * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "pokerthexception.h" + +PokerTHException::~PokerTHException() +{ +} + diff --git a/src/core/pokerthexception.h b/src/core/pokerthexception.h new file mode 100644 index 00000000..286a1236 --- /dev/null +++ b/src/core/pokerthexception.h @@ -0,0 +1,41 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +/* Base exception class. */ + +#ifndef _POKERTHEXCEPTION_H_ +#define _POKERTHEXCEPTION_H_ + + +class PokerTHException +{ +public: + + PokerTHException(int errorId, int osErrorCode) + : m_errorId(errorId), m_osErrorCode(osErrorCode) {} + virtual ~PokerTHException(); + + int GetErrorId() const {return m_errorId;} + int GetOsErrorCode() const {return m_osErrorCode;} + +private: + int m_errorId; + int m_osErrorCode; +}; + +#endif diff --git a/src/engine/local_engine/localboard.cpp b/src/engine/local_engine/localboard.cpp index 82ab1e14..9b0b3ebf 100755 --- a/src/engine/local_engine/localboard.cpp +++ b/src/engine/local_engine/localboard.cpp @@ -21,6 +21,7 @@ #include "handinterface.h" #include +#include "localexception.h" using namespace std; diff --git a/src/engine/local_engine/localexception.cpp b/src/engine/local_engine/localexception.cpp new file mode 100644 index 00000000..1d04cee3 --- /dev/null +++ b/src/engine/local_engine/localexception.cpp @@ -0,0 +1,26 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "localexception.h" + + +LocalException::~LocalException() +{ +} + diff --git a/src/engine/local_engine/localexception.h b/src/engine/local_engine/localexception.h new file mode 100644 index 00000000..1296a2e9 --- /dev/null +++ b/src/engine/local_engine/localexception.h @@ -0,0 +1,35 @@ +/*************************************************************************** + * Copyright (C) 2007 by Lothar May * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +/* Exception class for engine errors. */ + +#ifndef _LOCALEXCEPTION_H_ +#define _LOCALEXCEPTION_H_ + +#include "pokerthexception.h" + +class LocalException : public PokerTHException +{ +public: + + LocalException(int errorId) + : PokerTHException(errorId, 0) {} + virtual ~LocalException(); +}; + +#endif diff --git a/src/engine/local_engine/localhand.cpp b/src/engine/local_engine/localhand.cpp index 8e46d835..eb47d26c 100755 --- a/src/engine/local_engine/localhand.cpp +++ b/src/engine/local_engine/localhand.cpp @@ -112,7 +112,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardI case 1: { - tempBoardArray[0] = 27; +/* tempBoardArray[0] = 27; tempBoardArray[1] = 37; tempBoardArray[2] = 45; tempBoardArray[3] = 51; @@ -124,7 +124,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardI tempPlayerAndBoardArray[3] = tempBoardArray[1]; tempPlayerAndBoardArray[4] = tempBoardArray[2]; tempPlayerAndBoardArray[5] = tempBoardArray[3]; - tempPlayerAndBoardArray[6] = tempBoardArray[4]; + tempPlayerAndBoardArray[6] = tempBoardArray[4];*/ // player0 it = seatsList->begin(); @@ -142,7 +142,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardI // player1 it++; - tempPlayerArray[0] = 12; +/* tempPlayerArray[0] = 12; tempPlayerArray[1] = 48; tempPlayerAndBoardArray[0] = tempPlayerArray[0]; tempPlayerAndBoardArray[1] = tempPlayerArray[1]; @@ -150,7 +150,7 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardI (*it)->setMyCards(tempPlayerArray); (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); - (*it)->setMyBestHandPosition(temp5Array); + (*it)->setMyBestHandPosition(temp5Array);*/ // player2 it++; @@ -181,28 +181,28 @@ LocalHand::LocalHand(boost::shared_ptr f, GuiInterface *g, BoardI // player4 it++; - tempPlayerArray[0] = 25; - tempPlayerArray[1] = 16; - tempPlayerAndBoardArray[0] = tempPlayerArray[0]; - tempPlayerAndBoardArray[1] = tempPlayerArray[1]; - - (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); - - (*it)->setMyBestHandPosition(temp5Array); +// tempPlayerArray[0] = 25; +// tempPlayerArray[1] = 16; +// tempPlayerAndBoardArray[0] = tempPlayerArray[0]; +// tempPlayerAndBoardArray[1] = tempPlayerArray[1]; +// +// (*it)->setMyCards(tempPlayerArray); +// (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); +// +// (*it)->setMyBestHandPosition(temp5Array); // player5 it++; - tempPlayerArray[0] = 43; - tempPlayerArray[1] = 30; - tempPlayerAndBoardArray[0] = tempPlayerArray[0]; - tempPlayerAndBoardArray[1] = tempPlayerArray[1]; - - (*it)->setMyCards(tempPlayerArray); - (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); - - (*it)->setMyBestHandPosition(temp5Array); +// tempPlayerArray[0] = 43; +// tempPlayerArray[1] = 30; +// tempPlayerAndBoardArray[0] = tempPlayerArray[0]; +// tempPlayerAndBoardArray[1] = tempPlayerArray[1]; +// +// (*it)->setMyCards(tempPlayerArray); +// (*it)->setMyCardsValueInt(myCardsValue.cardsValue(tempPlayerAndBoardArray,temp5Array)); +// +// (*it)->setMyBestHandPosition(temp5Array); } break; diff --git a/src/engine/local_engine/localplayer.cpp b/src/engine/local_engine/localplayer.cpp index 7fe2cb64..0ae4e61d 100755 --- a/src/engine/local_engine/localplayer.cpp +++ b/src/engine/local_engine/localplayer.cpp @@ -860,22 +860,22 @@ LocalPlayer::LocalPlayer(ConfigFile *c, BoardInterface *b, int id, unsigned uniq myCash=0; } break; case 1: { - myCash=2520; + myCash=0; } break; case 2: { - myCash=0; + myCash=180; } break; case 3: { - myCash=0; + myCash=3930; } break; case 4: { - myCash=14700; + myCash=0; } break; case 5: { - myCash=3780; + myCash=13590; } break; case 6: { - myCash=0; + myCash=3300; } break; default: { } @@ -1202,8 +1202,8 @@ void LocalPlayer::preflopEngine() { switch(actualHand->getMyID()) { case 1: { - myAction = PLAYER_ACTION_RAISE; - raise = 3000; +// myAction = PLAYER_ACTION_RAISE; +// raise = 3000; } break; case 2: { @@ -1246,7 +1246,7 @@ void LocalPlayer::preflopEngine() { case 3: { switch(actualHand->getMyID()) { case 1: { -// myAction = PLAYER_ACTION_FOLD; + myAction = PLAYER_ACTION_FOLD; // raise = 20; // if(mySet >= 40) { // myAction = PLAYER_ACTION_CALL; @@ -1290,7 +1290,15 @@ void LocalPlayer::preflopEngine() { } break; case 5: { -// myAction = PLAYER_ACTION_FOLD; + if(mySet == 0) { + myAction = PLAYER_ACTION_CALL; + } + } + break; + case 6: { + if(mySet == 160) { + myAction = PLAYER_ACTION_CALL; + } } break; default: {} diff --git a/src/game.cpp b/src/game.cpp index 0e09b08e..452abf74 100755 --- a/src/game.cpp +++ b/src/game.cpp @@ -28,7 +28,7 @@ using namespace std; Game::Game(GuiInterface* gui, boost::shared_ptr factory, - const PlayerDataList &playerDataList, const GameData gameData, + const PlayerDataList &playerDataList, const GameData &gameData, const StartData &startData, int gameId) : myFactory(factory), myGui(gui), actualHand(0), actualBoard(0), startQuantityPlayers(startData.numberOfPlayers), @@ -37,7 +37,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr factory, myGameID(gameId), actualSmallBlind(gameData.smallBlind), actualHandID(0), dealerPosition(0), lastHandBlindsRaised(1), lastTimeBlindsRaised(0), myGameData(gameData) { if(DEBUG_MODE) { - startSmallBlind = 5120; + startSmallBlind = 160; actualSmallBlind = startSmallBlind; } diff --git a/src/game.h b/src/game.h index ea6646d8..0b04139c 100755 --- a/src/game.h +++ b/src/game.h @@ -45,7 +45,7 @@ class Game { public: Game(GuiInterface *gui, boost::shared_ptr factory, - const PlayerDataList &playerDataList, const GameData gameData, + const PlayerDataList &playerDataList, const GameData &gameData, const StartData &startData, int gameId); ~Game(); diff --git a/src/gui/qt/mainwindow.ui b/src/gui/qt/mainwindow.ui index 733eef01..34267328 100644 --- a/src/gui/qt/mainwindow.ui +++ b/src/gui/qt/mainwindow.ui @@ -2522,7 +2522,7 @@ 0 0 1000 - 30 + 29 diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index f1dcb6e6..2ad4dcc1 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -805,7 +805,7 @@ void mainWindowImpl::startNewLocalGame(newGameDialogImpl *v) { startData.numberOfPlayers = gameData.maxNumberOfPlayers; Tools::getRandNumber(0, startData.numberOfPlayers-1, 1, &tmpDealerPos, 0); if(DEBUG_MODE) { - tmpDealerPos = 4; + tmpDealerPos = 5; } startData.startDealerPlayerId = static_cast(tmpDealerPos); @@ -2944,7 +2944,7 @@ void mainWindowImpl::localGameModification() { } //Set the playing mode to "manual" - playingMode = 1; + playingMode = 0; } diff --git a/src/net/netexception.h b/src/net/netexception.h index fd69b1c0..b911de9b 100644 --- a/src/net/netexception.h +++ b/src/net/netexception.h @@ -21,21 +21,15 @@ #ifndef _NETEXCEPTION_H_ #define _NETEXCEPTION_H_ +#include "pokerthexception.h" -class NetException +class NetException : public PokerTHException { public: NetException(int errorId, int osErrorCode) - : m_errorId(errorId), m_osErrorCode(osErrorCode) {} + : PokerTHException(errorId, osErrorCode) {} virtual ~NetException(); - - int GetErrorId() const {return m_errorId;} - int GetOsErrorCode() const {return m_osErrorCode;} - -private: - int m_errorId; - int m_osErrorCode; }; #endif diff --git a/src/session.cpp b/src/session.cpp index fc1fe262..d9e560bf 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -96,6 +96,7 @@ void Session::startLocalGame(const GameData &gameData, const StartData &startDat currentGame->initHand(); currentGame->startHand(); // SPIEL-SCHLEIFE + } void Session::startClientGame(boost::shared_ptr game)