diff options
author | Max Horn | 2008-09-30 12:58:27 +0000 |
---|---|---|
committer | Max Horn | 2008-09-30 12:58:27 +0000 |
commit | 6aa12974bd0aaff41e5a39ea032a849e4e0f615b (patch) | |
tree | e9364773598a35933d0bc5bb589c01d4242da84c /engines | |
parent | ae8c0857b9dcaf16065482c47cd4e5d0873585bc (diff) | |
download | scummvm-rg350-6aa12974bd0aaff41e5a39ea032a849e4e0f615b.tar.gz scummvm-rg350-6aa12974bd0aaff41e5a39ea032a849e4e0f615b.tar.bz2 scummvm-rg350-6aa12974bd0aaff41e5a39ea032a849e4e0f615b.zip |
SAGA: Some code cleanup
svn-id: r34703
Diffstat (limited to 'engines')
-rw-r--r-- | engines/saga/music.cpp | 2 | ||||
-rw-r--r-- | engines/saga/rscfile.cpp | 6 | ||||
-rw-r--r-- | engines/saga/rscfile.h | 33 | ||||
-rw-r--r-- | engines/saga/scene.cpp | 2 | ||||
-rw-r--r-- | engines/saga/sndres.cpp | 4 |
5 files changed, 19 insertions, 28 deletions
diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index 5d0c75d0ce..d022768957 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -86,7 +86,7 @@ DigitalMusicInputStream::DigitalMusicInputStream(SagaEngine *vm, ResourceContext byte compressedHeader[10]; - resourceData = _vm->_resource->getResourceData(context, resourceId); + resourceData = context->getResourceData(resourceId); _file = context->getFile(resourceData); _musicInfo = _vm->getMusicInfo(); diff --git a/engines/saga/rscfile.cpp b/engines/saga/rscfile.cpp index 345e85a903..578d0d91c6 100644 --- a/engines/saga/rscfile.cpp +++ b/engines/saga/rscfile.cpp @@ -309,8 +309,8 @@ bool Resource::loadContext(ResourceContext *context) { for (i = 0; i < tableSize / 8; i++) { subjectResourceId = readS2.readUint32(); patchResourceId = readS2.readUint32(); - subjectResourceData = getResourceData(subjectContext, subjectResourceId); - resourceData = getResourceData(context, patchResourceId); + subjectResourceData = subjectContext->getResourceData(subjectResourceId); + resourceData = context->getResourceData(patchResourceId); subjectResourceData->patchData = new PatchData(context->file); subjectResourceData->offset = resourceData->offset; subjectResourceData->size = resourceData->size; @@ -632,7 +632,7 @@ void Resource::loadResource(ResourceContext *context, uint32 resourceId, byte*&r debug(8, "loadResource %d", resourceId); - resourceData = getResourceData(context, resourceId); + resourceData = context->getResourceData(resourceId); file = context->getFile(resourceData); diff --git a/engines/saga/rscfile.h b/engines/saga/rscfile.h index ee2181ae09..27d13d8835 100644 --- a/engines/saga/rscfile.h +++ b/engines/saga/rscfile.h @@ -90,6 +90,18 @@ struct ResourceContext { return file; } } + + bool validResourceId(uint32 resourceId) const { + return (resourceId < count); + } + + ResourceData *getResourceData(uint32 resourceId) const { + if (resourceId >= count) { + error("ResourceContext::getResourceData() wrong resourceId %d", resourceId); + } + return &table[resourceId]; + } + }; struct MetaResource { @@ -122,7 +134,6 @@ public: bool createContexts(); void clearContexts(); void loadResource(ResourceContext *context, uint32 resourceId, byte*&resourceBuffer, size_t &resourceSize); - size_t getResourceSize(ResourceContext *context, uint32 resourceId); uint32 convertResourceId(uint32 resourceId); void loadGlobalResources(int chapter, int actorsEntrance); @@ -137,26 +148,6 @@ public: return NULL; } - bool validResourceId(ResourceContext *context, uint32 resourceId) const { - return (resourceId < context->count); - } - - size_t getResourceSize(ResourceContext *context, uint32 resourceId) const { - return getResourceData(context, resourceId)->size; - } - - size_t getResourceOffset(ResourceContext *context, uint32 resourceId) const { - return getResourceData(context, resourceId)->offset; - } - - ResourceData *getResourceData(ResourceContext *context, uint32 resourceId) const { - if (!validResourceId(context, resourceId)) { - warning("Resource::getResourceData() wrong resourceId %d", resourceId); - assert(0); - } - return &context->table[resourceId]; - } - private: SagaEngine *_vm; ResourceContext *_contexts; diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp index 074b4c933a..e6afb8241c 100644 --- a/engines/saga/scene.cpp +++ b/engines/saga/scene.cpp @@ -957,7 +957,7 @@ void Scene::loadSceneResourceList(uint32 resourceId) { _resourceList[i].resourceId = readS.readUint16(); _resourceList[i].resourceType = readS.readUint16(); // demo version may contain invalid resourceId - _resourceList[i].invalid = !_vm->_resource->validResourceId(_sceneContext, _resourceList[i].resourceId); + _resourceList[i].invalid = !_sceneContext->validResourceId(_resourceList[i].resourceId); } } diff --git a/engines/saga/sndres.cpp b/engines/saga/sndres.cpp index b990b8ddf7..29de6f6be1 100644 --- a/engines/saga/sndres.cpp +++ b/engines/saga/sndres.cpp @@ -205,7 +205,7 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff soundResourceLength = file->size(); } else { - ResourceData* resourceData = _vm->_resource->getResourceData(context, resourceId); + ResourceData* resourceData = context->getResourceData(resourceId); file = context->getFile(resourceData); file->seek(resourceData->offset); @@ -373,7 +373,7 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff case kSoundOGG: case kSoundFLAC: ResourceData *resourceData; - resourceData = _vm->_resource->getResourceData(context, resourceId); + resourceData = context->getResourceData(resourceId); // Read compressed sfx header readS.seek(1); // Skip compression identifier byte |