1
0
forked from 0ad/0ad

Added safe (identical across platforms) replacement sin and cos functions for scripts. This is part of #1193.

This was SVN commit r11226.
This commit is contained in:
Jonathan Waller 2012-03-03 00:06:16 +00:00
parent 1657c34979
commit e2e5c81272

View File

@ -613,6 +613,14 @@ void ScriptInterface::ReplaceNondeterministicFunctions(boost::rand48& rng)
}
// Store the RNG in a slot which is sort-of-guaranteed to be unused by the JS engine
JS_SetReservedSlot(m->m_cx, JS_GetFunctionObject(random), 0, PRIVATE_TO_JSVAL(&rng));
// Load a script which replaces some of the system dependent trig functions
VfsPath path("globalscripts/Math.js");
if (!this->LoadGlobalScriptFile(path))
{
LOGERROR(L"ReplaceNondeterministicFunctions: failed to load globalscripts/Math.js");
return;
}
}
void ScriptInterface::Register(const char* name, JSNative fptr, size_t nargs)