aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorColin Snover2016-10-27 20:04:30 -0500
committerColin Snover2016-10-27 20:23:10 -0500
commite12496bd0c2a15d4e7701422ca9fd860482dcb1f (patch)
tree7cb59af2c2fd915ad6d7d105d046458ae718cce2 /engines/sci
parent9b1a2555f950738fa9ef2cbe5b5fba54a500715c (diff)
downloadscummvm-rg350-e12496bd0c2a15d4e7701422ca9fd860482dcb1f.tar.gz
scummvm-rg350-e12496bd0c2a15d4e7701422ca9fd860482dcb1f.tar.bz2
scummvm-rg350-e12496bd0c2a15d4e7701422ca9fd860482dcb1f.zip
SCI32: Read byte/string array values as signed in SCI2.1early-
KQ7 1.51 writes int16s from the save game catalogue into a Str object, then retrieves byte 0 from the string and compares it to -1. This happens to work out because (1) characters were treated as signed in SCI2.1early and earlier, and (2) int16s in the save game catalogue were little-endian. In SCI2.1mid and later, this trick no longer works because characters are treated as unsigned and get zero-extended instead. Fixes Trac#9632.
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/segment.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h
index 361c1cb895..e8f0be3a79 100644
--- a/engines/sci/engine/segment.h
+++ b/engines/sci/engine/segment.h
@@ -552,8 +552,17 @@ public:
case kArrayTypeID:
return ((reg_t *)_data)[index];
case kArrayTypeByte:
- case kArrayTypeString:
- return make_reg(0, ((byte *)_data)[index]);
+ case kArrayTypeString: {
+ int16 value;
+
+ if (getSciVersion() < SCI_VERSION_2_1_MIDDLE) {
+ value = ((int8 *)_data)[index];
+ } else {
+ value = ((uint8 *)_data)[index];
+ }
+
+ return make_reg(0, value);
+ }
default:
error("Invalid array type %d", _type);
}