DIRECTOR: LINGO: Make m_perform inject the current object into the stack

Fixes the dialogue trees in Total Distortion.
This commit is contained in:
Scott Percival 2021-09-19 14:15:52 +08:00
parent 7c145266b6
commit 9c6d95e041
2 changed files with 6 additions and 4 deletions

View File

@ -1456,7 +1456,7 @@ void LC::call(const Common::String &name, int nargs, bool allowRetVal) {
objName.type = VARREF;
Datum obj = g_lingo->varFetch(objName, true);
if (obj.type == OBJECT && (obj.u.obj->getObjType() & (kFactoryObj | kXObj))) {
debugC(3, kDebugLingoExec, "Method called on object: <%s>", obj.asString(true).c_str());
debugC(3, kDebugLingoExec, "Factory/XObject method called on object: <%s>", obj.asString(true).c_str());
AbstractObject *target = obj.u.obj;
if (firstArg.u.s->equalsIgnoreCase("mNew")) {
target = target->clone();
@ -1475,7 +1475,7 @@ void LC::call(const Common::String &name, int nargs, bool allowRetVal) {
// Script/Xtra method call
if (firstArg.type == OBJECT && !(firstArg.u.obj->getObjType() & (kFactoryObj | kXObj))) {
debugC(3, kDebugLingoExec, "Method called on object: <%s>", firstArg.asString(true).c_str());
debugC(3, kDebugLingoExec, "Script/Xtra method called on object: <%s>", firstArg.asString(true).c_str());
AbstractObject *target = firstArg.u.obj;
if (name.equalsIgnoreCase("birth") || name.equalsIgnoreCase("new")) {
target = target->clone();

View File

@ -381,10 +381,12 @@ void LM::m_put(int nargs) {
void LM::m_perform(int nargs) {
// Lingo doesn't seem to bother cloning the object when
// mNew is called with mPerform
AbstractObject *me = g_lingo->_currentMe.u.obj;
Datum d(g_lingo->_currentMe);
AbstractObject *me = d.u.obj;
Datum methodName = g_lingo->_stack.remove_at(g_lingo->_stack.size() - nargs); // Take method name out of stack
nargs -= 1;
Symbol funcSym = me->getMethod(*methodName.u.s);
// Object methods expect the first argument to be the object
g_lingo->_stack.insert_at(g_lingo->_stack.size() - nargs + 1, d);
LC::call(funcSym, nargs, true);
}