From dc3372b5804b61f5e213ccbfd98c8847fd5f10cf Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Tue, 14 Jun 2005 08:54:11 +0000 Subject: Applied patch #1208299. A warning message about the "playing from CD under Windows" bug is better than nothing, even if a proper bugfix - if one is possible - would be preferable. svn-id: r18389 --- base/engine.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ base/engine.h | 3 +++ 2 files changed, 55 insertions(+) (limited to 'base') 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; -- cgit v1.2.3