Skip to content

Commit

Permalink
DIRECTOR: Lingo: Implemented script execution
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Aug 3, 2016
1 parent 76282dc commit b367690
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions engines/director/lingo/lingo.cpp
Expand Up @@ -100,6 +100,8 @@ int Lingo::codeString(const char *str) {
}

void Lingo::addCode(Common::String code, ScriptType type, uint16 id) {
code += '\n';

debug(2, "Add code \"%s\" for type %d with id %d", code.c_str(), type, id);

if (_scripts[type].contains(id)) {
Expand All @@ -114,6 +116,17 @@ void Lingo::addCode(Common::String code, ScriptType type, uint16 id) {
Common::hexdump((byte *)&_currentScript->front(), _currentScript->size() * sizeof(inst));
}

void Lingo::executeScript(ScriptType type, uint16 id) {
if (!_scripts[type].contains(id)) {
warning("Request to execute non-existant script type %d id %d", type, id);
return;
}

for(_pc = &_scripts[type][id]->front(); *_pc != STOP;) {
(*((++_pc)[-1]))();
}
}

void Lingo::processEvent(LEvent event, int entityId) {
if (!_eventHandlerTypes.contains(event))
error("processEvent: Unknown event %d for entity %d", event, entityId);
Expand Down
1 change: 1 addition & 0 deletions engines/director/lingo/lingo.h
Expand Up @@ -99,6 +99,7 @@ class Lingo {
~Lingo();

void addCode(Common::String code, ScriptType type, uint16 id);
void executeScript(ScriptType type, uint16 id);

void processEvent(LEvent event, int entityId);

Expand Down

0 comments on commit b367690

Please sign in to comment.