mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
DIRECTOR: LINGO: Add name to ScriptContext
This commit is contained in:
@@ -738,7 +738,7 @@ void LC::cb_zeropush() {
|
||||
g_lingo->push(d);
|
||||
}
|
||||
|
||||
void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, int archiveIndex, ScriptType type, uint16 id, Common::String &archName) {
|
||||
void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, int archiveIndex, ScriptType type, uint16 id, Common::String &scriptName, Common::String &archName) {
|
||||
debugC(1, kDebugCompile, "Add V4 bytecode for type %s with id %d", scriptType2str(type), id);
|
||||
|
||||
if (getScriptContext(archiveIndex, type, id)) {
|
||||
@@ -752,6 +752,8 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, int archiveIn
|
||||
_assemblyContext = new ScriptContext;
|
||||
_archives[_assemblyArchive].scriptContexts[type][id] = _assemblyContext;
|
||||
|
||||
_assemblyContext->name = !scriptName.empty() ? scriptName : Common::String::format("%d", id);
|
||||
|
||||
if (stream.size() < 0x5c) {
|
||||
warning("Lscr header too small");
|
||||
return;
|
||||
|
||||
@@ -253,7 +253,7 @@ const char *Lingo::findNextDefinition(const char *s) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ScriptContext *Lingo::addCode(const char *code, int archiveIndex, ScriptType type, uint16 id) {
|
||||
ScriptContext *Lingo::addCode(const char *code, int archiveIndex, ScriptType type, uint16 id, const char *scriptName) {
|
||||
debugC(1, kDebugCompile, "Add code for type %s(%d) with id %d\n"
|
||||
"***********\n%s\n\n***********", scriptType2str(type), type, id, code);
|
||||
|
||||
@@ -270,6 +270,11 @@ ScriptContext *Lingo::addCode(const char *code, int archiveIndex, ScriptType typ
|
||||
if (archiveIndex >= 0)
|
||||
_archives[_assemblyArchive].scriptContexts[type][id] = _assemblyContext;
|
||||
|
||||
if (scriptName && strlen(scriptName) > 0)
|
||||
_assemblyContext->name = Common::String(scriptName);
|
||||
else
|
||||
_assemblyContext->name = Common::String::format("%d", id);
|
||||
|
||||
_methodVars = new Common::HashMap<Common::String, VarType, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo>();
|
||||
_linenumber = _colnumber = 1;
|
||||
_hadError = false;
|
||||
@@ -355,15 +360,8 @@ ScriptContext *Lingo::addCode(const char *code, int archiveIndex, ScriptType typ
|
||||
|
||||
currentFunc.type = HANDLER;
|
||||
currentFunc.u.defn = _currentAssembly;
|
||||
// guess the name. don't actually bind it to the event, there's a seperate
|
||||
// triggering mechanism for that.
|
||||
if (type == kScoreScript) {
|
||||
currentFunc.name = new Common::String("[score script]");
|
||||
} else if (type == kCastScript) {
|
||||
currentFunc.name = new Common::String("[cast script");
|
||||
} else {
|
||||
currentFunc.name = new Common::String("[unknown]");
|
||||
}
|
||||
Common::String typeStr = Common::String(scriptType2str(type));
|
||||
currentFunc.name = new Common::String("[" + typeStr + " " + _assemblyContext->name + "]");
|
||||
currentFunc.ctx = _currentScriptContext;
|
||||
currentFunc.archiveIndex = _assemblyArchive;
|
||||
// arg names should be empty, but just in case
|
||||
|
||||
@@ -214,6 +214,7 @@ typedef Common::HashMap<Common::String, TheEntity *, Common::IgnoreCase_Hash, Co
|
||||
typedef Common::HashMap<Common::String, TheEntityField *, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> TheEntityFieldHash;
|
||||
|
||||
struct ScriptContext {
|
||||
Common::String name;
|
||||
Common::Array<Symbol> functions; // used only by bytecode
|
||||
Common::HashMap<uint32, Symbol> eventHandlers;
|
||||
SymbolHash functionHandlers;
|
||||
@@ -315,8 +316,8 @@ public:
|
||||
|
||||
void restartLingo(bool keepSharedCast);
|
||||
|
||||
ScriptContext *addCode(const char *code, int archiveIndex, ScriptType type, uint16 id);
|
||||
void addCodeV4(Common::SeekableSubReadStreamEndian &stream, int archiveIndex, ScriptType type, uint16 id, Common::String &archName);
|
||||
ScriptContext *addCode(const char *code, int archiveIndex, ScriptType type, uint16 id, const char *scriptName = nullptr);
|
||||
void addCodeV4(Common::SeekableSubReadStreamEndian &stream, int archiveIndex, ScriptType type, uint16 id, Common::String &scriptName, Common::String &archName);
|
||||
void addNamesV4(Common::SeekableSubReadStreamEndian &stream, int archiveIndex);
|
||||
void executeHandler(const Common::String &name);
|
||||
void executeScript(ScriptType type, uint16 id);
|
||||
|
||||
@@ -873,7 +873,7 @@ void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id,
|
||||
if (scriptId < _castScriptIds.size()) {
|
||||
int resourceId = _castScriptIds[scriptId];
|
||||
Common::SeekableSubReadStreamEndian *r;
|
||||
_lingo->addCodeV4(*(r = _movieArchive->getResource(MKTAG('L', 's', 'c', 'r'), resourceId)), _lingoArchive, ((ScriptCast *)member)->_scriptType, id, _macName);
|
||||
_lingo->addCodeV4(*(r = _movieArchive->getResource(MKTAG('L', 's', 'c', 'r'), resourceId)), _lingoArchive, ((ScriptCast *)member)->_scriptType, id, ci->name, _macName);
|
||||
delete r;
|
||||
} else {
|
||||
warning("Score::loadCastData(): Lingo context missing a resource entry for script %d referenced in cast %d", scriptId, id);
|
||||
@@ -889,7 +889,7 @@ void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id,
|
||||
if (ConfMan.getBool("dump_scripts"))
|
||||
dumpScript(ci->script.c_str(), scriptType, id);
|
||||
|
||||
_lingo->addCode(ci->script.c_str(), _lingoArchive, scriptType, id);
|
||||
_lingo->addCode(ci->script.c_str(), _lingoArchive, scriptType, id, ci->name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1127,7 +1127,7 @@ void Score::loadCastInfo(Common::SeekableSubReadStreamEndian &stream, uint16 id)
|
||||
dumpScript(ci->script.c_str(), kCastScript, id);
|
||||
|
||||
if (!ci->script.empty())
|
||||
_lingo->addCode(ci->script.c_str(), _lingoArchive, kCastScript, id);
|
||||
_lingo->addCode(ci->script.c_str(), _lingoArchive, kCastScript, id, ci->name.c_str());
|
||||
|
||||
ci->name = getString(castStrings[1]);
|
||||
ci->directory = getString(castStrings[2]);
|
||||
|
||||
Reference in New Issue
Block a user