New log object for network/internet games. Preliminary code.
This commit is contained in:
+5
-5
@@ -41,12 +41,12 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||
|
||||
blindsList = myGameData.manualBlindsList;
|
||||
|
||||
dealerPosition = startData.startDealerPlayerId;
|
||||
dealerPosition = startData.startDealerPlayerId;
|
||||
|
||||
if(DEBUG_MODE) {
|
||||
startSmallBlind = 10;
|
||||
if(DEBUG_MODE) {
|
||||
startSmallBlind = 10;
|
||||
currentSmallBlind = startSmallBlind;
|
||||
dealerPosition = 4;
|
||||
dealerPosition = 4;
|
||||
}
|
||||
|
||||
int i;
|
||||
@@ -57,7 +57,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||
|
||||
while (player_i != player_end)
|
||||
{
|
||||
if ((*player_i)->GetUniqueId() == dealerPosition)
|
||||
if ((*player_i)->GetUniqueId() == dealerPosition)
|
||||
break;
|
||||
++player_i;
|
||||
}
|
||||
|
||||
+2
-2
@@ -44,7 +44,7 @@ class Game {
|
||||
public:
|
||||
Game(GuiInterface *gui, boost::shared_ptr<EngineFactory> factory,
|
||||
const PlayerDataList &playerDataList, const GameData &gameData,
|
||||
const StartData &startData, int gameId, Log *myLog = 0);
|
||||
const StartData &startData, int gameId, Log *myLog);
|
||||
|
||||
~Game();
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
void setCurrentHandID(int theValue) { currentHandID = theValue; }
|
||||
int getCurrentHandID() const { return currentHandID; }
|
||||
|
||||
unsigned getDealerPosition() const { return dealerPosition; }
|
||||
unsigned getDealerPosition() const { return dealerPosition; }
|
||||
|
||||
boost::shared_ptr<PlayerInterface> getPlayerByUniqueId(unsigned id);
|
||||
boost::shared_ptr<PlayerInterface> getCurrentPlayer();
|
||||
|
||||
@@ -41,6 +41,7 @@ class ClientSenderCallback;
|
||||
class Game;
|
||||
class NetPacket;
|
||||
class AvatarManager;
|
||||
class Log;
|
||||
class QtToolsInterface;
|
||||
struct Gsasl;
|
||||
|
||||
@@ -214,6 +215,7 @@ private:
|
||||
|
||||
boost::shared_ptr<boost::asio::io_service> m_ioService;
|
||||
boost::shared_ptr<ClientSenderCallback> m_senderCallback;
|
||||
boost::shared_ptr<Log> m_clientLog;
|
||||
|
||||
Gsasl *m_authContext;
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <core/loghelper.h>
|
||||
#include <clientenginefactory.h>
|
||||
#include <game.h>
|
||||
#include <log.h>
|
||||
#include <qttoolsinterface.h>
|
||||
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
@@ -71,6 +72,7 @@ ClientThread::ClientThread(GuiInterface &gui, AvatarManager &avatarManager)
|
||||
m_curGameId(0), m_curGameNum(1), m_guiPlayerId(0), m_sessionEstablished(false),
|
||||
m_stateTimer(*m_ioService), m_avatarTimer(*m_ioService)
|
||||
{
|
||||
m_clientLog.reset(new Log("", 0));
|
||||
m_context.reset(new ClientContext);
|
||||
m_receiver.reset(new ReceiverHelper);
|
||||
myQtToolsInterface.reset(CreateQtToolsWrapper());
|
||||
@@ -626,7 +628,7 @@ ClientThread::InitGame()
|
||||
MapPlayerDataList();
|
||||
if (GetPlayerDataList().size() != (unsigned)GetStartData().numberOfPlayers)
|
||||
throw ClientException(__FILE__, __LINE__, ERR_NET_INVALID_PLAYER_COUNT, 0);
|
||||
m_game.reset(new Game(&m_gui, factory, GetPlayerDataList(), GetGameData(), GetStartData(), m_curGameNum++));
|
||||
m_game.reset(new Game(&m_gui, factory, GetPlayerDataList(), GetGameData(), GetStartData(), m_curGameNum++, m_clientLog.get()));
|
||||
// Initialize Minimum GUI speed.
|
||||
int minimumGuiSpeed = 1;
|
||||
if(GetGameData().delayBetweenHandsSec < 11) {
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <db/serverdbinterface.h>
|
||||
#include <db/serverdbnoaction.h>
|
||||
#include <game.h>
|
||||
#include <log.h>
|
||||
#include <localenginefactory.h>
|
||||
#include <tools.h>
|
||||
#include <configfile.h>
|
||||
@@ -48,11 +49,11 @@ static bool LessThanPlayerHandStartMoney(const boost::shared_ptr<PlayerInterface
|
||||
}
|
||||
|
||||
|
||||
ServerGame::ServerGame(boost::shared_ptr<ServerLobbyThread> lobbyThread, u_int32_t id, const string &name, const string &pwd, const GameData &gameData, unsigned adminPlayerId, GuiInterface &gui, ConfigFile *playerConfig)
|
||||
ServerGame::ServerGame(boost::shared_ptr<ServerLobbyThread> lobbyThread, u_int32_t id, const string &name, const string &pwd, const GameData &gameData, unsigned adminPlayerId, GuiInterface &gui, ConfigFile &playerConfig, Log &serverLog)
|
||||
: m_adminPlayerId(adminPlayerId), m_lobbyThread(lobbyThread), m_gui(gui),
|
||||
m_gameData(gameData), m_curState(NULL), m_id(id), m_dbId(DB_ID_INVALID), m_name(name),
|
||||
m_password(pwd), m_playerConfig(playerConfig), m_gameNum(1), m_curPetitionId(1),
|
||||
m_doNotAutoKickSmallDelaySec(10), m_voteKickTimer(lobbyThread->GetIOService()),
|
||||
m_password(pwd), m_playerConfig(playerConfig), m_serverLog(serverLog), m_gameNum(1),
|
||||
m_curPetitionId(1), m_doNotAutoKickSmallDelaySec(10), m_voteKickTimer(lobbyThread->GetIOService()),
|
||||
m_stateTimer1(lobbyThread->GetIOService()), m_stateTimer2(lobbyThread->GetIOService())
|
||||
{
|
||||
LOG_VERBOSE("Game object " << GetId() << " created.");
|
||||
@@ -68,7 +69,7 @@ ServerGame::~ServerGame()
|
||||
void
|
||||
ServerGame::Init()
|
||||
{
|
||||
m_doNotAutoKickSmallDelaySec = m_playerConfig->readConfigInt("ServerDoNotAutoKickSmallDelaySec");
|
||||
m_doNotAutoKickSmallDelaySec = m_playerConfig.readConfigInt("ServerDoNotAutoKickSmallDelaySec");
|
||||
SetState(SERVER_INITIAL_STATE::Instance());
|
||||
}
|
||||
|
||||
@@ -257,7 +258,7 @@ ServerGame::InternalStartGame()
|
||||
AssignPlayerNumbers(playerData);
|
||||
|
||||
// Create EngineFactory
|
||||
boost::shared_ptr<EngineFactory> factory(new LocalEngineFactory(m_playerConfig)); // LocalEngine erstellen
|
||||
boost::shared_ptr<EngineFactory> factory(new LocalEngineFactory(&m_playerConfig)); // LocalEngine erstellen
|
||||
|
||||
// Set start data.
|
||||
StartData startData;
|
||||
@@ -286,7 +287,7 @@ ServerGame::InternalStartGame()
|
||||
SetStartData(startData);
|
||||
|
||||
GuiInterface &gui = GetGui();
|
||||
m_game.reset(new Game(&gui, factory, playerData, GetGameData(), GetStartData(), GetNextGameNum()));
|
||||
m_game.reset(new Game(&gui, factory, playerData, GetGameData(), GetStartData(), GetNextGameNum(), &m_serverLog));
|
||||
|
||||
GetDatabase().AsyncCreateGame(GetId(), GetName());
|
||||
InitRankingMap(playerData);
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <core/loghelper.h>
|
||||
#include <core/openssl_wrapper.h>
|
||||
#include <configfile.h>
|
||||
#include <log.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
@@ -172,7 +173,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
ServerLobbyThread::ServerLobbyThread(GuiInterface &gui, ServerMode mode, ServerIrcBotCallback &ircBotCb, ConfigFile *serverConfig,
|
||||
ServerLobbyThread::ServerLobbyThread(GuiInterface &gui, ServerMode mode, ServerIrcBotCallback &ircBotCb, ConfigFile &serverConfig,
|
||||
AvatarManager &avatarManager, boost::shared_ptr<boost::asio::io_service> ioService)
|
||||
: m_ioService(ioService), m_authContext(NULL), m_gui(gui), m_ircBotCb(ircBotCb), m_avatarManager(avatarManager),
|
||||
m_mode(mode), m_serverConfig(serverConfig), m_curGameId(0), m_curUniquePlayerId(0), m_curSessionId(INVALID_SESSION + 1),
|
||||
@@ -209,13 +210,14 @@ ServerLobbyThread::Init(const string &logDir)
|
||||
}
|
||||
}
|
||||
m_database->Init(
|
||||
m_serverConfig->readConfigString("DBServerAddress"),
|
||||
m_serverConfig->readConfigString("DBServerUser"),
|
||||
m_serverConfig->readConfigString("DBServerPassword"),
|
||||
m_serverConfig->readConfigString("DBServerDatabaseName"),
|
||||
m_serverConfig->readConfigString("DBServerEncryptionKey"));
|
||||
m_serverConfig.readConfigString("DBServerAddress"),
|
||||
m_serverConfig.readConfigString("DBServerUser"),
|
||||
m_serverConfig.readConfigString("DBServerPassword"),
|
||||
m_serverConfig.readConfigString("DBServerDatabaseName"),
|
||||
m_serverConfig.readConfigString("DBServerEncryptionKey"));
|
||||
|
||||
GetBanManager().InitGameNameBadWordList(m_serverConfig->readConfigStringList("GameNameBadWordList"));
|
||||
GetBanManager().InitGameNameBadWordList(m_serverConfig.readConfigStringList("GameNameBadWordList"));
|
||||
m_serverLog.reset(new Log(logDir, 0));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -812,14 +814,14 @@ ServerLobbyThread::ClearAuthContext()
|
||||
void
|
||||
ServerLobbyThread::InitChatCleaner()
|
||||
{
|
||||
if (m_serverConfig->readConfigInt("UseChatCleaner") != 0)
|
||||
if (m_serverConfig.readConfigInt("UseChatCleaner") != 0)
|
||||
{
|
||||
m_chatCleanerManager->Init(
|
||||
m_serverConfig->readConfigString("ChatCleanerHostAddress"),
|
||||
m_serverConfig->readConfigInt("ChatCleanerPort"),
|
||||
m_serverConfig->readConfigInt("ChatCleanerUseIpv6") != 0,
|
||||
m_serverConfig->readConfigString("ChatCleanerClientAuth"),
|
||||
m_serverConfig->readConfigString("ChatCleanerServerAuth"));
|
||||
m_serverConfig.readConfigString("ChatCleanerHostAddress"),
|
||||
m_serverConfig.readConfigInt("ChatCleanerPort"),
|
||||
m_serverConfig.readConfigInt("ChatCleanerUseIpv6") != 0,
|
||||
m_serverConfig.readConfigString("ChatCleanerClientAuth"),
|
||||
m_serverConfig.readConfigString("ChatCleanerServerAuth"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1008,7 +1010,7 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const InitMessage
|
||||
// Before any other processing, perform some denial of service and
|
||||
// brute force attack prevention by checking whether the user recently sent an
|
||||
// Init packet.
|
||||
if (m_serverConfig->readConfigInt("ServerBruteForceProtection") != 0)
|
||||
if (m_serverConfig.readConfigInt("ServerBruteForceProtection") != 0)
|
||||
{
|
||||
bool recentlySentInit = false;
|
||||
{
|
||||
@@ -1376,7 +1378,8 @@ ServerLobbyThread::HandleNetPacketCreateGame(SessionWrapper session, const std::
|
||||
tmpData,
|
||||
session.playerData->GetUniqueId(),
|
||||
GetGui(),
|
||||
m_serverConfig));
|
||||
m_serverConfig,
|
||||
*m_serverLog));
|
||||
game->Init();
|
||||
|
||||
// Add game to list of games.
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
ServerManager::ServerManager(GuiInterface &gui, ConfigFile *config, AvatarManager &avatarManager)
|
||||
ServerManager::ServerManager(GuiInterface &gui, ConfigFile &config, AvatarManager &avatarManager)
|
||||
: m_gui(gui), m_playerConfig(config), m_avatarManager(avatarManager)
|
||||
{
|
||||
m_ioService.reset(new boost::asio::io_service);
|
||||
|
||||
@@ -38,12 +38,13 @@ class ServerDBInterface;
|
||||
class ConfigFile;
|
||||
struct GameData;
|
||||
class Game;
|
||||
class Log;
|
||||
|
||||
class ServerGame : public boost::enable_shared_from_this<ServerGame>
|
||||
{
|
||||
public:
|
||||
ServerGame(
|
||||
boost::shared_ptr<ServerLobbyThread> lobbyThread, u_int32_t id, const std::string &name, const std::string &pwd, const GameData &gameData, unsigned adminPlayerId, GuiInterface &gui, ConfigFile *playerConfig);
|
||||
boost::shared_ptr<ServerLobbyThread> lobbyThread, u_int32_t id, const std::string &name, const std::string &pwd, const GameData &gameData, unsigned adminPlayerId, GuiInterface &gui, ConfigFile &playerConfig, Log &serverLog);
|
||||
virtual ~ServerGame();
|
||||
|
||||
void Init();
|
||||
@@ -194,7 +195,8 @@ private:
|
||||
DB_id m_dbId;
|
||||
const std::string m_name;
|
||||
const std::string m_password;
|
||||
ConfigFile *m_playerConfig;
|
||||
ConfigFile &m_playerConfig;
|
||||
Log &m_serverLog;
|
||||
unsigned m_gameNum;
|
||||
unsigned m_curPetitionId;
|
||||
unsigned m_doNotAutoKickSmallDelaySec;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <gui/guiinterface.h>
|
||||
#include <gamedata.h>
|
||||
|
||||
class Log;
|
||||
|
||||
#define NET_LOBBY_THREAD_TERMINATE_TIMEOUT_MSEC 20000
|
||||
#define NET_ADMIN_IRC_TERMINATE_TIMEOUT_MSEC 4000
|
||||
@@ -52,7 +53,7 @@ struct Gsasl;
|
||||
class ServerLobbyThread : public Thread, public boost::enable_shared_from_this<ServerLobbyThread>
|
||||
{
|
||||
public:
|
||||
ServerLobbyThread(GuiInterface &gui, ServerMode mode, ServerIrcBotCallback &ircBotCb, ConfigFile *serverConfig, AvatarManager &avatarManager,
|
||||
ServerLobbyThread(GuiInterface &gui, ServerMode mode, ServerIrcBotCallback &ircBotCb, ConfigFile &serverConfig, AvatarManager &avatarManager,
|
||||
boost::shared_ptr<boost::asio::io_service> ioService);
|
||||
virtual ~ServerLobbyThread();
|
||||
|
||||
@@ -227,13 +228,15 @@ private:
|
||||
|
||||
const ServerMode m_mode;
|
||||
std::string m_statisticsFileName;
|
||||
ConfigFile *m_serverConfig;
|
||||
ConfigFile &m_serverConfig;
|
||||
u_int32_t m_curGameId;
|
||||
|
||||
u_int32_t m_curUniquePlayerId;
|
||||
u_int32_t m_curSessionId;
|
||||
mutable boost::mutex m_curUniquePlayerIdMutex;
|
||||
|
||||
boost::shared_ptr<Log> m_serverLog;
|
||||
|
||||
ServerStats m_statData;
|
||||
bool m_statDataChanged;
|
||||
mutable boost::mutex m_statMutex;
|
||||
|
||||
@@ -40,7 +40,7 @@ class AvatarManager;
|
||||
class ServerManager
|
||||
{
|
||||
public:
|
||||
ServerManager(GuiInterface &gui, ConfigFile *config, AvatarManager &avatarManager);
|
||||
ServerManager(GuiInterface &gui, ConfigFile &config, AvatarManager &avatarManager);
|
||||
virtual ~ServerManager();
|
||||
|
||||
// Set the parameters.
|
||||
@@ -66,7 +66,7 @@ protected:
|
||||
|
||||
private:
|
||||
GuiInterface &m_gui;
|
||||
ConfigFile *m_playerConfig;
|
||||
ConfigFile &m_playerConfig;
|
||||
AvatarManager &m_avatarManager;
|
||||
|
||||
boost::shared_ptr<boost::asio::io_service> m_ioService;
|
||||
|
||||
+1
-1
@@ -268,7 +268,7 @@ void Session::startNetworkServer(bool dedicated)
|
||||
return;
|
||||
}
|
||||
|
||||
myNetServer.reset(new ServerManager(*myGui, myConfig, *myAvatarManager));
|
||||
myNetServer.reset(new ServerManager(*myGui, *myConfig, *myAvatarManager));
|
||||
|
||||
boost::shared_ptr<IrcThread> tmpIrcAdminThread;
|
||||
boost::shared_ptr<IrcThread> tmpIrcLobbyThread;
|
||||
|
||||
Reference in New Issue
Block a user