aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2002-12-24 16:10:31 +0000
committerMax Horn2002-12-24 16:10:31 +0000
commit190685dc69dad12563ccf8ed3689ec1f34cff360 (patch)
tree540f3044d93a6049b8f3e862be44dceb59dff68b /scumm
parent22ab263b002c2f0946fa56c2463860f64b384278 (diff)
downloadscummvm-rg350-190685dc69dad12563ccf8ed3689ec1f34cff360.tar.gz
scummvm-rg350-190685dc69dad12563ccf8ed3689ec1f34cff360.tar.bz2
scummvm-rg350-190685dc69dad12563ccf8ed3689ec1f34cff360.zip
added a map from object names to object ids
svn-id: r6104
Diffstat (limited to 'scumm')
-rw-r--r--scumm/object.cpp18
-rw-r--r--scumm/resource.cpp11
-rw-r--r--scumm/script_v8.cpp2
-rw-r--r--scumm/scumm.h7
4 files changed, 23 insertions, 15 deletions
diff --git a/scumm/object.cpp b/scumm/object.cpp
index 25a526624f..a28f7fdd36 100644
--- a/scumm/object.cpp
+++ b/scumm/object.cpp
@@ -459,9 +459,9 @@ void Scumm::loadRoomObjects()
imhd = (ImageHeader *)findResourceData(MKID('IMHD'), ptr);
if (_features & GF_AFTER_V8)
- // FIXME - in v8, IMHD seems to contain no obj_id, but rather a name string
- // EVIL HACK to allow loading of the first COMI room
- obim_id = 1373 + i;
+ // In V8, IMHD has no obj_id, but rather a name string. We map the name
+ // back to an object id using a table derived from the DOBJ resource.
+ obim_id = _objectIDMap[imhd->v8.name];
else if (_features & GF_AFTER_V7)
obim_id = READ_LE_UINT16(&imhd->v7.obj_id);
else
@@ -901,11 +901,7 @@ void Scumm::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, uint
}
} else {
cdhd = (CodeHeader *)findResourceData(MKID('CDHD'), obcdptr);
- if (_features & GF_AFTER_V8)
- // FIXME - in v8, IMHD seems to contain no obj_id, but rather a name string
- id2 = 0;
-// id2 = READ_LE_UINT32(&(cdhd->v8.obj_id));
- else if (_features & GF_AFTER_V7)
+ if (_features & GF_AFTER_V7)
id2 = READ_LE_UINT16(&(cdhd->v7.obj_id));
else if (_features & GF_AFTER_V6)
id2 = READ_LE_UINT16(&(cdhd->v6.obj_id));
@@ -942,9 +938,9 @@ void Scumm::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, uint
}
} else {
if (_features & GF_AFTER_V8)
- // FIXME - in v8, IMHD seems to contain no obj_id, but rather a name string
- id3 = 0;
-// id3 = READ_LE_UINT32(&imhd->v8.obj_id);
+ // In V8, IMHD has no obj_id, but rather a name string. We map the name
+ // back to an object id using a table derived from the DOBJ resource.
+ id3 = _objectIDMap[imhd->v8.name];
else if (_features & GF_AFTER_V7)
id3 = READ_LE_UINT16(&imhd->v7.obj_id);
else
diff --git a/scumm/resource.cpp b/scumm/resource.cpp
index 475e80bbc0..1d49f702b5 100644
--- a/scumm/resource.cpp
+++ b/scumm/resource.cpp
@@ -25,6 +25,8 @@
#include "resource.h"
#include "verbs.h"
#include "scumm/sound.h"
+#include "common/map.h"
+#include "common/str.h"
#include <stdio.h>
@@ -274,8 +276,13 @@ void Scumm::readIndexFile()
assert(num == _numGlobalObjects);
if (_features & GF_AFTER_V8) { /* FIXME: Not sure.. */
+ char buffer[40];
for (i = 0; i < num; i++) {
- _fileHandle.seek(40, SEEK_CUR);
+ _fileHandle.read(buffer, 40);
+ if (buffer[0]) {
+ // Add to object name-to-id map
+ _objectIDMap[buffer] = i;
+ }
_objectStateTable[i] = _fileHandle.readByte();
_objectRoomTable[i] = _fileHandle.readByte();
_classData[i] = _fileHandle.readUint32LE();
@@ -292,7 +299,7 @@ void Scumm::readIndexFile()
_objectOwnerTable[i] &= OF_OWNER_MASK;
}
}
-
+
if (!(_features & GF_AFTER_V8)) {
_fileHandle.read(_classData, num * sizeof(uint32));
diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp
index ef6121f3c2..40d4ae1aed 100644
--- a/scumm/script_v8.cpp
+++ b/scumm/script_v8.cpp
@@ -1676,4 +1676,4 @@ The following are subopcodes - just strip the leading 1
1FE SO_510
1FF SO_511
-*/ \ No newline at end of file
+*/
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 08cec56057..c89fae7682 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -25,8 +25,10 @@
#include "common/engine.h"
#include "common/gameDetector.h"
-#include "common/timer.h"
#include "common/file.h"
+#include "common/map.h"
+#include "common/str.h"
+#include "common/timer.h"
#include "common/util.h"
class GameDetector;
@@ -43,6 +45,8 @@ class ScummDebugger;
class Serializer;
struct FindObjectInRoom;
+typedef ScummVM::Map<ScummVM::String, int> ObjectIDMap;
+
// Use g_scumm from error() ONLY
extern Scumm *g_scumm;
@@ -404,6 +408,7 @@ public:
void startScene(int room, Actor *a, int b);
virtual void setupScummVars();
byte *_objectOwnerTable, *_objectRoomTable, *_objectStateTable;
+ ObjectIDMap _objectIDMap;
byte _numObjectsInRoom;
int8 _userPut;
int _resourceHeaderSize;