1
0
forked from 0ad/0ad

Deep freeze simulation commands to prevent accidental updates. Fixes #3647.

This was SVN commit r17673.
This commit is contained in:
leper 2016-01-18 22:24:50 +00:00
parent e035e3e985
commit f34dc412b6
2 changed files with 3 additions and 1 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2015 Wildfire Games. /* Copyright (C) 2016 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@ -298,6 +298,7 @@ void CNetTurnManager::AddCommand(int client, int player, JS::HandleValue data, u
return; return;
} }
m_Simulation2.GetScriptInterface().FreezeObject(data, true);
m_QueuedCommands[turn - (m_CurrentTurn+1)][client].emplace_back(player, m_Simulation2.GetScriptInterface().GetContext(), data); m_QueuedCommands[turn - (m_CurrentTurn+1)][client].emplace_back(player, m_Simulation2.GetScriptInterface().GetContext(), data);
} }

View File

@ -164,6 +164,7 @@ public:
JSContext* cxNew = newScript.GetContext(); JSContext* cxNew = newScript.GetContext();
JSAutoRequest rqNew(cxNew); JSAutoRequest rqNew(cxNew);
JS::RootedValue tmpCommand(cxNew, newScript.CloneValueFromOtherContext(oldScript, command.data)); JS::RootedValue tmpCommand(cxNew, newScript.CloneValueFromOtherContext(oldScript, command.data));
newScript.FreezeObject(tmpCommand, true);
SimulationCommand cmd(command.player, cxNew, tmpCommand); SimulationCommand cmd(command.player, cxNew, tmpCommand);
newCommands.emplace_back(std::move(cmd)); newCommands.emplace_back(std::move(cmd));
} }