diff options
author | Eugene Sandulenko | 2016-06-18 15:43:05 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 6d2a7aa7590775950aa76f363cb83d4844b4fe04 (patch) | |
tree | 44722a9651005a13bb80597300fa94da52a1dcc7 | |
parent | 53dceb95f70774096a1653693286e86092f3bc0a (diff) | |
download | scummvm-rg350-6d2a7aa7590775950aa76f363cb83d4844b4fe04.tar.gz scummvm-rg350-6d2a7aa7590775950aa76f363cb83d4844b4fe04.tar.bz2 scummvm-rg350-6d2a7aa7590775950aa76f363cb83d4844b4fe04.zip |
DIRECTOR: Lingo: Fix codeString() method
-rw-r--r-- | engines/director/lingo/lingo.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp index c96e353a52..141f227af8 100644 --- a/engines/director/lingo/lingo.cpp +++ b/engines/director/lingo/lingo.cpp @@ -82,16 +82,18 @@ Lingo::~Lingo() { int Lingo::codeString(const char *str) { int instLen = sizeof(inst); - int numInsts = (strlen(str) + 1 + instLen - 1) % instLen; + int numInsts = strlen(str) / instLen + (strlen(str) + 1 + instLen - 1) % instLen; - // Allocate needed space in script - _currentScript->push_back(0); - char *start = (char *)(&_currentScript->back()); + // Where we copy the string over + int pos = _currentScript->size(); - for (int i = 0; i < numInsts - 1; i++) + // Allocate needed space in script + for (int i = 0; i < numInsts; i++) _currentScript->push_back(0); - Common::strlcpy(start, str, numInsts * instLen); + byte *dst = (byte *)&_currentScript->front() + pos * sizeof(inst); + + memcpy(dst, str, strlen(str) + 1); return _currentScript->size(); } @@ -107,6 +109,8 @@ void Lingo::addCode(Common::String code, ScriptType type, uint16 id) { _scripts[type][id] = _currentScript; parse(code.c_str()); + + Common::hexdump((byte *)&_currentScript->front(), _currentScript->size() * sizeof(inst)); } void Lingo::processEvent(LEvent event, int entityId) { |