mirror of https://github.com/OpenRCT2/OpenRCT2.git
#21193: Move ParkEntrances to GameState_t
This commit is contained in:
parent
ce45cb3360
commit
74d61369be
|
@ -616,10 +616,12 @@ private:
|
|||
if (page != WINDOW_PARK_PAGE_ENTRANCE)
|
||||
return;
|
||||
|
||||
const auto& gameState = GetGameState();
|
||||
|
||||
std::optional<Focus> newFocus = std::nullopt;
|
||||
if (!gParkEntrances.empty())
|
||||
if (!gameState.ParkEntrances.empty())
|
||||
{
|
||||
const auto& entrance = gParkEntrances[0];
|
||||
const auto& entrance = gameState.ParkEntrances[0];
|
||||
newFocus = Focus(CoordsXYZ{ entrance.x + 16, entrance.y + 16, entrance.z + 32 });
|
||||
}
|
||||
|
||||
|
|
|
@ -505,12 +505,13 @@ namespace Editor
|
|||
return { false, STR_PARK_MUST_OWN_SOME_LAND };
|
||||
}
|
||||
|
||||
if (gParkEntrances.empty())
|
||||
const auto& gameState = GetGameState();
|
||||
if (gameState.ParkEntrances.empty())
|
||||
{
|
||||
return { false, STR_NO_PARK_ENTRANCES };
|
||||
}
|
||||
|
||||
for (const auto& parkEntrance : gParkEntrances)
|
||||
for (const auto& parkEntrance : gameState.ParkEntrances)
|
||||
{
|
||||
int32_t direction = DirectionReverse(parkEntrance.direction);
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <chrono>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
|
@ -30,6 +31,7 @@ namespace OpenRCT2
|
|||
uint64_t ParkFlags;
|
||||
uint16_t ParkRating;
|
||||
money64 ParkEntranceFee;
|
||||
std::vector<CoordsXYZD> ParkEntrances;
|
||||
uint32_t ParkSize;
|
||||
ClimateType Climate;
|
||||
ClimateState ClimateCurrent;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "ParkEntrancePlaceAction.h"
|
||||
|
||||
#include "../Cheats.h"
|
||||
#include "../GameState.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../core/MemoryStream.h"
|
||||
#include "../localisation/StringIds.h"
|
||||
|
@ -21,6 +22,8 @@
|
|||
#include "../world/Park.h"
|
||||
#include "../world/Surface.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
ParkEntrancePlaceAction::ParkEntrancePlaceAction(const CoordsXYZD& location, ObjectEntryIndex pathType)
|
||||
: _loc(location)
|
||||
, _pathType(pathType)
|
||||
|
@ -71,7 +74,8 @@ GameActions::Result ParkEntrancePlaceAction::Query() const
|
|||
GameActions::Status::NoFreeElements, STR_CANT_BUILD_THIS_HERE, STR_ERR_LANDSCAPE_DATA_AREA_FULL);
|
||||
}
|
||||
|
||||
if (gParkEntrances.size() >= OpenRCT2::Limits::MaxParkEntrances)
|
||||
const auto& gameState = GetGameState();
|
||||
if (gameState.ParkEntrances.size() >= OpenRCT2::Limits::MaxParkEntrances)
|
||||
{
|
||||
return GameActions::Result(
|
||||
GameActions::Status::InvalidParameters, STR_CANT_BUILD_THIS_HERE, STR_ERR_TOO_MANY_PARK_ENTRANCES);
|
||||
|
@ -117,7 +121,7 @@ GameActions::Result ParkEntrancePlaceAction::Execute() const
|
|||
|
||||
uint32_t flags = GetFlags();
|
||||
|
||||
gParkEntrances.push_back(_loc);
|
||||
GetGameState().ParkEntrances.push_back(_loc);
|
||||
|
||||
auto zLow = _loc.z;
|
||||
auto zHigh = zLow + ParkEntranceHeight;
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
#include "../management/Finance.h"
|
||||
#include "../world/Entrance.h"
|
||||
#include "../world/Park.h"
|
||||
#include "../GameState.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
ParkEntranceRemoveAction::ParkEntranceRemoveAction(const CoordsXYZ& loc)
|
||||
: _loc(loc)
|
||||
|
@ -71,7 +74,8 @@ GameActions::Result ParkEntranceRemoveAction::Execute() const
|
|||
return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_REMOVE_THIS, STR_NONE);
|
||||
}
|
||||
|
||||
auto direction = (gParkEntrances[entranceIndex].direction - 1) & 3;
|
||||
auto& gameState = GetGameState();
|
||||
auto direction = (gameState.ParkEntrances[entranceIndex].direction - 1) & 3;
|
||||
|
||||
// Centre (sign)
|
||||
ParkEntranceRemoveSegment(_loc);
|
||||
|
@ -84,7 +88,7 @@ GameActions::Result ParkEntranceRemoveAction::Execute() const
|
|||
ParkEntranceRemoveSegment(
|
||||
{ _loc.x - CoordsDirectionDelta[direction].x, _loc.y - CoordsDirectionDelta[direction].y, _loc.z });
|
||||
|
||||
gParkEntrances.erase(gParkEntrances.begin() + entranceIndex);
|
||||
gameState.ParkEntrances.erase(gameState.ParkEntrances.begin() + entranceIndex);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "../Cheats.h"
|
||||
#include "../Context.h"
|
||||
#include "../GameState.h"
|
||||
#include "../core/MemoryStream.h"
|
||||
#include "../drawing/Drawing.h"
|
||||
#include "../entity/EntityRegistry.h"
|
||||
|
@ -28,6 +29,8 @@
|
|||
|
||||
#include <set>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
/* rct2: 0x009929FC */
|
||||
static constexpr PeepSpriteType spriteTypes[] = {
|
||||
PeepSpriteType::Handyman,
|
||||
|
@ -288,10 +291,11 @@ void StaffHireNewAction::AutoPositionNewStaff(Peep* newPeep) const
|
|||
else
|
||||
{
|
||||
// No walking guests; pick random park entrance
|
||||
if (!gParkEntrances.empty())
|
||||
const auto& gameState = GetGameState();
|
||||
if (!gameState.ParkEntrances.empty())
|
||||
{
|
||||
auto rand = ScenarioRandMax(static_cast<uint32_t>(gParkEntrances.size()));
|
||||
const auto& entrance = gParkEntrances[rand];
|
||||
auto rand = ScenarioRandMax(static_cast<uint32_t>(gameState.ParkEntrances.size()));
|
||||
const auto& entrance = gameState.ParkEntrances[rand];
|
||||
auto dir = entrance.direction;
|
||||
newLocation = entrance;
|
||||
// TODO: Replace with CoordsDirectionDelta
|
||||
|
|
|
@ -1885,8 +1885,8 @@ static bool PeepInteractWithEntrance(Peep* peep, const CoordsXYE& coords, uint8_
|
|||
|
||||
bool found = false;
|
||||
auto entrance = std::find_if(
|
||||
gParkEntrances.begin(), gParkEntrances.end(), [coords](const auto& e) { return coords.ToTileStart() == e; });
|
||||
if (entrance != gParkEntrances.end())
|
||||
gameState.ParkEntrances.begin(), gameState.ParkEntrances.end(), [coords](const auto& e) { return coords.ToTileStart() == e; });
|
||||
if (entrance != gameState.ParkEntrances.end())
|
||||
{
|
||||
int16_t z = entrance->z / 8;
|
||||
entranceDirection = entrance->direction;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "GuestPathfinding.h"
|
||||
|
||||
#include "../GameState.h"
|
||||
#include "../core/Guard.hpp"
|
||||
#include "../entity/Guest.h"
|
||||
#include "../entity/Staff.h"
|
||||
|
@ -1643,7 +1644,7 @@ static std::optional<CoordsXYZ> GetNearestParkEntrance(const CoordsXY& loc)
|
|||
{
|
||||
std::optional<CoordsXYZ> chosenEntrance = std::nullopt;
|
||||
uint16_t nearestDist = 0xFFFF;
|
||||
for (const auto& parkEntrance : gParkEntrances)
|
||||
for (const auto& parkEntrance : GetGameState().ParkEntrances)
|
||||
{
|
||||
auto dist = abs(parkEntrance.x - loc.x) + abs(parkEntrance.y - loc.y);
|
||||
if (dist < nearestDist)
|
||||
|
|
|
@ -2410,10 +2410,11 @@ namespace RCT1
|
|||
|
||||
void FixEntrancePositions()
|
||||
{
|
||||
gParkEntrances.clear();
|
||||
auto& gameState = GetGameState();
|
||||
gameState.ParkEntrances.clear();
|
||||
TileElementIterator it;
|
||||
TileElementIteratorBegin(&it);
|
||||
while (TileElementIteratorNext(&it) && gParkEntrances.size() < Limits::MaxParkEntrances)
|
||||
while (TileElementIteratorNext(&it) && gameState.ParkEntrances.size() < Limits::MaxParkEntrances)
|
||||
{
|
||||
TileElement* element = it.element;
|
||||
|
||||
|
@ -2425,7 +2426,7 @@ namespace RCT1
|
|||
continue;
|
||||
|
||||
CoordsXYZD entrance = { TileCoordsXY(it.x, it.y).ToCoordsXY(), element->GetBaseZ(), element->GetDirection() };
|
||||
gParkEntrances.push_back(entrance);
|
||||
gameState.ParkEntrances.push_back(entrance);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -412,7 +412,7 @@ namespace RCT2
|
|||
gBankLoanInterestRate = _s6.CurrentInterestRate;
|
||||
// Pad0135934B
|
||||
// Preserve compatibility with vanilla RCT2's save format.
|
||||
gParkEntrances.clear();
|
||||
gameState.ParkEntrances.clear();
|
||||
for (uint8_t i = 0; i < Limits::MaxParkEntrances; i++)
|
||||
{
|
||||
if (_s6.ParkEntranceX[i] != LOCATION_NULL)
|
||||
|
@ -422,7 +422,7 @@ namespace RCT2
|
|||
entrance.y = _s6.ParkEntranceY[i];
|
||||
entrance.z = _s6.ParkEntranceZ[i];
|
||||
entrance.direction = _s6.ParkEntranceDirection[i];
|
||||
gParkEntrances.push_back(entrance);
|
||||
gameState.ParkEntrances.push_back(entrance);
|
||||
}
|
||||
}
|
||||
if (_s6.Header.Type == S6_TYPE_SCENARIO)
|
||||
|
|
|
@ -239,11 +239,12 @@ static void ScenarioCheckEntranceFeeTooHigh()
|
|||
{
|
||||
const auto max_fee = AddClamp_money64(gTotalRideValueForMoney, gTotalRideValueForMoney / 2);
|
||||
|
||||
if ((GetGameState().ParkFlags & PARK_FLAGS_PARK_OPEN) && ParkGetEntranceFee() > max_fee)
|
||||
const auto& gameState = GetGameState();
|
||||
if ((gameState.ParkFlags & PARK_FLAGS_PARK_OPEN) && ParkGetEntranceFee() > max_fee)
|
||||
{
|
||||
if (!gParkEntrances.empty())
|
||||
if (!gameState.ParkEntrances.empty())
|
||||
{
|
||||
const auto& entrance = gParkEntrances[0];
|
||||
const auto& entrance = gameState.ParkEntrances[0];
|
||||
auto x = entrance.x + 16;
|
||||
auto y = entrance.y + 16;
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "../Cheats.h"
|
||||
#include "../Context.h"
|
||||
#include "../Game.h"
|
||||
#include "../GameState.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../actions/ParkEntranceRemoveAction.h"
|
||||
#include "../actions/RideEntranceExitPlaceAction.h"
|
||||
|
@ -32,9 +33,10 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
bool gParkEntranceGhostExists = false;
|
||||
CoordsXYZD gParkEntranceGhostPosition = { 0, 0, 0, 0 };
|
||||
std::vector<CoordsXYZD> gParkEntrances;
|
||||
|
||||
CoordsXYZD gRideEntranceExitGhostPosition;
|
||||
StationIndex gRideEntranceExitGhostStationIndex;
|
||||
|
@ -68,7 +70,7 @@ void ParkEntranceRemoveGhost()
|
|||
int32_t ParkEntranceGetIndex(const CoordsXYZ& entrancePos)
|
||||
{
|
||||
int32_t i = 0;
|
||||
for (const auto& entrance : gParkEntrances)
|
||||
for (const auto& entrance : GetGameState().ParkEntrances)
|
||||
{
|
||||
if (entrancePos == entrance)
|
||||
{
|
||||
|
@ -81,7 +83,7 @@ int32_t ParkEntranceGetIndex(const CoordsXYZ& entrancePos)
|
|||
|
||||
void ParkEntranceReset()
|
||||
{
|
||||
gParkEntrances.clear();
|
||||
GetGameState().ParkEntrances.clear();
|
||||
}
|
||||
|
||||
void RideEntranceExitPlaceProvisionalGhost()
|
||||
|
@ -210,17 +212,19 @@ void MazeEntranceHedgeRemoval(const CoordsXYE& entrance)
|
|||
|
||||
void ParkEntranceFixLocations(void)
|
||||
{
|
||||
// Fix gParkEntrance locations for which the tile_element no longer exists
|
||||
gParkEntrances.erase(
|
||||
auto& gameState = GetGameState();
|
||||
// Fix ParkEntrance locations for which the tile_element no longer exists
|
||||
gameState.ParkEntrances.erase(
|
||||
std::remove_if(
|
||||
gParkEntrances.begin(), gParkEntrances.end(),
|
||||
gameState.ParkEntrances.begin(), gameState.ParkEntrances.end(),
|
||||
[](const auto& entrance) { return MapGetParkEntranceElementAt(entrance, false) == nullptr; }),
|
||||
gParkEntrances.end());
|
||||
gameState.ParkEntrances.end());
|
||||
}
|
||||
|
||||
void ParkEntranceUpdateLocations()
|
||||
{
|
||||
gParkEntrances.clear();
|
||||
auto& gameState = GetGameState();
|
||||
gameState.ParkEntrances.clear();
|
||||
TileElementIterator it;
|
||||
TileElementIteratorBegin(&it);
|
||||
while (TileElementIteratorNext(&it))
|
||||
|
@ -230,7 +234,7 @@ void ParkEntranceUpdateLocations()
|
|||
&& entranceElement->GetSequenceIndex() == 0 && !entranceElement->IsGhost())
|
||||
{
|
||||
auto entrance = TileCoordsXYZD(it.x, it.y, it.element->BaseHeight, it.element->GetDirection()).ToCoordsXYZD();
|
||||
gParkEntrances.push_back(entrance);
|
||||
gameState.ParkEntrances.push_back(entrance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
#include "Location.hpp"
|
||||
#include "Map.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
struct TileElement;
|
||||
|
||||
enum
|
||||
|
@ -39,8 +37,6 @@ extern CoordsXYZD gParkEntranceGhostPosition;
|
|||
|
||||
constexpr int32_t MaxRideEntranceOrExitHeight = 244 * COORDS_Z_STEP;
|
||||
|
||||
extern std::vector<CoordsXYZD> gParkEntrances;
|
||||
|
||||
extern CoordsXYZD gRideEntranceExitGhostPosition;
|
||||
extern StationIndex gRideEntranceExitGhostStationIndex;
|
||||
|
||||
|
|
Loading…
Reference in New Issue