# Basic in-game building placement with new simulation system

This was SVN commit r7285.
This commit is contained in:
Ykkrosh
2010-01-24 17:24:35 +00:00
parent 0d9c9d646b
commit 953fb41c82
26 changed files with 421 additions and 27 deletions
+13 -1
View File
@@ -327,8 +327,20 @@ jsval ScriptInterface::GetGlobalObject()
return OBJECT_TO_JSVAL(JS_GetGlobalObject(m->m_cx));
}
bool ScriptInterface::SetGlobal_(const char* name, jsval value)
bool ScriptInterface::SetGlobal_(const char* name, jsval value, bool replace)
{
if (!replace)
{
JSBool found;
if (!JS_HasProperty(m->m_cx, m->m_glob, name, &found))
return false;
if (found)
{
JS_ReportError(m->m_cx, "SetGlobal \"%s\" called multiple times", name);
return false;
}
}
JSBool ok = JS_DefineProperty(m->m_cx, m->m_glob, name, value, NULL, NULL, JSPROP_ENUMERATE | JSPROP_READONLY
| JSPROP_PERMANENT);
return ok ? true : false;