Skip to content

Commit ebd409c

Browse files
authored
Merge pull request #1752 from marauder2k9-torque/ScriptFix-ParentCallWithoutThis
Script Fix for Parent call that does not use %this
2 parents c2c5674 + 721b849 commit ebd409c

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

Engine/source/console/torquescript/compiledEval.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,10 +1981,22 @@ Con::EvalResult CodeBlock::exec(U32 ip, const char* functionName, Namespace* thi
19811981
}
19821982
else // it's a ParentCall
19831983
{
1984-
ConsoleValue& simObjectLookupValue = callArgv[1];
1985-
thisObject = getThisObject(simObjectLookupValue);
1984+
if (callArgc > 1)
1985+
{
1986+
ConsoleValue& simObjectLookupValue = callArgv[1];
1987+
thisObject = getThisObject(simObjectLookupValue);
1988+
}
19861989

1987-
if (thisObject == NULL)
1990+
// The grammar does NOT prepend anything. callArgv[1] is either
1991+
// a plain script argument (Parent::func(%arg)) or an explicitly
1992+
// passed %this (Parent::method(%this, %arg)) — the programmer's
1993+
// choice. For plain function parent calls callArgv[1] is never
1994+
// an object, so getThisObject returning NULL is expected and
1995+
// correct, not an error condition. The old guard was aborting
1996+
// these calls with a misleading "unable to find object" error
1997+
// using the value of %arg as the object name.
1998+
1999+
/*if (thisObject == NULL)
19882000
{
19892001
Con::warnf(
19902002
ConsoleLogEntry::General,
@@ -1998,7 +2010,7 @@ Con::EvalResult CodeBlock::exec(U32 ip, const char* functionName, Namespace* thi
19982010
stack[_STK + 1].setEmptyString();
19992011
_STK++;
20002012
break;
2001-
}
2013+
}*/
20022014

20032015
if (thisNamespace)
20042016
{

0 commit comments

Comments
 (0)