[Scummvm-git-logs] scummvm master -> 04642eef8afdda3aaa0bc377d9f80835b49506eb
sev-
sev at scummvm.org
Tue Jul 27 18:52:00 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
04642eef8a ENGINES: Replace checkCD with isolated partial methods
Commit: 04642eef8afdda3aaa0bc377d9f80835b49506eb
https://github.com/scummvm/scummvm/commit/04642eef8afdda3aaa0bc377d9f80835b49506eb
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2021-07-27T20:51:57+02:00
Commit Message:
ENGINES: Replace checkCD with isolated partial methods
This is PR #3018 "rebased" on the current HEAD, after the conflicts with PR #3003 and me botching the rebase in that PR
Old PR is here: https://github.com/scummvm/scummvm/pull/3018
Changed paths:
engines/cine/cine.cpp
engines/drascula/drascula.cpp
engines/engine.cpp
engines/engine.h
engines/gob/gob.cpp
engines/groovie/groovie.cpp
engines/kyra/sound/sound_pc98_v2.cpp
engines/kyra/sound/sound_towns_lok.cpp
engines/made/made.cpp
engines/scumm/scumm.cpp
diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp
index db32724e13..212e082569 100644
--- a/engines/cine/cine.cpp
+++ b/engines/cine/cine.cpp
@@ -100,8 +100,12 @@ Common::Error CineEngine::run() {
// Initialize backend
initGraphics(320, 200);
- if (g_cine->getGameType() == GType_FW && (g_cine->getFeatures() & GF_CD))
- checkCD();
+ if (g_cine->getGameType() == GType_FW && (g_cine->getFeatures() & GF_CD)) {
+ if (!existExtractedCDAudioFiles()
+ && !isDataAndCDAudioReadFromSameCD()) {
+ warnMissingExtractedCDAudio();
+ }
+ }
if (getPlatform() == Common::kPlatformDOS) {
g_sound = new PCSound(_mixer, this);
diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp
index b18e245ec6..08c092909e 100644
--- a/engines/drascula/drascula.cpp
+++ b/engines/drascula/drascula.cpp
@@ -277,7 +277,10 @@ Common::Error DrasculaEngine::run() {
currentChapter++;
}
- checkCD();
+ if (!existExtractedCDAudioFiles()
+ && !isDataAndCDAudioReadFromSameCD()) {
+ warnMissingExtractedCDAudio();
+ }
allocMemory();
diff --git a/engines/engine.cpp b/engines/engine.cpp
index 4da6431e0c..b62f0f0b52 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -460,25 +460,39 @@ void GUIErrorMessageFormat(Common::U32String fmt, ...) {
GUIErrorMessage(msg);
}
-void Engine::checkCD() {
+/**
+ * Checks if supported (extracted) audio files are found.
+ *
+ * @return true if audio files of the expected naming scheme are found, as long as ScummVM
+ * is also built with support to the respective audio format (eg. ogg, flac, mad/mp3)
+ */
+bool Engine::existExtractedCDAudioFiles() {
#ifdef USE_VORBIS
if (Common::File::exists("track1.ogg") ||
Common::File::exists("track01.ogg"))
- return;
+ return true;
#endif
#ifdef USE_FLAC
if (Common::File::exists("track1.fla") ||
Common::File::exists("track1.flac") ||
Common::File::exists("track01.fla") ||
Common::File::exists("track01.flac"))
- return;
+ return true;
#endif
#ifdef USE_MAD
if (Common::File::exists("track1.mp3") ||
Common::File::exists("track01.mp3"))
- return;
+ return true;
#endif
+ return false;
+}
+/**
+ * Displays a warning on Windows version of ScummVM, if game data
+ * are read from the same CD drive which should also play game CD audio.
+ * @return true, if this case is applicable and the warning is displayed
+ */
+bool Engine::isDataAndCDAudioReadFromSameCD() {
#if defined(WIN32) && !defined(__SYMBIAN32__)
// 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
@@ -496,7 +510,7 @@ void Engine::checkCD() {
if (!currentDir.getPath().empty()) {
driveLetter = currentDir.getPath()[0];
} else {
- return;
+ return false;
}
}
@@ -506,23 +520,32 @@ void Engine::checkCD() {
"from the CD. This is known to cause problems,\n"
"and it is therefore recommended that you copy\n"
"the data files to your hard disk instead.\n"
- "See the Documentation (CD audio) for details."), _("OK"));
+ "See the documentation (CD audio) for details."), _("OK"));
dialog.runModal();
- } else {
-#endif // defined(WIN32) && !defined(__SYMBIAN32__)
- // If we reached here, the game has audio tracks,
- // it's not ran from the CD and the tracks have not
- // been ripped.
- GUI::MessageDialog dialog(
- _("This game has audio tracks in its disk. These\n"
- "tracks need to be ripped from the disk using\n"
- "an appropriate CD audio extracting tool in\n"
- "order to listen to the game's music.\n"
- "See the Documentation (CD audio) for details."), _("OK"));
- dialog.runModal();
-#if defined(WIN32) && !defined(__SYMBIAN32__)
+ return true;
}
#endif // defined(WIN32) && !defined(__SYMBIAN32__)
+ return false;
+}
+
+/**
+ * Displays a warning, for the case when the game has CD audio but
+ * no extracted (ripped) audio files were found.
+ *
+ * This method only shows the warning. It does not check for the
+ * existence of the ripped audio files.
+ */
+void Engine::warnMissingExtractedCDAudio() {
+ // Display a modal informative dialogue for the case when:
+ // - The game has audio tracks,
+ // - and the tracks have not been ripped.
+ GUI::MessageDialog dialog(
+ _("This game has audio tracks on its CD. These\n"
+ "tracks need to be ripped from the CD using\n"
+ "an appropriate CD audio extracting tool in\n"
+ "order to listen to the game's music.\n"
+ "See the documentation (CD audio) for details."), _("OK"));
+ dialog.runModal();
}
void Engine::handleAutoSave() {
diff --git a/engines/engine.h b/engines/engine.h
index c2198eaa5f..33d62c5c78 100644
--- a/engines/engine.h
+++ b/engines/engine.h
@@ -587,9 +587,19 @@ public:
inline Common::SaveFileManager *getSaveFileManager() { return _saveFileMan; }
public:
- /** On some systems, check whether the game appears to be run from CD. */
- void checkCD();
-
+ /**
+ * Check if extracted CD Audio files are found.
+ */
+ bool existExtractedCDAudioFiles();
+ /**
+ * On some systems, check whether the game appears to be run
+ * from the same CD drive, which also should play CD audio.
+ */
+ bool isDataAndCDAudioReadFromSameCD();
+ /**
+ *Display a warning for no extracted CD Audio files found.
+ */
+ void warnMissingExtractedCDAudio();
/**
* Check whether it is time to autosave, and if so, do it.
diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp
index b13842f463..8413b47e60 100644
--- a/engines/gob/gob.cpp
+++ b/engines/gob/gob.cpp
@@ -282,8 +282,12 @@ Common::Error GobEngine::run() {
return err;
// On some systems it's not safe to run CD audio games from the CD.
- if (isCD())
- checkCD();
+ if (isCD()) {
+ if (!existExtractedCDAudioFiles()
+ && !isDataAndCDAudioReadFromSameCD()) {
+ warnMissingExtractedCDAudio();
+ }
+ }
_system->getAudioCDManager()->open();
diff --git a/engines/groovie/groovie.cpp b/engines/groovie/groovie.cpp
index 6a55bafca0..533db607fe 100644
--- a/engines/groovie/groovie.cpp
+++ b/engines/groovie/groovie.cpp
@@ -246,7 +246,10 @@ Common::Error GroovieEngine::run() {
// Check that the game files and the audio tracks aren't together run from
// the same cd
if (getPlatform() != Common::kPlatformIOS) {
- checkCD();
+ if (!existExtractedCDAudioFiles()
+ && !isDataAndCDAudioReadFromSameCD()) {
+ warnMissingExtractedCDAudio();
+ }
_system->getAudioCDManager()->open();
}
diff --git a/engines/kyra/sound/sound_pc98_v2.cpp b/engines/kyra/sound/sound_pc98_v2.cpp
index 969702d9c4..59cbf7843e 100644
--- a/engines/kyra/sound/sound_pc98_v2.cpp
+++ b/engines/kyra/sound/sound_pc98_v2.cpp
@@ -53,8 +53,12 @@ bool SoundTownsPC98_v2::init() {
if (_vm->gameFlags().platform == Common::kPlatformFMTowns) {
if (_resInfo[_currentResourceSet])
- if (_resInfo[_currentResourceSet]->cdaTableSize)
- _vm->checkCD();
+ if (_resInfo[_currentResourceSet]->cdaTableSize) {
+ if (!_vm->existExtractedCDAudioFiles()
+ && !_vm->isDataAndCDAudioReadFromSameCD()) {
+ _vm->warnMissingExtractedCDAudio();
+ }
+ }
// Initialize CD for audio
bool hasRealCD = g_system->getAudioCDManager()->open();
diff --git a/engines/kyra/sound/sound_towns_lok.cpp b/engines/kyra/sound/sound_towns_lok.cpp
index 16de13cd96..e50dfa83ca 100644
--- a/engines/kyra/sound/sound_towns_lok.cpp
+++ b/engines/kyra/sound/sound_towns_lok.cpp
@@ -49,7 +49,10 @@ SoundTowns_LoK::~SoundTowns_LoK() {
}
bool SoundTowns_LoK::init() {
- _vm->checkCD();
+ if (!_vm->existExtractedCDAudioFiles()
+ && !_vm->isDataAndCDAudioReadFromSameCD()) {
+ _vm->warnMissingExtractedCDAudio();
+ }
int unused = 0;
_musicFadeTable = _vm->staticres()->loadRawData(k1TownsMusicFadeTable, unused);
_sfxWDTable = _vm->staticres()->loadRawData(k1TownsSFXwdTable, unused);
diff --git a/engines/made/made.cpp b/engines/made/made.cpp
index c9f20bab82..cdcc3cd8dc 100644
--- a/engines/made/made.cpp
+++ b/engines/made/made.cpp
@@ -296,8 +296,12 @@ Common::Error MadeEngine::run() {
error ("Unknown MADE game");
}
- if ((getFeatures() & GF_CD) || (getFeatures() & GF_CD_COMPRESSED))
- checkCD();
+ if ((getFeatures() & GF_CD) || (getFeatures() & GF_CD_COMPRESSED)) {
+ if (!existExtractedCDAudioFiles()
+ && !isDataAndCDAudioReadFromSameCD()) {
+ warnMissingExtractedCDAudio();
+ }
+ }
_autoStopSound = false;
_eventNum = _eventKey = _eventMouseX = _eventMouseY = 0;
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 8afa32e2c8..d422a5e2da 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -1503,7 +1503,10 @@ void ScummEngine::setupScumm(const Common::String &macResourceFile) {
// On some systems it's not safe to run CD audio games from the CD.
if (_game.features & GF_AUDIOTRACKS && !Common::File::exists("CDDA.SOU")) {
- checkCD();
+ if (!existExtractedCDAudioFiles()
+ && !isDataAndCDAudioReadFromSameCD()) {
+ warnMissingExtractedCDAudio();
+ }
_system->getAudioCDManager()->open();
}
More information about the Scummvm-git-logs
mailing list