Implementing optional unlimited thinking time in LAN games on server side (GUI missing) ticket #24

This commit is contained in:
lotodore
2011-02-06 10:37:40 +00:00
parent 8c9a17f7db
commit e729647cec
6 changed files with 19 additions and 9 deletions
+8 -1
View File
@@ -1002,9 +1002,16 @@ ServerGame::CheckPassword(const string &password) const
}
bool
ServerGame::CheckSettings(const GameData &data, const string &password)
ServerGame::CheckSettings(const GameData &data, const string &password, ServerMode mode)
{
bool retVal = true;
if (mode != SERVER_MODE_LAN)
{
if (data.playerActionTimeoutSec < 5)
{
retVal = false;
}
}
if (data.gameType == GAME_TYPE_RANKING)
{
if ((data.startMoney != RANKING_GAME_START_CASH)
+7 -4
View File
@@ -1315,10 +1315,13 @@ ServerGameStateWaitPlayerAction::Enter(boost::shared_ptr<ServerGame> server)
int timeoutSec = server->GetGameData().playerActionTimeoutSec + SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC;
#endif
server->GetStateTimer1().expires_from_now(boost::posix_time::seconds(timeoutSec));
server->GetStateTimer1().async_wait(
boost::bind(
&ServerGameStateWaitPlayerAction::TimerTimeout, this, boost::asio::placeholders::error, server));
if (timeoutSec != SERVER_PLAYER_TIMEOUT_ADD_DELAY_SEC) // minimum value means unlimited thinking time
{
server->GetStateTimer1().expires_from_now(boost::posix_time::seconds(timeoutSec));
server->GetStateTimer1().async_wait(
boost::bind(
&ServerGameStateWaitPlayerAction::TimerTimeout, this, boost::asio::placeholders::error, server));
}
}
void
+1 -1
View File
@@ -1405,7 +1405,7 @@ ServerLobbyThread::HandleNetPacketCreateGame(SessionWrapper session, const std::
{
SendJoinGameFailed(session.sessionData, gameId, NTF_NET_JOIN_GUEST_FORBIDDEN);
}
else if (!ServerGame::CheckSettings(tmpData, password))
else if (!ServerGame::CheckSettings(tmpData, password, GetServerMode()))
{
SendJoinGameFailed(session.sessionData, gameId, NTF_NET_JOIN_INVALID_SETTINGS);
}