diff options
author | Max Horn | 2011-05-13 14:12:00 +0200 |
---|---|---|
committer | Max Horn | 2011-05-13 14:12:00 +0200 |
commit | 45207a52d480cdd70f6bf08bbad76ec3d23a5688 (patch) | |
tree | efb201443e11d3a4c1ab6704e13a0f3c92c28975 /engines | |
parent | dfd61124039dc04540207a09f7f26e2693599ded (diff) | |
download | scummvm-rg350-45207a52d480cdd70f6bf08bbad76ec3d23a5688.tar.gz scummvm-rg350-45207a52d480cdd70f6bf08bbad76ec3d23a5688.tar.bz2 scummvm-rg350-45207a52d480cdd70f6bf08bbad76ec3d23a5688.zip |
SCUMM: Remove ResTypeData::_num
Diffstat (limited to 'engines')
-rw-r--r-- | engines/scumm/debugger.cpp | 4 | ||||
-rw-r--r-- | engines/scumm/resource.cpp | 20 | ||||
-rw-r--r-- | engines/scumm/resource.h | 7 | ||||
-rw-r--r-- | engines/scumm/resource_v4.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/room.cpp | 15 | ||||
-rw-r--r-- | engines/scumm/saveload.cpp | 12 | ||||
-rw-r--r-- | engines/scumm/script.cpp | 4 |
7 files changed, 28 insertions, 36 deletions
diff --git a/engines/scumm/debugger.cpp b/engines/scumm/debugger.cpp index f7293b563b..5502715b07 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->_types[rtCostume]._num) - DebugPrintf("Costume not changed as %d exceeds max of %d\n", value, _vm->_res->_types[rtCostume]._num); + if (value >= (int)_vm->_res->_types[rtCostume]._resources.size()) + DebugPrintf("Costume not changed as %d exceeds max of %d\n", value, _vm->_res->_types[rtCostume]._resources.size()); else { a->setActorCostume(value); _vm->_fullRedraw = true; diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp index b24c172a33..b5cfa40534 100644 --- a/engines/scumm/resource.cpp +++ b/engines/scumm/resource.cpp @@ -491,7 +491,7 @@ int ScummEngine::readResTypeList(ResType type) { else num = _fileHandle->readUint16LE(); - if (num != _res->_types[type]._num) { + if (num != _res->_types[type]._resources.size()) { error("Invalid number of %ss (%d) in directory", nameOfResType(type), num); } @@ -534,7 +534,6 @@ void ResourceManager::allocResTypeData(ResType type, uint32 tag, int num, ResTyp error("Too many %s resources (%d) in directory", nameOfResType(type), num); _types[type]._mode = mode; - _types[type]._num = num; _types[type]._tag = tag; _types[type]._resources.resize(num); @@ -604,7 +603,7 @@ void ScummEngine::ensureResourceLoaded(ResType type, ResId idx) { if (type != rtCharset && idx == 0) return; - if (idx <= _res->_types[type]._num && _res->_types[type]._resources[idx]._address) + if (idx <= _res->_types[type]._resources.size() && _res->_types[type]._resources[idx]._address) return; loadResource(type, idx); @@ -627,8 +626,8 @@ int ScummEngine::loadResource(ResType type, ResId idx) { roomNr = getResourceRoomNr(type, idx); - if (idx >= _res->_types[type]._num) - error("%s %d undefined %d %d", nameOfResType(type), idx, _res->_types[type]._num, roomNr); + if (idx >= _res->_types[type]._resources.size()) + error("%s %d undefined %d %d", nameOfResType(type), idx, _res->_types[type]._resources.size(), roomNr); if (roomNr == 0) roomNr = _roomResource; @@ -765,7 +764,7 @@ void ResourceManager::increaseExpireCounter() { void ResourceManager::increaseResourceCounters() { for (ResType type = rtFirst; type <= rtLast; type = ResType(type + 1)) { - ResId idx = _types[type]._num; + ResId idx = _types[type]._resources.size(); while (idx-- > 0) { byte counter = _types[type]._resources[idx].getResourceCounter(); if (counter && counter < RF_USAGE_MAX) { @@ -848,7 +847,6 @@ void ResourceManager::Resource::nuke() { ResourceManager::ResTypeData::ResTypeData() { _mode = kDynamicResTypeMode; - _num = 0; _tag = 0; } @@ -874,7 +872,7 @@ void ResourceManager::setHeapThreshold(int min, int max) { } bool ResourceManager::validateResource(const char *str, ResType type, ResId idx) const { - if (type < rtFirst || type > rtLast || (uint)idx >= (uint)_types[type]._num) { + if (type < rtFirst || type > rtLast || (uint)idx >= (uint)_types[type]._resources.size()) { error("%s Illegal Glob type %s (%d) num %d", str, nameOfResType(type), type, idx); return false; } @@ -1020,7 +1018,7 @@ void ResourceManager::expireResources(uint32 size) { if (_types[type]._mode != kDynamicResTypeMode) { // Resources of this type can be reloaded from the data files, // so we can potentially unload them to free memory. - ResId idx = _types[type]._num; + ResId idx = _types[type]._resources.size(); while (idx-- > 0) { Resource &tmp = _types[type]._resources[idx]; byte counter = tmp.getResourceCounter(); @@ -1045,7 +1043,7 @@ void ResourceManager::expireResources(uint32 size) { void ResourceManager::freeResources() { for (ResType type = rtFirst; type <= rtLast; type = ResType(type + 1)) { - ResId idx = _types[type]._num; + ResId idx = _types[type]._resources.size(); while (idx-- > 0) { if (isResourceLoaded(type, idx)) nukeResource(type, idx); @@ -1087,7 +1085,7 @@ void ResourceManager::resourceStats() { uint32 lockedSize = 0, lockedNum = 0; for (ResType type = rtFirst; type <= rtLast; type = ResType(type + 1)) { - ResId idx = _types[type]._num; + ResId idx = _types[type]._resources.size(); while (idx-- > 0) { Resource &tmp = _types[type]._resources[idx]; if (tmp.isLocked() && tmp._address) { diff --git a/engines/scumm/resource.h b/engines/scumm/resource.h index 15aed24b36..e8c2255fbb 100644 --- a/engines/scumm/resource.h +++ b/engines/scumm/resource.h @@ -154,11 +154,6 @@ public: friend class ResourceManager; public: ResTypeMode _mode; - /** - * The maximal number of resource of this type. Determines the size - * of various arrays. - */ - uint16 _num; /** * The 4-byte tag or chunk type associated to this resource type, if any. @@ -167,7 +162,7 @@ public: uint32 _tag; /** - * Array of size _num containing pointers to each resource of this type. + * Array containing the resources of this type. */ Common::Array<Resource> _resources; diff --git a/engines/scumm/resource_v4.cpp b/engines/scumm/resource_v4.cpp index 258122b89f..e0d86e707c 100644 --- a/engines/scumm/resource_v4.cpp +++ b/engines/scumm/resource_v4.cpp @@ -37,7 +37,7 @@ int ScummEngine_v4::readResTypeList(ResType type) { num = _fileHandle->readUint16LE(); - if (num != _res->_types[type]._num) { + if (num != _res->_types[type]._resources.size()) { error("Invalid number of %ss (%d) in directory", nameOfResType(type), num); } diff --git a/engines/scumm/room.cpp b/engines/scumm/room.cpp index a0bb5278fa..4ee771e9d5 100644 --- a/engines/scumm/room.cpp +++ b/engines/scumm/room.cpp @@ -465,7 +465,7 @@ void ScummEngine::setupRoomSubBlocks() { * So it is not appropriate to call it after loading a savegame. */ void ScummEngine::resetRoomSubBlocks() { - int i; + ResId i; const byte *ptr; byte *roomptr; @@ -525,14 +525,14 @@ void ScummEngine::resetRoomSubBlocks() { // // Load scale data // - for (i = 1; i < _res->_types[rtScaleTable]._num; i++) + for (i = 1; i < _res->_types[rtScaleTable]._resources.size(); 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->_types[rtScaleTable]._num; i++, ptr += 16) { + for (i = 1; i < _res->_types[rtScaleTable]._resources.size(); 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->_types[rtScaleTable]._num; i++, ptr += 8) { + for (i = 1; i < _res->_types[rtScaleTable]._resources.size(); i++, ptr += 8) { s1 = READ_LE_UINT16(ptr); y1 = READ_LE_UINT16(ptr + 2); s2 = READ_LE_UINT16(ptr + 4); @@ -712,7 +712,6 @@ void ScummEngine_v3old::setupRoomSubBlocks() { } void ScummEngine_v3old::resetRoomSubBlocks() { - int i; const byte *ptr; byte *roomptr; @@ -769,7 +768,7 @@ void ScummEngine_v3old::resetRoomSubBlocks() { size = 0; // Compute matrix size - for (i = 0; i < numOfBoxes; i++) { + for (int i = 0; i < numOfBoxes; i++) { while (*tmp != 0xFF) { size++; tmp++; @@ -794,8 +793,8 @@ void ScummEngine_v3old::resetRoomSubBlocks() { // // No scale data in old bundle games // - for (i = 1; i < _res->_types[rtScaleTable]._num; i++) - _res->nukeResource(rtScaleTable, i); + for (ResId id = 1; id < _res->_types[rtScaleTable]._resources.size(); id++) + _res->nukeResource(rtScaleTable, id); } diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index f37ca36c6f..b823e3c8f5 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -427,7 +427,7 @@ bool ScummEngine::loadState(int slot, bool compat) { // Nuke all resources for (ResType type = rtFirst; type <= rtLast; type = ResType(type + 1)) if (type != rtTemp && type != rtBuffer && (type != rtSound || _saveSound || !compat)) - for (ResId idx = 0; idx < _res->_types[type]._num; idx++) { + for (ResId idx = 0; idx < _res->_types[type]._resources.size(); idx++) { _res->nukeResource(type, idx); } @@ -516,7 +516,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 (ResId idx = 1; idx < _res->_types[rtScaleTable]._num; idx++) { + for (ResId idx = 1; idx < _res->_types[rtScaleTable]._resources.size(); idx++) { convertScaleTableToScaleSlot(idx); } } @@ -1245,7 +1245,7 @@ void ScummEngine::saveOrLoad(Serializer *s) { for (type = rtFirst; type <= rtLast; type = ResType(type + 1)) { if (_res->_types[type]._mode != kStaticResTypeMode && type != rtTemp && type != rtBuffer) { s->saveUint16(type); // Save the res type... - for (idx = 0; idx < _res->_types[type]._num; idx++) { + for (idx = 0; idx < _res->_types[type]._resources.size(); idx++) { // Only save resources which actually exist... if (_res->_types[type]._resources[idx]._address) { s->saveUint16(idx); // Save the index of the resource @@ -1259,7 +1259,7 @@ void ScummEngine::saveOrLoad(Serializer *s) { } else { while ((type = (ResType)s->loadUint16()) != 0xFFFF) { while ((idx = s->loadUint16()) != 0xFFFF) { - assert(idx < _res->_types[type]._num); + assert(idx < _res->_types[type]._resources.size()); loadResource(s, type, idx); } } @@ -1275,7 +1275,7 @@ void ScummEngine::saveOrLoad(Serializer *s) { // unchanged resource counts, we have to hard code the following check if (_game.version < 6 && type == rtObjectName) continue; - for (idx = 1; idx < _res->_types[type]._num; idx++) + for (idx = 1; idx < _res->_types[type]._resources.size(); idx++) loadResourceOLD(s, type, idx); } } @@ -1388,7 +1388,7 @@ void ScummEngine::saveOrLoad(Serializer *s) { // if (s->isSaving()) { for (type = rtFirst; type <= rtLast; type = ResType(type + 1)) - for (idx = 1; idx < _res->_types[type]._num; idx++) { + for (idx = 1; idx < _res->_types[type]._resources.size(); idx++) { if (_res->isLocked(type, idx)) { s->saveByte(type); s->saveUint16(idx); diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp index 47cf8e024e..6fe80de364 100644 --- a/engines/scumm/script.cpp +++ b/engines/scumm/script.cpp @@ -397,7 +397,7 @@ void ScummEngine::getScriptBaseAddress() { case WIO_ROOM: /* room script */ if (_game.version == 8) { _scriptOrgPointer = getResourceAddress(rtRoomScripts, _roomResource); - assert(_roomResource < _res->_types[rtRoomScripts]._num); + assert(_roomResource < (int)_res->_types[rtRoomScripts]._resources.size()); _lastCodePtr = &_res->_types[rtRoomScripts]._resources[_roomResource]._address; } else { _scriptOrgPointer = getResourceAddress(rtRoom, _roomResource); @@ -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->_types[rtScript]._num > 460) { + if (_res->_types[rtScript]._resources.size() > 460) { if (sentenceScript == 104) sentenceScript = 29; } else { |