diff options
-rw-r--r-- | base/engine.cpp | 52 | ||||
-rw-r--r-- | base/engine.h | 3 | ||||
-rw-r--r-- | scumm/scumm.cpp | 4 |
3 files changed, 59 insertions, 0 deletions
diff --git a/base/engine.cpp b/base/engine.cpp index 5905e7e598..f48ca83c96 100644 --- a/base/engine.cpp +++ b/base/engine.cpp @@ -30,6 +30,7 @@ #include "common/savefile.h" #include "common/system.h" #include "sound/mixer.h" +#include "gui/message.h" /* FIXME - BIG HACK for MidiEmu */ Engine *g_engine = 0; @@ -84,6 +85,57 @@ void Engine::initCommonGFX(GameDetector &detector) { _system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen")); } +void Engine::checkCD() { +#ifdef WIN32 + // It is a known bug under Windows that games that play CD audio cause + // ScummVM to crash if the data files are read from the same CD. Check + // if this appears to be the case and issue a warning. + + // If we can find a compressed audio track, then it should be ok even + // if it's running from CD. + +#ifdef USE_VORBIS + if (Common::File::exists("track1.ogg")) + return; +#endif +#ifdef USE_FLAC + if (Common::File::exists("track1.fla") || Common::File::exists("track1.flac")) + return; +#endif +#ifdef USE_MAD + if (Common::File::exists("track1.mp3")) + return; +#endif + + char buffer[MAXPATHLEN]; + int i; + + if (strlen(getGameDataPath()) == 0) { + // That's it! I give up! + if (getcwd(buffer, MAXPATHLEN) == NULL) + return; + } else + strncpy(buffer, getGameDataPath(), MAXPATHLEN); + + for (i = 0; i < MAXPATHLEN - 1; i++) { + if (buffer[i] == '\\') + break; + } + + buffer[i + 1] = 0; + + if (GetDriveType(buffer) == DRIVE_CDROM) { + GUI::MessageDialog dialog( + "You appear to be playing this game directly\n" + "from the CD. This is known to cause problems,\n" + "and it's therefore recommended that you copy\n" + "the data files to your hard disk instead.\n" + "See the README file for details.", "OK"); + dialog.runModal(); + } +#endif +} + const char *Engine::getGameDataPath() const { return _gameDataPath.c_str(); } diff --git a/base/engine.h b/base/engine.h index 6c34b988de..42212be230 100644 --- a/base/engine.h +++ b/base/engine.h @@ -69,6 +69,9 @@ public: virtual void errorString(const char *buf_input, char *buf_output) = 0; void initCommonGFX(GameDetector &detector); + + /** On some systems, check if the game appears to be run from CD. */ + void checkCD(); }; extern Engine *g_engine; diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp index 9be88af8ea..2b05c35fbe 100644 --- a/scumm/scumm.cpp +++ b/scumm/scumm.cpp @@ -1461,6 +1461,10 @@ int ScummEngine::init(GameDetector &detector) { _system->endGFXTransaction(); + // On some systems it's not safe to run CD audio games from the CD. + if (_features & GF_AUDIOTRACKS) + checkCD(); + int cd_num = ConfMan.getInt("cdrom"); if (cd_num >= 0 && (_features & GF_AUDIOTRACKS)) _system->openCD(cd_num); |