mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Move gLastEntranceStyle to GameState_t
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "Construction.h"
|
#include "Construction.h"
|
||||||
|
|
||||||
|
#include <openrct2/GameState.h>
|
||||||
#include <openrct2/actions/RideCreateAction.h>
|
#include <openrct2/actions/RideCreateAction.h>
|
||||||
#include <openrct2/ride/Ride.h>
|
#include <openrct2/ride/Ride.h>
|
||||||
#include <openrct2/ride/RideConstruction.h>
|
#include <openrct2/ride/RideConstruction.h>
|
||||||
@@ -28,7 +29,8 @@ void RideConstructNew(RideSelection listItem)
|
|||||||
int32_t colour1 = RideGetRandomColourPresetIndex(listItem.Type);
|
int32_t colour1 = RideGetRandomColourPresetIndex(listItem.Type);
|
||||||
int32_t colour2 = RideGetUnusedPresetVehicleColour(rideEntryIndex);
|
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) {
|
gameAction.SetCallback([](const GameAction* ga, const GameActions::Result* result) {
|
||||||
if (result->Error != GameActions::Status::Ok)
|
if (result->Error != GameActions::Status::Ok)
|
||||||
|
|||||||
@@ -4322,7 +4322,7 @@ private:
|
|||||||
rideSetAppearanceAction.SetCallback([objIndex](const GameAction*, const GameActions::Result* res) {
|
rideSetAppearanceAction.SetCallback([objIndex](const GameAction*, const GameActions::Result* res) {
|
||||||
if (res->Error != GameActions::Status::Ok)
|
if (res->Error != GameActions::Status::Ok)
|
||||||
return;
|
return;
|
||||||
gLastEntranceStyle = objIndex;
|
GetGameState().LastEntranceStyle = objIndex;
|
||||||
});
|
});
|
||||||
GameActions::Execute(&rideSetAppearanceAction);
|
GameActions::Execute(&rideSetAppearanceAction);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -487,10 +487,10 @@ void FinishObjectSelection()
|
|||||||
SetEveryRideEntryInvented();
|
SetEveryRideEntryInvented();
|
||||||
|
|
||||||
auto& objManager = OpenRCT2::GetContext()->GetObjectManager();
|
auto& objManager = OpenRCT2::GetContext()->GetObjectManager();
|
||||||
gLastEntranceStyle = objManager.GetLoadedObjectEntryIndex("rct2.station.plain");
|
gameState.LastEntranceStyle = objManager.GetLoadedObjectEntryIndex("rct2.station.plain");
|
||||||
if (gLastEntranceStyle == OBJECT_ENTRY_INDEX_NULL)
|
if (gameState.LastEntranceStyle == OBJECT_ENTRY_INDEX_NULL)
|
||||||
{
|
{
|
||||||
gLastEntranceStyle = 0;
|
gameState.LastEntranceStyle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
gameState.EditorStep = EditorStep::RollercoasterDesigner;
|
gameState.EditorStep = EditorStep::RollercoasterDesigner;
|
||||||
|
|||||||
@@ -125,6 +125,8 @@ namespace OpenRCT2
|
|||||||
uint8_t SavedViewRotation;
|
uint8_t SavedViewRotation;
|
||||||
ZoomLevel SavedViewZoom;
|
ZoomLevel SavedViewZoom;
|
||||||
|
|
||||||
|
ObjectEntryIndex LastEntranceStyle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Probability out of 65535, of gaining a new guest per game tick.
|
* Probability out of 65535, of gaining a new guest per game tick.
|
||||||
* new guests per second = 40 * (probability / 65535)
|
* new guests per second = 40 * (probability / 65535)
|
||||||
|
|||||||
@@ -64,20 +64,21 @@ GameActions::Result TrackDesignAction::Query() const
|
|||||||
GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_OFF_EDGE_OF_MAP);
|
GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_OFF_EDGE_OF_MAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto& gameState = GetGameState();
|
||||||
auto& objManager = GetContext()->GetObjectManager();
|
auto& objManager = GetContext()->GetObjectManager();
|
||||||
auto entryIndex = objManager.GetLoadedObjectEntryIndex(_td.vehicle_object);
|
auto entryIndex = objManager.GetLoadedObjectEntryIndex(_td.vehicle_object);
|
||||||
if (entryIndex == OBJECT_ENTRY_INDEX_NULL)
|
if (entryIndex == OBJECT_ENTRY_INDEX_NULL)
|
||||||
{
|
{
|
||||||
// Force a fallback if the entry is not invented yet a td6 of it is selected,
|
// 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
|
// 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;
|
entryIndex = OBJECT_ENTRY_INDEX_NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Colours do not matter as will be overwritten
|
// 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());
|
rideCreateAction.SetFlags(GetFlags());
|
||||||
auto r = GameActions::ExecuteNested(&rideCreateAction);
|
auto r = GameActions::ExecuteNested(&rideCreateAction);
|
||||||
if (r.Error != GameActions::Status::Ok)
|
if (r.Error != GameActions::Status::Ok)
|
||||||
@@ -136,20 +137,21 @@ GameActions::Result TrackDesignAction::Execute() const
|
|||||||
res.Position.z = _loc.z;
|
res.Position.z = _loc.z;
|
||||||
res.Expenditure = ExpenditureType::RideConstruction;
|
res.Expenditure = ExpenditureType::RideConstruction;
|
||||||
|
|
||||||
|
auto& gameState = GetGameState();
|
||||||
auto& objManager = GetContext()->GetObjectManager();
|
auto& objManager = GetContext()->GetObjectManager();
|
||||||
auto entryIndex = objManager.GetLoadedObjectEntryIndex(_td.vehicle_object);
|
auto entryIndex = objManager.GetLoadedObjectEntryIndex(_td.vehicle_object);
|
||||||
if (entryIndex != OBJECT_ENTRY_INDEX_NULL)
|
if (entryIndex != OBJECT_ENTRY_INDEX_NULL)
|
||||||
{
|
{
|
||||||
// Force a fallback if the entry is not invented yet a track design using it is selected.
|
// 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 haven’t.
|
// This can happen on rides with multiple vehicles where some have been invented and some haven’t.
|
||||||
if (!RideEntryIsInvented(entryIndex) && !GetGameState().Cheats.IgnoreResearchStatus)
|
if (!RideEntryIsInvented(entryIndex) && !gameState.Cheats.IgnoreResearchStatus)
|
||||||
{
|
{
|
||||||
entryIndex = OBJECT_ENTRY_INDEX_NULL;
|
entryIndex = OBJECT_ENTRY_INDEX_NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Colours do not matter as will be overwritten
|
// 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());
|
rideCreateAction.SetFlags(GetFlags());
|
||||||
auto r = GameActions::ExecuteNested(&rideCreateAction);
|
auto r = GameActions::ExecuteNested(&rideCreateAction);
|
||||||
if (r.Error != GameActions::Status::Ok)
|
if (r.Error != GameActions::Status::Ok)
|
||||||
@@ -247,7 +249,7 @@ GameActions::Result TrackDesignAction::Execute() const
|
|||||||
ride->entrance_style = objManager.GetLoadedObjectEntryIndex(_td.StationObjectIdentifier);
|
ride->entrance_style = objManager.GetLoadedObjectEntryIndex(_td.StationObjectIdentifier);
|
||||||
if (ride->entrance_style == OBJECT_ENTRY_INDEX_NULL)
|
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++)
|
for (int32_t i = 0; i < Limits::NumColourSchemes; i++)
|
||||||
|
|||||||
@@ -617,7 +617,7 @@ namespace OpenRCT2
|
|||||||
cs.Write(static_cast<int8_t>(gameState.SavedViewZoom));
|
cs.Write(static_cast<int8_t>(gameState.SavedViewZoom));
|
||||||
}
|
}
|
||||||
cs.ReadWrite(gameState.SavedViewRotation);
|
cs.ReadWrite(gameState.SavedViewRotation);
|
||||||
cs.ReadWrite(gLastEntranceStyle);
|
cs.ReadWrite(gameState.LastEntranceStyle);
|
||||||
cs.ReadWrite(gameState.EditorStep);
|
cs.ReadWrite(gameState.EditorStep);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -407,7 +407,7 @@ namespace RCT2
|
|||||||
| (static_cast<uint64_t>(_s6.SamePriceThroughoutExtended) << 32);
|
| (static_cast<uint64_t>(_s6.SamePriceThroughoutExtended) << 32);
|
||||||
gameState.SuggestedGuestMaximum = _s6.SuggestedMaxGuests;
|
gameState.SuggestedGuestMaximum = _s6.SuggestedMaxGuests;
|
||||||
gameState.ScenarioParkRatingWarningDays = _s6.ParkRatingWarningDays;
|
gameState.ScenarioParkRatingWarningDays = _s6.ParkRatingWarningDays;
|
||||||
gLastEntranceStyle = _s6.LastEntranceStyle;
|
gameState.LastEntranceStyle = _s6.LastEntranceStyle;
|
||||||
// rct1_water_colour
|
// rct1_water_colour
|
||||||
// Pad01358842
|
// Pad01358842
|
||||||
ImportResearchList(gameState);
|
ImportResearchList(gameState);
|
||||||
|
|||||||
@@ -1014,8 +1014,6 @@ std::string_view GetRideEntryName(ObjectEntryIndex index);
|
|||||||
|
|
||||||
extern const StringId ColourSchemeNames[4];
|
extern const StringId ColourSchemeNames[4];
|
||||||
|
|
||||||
extern ObjectEntryIndex gLastEntranceStyle;
|
|
||||||
|
|
||||||
int32_t RideGetCount();
|
int32_t RideGetCount();
|
||||||
void RideInitAll();
|
void RideInitAll();
|
||||||
void ResetAllRideBuildDates();
|
void ResetAllRideBuildDates();
|
||||||
|
|||||||
@@ -79,8 +79,6 @@ uint8_t _currentSeatRotationAngle;
|
|||||||
|
|
||||||
CoordsXYZD _unkF440C5;
|
CoordsXYZD _unkF440C5;
|
||||||
|
|
||||||
ObjectEntryIndex gLastEntranceStyle;
|
|
||||||
|
|
||||||
uint8_t gRideEntranceExitPlaceType;
|
uint8_t gRideEntranceExitPlaceType;
|
||||||
RideId gRideEntranceExitPlaceRideIndex;
|
RideId gRideEntranceExitPlaceRideIndex;
|
||||||
StationIndex gRideEntranceExitPlaceStationIndex;
|
StationIndex gRideEntranceExitPlaceStationIndex;
|
||||||
|
|||||||
@@ -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)
|
static money64 TrackDesignCreateRide(int32_t type, int32_t subType, int32_t flags, RideId* outRideIndex)
|
||||||
{
|
{
|
||||||
// Don't set colours as will be set correctly later.
|
// 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);
|
gameAction.SetFlags(flags);
|
||||||
|
|
||||||
auto res = GameActions::ExecuteNested(&gameAction);
|
auto res = GameActions::ExecuteNested(&gameAction);
|
||||||
@@ -1900,6 +1900,7 @@ static bool TrackDesignPlacePreview(TrackDesignState& tds, TrackDesign* td6, mon
|
|||||||
*outRide = nullptr;
|
*outRide = nullptr;
|
||||||
*flags = 0;
|
*flags = 0;
|
||||||
|
|
||||||
|
auto& gameState = GetGameState();
|
||||||
auto& objManager = GetContext()->GetObjectManager();
|
auto& objManager = GetContext()->GetObjectManager();
|
||||||
auto entry_index = objManager.GetLoadedObjectEntryIndex(td6->vehicle_object);
|
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);
|
ride->entrance_style = objManager.GetLoadedObjectEntryIndex(td6->StationObjectIdentifier);
|
||||||
if (ride->entrance_style == OBJECT_ENTRY_INDEX_NULL)
|
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++)
|
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;
|
_trackDesignDrawingPreview = true;
|
||||||
uint8_t backup_rotation = _currentTrackPieceDirection;
|
uint8_t backup_rotation = _currentTrackPieceDirection;
|
||||||
uint32_t backup_park_flags = gameState.ParkFlags;
|
uint32_t backup_park_flags = gameState.ParkFlags;
|
||||||
|
|||||||
@@ -156,11 +156,11 @@ void ScenarioReset(GameState_t& gameState)
|
|||||||
Staff::ResetStats();
|
Staff::ResetStats();
|
||||||
|
|
||||||
auto& objManager = GetContext()->GetObjectManager();
|
auto& objManager = GetContext()->GetObjectManager();
|
||||||
gLastEntranceStyle = objManager.GetLoadedObjectEntryIndex("rct2.station.plain");
|
gameState.LastEntranceStyle = objManager.GetLoadedObjectEntryIndex("rct2.station.plain");
|
||||||
if (gLastEntranceStyle == OBJECT_ENTRY_INDEX_NULL)
|
if (gameState.LastEntranceStyle == OBJECT_ENTRY_INDEX_NULL)
|
||||||
{
|
{
|
||||||
// Fall back to first entrance object
|
// Fall back to first entrance object
|
||||||
gLastEntranceStyle = 0;
|
gameState.LastEntranceStyle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
gMarketingCampaigns.clear();
|
gMarketingCampaigns.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user