diff options
author | Max Horn | 2003-01-13 15:27:06 +0000 |
---|---|---|
committer | Max Horn | 2003-01-13 15:27:06 +0000 |
commit | d900d280c08bb5932c66ba1b9d481587e4a797fe (patch) | |
tree | ca6c1057caf12d1c1dec92063dbbe8ddd26065a2 /scumm | |
parent | 0a3bc7d36fb2764d65e2666d4f7542333f94b498 (diff) | |
download | scummvm-rg350-d900d280c08bb5932c66ba1b9d481587e4a797fe.tar.gz scummvm-rg350-d900d280c08bb5932c66ba1b9d481587e4a797fe.tar.bz2 scummvm-rg350-d900d280c08bb5932c66ba1b9d481587e4a797fe.zip |
fixed checkRange output; added checkRange call to drawObject; cleanup
svn-id: r6447
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/object.cpp | 54 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 6 |
2 files changed, 29 insertions, 31 deletions
diff --git a/scumm/object.cpp b/scumm/object.cpp index 5206baf6ff..fd95c2c062 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -188,41 +188,35 @@ void Scumm::getObjectXYPos(int object, int &x, int &y, int &dir) byte *ptr; ImageHeader *imhd; - if (!(_features & GF_SMALL_HEADER)) { - if (_features & GF_AFTER_V6) { - state = getState(object) - 1; - if (state < 0) - state = 0; - - if (od->fl_object_index) { - ptr = getResourceAddress(rtFlObject, od->fl_object_index); - ptr = findResource(MKID('OBIM'), ptr); - } else { - ptr = getResourceAddress(rtRoom, _roomResource); - ptr += od->OBIMoffset; - } - assert(ptr); - imhd = (ImageHeader *)findResourceData(MKID('IMHD'), ptr); - if (_features & GF_AFTER_V8) { - x = od->x_pos + (int32)READ_LE_UINT32(&imhd->v8.hotspot[state].x); - y = od->y_pos + (int32)READ_LE_UINT32(&imhd->v8.hotspot[state].y); - } else if (_features & GF_AFTER_V7) { - x = od->x_pos + (int16)READ_LE_UINT16(&imhd->v7.hotspot[state].x); - y = od->y_pos + (int16)READ_LE_UINT16(&imhd->v7.hotspot[state].y); - } else { - x = od->x_pos + (int16)READ_LE_UINT16(&imhd->old.hotspot[state].x); - y = od->y_pos + (int16)READ_LE_UINT16(&imhd->old.hotspot[state].y); - } + if (_features & GF_AFTER_V6) { + state = getState(object) - 1; + if (state < 0) + state = 0; + + if (od->fl_object_index) { + ptr = getResourceAddress(rtFlObject, od->fl_object_index); + ptr = findResource(MKID('OBIM'), ptr); } else { - x = od->walk_x; - y = od->walk_y; + ptr = getResourceAddress(rtRoom, _roomResource); + ptr += od->OBIMoffset; + } + assert(ptr); + imhd = (ImageHeader *)findResourceData(MKID('IMHD'), ptr); + if (_features & GF_AFTER_V8) { + x = od->x_pos + (int32)READ_LE_UINT32(&imhd->v8.hotspot[state].x); + y = od->y_pos + (int32)READ_LE_UINT32(&imhd->v8.hotspot[state].y); + } else if (_features & GF_AFTER_V7) { + x = od->x_pos + (int16)READ_LE_UINT16(&imhd->v7.hotspot[state].x); + y = od->y_pos + (int16)READ_LE_UINT16(&imhd->v7.hotspot[state].y); + } else { + x = od->x_pos + (int16)READ_LE_UINT16(&imhd->old.hotspot[state].x); + y = od->y_pos + (int16)READ_LE_UINT16(&imhd->old.hotspot[state].y); } - dir = oldDirToNewDir(od->actordir & 3); } else { x = od->walk_x; y = od->walk_y; - dir = oldDirToNewDir(od->actordir & 3); } + dir = oldDirToNewDir(od->actordir & 3); } int Scumm::getObjActToObjActDist(int a, int b) @@ -352,6 +346,8 @@ void Scumm::drawObject(int obj, int arg) if (od->obj_nr == 0) return; + checkRange(_numGlobalObjects - 1, 0, od->obj_nr, "Object %d out of range in drawObject"); + xpos = od->x_pos >> 3; ypos = od->y_pos; diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index 8c9bea8b85..b3dc865e0e 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -370,8 +370,10 @@ void Scumm::initScummVars() void Scumm::checkRange(int max, int min, int no, const char *str) { if (no < min || no > max) { - error("Value %d is out of bounds (%d,%d) int script(%d) msg %s", no, min, - max, vm.slot[_curExecScript].number, str); + char buf[1024]; + sprintf(buf, str, no); + error("Value %d is out of bounds (%d,%d) in script %d (%s)", no, min, + max, vm.slot[_curExecScript].number, buf); } } |