diff options
author | Eugene Sandulenko | 2016-07-10 13:34:43 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 46138a2c9dc1fd333f40bee3e661dc83dff06e43 (patch) | |
tree | e40a0110bfeea498d1b639a5604f68b4024a22d4 | |
parent | 1f0005c4e269ec8d9b848b85e40ab11d7d67a979 (diff) | |
download | scummvm-rg350-46138a2c9dc1fd333f40bee3e661dc83dff06e43.tar.gz scummvm-rg350-46138a2c9dc1fd333f40bee3e661dc83dff06e43.tar.bz2 scummvm-rg350-46138a2c9dc1fd333f40bee3e661dc83dff06e43.zip |
DIRECTOR: Lingo: Made addCode() accept const char *
-rw-r--r-- | engines/director/lingo/lingo.cpp | 16 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 2 | ||||
-rw-r--r-- | engines/director/score.cpp | 18 |
3 files changed, 19 insertions, 17 deletions
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp index 26fdfc2edb..a7362d18b9 100644 --- a/engines/director/lingo/lingo.cpp +++ b/engines/director/lingo/lingo.cpp @@ -100,10 +100,10 @@ Lingo::Lingo(DirectorEngine *vm) : _vm(vm) { Lingo::~Lingo() { } -void Lingo::addCode(Common::String code, ScriptType type, uint16 id) { +void Lingo::addCode(const char *code, ScriptType type, uint16 id) { code += '\n'; - debug(2, "Add code \"%s\" for type %d with id %d", code.c_str(), type, id); + debug(2, "Add code \"%s\" for type %d with id %d", code, type, id); if (_scripts[type].contains(id)) { delete _scripts[type][id]; @@ -115,15 +115,17 @@ void Lingo::addCode(Common::String code, ScriptType type, uint16 id) { _linenumber = _colnumber = 1; + const char *begin, *end; + // macros have conflicting grammar. Thus we ease life for the parser. - if (code.contains("\nmacro ")) { - const char *begin = strstr(code.c_str(), "\nmacro ") + 1; - const char *end; + if ((begin = strstr(code, "\nmacro "))) { bool first = true; + begin += 1; + while ((end = strstr(begin, "\nmacro "))) { if (first) { - begin = code.c_str(); + begin = code; first = false; } Common::String chunk(begin, end); @@ -137,7 +139,7 @@ void Lingo::addCode(Common::String code, ScriptType type, uint16 id) { parse(begin); } else { - parse(code.c_str()); + parse(code); code1(STOP); } diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 6aa7917ff4..1509c1d36e 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -135,7 +135,7 @@ public: Lingo(DirectorEngine *vm); ~Lingo(); - void addCode(Common::String code, ScriptType type, uint16 id); + void addCode(const char *code, ScriptType type, uint16 id); void executeScript(ScriptType type, uint16 id); void processEvent(LEvent event, int entityId); diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 24d0b3494f..4ca299846f 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -340,8 +340,8 @@ void Score::loadActions(Common::SeekableSubReadStreamEndian &stream) { Common::HashMap<uint16, Common::String>::iterator j; for (j = _actions.begin(); j != _actions.end(); ++j) - if (j->_value != "") - _lingo->addCode(j->_value, kFrameScript, j->_key); + if (!j->_value.empty()) + _lingo->addCode(j->_value.c_str(), kFrameScript, j->_key); if (!ConfMan.getBool("dump_scripts")) return; @@ -368,10 +368,10 @@ void Score::loadScriptText(Common::SeekableSubReadStreamEndian &stream) { script += ch; } - if (script != "") - _lingo->addCode(script, kMovieScript, _movieScriptCount); + if (!script.empty()) + _lingo->addCode(script.c_str(), kMovieScript, _movieScriptCount); - if (ConfMan.getBool("dump_scripts") && (script != "")) { + if (ConfMan.getBool("dump_scripts") && (!script.empty())) { dumpScript(_movieScriptCount, kMovieScript, script); } @@ -427,8 +427,8 @@ void Score::loadCastInfo(Common::SeekableSubReadStreamEndian &stream, uint16 id) ci->script = castStrings[0]; - if (ci->script != "") { - _lingo->addCode(ci->script, kSpriteScript, id); + if (!ci->script.empty()) { + _lingo->addCode(ci->script.c_str(), kSpriteScript, id); } if (!ConfMan.getBool("dump_scripts")) { @@ -525,8 +525,8 @@ void Score::loadFileInfo(Common::SeekableSubReadStreamEndian &stream) { Common::Array<Common::String> fileInfoStrings = loadStrings(stream, _flags); _script = fileInfoStrings[0]; - if (_script != "") { - _lingo->addCode(_script, kMovieScript, _movieScriptCount); + if (!_script.empty()) { + _lingo->addCode(_script.c_str(), kMovieScript, _movieScriptCount); } if (!ConfMan.getBool("dump_scripts")) { |