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
This commit is contained in:
parent
c05acdafd5
commit
04642eef8a
10 changed files with 95 additions and 34 deletions
|
@ -100,8 +100,12 @@ Common::Error CineEngine::run() {
|
||||||
// Initialize backend
|
// Initialize backend
|
||||||
initGraphics(320, 200);
|
initGraphics(320, 200);
|
||||||
|
|
||||||
if (g_cine->getGameType() == GType_FW && (g_cine->getFeatures() & GF_CD))
|
if (g_cine->getGameType() == GType_FW && (g_cine->getFeatures() & GF_CD)) {
|
||||||
checkCD();
|
if (!existExtractedCDAudioFiles()
|
||||||
|
&& !isDataAndCDAudioReadFromSameCD()) {
|
||||||
|
warnMissingExtractedCDAudio();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (getPlatform() == Common::kPlatformDOS) {
|
if (getPlatform() == Common::kPlatformDOS) {
|
||||||
g_sound = new PCSound(_mixer, this);
|
g_sound = new PCSound(_mixer, this);
|
||||||
|
|
|
@ -277,7 +277,10 @@ Common::Error DrasculaEngine::run() {
|
||||||
currentChapter++;
|
currentChapter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkCD();
|
if (!existExtractedCDAudioFiles()
|
||||||
|
&& !isDataAndCDAudioReadFromSameCD()) {
|
||||||
|
warnMissingExtractedCDAudio();
|
||||||
|
}
|
||||||
|
|
||||||
allocMemory();
|
allocMemory();
|
||||||
|
|
||||||
|
|
|
@ -460,25 +460,39 @@ void GUIErrorMessageFormat(Common::U32String fmt, ...) {
|
||||||
GUIErrorMessage(msg);
|
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
|
#ifdef USE_VORBIS
|
||||||
if (Common::File::exists("track1.ogg") ||
|
if (Common::File::exists("track1.ogg") ||
|
||||||
Common::File::exists("track01.ogg"))
|
Common::File::exists("track01.ogg"))
|
||||||
return;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_FLAC
|
#ifdef USE_FLAC
|
||||||
if (Common::File::exists("track1.fla") ||
|
if (Common::File::exists("track1.fla") ||
|
||||||
Common::File::exists("track1.flac") ||
|
Common::File::exists("track1.flac") ||
|
||||||
Common::File::exists("track01.fla") ||
|
Common::File::exists("track01.fla") ||
|
||||||
Common::File::exists("track01.flac"))
|
Common::File::exists("track01.flac"))
|
||||||
return;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_MAD
|
#ifdef USE_MAD
|
||||||
if (Common::File::exists("track1.mp3") ||
|
if (Common::File::exists("track1.mp3") ||
|
||||||
Common::File::exists("track01.mp3"))
|
Common::File::exists("track01.mp3"))
|
||||||
return;
|
return true;
|
||||||
#endif
|
#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__)
|
#if defined(WIN32) && !defined(__SYMBIAN32__)
|
||||||
// It is a known bug under Windows that games that play CD audio cause
|
// 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
|
// 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()) {
|
if (!currentDir.getPath().empty()) {
|
||||||
driveLetter = currentDir.getPath()[0];
|
driveLetter = currentDir.getPath()[0];
|
||||||
} else {
|
} else {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,23 +520,32 @@ void Engine::checkCD() {
|
||||||
"from the CD. This is known to cause problems,\n"
|
"from the CD. This is known to cause problems,\n"
|
||||||
"and it is therefore recommended that you copy\n"
|
"and it is therefore recommended that you copy\n"
|
||||||
"the data files to your hard disk instead.\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();
|
dialog.runModal();
|
||||||
} else {
|
return true;
|
||||||
#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__)
|
|
||||||
}
|
}
|
||||||
#endif // defined(WIN32) && !defined(__SYMBIAN32__)
|
#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() {
|
void Engine::handleAutoSave() {
|
||||||
|
|
|
@ -587,9 +587,19 @@ public:
|
||||||
inline Common::SaveFileManager *getSaveFileManager() { return _saveFileMan; }
|
inline Common::SaveFileManager *getSaveFileManager() { return _saveFileMan; }
|
||||||
|
|
||||||
public:
|
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.
|
* Check whether it is time to autosave, and if so, do it.
|
||||||
|
|
|
@ -282,8 +282,12 @@ Common::Error GobEngine::run() {
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
// On some systems it's not safe to run CD audio games from the CD.
|
// On some systems it's not safe to run CD audio games from the CD.
|
||||||
if (isCD())
|
if (isCD()) {
|
||||||
checkCD();
|
if (!existExtractedCDAudioFiles()
|
||||||
|
&& !isDataAndCDAudioReadFromSameCD()) {
|
||||||
|
warnMissingExtractedCDAudio();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_system->getAudioCDManager()->open();
|
_system->getAudioCDManager()->open();
|
||||||
|
|
||||||
|
|
|
@ -246,7 +246,10 @@ Common::Error GroovieEngine::run() {
|
||||||
// Check that the game files and the audio tracks aren't together run from
|
// Check that the game files and the audio tracks aren't together run from
|
||||||
// the same cd
|
// the same cd
|
||||||
if (getPlatform() != Common::kPlatformIOS) {
|
if (getPlatform() != Common::kPlatformIOS) {
|
||||||
checkCD();
|
if (!existExtractedCDAudioFiles()
|
||||||
|
&& !isDataAndCDAudioReadFromSameCD()) {
|
||||||
|
warnMissingExtractedCDAudio();
|
||||||
|
}
|
||||||
_system->getAudioCDManager()->open();
|
_system->getAudioCDManager()->open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,12 @@ bool SoundTownsPC98_v2::init() {
|
||||||
|
|
||||||
if (_vm->gameFlags().platform == Common::kPlatformFMTowns) {
|
if (_vm->gameFlags().platform == Common::kPlatformFMTowns) {
|
||||||
if (_resInfo[_currentResourceSet])
|
if (_resInfo[_currentResourceSet])
|
||||||
if (_resInfo[_currentResourceSet]->cdaTableSize)
|
if (_resInfo[_currentResourceSet]->cdaTableSize) {
|
||||||
_vm->checkCD();
|
if (!_vm->existExtractedCDAudioFiles()
|
||||||
|
&& !_vm->isDataAndCDAudioReadFromSameCD()) {
|
||||||
|
_vm->warnMissingExtractedCDAudio();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize CD for audio
|
// Initialize CD for audio
|
||||||
bool hasRealCD = g_system->getAudioCDManager()->open();
|
bool hasRealCD = g_system->getAudioCDManager()->open();
|
||||||
|
|
|
@ -49,7 +49,10 @@ SoundTowns_LoK::~SoundTowns_LoK() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SoundTowns_LoK::init() {
|
bool SoundTowns_LoK::init() {
|
||||||
_vm->checkCD();
|
if (!_vm->existExtractedCDAudioFiles()
|
||||||
|
&& !_vm->isDataAndCDAudioReadFromSameCD()) {
|
||||||
|
_vm->warnMissingExtractedCDAudio();
|
||||||
|
}
|
||||||
int unused = 0;
|
int unused = 0;
|
||||||
_musicFadeTable = _vm->staticres()->loadRawData(k1TownsMusicFadeTable, unused);
|
_musicFadeTable = _vm->staticres()->loadRawData(k1TownsMusicFadeTable, unused);
|
||||||
_sfxWDTable = _vm->staticres()->loadRawData(k1TownsSFXwdTable, unused);
|
_sfxWDTable = _vm->staticres()->loadRawData(k1TownsSFXwdTable, unused);
|
||||||
|
|
|
@ -296,8 +296,12 @@ Common::Error MadeEngine::run() {
|
||||||
error ("Unknown MADE game");
|
error ("Unknown MADE game");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((getFeatures() & GF_CD) || (getFeatures() & GF_CD_COMPRESSED))
|
if ((getFeatures() & GF_CD) || (getFeatures() & GF_CD_COMPRESSED)) {
|
||||||
checkCD();
|
if (!existExtractedCDAudioFiles()
|
||||||
|
&& !isDataAndCDAudioReadFromSameCD()) {
|
||||||
|
warnMissingExtractedCDAudio();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_autoStopSound = false;
|
_autoStopSound = false;
|
||||||
_eventNum = _eventKey = _eventMouseX = _eventMouseY = 0;
|
_eventNum = _eventKey = _eventMouseX = _eventMouseY = 0;
|
||||||
|
|
|
@ -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.
|
// 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")) {
|
if (_game.features & GF_AUDIOTRACKS && !Common::File::exists("CDDA.SOU")) {
|
||||||
checkCD();
|
if (!existExtractedCDAudioFiles()
|
||||||
|
&& !isDataAndCDAudioReadFromSameCD()) {
|
||||||
|
warnMissingExtractedCDAudio();
|
||||||
|
}
|
||||||
_system->getAudioCDManager()->open();
|
_system->getAudioCDManager()->open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue