Ticket #8432: cd-warning.diff

File cd-warning.diff, 2.9 KB (added by eriktorbjorn, 16 years ago)

Patch against a May 25 CVS snapshot

  • base/engine.cpp

    diff -ur --exclude=CVS --exclude=Makefile ScummVM/base/engine.cpp ScummVM+hack/base/engine.cpp
    old new  
    3030#include "common/savefile.h"
    3131#include "common/system.h"
    3232#include "sound/mixer.h"
     33#include "gui/message.h"
    3334
    3435/* FIXME - BIG HACK for MidiEmu */
    3536Engine *g_engine = 0;
     
    8485                _system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
    8586}
    8687
     88void Engine::checkCD() {
     89#ifdef WIN32
     90        // It is a known bug under Windows that games that play CD audio cause
     91        // ScummVM to crash if the data files are read from the same CD. Check
     92        // if this appears to be the case and issue a warning.
     93
     94        // If we can find a compressed audio track, then it should be ok even
     95        // if it's running from CD.
     96
     97#ifdef USE_VORBIS
     98        if (Common::File::exists("track1.ogg"))
     99                return;
     100#endif
     101#ifdef USE_FLAC
     102        if (Common::File::exists("track1.fla") || Common::File::exists("track1.flac"))
     103                return;
     104#endif
     105#ifdef USE_MAD
     106        if (Common::File::exists("track1.mp3"))
     107                return;
     108#endif
     109
     110        char buffer[MAXPATHLEN];
     111        int i;
     112
     113        if (strlen(getGameDataPath()) == 0) {
     114                // That's it! I give up!
     115                if (getcwd(buffer, MAXPATHLEN) == NULL)
     116                        return;
     117        } else
     118                strncpy(buffer, getGameDataPath(), MAXPATHLEN);
     119
     120        for (i = 0; i < MAXPATHLEN - 1; i++) {
     121                if (buffer[i] == '\\')
     122                        break;
     123        }
     124
     125        buffer[i + 1] = 0;
     126
     127        if (GetDriveType(buffer) == DRIVE_CDROM) {
     128                GUI::MessageDialog dialog(
     129                        "You appear to be playing this game directly\n"
     130                        "from the CD. This is known to cause problems,\n"
     131                        "and it's therefore recommended that you copy\n"
     132                        "the data files to your hard disk instead.\n"
     133                        "See the README file for details.", "OK");
     134                dialog.runModal();
     135        }
     136#endif
     137}
     138
    87139const char *Engine::getGameDataPath() const {
    88140        return _gameDataPath.c_str();
    89141}
  • base/engine.h

    diff -ur --exclude=CVS --exclude=Makefile ScummVM/base/engine.h ScummVM+hack/base/engine.h
    old new  
    6969        virtual void errorString(const char *buf_input, char *buf_output) = 0;
    7070
    7171        void initCommonGFX(GameDetector &detector);
     72
     73        /** On some systems, check if the game appears to be run from CD. */
     74        void checkCD();
    7275};
    7376
    7477extern Engine *g_engine;
  • scumm/scumm.cpp

    diff -ur --exclude=CVS --exclude=Makefile ScummVM/scumm/scumm.cpp ScummVM+hack/scumm/scumm.cpp
    old new  
    14501450
    14511451        _system->endGFXTransaction();
    14521452
     1453        // On some systems it's not safe to run CD audio games from the CD.
     1454        if (_features & GF_AUDIOTRACKS)
     1455                checkCD();
     1456
    14531457        int cd_num = ConfMan.getInt("cdrom");
    14541458        if (cd_num >= 0 && (_features & GF_AUDIOTRACKS))
    14551459                _system->openCD(cd_num);