[Scummvm-cvs-logs] CVS: scummvm/scumm object.cpp,1.25,1.26 resource.cpp,1.39,1.40 script_v8.cpp,2.24,2.25 scumm.h,1.95,1.96
Max Horn
fingolfin at users.sourceforge.net
Tue Dec 24 08:11:04 CET 2002
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv20932
Modified Files:
object.cpp resource.cpp script_v8.cpp scumm.h
Log Message:
added a map from object names to object ids
Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- object.cpp 24 Dec 2002 15:27:26 -0000 1.25
+++ object.cpp 24 Dec 2002 16:10:29 -0000 1.26
@@ -459,9 +459,9 @@
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 @@
}
} 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 @@
}
} 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
Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- resource.cpp 24 Dec 2002 02:18:02 -0000 1.39
+++ resource.cpp 24 Dec 2002 16:10:30 -0000 1.40
@@ -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 @@
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 @@
_objectOwnerTable[i] &= OF_OWNER_MASK;
}
}
-
+
if (!(_features & GF_AFTER_V8)) {
_fileHandle.read(_classData, num * sizeof(uint32));
Index: script_v8.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v8.cpp,v
retrieving revision 2.24
retrieving revision 2.25
diff -u -d -r2.24 -r2.25
--- script_v8.cpp 24 Dec 2002 15:23:24 -0000 2.24
+++ script_v8.cpp 24 Dec 2002 16:10:30 -0000 2.25
@@ -1676,4 +1676,4 @@
1FE SO_510
1FF SO_511
-*/
\ No newline at end of file
+*/
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -d -r1.95 -r1.96
--- scumm.h 23 Dec 2002 23:30:14 -0000 1.95
+++ scumm.h 24 Dec 2002 16:10:31 -0000 1.96
@@ -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 Serializer;
struct FindObjectInRoom;
+typedef ScummVM::Map<ScummVM::String, int> ObjectIDMap;
+
// Use g_scumm from error() ONLY
extern Scumm *g_scumm;
@@ -404,6 +408,7 @@
void startScene(int room, Actor *a, int b);
virtual void setupScummVars();
byte *_objectOwnerTable, *_objectRoomTable, *_objectStateTable;
+ ObjectIDMap _objectIDMap;
byte _numObjectsInRoom;
int8 _userPut;
int _resourceHeaderSize;
More information about the Scummvm-git-logs
mailing list