aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2003-05-22 15:27:44 +0000
committerMax Horn2003-05-22 15:27:44 +0000
commit871df7fb57d18ec72e787cf3cbb9c719a386eaee (patch)
tree264a5c57005ca8d454917e71dcaa15317b107ee9 /scumm
parenta6c8b58045e4f2de019fcadc951a344b5b2c5a99 (diff)
downloadscummvm-rg350-871df7fb57d18ec72e787cf3cbb9c719a386eaee.tar.gz
scummvm-rg350-871df7fb57d18ec72e787cf3cbb9c719a386eaee.tar.bz2
scummvm-rg350-871df7fb57d18ec72e787cf3cbb9c719a386eaee.zip
restricted getObjectIndex to only search thru _objs, not _inventory(to avoid future confusion), this might cause regressions, though; fixed o2_getObjPreposition; adapted some code to the changed getObjectIndex
svn-id: r7829
Diffstat (limited to 'scumm')
-rw-r--r--scumm/object.cpp17
-rw-r--r--scumm/script.cpp4
-rw-r--r--scumm/script_v2.cpp10
3 files changed, 25 insertions, 6 deletions
diff --git a/scumm/object.cpp b/scumm/object.cpp
index 15cbcfb346..5c2db5cb96 100644
--- a/scumm/object.cpp
+++ b/scumm/object.cpp
@@ -129,7 +129,21 @@ int Scumm::getObjectIndex(int object) {
if (object < 1)
return -1;
- /* OF_OWNER_ROOM should be 0xFF for full throttle, else 0xF */
+#if 1
+ for (i = (_numLocalObjects-1); i > 0; i--) {
+ if (_objs[i].obj_nr == object)
+ return i;
+ }
+ return -1;
+#else
+ // FIXME: this function searches thru the _inventory. Yet almost all
+ // functions calling it assumg the index will always be into _objs.
+ // For script_v2.cpp this already caused some hard to track buglets.
+ // Maybe it also causes problems in other places. The question is,
+ // under which cirumstances would the _inventory result ever be
+ // useful for us?
+
+ // OF_OWNER_ROOM should be 0xFF for full throttle, else 0xF
if (_objectOwnerTable[object] != OF_OWNER_ROOM) {
for (i = 0; i < _maxInventoryItems; i++)
if (_inventory[i] == object)
@@ -142,6 +156,7 @@ int Scumm::getObjectIndex(int object) {
}
return -1;
}
+#endif
}
int Scumm::whereIsObject(int object) {
diff --git a/scumm/script.cpp b/scumm/script.cpp
index 0e96083cb4..73d508c96f 100644
--- a/scumm/script.cpp
+++ b/scumm/script.cpp
@@ -344,7 +344,9 @@ void Scumm::getScriptBaseAddress() {
ss = &vm.slot[_currentScript];
switch (ss->where) {
case WIO_INVENTORY: /* inventory script * */
- idx = getObjectIndex(ss->number);
+ for (idx = 0; idx < _maxInventoryItems; idx++)
+ if (_inventory[idx] == ss->number)
+ break;
_scriptOrgPointer = getResourceAddress(rtInventory, idx);
assert(idx < _maxInventoryItems);
_lastCodePtr = &_baseInventoryItems[idx];
diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp
index 1fdcc2bd92..632a3c2ffe 100644
--- a/scumm/script_v2.cpp
+++ b/scumm/script_v2.cpp
@@ -517,8 +517,10 @@ void Scumm_v2::o2_setObjPreposition() {
int unk = fetchScriptByte();
if (whereIsObject(obj) != WIO_NOT_FOUND) {
- ObjectData *od = &_objs[getObjectIndex(obj)];
- od->walk_y = (unk << 5) | (od->walk_y & 0x1F);
+ // FIXME: this might not work properly the moment we save and restore the game.
+ byte *ptr = getOBCDFromObject(obj) + 12;
+ *ptr &= 0x1F;
+ *ptr |= unk << 5;
}
}
@@ -527,8 +529,8 @@ void Scumm_v2::o2_getObjPreposition() {
int obj = getVarOrDirectWord(0x80);
if (whereIsObject(obj) != WIO_NOT_FOUND) {
- ObjectData *od = &_objs[getObjectIndex(obj)];
- setResult(od->walk_y >> 5);
+ byte *ptr = getOBCDFromObject(obj) + 12;
+ setResult(*ptr >> 5);
} else {
setResult(0xFF);
}