Fix #17541: Station style not correctly saved to TD6

This commit is contained in:
Michael Steenbeek 2022-07-28 14:23:53 +02:00 committed by GitHub
parent a75cc10dd5
commit 6852b184b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 1 deletions

View file

@ -17,6 +17,7 @@
- Fix: [#17503] Parks with staff with an ID of 0 have all staff windows focus on that staff.
- Fix: [#17508] Grid doesnt disable after setting patrol area.
- Fix: [#17533] Missing audio when specifying --rct2-data-path.
- Fix: [#17541] Station style not correctly saved to TD6.
- Fix: [#17553] Crash when moving invention list items to empty list.
- Fix: [#17605] Crash when opening parks which have had objects removed externally.

View file

@ -743,6 +743,23 @@ std::string_view GetStationIdentifierFromStyle(uint8_t style)
return {};
}
uint8_t GetStationStyleFromIdentifier(u8string_view identifier)
{
// Not supported in TD6, closest match.
if (identifier == "openrct2.station.noplatformnoentrance")
return RCT12_STATION_STYLE_INVISIBLE;
for (uint8_t i = RCT12_STATION_STYLE_PLAIN; i < std::size(_stationStyles); i++)
{
if (_stationStyles[i] == identifier)
{
return i;
}
}
return RCT12_STATION_STYLE_PLAIN;
}
std::optional<uint8_t> GetStyleFromMusicIdentifier(std::string_view identifier)
{
auto it = std::find(std::begin(_musicStyles), std::end(_musicStyles), identifier);

View file

@ -854,6 +854,7 @@ std::string ConvertFormattedStringToOpenRCT2(std::string_view buffer);
track_type_t RCT12FlatTrackTypeToOpenRCT2(RCT12TrackType origTrackType);
RCT12TrackType OpenRCT2FlatTrackTypeToRCT12(track_type_t origTrackType);
std::string_view GetStationIdentifierFromStyle(uint8_t style);
uint8_t GetStationStyleFromIdentifier(u8string_view identifier);
std::optional<uint8_t> GetStyleFromMusicIdentifier(std::string_view identifier);
void RCT12AddDefaultObjects(ObjectList& objectList);
void AppendRequiredObjects(ObjectList& objectList, ObjectType objectType, const RCT12::EntryList& entryList);

View file

@ -42,6 +42,7 @@
#include "../object/ObjectList.h"
#include "../object/ObjectManager.h"
#include "../object/ObjectRepository.h"
#include "../object/StationObject.h"
#include "../rct1/RCT1.h"
#include "../rct1/Tables.h"
#include "../ride/RideConstruction.h"
@ -79,6 +80,17 @@ static bool _trackDesignPlaceStateEntranceExitPlaced{};
static void TrackDesignPreviewClearMap();
static uint8_t TrackDesignGetEntranceStyle(const Ride& ride)
{
const auto* stationObject = ride.GetStationObject();
if (stationObject == nullptr)
return RCT12_STATION_STYLE_PLAIN;
const auto objectName = stationObject->GetIdentifier();
return GetStationStyleFromIdentifier(objectName);
}
rct_string_id TrackDesign::CreateTrackDesign(TrackDesignState& tds, const Ride& ride)
{
type = ride.type;
@ -121,7 +133,7 @@ rct_string_id TrackDesign::CreateTrackDesign(TrackDesignState& tds, const Ride&
lift_hill_speed = ride.lift_hill_speed;
num_circuits = ride.num_circuits;
entrance_style = ride.entrance_style;
entrance_style = TrackDesignGetEntranceStyle(ride);
max_speed = static_cast<int8_t>(ride.max_speed / 65536);
average_speed = static_cast<int8_t>(ride.average_speed / 65536);
ride_length = ride.GetTotalLength() / 65536;