mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix music style check for ‘niceness’
This commit is contained in:
parent
9d29de1444
commit
92f38c566a
|
@ -28,6 +28,7 @@
|
|||
#include "../management/Marketing.h"
|
||||
#include "../management/NewsItem.h"
|
||||
#include "../network/network.h"
|
||||
#include "../object/MusicObject.h"
|
||||
#include "../peep/GuestPathfinding.h"
|
||||
#include "../peep/RideUseSystem.h"
|
||||
#include "../rct2/RCT2.h"
|
||||
|
@ -2936,32 +2937,31 @@ static PeepThoughtType peep_assess_surroundings(int16_t centre_x, int16_t centre
|
|||
num_scenery++;
|
||||
break;
|
||||
case TileElementType::Track:
|
||||
{
|
||||
ride = get_ride(tileElement->AsTrack()->GetRideIndex());
|
||||
if (ride != nullptr)
|
||||
if (ride == nullptr)
|
||||
break;
|
||||
|
||||
bool isPlayingMusic = ride->lifecycle_flags & RIDE_LIFECYCLE_MUSIC && ride->status != RideStatus::Closed
|
||||
&& !(ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED));
|
||||
if (!isPlayingMusic)
|
||||
break;
|
||||
|
||||
const auto* musicObject = ride->GetMusicObject();
|
||||
if (musicObject == nullptr)
|
||||
break;
|
||||
|
||||
if (musicObject->GetNiceFactor() == MusicNiceFactor::Nice)
|
||||
{
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_MUSIC && ride->status != RideStatus::Closed
|
||||
&& !(ride->lifecycle_flags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)))
|
||||
{
|
||||
if (ride->type == RIDE_TYPE_MERRY_GO_ROUND)
|
||||
{
|
||||
nearby_music |= 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ride->music == MUSIC_STYLE_ORGAN)
|
||||
{
|
||||
nearby_music |= 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ride->type == RIDE_TYPE_DODGEMS)
|
||||
{
|
||||
// Dodgems drown out music?
|
||||
nearby_music |= 2;
|
||||
}
|
||||
}
|
||||
nearby_music |= 1;
|
||||
}
|
||||
else if (musicObject->GetNiceFactor() == MusicNiceFactor::NotNice)
|
||||
{
|
||||
nearby_music |= 2;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ void MusicObject::ReadJson(IReadObjectContext* context, json_t& root)
|
|||
_originalStyleId = {};
|
||||
_rideTypes.clear();
|
||||
_tracks.clear();
|
||||
_niceFactor = MusicNiceFactor::Neutral;
|
||||
|
||||
auto& properties = root["properties"];
|
||||
if (properties != nullptr)
|
||||
|
@ -66,6 +67,12 @@ void MusicObject::ReadJson(IReadObjectContext* context, json_t& root)
|
|||
_originalStyleId = originalStyleId.get<uint8_t>();
|
||||
}
|
||||
|
||||
const auto& niceFactor = properties["niceFactor"];
|
||||
if (niceFactor.is_number_integer())
|
||||
{
|
||||
_niceFactor = static_cast<MusicNiceFactor>(std::clamp<int8_t>(niceFactor.get<int8_t>(), -1, 1));
|
||||
}
|
||||
|
||||
const auto& jRideTypes = properties["rideTypes"];
|
||||
if (jRideTypes.is_array())
|
||||
{
|
||||
|
|
|
@ -32,12 +32,20 @@ public:
|
|||
size_t Size;
|
||||
};
|
||||
|
||||
enum class MusicNiceFactor : int8_t
|
||||
{
|
||||
NotNice = -1,
|
||||
Neutral = 0,
|
||||
Nice = 1,
|
||||
};
|
||||
|
||||
class MusicObject final : public Object
|
||||
{
|
||||
private:
|
||||
std::vector<uint8_t> _rideTypes;
|
||||
std::vector<MusicObjectTrack> _tracks;
|
||||
std::optional<uint8_t> _originalStyleId;
|
||||
MusicNiceFactor _niceFactor;
|
||||
|
||||
public:
|
||||
rct_string_id NameStringId{};
|
||||
|
@ -52,6 +60,10 @@ public:
|
|||
bool SupportsRideType(uint8_t rideType);
|
||||
size_t GetTrackCount() const;
|
||||
const MusicObjectTrack* GetTrack(size_t trackIndex) const;
|
||||
constexpr MusicNiceFactor GetNiceFactor() const
|
||||
{
|
||||
return _niceFactor;
|
||||
}
|
||||
|
||||
private:
|
||||
void ParseRideTypes(const json_t& jRideTypes);
|
||||
|
|
|
@ -5529,6 +5529,12 @@ const StationObject* Ride::GetStationObject() const
|
|||
return static_cast<StationObject*>(objManager.GetLoadedObject(ObjectType::Station, entrance_style));
|
||||
}
|
||||
|
||||
const MusicObject* Ride::GetMusicObject() const
|
||||
{
|
||||
auto& objManager = GetContext()->GetObjectManager();
|
||||
return static_cast<MusicObject*>(objManager.GetLoadedObject(ObjectType::Music, music));
|
||||
}
|
||||
|
||||
// Normally, a station has at most one entrance and one exit, which are at the same height
|
||||
// as the station. But in hacked parks, neither can be taken for granted. This code ensures
|
||||
// that the ride->entrances and ride->exits arrays will point to one of them. There is
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "../common.h"
|
||||
#include "../object/MusicObject.h"
|
||||
#include "../rct2/DATLimits.h"
|
||||
#include "../rct2/Limits.h"
|
||||
#include "../world/Map.h"
|
||||
|
@ -382,6 +383,7 @@ public:
|
|||
int32_t GetTotalTime() const;
|
||||
|
||||
const StationObject* GetStationObject() const;
|
||||
const MusicObject* GetMusicObject() const;
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
|
Loading…
Reference in New Issue