From 5c650274fc4664f0c2c73c5485d2728db08ea761 Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sun, 6 Mar 2005 02:03:18 +0000 Subject: Correct class_flag checks for sprites svn-id: r16996 --- scumm/sprite_he.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'scumm') diff --git a/scumm/sprite_he.cpp b/scumm/sprite_he.cpp index 399afcebfd..252c7d4c7b 100644 --- a/scumm/sprite_he.cpp +++ b/scumm/sprite_he.cpp @@ -39,7 +39,7 @@ void ScummEngine_v90he::allocateArrays() { // spriteInfoGet functions // int ScummEngine_v90he::findSpriteWithClassOf(int x, int y, int spriteGroupId, int d, int num, int *args) { - int classId; + int code, classId; debug(1, "findSprite: x %d, y %d, spriteGroup %d, d %d, num %d", x, y, spriteGroupId, d, num); for (int i = 0; i < _numSpritesToProcess; ++i) { @@ -51,10 +51,16 @@ int ScummEngine_v90he::findSpriteWithClassOf(int x, int y, int spriteGroupId, in continue; for (int j = 0; j < num; j++) { - classId = args[j] & 0x7F; + code = classId = args[j]; + classId &= 0x7F; checkRange(32, 1, classId, "class %d out of range in statement"); - if (!(spi->class_flags & (1 << classId))) - continue; + if (code & 0x80) { + if ((spi->class_flags & (1 << classId))) + return 0; + } else { + if (!(spi->class_flags & (1 << classId))) + return 0; + } } if (d) { @@ -146,7 +152,7 @@ int ScummEngine_v90he::spriteInfoGet_classFlags(int spriteId, int classId) { } int ScummEngine_v90he::spriteInfoGet_classFlagsAnd(int spriteId, int num, int *args) { - int classId; + int code, classId; checkRange(_varNumSprites, 1, spriteId, "Invalid sprite %d"); @@ -154,10 +160,16 @@ int ScummEngine_v90he::spriteInfoGet_classFlagsAnd(int spriteId, int num, int *a return 1; for (int i = 0; i < num; i++) { - classId = args[i] & 0x7F; + code = classId = args[i]; + classId &= 0x7F; checkRange(32, 1, classId, "class %d out of range in statement"); - if (!(_spriteTable[spriteId].class_flags & (1 << classId))) - return 0; + if (code & 0x80) { + if ((_spriteTable[spriteId].class_flags & (1 << classId))) + return 0; + } else { + if (!(_spriteTable[spriteId].class_flags & (1 << classId))) + return 0; + } } return 1; -- cgit v1.2.3