aboutsummaryrefslogtreecommitdiff
path: root/scumm/resource.cpp
diff options
context:
space:
mode:
authorMax Horn2005-04-23 16:52:11 +0000
committerMax Horn2005-04-23 16:52:11 +0000
commit554ecd57cbe1bf396cda807e25bd4ed832850d0c (patch)
tree1721b41a946b7ea85b7826513f16d063ac51f87b /scumm/resource.cpp
parentb43e1e960fadff6b900329ec96c32121406cb92b (diff)
downloadscummvm-rg350-554ecd57cbe1bf396cda807e25bd4ed832850d0c.tar.gz
scummvm-rg350-554ecd57cbe1bf396cda807e25bd4ed832850d0c.tar.bz2
scummvm-rg350-554ecd57cbe1bf396cda807e25bd4ed832850d0c.zip
Don't use Common::Map for the object table at all; rather use bsearch on a fixed size table.
svn-id: r17777
Diffstat (limited to 'scumm/resource.cpp')
-rw-r--r--scumm/resource.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/scumm/resource.cpp b/scumm/resource.cpp
index 060f3f83b8..668e2b3431 100644
--- a/scumm/resource.cpp
+++ b/scumm/resource.cpp
@@ -1148,18 +1148,24 @@ void ScummEngine_v8::readGlobalObjects() {
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() {