[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.458,2.459 object.cpp,1.232,1.233 resource.cpp,1.319,1.320 scumm.cpp,1.459,1.460
Max Horn
fingolfin at users.sourceforge.net
Sat Apr 23 09:52:33 CEST 2005
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4883
Modified Files:
intern.h object.cpp resource.cpp scumm.cpp
Log Message:
Don't use Common::Map for the object table at all; rather use bsearch on a fixed size table.
Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.458
retrieving revision 2.459
diff -u -d -r2.458 -r2.459
--- intern.h 23 Apr 2005 16:09:22 -0000 2.458
+++ intern.h 23 Apr 2005 16:52:03 -0000 2.459
@@ -23,8 +23,6 @@
#ifndef INTERN_H
#define INTERN_H
-#include "common/map.h"
-
#include "scumm/scumm.h"
#include "scumm/wiz_he.h"
@@ -1264,12 +1262,16 @@
const OpcodeEntryV8 *_opcodesV8;
- typedef Common::Map<Common::String, int> ObjectIDMap;
-
- ObjectIDMap _objectIDMap;
+ struct ObjectNameId {
+ char name[40];
+ int id;
+ };
+ int _objectIDMapSize;
+ ObjectNameId *_objectIDMap;
public:
- ScummEngine_v8(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v7(detector, syst, gs, md5sum) {}
+ ScummEngine_v8(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]);
+ ~ScummEngine_v8();
protected:
virtual void setupOpcodes();
Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.232
retrieving revision 1.233
diff -u -d -r1.232 -r1.233
--- object.cpp 20 Apr 2005 23:53:27 -0000 1.232
+++ object.cpp 23 Apr 2005 16:52:07 -0000 1.233
@@ -1093,7 +1093,10 @@
// 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.
const ImageHeader *imhd = (const ImageHeader *)findResourceData(MKID('IMHD'), obim);
- return _objectIDMap[imhd->v8.name];
+ ObjectNameId *found = (ObjectNameId *)bsearch(imhd->v8.name, _objectIDMap, _objectIDMapSize,
+ sizeof(ObjectNameId), (int (*)(const void*, const void*))strcmp);
+ assert(found);
+ return found->id;
}
int ScummEngine_v7::getObjectIdFromOBIM(const byte *obim) {
Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
retrieving revision 1.319
retrieving revision 1.320
diff -u -d -r1.319 -r1.320
--- resource.cpp 20 Apr 2005 23:33:32 -0000 1.319
+++ resource.cpp 23 Apr 2005 16:52:08 -0000 1.320
@@ -1148,18 +1148,24 @@
int num = _fileHandle->readUint32LE();
assert(num == _numGlobalObjects);
- char buffer[40];
+ _objectIDMap = new ObjectNameId[num];
+ _objectIDMapSize = num;
for (i = 0; i < num; i++) {
- _fileHandle->read(buffer, 40);
- if (buffer[0]) {
- // Add to object name-to-id map
- _objectIDMap[buffer] = i;
- }
+ // Add to object name-to-id map
+ _fileHandle->read(_objectIDMap[i].name, 40);
+ _objectIDMap[i].id = i;
+
_objectStateTable[i] = _fileHandle->readByte();
_objectRoomTable[i] = _fileHandle->readByte();
_classData[i] = _fileHandle->readUint32LE();
}
memset(_objectOwnerTable, 0xFF, num);
+
+ // Finally, sort the object name->ID map, so we can later use
+ // bsearch on it. For this we (ab)use strcmp, which works fine
+ // since the table entries start with a string.
+ qsort(_objectIDMap, _objectIDMapSize, sizeof(ObjectNameId),
+ (int (*)(const void*, const void*))strcmp);
}
void ScummEngine_v7::readGlobalObjects() {
Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.459
retrieving revision 1.460
diff -u -d -r1.459 -r1.460
--- scumm.cpp 23 Apr 2005 13:52:27 -0000 1.459
+++ scumm.cpp 23 Apr 2005 16:52:11 -0000 1.460
@@ -1287,6 +1287,16 @@
VAR_WIZ_TCOLOR = 0xFF;
}
+ScummEngine_v8::ScummEngine_v8(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16])
+ : ScummEngine_v7(detector, syst, gs, md5sum) {
+ _objectIDMap = 0;
+}
+
+ScummEngine_v8::~ScummEngine_v8() {
+ delete [] _objectIDMap;
+}
+
+
#pragma mark -
#pragma mark --- Initialization ---
#pragma mark -
More information about the Scummvm-git-logs
mailing list