[Scummvm-cvs-logs] SF.net SVN: scummvm: [30652] scummvm/branches/branch-0-11-0/engines/saga
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Sun Jan 27 16:23:46 CET 2008
Revision: 30652
http://scummvm.svn.sourceforge.net/scummvm/?rev=30652&view=rev
Author: thebluegr
Date: 2008-01-27 07:23:45 -0800 (Sun, 27 Jan 2008)
Log Message:
-----------
Backport commits #30617 and #30648 to 0.11.0 branch
Modified Paths:
--------------
scummvm/branches/branch-0-11-0/engines/saga/rscfile.cpp
scummvm/branches/branch-0-11-0/engines/saga/rscfile.h
scummvm/branches/branch-0-11-0/engines/saga/sndres.cpp
Modified: scummvm/branches/branch-0-11-0/engines/saga/rscfile.cpp
===================================================================
--- scummvm/branches/branch-0-11-0/engines/saga/rscfile.cpp 2008-01-27 15:12:55 UTC (rev 30651)
+++ scummvm/branches/branch-0-11-0/engines/saga/rscfile.cpp 2008-01-27 15:23:45 UTC (rev 30652)
@@ -342,6 +342,12 @@
}
}
+ // Close the file if it's part of a series of files
+ // This prevents having all voice files open in IHNM for no reason, as each chapter uses
+ // a different voice file
+ if (context->serial > 0)
+ context->file->close();
+
return true;
}
@@ -350,7 +356,6 @@
ResourceContext *context;
char musicFileName[256];
char soundFileName[256];
- char voicesFileName[256];
int soundFileIndex = 0;
int voicesFileIndex = 0;
bool digitalMusic = false;
@@ -428,18 +433,18 @@
_contextsCount++;
voicesFileIndex = _contextsCount - 1;
if (Common::File::exists("voices.rsc")) {
- sprintf(voicesFileName, "voices.rsc");
+ sprintf(_voicesFileName[0], "voices.rsc");
} else {
- sprintf(voicesFileName, "voices.cmp");
+ sprintf(_voicesFileName[0], "voices.cmp");
_vm->_gf_compressed_sounds = true;
}
} else if (Common::File::exists("voicesd.rsc") || Common::File::exists("voicesd.cmp")) {
_contextsCount++;
voicesFileIndex = _contextsCount - 1;
if (Common::File::exists("voicesd.rsc")) {
- sprintf(voicesFileName, "voicesd.rsc");
+ sprintf(_voicesFileName[0], "voicesd.rsc");
} else {
- sprintf(voicesFileName, "voicesd.cmp");
+ sprintf(_voicesFileName[0], "voicesd.cmp");
_vm->_gf_compressed_sounds = true;
}
} else if (Common::File::exists("inherit the earth voices") ||
@@ -447,9 +452,9 @@
_contextsCount++;
voicesFileIndex = _contextsCount - 1;
if (Common::File::exists("inherit the earth voices")) {
- sprintf(voicesFileName, "inherit the earth voices");
+ sprintf(_voicesFileName[0], "inherit the earth voices");
} else {
- sprintf(voicesFileName, "inherit the earth voices.cmp");
+ sprintf(_voicesFileName[0], "inherit the earth voices.cmp");
_vm->_gf_compressed_sounds = true;
}
@@ -483,18 +488,18 @@
censoredVersion = true;
}
if (Common::File::exists("voicess.res")) {
- sprintf(voicesFileName, "voicess.res");
+ sprintf(_voicesFileName[0], "voicess.res");
} else {
- sprintf(voicesFileName, "voicess.cmp");
+ sprintf(_voicesFileName[0], "voicess.cmp");
_vm->_gf_compressed_sounds = true;
}
} else if (Common::File::exists("voicesd.res") || Common::File::exists("voicesd.cmp")) {
_contextsCount++;
voicesFileIndex = _contextsCount - 1;
if (Common::File::exists("voicesd.res")) {
- sprintf(voicesFileName, "voicesd.res");
+ sprintf(_voicesFileName[0], "voicesd.res");
} else {
- sprintf(voicesFileName, "voicesd.cmp");
+ sprintf(_voicesFileName[0], "voicesd.cmp");
_vm->_gf_compressed_sounds = true;
}
} else {
@@ -534,6 +539,7 @@
for (i = 0; i < _contextsCount; i++) {
context = &_contexts[i];
context->file = new Common::File();
+ context->serial = 0;
// For ITE, add the digital music file and sfx file information here
if (_vm->getGameType() == GType_ITE && digitalMusic && i == _contextsCount - 1) {
@@ -543,7 +549,7 @@
context->fileName = soundFileName;
context->fileType = GAME_SOUNDFILE;
} else if (!voicesFileInArray && i == voicesFileIndex) {
- context->fileName = voicesFileName;
+ context->fileName = _voicesFileName[0];
// can be GAME_VOICEFILE or GAME_SOUNDFILE | GAME_VOICEFILE or GAME_VOICEFILE | GAME_SWAPENDIAN
context->fileType = voiceFileType;
} else {
@@ -554,26 +560,19 @@
int token = (censoredVersion && (i - voicesFileIndex >= 4)) ? 1 : 0; // censored versions don't have voice4
if (_vm->getFeatures() & GF_COMPRESSED_SOUNDS)
- sprintf(voicesFileName, "voices%i.cmp", i - voicesFileIndex + token);
+ sprintf(_voicesFileName[i - voicesFileIndex + token], "voices%i.cmp", i - voicesFileIndex + token);
else
- sprintf(voicesFileName, "voices%i.res", i - voicesFileIndex + token);
+ sprintf(_voicesFileName[i - voicesFileIndex + token], "voices%i.res", i - voicesFileIndex + token);
- context->fileName = voicesFileName;
+ context->fileName = _voicesFileName[i - voicesFileIndex + token];
context->fileType = GAME_VOICEFILE;
- }
- }
- context->serial = 0;
- // IHNM has several 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 a 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;
+ // IHNM has several 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 a unique serial
+ // number. The default behaviour when requesting a context will
+ // be to look for serial number 0.
+ context->serial = i - voicesFileIndex + token;
}
}
Modified: scummvm/branches/branch-0-11-0/engines/saga/rscfile.h
===================================================================
--- scummvm/branches/branch-0-11-0/engines/saga/rscfile.h 2008-01-27 15:12:55 UTC (rev 30651)
+++ scummvm/branches/branch-0-11-0/engines/saga/rscfile.h 2008-01-27 15:23:45 UTC (rev 30652)
@@ -161,12 +161,12 @@
SagaEngine *_vm;
ResourceContext *_contexts;
int _contextsCount;
+ char _voicesFileName[8][256];
bool loadContext(ResourceContext *context);
bool loadMacContext(ResourceContext *context);
- bool loadSagaContext(ResourceContext *context, uint32 contextOffset, uint32 contextSize);
+ bool loadSagaContext(ResourceContext *context, uint32 contextOffset, uint32 contextSize);
-
public:
MetaResource _metaResource;
};
Modified: scummvm/branches/branch-0-11-0/engines/saga/sndres.cpp
===================================================================
--- scummvm/branches/branch-0-11-0/engines/saga/sndres.cpp 2008-01-27 15:12:55 UTC (rev 30651)
+++ scummvm/branches/branch-0-11-0/engines/saga/sndres.cpp 2008-01-27 15:23:45 UTC (rev 30652)
@@ -103,9 +103,17 @@
void SndRes::setVoiceBank(int serial) {
if (_voiceSerial == serial) return;
+ // Close previous voice bank file
+ if (_voiceSerial >= 0 && _voiceContext->file->isOpen())
+ _voiceContext->file->close();
+
_voiceSerial = serial;
_voiceContext = _vm->_resource->getContext(GAME_VOICEFILE, _voiceSerial);
+
+ // Open new voice bank file
+ if (!_voiceContext->file->isOpen())
+ _voiceContext->file->open(_voiceContext->fileName);
}
void SndRes::playSound(uint32 resourceId, int volume, bool loop) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list