Fix: useless warning with -snull and no BaseSounds available (#8361)

If I explicitly tell the system I do not want sound, I still get
presented a nice message I do not have any BaseSounds available
on my system, and that I should download one to enjoy sound. Well,
let me tell you, with "-snull" that is really really not going to
help. So please, be quiet, and let me enjoy the game without
"boooooo" and "DING DING DING".

Thank you.
This commit is contained in:
Patric Stout 2020-12-08 10:24:59 +01:00 committed by GitHub
parent 6e689e2038
commit 2864d019f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -1111,7 +1111,7 @@ void SwitchToMode(SwitchMode new_mode)
case SM_MENU: // Switch to game intro menu
LoadIntroGame();
if (BaseSounds::ini_set.empty() && BaseSounds::GetUsedSet()->fallback) {
if (BaseSounds::ini_set.empty() && BaseSounds::GetUsedSet()->fallback && SoundDriver::GetInstance()->HasOutput()) {
ShowErrorMessage(STR_WARNING_FALLBACK_SOUNDSET, INVALID_STRING_ID, WL_CRITICAL);
BaseSounds::ini_set = BaseSounds::GetUsedSet()->name;
}

View File

@ -19,6 +19,7 @@ public:
void Stop() override { }
const char *GetName() const override { return "null"; }
bool HasOutput() const override { return false; }
};
/** Factory for the null sound driver. */

View File

@ -18,6 +18,17 @@ public:
/** Called once every tick */
virtual void MainLoop() {}
/**
* Whether the driver has an output from which the user can hear sound.
* Or in other words, whether we should warn the user if no soundset is
* loaded and that loading one would fix the sound problems.
* @return True for all drivers except null.
*/
virtual bool HasOutput() const
{
return true;
}
/**
* Get the currently active instance of the sound driver.
*/