diff options
-rw-r--r-- | engines/sci/engine/vm.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 94fa016790..80500f74d1 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -641,6 +641,30 @@ static reg_t pointer_add(EngineState *s, reg_t base, int offset) { base.offset += offset; return base; + case SEG_TYPE_STRING: { + // We need to copy over the string into a new one + // Make sure that the offset is positive + if (offset < 0) + error("pointer_add: Attempt to reference a previous offset of a SCI string"); + + // Get the source string... + SciString *str = s->_segMan->lookupString(base); + Common::String rawStr = str->toString(); + + // ...and copy it to a new one + reg_t newStringAddr; + SciString *newStr = s->_segMan->allocateString(&newStringAddr); + newStr->setSize(str->getSize() - offset); + + // Cut off characters till we reach the desired location + for (int i = 0; i < offset; i++) + rawStr.deleteChar(0); + + newStr->fromString(rawStr); + + return newStringAddr; + } + default: // FIXME: Changed this to warning, because iceman does this during dancing with girl. // Investigate why that is so and either fix the underlying issue or implement a more |