mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-20 08:48:13 +00:00
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
This commit is contained in:
parent
a641c3add7
commit
71436ff1de
@ -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;
|
||||
|
||||
//self check
|
||||
for (j = 0; j < i; j++) {
|
||||
if ((_contexts[j].fileType & context->fileType) != 0) {
|
||||
error("Resource::createContexts() duplicate fileType");
|
||||
// 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.
|
||||
|
||||
for (int j = i - 1; j >= 0; j--) {
|
||||
if (_contexts[j].fileType & context->fileType) {
|
||||
context->serial = _contexts[j].serial + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user