Deepfreeze the map settings object (created from g_GameAttributes.settings by the gamesetup extending the map JSON data) to prevent random map scripts from unintentionally modifying that, refs #4257.

This was SVN commit r20265.
This commit is contained in:
elexis 2017-10-06 18:53:24 +00:00
parent a8b8a33c8e
commit 1fcdc3d7f4

View File

@ -119,6 +119,13 @@ bool CMapGeneratorWorker::Run()
return false;
}
// Prevent unintentional modifications to the settings object by random map scripts
if (!m_ScriptInterface->FreezeObject(settingsVal, true))
{
LOGERROR("CMapGeneratorWorker::Run: Failed to deepfreeze settings");
return false;
}
// Init RNG seed
u32 seed = 0;
if (!m_ScriptInterface->HasProperty(settingsVal, "Seed") ||
@ -129,7 +136,7 @@ bool CMapGeneratorWorker::Run()
// Copy settings to global variable
JS::RootedValue global(cx, m_ScriptInterface->GetGlobalObject());
if (!m_ScriptInterface->SetProperty(global, "g_MapSettings", settingsVal))
if (!m_ScriptInterface->SetProperty(global, "g_MapSettings", settingsVal, true, true))
{
LOGERROR("CMapGeneratorWorker::Run: Failed to define g_MapSettings");
return false;