1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-22 23:33:04 +01:00

Move gLastEntranceStyle to GameState_t

This commit is contained in:
Harry Hopkinson
2024-03-09 10:27:05 +00:00
committed by GitHub
parent d0592e0887
commit 048276b67a
11 changed files with 24 additions and 22 deletions

View File

@@ -9,6 +9,7 @@
#include "Construction.h"
#include <openrct2/GameState.h>
#include <openrct2/actions/RideCreateAction.h>
#include <openrct2/ride/Ride.h>
#include <openrct2/ride/RideConstruction.h>
@@ -28,7 +29,8 @@ void RideConstructNew(RideSelection listItem)
int32_t colour1 = RideGetRandomColourPresetIndex(listItem.Type);
int32_t colour2 = RideGetUnusedPresetVehicleColour(rideEntryIndex);
auto gameAction = RideCreateAction(listItem.Type, listItem.EntryIndex, colour1, colour2, gLastEntranceStyle);
auto gameAction = RideCreateAction(
listItem.Type, listItem.EntryIndex, colour1, colour2, OpenRCT2::GetGameState().LastEntranceStyle);
gameAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) {
if (result->Error != GameActions::Status::Ok)

View File

@@ -4322,7 +4322,7 @@ private:
rideSetAppearanceAction.SetCallback([objIndex](const GameAction*, const GameActions::Result* res) {
if (res->Error != GameActions::Status::Ok)
return;
gLastEntranceStyle = objIndex;
GetGameState().LastEntranceStyle = objIndex;
});
GameActions::Execute(&rideSetAppearanceAction);
break;

View File

@@ -487,10 +487,10 @@ void FinishObjectSelection()
SetEveryRideEntryInvented();
auto& objManager = OpenRCT2::GetContext()->GetObjectManager();
gLastEntranceStyle = objManager.GetLoadedObjectEntryIndex("rct2.station.plain");
if (gLastEntranceStyle == OBJECT_ENTRY_INDEX_NULL)
gameState.LastEntranceStyle = objManager.GetLoadedObjectEntryIndex("rct2.station.plain");
if (gameState.LastEntranceStyle == OBJECT_ENTRY_INDEX_NULL)
{
gLastEntranceStyle = 0;
gameState.LastEntranceStyle = 0;
}
gameState.EditorStep = EditorStep::RollercoasterDesigner;

View File

@@ -125,6 +125,8 @@ namespace OpenRCT2
uint8_t SavedViewRotation;
ZoomLevel SavedViewZoom;
ObjectEntryIndex LastEntranceStyle;
/**
* Probability out of 65535, of gaining a new guest per game tick.
* new guests per second = 40 * (probability / 65535)

View File

@@ -64,20 +64,21 @@ GameActions::Result TrackDesignAction::Query() const
GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_OFF_EDGE_OF_MAP);
}
auto& gameState = GetGameState();
auto& objManager = GetContext()->GetObjectManager();
auto entryIndex = objManager.GetLoadedObjectEntryIndex(_td.vehicle_object);
if (entryIndex == OBJECT_ENTRY_INDEX_NULL)
{
// Force a fallback if the entry is not invented yet a td6 of it is selected,
// which can happen in select-by-track-type mode
if (!RideEntryIsInvented(entryIndex) && !GetGameState().Cheats.IgnoreResearchStatus)
if (!RideEntryIsInvented(entryIndex) && !gameState.Cheats.IgnoreResearchStatus)
{
entryIndex = OBJECT_ENTRY_INDEX_NULL;
}
}
// Colours do not matter as will be overwritten
auto rideCreateAction = RideCreateAction(_td.type, entryIndex, 0, 0, gLastEntranceStyle);
auto rideCreateAction = RideCreateAction(_td.type, entryIndex, 0, 0, gameState.LastEntranceStyle);
rideCreateAction.SetFlags(GetFlags());
auto r = GameActions::ExecuteNested(&rideCreateAction);
if (r.Error != GameActions::Status::Ok)
@@ -136,20 +137,21 @@ GameActions::Result TrackDesignAction::Execute() const
res.Position.z = _loc.z;
res.Expenditure = ExpenditureType::RideConstruction;
auto& gameState = GetGameState();
auto& objManager = GetContext()->GetObjectManager();
auto entryIndex = objManager.GetLoadedObjectEntryIndex(_td.vehicle_object);
if (entryIndex != OBJECT_ENTRY_INDEX_NULL)
{
// Force a fallback if the entry is not invented yet a track design using it is selected.
// This can happen on rides with multiple vehicles where some have been invented and some havent.
if (!RideEntryIsInvented(entryIndex) && !GetGameState().Cheats.IgnoreResearchStatus)
if (!RideEntryIsInvented(entryIndex) && !gameState.Cheats.IgnoreResearchStatus)
{
entryIndex = OBJECT_ENTRY_INDEX_NULL;
}
}
// Colours do not matter as will be overwritten
auto rideCreateAction = RideCreateAction(_td.type, entryIndex, 0, 0, gLastEntranceStyle);
auto rideCreateAction = RideCreateAction(_td.type, entryIndex, 0, 0, gameState.LastEntranceStyle);
rideCreateAction.SetFlags(GetFlags());
auto r = GameActions::ExecuteNested(&rideCreateAction);
if (r.Error != GameActions::Status::Ok)
@@ -247,7 +249,7 @@ GameActions::Result TrackDesignAction::Execute() const
ride->entrance_style = objManager.GetLoadedObjectEntryIndex(_td.StationObjectIdentifier);
if (ride->entrance_style == OBJECT_ENTRY_INDEX_NULL)
{
ride->entrance_style = gLastEntranceStyle;
ride->entrance_style = gameState.LastEntranceStyle;
}
for (int32_t i = 0; i < Limits::NumColourSchemes; i++)

View File

@@ -617,7 +617,7 @@ namespace OpenRCT2
cs.Write(static_cast<int8_t>(gameState.SavedViewZoom));
}
cs.ReadWrite(gameState.SavedViewRotation);
cs.ReadWrite(gLastEntranceStyle);
cs.ReadWrite(gameState.LastEntranceStyle);
cs.ReadWrite(gameState.EditorStep);
});
}

View File

@@ -407,7 +407,7 @@ namespace RCT2
| (static_cast<uint64_t>(_s6.SamePriceThroughoutExtended) << 32);
gameState.SuggestedGuestMaximum = _s6.SuggestedMaxGuests;
gameState.ScenarioParkRatingWarningDays = _s6.ParkRatingWarningDays;
gLastEntranceStyle = _s6.LastEntranceStyle;
gameState.LastEntranceStyle = _s6.LastEntranceStyle;
// rct1_water_colour
// Pad01358842
ImportResearchList(gameState);

View File

@@ -1014,8 +1014,6 @@ std::string_view GetRideEntryName(ObjectEntryIndex index);
extern const StringId ColourSchemeNames[4];
extern ObjectEntryIndex gLastEntranceStyle;
int32_t RideGetCount();
void RideInitAll();
void ResetAllRideBuildDates();

View File

@@ -79,8 +79,6 @@ uint8_t _currentSeatRotationAngle;
CoordsXYZD _unkF440C5;
ObjectEntryIndex gLastEntranceStyle;
uint8_t gRideEntranceExitPlaceType;
RideId gRideEntranceExitPlaceRideIndex;
StationIndex gRideEntranceExitPlaceStationIndex;

View File

@@ -1873,7 +1873,7 @@ int32_t TrackDesignGetZPlacement(TrackDesign* td6, Ride& ride, const CoordsXYZD&
static money64 TrackDesignCreateRide(int32_t type, int32_t subType, int32_t flags, RideId* outRideIndex)
{
// Don't set colours as will be set correctly later.
auto gameAction = RideCreateAction(type, subType, 0, 0, gLastEntranceStyle);
auto gameAction = RideCreateAction(type, subType, 0, 0, GetGameState().LastEntranceStyle);
gameAction.SetFlags(flags);
auto res = GameActions::ExecuteNested(&gameAction);
@@ -1900,6 +1900,7 @@ static bool TrackDesignPlacePreview(TrackDesignState& tds, TrackDesign* td6, mon
*outRide = nullptr;
*flags = 0;
auto& gameState = GetGameState();
auto& objManager = GetContext()->GetObjectManager();
auto entry_index = objManager.GetLoadedObjectEntryIndex(td6->vehicle_object);
@@ -1919,7 +1920,7 @@ static bool TrackDesignPlacePreview(TrackDesignState& tds, TrackDesign* td6, mon
ride->entrance_style = objManager.GetLoadedObjectEntryIndex(td6->StationObjectIdentifier);
if (ride->entrance_style == OBJECT_ENTRY_INDEX_NULL)
{
ride->entrance_style = gLastEntranceStyle;
ride->entrance_style = gameState.LastEntranceStyle;
}
for (int32_t i = 0; i < OpenRCT2::Limits::NumColourSchemes; i++)
@@ -1939,7 +1940,6 @@ static bool TrackDesignPlacePreview(TrackDesignState& tds, TrackDesign* td6, mon
}
}
auto& gameState = GetGameState();
_trackDesignDrawingPreview = true;
uint8_t backup_rotation = _currentTrackPieceDirection;
uint32_t backup_park_flags = gameState.ParkFlags;

View File

@@ -156,11 +156,11 @@ void ScenarioReset(GameState_t& gameState)
Staff::ResetStats();
auto& objManager = GetContext()->GetObjectManager();
gLastEntranceStyle = objManager.GetLoadedObjectEntryIndex("rct2.station.plain");
if (gLastEntranceStyle == OBJECT_ENTRY_INDEX_NULL)
gameState.LastEntranceStyle = objManager.GetLoadedObjectEntryIndex("rct2.station.plain");
if (gameState.LastEntranceStyle == OBJECT_ENTRY_INDEX_NULL)
{
// Fall back to first entrance object
gLastEntranceStyle = 0;
gameState.LastEntranceStyle = 0;
}
gMarketingCampaigns.clear();