Working on storing places of all players in ranking games.
This commit is contained in:
+62
-60
@@ -1,60 +1,62 @@
|
|||||||
# QMake pro-file for PokerTH common library
|
# QMake pro-file for PokerTH common library
|
||||||
|
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
CODECFORSRC = UTF-8
|
CODECFORSRC = UTF-8
|
||||||
|
|
||||||
CONFIG += staticlib thread exceptions rtti stl warn_on
|
CONFIG += staticlib thread exceptions rtti stl warn_on
|
||||||
UI_DIR = uics
|
UI_DIR = uics
|
||||||
TARGET = lib/pokerth_db
|
TARGET = lib/pokerth_db
|
||||||
MOC_DIR = mocs
|
MOC_DIR = mocs
|
||||||
OBJECTS_DIR = obj
|
OBJECTS_DIR = obj
|
||||||
DEFINES += ENABLE_IPV6
|
DEFINES += ENABLE_IPV6
|
||||||
QT -= core gui
|
QT -= core gui
|
||||||
#PRECOMPILED_HEADER = src/pch_lib.h
|
#PRECOMPILED_HEADER = src/pch_lib.h
|
||||||
|
|
||||||
INCLUDEPATH += . \
|
INCLUDEPATH += . \
|
||||||
src
|
src
|
||||||
|
|
||||||
DEPENDPATH += . \
|
DEPENDPATH += . \
|
||||||
src
|
src
|
||||||
|
|
||||||
# Input
|
# Input
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/db/serverdbcallback.h \
|
src/db/serverdbcallback.h \
|
||||||
src/db/serverdbfactory.h \
|
src/db/serverdbfactory.h \
|
||||||
src/db/serverdbinterface.h \
|
src/db/serverdbinterface.h \
|
||||||
src/db/serverdbgeneric.h \
|
src/db/serverdbgeneric.h \
|
||||||
src/db/serverdbfactorygeneric.h
|
src/db/serverdbfactorygeneric.h \
|
||||||
|
src/db/serverdbnoaction.h
|
||||||
SOURCES += \
|
|
||||||
src/db/common/serverdbcallback.cpp \
|
SOURCES += \
|
||||||
src/db/common/serverdbfactory.cpp \
|
src/db/common/serverdbcallback.cpp \
|
||||||
src/db/common/serverdbinterface.cpp \
|
src/db/common/serverdbfactory.cpp \
|
||||||
src/db/common/serverdbgeneric.cpp \
|
src/db/common/serverdbinterface.cpp \
|
||||||
src/db/common/serverdbfactorygeneric.cpp
|
src/db/common/serverdbgeneric.cpp \
|
||||||
|
src/db/common/serverdbfactorygeneric.cpp \
|
||||||
win32{
|
src/db/common/serverdbnoaction.cpp
|
||||||
DEFINES += CURL_STATICLIB
|
|
||||||
DEFINES += _WIN32_WINNT=0x0501
|
win32{
|
||||||
DEPENDPATH += src/net/win32/ src/core/win32
|
DEFINES += CURL_STATICLIB
|
||||||
INCLUDEPATH += ../boost/ ../GnuTLS/include ../curl/include ../zlib
|
DEFINES += _WIN32_WINNT=0x0501
|
||||||
}
|
DEPENDPATH += src/net/win32/ src/core/win32
|
||||||
!win32{
|
INCLUDEPATH += ../boost/ ../GnuTLS/include ../curl/include ../zlib
|
||||||
##### My release static build options
|
}
|
||||||
#QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections
|
!win32{
|
||||||
}
|
##### My release static build options
|
||||||
|
#QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections
|
||||||
mac{
|
}
|
||||||
# make it universal
|
|
||||||
CONFIG += x86
|
mac{
|
||||||
CONFIG -= ppc
|
# make it universal
|
||||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
|
CONFIG += x86
|
||||||
|
CONFIG -= ppc
|
||||||
# for universal-compilation on PPC-Mac uncomment the following line
|
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
|
||||||
# on Intel-Mac you have to comment this line out or build will fail.
|
|
||||||
# QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk/
|
# for universal-compilation on PPC-Mac uncomment the following line
|
||||||
|
# on Intel-Mac you have to comment this line out or build will fail.
|
||||||
INCLUDEPATH += /Developer/SDKs/MacOSX10.5.sdk/usr/include/
|
# QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk/
|
||||||
INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers
|
|
||||||
INCLUDEPATH += /Library/Frameworks/SDL_mixer.framework/Headers
|
INCLUDEPATH += /Developer/SDKs/MacOSX10.5.sdk/usr/include/
|
||||||
}
|
INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers
|
||||||
|
INCLUDEPATH += /Library/Frameworks/SDL_mixer.framework/Headers
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2010 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 <db/serverdbnoaction.h>
|
||||||
|
|
||||||
|
|
||||||
|
ServerDBNoAction::ServerDBNoAction()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerDBNoAction::~ServerDBNoAction()
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2010 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. *
|
||||||
|
***************************************************************************/
|
||||||
|
/* Generic server database implementation. Basically does nothing. */
|
||||||
|
|
||||||
|
#ifndef _SERVERDBNOACTION_H_
|
||||||
|
#define _SERVERDBNOACTION_H_
|
||||||
|
|
||||||
|
#include <db/serverdbinterface.h>
|
||||||
|
|
||||||
|
|
||||||
|
class ServerDBNoAction : public ServerDBInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ServerDBNoAction();
|
||||||
|
virtual ~ServerDBNoAction();
|
||||||
|
|
||||||
|
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 PlayerLogout(DB_id playerId) {}
|
||||||
|
|
||||||
|
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName) {}
|
||||||
|
virtual void SetGamePlayerPlace(DB_id gameId, DB_id playerId, unsigned place) {}
|
||||||
|
virtual void EndGame(DB_id gameId) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _SERVERDBNOACTION_H_
|
||||||
@@ -29,6 +29,7 @@
|
|||||||
#include <net/socket_msg.h>
|
#include <net/socket_msg.h>
|
||||||
#include <core/loghelper.h>
|
#include <core/loghelper.h>
|
||||||
#include <db/serverdbinterface.h>
|
#include <db/serverdbinterface.h>
|
||||||
|
#include <db/serverdbnoaction.h>
|
||||||
#include <game.h>
|
#include <game.h>
|
||||||
#include <localenginefactory.h>
|
#include <localenginefactory.h>
|
||||||
#include <tools.h>
|
#include <tools.h>
|
||||||
@@ -231,6 +232,12 @@ ServerGame::TimerVoteKick(const boost::system::error_code &ec)
|
|||||||
void
|
void
|
||||||
ServerGame::InternalStartGame()
|
ServerGame::InternalStartGame()
|
||||||
{
|
{
|
||||||
|
// Set DB Backend.
|
||||||
|
if (GetGameData().gameType == GAME_TYPE_RANKING)
|
||||||
|
m_database = GetLobbyThread().GetDatabase();
|
||||||
|
else
|
||||||
|
m_database.reset(new ServerDBNoAction);
|
||||||
|
|
||||||
// Set order of players.
|
// Set order of players.
|
||||||
AssignPlayerNumbers();
|
AssignPlayerNumbers();
|
||||||
|
|
||||||
@@ -751,6 +758,13 @@ ServerGame::GetSessionManager() const
|
|||||||
return m_sessionManager;
|
return m_sessionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ServerDBInterface &
|
||||||
|
ServerGame::GetDatabase()
|
||||||
|
{
|
||||||
|
assert(m_database);
|
||||||
|
return *m_database;
|
||||||
|
}
|
||||||
|
|
||||||
ServerLobbyThread &
|
ServerLobbyThread &
|
||||||
ServerGame::GetLobbyThread()
|
ServerGame::GetLobbyThread()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -655,8 +655,7 @@ ServerGameStateStartGame::DoStart(boost::shared_ptr<ServerGame> server)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
server->InternalStartGame();
|
server->InternalStartGame();
|
||||||
if (server->GetGameData().gameType == GAME_TYPE_RANKING)
|
server->GetDatabase().AsyncCreateGame(server->GetId(), server->GetName());
|
||||||
server->GetLobbyThread().GetDatabase().AsyncCreateGame(server->GetId(), server->GetName());
|
|
||||||
|
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket(NetPacket::Alloc));
|
boost::shared_ptr<NetPacket> packet(new NetPacket(NetPacket::Alloc));
|
||||||
packet->GetMsg()->present = PokerTHMessage_PR_gameStartMessage;
|
packet->GetMsg()->present = PokerTHMessage_PR_gameStartMessage;
|
||||||
@@ -848,7 +847,7 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr<ServerGame> server)
|
|||||||
&ServerGameStateHand::TimerComputerAction, this, boost::asio::placeholders::error, server));
|
&ServerGameStateHand::TimerComputerAction, this, boost::asio::placeholders::error, server));
|
||||||
}
|
}
|
||||||
// If the player we are waiting for left, continue without him.
|
// If the player we are waiting for left, continue without him.
|
||||||
else if (!server->GetSessionManager().IsPlayerConnected(curPlayer->getMyName()))
|
else if (!server->GetSessionManager().IsPlayerConnected(curPlayer->getMyUniqueID()))
|
||||||
{
|
{
|
||||||
PerformPlayerAction(*server, curPlayer, PLAYER_ACTION_FOLD, 0);
|
PerformPlayerAction(*server, curPlayer, PLAYER_ACTION_FOLD, 0);
|
||||||
|
|
||||||
@@ -935,11 +934,11 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr<ServerGame> server)
|
|||||||
// Store winner in database.
|
// Store winner in database.
|
||||||
boost::shared_ptr<PlayerInterface> winnerPlayer = *(playersWithCash.begin());
|
boost::shared_ptr<PlayerInterface> winnerPlayer = *(playersWithCash.begin());
|
||||||
boost::shared_ptr<PlayerData> tmpPlayer = server->GetPlayerDataByUniqueId(winnerPlayer->getMyUniqueID());
|
boost::shared_ptr<PlayerData> tmpPlayer = server->GetPlayerDataByUniqueId(winnerPlayer->getMyUniqueID());
|
||||||
if (server->GetGameData().gameType == GAME_TYPE_RANKING && tmpPlayer && server->GetDBId())
|
if (tmpPlayer && server->GetDBId())
|
||||||
{
|
{
|
||||||
cerr << "Setting winner for game " << server->GetDBId() << " player id " << tmpPlayer->GetDBId() << endl;
|
cerr << "Setting winner for game " << server->GetDBId() << " player id " << tmpPlayer->GetDBId() << endl;
|
||||||
server->GetLobbyThread().GetDatabase().SetGamePlayerPlace(server->GetDBId(), tmpPlayer->GetDBId(), 1);
|
server->GetDatabase().SetGamePlayerPlace(server->GetDBId(), tmpPlayer->GetDBId(), 1);
|
||||||
server->GetLobbyThread().GetDatabase().EndGame(server->GetDBId());
|
server->GetDatabase().EndGame(server->GetDBId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// View a dialog for a new game - delayed.
|
// View a dialog for a new game - delayed.
|
||||||
|
|||||||
@@ -646,11 +646,10 @@ ServerLobbyThread::GetIOService()
|
|||||||
return *m_ioService;
|
return *m_ioService;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerDBInterface &
|
boost::shared_ptr<ServerDBInterface>
|
||||||
ServerLobbyThread::GetDatabase()
|
ServerLobbyThread::GetDatabase()
|
||||||
{
|
{
|
||||||
assert(m_database);
|
return m_database;
|
||||||
return *m_database;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerBanManager &
|
ServerBanManager &
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
class ReceiverHelper;
|
class ReceiverHelper;
|
||||||
class ServerLobbyThread;
|
class ServerLobbyThread;
|
||||||
class ServerGameState;
|
class ServerGameState;
|
||||||
|
class ServerDBInterface;
|
||||||
class ConfigFile;
|
class ConfigFile;
|
||||||
struct GameData;
|
struct GameData;
|
||||||
class Game;
|
class Game;
|
||||||
@@ -140,6 +141,7 @@ protected:
|
|||||||
|
|
||||||
const SessionManager &GetSessionManager() const;
|
const SessionManager &GetSessionManager() const;
|
||||||
SessionManager &GetSessionManager();
|
SessionManager &GetSessionManager();
|
||||||
|
ServerDBInterface &GetDatabase();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ServerGame(const ServerGame &other);
|
ServerGame(const ServerGame &other);
|
||||||
@@ -157,6 +159,7 @@ private:
|
|||||||
|
|
||||||
boost::shared_ptr<ServerLobbyThread> m_lobbyThread;
|
boost::shared_ptr<ServerLobbyThread> m_lobbyThread;
|
||||||
boost::shared_ptr<ReceiverHelper> m_receiver;
|
boost::shared_ptr<ReceiverHelper> m_receiver;
|
||||||
|
boost::shared_ptr<ServerDBInterface> m_database;
|
||||||
GuiInterface &m_gui;
|
GuiInterface &m_gui;
|
||||||
|
|
||||||
const GameData m_gameData;
|
const GameData m_gameData;
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public:
|
|||||||
|
|
||||||
SenderHelper &GetSender();
|
SenderHelper &GetSender();
|
||||||
boost::asio::io_service &GetIOService();
|
boost::asio::io_service &GetIOService();
|
||||||
ServerDBInterface &GetDatabase();
|
boost::shared_ptr<ServerDBInterface> GetDatabase();
|
||||||
ServerBanManager &GetBanManager();
|
ServerBanManager &GetBanManager();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
Reference in New Issue
Block a user