mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-12 14:09:28 +00:00
DIRECTOR: LINGO: Don't warn when replacing script is expected
This commit is contained in:
parent
ef082abc6e
commit
fa01b6d434
@ -1850,7 +1850,7 @@ void LB::b_installMenu(int nargs) {
|
||||
while (mainArchive->getScriptContext(kEventScript, commandId)) {
|
||||
commandId++;
|
||||
}
|
||||
mainArchive->addCode(command.decode(Common::kMacRoman), kEventScript, commandId);
|
||||
mainArchive->replaceCode(command.decode(Common::kMacRoman), kEventScript, commandId);
|
||||
submenuText += Common::String::format("[%d];", commandId);
|
||||
} else {
|
||||
submenuText += ';';
|
||||
|
@ -106,7 +106,7 @@ void Movie::setPrimaryEventHandler(LEvent event, const Common::String &code) {
|
||||
debugC(3, kDebugLingoExec, "setting primary event handler (%s)", _lingo->_eventHandlerTypes[event]);
|
||||
LingoArchive *mainArchive = getMainLingoArch();
|
||||
mainArchive->primaryEventHandlers[event] = code;
|
||||
mainArchive->addCode(code, kEventScript, event);
|
||||
mainArchive->replaceCode(code, kEventScript, event);
|
||||
}
|
||||
|
||||
void Movie::queueSpriteEvent(Common::Queue<LingoEvent> &queue, LEvent event, int eventId, int spriteId) {
|
||||
|
@ -715,7 +715,7 @@ bool CastMember::setField(int field, const Datum &d) {
|
||||
warning("CastMember::setField(): CastMember info for %d not found", _castId);
|
||||
return false;
|
||||
}
|
||||
_cast->_lingoArchive->addCode(*d.u.s, kCastScript, _castId);
|
||||
_cast->_lingoArchive->replaceCode(*d.u.s, kCastScript, _castId);
|
||||
castInfo->script = d.asString();
|
||||
return true;
|
||||
case kTheWidth:
|
||||
|
@ -1219,7 +1219,7 @@ void Lingo::setTheMenuItemEntity(int entity, Datum &menuId, int field, Datum &me
|
||||
int commandId = 100;
|
||||
while (mainArchive->getScriptContext(kEventScript, commandId))
|
||||
commandId++;
|
||||
mainArchive->addCode(d.asString(), kEventScript, commandId);
|
||||
mainArchive->replaceCode(d.asString(), kEventScript, commandId);
|
||||
|
||||
if (menuId.type == STRING && menuItemId.type == STRING)
|
||||
g_director->_wm->setMenuItemAction(menuId.asString(), menuItemId.asString(), commandId);
|
||||
|
@ -256,6 +256,8 @@ void LingoArchive::addCode(const Common::U32String &code, ScriptType type, uint1
|
||||
|
||||
if (getScriptContext(type, id)) {
|
||||
// Replace the pre-existing context but warn about it.
|
||||
// For cases where replacing the script context is expected (e.g. 'when' event handlers)
|
||||
// use replaceCode instead of addCode.
|
||||
warning("Script already defined for type %d, id %d", type, id);
|
||||
removeCode(type, id);
|
||||
}
|
||||
@ -285,6 +287,11 @@ void LingoArchive::removeCode(ScriptType type, uint16 id) {
|
||||
scriptContexts[type].erase(id);
|
||||
}
|
||||
|
||||
void LingoArchive::replaceCode(const Common::U32String &code, ScriptType type, uint16 id, const char *scriptName) {
|
||||
removeCode(type, id);
|
||||
addCode(code, type, id, scriptName);
|
||||
}
|
||||
|
||||
void Lingo::printStack(const char *s, uint pc) {
|
||||
Common::String stack(s);
|
||||
|
||||
|
@ -271,6 +271,7 @@ struct LingoArchive {
|
||||
|
||||
void addCode(const Common::U32String &code, ScriptType type, uint16 id, const char *scriptName = nullptr);
|
||||
void removeCode(ScriptType type, uint16 id);
|
||||
void replaceCode(const Common::U32String &code, ScriptType type, uint16 id, const char *scriptName = nullptr);
|
||||
void addCodeV4(Common::SeekableReadStreamEndian &stream, uint16 lctxIndex, const Common::String &archName, uint16 version);
|
||||
void addNamesV4(Common::SeekableReadStreamEndian &stream);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user