Working on storing places of all players in ranking games.

This commit is contained in:
lotodore
2010-08-07 23:06:59 +00:00
parent 96b4f864f6
commit 0646bc9d2e
8 changed files with 163 additions and 70 deletions
+14
View File
@@ -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()
{
+5 -6
View File
@@ -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.
+2 -3
View File
@@ -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 &