diff options
author | Andrew Kurushin | 2005-07-30 17:28:58 +0000 |
---|---|---|
committer | Andrew Kurushin | 2005-07-30 17:28:58 +0000 |
commit | 86ab70b149e5cd00cf54f2e41896e2c4e16795e4 (patch) | |
tree | 90832c81b05f4ae41dbd7e0341c22b3ed973e7b5 | |
parent | 372a483ceba36eb21453e83d8dfd9303c706da99 (diff) | |
download | scummvm-rg350-86ab70b149e5cd00cf54f2e41896e2c4e16795e4.tar.gz scummvm-rg350-86ab70b149e5cd00cf54f2e41896e2c4e16795e4.tar.bz2 scummvm-rg350-86ab70b149e5cd00cf54f2e41896e2c4e16795e4.zip |
added Patch.re_ support
svn-id: r18603
-rw-r--r-- | saga/game.cpp | 4 | ||||
-rw-r--r-- | saga/rscfile.cpp | 29 | ||||
-rw-r--r-- | saga/rscfile.h | 20 | ||||
-rw-r--r-- | saga/sndres.cpp | 7 |
4 files changed, 48 insertions, 12 deletions
diff --git a/saga/game.cpp b/saga/game.cpp index 2a06dd7237..b68dfef01f 100644 --- a/saga/game.cpp +++ b/saga/game.cpp @@ -601,7 +601,7 @@ static GameFileDescription IHNMCD_GameFiles[] = { {"musicfm.res", GAME_MUSICFILE_FM}, {"musicgm.res", GAME_MUSICFILE_GM}, {"scream.res", GAME_RESOURCEFILE}, - {"patch.re_", GAME_PATCHFILE}, + {"patch.re_", GAME_PATCHFILE | GAME_RESOURCEFILE}, {"scripts.res", GAME_SCRIPTFILE}, {"sfx.res", GAME_SOUNDFILE}, {"voicess.res", GAME_VOICEFILE}, //order of voice bank file is important @@ -619,7 +619,7 @@ static GameFileDescription IHNMCDDE_GameFiles[] = { {"musicgm.res", GAME_MUSICFILE_GM}, {"scream.res", GAME_RESOURCEFILE}, {"scripts.res", GAME_SCRIPTFILE}, - {"patch.re_", GAME_PATCHFILE}, + {"patch.re_", GAME_PATCHFILE | GAME_RESOURCEFILE}, {"sfx.res", GAME_SOUNDFILE}, {"voicess.res", GAME_VOICEFILE}, //order of voice bank file is important {"voices1.res", GAME_VOICEFILE}, diff --git a/saga/rscfile.cpp b/saga/rscfile.cpp index c93bbcd980..3f933b99dd 100644 --- a/saga/rscfile.cpp +++ b/saga/rscfile.cpp @@ -48,6 +48,11 @@ bool Resource::loadContext(ResourceContext *context) { ResourceData *resourceData; byte *tableBuffer; size_t tableSize; + uint16 subjectResourceType; + ResourceContext *subjectContext; + uint32 subjectResourceId; + uint32 patchResourceId; + ResourceData *subjectResourceData; if (!context->file->open(context->fileName)) { return false; @@ -103,7 +108,29 @@ bool Resource::loadContext(ResourceContext *context) { free(tableBuffer); - //process patch files + //process internal patch files + if (GAME_PATCHFILE & context->fileType) { + subjectResourceType = ~GAME_PATCHFILE & context->fileType; + subjectContext = getContext(subjectResourceType); + if (subjectContext == NULL) { + error("Resource::loadContext() Subject context not found"); + } + loadResource(context, context->count - 1, tableBuffer, tableSize); + + MemoryReadStreamEndian readS2(tableBuffer, tableSize, context->isBigEndian); + for (i = 0; i < tableSize / 8; i++) { + subjectResourceId = readS2.readUint32(); + patchResourceId = readS2.readUint32(); + subjectResourceData = getResourceData(subjectContext, subjectResourceId); + resourceData = getResourceData(context, patchResourceId); + subjectResourceData->patchData = new PatchData(context->file); + subjectResourceData->offset = resourceData->offset; + subjectResourceData->size = resourceData->size; + } + + } + + //process external patch files if (result) { for (j = 0; j < _vm->getGameDescription()->patchsCount; j++) { patchDescription = &_vm->getGameDescription()->patchDescriptions[j]; diff --git a/saga/rscfile.h b/saga/rscfile.h index 63d8ef79f9..aff29a795c 100644 --- a/saga/rscfile.h +++ b/saga/rscfile.h @@ -36,18 +36,21 @@ namespace Saga { #define RSC_MIN_FILESIZE (RSC_TABLEINFO_SIZE + RSC_TABLEENTRY_SIZE + 1) -//TODO: good PATCH.RE_ support - struct PatchData { + bool _deletePatchFile; Common::File *_patchFile; GamePatchDescription *_patchDescription; - PatchData(GamePatchDescription *patchDescription): _patchDescription(patchDescription) { + PatchData(GamePatchDescription *patchDescription): _patchDescription(patchDescription), _deletePatchFile(true) { _patchFile = new Common::File(); } + PatchData(Common::File *patchFile): _patchDescription(NULL), _patchFile(patchFile), _deletePatchFile(false) { + } ~PatchData() { - delete _patchFile; + if (_deletePatchFile) { + delete _patchFile; + } } }; @@ -55,6 +58,15 @@ struct ResourceData { size_t offset; size_t size; PatchData *patchData; + void fillSoundPatch(const GameSoundInfo *&soundInfo) { + if (patchData != NULL) { + if (patchData->_patchDescription != NULL) { + if (patchData->_patchDescription->soundInfo != NULL) { + soundInfo = patchData->_patchDescription->soundInfo; + } + } + } + } }; struct ResourceContext { diff --git a/saga/sndres.cpp b/saga/sndres.cpp index 1cb7815571..7d228628ca 100644 --- a/saga/sndres.cpp +++ b/saga/sndres.cpp @@ -116,11 +116,8 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff } else { soundInfo = _vm->getSfxInfo(); } - if (context->table[resourceId].patchData != NULL) { - if (context->table[resourceId].patchData->_patchDescription->soundInfo != NULL) { - soundInfo = context->table[resourceId].patchData->_patchDescription->soundInfo; - } - } + + context->table[resourceId].fillSoundPatch(soundInfo); MemoryReadStream readS(soundResource, soundResourceLength); |