2017-01-23 18:04:50 -08:00
|
|
|
/* Copyright (C) 2017 Wildfire Games.
|
|
|
|
|
* This file is part of 0 A.D.
|
|
|
|
|
*
|
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
|
|
#include "LocalTurnManager.h"
|
|
|
|
|
|
|
|
|
|
CLocalTurnManager::CLocalTurnManager(CSimulation2& simulation, IReplayLogger& replay)
|
Increase MP Command delay to 4 turns, decrease MP turns to 200ms.
To hide network latency, MP turns send commands not for the next turn
but N turns after that (introduced in c684c211a2).
Further, MP turn length was increased to 500ms compared to 200ms SP
turns (introduced in 6a15b78c98).
Unfortunately, increasing MP turn length has negative consequences:
- makes pathfinding/unit motion much worse & unit behaviour worse in
general.
- makes the game more 'lag-spikey', since computations are done less
often, but thus then can take more time.
This diff essentially reverts 6a15b78c98, instead increasing
COMMAND_DELAY from 2 to 4 in MP. This:
- Reduces the 'inherent command lag' in MP from 1000ms to 800ms
- Increases the lag range at which MP will run smoothtly from 500ms to
600ms
- makes SP and MP turns behave identically again, removing the
hindrances described above.
As a side effect, single-player was not actually using COMMAND_DELAY,
this is now done (can be used to simulate MP command lag).
Refs #3752
Differential Revision: https://code.wildfiregames.com/D3275
This was SVN commit r25001.
2021-03-03 13:02:57 -08:00
|
|
|
: CTurnManager(simulation, DEFAULT_TURN_LENGTH, COMMAND_DELAY_SP, 0, replay)
|
2017-01-23 18:04:50 -08:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-01 03:52:59 -07:00
|
|
|
void CLocalTurnManager::PostCommand(player_id_t playerid, JS::HandleValue data)
|
|
|
|
|
{
|
Increase MP Command delay to 4 turns, decrease MP turns to 200ms.
To hide network latency, MP turns send commands not for the next turn
but N turns after that (introduced in c684c211a2).
Further, MP turn length was increased to 500ms compared to 200ms SP
turns (introduced in 6a15b78c98).
Unfortunately, increasing MP turn length has negative consequences:
- makes pathfinding/unit motion much worse & unit behaviour worse in
general.
- makes the game more 'lag-spikey', since computations are done less
often, but thus then can take more time.
This diff essentially reverts 6a15b78c98, instead increasing
COMMAND_DELAY from 2 to 4 in MP. This:
- Reduces the 'inherent command lag' in MP from 1000ms to 800ms
- Increases the lag range at which MP will run smoothtly from 500ms to
600ms
- makes SP and MP turns behave identically again, removing the
hindrances described above.
As a side effect, single-player was not actually using COMMAND_DELAY,
this is now done (can be used to simulate MP command lag).
Refs #3752
Differential Revision: https://code.wildfiregames.com/D3275
This was SVN commit r25001.
2021-03-03 13:02:57 -08:00
|
|
|
AddCommand(m_ClientId, playerid, data, m_CurrentTurn + m_CommandDelay);
|
2020-08-01 03:52:59 -07:00
|
|
|
}
|
|
|
|
|
|
2017-01-23 18:04:50 -08:00
|
|
|
void CLocalTurnManager::PostCommand(JS::HandleValue data)
|
|
|
|
|
{
|
Increase MP Command delay to 4 turns, decrease MP turns to 200ms.
To hide network latency, MP turns send commands not for the next turn
but N turns after that (introduced in c684c211a2).
Further, MP turn length was increased to 500ms compared to 200ms SP
turns (introduced in 6a15b78c98).
Unfortunately, increasing MP turn length has negative consequences:
- makes pathfinding/unit motion much worse & unit behaviour worse in
general.
- makes the game more 'lag-spikey', since computations are done less
often, but thus then can take more time.
This diff essentially reverts 6a15b78c98, instead increasing
COMMAND_DELAY from 2 to 4 in MP. This:
- Reduces the 'inherent command lag' in MP from 1000ms to 800ms
- Increases the lag range at which MP will run smoothtly from 500ms to
600ms
- makes SP and MP turns behave identically again, removing the
hindrances described above.
As a side effect, single-player was not actually using COMMAND_DELAY,
this is now done (can be used to simulate MP command lag).
Refs #3752
Differential Revision: https://code.wildfiregames.com/D3275
This was SVN commit r25001.
2021-03-03 13:02:57 -08:00
|
|
|
AddCommand(m_ClientId, m_PlayerId, data, m_CurrentTurn + m_CommandDelay);
|
2017-01-23 18:04:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLocalTurnManager::NotifyFinishedOwnCommands(u32 turn)
|
|
|
|
|
{
|
|
|
|
|
FinishedAllCommands(turn, m_TurnLength);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLocalTurnManager::NotifyFinishedUpdate(u32 UNUSED(turn))
|
|
|
|
|
{
|
|
|
|
|
#if 0 // this hurts performance and is only useful for verifying log replays
|
|
|
|
|
std::string hash;
|
|
|
|
|
{
|
|
|
|
|
PROFILE3("state hash check");
|
|
|
|
|
ENSURE(m_Simulation2.ComputeStateHash(hash));
|
|
|
|
|
}
|
|
|
|
|
m_Replay.Hash(hash);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLocalTurnManager::OnSimulationMessage(CSimulationMessage* UNUSED(msg))
|
|
|
|
|
{
|
|
|
|
|
debug_warn(L"This should never be called");
|
|
|
|
|
}
|