mirror of https://github.com/OpenRCT2/OpenRCT2.git
Allow game to run with GUI while without audio.
This commit is contained in:
parent
fbeff35aec
commit
3127a4dc64
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "Ui.h"
|
||||
|
||||
#include "SDLException.h"
|
||||
#include "UiContext.h"
|
||||
#include "audio/AudioContext.h"
|
||||
#include "drawing/BitmapReader.h"
|
||||
|
@ -55,7 +56,16 @@ int main(int argc, const char** argv)
|
|||
{
|
||||
// Run OpenRCT2 with a UI context
|
||||
auto env = ToShared(CreatePlatformEnvironment());
|
||||
auto audioContext = ToShared(CreateAudioContext());
|
||||
std::shared_ptr<IAudioContext> audioContext;
|
||||
try
|
||||
{
|
||||
audioContext = ToShared(CreateAudioContext());
|
||||
}
|
||||
catch (const SDLException&)
|
||||
{
|
||||
log_warning("Failed to create audio context. Using dummy audio context.");
|
||||
audioContext = ToShared(CreateDummyAudioContext());
|
||||
}
|
||||
auto uiContext = ToShared(CreateUiContext(env));
|
||||
context = CreateContext(env, audioContext, uiContext);
|
||||
}
|
||||
|
|
|
@ -1447,7 +1447,7 @@ private:
|
|||
rct_string_id audioDeviceStringId = STR_OPTIONS_SOUND_VALUE_DEFAULT;
|
||||
const char* audioDeviceName = nullptr;
|
||||
const int32_t currentDeviceIndex = OpenRCT2::Audio::GetCurrentDeviceIndex();
|
||||
if (currentDeviceIndex == -1)
|
||||
if (currentDeviceIndex == -1 || OpenRCT2::Audio::GetDeviceCount() == 0)
|
||||
{
|
||||
audioDeviceStringId = STR_SOUND_NONE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue