mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
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
@ -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);
|
||||
|
@ -277,7 +277,10 @@ Common::Error DrasculaEngine::run() {
|
||||
currentChapter++;
|
||||
}
|
||||
|
||||
checkCD();
|
||||
if (!existExtractedCDAudioFiles()
|
||||
&& !isDataAndCDAudioReadFromSameCD()) {
|
||||
warnMissingExtractedCDAudio();
|
||||
}
|
||||
|
||||
allocMemory();
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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.
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user