aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2016-08-23 15:52:20 +0300
committerFilippos Karapetis2016-08-23 15:52:54 +0300
commit511d9f1e402834cae8f74d3ccca02b660fd03701 (patch)
tree776b58d1fff3b6eadc30faf692d05154f93130fc /engines
parenta26a3d433877175cb1a48224c797d3172555fd8f (diff)
downloadscummvm-rg350-511d9f1e402834cae8f74d3ccca02b660fd03701.tar.gz
scummvm-rg350-511d9f1e402834cae8f74d3ccca02b660fd03701.tar.bz2
scummvm-rg350-511d9f1e402834cae8f74d3ccca02b660fd03701.zip
SCI32: Fix crash in Torin, chapter 4, catapult scene (via ScreenItem)
loopNo/celNo are set to unsigned integers in ScreenItem::setFromObject in SSCI, thus their value will be adjusted when it's negative, like in this case
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/graphics/screen_item32.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/engines/sci/graphics/screen_item32.cpp b/engines/sci/graphics/screen_item32.cpp
index 7383dc222e..f4ed269265 100644
--- a/engines/sci/graphics/screen_item32.cpp
+++ b/engines/sci/graphics/screen_item32.cpp
@@ -178,7 +178,9 @@ void ScreenItem::setFromObject(SegManager *segMan, const reg_t object, const boo
const uint8 loopCount = view->data[2];
const uint8 loopSize = view->data[12];
- if (_celInfo.loopNo >= loopCount) {
+ // loopNo is set to be an unsigned integer in SSCI, so if it's a
+ // negative value, it'll be fixed accordingly
+ if ((uint16)_celInfo.loopNo >= loopCount) {
const int maxLoopNo = loopCount - 1;
_celInfo.loopNo = maxLoopNo;
writeSelectorValue(segMan, object, SELECTOR(loop), maxLoopNo);
@@ -189,8 +191,11 @@ void ScreenItem::setFromObject(SegManager *segMan, const reg_t object, const boo
if (seekEntry != -1) {
loopData = view->data + headerSize + (seekEntry * loopSize);
}
+
+ // celNo is set to be an unsigned integer in SSCI, so if it's a
+ // negative value, it'll be fixed accordingly
const uint8 celCount = loopData[2];
- if (_celInfo.celNo >= celCount) {
+ if ((uint16)_celInfo.celNo >= celCount) {
const int maxCelNo = celCount - 1;
_celInfo.celNo = maxCelNo;
writeSelectorValue(segMan, object, SELECTOR(cel), maxCelNo);