diff options
author | James Brown | 2004-07-11 04:41:48 +0000 |
---|---|---|
committer | James Brown | 2004-07-11 04:41:48 +0000 |
commit | 9756a420a3629900783c63f1bc4778c08e2c969b (patch) | |
tree | 80124eac426f0a93ac6a4767ab669a5186a48eed | |
parent | 26f4df6aa35199522be4111da17e38f7a6ffbd61 (diff) | |
download | scummvm-rg350-9756a420a3629900783c63f1bc4778c08e2c969b.tar.gz scummvm-rg350-9756a420a3629900783c63f1bc4778c08e2c969b.tar.bz2 scummvm-rg350-9756a420a3629900783c63f1bc4778c08e2c969b.zip |
Use extrapath in Sword1 engine (from 0.6.0 branch). More verbose errors to go with the forthcoming new manual. Sword1 CD swapping doesn't work as expected HERE, either :)
svn-id: r14188
-rw-r--r-- | graphics/animation.cpp | 10 | ||||
-rw-r--r-- | sound/audiostream.cpp | 7 | ||||
-rw-r--r-- | sound/audiostream.h | 2 | ||||
-rw-r--r-- | sword1/animation.cpp | 7 | ||||
-rw-r--r-- | sword1/resman.cpp | 44 | ||||
-rw-r--r-- | sword1/sword1.cpp | 19 |
6 files changed, 74 insertions, 15 deletions
diff --git a/graphics/animation.cpp b/graphics/animation.cpp index 0b5aba1e99..c5dcef267e 100644 --- a/graphics/animation.cpp +++ b/graphics/animation.cpp @@ -23,6 +23,7 @@ #include "graphics/animation.h" #include "common/file.h" #include "sound/audiostream.h" +#include "common/config-manager.h" namespace Graphics { @@ -46,6 +47,8 @@ BaseAnimationState::~BaseAnimationState() { bool BaseAnimationState::init(const char *name) { + const Common::String ePath = ConfMan.get("extrapath"); + #ifdef USE_MPEG2 char tempFile[512]; @@ -62,7 +65,7 @@ bool BaseAnimationState::init(const char *name) { File f; - if (!f.open(tempFile)) { + if (!f.open(tempFile) && !f.open(tempFile, File::kFileReadMode, ePath.c_str())) { warning("Cutscene: %s palette missing", tempFile); return false; } @@ -111,7 +114,8 @@ bool BaseAnimationState::init(const char *name) { // Open MPEG2 stream mpgfile = new File(); sprintf(tempFile, "%s.mp2", name); - if (!mpgfile->open(tempFile)) { + if (!mpgfile->open(tempFile) && + !mpgfile->open(tempFile, File::kFileReadMode, ePath.c_str())) { warning("Cutscene: Could not open %s", tempFile); return false; } @@ -130,6 +134,8 @@ bool BaseAnimationState::init(const char *name) { // Play audio bgSoundStream = AudioStream::openStreamFile(name); + if (bgSoundStream == NULL) + bgSoundStream = AudioStream::openStreamFile(name, ePath.c_str()); if (bgSoundStream != NULL) { _snd->playInputStream(&bgSound, bgSoundStream, false, 255, 0, -1, false); diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp index ee86fd9c30..d61f572f34 100644 --- a/sound/audiostream.cpp +++ b/sound/audiostream.cpp @@ -67,7 +67,7 @@ static const StreamFileFormat STREAM_FILEFORMATS[] = { { NULL, NULL, NULL } // Terminator }; -AudioStream* AudioStream::openStreamFile(const char* filename) +AudioStream* AudioStream::openStreamFile(const char* filename, const char *path) { char buffer[1024]; const uint len = strlen(filename); @@ -82,7 +82,10 @@ AudioStream* AudioStream::openStreamFile(const char* filename) for (int i = 0; i < ARRAYSIZE(STREAM_FILEFORMATS)-1 && stream == NULL; ++i) { strcpy(ext, STREAM_FILEFORMATS[i].fileExtension); - fileHandle->open(buffer); + if (path != NULL) + fileHandle->open(buffer, File::kFileReadMode, path); + else + fileHandle->open(buffer); if (fileHandle->isOpen()) stream = STREAM_FILEFORMATS[i].openStreamFile(fileHandle, fileHandle->size()); } diff --git a/sound/audiostream.h b/sound/audiostream.h index ac456233ba..bd39c04c2b 100644 --- a/sound/audiostream.h +++ b/sound/audiostream.h @@ -86,7 +86,7 @@ public: * @return an Audiostream ready to use in case of success; * NULL in case of an error (e.g. invalid/nonexisting file) */ - static AudioStream* openStreamFile(const char* filename); + static AudioStream* openStreamFile(const char* filename, const char* path=NULL); }; class AppendableAudioStream : public AudioStream { diff --git a/sword1/animation.cpp b/sword1/animation.cpp index a0962f0237..6dee00941a 100644 --- a/sword1/animation.cpp +++ b/sword1/animation.cpp @@ -25,6 +25,8 @@ #include "sound/audiostream.h" +#include "common/config-manager.h" +#include "common/str.h" namespace Sword1 { AnimationState::AnimationState(Screen *scr, SoundMixer *snd, OSystem *sys) @@ -63,8 +65,9 @@ MoviePlayer::MoviePlayer(Screen *scr, SoundMixer *snd, OSystem *sys) void MoviePlayer::play(const char *filename) { #ifdef USE_MPEG2 AnimationState *anim = new AnimationState(_scr, _snd, _sys); + bool initOK = anim->init(filename); - if (anim->init(filename)) { + if (initOK) { while (anim->decodeFrame()) { #ifndef BACKEND_8BIT _sys->updateScreen(); @@ -98,4 +101,4 @@ void MoviePlayer::play(const char *filename) { #endif } -} // End of namespace Sword2 +} // End of namespace Sword1 diff --git a/sword1/resman.cpp b/sword1/resman.cpp index 49123ddba3..2cd0205286 100644 --- a/sword1/resman.cpp +++ b/sword1/resman.cpp @@ -25,10 +25,24 @@ #include "resman.h" #include "sworddefs.h" #include "base/engine.h" +#include "common/config-manager.h" #include "common/util.h" +#include "common/str.h" #include "swordres.h" +#include "gui/message.h" +#include "gui/newgui.h" + namespace Sword1 { + void guiFatalError(char *msg) { + // Displays a dialog on-screen before terminating the engine. + // TODO: We really need to setup a special palette for cases when + // the engine is erroring before setting one... otherwise invisible cursor :) + + GUI::MessageDialog dialog(msg); + dialog.runModal(); + error(msg); +} #define MAX_PATH_LEN 260 @@ -44,8 +58,19 @@ ResMan::~ResMan(void) { void ResMan::loadCluDescript(const char *fileName) { File resFile; resFile.open(fileName); - if (!resFile.isOpen()) - error("ResMan::loadCluDescript(): File %s not found!", fileName); + if (!resFile.isOpen()) { + // Uh-uh, file not found. Perhaps we're playing straight from CD2? + // Check the Extra Path. + const Common::String ePath = ConfMan.get("extrapath"); + resFile.open(fileName, File::kFileReadMode, ePath.c_str()); + } + + if (!resFile.isOpen()) { + char msg[512]; + sprintf(msg, "Couldn't open CLU description '%s'\n\nIf you are running from CD, please ensure you have read the ScummVM documentation regarding multi-cd games.", fileName); + guiFatalError(msg); + } + _prj.noClu = resFile.readUint32LE(); _prj.clu = new Clu*[_prj.noClu]; @@ -232,8 +257,19 @@ File *ResMan::openClusterFile(uint32 id) { char fileName[15]; sprintf(fileName, "%s.CLU", _prj.clu[(id >> 24)-1]->label); clusFile->open(fileName); - if (!clusFile->isOpen()) - error("Can't open cluster file %s", fileName); + if (!clusFile->isOpen()) { + // Uh-uh, file not found. Perhaps we're playing straight from CD2, + // and its looking for something like SCRIPTS.CLU. Check the Extra Path. + const Common::String ePath = ConfMan.get("extrapath"); + clusFile->open(fileName, File::kFileReadMode, ePath.c_str()); + } + + if (!clusFile->isOpen()) { + char msg[512]; + sprintf(msg, "Couldn't open game cluster file '%s'\n\nIf you are running from CD, please ensure you have read the ScummVM documentation regarding multi-cd games.", fileName); + guiFatalError(msg); + } + return clusFile; } diff --git a/sword1/sword1.cpp b/sword1/sword1.cpp index da41398659..b29ad6f09b 100644 --- a/sword1/sword1.cpp +++ b/sword1/sword1.cpp @@ -41,6 +41,9 @@ #include "music.h" #include "control.h" +#include "gui/message.h" +#include "gui/newgui.h" + using namespace Sword1; /* Broken Sword 1 */ @@ -1062,8 +1065,12 @@ void SwordEngine::checkCdFiles(void) { // check if we're running from cd, hdd or _systemVars.runningFromCd = false; _systemVars.playSpeech = true; return ; - } else - error("SPEECH2.CLU not found.\nPlease copy the SPEECH.CLU from CD2 and rename it to SPEECH2.CLU"); + } else { + const char msg[] = "SPEECH2.CLU not found.\nPlease copy the SPEECH.CLU from CD2 and rename it to SPEECH2.CLU"; + GUI::MessageDialog dialog(msg); + dialog.runModal(); + error(msg); + } } else { // speech1.clu & speech2.clu not present. are we running from cd? if (test.open("cd1.id")) { _systemVars.runningFromCd = true; @@ -1073,8 +1080,12 @@ void SwordEngine::checkCdFiles(void) { // check if we're running from cd, hdd or _systemVars.runningFromCd = true; _systemVars.currentCD = 2; test.close(); - } else - error("Unable to find files.\nPlease read the instructions again"); + } else { + const char msg[] = "Unable to find the game files.\nPlease read the ScummVM documentation"; + GUI::MessageDialog dialog(msg); + dialog.runModal(); + error(msg); + } } } |