SCI: Added pointer arithmetic support for SCI2 strings

svn-id: r54365
This commit is contained in:
Filippos Karapetis 2010-11-19 10:28:43 +00:00
parent 6ec8ec416b
commit c19e8377f9

View File

@ -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