Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/system/TurnManager.cpp
Show First 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | |||||
void CTurnManager::AddCommand(int client, int player, JS::HandleValue data, u32 turn) | void CTurnManager::AddCommand(int client, int player, JS::HandleValue data, u32 turn) | ||||
{ | { | ||||
NETTURN_LOG("AddCommand(client=%d player=%d turn=%d current=%d, ready=%d)\n", client, player, turn, m_CurrentTurn, m_ReadyTurn); | NETTURN_LOG("AddCommand(client=%d player=%d turn=%d current=%d, ready=%d)\n", client, player, turn, m_CurrentTurn, m_ReadyTurn); | ||||
// Reject commands for turns that we should not be able to compute (in the past). | // Reject commands for turns that we should not be able to compute (in the past). | ||||
if (m_CurrentTurn >= turn) | if (m_CurrentTurn >= turn) | ||||
{ | { | ||||
// The most likely explanation is that an observer that's lagging behind is sending commands, | // The most likely explanation is that an observer that's lagging behind is sending commands, | ||||
// which is possible when cheats are enabled. Report & ignore. | // which is possible when cheats are enabled (this allows coop-play). | ||||
// It seems a bad idea to error out too badly here: | // It seems like it could be desirable in the future for observers to message other observers, | ||||
// so it will be ignored then. If the target is a real player, warn about it. | |||||
// @see CNetServer::OnSimulationCommand for additional details. | |||||
if (player == -1) | |||||
return; | |||||
// Report & ignore. It seems a bad idea to error out too badly here: | |||||
// nefarious clients could try and send broken commands to DOS. | // nefarious clients could try and send broken commands to DOS. | ||||
LOGWARNING("Received command for invalid turn %i (current turn is %i)", turn, m_CurrentTurn); | LOGWARNING("Received command for player %i on invalid turn %i (current turn is %i)", player, turn, m_CurrentTurn); | ||||
return; | return; | ||||
} | } | ||||
ScriptRequest rq(m_Simulation2.GetScriptInterface()); | ScriptRequest rq(m_Simulation2.GetScriptInterface()); | ||||
Script::FreezeObject(rq, data, true); | Script::FreezeObject(rq, data, true); | ||||
size_t command_in_turns = turn - (m_CurrentTurn+1); | size_t command_in_turns = turn - (m_CurrentTurn+1); | ||||
▲ Show 20 Lines • Show All 108 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator