mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-12 19:31:41 +00:00
Added error checking for using a local variable in global scope, and added optimization to method object parameter.
This commit is contained in:
parent
bfc0109485
commit
bb12638ea5
2 changed files with 25 additions and 10 deletions
|
|
@ -1682,7 +1682,16 @@ ConsoleValue CodeBlock::exec(U32 ip, const char* functionName, Namespace* thisNa
|
|||
if (simObjectLookupValue.getType() == ConsoleValueType::cvInteger)
|
||||
gEvalState.thisObject = Sim::findObject(static_cast<SimObjectId>(simObjectLookupValue.getInt()));
|
||||
else
|
||||
gEvalState.thisObject = Sim::findObject(simObjectLookupValue.getString());
|
||||
{
|
||||
SimObject *foundObject = Sim::findObject(simObjectLookupValue.getString());
|
||||
|
||||
// Optimization: If we're not an integer, let's make it so that the fast path exists
|
||||
// on the first argument of the method call (speeds up future usage of %this, for example)
|
||||
if (foundObject != NULL)
|
||||
callArgv[1].setInt(static_cast<S64>(foundObject->getId()));
|
||||
|
||||
gEvalState.thisObject = foundObject;
|
||||
}
|
||||
|
||||
if (gEvalState.thisObject == NULL)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue