diff options
| -rw-r--r-- | scumm/object.cpp | 18 | ||||
| -rw-r--r-- | scumm/resource.cpp | 11 | ||||
| -rw-r--r-- | scumm/script_v8.cpp | 2 | ||||
| -rw-r--r-- | scumm/scumm.h | 7 | 
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; | 
