diff options
-rw-r--r-- | scumm/script_v72he.cpp | 10 | ||||
-rw-r--r-- | scumm/script_v90he.cpp | 14 | ||||
-rw-r--r-- | scumm/sprite_he.cpp | 15 |
3 files changed, 21 insertions, 18 deletions
diff --git a/scumm/script_v72he.cpp b/scumm/script_v72he.cpp index 5786c5e45b..4742af19fb 100644 --- a/scumm/script_v72he.cpp +++ b/scumm/script_v72he.cpp @@ -1809,17 +1809,17 @@ void ScummEngine_v72he::o72_writeFile() { void ScummEngine_v72he::o72_findAllObjects() { int room = pop(); - int i = 1; + int i; if (room != _currentRoom) - warning("o72_findAllObjects: current room is not %d", room); + error("o72_findAllObjects: current room is not %d", room); + writeVar(0, 0); - defineArray(0, kDwordArray, 0, 0, 0, _numLocalObjects + 1); + defineArray(0, kDwordArray, 0, 0, 0, _numLocalObjects); writeArray(0, 0, 0, _numLocalObjects); - while (i < _numLocalObjects) { + for (int i = 1; i < _numLocalObjects; i++) { writeArray(0, 0, i, _objs[i].obj_nr); - i++; } push(readVar(0)); diff --git a/scumm/script_v90he.cpp b/scumm/script_v90he.cpp index 93eb115bf3..6a050e6d4d 100644 --- a/scumm/script_v90he.cpp +++ b/scumm/script_v90he.cpp @@ -1698,13 +1698,13 @@ void ScummEngine_v90he::o90_findAllObjectsWithClassOf() { num = getStackList(args, ARRAYSIZE(args)); int room = pop(); - int j = 1; + int numObjs = 0; if (room != _currentRoom) - warning("o90_findAllObjectsWithClassOf: current room is not %d", room); + error("o90_findAllObjectsWithClassOf: current room is not %d", room); writeVar(0, 0); - defineArray(0, kDwordArray, 0, 0, 0, _numLocalObjects + 1); + defineArray(0, kDwordArray, 0, 0, 0, _numLocalObjects); for (int i = 1; i < _numLocalObjects; i++) { cond = 1; tmp = num; @@ -1715,11 +1715,13 @@ void ScummEngine_v90he::o90_findAllObjectsWithClassOf() { cond = 0; } - if (cond) - writeArray(0, 0, j++, _objs[i].obj_nr); + if (cond) { + numObjs++; + writeArray(0, 0, numObjs, _objs[i].obj_nr); + } } - writeArray(0, 0, 0, j); + writeArray(0, 0, 0, numObjs); push(readVar(0)); } diff --git a/scumm/sprite_he.cpp b/scumm/sprite_he.cpp index e22b518cb1..0f5bf08abe 100644 --- a/scumm/sprite_he.cpp +++ b/scumm/sprite_he.cpp @@ -408,25 +408,26 @@ void ScummEngine_v90he::spriteInfoGet_dx_dy(int spriteId, int32 &dx, int32 &dy) // spriteGroupGet functions // int ScummEngine_v90he::spriteGroupGet_allocateGroupSpritesList(int spriteGroupId) { - int i, j = 0, sprites = 0; + int i, numSprites = 0; checkRange(_varNumSpriteGroups, 1, spriteGroupId, "Invalid sprite group %d"); - for (i = 1; i < _varNumSprites; i++) { + for (i = (_varNumSprites - 1); i > 0; i--) { if (_spriteTable[i].groupNum == spriteGroupId) - sprites++; + numSprites++; } - if (!sprites) + if (!numSprites) return 0; writeVar(0, 0); - defineArray(0, kDwordArray, 0, 0, 0, sprites); - writeArray(0, 0, 0, sprites); + defineArray(0, kDwordArray, 0, 0, 0, numSprites); + writeArray(0, 0, 0, numSprites); + numSprites = 1; for (i = (_varNumSprites - 1); i > 0; i--) { if (_spriteTable[i].groupNum == spriteGroupId) - writeArray(0, 0, ++j, i); + writeArray(0, 0, numSprites, i); } return readVar(0); |