diff options
author | Filippos Karapetis | 2012-06-11 11:51:54 +0300 |
---|---|---|
committer | Filippos Karapetis | 2012-06-11 11:54:11 +0300 |
commit | b812ed50c8f6d9a24b607831a88a398730458d9a (patch) | |
tree | cdeaa369c0c7adee32ae228e3f54624da2699ce9 /engines | |
parent | 0ccfd614aa935ed38a4fce7888c91ff1429691f1 (diff) | |
download | scummvm-rg350-b812ed50c8f6d9a24b607831a88a398730458d9a.tar.gz scummvm-rg350-b812ed50c8f6d9a24b607831a88a398730458d9a.tar.bz2 scummvm-rg350-b812ed50c8f6d9a24b607831a88a398730458d9a.zip |
SCI: Bugfix for negative numbers in kString(at)
Fixes one of the bugs in the savegame selection screen in Phantasmagoria
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/kstring.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp index fe8d631497..0877e37a65 100644 --- a/engines/sci/engine/kstring.cpp +++ b/engines/sci/engine/kstring.cpp @@ -653,10 +653,18 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) { case 1: // Size return make_reg(0, s->_segMan->getString(argv[1]).size()); case 2: { // At (return value at an index) - if (argv[1].segment == s->_segMan->getStringSegmentId()) - return make_reg(0, s->_segMan->lookupString(argv[1])->getRawData()[argv[2].toUint16()]); - - return make_reg(0, s->_segMan->getString(argv[1])[argv[2].toUint16()]); + // Note that values need to be truncated to bytes, otherwise + // 0xff (negative char -1) will incorrectly be changed to + // 0xffff (negative int16 -1) + if (argv[1].segment == s->_segMan->getStringSegmentId()) { + SciString *string = s->_segMan->lookupString(argv[1]); + byte val = string->getRawData()[argv[2].toUint16()]; + return make_reg(0, val); + } else { + Common::String string = s->_segMan->getString(argv[1]); + byte val = string[argv[2].toUint16()]; + return make_reg(0, val); + } } case 3: { // Atput (put value at an index) SciString *string = s->_segMan->lookupString(argv[1]); |