From 3016d6b3b2809ae03c50ae3ce158dafe6be52ca5 Mon Sep 17 00:00:00 2001 From: lotodore Date: Sat, 11 Sep 2010 21:37:27 +0000 Subject: [PATCH] Make small delay which prevents auto-kick from occurring configurable. --- src/config/configfile.cpp | 3 ++- src/net/common/servergame.cpp | 12 ++++++++++-- src/net/common/servergamestate.cpp | 2 +- src/net/servergame.h | 3 +++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/config/configfile.cpp b/src/config/configfile.cpp index b7aeda83..dcb84058 100644 --- a/src/config/configfile.cpp +++ b/src/config/configfile.cpp @@ -50,7 +50,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly) myConfigState = OK; // !!!! Revisionsnummer der Configdefaults !!!!! - configRev = 87; + configRev = 88; //standard defaults logOnOffDefault = "1"; @@ -201,6 +201,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly) configList.push_back(ConfigInfo("ServerPutAvatarsAddress", CONFIG_TYPE_STRING, "")); configList.push_back(ConfigInfo("ServerPutAvatarsUser", CONFIG_TYPE_STRING, "")); configList.push_back(ConfigInfo("ServerPutAvatarsPassword", CONFIG_TYPE_STRING, "")); + configList.push_back(ConfigInfo("ServerDoNotAutoKickSmallDelaySec", CONFIG_TYPE_STRING, "10")); configList.push_back(ConfigInfo("InternetServerConfigMode", CONFIG_TYPE_INT, "0")); configList.push_back(ConfigInfo("InternetServerListAddress", CONFIG_TYPE_STRING, "pokerth.net/serverlist.xml.z")); configList.push_back(ConfigInfo("InternetServerAddress", CONFIG_TYPE_STRING, "pokerth.6dns.org")); diff --git a/src/net/common/servergame.cpp b/src/net/common/servergame.cpp index 13840dcd..bd91adec 100644 --- a/src/net/common/servergame.cpp +++ b/src/net/common/servergame.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #define SERVER_CHECK_VOTE_KICK_INTERVAL_MSEC 500 @@ -50,8 +51,8 @@ ServerGame::ServerGame(boost::shared_ptr lobbyThread, u_int32 : 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_voteKickTimer(lobbyThread->GetIOService()), m_stateTimer1(lobbyThread->GetIOService()), - m_stateTimer2(lobbyThread->GetIOService()) + m_doNotAutoKickSmallDelaySec(10), m_voteKickTimer(lobbyThread->GetIOService()), + m_stateTimer1(lobbyThread->GetIOService()), m_stateTimer2(lobbyThread->GetIOService()) { LOG_VERBOSE("Game object " << GetId() << " created."); @@ -66,6 +67,7 @@ ServerGame::~ServerGame() void ServerGame::Init() { + m_doNotAutoKickSmallDelaySec = m_playerConfig->readConfigInt("ServerDoNotAutoKickSmallDelaySec"); m_voteKickTimer.expires_from_now( boost::posix_time::milliseconds(SERVER_CHECK_VOTE_KICK_INTERVAL_MSEC)); m_voteKickTimer.async_wait( @@ -911,6 +913,12 @@ ServerGame::GetReceiver() return *m_receiver; } +unsigned +ServerGame::GetSmallDelaySec() const +{ + return m_doNotAutoKickSmallDelaySec; +} + Game & ServerGame::GetGame() { diff --git a/src/net/common/servergamestate.cpp b/src/net/common/servergamestate.cpp index ea9288ab..d9067faa 100644 --- a/src/net/common/servergamestate.cpp +++ b/src/net/common/servergamestate.cpp @@ -1360,7 +1360,7 @@ ServerGameStateWaitPlayerAction::TimerTimeout(const boost::system::error_code &e curPlayer->incrementActionTimeoutCounter(); if (server->GetGameData().gameType == GAME_TYPE_RANKING - && server->GetGameData().playerActionTimeoutSec >= 10) + && server->GetGameData().playerActionTimeoutSec >= server->GetSmallDelaySec()) { if (curPlayer->getActionTimeoutCounter() == SERVER_WARNING_ACTION_TIMEOUT_THRESHOLD) { diff --git a/src/net/servergame.h b/src/net/servergame.h index 0c59d143..ab407dc9 100644 --- a/src/net/servergame.h +++ b/src/net/servergame.h @@ -86,6 +86,8 @@ public: void RemovePlayerInvitation(unsigned playerId); bool IsPlayerInvited(unsigned playerId) const; + unsigned GetSmallDelaySec() const; + // should be protected, but is needed in function. const Game &GetGame() const; Game &GetGame(); @@ -188,6 +190,7 @@ private: ConfigFile *m_playerConfig; unsigned m_gameNum; unsigned m_curPetitionId; + unsigned m_doNotAutoKickSmallDelaySec; boost::asio::deadline_timer m_voteKickTimer; boost::asio::deadline_timer m_stateTimer1; boost::asio::deadline_timer m_stateTimer2;