mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-22 15:23:01 +01:00
Add support for RCT Classic audio files
This commit is contained in:
@@ -111,6 +111,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool IsUsingClassic() const override
|
||||
{
|
||||
return _usingRctClassic;
|
||||
}
|
||||
|
||||
private:
|
||||
static const char* DirectoryNamesRCT2[];
|
||||
static const u8string DirectoryNamesOpenRCT2[];
|
||||
|
||||
@@ -83,6 +83,7 @@ namespace OpenRCT2
|
||||
virtual u8string GetFilePath(PATHID pathid) const abstract;
|
||||
virtual u8string FindFile(DIRBASE base, DIRID did, u8string_view fileName) const abstract;
|
||||
virtual void SetBasePath(DIRBASE base, u8string_view path) abstract;
|
||||
virtual bool IsUsingClassic() const abstract;
|
||||
};
|
||||
|
||||
[[nodiscard]] std::unique_ptr<IPlatformEnvironment> CreatePlatformEnvironment(DIRBASE_VALUES basePaths);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "../Context.h"
|
||||
#include "../Intro.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../PlatformEnvironment.h"
|
||||
#include "../config/Config.h"
|
||||
#include "../core/File.h"
|
||||
#include "../core/FileStream.h"
|
||||
@@ -98,11 +99,31 @@ namespace OpenRCT2::Audio
|
||||
void LoadAudioObjects()
|
||||
{
|
||||
auto& objManager = GetContext()->GetObjectManager();
|
||||
auto* baseAudio = objManager.LoadObject(AudioObjectIdentifiers::Rct2Base);
|
||||
if (baseAudio != nullptr)
|
||||
|
||||
Object* baseAudio{};
|
||||
|
||||
// We have a different audio object for RCT Classic
|
||||
auto env = GetContext()->GetPlatformEnvironment();
|
||||
if (env->IsUsingClassic())
|
||||
{
|
||||
_soundsAudioObjectEntryIndex = objManager.GetLoadedObjectEntryIndex(baseAudio);
|
||||
baseAudio = objManager.LoadObject(AudioObjectIdentifiers::Rct2cBase);
|
||||
if (baseAudio != nullptr)
|
||||
{
|
||||
baseAudio->SetIdentifier(AudioObjectIdentifiers::Rct2Base);
|
||||
_soundsAudioObjectEntryIndex = objManager.GetLoadedObjectEntryIndex(baseAudio);
|
||||
}
|
||||
}
|
||||
|
||||
if (baseAudio == nullptr)
|
||||
{
|
||||
// Fallback to vanilla RCT2 audio object
|
||||
baseAudio = objManager.LoadObject(AudioObjectIdentifiers::Rct2Base);
|
||||
if (baseAudio != nullptr)
|
||||
{
|
||||
_soundsAudioObjectEntryIndex = objManager.GetLoadedObjectEntryIndex(baseAudio);
|
||||
}
|
||||
}
|
||||
|
||||
objManager.LoadObject(AudioObjectIdentifiers::Rct2Circus);
|
||||
}
|
||||
|
||||
|
||||
@@ -137,6 +137,7 @@ namespace OpenRCT2::Audio
|
||||
{
|
||||
constexpr std::string_view Rct1Title = "rct1.audio.title";
|
||||
constexpr std::string_view Rct2Base = "rct2.audio.base";
|
||||
constexpr std::string_view Rct2cBase = "rct2.audio.base.rctc";
|
||||
constexpr std::string_view Rct2Title = "rct2.audio.title";
|
||||
constexpr std::string_view Rct2Circus = "rct2.audio.circus";
|
||||
} // namespace AudioObjectIdentifiers
|
||||
|
||||
@@ -502,7 +502,10 @@ namespace ObjectFactory
|
||||
std::unique_ptr<Object> CreateObjectFromJson(
|
||||
IObjectRepository& objectRepository, json_t& jRoot, const IFileDataRetriever* fileRetriever, bool loadImageTable)
|
||||
{
|
||||
Guard::Assert(jRoot.is_object(), "ObjectFactory::CreateObjectFromJson expects parameter jRoot to be object");
|
||||
if (!jRoot.is_object())
|
||||
{
|
||||
throw std::runtime_error("Object JSON root was not an object");
|
||||
}
|
||||
|
||||
log_verbose("CreateObjectFromJson(...)");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user