aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-07-23 15:23:01 +0000
committerTorbjörn Andersson2005-07-23 15:23:01 +0000
commit71436ff1dea082d54106aec6c6d51777d09fff32 (patch)
treebcb1af5fae495214833aa1686763e110d5458170
parenta641c3add768f4e6f648670f00f5f793bdbf3d34 (diff)
downloadscummvm-rg350-71436ff1dea082d54106aec6c6d51777d09fff32.tar.gz
scummvm-rg350-71436ff1dea082d54106aec6c6d51777d09fff32.tar.bz2
scummvm-rg350-71436ff1dea082d54106aec6c6d51777d09fff32.zip
Allow multiple resource contexts of the same type. IHNM has serveral
different voice files, presumably one for each section of the game plus one for shared voices. The getContext() function takes an optional second parameter to indicate which of the resource files is requested. svn-id: r18575
-rw-r--r--saga/rscfile.cpp17
-rw-r--r--saga/rscfile.h5
2 files changed, 15 insertions, 7 deletions
diff --git a/saga/rscfile.cpp b/saga/rscfile.cpp
index b6eac5cdfe..f9d2afb4aa 100644
--- a/saga/rscfile.cpp
+++ b/saga/rscfile.cpp
@@ -133,7 +133,7 @@ bool Resource::loadContext(ResourceContext *context) {
}
bool Resource::createContexts() {
- int i, j;
+ int i;
ResourceContext *context;
_contextsCount = _vm->getGameDescription()->filesCount;
_contexts = (ResourceContext*)calloc(_contextsCount, sizeof(*_contexts));
@@ -143,11 +143,18 @@ bool Resource::createContexts() {
context->file = new Common::File();
context->fileName = _vm->getGameDescription()->filesDescriptions[i].fileName;
context->fileType = _vm->getGameDescription()->filesDescriptions[i].fileType;
+ context->serial = 0;
+
+ // IHNM has serveral different voice files, so we need to allow
+ // multiple resource contexts of the same type. We tell them
+ // apart by assigning each of the duplicates an unique serial
+ // number. The default behaviour when requesting a context will
+ // be to look for serial number 0.
- //self check
- for (j = 0; j < i; j++) {
- if ((_contexts[j].fileType & context->fileType) != 0) {
- error("Resource::createContexts() duplicate fileType");
+ for (int j = i - 1; j >= 0; j--) {
+ if (_contexts[j].fileType & context->fileType) {
+ context->serial = _contexts[j].serial + 1;
+ break;
}
}
diff --git a/saga/rscfile.h b/saga/rscfile.h
index 3e0e8015aa..343e25b0c7 100644
--- a/saga/rscfile.h
+++ b/saga/rscfile.h
@@ -48,6 +48,7 @@ struct ResourceContext {
const char *fileName;
uint16 fileType;
Common::File *file;
+ int serial;
bool isBigEndian;
ResourceData *table;
@@ -72,10 +73,10 @@ public:
size_t getResourceSize(ResourceContext *context, uint32 resourceId);
uint32 convertResourceId(uint32 resourceId);
- ResourceContext *getContext(uint16 fileType) {
+ ResourceContext *getContext(uint16 fileType, int serial = 0) {
int i;
for (i = 0; i < _contextsCount; i++) {
- if (_contexts[i].fileType & fileType) {
+ if ((_contexts[i].fileType & fileType) && _contexts[i].serial == serial) {
return &_contexts[i];
}
}