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
|
||||
|
||||
TEMPLATE = lib
|
||||
CODECFORSRC = UTF-8
|
||||
|
||||
CONFIG += staticlib thread exceptions rtti stl warn_on
|
||||
UI_DIR = uics
|
||||
TARGET = lib/pokerth_db
|
||||
MOC_DIR = mocs
|
||||
OBJECTS_DIR = obj
|
||||
DEFINES += ENABLE_IPV6
|
||||
QT -= core gui
|
||||
#PRECOMPILED_HEADER = src/pch_lib.h
|
||||
|
||||
INCLUDEPATH += . \
|
||||
src
|
||||
|
||||
DEPENDPATH += . \
|
||||
src
|
||||
|
||||
# Input
|
||||
HEADERS += \
|
||||
src/db/serverdbcallback.h \
|
||||
src/db/serverdbfactory.h \
|
||||
src/db/serverdbinterface.h \
|
||||
src/db/serverdbgeneric.h \
|
||||
src/db/serverdbfactorygeneric.h
|
||||
|
||||
SOURCES += \
|
||||
src/db/common/serverdbcallback.cpp \
|
||||
src/db/common/serverdbfactory.cpp \
|
||||
src/db/common/serverdbinterface.cpp \
|
||||
src/db/common/serverdbgeneric.cpp \
|
||||
src/db/common/serverdbfactorygeneric.cpp
|
||||
|
||||
win32{
|
||||
DEFINES += CURL_STATICLIB
|
||||
DEFINES += _WIN32_WINNT=0x0501
|
||||
DEPENDPATH += src/net/win32/ src/core/win32
|
||||
INCLUDEPATH += ../boost/ ../GnuTLS/include ../curl/include ../zlib
|
||||
}
|
||||
!win32{
|
||||
##### My release static build options
|
||||
#QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
# QMake pro-file for PokerTH common library
|
||||
|
||||
TEMPLATE = lib
|
||||
CODECFORSRC = UTF-8
|
||||
|
||||
CONFIG += staticlib thread exceptions rtti stl warn_on
|
||||
UI_DIR = uics
|
||||
TARGET = lib/pokerth_db
|
||||
MOC_DIR = mocs
|
||||
OBJECTS_DIR = obj
|
||||
DEFINES += ENABLE_IPV6
|
||||
QT -= core gui
|
||||
#PRECOMPILED_HEADER = src/pch_lib.h
|
||||
|
||||
INCLUDEPATH += . \
|
||||
src
|
||||
|
||||
DEPENDPATH += . \
|
||||
src
|
||||
|
||||
# Input
|
||||
HEADERS += \
|
||||
src/db/serverdbcallback.h \
|
||||
src/db/serverdbfactory.h \
|
||||
src/db/serverdbinterface.h \
|
||||
src/db/serverdbgeneric.h \
|
||||
src/db/serverdbfactorygeneric.h \
|
||||
src/db/serverdbnoaction.h
|
||||
|
||||
SOURCES += \
|
||||
src/db/common/serverdbcallback.cpp \
|
||||
src/db/common/serverdbfactory.cpp \
|
||||
src/db/common/serverdbinterface.cpp \
|
||||
src/db/common/serverdbgeneric.cpp \
|
||||
src/db/common/serverdbfactorygeneric.cpp \
|
||||
src/db/common/serverdbnoaction.cpp
|
||||
|
||||
win32{
|
||||
DEFINES += CURL_STATICLIB
|
||||
DEFINES += _WIN32_WINNT=0x0501
|
||||
DEPENDPATH += src/net/win32/ src/core/win32
|
||||
INCLUDEPATH += ../boost/ ../GnuTLS/include ../curl/include ../zlib
|
||||
}
|
||||
!win32{
|
||||
##### My release static build options
|
||||
#QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -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 <core/loghelper.h>
|
||||
#include <db/serverdbinterface.h>
|
||||
#include <db/serverdbnoaction.h>
|
||||
#include <game.h>
|
||||
#include <localenginefactory.h>
|
||||
#include <tools.h>
|
||||
@@ -231,6 +232,12 @@ ServerGame::TimerVoteKick(const boost::system::error_code &ec)
|
||||
void
|
||||
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.
|
||||
AssignPlayerNumbers();
|
||||
|
||||
@@ -751,6 +758,13 @@ ServerGame::GetSessionManager() const
|
||||
return m_sessionManager;
|
||||
}
|
||||
|
||||
ServerDBInterface &
|
||||
ServerGame::GetDatabase()
|
||||
{
|
||||
assert(m_database);
|
||||
return *m_database;
|
||||
}
|
||||
|
||||
ServerLobbyThread &
|
||||
ServerGame::GetLobbyThread()
|
||||
{
|
||||
|
||||
@@ -655,8 +655,7 @@ ServerGameStateStartGame::DoStart(boost::shared_ptr<ServerGame> server)
|
||||
else
|
||||
{
|
||||
server->InternalStartGame();
|
||||
if (server->GetGameData().gameType == GAME_TYPE_RANKING)
|
||||
server->GetLobbyThread().GetDatabase().AsyncCreateGame(server->GetId(), server->GetName());
|
||||
server->GetDatabase().AsyncCreateGame(server->GetId(), server->GetName());
|
||||
|
||||
boost::shared_ptr<NetPacket> packet(new NetPacket(NetPacket::Alloc));
|
||||
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));
|
||||
}
|
||||
// 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);
|
||||
|
||||
@@ -935,11 +934,11 @@ ServerGameStateHand::EngineLoop(boost::shared_ptr<ServerGame> server)
|
||||
// Store winner in database.
|
||||
boost::shared_ptr<PlayerInterface> winnerPlayer = *(playersWithCash.begin());
|
||||
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;
|
||||
server->GetLobbyThread().GetDatabase().SetGamePlayerPlace(server->GetDBId(), tmpPlayer->GetDBId(), 1);
|
||||
server->GetLobbyThread().GetDatabase().EndGame(server->GetDBId());
|
||||
server->GetDatabase().SetGamePlayerPlace(server->GetDBId(), tmpPlayer->GetDBId(), 1);
|
||||
server->GetDatabase().EndGame(server->GetDBId());
|
||||
}
|
||||
|
||||
// View a dialog for a new game - delayed.
|
||||
|
||||
@@ -646,11 +646,10 @@ ServerLobbyThread::GetIOService()
|
||||
return *m_ioService;
|
||||
}
|
||||
|
||||
ServerDBInterface &
|
||||
boost::shared_ptr<ServerDBInterface>
|
||||
ServerLobbyThread::GetDatabase()
|
||||
{
|
||||
assert(m_database);
|
||||
return *m_database;
|
||||
return m_database;
|
||||
}
|
||||
|
||||
ServerBanManager &
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
class ReceiverHelper;
|
||||
class ServerLobbyThread;
|
||||
class ServerGameState;
|
||||
class ServerDBInterface;
|
||||
class ConfigFile;
|
||||
struct GameData;
|
||||
class Game;
|
||||
@@ -140,6 +141,7 @@ protected:
|
||||
|
||||
const SessionManager &GetSessionManager() const;
|
||||
SessionManager &GetSessionManager();
|
||||
ServerDBInterface &GetDatabase();
|
||||
|
||||
private:
|
||||
ServerGame(const ServerGame &other);
|
||||
@@ -157,6 +159,7 @@ private:
|
||||
|
||||
boost::shared_ptr<ServerLobbyThread> m_lobbyThread;
|
||||
boost::shared_ptr<ReceiverHelper> m_receiver;
|
||||
boost::shared_ptr<ServerDBInterface> m_database;
|
||||
GuiInterface &m_gui;
|
||||
|
||||
const GameData m_gameData;
|
||||
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
|
||||
SenderHelper &GetSender();
|
||||
boost::asio::io_service &GetIOService();
|
||||
ServerDBInterface &GetDatabase();
|
||||
boost::shared_ptr<ServerDBInterface> GetDatabase();
|
||||
ServerBanManager &GetBanManager();
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user