DIRECTOR: LINGO: Don't add scripts w/o cast member

This commit is contained in:
djsrv 2020-08-04 21:25:40 -04:00
parent 6b2ed3c8ca
commit dabc82efdb
4 changed files with 7 additions and 6 deletions

View File

@ -983,7 +983,7 @@ void Cast::loadLingoContext(Common::SeekableSubReadStreamEndian &stream) {
// actually define scripts
for (ScriptContextHash::iterator it = _lingoArchive->lctxContexts.begin(); it != _lingoArchive->lctxContexts.end(); ++it) {
ScriptContext *script = it->_value;
if (!script->isFactory()) {
if (script->_id >= 0 && !script->isFactory()) {
if (_lingoArchive->getScriptContext(script->_scriptType, script->_id)) {
error("Cast::loadLingoContext: Script already defined for type %s, id %d", scriptType2str(script->_scriptType), script->_id);
}

View File

@ -921,7 +921,7 @@ ScriptContext *Lingo::compileLingoV4(Common::SeekableSubReadStreamEndian &stream
ScriptType scriptType = kCastScript;
Common::String castName;
CastMember *member = g_director->getCurrentMovie()->getCastMemberByScriptId(scriptId);
uint16 castId;
int castId;
if (member) {
if (member->_type == kCastLingoScript)
scriptType = ((ScriptCastMember *)member)->_scriptType;
@ -931,8 +931,9 @@ ScriptContext *Lingo::compileLingoV4(Common::SeekableSubReadStreamEndian &stream
if (info)
castName = info->name;
} else {
warning("Script %d has no associated cast member", scriptId);
scriptType = kNoneScript;
castId = -1;
warning("Script %d has invalid cast member %d", scriptId, castId);
}
_assemblyArchive = archive;

View File

@ -150,7 +150,7 @@ void LM::m_dispose(int nargs) {
/* ScriptContext */
ScriptContext::ScriptContext(Common::String name, LingoArchive *archive, ScriptType type, uint16 id)
ScriptContext::ScriptContext(Common::String name, LingoArchive *archive, ScriptType type, int id)
: Object<ScriptContext>(name), _archive(archive), _scriptType(type), _id(id) {
_objType = kScriptObj;
}

View File

@ -181,7 +181,7 @@ class ScriptContext : public Object<ScriptContext> {
public:
LingoArchive *_archive;
ScriptType _scriptType;
uint16 _id;
int _id;
Common::Array<Common::String> _functionNames; // used by cb_localcall
SymbolHash _functionHandlers;
Common::HashMap<uint32, Symbol> _eventHandlers;
@ -190,7 +190,7 @@ public:
Common::HashMap<uint32, Datum> _objArray;
public:
ScriptContext(Common::String name, LingoArchive *archive = nullptr, ScriptType type = kNoneScript, uint16 id = 0);
ScriptContext(Common::String name, LingoArchive *archive = nullptr, ScriptType type = kNoneScript, int id = 0);
ScriptContext(const ScriptContext &sc);
virtual ~ScriptContext();