[Scummvm-git-logs] scummvm master -> 4e2184956aa7b0fbf6094c52e6aee72196b765f5
djsrv
dservilla at gmail.com
Thu Jun 25 19:39:20 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
4e2184956a DIRECTOR: LINGO: Load factories from Lscr
Commit: 4e2184956aa7b0fbf6094c52e6aee72196b765f5
https://github.com/scummvm/scummvm/commit/4e2184956aa7b0fbf6094c52e6aee72196b765f5
Author: djsrv (dservilla at gmail.com)
Date: 2020-06-25T15:35:56-04:00
Commit Message:
DIRECTOR: LINGO: Load factories from Lscr
Changed paths:
engines/director/lingo/lingo-bytecode.cpp
engines/director/types.h
diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp
index fdc784bd94..95e73da06a 100644
--- a/engines/director/lingo/lingo-bytecode.cpp
+++ b/engines/director/lingo/lingo-bytecode.cpp
@@ -812,13 +812,18 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, int archiveIn
// offset 36
/* uint16 unk3 = */ stream.readUint16();
- uint32 scriptTypeMask = stream.readUint32();
+ uint32 scriptFlags = stream.readUint32();
+ debugC(1, kDebugCompile, "Script flags:");
+ debugC(1, kDebugCompile, "unk0: %d global: %d unk2: %d unk3: %d", (scriptFlags & kScriptFlagUnk0) != 0, (scriptFlags & kScriptFlagGlobal) != 0, (scriptFlags & kScriptFlagUnk2) != 0, (scriptFlags & kScriptFlagUnk3) != 0);
+ debugC(1, kDebugCompile, "factoryDef: %d unk5: %d unk6: %d unk7: %d", (scriptFlags & kScriptFlagFactoryDef) != 0, (scriptFlags & kScriptFlagUnk5) != 0, (scriptFlags & kScriptFlagUnk6) != 0, (scriptFlags & kScriptFlagUnk7) != 0);
+ debugC(1, kDebugCompile, "hasFactory: %d unk9: %d unkA: %d unkB: %d", (scriptFlags & kScriptFlagHasFactory) != 0, (scriptFlags & kScriptFlagUnk9) != 0, (scriptFlags & kScriptFlagUnkA) != 0, (scriptFlags & kScriptFlagUnkB) != 0);
+ debugC(1, kDebugCompile, "unkC: %d unkD: %d unkE: %d unkF: %d", (scriptFlags & kScriptFlagUnkC) != 0, (scriptFlags & kScriptFlagUnkD) != 0, (scriptFlags & kScriptFlagUnkE) != 0, (scriptFlags & kScriptFlagUnkF) != 0);
// unk4
for (uint32 i = 0; i < 0x4; i++) {
stream.readByte();
}
uint16 castId = stream.readUint16();
- /* uint16 unk5 = */ stream.readUint16();
+ int16 factoryNameId = stream.readSint16();
// offset 50 - contents map
// TODO: I believe the handler vectors map handlers to some sort of identifier
@@ -841,30 +846,41 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, int archiveIn
Common::String castName;
Cast *member = g_director->getCastMember(castId);
if (member) {
- if (member->_type == kCastLingoScript) {
- // TODO: Determine what the other bits in the mask mean
- if (scriptTypeMask & (1 << 1))
- scriptType = kMovieScript;
- else
- scriptType = kScoreScript;
- }
+ if (member->_type == kCastLingoScript)
+ scriptType = ((ScriptCast *)member)->_scriptType;
+
CastInfo *info = member->_score->_castsInfo[castId];
if (info)
castName = info->name;
}
- debugC(1, kDebugCompile, "Add V4 bytecode for type %s with id %d", scriptType2str(scriptType), castId);
+ _assemblyArchive = archiveIndex;
- if (getScriptContext(archiveIndex, scriptType, castId)) {
- // We can't undefine context data because it could be used in e.g. symbols.
- // Abort on double definitions.
- error("Script already defined for type %d, id %d", scriptType, castId);
- return;
- }
+ Common::String factoryName;
+ if (scriptFlags & kScriptFlagFactoryDef) {
+ if (0 <= factoryNameId && factoryNameId < (int16)_archives[_assemblyArchive].names.size()) {
+ factoryName = _archives[_assemblyArchive].names[factoryNameId];
+ } else {
+ warning("Factory %d has unknown name id %d, skipping define", castId, factoryNameId);
+ return;
+ }
+ debugC(1, kDebugCompile, "Add V4 bytecode for factory '%s' with id %d", factoryName.c_str(), castId);
- _assemblyArchive = archiveIndex;
- _assemblyContext = new ScriptContext(scriptType, !castName.empty() ? castName : Common::String::format("%d", castId));
- _archives[_assemblyArchive].scriptContexts[scriptType][castId] = _assemblyContext;
+ codeFactory(factoryName);
+ _assemblyContext = _currentFactory->ctx;
+ } else {
+ debugC(1, kDebugCompile, "Add V4 bytecode for type %s with id %d", scriptType2str(scriptType), castId);
+
+ if (getScriptContext(archiveIndex, scriptType, castId)) {
+ // We can't undefine context data because it could be used in e.g. symbols.
+ // Abort on double definitions.
+ error("Script already defined for type %d, id %d", scriptType, castId);
+ return;
+ }
+
+ _assemblyContext = new ScriptContext(scriptType, !castName.empty() ? castName : Common::String::format("%d", castId));
+ _archives[_assemblyArchive].scriptContexts[scriptType][castId] = _assemblyContext;
+ }
// initialise each property
if ((uint32)stream.size() < propertiesOffset + propertiesCount * 2) {
@@ -879,7 +895,11 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, int archiveIn
if (index < _archives[_assemblyArchive].names.size()) {
const char *name = _archives[_assemblyArchive].names[index].c_str();
debugC(5, kDebugLoading, "%d: %s", i, name);
- _assemblyContext->_propNames.push_back(name);
+ if (scriptFlags & kScriptFlagFactoryDef) {
+ _currentFactory->properties[name] = Datum();
+ } else {
+ _assemblyContext->_propNames.push_back(name);
+ }
} else {
warning("Property %d has unknown name id %d, skipping define", i, index);
}
@@ -1363,6 +1383,7 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, int archiveIn
}
free(codeStore);
+ _currentFactory = nullptr;
}
diff --git a/engines/director/types.h b/engines/director/types.h
index 3fe846e847..aa0bd8a901 100644
--- a/engines/director/types.h
+++ b/engines/director/types.h
@@ -44,12 +44,31 @@ enum CastType {
enum ScriptType {
kNoneScript = -1,
kScoreScript = 0,
- kCastScript = 1, // not a canonical ID - change if it's actually used by Director
+ kCastScript = 1,
kMovieScript = 2,
- kGlobalScript = 3, // not a canonical ID
+ kGlobalScript = 3,
kMaxScriptType = 3 // Sync with score-loading.cpp:45, array scriptTypes[]
};
+enum ScriptFlag {
+ kScriptFlagUnk0 = (1 << 0x0),
+ kScriptFlagGlobal = (1 << 0x1),
+ kScriptFlagUnk2 = (1 << 0x2),
+ kScriptFlagUnk3 = (1 << 0x3),
+ kScriptFlagFactoryDef = (1 << 0x4),
+ kScriptFlagUnk5 = (1 << 0x5),
+ kScriptFlagUnk6 = (1 << 0x6),
+ kScriptFlagUnk7 = (1 << 0x7),
+ kScriptFlagHasFactory = (1 << 0x8),
+ kScriptFlagUnk9 = (1 << 0x9),
+ kScriptFlagUnkA = (1 << 0xa),
+ kScriptFlagUnkB = (1 << 0xb),
+ kScriptFlagUnkC = (1 << 0xc),
+ kScriptFlagUnkD = (1 << 0xd),
+ kScriptFlagUnkE = (1 << 0xe),
+ kScriptFlagUnkF = (1 << 0xf)
+};
+
enum ShapeType {
kShapeRectangle = 1,
kShapeRoundRect = 2,
More information about the Scummvm-git-logs
mailing list