aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
Diffstat (limited to 'saga')
-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];
}
}