Fix sound effects not working with RCTC base, fix audio object conflict

Due to this overwriting of object IDs, loading the sound effects would not work on RCTC. This overwriting also caused object conflicts which weren’t always won by the RCTC one. This fixes both problems by using non-clashing names, and only renaming one to `rct2.audio.base`, the name expected by the asset packs.
This commit is contained in:
Michael Steenbeek 2024-04-01 00:28:17 +02:00 committed by GitHub
parent 06081eb23d
commit 9062049be1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 28 additions and 29 deletions

View File

@ -64,9 +64,9 @@ set(TITLE_SEQUENCE_VERSION "0.4.6")
set(TITLE_SEQUENCE_URL "https://github.com/OpenRCT2/title-sequences/releases/download/v${TITLE_SEQUENCE_VERSION}/title-sequences.zip")
set(TITLE_SEQUENCE_SHA1 "80fefc6ebbabc42a6f4703412daa5c62f661420d")
set(OBJECTS_VERSION "1.4.2")
set(OBJECTS_VERSION "1.4.3")
set(OBJECTS_URL "https://github.com/OpenRCT2/objects/releases/download/v${OBJECTS_VERSION}/objects.zip")
set(OBJECTS_SHA1 "2adc4cb66a6446533d67097bdf44cd9c5882fea3")
set(OBJECTS_SHA1 "ac78210ef46465c0f51bbffd6fe21845092af48e")
set(OPENSFX_VERSION "1.0.5")
set(OPENSFX_URL "https://github.com/OpenRCT2/OpenSoundEffects/releases/download/v${OPENSFX_VERSION}/opensound.zip")

View File

@ -27,6 +27,8 @@
- Fix: [#21635] Tile inspector hotkey can set wall slope for non-slopeable objects.
- Fix: [#21641] Crash when creating track iterator from an invalid tile element.
- Fix: [#21652] Dialog window to confirm overwriting files does not apply the theme colours correctly.
- Fix: [#21654] No sound effects when using RCT Classic as an asset base.
- Fix: [#21654] Extraneous reports of an object conflict between `rct2.audio.base` and `rct2.audio.base.rctc`.
- Fix: [#21668] Crash when on null ride in Guest::UpdateRideLeaveExit.
- Fix: [#21691] Crash when validating rides which can't contain banked track.
- Fix: [objects#290] “Haunted Mansion” cars have a non-functional third remap colour.

View File

@ -45,8 +45,8 @@
<LibsSha1 Condition="'$(Platform)'=='ARM64'">bd338aa3da9a357fb996dcaa6cea02c4f906718c</LibsSha1>
<TitleSequencesUrl>https://github.com/OpenRCT2/title-sequences/releases/download/v0.4.6/title-sequences.zip</TitleSequencesUrl>
<TitleSequencesSha1>80fefc6ebbabc42a6f4703412daa5c62f661420d</TitleSequencesSha1>
<ObjectsUrl>https://github.com/OpenRCT2/objects/releases/download/v1.4.2/objects.zip</ObjectsUrl>
<ObjectsSha1>2adc4cb66a6446533d67097bdf44cd9c5882fea3</ObjectsSha1>
<ObjectsUrl>https://github.com/OpenRCT2/objects/releases/download/v1.4.3/objects.zip</ObjectsUrl>
<ObjectsSha1>ac78210ef46465c0f51bbffd6fe21845092af48e</ObjectsSha1>
<OpenSFXUrl>https://github.com/OpenRCT2/OpenSoundEffects/releases/download/v1.0.5/opensound.zip</OpenSFXUrl>
<OpenSFXSha1>b1b1f1b241d2cbff63a1889c4dc5a09bdf769bfb</OpenSFXSha1>
<OpenMSXUrl>https://github.com/OpenRCT2/OpenMusic/releases/download/v1.5/openmusic.zip</OpenMSXUrl>

View File

@ -101,27 +101,10 @@ namespace OpenRCT2::Audio
{
auto& objManager = GetContext()->GetObjectManager();
Object* baseAudio{};
// We have a different audio object for RCT Classic
auto env = GetContext()->GetPlatformEnvironment();
if (env->IsUsingClassic())
Object* baseAudio = objManager.LoadObject(AudioObjectIdentifiers::RCT2);
if (baseAudio != nullptr)
{
baseAudio = objManager.LoadObject(AudioObjectIdentifiers::RCTCBase);
if (baseAudio != nullptr)
{
_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);
}
_soundsAudioObjectEntryIndex = objManager.GetLoadedObjectEntryIndex(baseAudio);
}
objManager.LoadObject(AudioObjectIdentifiers::OpenRCT2Additional);

View File

@ -140,7 +140,9 @@ namespace OpenRCT2::Audio
namespace AudioObjectIdentifiers
{
constexpr std::string_view RCT1Title = "rct1.audio.title";
constexpr std::string_view RCT2Base = "rct2.audio.base";
// virtual name, used by either RCT2Base or RCTCBase, depending on which one is loaded.
constexpr std::string_view RCT2 = "rct2.audio.base";
constexpr std::string_view RCT2Base = "rct2.audio.base.rct2";
constexpr std::string_view RCTCBase = "rct2.audio.base.rctc";
constexpr std::string_view RCT2Title = "rct2.audio.title";
constexpr std::string_view OpenRCT2Title = "openrct2.audio.title";

View File

@ -46,7 +46,7 @@ using namespace OpenRCT2;
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "2"
#define NETWORK_STREAM_VERSION "3"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION

View File

@ -9,7 +9,9 @@
#include "ObjectFactory.h"
#include "../Context.h"
#include "../OpenRCT2.h"
#include "../PlatformEnvironment.h"
#include "../audio/audio.h"
#include "../core/Console.hpp"
#include "../core/File.h"
@ -500,6 +502,12 @@ namespace ObjectFactory
}
}
static bool isUsingClassic()
{
auto env = OpenRCT2::GetContext()->GetPlatformEnvironment();
return env->IsUsingClassic();
}
std::unique_ptr<Object> CreateObjectFromJson(
IObjectRepository& objectRepository, json_t& jRoot, const IFileDataRetriever* fileRetriever, bool loadImageTable)
{
@ -517,9 +525,13 @@ namespace ObjectFactory
{
auto id = Json::GetString(jRoot["id"]);
// HACK Disguise RCT Classic audio as RCT2 audio so asset packs override correctly
if (id == OpenRCT2::Audio::AudioObjectIdentifiers::RCTCBase)
id = OpenRCT2::Audio::AudioObjectIdentifiers::RCT2Base;
// Base audio files are renamed to a common, virtual name so asset packs can override it correctly.
const bool isRCT2BaseAudio = id == OpenRCT2::Audio::AudioObjectIdentifiers::RCT2Base && !isUsingClassic();
const bool isRCTCBaseAudio = id == OpenRCT2::Audio::AudioObjectIdentifiers::RCTCBase && isUsingClassic();
if (isRCT2BaseAudio || isRCTCBaseAudio)
{
id = OpenRCT2::Audio::AudioObjectIdentifiers::RCT2;
}
auto version = VersionTuple(Json::GetString(jRoot["version"]));
ObjectEntryDescriptor descriptor;