Use one timer less per game (optimisation).

This commit is contained in:
lotodore
2010-10-19 13:13:39 +00:00
parent 3575fc3baf
commit 045218c2e3
+8 -7
View File
@@ -68,12 +68,6 @@ 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(
boost::bind(
&ServerGame::TimerVoteKick, shared_from_this(), boost::asio::placeholders::error));
SetState(SERVER_INITIAL_STATE::Instance());
}
@@ -228,7 +222,6 @@ ServerGame::TimerVoteKick(const boost::system::error_code &ec)
// This petition has ended.
m_voteKickData.reset();
}
}
m_voteKickTimer.expires_from_now(
boost::posix_time::milliseconds(SERVER_CHECK_VOTE_KICK_INTERVAL_MSEC));
m_voteKickTimer.async_wait(
@@ -236,6 +229,7 @@ ServerGame::TimerVoteKick(const boost::system::error_code &ec)
&ServerGame::TimerVoteKick, shared_from_this(), boost::asio::placeholders::error));
}
}
}
void
ServerGame::InternalStartGame()
@@ -437,6 +431,13 @@ ServerGame::InternalAskVoteKick(SessionWrapper byWhom, unsigned playerIdWho, uns
netStartPetition->kickTimeoutSec = timeoutSec;
netStartPetition->numVotesNeededToKick = m_voteKickData->numVotesToKick;
SendToAllPlayers(packet, SessionData::Game);
m_voteKickTimer.expires_from_now(
boost::posix_time::milliseconds(SERVER_CHECK_VOTE_KICK_INTERVAL_MSEC));
m_voteKickTimer.async_wait(
boost::bind(
&ServerGame::TimerVoteKick, shared_from_this(), boost::asio::placeholders::error));
}
else
InternalDenyAskVoteKick(byWhom, playerIdWho, KICK_DENIED_OTHER_IN_PROGRESS);