DIRECTOR: Fix resolution of "me" objects

In factory methods, the first argument is usually the "me" object.
When calling the method from a different script context, this is used
to set Lingo's current me object. However, when calling the method
from the -same- script context, this is ignored. You can pass whatever
nonsense you like in as argument 1; the value will be ignored and
"me" will resolve as the current me object.

Fixes several broken scripts in The Dark Eye.
This commit is contained in:
Scott Percival 2023-11-02 23:56:27 +08:00 committed by Eugene Sandulenko
parent e4c00147ad
commit 1851b9eee3
2 changed files with 7 additions and 5 deletions

View File

@ -633,11 +633,9 @@ void LC::cb_thepush() {
warning("cb_thepush: me object has no property '%s', type: %d", name.c_str(), g_lingo->_state->me.type);
} else {
warning("cb_thepush: no me object");
g_lingo->lingoError("cb_thepush: no me object");
}
Datum result;
result.type = VOID;
g_lingo->push(result);
g_lingo->pushVoid();
}
void LC::cb_thepush2() {

View File

@ -1653,7 +1653,11 @@ Datum Lingo::varFetch(const Datum &var, bool silent) {
{
Common::String name = *var.u.s;
g_debugger->varReadHook(name);
if (_state->localVars && _state->localVars->contains(name)) {
// "me" is a special case; even if there is a local variable or argument called "me",
// the current me object will take precedence.
if (name == "me" && _state->me.type == OBJECT) {
return _state->me;
} else if (_state->localVars && _state->localVars->contains(name)) {
return (*_state->localVars)[name];
}
debugC(1, kDebugLingoExec, "varFetch: local variable %s not defined", name.c_str());