From 6da5eb9d30c78837831b0f015020e1944bb2a6f5 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sun, 18 Aug 2019 08:24:22 +0100 Subject: [PATCH] Use coordsXYZ for audio_get_params_from_location --- src/openrct2/audio/Audio.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/openrct2/audio/Audio.cpp b/src/openrct2/audio/Audio.cpp index e2098eda55..142bd1ab2a 100644 --- a/src/openrct2/audio/Audio.cpp +++ b/src/openrct2/audio/Audio.cpp @@ -125,7 +125,7 @@ static int32_t SoundVolumeAdjust[RCT2SoundCount] = }; // clang-format on -AudioParams audio_get_params_from_location(SoundId soundId, const LocationXYZ16* location); +static AudioParams audio_get_params_from_location(SoundId soundId, const CoordsXYZ& location); void audio_init() { @@ -185,12 +185,7 @@ void audio_play_sound_at_location(SoundId soundId, const CoordsXYZ& loc) if (gGameSoundsOff) return; - LocationXYZ16 location; - location.x = loc.x; - location.y = loc.y; - location.z = loc.z; - - AudioParams params = audio_get_params_from_location(soundId, &location); + AudioParams params = audio_get_params_from_location(soundId, loc); if (params.in_range) { audio_play_sound(soundId, params.volume, params.pan); @@ -203,7 +198,7 @@ void audio_play_sound_at_location(SoundId soundId, const CoordsXYZ& loc) * @param location The location at which the sound effect is to be played. * @return The audio parameters to be used when playing this sound effect. */ -AudioParams audio_get_params_from_location(SoundId soundId, const LocationXYZ16* location) +static AudioParams audio_get_params_from_location(SoundId soundId, const CoordsXYZ& location) { int32_t volumeDown = 0; AudioParams params; @@ -211,14 +206,14 @@ AudioParams audio_get_params_from_location(SoundId soundId, const LocationXYZ16* params.volume = 0; params.pan = 0; - auto element = map_get_surface_element_at({ location->x, location->y }); - if (element && (element->base_height * 8) - 5 > location->z) + auto element = map_get_surface_element_at(location); + if (element && (element->base_height * 8) - 5 > location.z) { volumeDown = 10; } uint8_t rotation = get_current_rotation(); - LocationXY16 pos2 = coordinate_3d_to_2d(location, rotation); + auto pos2 = translate_3d_to_2d_with_z(rotation, location); rct_viewport* viewport = nullptr; while ((viewport = window_get_previous_viewport(viewport)) != nullptr)