diff options
Diffstat (limited to 'engines/scumm')
-rw-r--r-- | engines/scumm/debugger.cpp | 4 | ||||
-rw-r--r-- | engines/scumm/detection.cpp | 4 | ||||
-rw-r--r-- | engines/scumm/he/resource_he.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/he/script_v72he.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/object.cpp | 6 | ||||
-rw-r--r-- | engines/scumm/resource.cpp | 144 | ||||
-rw-r--r-- | engines/scumm/resource.h | 29 | ||||
-rw-r--r-- | engines/scumm/resource_v2.cpp | 32 | ||||
-rw-r--r-- | engines/scumm/resource_v3.cpp | 10 | ||||
-rw-r--r-- | engines/scumm/resource_v4.cpp | 6 | ||||
-rw-r--r-- | engines/scumm/room.cpp | 8 | ||||
-rw-r--r-- | engines/scumm/saveload.cpp | 36 | ||||
-rw-r--r-- | engines/scumm/script.cpp | 14 | ||||
-rw-r--r-- | engines/scumm/script_v6.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/scumm.cpp | 4 | ||||
-rw-r--r-- | engines/scumm/sound.cpp | 6 |
16 files changed, 157 insertions, 152 deletions
diff --git a/engines/scumm/debugger.cpp b/engines/scumm/debugger.cpp index 7de8a28536..d404802c3c 100644 --- a/engines/scumm/debugger.cpp +++ b/engines/scumm/debugger.cpp @@ -374,8 +374,8 @@ bool ScummDebugger::Cmd_Actor(int argc, const char **argv) { DebugPrintf("Actor[%d]._elevation = %d\n", actnum, a->getElevation()); _vm->_fullRedraw = true; } else if (!strcmp(argv[2], "costume")) { - if (value >= _vm->_res->num[rtCostume]) - DebugPrintf("Costume not changed as %d exceeds max of %d\n", value, _vm->_res->num[rtCostume]); + if (value >= _vm->_res->_types[rtCostume].num) + DebugPrintf("Costume not changed as %d exceeds max of %d\n", value, _vm->_res->_types[rtCostume].num); else { a->setActorCostume(value); _vm->_fullRedraw = true; diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index ad1cb3da89..6440228d78 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -68,7 +68,7 @@ static const MD5Table *findInMD5Table(const char *md5) { } Common::String ScummEngine::generateFilename(const int room) const { - const int diskNumber = (room > 0) ? _res->roomno[rtRoom][room] : 0; + const int diskNumber = (room > 0) ? _res->_types[rtRoom].roomno[room] : 0; char buf[128]; if (_game.version == 4) { @@ -110,7 +110,7 @@ Common::String ScummEngine_v60he::generateFilename(const int room) const { if (room < 0) { id = '0' - room; } else { - const int diskNumber = (room > 0) ? _res->roomno[rtRoom][room] : 0; + const int diskNumber = (room > 0) ? _res->_types[rtRoom].roomno[room] : 0; id = diskNumber + '0'; } diff --git a/engines/scumm/he/resource_he.cpp b/engines/scumm/he/resource_he.cpp index dd502715c8..435e0e547b 100644 --- a/engines/scumm/he/resource_he.cpp +++ b/engines/scumm/he/resource_he.cpp @@ -226,7 +226,7 @@ void ScummEngine_v70he::readRoomsOffsets() { num = READ_LE_UINT16(_heV7RoomOffsets); ptr = _heV7RoomOffsets + 2; for (i = 0; i < num; i++) { - _res->roomoffs[rtRoom][i] = READ_LE_UINT32(ptr); + _res->_types[rtRoom].roomoffs[i] = READ_LE_UINT32(ptr); ptr += 4; } } diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp index 63c97a958e..b63feeb580 100644 --- a/engines/scumm/he/script_v72he.cpp +++ b/engines/scumm/he/script_v72he.cpp @@ -621,7 +621,7 @@ void ScummEngine_v72he::o72_getArrayDimSize() { } void ScummEngine_v72he::o72_getNumFreeArrays() { - byte **addr = _res->address[rtString]; + byte **addr = _res->_types[rtString].address; int i, num = 0; for (i = 1; i < _numArray; i++) { diff --git a/engines/scumm/object.cpp b/engines/scumm/object.cpp index 8b4d39a838..457e2c717c 100644 --- a/engines/scumm/object.cpp +++ b/engines/scumm/object.cpp @@ -192,8 +192,8 @@ void ScummEngine::clearOwnerOf(int obj) { if (!_inventory[i] && _inventory[i+1]) { _inventory[i] = _inventory[i+1]; _inventory[i+1] = 0; - _res->address[rtInventory][i] = _res->address[rtInventory][i + 1]; - _res->address[rtInventory][i + 1] = NULL; + _res->_types[rtInventory].address[i] = _res->_types[rtInventory].address[i + 1]; + _res->_types[rtInventory].address[i + 1] = NULL; } } break; @@ -1796,7 +1796,7 @@ int ScummEngine::findLocalObjectSlot() { int ScummEngine::findFlObjectSlot() { int i; for (i = 1; i < _numFlObject; i++) { - if (_res->address[rtFlObject][i] == NULL) + if (_res->_types[rtFlObject].address[i] == NULL) return i; } error("findFlObjectSlot: Out of FLObject slots"); diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp index ac238abae5..76b6830137 100644 --- a/engines/scumm/resource.cpp +++ b/engines/scumm/resource.cpp @@ -83,8 +83,8 @@ void ScummEngine::openRoom(const int room) { // Load the disk numer / room offs (special case for room 0 exists because // room 0 contains the data which is used to create the roomno / roomoffs // tables -- hence obviously we mustn't use those when loading room 0. - const uint32 diskNumber = room ? _res->roomno[rtRoom][room] : 0; - const uint32 room_offs = room ? _res->roomoffs[rtRoom][room] : 0; + const uint32 diskNumber = room ? _res->_types[rtRoom].roomno[room] : 0; + const uint32 room_offs = room ? _res->_types[rtRoom].roomoffs[room] : 0; // FIXME: Since room_offs is const, clearly the following loop either // is never entered, or loops forever (if it wasn't for the return/error @@ -94,7 +94,7 @@ void ScummEngine::openRoom(const int room) { while (room_offs != RES_INVALID_OFFSET) { if (room_offs != 0 && room != 0 && _game.heversion < 98) { - _fileOffset = _res->roomoffs[rtRoom][room]; + _fileOffset = _res->_types[rtRoom].roomoffs[room]; return; } @@ -122,7 +122,7 @@ void ScummEngine::openRoom(const int room) { return; deleteRoomOffsets(); readRoomsOffsets(); - _fileOffset = _res->roomoffs[rtRoom][room]; + _fileOffset = _res->_types[rtRoom].roomoffs[room]; if (_fileOffset != 8) return; @@ -157,8 +157,8 @@ void ScummEngine::closeRoom() { /** Delete the currently loaded room offsets. */ void ScummEngine::deleteRoomOffsets() { for (int i = 0; i < _numRooms; i++) { - if (_res->roomoffs[rtRoom][i] != RES_INVALID_OFFSET) - _res->roomoffs[rtRoom][i] = 0; + if (_res->_types[rtRoom].roomoffs[i] != RES_INVALID_OFFSET) + _res->_types[rtRoom].roomoffs[i] = 0; } } @@ -174,8 +174,8 @@ void ScummEngine::readRoomsOffsets() { while (num--) { int room = _fileHandle->readByte(); int offset = _fileHandle->readUint32LE(); - if (_res->roomoffs[rtRoom][room] != RES_INVALID_OFFSET) { - _res->roomoffs[rtRoom][room] = offset; + if (_res->_types[rtRoom].roomoffs[room] != RES_INVALID_OFFSET) { + _res->_types[rtRoom].roomoffs[room] = offset; } } } @@ -491,7 +491,7 @@ int ScummEngine::readResTypeList(int id) { else num = _fileHandle->readUint16LE(); - if (num != _res->num[id]) { + if (num != _res->_types[id].num) { error("Invalid number of %ss (%d) in directory", resTypeFromId(id), num); } @@ -499,10 +499,10 @@ int ScummEngine::readResTypeList(int id) { for (i = 0; i < num; i++) { - _res->roomno[id][i] = _fileHandle->readByte(); + _res->_types[id].roomno[i] = _fileHandle->readByte(); } for (i = 0; i < num; i++) { - _res->roomoffs[id][i] = _fileHandle->readUint32LE(); + _res->_types[id].roomoffs[i] = _fileHandle->readUint32LE(); } return num; @@ -516,11 +516,11 @@ int ScummEngine_v70he::readResTypeList(int id) { if (id == rtRoom) for (i = 0; i < num; i++) { - _heV7RoomIntOffsets[i] = _res->roomoffs[rtRoom][i]; + _heV7RoomIntOffsets[i] = _res->_types[rtRoom].roomoffs[i]; } for (i = 0; i < num; i++) { - _res->globsize[id][i] = _fileHandle->readUint32LE(); + _res->_types[id].globsize[i] = _fileHandle->readUint32LE(); } return num; @@ -528,26 +528,26 @@ int ScummEngine_v70he::readResTypeList(int id) { void ResourceManager::allocResTypeData(int id, uint32 tag, int num_, const char *name_, int mode_) { debug(9, "allocResTypeData(%s/%s,%s,%d,%d)", resTypeFromId(id), name_, tag2str(TO_BE_32(tag)), num_, mode_); - assert(id >= 0 && id < (int)(ARRAYSIZE(this->mode))); + assert(id >= 0 && id < (int)(ARRAYSIZE(_types))); if (num_ >= 8000) error("Too many %ss (%d) in directory", name_, num_); - mode[id] = mode_; - num[id] = num_; - tags[id] = tag; - name[id] = name_; - address[id] = (byte **)calloc(num_, sizeof(void *)); - flags[id] = (byte *)calloc(num_, sizeof(byte)); - status[id] = (byte *)calloc(num_, sizeof(byte)); + _types[id].mode = mode_; + _types[id].num = num_; + _types[id].tags = tag; + _types[id].name = name_; + _types[id].address = (byte **)calloc(num_, sizeof(void *)); + _types[id].flags = (byte *)calloc(num_, sizeof(byte)); + _types[id].status = (byte *)calloc(num_, sizeof(byte)); if (mode_) { - roomno[id] = (byte *)calloc(num_, sizeof(byte)); - roomoffs[id] = (uint32 *)calloc(num_, sizeof(uint32)); + _types[id].roomno = (byte *)calloc(num_, sizeof(byte)); + _types[id].roomoffs = (uint32 *)calloc(num_, sizeof(uint32)); } if (_vm->_game.heversion >= 70) { - globsize[id] = (uint32 *)calloc(num_, sizeof(uint32)); + _types[id].globsize = (uint32 *)calloc(num_, sizeof(uint32)); } } @@ -606,8 +606,8 @@ void ScummEngine::ensureResourceLoaded(int type, int i) { if (type != rtCharset && i == 0) return; - if (i <= _res->num[type]) - addr = _res->address[type][i]; + if (i <= _res->_types[type].num) + addr = _res->_types[type].address[i]; if (addr) return; @@ -632,8 +632,8 @@ int ScummEngine::loadResource(int type, int idx) { roomNr = getResourceRoomNr(type, idx); - if (idx >= _res->num[type]) - error("%s %d undefined %d %d", _res->name[type], idx, _res->num[type], roomNr); + if (idx >= _res->_types[type].num) + error("%s %d undefined %d %d", _res->_types[type].name, idx, _res->_types[type].num, roomNr); if (roomNr == 0) roomNr = _roomResource; @@ -669,9 +669,9 @@ int ScummEngine::loadResource(int type, int idx) { tag = _fileHandle->readUint32BE(); - if (tag != _res->tags[type] && _game.heversion < 70) { + if (tag != _res->_types[type].tags && _game.heversion < 70) { error("%s %d not in room %d at %d+%d in file %s", - _res->name[type], idx, roomNr, + _res->_types[type].name, idx, roomNr, _fileOffset, fileOffs, _fileHandle->getName()); } @@ -695,21 +695,21 @@ int ScummEngine::loadResource(int type, int idx) { int ScummEngine::getResourceRoomNr(int type, int idx) { if (type == rtRoom && _game.heversion < 70) return idx; - return _res->roomno[type][idx]; + return _res->_types[type].roomno[idx]; } uint32 ScummEngine::getResourceRoomOffset(int type, int idx) { if (type == rtRoom) { return (_game.version == 8) ? 8 : 0; } - return _res->roomoffs[type][idx]; + return _res->_types[type].roomoffs[idx]; } uint32 ScummEngine_v70he::getResourceRoomOffset(int type, int idx) { if (type == rtRoom) { return _heV7RoomIntOffsets[idx]; } - return _res->roomoffs[type][idx]; + return _res->_types[type].roomoffs[idx]; } int ScummEngine::getResourceSize(int type, int idx) { @@ -729,16 +729,16 @@ byte *ScummEngine::getResourceAddress(int type, int idx) { if (!_res->validateResource("getResourceAddress", type, idx)) return NULL; - if (!_res->address[type]) { - debugC(DEBUG_RESOURCE, "getResourceAddress(%s,%d), _res->address[type] == NULL", resTypeFromId(type), idx); + if (!_res->_types[type].address) { + debugC(DEBUG_RESOURCE, "getResourceAddress(%s,%d), _res->_types[type].address == NULL", resTypeFromId(type), idx); return NULL; } - if (_res->mode[type] && !_res->address[type][idx]) { + if (_res->_types[type].mode && !_res->_types[type].address[idx]) { ensureResourceLoaded(type, idx); } - if (!(ptr = (byte *)_res->address[type][idx])) { + if (!(ptr = (byte *)_res->_types[type].address[idx])) { debugC(DEBUG_RESOURCE, "getResourceAddress(%s,%d) == NULL", resTypeFromId(type), idx); return NULL; } @@ -777,8 +777,8 @@ void ResourceManager::increaseResourceCounter() { byte counter; for (i = rtFirst; i <= rtLast; i++) { - for (j = num[i]; --j >= 0;) { - counter = flags[i][j] & RF_USAGE; + for (j = _types[i].num; --j >= 0;) { + counter = _types[i].flags[j] & RF_USAGE; if (counter && counter < RF_USAGE_MAX) { setResourceCounter(i, j, counter + 1); } @@ -787,8 +787,8 @@ void ResourceManager::increaseResourceCounter() { } void ResourceManager::setResourceCounter(int type, int idx, byte flag) { - flags[type][idx] &= ~RF_USAGE; - flags[type][idx] |= flag; + _types[type].flags[idx] &= ~RF_USAGE; + _types[type].flags[idx] |= flag; } /* 2 bytes safety area to make "precaching" of bytes in the gdi drawer easier */ @@ -805,8 +805,8 @@ byte *ResourceManager::createResource(int type, int idx, uint32 size) { // cases. For instance, Zak tries to reload the intro music // while it's playing. See bug #1253171. - if (address[type][idx] && (type == rtSound || type == rtScript || type == rtCostume)) - return address[type][idx] + sizeof(MemBlkHeader); + if (_types[type].address[idx] && (type == rtSound || type == rtScript || type == rtCostume)) + return _types[type].address[idx] + sizeof(MemBlkHeader); } nukeResource(type, idx); @@ -820,7 +820,7 @@ byte *ResourceManager::createResource(int type, int idx, uint32 size) { _allocatedSize += size; - address[type][idx] = (byte *)ptr; + _types[type].address[idx] = (byte *)ptr; ((MemBlkHeader *)ptr)->size = size; setResourceCounter(type, idx, 1); return (byte *)ptr + sizeof(MemBlkHeader); /* skip header */ @@ -844,7 +844,7 @@ void ResourceManager::setHeapThreshold(int min, int max) { } bool ResourceManager::validateResource(const char *str, int type, int idx) const { - if (type < rtFirst || type > rtLast || (uint) idx >= (uint)num[type]) { + if (type < rtFirst || type > rtLast || (uint) idx >= (uint)_types[type].num) { error("%s Illegal Glob type %s (%d) num %d", str, resTypeFromId(type), type, idx); return false; } @@ -854,17 +854,17 @@ bool ResourceManager::validateResource(const char *str, int type, int idx) const void ResourceManager::nukeResource(int type, int idx) { byte *ptr; - if (!address[type]) + if (!_types[type].address) return; - assert(idx >= 0 && idx < num[type]); + assert(idx >= 0 && idx < _types[type].num); - ptr = address[type][idx]; + ptr = _types[type].address[idx]; if (ptr != NULL) { debugC(DEBUG_RESOURCE, "nukeResource(%s,%d)", resTypeFromId(type), idx); - address[type][idx] = 0; - flags[type][idx] = 0; - status[type][idx] &= ~RS_MODIFIED; + _types[type].address[idx] = 0; + _types[type].flags[idx] = 0; + _types[type].status[idx] &= ~RS_MODIFIED; _allocatedSize -= ((MemBlkHeader *)ptr)->size; free(ptr); } @@ -898,19 +898,19 @@ int ScummEngine::getResourceDataSize(const byte *ptr) const { void ResourceManager::lock(int type, int i) { if (!validateResource("Locking", type, i)) return; - flags[type][i] |= RF_LOCK; + _types[type].flags[i] |= RF_LOCK; } void ResourceManager::unlock(int type, int i) { if (!validateResource("Unlocking", type, i)) return; - flags[type][i] &= ~RF_LOCK; + _types[type].flags[i] &= ~RF_LOCK; } bool ResourceManager::isLocked(int type, int i) const { if (!validateResource("isLocked", type, i)) return false; - return (flags[type][i] & RF_LOCK) != 0; + return (_types[type].flags[i] & RF_LOCK) != 0; } bool ScummEngine::isResourceInUse(int type, int i) const { @@ -947,13 +947,13 @@ bool ScummEngine::isResourceInUse(int type, int i) const { void ResourceManager::setModified(int type, int i) { if (!validateResource("Modified", type, i)) return; - status[type][i] |= RS_MODIFIED; + _types[type].status[i] |= RS_MODIFIED; } bool ResourceManager::isModified(int type, int i) const { if (!validateResource("isModified", type, i)) return false; - return (status[type][i] & RS_MODIFIED) != 0; + return (_types[type].status[i] & RS_MODIFIED) != 0; } void ResourceManager::expireResources(uint32 size) { @@ -978,10 +978,10 @@ void ResourceManager::expireResources(uint32 size) { best_counter = 2; for (i = rtFirst; i <= rtLast; i++) - if (mode[i]) { - for (j = num[i]; --j >= 0;) { - flag = flags[i][j]; - if (!(flag & RF_LOCK) && flag >= best_counter && address[i][j] && !_vm->isResourceInUse(i, j)) { + if (_types[i].mode) { + for (j = _types[i].num; --j >= 0;) { + flag = _types[i].flags[j]; + if (!(flag & RF_LOCK) && flag >= best_counter && _types[i].address[j] && !_vm->isResourceInUse(i, j)) { best_counter = flag; best_type = i; best_res = j; @@ -1002,17 +1002,17 @@ void ResourceManager::expireResources(uint32 size) { void ResourceManager::freeResources() { int i, j; for (i = rtFirst; i <= rtLast; i++) { - for (j = num[i]; --j >= 0;) { + for (j = _types[i].num; --j >= 0;) { if (isResourceLoaded(i, j)) nukeResource(i, j); } - free(address[i]); - free(flags[i]); - free(status[i]); - free(roomno[i]); - free(roomoffs[i]); + free(_types[i].address); + free(_types[i].flags); + free(_types[i].status); + free(_types[i].roomno); + free(_types[i].roomoffs); - free(globsize[i]); + free(_types[i].globsize); } } @@ -1043,7 +1043,7 @@ void ScummEngine::loadPtrToResource(int type, int resindex, const byte *source) bool ResourceManager::isResourceLoaded(int type, int idx) const { if (!validateResource("isResourceLoaded", type, idx)) return false; - return address[type][idx] != NULL; + return _types[type].address[idx] != NULL; } void ResourceManager::resourceStats() { @@ -1052,10 +1052,10 @@ void ResourceManager::resourceStats() { byte flag; for (i = rtFirst; i <= rtLast; i++) - for (j = num[i]; --j >= 0;) { - flag = flags[i][j]; - if (flag & RF_LOCK && address[i][j]) { - lockedSize += ((MemBlkHeader *)address[i][j])->size; + for (j = _types[i].num; --j >= 0;) { + flag = _types[i].flags[j]; + if (flag & RF_LOCK && _types[i].address[j]) { + lockedSize += ((MemBlkHeader *)_types[i].roomoffs[j])->size; lockedNum++; } } diff --git a/engines/scumm/resource.h b/engines/scumm/resource.h index 32873a129b..b3cb424d4f 100644 --- a/engines/scumm/resource.h +++ b/engines/scumm/resource.h @@ -60,18 +60,23 @@ protected: ScummEngine *_vm; public: - byte mode[rtNumTypes]; - uint16 num[rtNumTypes]; - uint32 tags[rtNumTypes]; - const char *name[rtNumTypes]; - byte **address[rtNumTypes]; -protected: - byte *flags[rtNumTypes]; - byte *status[rtNumTypes]; -public: - byte *roomno[rtNumTypes]; - uint32 *roomoffs[rtNumTypes]; - uint32 *globsize[rtNumTypes]; + class ResTypeData { + friend class ResourceManager; + public: + byte mode; + uint16 num; + uint32 tags; + const char *name; + byte **address; + protected: + byte *flags; + byte *status; + public: + byte *roomno; + uint32 *roomoffs; + uint32 *globsize; + }; + ResTypeData _types[rtNumTypes]; protected: uint32 _allocatedSize; diff --git a/engines/scumm/resource_v2.cpp b/engines/scumm/resource_v2.cpp index c183a0e83b..f86924821d 100644 --- a/engines/scumm/resource_v2.cpp +++ b/engines/scumm/resource_v2.cpp @@ -84,40 +84,40 @@ void ScummEngine_v2::readClassicIndexFile() { } for (i = 0; i < _numRooms; i++) { - _res->roomno[rtRoom][i] = i; + _res->_types[rtRoom].roomno[i] = i; } _fileHandle->seek(_numRooms, SEEK_CUR); for (i = 0; i < _numRooms; i++) { - _res->roomoffs[rtRoom][i] = _fileHandle->readUint16LE(); - if (_res->roomoffs[rtRoom][i] == 0xFFFF) - _res->roomoffs[rtRoom][i] = (uint32)RES_INVALID_OFFSET; + _res->_types[rtRoom].roomoffs[i] = _fileHandle->readUint16LE(); + if (_res->_types[rtRoom].roomoffs[i] == 0xFFFF) + _res->_types[rtRoom].roomoffs[i] = (uint32)RES_INVALID_OFFSET; } for (i = 0; i < _numCostumes; i++) { - _res->roomno[rtCostume][i] = _fileHandle->readByte(); + _res->_types[rtCostume].roomno[i] = _fileHandle->readByte(); } for (i = 0; i < _numCostumes; i++) { - _res->roomoffs[rtCostume][i] = _fileHandle->readUint16LE(); - if (_res->roomoffs[rtCostume][i] == 0xFFFF) - _res->roomoffs[rtCostume][i] = (uint32)RES_INVALID_OFFSET; + _res->_types[rtCostume].roomoffs[i] = _fileHandle->readUint16LE(); + if (_res->_types[rtCostume].roomoffs[i] == 0xFFFF) + _res->_types[rtCostume].roomoffs[i] = (uint32)RES_INVALID_OFFSET; } for (i = 0; i < _numScripts; i++) { - _res->roomno[rtScript][i] = _fileHandle->readByte(); + _res->_types[rtScript].roomno[i] = _fileHandle->readByte(); } for (i = 0; i < _numScripts; i++) { - _res->roomoffs[rtScript][i] = _fileHandle->readUint16LE(); - if (_res->roomoffs[rtScript][i] == 0xFFFF) - _res->roomoffs[rtScript][i] = (uint32)RES_INVALID_OFFSET; + _res->_types[rtScript].roomoffs[i] = _fileHandle->readUint16LE(); + if (_res->_types[rtScript].roomoffs[i] == 0xFFFF) + _res->_types[rtScript].roomoffs[i] = (uint32)RES_INVALID_OFFSET; } for (i = 0; i < _numSounds; i++) { - _res->roomno[rtSound][i] = _fileHandle->readByte(); + _res->_types[rtSound].roomno[i] = _fileHandle->readByte(); } for (i = 0; i < _numSounds; i++) { - _res->roomoffs[rtSound][i] = _fileHandle->readUint16LE(); - if (_res->roomoffs[rtSound][i] == 0xFFFF) - _res->roomoffs[rtSound][i] = (uint32)RES_INVALID_OFFSET; + _res->_types[rtSound].roomoffs[i] = _fileHandle->readUint16LE(); + if (_res->_types[rtSound].roomoffs[i] == 0xFFFF) + _res->_types[rtSound].roomoffs[i] = (uint32)RES_INVALID_OFFSET; } } diff --git a/engines/scumm/resource_v3.cpp b/engines/scumm/resource_v3.cpp index 323e5b6370..3a8b1dd017 100644 --- a/engines/scumm/resource_v3.cpp +++ b/engines/scumm/resource_v3.cpp @@ -44,16 +44,16 @@ int ScummEngine_v3old::readResTypeList(int id) { if (id == rtRoom) { for (i = 0; i < num; i++) - _res->roomno[id][i] = i; + _res->_types[id].roomno[i] = i; _fileHandle->seek(num, SEEK_CUR); } else { for (i = 0; i < num; i++) - _res->roomno[id][i] = _fileHandle->readByte(); + _res->_types[id].roomno[i] = _fileHandle->readByte(); } for (i = 0; i < num; i++) { - _res->roomoffs[id][i] = _fileHandle->readUint16LE(); - if (_res->roomoffs[id][i] == 0xFFFF) - _res->roomoffs[id][i] = (uint32)RES_INVALID_OFFSET; + _res->_types[id].roomoffs[i] = _fileHandle->readUint16LE(); + if (_res->_types[id].roomoffs[i] == 0xFFFF) + _res->_types[id].roomoffs[i] = (uint32)RES_INVALID_OFFSET; } return num; diff --git a/engines/scumm/resource_v4.cpp b/engines/scumm/resource_v4.cpp index a3a2786e20..8fc27627b2 100644 --- a/engines/scumm/resource_v4.cpp +++ b/engines/scumm/resource_v4.cpp @@ -38,13 +38,13 @@ int ScummEngine_v4::readResTypeList(int id) { num = _fileHandle->readUint16LE(); - if (num != _res->num[id]) { + if (num != _res->_types[id].num) { error("Invalid number of %ss (%d) in directory", resTypeFromId(id), num); } for (i = 0; i < num; i++) { - _res->roomno[id][i] = _fileHandle->readByte(); - _res->roomoffs[id][i] = _fileHandle->readUint32LE(); + _res->_types[id].roomno[i] = _fileHandle->readByte(); + _res->_types[id].roomoffs[i] = _fileHandle->readUint32LE(); } return num; diff --git a/engines/scumm/room.cpp b/engines/scumm/room.cpp index f672798505..7e0f70e2cd 100644 --- a/engines/scumm/room.cpp +++ b/engines/scumm/room.cpp @@ -525,14 +525,14 @@ void ScummEngine::resetRoomSubBlocks() { // // Load scale data // - for (i = 1; i < _res->num[rtScaleTable]; i++) + for (i = 1; i < _res->_types[rtScaleTable].num; i++) _res->nukeResource(rtScaleTable, i); ptr = findResourceData(MKTAG('S','C','A','L'), roomptr); if (ptr) { int s1, s2, y1, y2; if (_game.version == 8) { - for (i = 1; i < _res->num[rtScaleTable]; i++, ptr += 16) { + for (i = 1; i < _res->_types[rtScaleTable].num; i++, ptr += 16) { s1 = READ_LE_UINT32(ptr); y1 = READ_LE_UINT32(ptr + 4); s2 = READ_LE_UINT32(ptr + 8); @@ -540,7 +540,7 @@ void ScummEngine::resetRoomSubBlocks() { setScaleSlot(i, 0, y1, s1, 0, y2, s2); } } else { - for (i = 1; i < _res->num[rtScaleTable]; i++, ptr += 8) { + for (i = 1; i < _res->_types[rtScaleTable].num; i++, ptr += 8) { s1 = READ_LE_UINT16(ptr); y1 = READ_LE_UINT16(ptr + 2); s2 = READ_LE_UINT16(ptr + 4); @@ -794,7 +794,7 @@ void ScummEngine_v3old::resetRoomSubBlocks() { // // No scale data in old bundle games // - for (i = 1; i < _res->num[rtScaleTable]; i++) + for (i = 1; i < _res->_types[rtScaleTable].num; i++) _res->nukeResource(rtScaleTable, i); } diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index be90ba2f39..424e0005f4 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -428,7 +428,7 @@ bool ScummEngine::loadState(int slot, bool compat) { // Nuke all resources for (i = rtFirst; i <= rtLast; i++) if (i != rtTemp && i != rtBuffer && (i != rtSound || _saveSound || !compat)) - for (j = 0; j < _res->num[i]; j++) { + for (j = 0; j < _res->_types[i].num; j++) { _res->nukeResource(i, j); } @@ -517,7 +517,7 @@ bool ScummEngine::loadState(int slot, bool compat) { // loading such an old save game, try to upgrade the old to new format. if (hdr.ver < VER(22)) { // Convert all rtScaleTable resources to matching scale items - for (i = 1; i < _res->num[rtScaleTable]; i++) { + for (i = 1; i < _res->_types[rtScaleTable].num; i++) { convertScaleTableToScaleSlot(i); } } @@ -1243,11 +1243,11 @@ void ScummEngine::saveOrLoad(Serializer *s) { // number of script resources, savegames won't break. if (s->isSaving()) { for (type = rtFirst; type <= rtLast; type++) { - if (_res->mode[type] != 1 && type != rtTemp && type != rtBuffer) { + if (_res->_types[type].mode != 1 && type != rtTemp && type != rtBuffer) { s->saveUint16(type); // Save the res type... - for (idx = 0; idx < _res->num[type]; idx++) { + for (idx = 0; idx < _res->_types[type].num; idx++) { // Only save resources which actually exist... - if (_res->address[type][idx]) { + if (_res->_types[type].address[idx]) { s->saveUint16(idx); // Save the index of the resource saveResource(s, type, idx); } @@ -1259,7 +1259,7 @@ void ScummEngine::saveOrLoad(Serializer *s) { } else { while ((type = s->loadUint16()) != 0xFFFF) { while ((idx = s->loadUint16()) != 0xFFFF) { - assert(0 <= idx && idx < _res->num[type]); + assert(0 <= idx && idx < _res->_types[type].num); loadResource(s, type, idx); } } @@ -1269,13 +1269,13 @@ void ScummEngine::saveOrLoad(Serializer *s) { // with index 0, and breaks whenever we change the limit on a given // resource type. for (type = rtFirst; type <= rtLast; type++) - if (_res->mode[type] != 1 && type != rtTemp && type != rtBuffer) { + if (_res->_types[type].mode != 1 && type != rtTemp && type != rtBuffer) { // For V1-V5 games, there used to be no object name resources. // At some point this changed. But since old savegames rely on // unchanged resource counts, we have to hard code the following check if (_game.version < 6 && type == rtObjectName) continue; - for (idx = 1; idx < _res->num[type]; idx++) + for (idx = 1; idx < _res->_types[type].num; idx++) saveLoadResource(s, type, idx); } } @@ -1388,7 +1388,7 @@ void ScummEngine::saveOrLoad(Serializer *s) { // if (s->isSaving()) { for (i = rtFirst; i <= rtLast; i++) - for (j = 1; j < _res->num[i]; j++) { + for (j = 1; j < _res->_types[i].num; j++) { if (_res->isLocked(i, j)) { s->saveByte(i); s->saveUint16(j); @@ -1637,9 +1637,9 @@ void ScummEngine::saveLoadResource(Serializer *ser, int type, int idx) { byte *ptr; uint32 size; - if (!_res->mode[type]) { + if (!_res->_types[type].mode) { if (ser->isSaving()) { - ptr = _res->address[type][idx]; + ptr = _res->_types[type].address[idx]; if (ptr == NULL) { ser->saveUint32(0); return; @@ -1676,10 +1676,10 @@ void ScummEngine::saveLoadResource(Serializer *ser, int type, int idx) { } } } - } else if (_res->mode[type] == 2 && ser->getVersion() >= VER(23)) { + } else if (_res->_types[type].mode == 2 && ser->getVersion() >= VER(23)) { // Save/load only a list of resource numbers that need to be reloaded. if (ser->isSaving()) { - ser->saveUint16(_res->address[type][idx] ? 1 : 0); + ser->saveUint16(_res->_types[type].address[idx] ? 1 : 0); } else { if (ser->loadUint16()) ensureResourceLoaded(type, idx); @@ -1688,10 +1688,10 @@ void ScummEngine::saveLoadResource(Serializer *ser, int type, int idx) { } void ScummEngine::saveResource(Serializer *ser, int type, int idx) { - assert(_res->address[type][idx]); + assert(_res->_types[type].address[idx]); - if (_res->mode[type] == 0) { - byte *ptr = _res->address[type][idx]; + if (_res->_types[type].mode == 0) { + byte *ptr = _res->_types[type].address[idx]; uint32 size = ((MemBlkHeader *)ptr)->size; ser->saveUint32(size); @@ -1713,7 +1713,7 @@ void ScummEngine::loadResource(Serializer *ser, int type, int idx) { assert(size); _res->createResource(type, idx, size); ser->loadBytes(getResourceAddress(type, idx), size); - } else if (_res->mode[type] == 0) { + } else if (_res->_types[type].mode == 0) { uint32 size = ser->loadUint32(); assert(size); _res->createResource(type, idx, size); @@ -1725,7 +1725,7 @@ void ScummEngine::loadResource(Serializer *ser, int type, int idx) { if (type == rtObjectName) { _newNames[idx] = ser->loadUint16(); } - } else if (_res->mode[type] == 2) { + } else if (_res->_types[type].mode == 2) { // HE Games use sound resource 1 for speech if (_game.heversion >= 60 && idx == 1) return; diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp index ae481393a9..4630ec1a5c 100644 --- a/engines/scumm/script.cpp +++ b/engines/scumm/script.cpp @@ -390,26 +390,26 @@ void ScummEngine::getScriptBaseAddress() { break; _scriptOrgPointer = getResourceAddress(rtInventory, idx); assert(idx < _numInventory); - _lastCodePtr = &_res->address[rtInventory][idx]; + _lastCodePtr = &_res->_types[rtInventory].address[idx]; break; case WIO_LOCAL: case WIO_ROOM: /* room script */ if (_game.version == 8) { _scriptOrgPointer = getResourceAddress(rtRoomScripts, _roomResource); - assert(_roomResource < _res->num[rtRoomScripts]); - _lastCodePtr = &_res->address[rtRoomScripts][_roomResource]; + assert(_roomResource < _res->_types[rtRoomScripts].num); + _lastCodePtr = &_res->_types[rtRoomScripts].address[_roomResource]; } else { _scriptOrgPointer = getResourceAddress(rtRoom, _roomResource); assert(_roomResource < _numRooms); - _lastCodePtr = &_res->address[rtRoom][_roomResource]; + _lastCodePtr = &_res->_types[rtRoom].address[_roomResource]; } break; case WIO_GLOBAL: /* global script */ _scriptOrgPointer = getResourceAddress(rtScript, ss->number); assert(ss->number < _numScripts); - _lastCodePtr = &_res->address[rtScript][ss->number]; + _lastCodePtr = &_res->_types[rtScript].address[ss->number]; break; case WIO_FLOBJECT: /* flobject script */ @@ -418,7 +418,7 @@ void ScummEngine::getScriptBaseAddress() { idx = _objs[idx].fl_object_index; _scriptOrgPointer = getResourceAddress(rtFlObject, idx); assert(idx < _numFlObject); - _lastCodePtr = &_res->address[rtFlObject][idx]; + _lastCodePtr = &_res->_types[rtFlObject].address[idx]; break; default: error("Bad type while getting base address"); @@ -1099,7 +1099,7 @@ void ScummEngine::checkAndRunSentenceScript() { // For now we assume that if there are more than 460 scripts, then // the pair 29/104 is used, else the pair 28/103. - if (_res->num[rtScript] > 460) { + if (_res->_types[rtScript].num > 460) { if (sentenceScript == 104) sentenceScript = 29; } else { diff --git a/engines/scumm/script_v6.cpp b/engines/scumm/script_v6.cpp index c5fa245d43..afc1eb6909 100644 --- a/engines/scumm/script_v6.cpp +++ b/engines/scumm/script_v6.cpp @@ -357,7 +357,7 @@ void ScummEngine_v6::nukeArray(int a) { } int ScummEngine_v6::findFreeArrayId() { - byte **addr = _res->address[rtString]; + byte **addr = _res->_types[rtString].address; int i; for (i = 1; i < _numArray; i++) { diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 70d8f0dab1..d5c2b2eeb9 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -1185,7 +1185,7 @@ Common::Error ScummEngine::init() { resetScummVars(); if (_imuse) { - _imuse->setBase(_res->address[rtSound]); + _imuse->setBase(_res->_types[rtSound].address); } if (_game.version >= 5 && _game.version <= 7) @@ -2462,7 +2462,7 @@ void ScummEngine::restart() { resetScummVars(); if (_imuse) { - _imuse->setBase(_res->address[rtSound]); + _imuse->setBase(_res->_types[rtSound].address); } // Reinit sound engine diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp index 567cf74d4a..f5068e75d0 100644 --- a/engines/scumm/sound.cpp +++ b/engines/scumm/sound.cpp @@ -1224,7 +1224,7 @@ int ScummEngine::readSoundResource(int idx) { if (!dmuFile.open(buffer)) { error("Can't open music file %s", buffer); - _res->roomoffs[rtSound][idx] = RES_INVALID_OFFSET; + _res->_types[rtSound].roomoffs[idx] = RES_INVALID_OFFSET; return 0; } dmuFile.seek(4, SEEK_SET); @@ -1248,7 +1248,7 @@ int ScummEngine::readSoundResource(int idx) { } error("Unrecognized base tag 0x%08x in sound %d", basetag, idx); } - _res->roomoffs[rtSound][idx] = RES_INVALID_OFFSET; + _res->_types[rtSound].roomoffs[idx] = RES_INVALID_OFFSET; return 0; } @@ -2123,7 +2123,7 @@ int ScummEngine::readSoundResourceSmallHeader(int idx) { _fileHandle->read(_res->createResource(rtSound, idx, ro_size - 4), ro_size - 4); return 1; } - _res->roomoffs[rtSound][idx] = RES_INVALID_OFFSET; + _res->_types[rtSound].roomoffs[idx] = RES_INVALID_OFFSET; return 0; } |