2017-02-25 14:51:30 +01:00
|
|
|
/*****************************************************************************
|
2024-01-01 12:52:28 +01:00
|
|
|
* Copyright (c) 2014-2024 OpenRCT2 developers
|
2017-02-25 14:51:30 +01:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2017-02-25 14:51:30 +01:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2017-02-25 14:51:30 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2017-12-14 10:34:12 +01:00
|
|
|
#include "Entrance.h"
|
2018-06-22 23:17:03 +02:00
|
|
|
|
2017-12-13 13:02:24 +01:00
|
|
|
#include "../Cheats.h"
|
2021-09-06 21:59:17 +02:00
|
|
|
#include "../Context.h"
|
2017-11-30 18:17:06 +01:00
|
|
|
#include "../Game.h"
|
2024-01-25 12:52:56 +01:00
|
|
|
#include "../GameState.h"
|
2018-06-22 23:17:03 +02:00
|
|
|
#include "../OpenRCT2.h"
|
Split actions hpp files into separate h and cpp files (#13548)
* Split up SmallSceneryPlace/Remove
Added undo function for Remove Scenery
* Refactor: Balloon and Banner actions hpp=>h/cpp
* Refactor: rename all action *.hpp files to *.cpp
This is preparation for separation in later commits. Note that without
the complete set of commits in this branch, the code will not build.
* Refactor Clear, Climate, Custom, and Footpath actions hpp=>h/cpp
* VSCode: add src subdirectories to includePath
* Refactor Guest actions hpp=>h/cpp
* Refactor Land actions hpp=>h/cpp
* Refactor LargeScenery actions hpp=>h/cpp
* Refactor Load, Maze, Network actions hpp=>h/cpp
* Refactor Park actions hpp=>h/cpp
* Refactor/style: move private function declarations in actions *.h
Previous action .h files included private function declarations with
private member variables, before public function declarations. This
commit re-orders the header files to the following order:
- public member variables
- private member variables
- public functions
- private functions
* Refactor Pause action hpp=>h/cpp
* Refactor Peep, Place, Player actions hpp=>h/cpp
* Refactor Ride actions hpp=>h/cpp
* Refactor Scenario, Set*, Sign* actions hpp=>h/cpp
* Refactor SmallScenerySetColourAction hpp=>h/cpp
* Refactor Staff actions hpp=>h/cpp
* Refactor Surface, Tile, Track* actions hpp=>h/cpp
* Refactor Wall and Water actions hpp=>h/cpp
* Fix various includes and other compile errors
Update includes for tests.
Move static function declarations to .h files
Add explicit includes to various files that were previously implicit
(the required header was a nested include in an action hpp file, and the
action .h file does not include that header)
Move RideSetStatus string enum to the cpp file to avoid unused imports
* Xcode: modify project file for actions refactor
* Cleanup whitespace and end-of-file newlines
Co-authored-by: duncanspumpkin <duncans_pumpkin@hotmail.co.uk>
2020-12-10 07:39:10 +01:00
|
|
|
#include "../actions/ParkEntranceRemoveAction.h"
|
|
|
|
#include "../actions/RideEntranceExitPlaceAction.h"
|
|
|
|
#include "../actions/RideEntranceExitRemoveAction.h"
|
2018-01-06 18:32:25 +01:00
|
|
|
#include "../localisation/StringIds.h"
|
2017-10-06 22:37:06 +02:00
|
|
|
#include "../management/Finance.h"
|
2018-06-22 23:17:03 +02:00
|
|
|
#include "../network/network.h"
|
2021-09-05 18:44:43 +02:00
|
|
|
#include "../object/FootpathObject.h"
|
2021-09-06 21:59:17 +02:00
|
|
|
#include "../object/FootpathSurfaceObject.h"
|
|
|
|
#include "../object/ObjectManager.h"
|
2021-12-18 19:50:29 +01:00
|
|
|
#include "../ride/RideConstruction.h"
|
2018-03-07 19:10:50 +01:00
|
|
|
#include "../ride/Station.h"
|
2018-06-22 23:17:03 +02:00
|
|
|
#include "../ride/Track.h"
|
|
|
|
#include "Footpath.h"
|
|
|
|
#include "Map.h"
|
|
|
|
#include "MapAnimation.h"
|
|
|
|
#include "Park.h"
|
2017-02-25 14:51:30 +01:00
|
|
|
|
2018-12-15 20:20:04 +01:00
|
|
|
#include <algorithm>
|
|
|
|
|
2024-01-25 12:52:56 +01:00
|
|
|
using namespace OpenRCT2;
|
|
|
|
|
2017-04-24 21:46:58 +02:00
|
|
|
bool gParkEntranceGhostExists = false;
|
2019-12-12 10:58:27 +01:00
|
|
|
CoordsXYZD gParkEntranceGhostPosition = { 0, 0, 0, 0 };
|
2017-02-25 14:51:30 +01:00
|
|
|
|
2018-02-16 09:50:40 +01:00
|
|
|
CoordsXYZD gRideEntranceExitGhostPosition;
|
2020-03-26 21:38:26 +01:00
|
|
|
StationIndex gRideEntranceExitGhostStationIndex;
|
2017-03-04 11:18:31 +01:00
|
|
|
|
2023-03-02 22:55:42 +01:00
|
|
|
static money64 RideEntranceExitPlaceGhost(
|
2022-01-19 14:17:11 +01:00
|
|
|
RideId rideIndex, const CoordsXY& entranceExitCoords, Direction direction, uint8_t placeType, StationIndex stationNum)
|
2017-03-04 11:18:31 +01:00
|
|
|
{
|
2019-02-28 11:56:25 +01:00
|
|
|
auto rideEntranceExitPlaceAction = RideEntranceExitPlaceAction(
|
2020-01-14 01:19:08 +01:00
|
|
|
entranceExitCoords, direction, rideIndex, stationNum, placeType == ENTRANCE_TYPE_RIDE_EXIT);
|
2019-02-28 11:56:25 +01:00
|
|
|
rideEntranceExitPlaceAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_GHOST);
|
|
|
|
auto res = GameActions::Execute(&rideEntranceExitPlaceAction);
|
|
|
|
|
2024-02-23 23:30:35 +01:00
|
|
|
return res.Error == GameActions::Status::Ok ? res.Cost : kMoney64Undefined;
|
2017-03-04 11:18:31 +01:00
|
|
|
}
|
2017-02-25 14:51:30 +01:00
|
|
|
|
2018-02-01 18:49:14 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00666F9E
|
|
|
|
*/
|
2022-10-04 08:38:00 +02:00
|
|
|
void ParkEntranceRemoveGhost()
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
|
|
|
if (gParkEntranceGhostExists)
|
2017-02-25 14:51:30 +01:00
|
|
|
{
|
2018-02-01 18:49:14 +01:00
|
|
|
gParkEntranceGhostExists = false;
|
2019-12-12 10:58:27 +01:00
|
|
|
auto parkEntranceRemoveAction = ParkEntranceRemoveAction(gParkEntranceGhostPosition);
|
2019-03-24 21:41:14 +01:00
|
|
|
parkEntranceRemoveAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED);
|
|
|
|
GameActions::Execute(&parkEntranceRemoveAction);
|
2017-02-25 14:51:30 +01:00
|
|
|
}
|
2018-02-01 18:49:14 +01:00
|
|
|
}
|
2017-02-25 14:51:30 +01:00
|
|
|
|
2022-10-04 08:38:00 +02:00
|
|
|
int32_t ParkEntranceGetIndex(const CoordsXYZ& entrancePos)
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
2018-12-15 18:57:23 +01:00
|
|
|
int32_t i = 0;
|
2024-03-26 21:35:55 +01:00
|
|
|
for (const auto& entrance : GetGameState().Park.Entrances)
|
2017-02-25 14:51:30 +01:00
|
|
|
{
|
2020-01-14 01:21:41 +01:00
|
|
|
if (entrancePos == entrance)
|
2017-03-01 22:19:15 +01:00
|
|
|
{
|
2018-02-01 18:49:14 +01:00
|
|
|
return i;
|
2017-03-01 22:19:15 +01:00
|
|
|
}
|
2018-12-15 18:57:23 +01:00
|
|
|
i++;
|
2017-02-25 14:51:30 +01:00
|
|
|
}
|
2018-02-01 18:49:14 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-10-04 08:51:27 +02:00
|
|
|
void ParkEntranceReset()
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
2024-03-26 21:35:55 +01:00
|
|
|
GetGameState().Park.Entrances.clear();
|
2018-02-01 18:49:14 +01:00
|
|
|
}
|
2017-03-04 11:18:31 +01:00
|
|
|
|
2022-10-04 08:38:00 +02:00
|
|
|
void RideEntranceExitPlaceProvisionalGhost()
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
2018-06-22 23:17:03 +02:00
|
|
|
if (_currentTrackSelectionFlags & TRACK_SELECTION_FLAG_ENTRANCE_OR_EXIT)
|
|
|
|
{
|
|
|
|
RideEntranceExitPlaceGhost(
|
2020-01-14 01:19:08 +01:00
|
|
|
_currentRideIndex, gRideEntranceExitGhostPosition, gRideEntranceExitGhostPosition.direction,
|
|
|
|
gRideEntranceExitPlaceType, gRideEntranceExitGhostStationIndex);
|
2017-03-04 11:18:31 +01:00
|
|
|
}
|
2018-02-01 18:49:14 +01:00
|
|
|
}
|
2017-03-04 11:18:31 +01:00
|
|
|
|
2022-10-04 08:38:00 +02:00
|
|
|
void RideEntranceExitRemoveGhost()
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
2018-06-22 23:17:03 +02:00
|
|
|
if (_currentTrackSelectionFlags & TRACK_SELECTION_FLAG_ENTRANCE_OR_EXIT)
|
|
|
|
{
|
2019-02-24 09:56:40 +01:00
|
|
|
auto rideEntranceExitRemove = RideEntranceExitRemoveAction(
|
2020-01-14 01:19:08 +01:00
|
|
|
gRideEntranceExitGhostPosition, _currentRideIndex, gRideEntranceExitGhostStationIndex,
|
|
|
|
gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_EXIT);
|
2019-02-24 09:56:40 +01:00
|
|
|
|
2019-02-27 19:35:55 +01:00
|
|
|
rideEntranceExitRemove.SetFlags(GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED);
|
2019-02-24 09:56:40 +01:00
|
|
|
GameActions::Execute(&rideEntranceExitRemove);
|
2017-03-04 11:18:31 +01:00
|
|
|
}
|
2018-02-01 18:49:14 +01:00
|
|
|
}
|
2017-03-04 11:18:31 +01:00
|
|
|
|
2018-02-01 18:49:14 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x006CA28C
|
|
|
|
*/
|
2023-03-02 22:55:42 +01:00
|
|
|
money64 RideEntranceExitPlaceGhost(
|
2023-01-07 14:02:18 +01:00
|
|
|
const Ride& ride, const CoordsXY& entranceExitCoords, Direction direction, int32_t placeType, StationIndex stationNum)
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
2023-01-17 01:32:54 +01:00
|
|
|
RideConstructionRemoveGhosts();
|
2023-03-02 22:55:42 +01:00
|
|
|
money64 result = RideEntranceExitPlaceGhost(ride.id, entranceExitCoords, direction, placeType, stationNum);
|
2017-03-04 11:18:31 +01:00
|
|
|
|
2024-02-23 23:30:35 +01:00
|
|
|
if (result != kMoney64Undefined)
|
2017-03-09 19:48:09 +01:00
|
|
|
{
|
2018-02-01 18:49:14 +01:00
|
|
|
_currentTrackSelectionFlags |= TRACK_SELECTION_FLAG_ENTRANCE_OR_EXIT;
|
2020-01-14 01:19:08 +01:00
|
|
|
gRideEntranceExitGhostPosition.x = entranceExitCoords.x;
|
|
|
|
gRideEntranceExitGhostPosition.y = entranceExitCoords.y;
|
2018-02-01 18:49:14 +01:00
|
|
|
gRideEntranceExitGhostPosition.direction = direction;
|
2020-03-26 21:38:26 +01:00
|
|
|
gRideEntranceExitGhostStationIndex = stationNum;
|
2017-03-04 11:18:31 +01:00
|
|
|
}
|
2018-02-01 18:49:14 +01:00
|
|
|
return result;
|
|
|
|
}
|
2017-03-04 11:18:31 +01:00
|
|
|
|
2018-02-01 18:49:14 +01:00
|
|
|
/**
|
|
|
|
* Replaces the outer hedge walls for an entrance placement removal.
|
|
|
|
* rct2: 0x00666D6F
|
|
|
|
*/
|
2022-10-04 08:38:00 +02:00
|
|
|
void MazeEntranceHedgeReplacement(const CoordsXYE& entrance)
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
2020-01-14 01:44:05 +01:00
|
|
|
int32_t direction = entrance.element->GetDirection();
|
|
|
|
auto hedgePos = entrance + CoordsDirectionDelta[direction];
|
|
|
|
int32_t z = entrance.element->GetBaseZ();
|
2022-01-19 14:17:11 +01:00
|
|
|
RideId rideIndex = entrance.element->AsEntrance()->GetRideIndex();
|
2018-02-01 18:49:14 +01:00
|
|
|
|
2022-10-11 20:39:24 +02:00
|
|
|
auto tileElement = MapGetFirstElementAt(hedgePos);
|
2019-10-09 16:02:21 +02:00
|
|
|
if (tileElement == nullptr)
|
|
|
|
return;
|
2018-06-22 23:17:03 +02:00
|
|
|
do
|
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
if (tileElement->GetType() != TileElementType::Track)
|
2018-06-22 23:17:03 +02:00
|
|
|
continue;
|
2018-09-18 13:10:29 +02:00
|
|
|
if (tileElement->AsTrack()->GetRideIndex() != rideIndex)
|
2018-06-22 23:17:03 +02:00
|
|
|
continue;
|
2019-12-27 15:26:40 +01:00
|
|
|
if (tileElement->GetBaseZ() != z)
|
2018-06-22 23:17:03 +02:00
|
|
|
continue;
|
2020-08-18 08:28:41 +02:00
|
|
|
if (tileElement->AsTrack()->GetTrackType() != TrackElemType::Maze)
|
2018-06-22 23:17:03 +02:00
|
|
|
continue;
|
2018-02-01 18:49:14 +01:00
|
|
|
|
|
|
|
// Each maze element is split into 4 sections with 4 different walls
|
2018-06-20 17:28:51 +02:00
|
|
|
uint8_t mazeSection = direction * 4;
|
2018-02-01 18:49:14 +01:00
|
|
|
// Add the top outer wall
|
2018-09-18 14:04:23 +02:00
|
|
|
tileElement->AsTrack()->MazeEntryAdd(1 << ((mazeSection + 9) & 0x0F));
|
2018-02-01 18:49:14 +01:00
|
|
|
// Add the bottom outer wall
|
2018-09-18 14:04:23 +02:00
|
|
|
tileElement->AsTrack()->MazeEntryAdd(1 << ((mazeSection + 12) & 0x0F));
|
2018-02-01 18:49:14 +01:00
|
|
|
|
2022-10-12 14:14:45 +02:00
|
|
|
MapInvalidateTile({ hedgePos, tileElement->GetBaseZ(), tileElement->GetClearanceZ() });
|
2018-02-01 18:49:14 +01:00
|
|
|
return;
|
2018-05-24 11:44:53 +02:00
|
|
|
} while (!(tileElement++)->IsLastForTile());
|
2018-02-01 18:49:14 +01:00
|
|
|
}
|
2017-10-22 23:22:46 +02:00
|
|
|
|
2018-02-01 18:49:14 +01:00
|
|
|
/**
|
|
|
|
* Removes the hedge walls for an entrance placement.
|
|
|
|
* rct2: 0x00666CBE
|
|
|
|
*/
|
2022-10-04 08:38:00 +02:00
|
|
|
void MazeEntranceHedgeRemoval(const CoordsXYE& entrance)
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
2020-01-14 01:48:12 +01:00
|
|
|
int32_t direction = entrance.element->GetDirection();
|
|
|
|
auto hedgePos = entrance + CoordsDirectionDelta[direction];
|
|
|
|
int32_t z = entrance.element->GetBaseZ();
|
2022-01-19 14:17:11 +01:00
|
|
|
RideId rideIndex = entrance.element->AsEntrance()->GetRideIndex();
|
2018-02-01 18:49:14 +01:00
|
|
|
|
2022-10-11 20:39:24 +02:00
|
|
|
auto tileElement = MapGetFirstElementAt(hedgePos);
|
2019-10-09 16:02:21 +02:00
|
|
|
if (tileElement == nullptr)
|
|
|
|
return;
|
2018-06-22 23:17:03 +02:00
|
|
|
do
|
|
|
|
{
|
2021-12-11 00:39:39 +01:00
|
|
|
if (tileElement->GetType() != TileElementType::Track)
|
2018-06-22 23:17:03 +02:00
|
|
|
continue;
|
2018-09-18 13:10:29 +02:00
|
|
|
if (tileElement->AsTrack()->GetRideIndex() != rideIndex)
|
2018-06-22 23:17:03 +02:00
|
|
|
continue;
|
2019-12-27 15:26:40 +01:00
|
|
|
if (tileElement->GetBaseZ() != z)
|
2018-06-22 23:17:03 +02:00
|
|
|
continue;
|
2020-08-18 08:28:41 +02:00
|
|
|
if (tileElement->AsTrack()->GetTrackType() != TrackElemType::Maze)
|
2018-06-22 23:17:03 +02:00
|
|
|
continue;
|
2018-02-01 18:49:14 +01:00
|
|
|
|
|
|
|
// Each maze element is split into 4 sections with 4 different walls
|
2018-06-20 17:28:51 +02:00
|
|
|
uint8_t mazeSection = direction * 4;
|
2018-02-01 18:49:14 +01:00
|
|
|
// Remove the top outer wall
|
2018-09-18 14:04:23 +02:00
|
|
|
tileElement->AsTrack()->MazeEntrySubtract(1 << ((mazeSection + 9) & 0x0F));
|
2018-02-01 18:49:14 +01:00
|
|
|
// Remove the bottom outer wall
|
2018-09-18 14:04:23 +02:00
|
|
|
tileElement->AsTrack()->MazeEntrySubtract(1 << ((mazeSection + 12) & 0x0F));
|
2018-02-01 18:49:14 +01:00
|
|
|
// Remove the intersecting wall
|
2018-09-18 14:04:23 +02:00
|
|
|
tileElement->AsTrack()->MazeEntrySubtract(1 << ((mazeSection + 10) & 0x0F));
|
2018-02-01 18:49:14 +01:00
|
|
|
// Remove the top hedge section
|
2018-09-18 14:04:23 +02:00
|
|
|
tileElement->AsTrack()->MazeEntrySubtract(1 << ((mazeSection + 11) & 0x0F));
|
2018-02-01 18:49:14 +01:00
|
|
|
// Remove the bottom hedge section
|
2018-09-18 14:04:23 +02:00
|
|
|
tileElement->AsTrack()->MazeEntrySubtract(1 << ((mazeSection + 15) & 0x0F));
|
2018-02-01 18:49:14 +01:00
|
|
|
|
2022-10-12 14:14:45 +02:00
|
|
|
MapInvalidateTile({ hedgePos, tileElement->GetBaseZ(), tileElement->GetClearanceZ() });
|
2018-02-01 18:49:14 +01:00
|
|
|
return;
|
2018-05-24 11:44:53 +02:00
|
|
|
} while (!(tileElement++)->IsLastForTile());
|
2018-02-01 18:49:14 +01:00
|
|
|
}
|
|
|
|
|
2022-10-04 08:38:00 +02:00
|
|
|
void ParkEntranceFixLocations(void)
|
2018-02-01 18:49:14 +01:00
|
|
|
{
|
2024-01-25 12:52:56 +01:00
|
|
|
auto& gameState = GetGameState();
|
|
|
|
// Fix ParkEntrance locations for which the tile_element no longer exists
|
2024-03-26 21:35:55 +01:00
|
|
|
gameState.Park.Entrances.erase(
|
2018-12-15 18:57:23 +01:00
|
|
|
std::remove_if(
|
2024-03-26 21:35:55 +01:00
|
|
|
gameState.Park.Entrances.begin(), gameState.Park.Entrances.end(),
|
2022-10-12 07:35:20 +02:00
|
|
|
[](const auto& entrance) { return MapGetParkEntranceElementAt(entrance, false) == nullptr; }),
|
2024-03-26 21:35:55 +01:00
|
|
|
gameState.Park.Entrances.end());
|
2017-04-24 21:46:58 +02:00
|
|
|
}
|
2018-09-17 22:51:28 +02:00
|
|
|
|
2022-10-04 08:38:00 +02:00
|
|
|
void ParkEntranceUpdateLocations()
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
2024-01-25 12:52:56 +01:00
|
|
|
auto& gameState = GetGameState();
|
2024-03-26 21:35:55 +01:00
|
|
|
gameState.Park.Entrances.clear();
|
2023-01-19 16:13:23 +01:00
|
|
|
TileElementIterator it;
|
2022-10-12 14:14:45 +02:00
|
|
|
TileElementIteratorBegin(&it);
|
|
|
|
while (TileElementIteratorNext(&it))
|
2021-10-27 14:21:14 +02:00
|
|
|
{
|
|
|
|
auto entranceElement = it.element->AsEntrance();
|
|
|
|
if (entranceElement != nullptr && entranceElement->GetEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE
|
|
|
|
&& entranceElement->GetSequenceIndex() == 0 && !entranceElement->IsGhost())
|
|
|
|
{
|
2023-01-19 20:36:30 +01:00
|
|
|
auto entrance = TileCoordsXYZD(it.x, it.y, it.element->BaseHeight, it.element->GetDirection()).ToCoordsXYZD();
|
2024-03-26 21:35:55 +01:00
|
|
|
gameState.Park.Entrances.push_back(entrance);
|
2021-10-27 14:21:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-26 13:28:19 +01:00
|
|
|
StationIndex EntranceElement::GetStationIndex() const
|
2018-09-17 22:51:28 +02:00
|
|
|
{
|
2022-01-26 13:28:19 +01:00
|
|
|
return stationIndex;
|
2018-09-17 22:51:28 +02:00
|
|
|
}
|
|
|
|
|
2022-01-26 13:28:19 +01:00
|
|
|
void EntranceElement::SetStationIndex(StationIndex newStationIndex)
|
2018-09-17 22:51:28 +02:00
|
|
|
{
|
2022-01-26 13:28:19 +01:00
|
|
|
stationIndex = newStationIndex;
|
2018-09-17 22:51:28 +02:00
|
|
|
}
|
2018-09-26 12:13:44 +02:00
|
|
|
|
|
|
|
uint8_t EntranceElement::GetEntranceType() const
|
|
|
|
{
|
|
|
|
return entranceType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EntranceElement::SetEntranceType(uint8_t newType)
|
|
|
|
{
|
|
|
|
entranceType = newType;
|
|
|
|
}
|
2018-09-26 12:30:27 +02:00
|
|
|
|
2022-01-19 14:17:11 +01:00
|
|
|
RideId EntranceElement::GetRideIndex() const
|
2018-09-26 12:30:27 +02:00
|
|
|
{
|
|
|
|
return rideIndex;
|
|
|
|
}
|
|
|
|
|
2022-01-19 14:17:11 +01:00
|
|
|
void EntranceElement::SetRideIndex(RideId newRideIndex)
|
2018-09-26 12:30:27 +02:00
|
|
|
{
|
|
|
|
rideIndex = newRideIndex;
|
|
|
|
}
|
2018-09-26 12:54:44 +02:00
|
|
|
|
|
|
|
uint8_t EntranceElement::GetSequenceIndex() const
|
|
|
|
{
|
2020-02-08 14:31:22 +01:00
|
|
|
return SequenceIndex & 0xF;
|
2018-09-26 12:54:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EntranceElement::SetSequenceIndex(uint8_t newSequenceIndex)
|
|
|
|
{
|
2020-02-08 14:31:22 +01:00
|
|
|
SequenceIndex &= ~0xF;
|
|
|
|
SequenceIndex |= (newSequenceIndex & 0xF);
|
2018-09-26 13:02:51 +02:00
|
|
|
}
|
|
|
|
|
2021-09-06 21:59:17 +02:00
|
|
|
bool EntranceElement::HasLegacyPathEntry() const
|
|
|
|
{
|
|
|
|
return (flags2 & ENTRANCE_ELEMENT_FLAGS2_LEGACY_PATH_ENTRY) != 0;
|
|
|
|
}
|
|
|
|
|
2021-09-05 18:44:43 +02:00
|
|
|
ObjectEntryIndex EntranceElement::GetLegacyPathEntryIndex() const
|
2018-09-26 13:02:51 +02:00
|
|
|
{
|
2021-09-06 21:59:17 +02:00
|
|
|
if (HasLegacyPathEntry())
|
|
|
|
return PathType;
|
2021-09-15 22:22:15 +02:00
|
|
|
|
|
|
|
return OBJECT_ENTRY_INDEX_NULL;
|
2021-09-06 21:59:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const FootpathObject* EntranceElement::GetLegacyPathEntry() const
|
|
|
|
{
|
|
|
|
auto& objMgr = OpenRCT2::GetContext()->GetObjectManager();
|
|
|
|
return static_cast<FootpathObject*>(objMgr.GetLoadedObject(ObjectType::Paths, GetLegacyPathEntryIndex()));
|
2018-09-26 13:02:51 +02:00
|
|
|
}
|
|
|
|
|
2021-09-05 18:44:43 +02:00
|
|
|
void EntranceElement::SetLegacyPathEntryIndex(ObjectEntryIndex newPathType)
|
2018-09-26 13:02:51 +02:00
|
|
|
{
|
2020-03-04 18:43:09 +01:00
|
|
|
PathType = newPathType;
|
2021-09-06 21:59:17 +02:00
|
|
|
flags2 |= ENTRANCE_ELEMENT_FLAGS2_LEGACY_PATH_ENTRY;
|
|
|
|
}
|
|
|
|
|
|
|
|
ObjectEntryIndex EntranceElement::GetSurfaceEntryIndex() const
|
|
|
|
{
|
|
|
|
if (HasLegacyPathEntry())
|
|
|
|
return OBJECT_ENTRY_INDEX_NULL;
|
2021-09-15 22:22:15 +02:00
|
|
|
|
|
|
|
return PathType;
|
2021-09-06 21:59:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const FootpathSurfaceObject* EntranceElement::GetSurfaceEntry() const
|
|
|
|
{
|
|
|
|
auto& objMgr = OpenRCT2::GetContext()->GetObjectManager();
|
|
|
|
return static_cast<FootpathSurfaceObject*>(objMgr.GetLoadedObject(ObjectType::FootpathSurface, GetSurfaceEntryIndex()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void EntranceElement::SetSurfaceEntryIndex(ObjectEntryIndex newIndex)
|
|
|
|
{
|
|
|
|
PathType = newIndex;
|
|
|
|
flags2 &= ~ENTRANCE_ELEMENT_FLAGS2_LEGACY_PATH_ENTRY;
|
2018-09-26 14:52:16 +02:00
|
|
|
}
|
2021-09-05 18:44:43 +02:00
|
|
|
|
|
|
|
const PathSurfaceDescriptor* EntranceElement::GetPathSurfaceDescriptor() const
|
|
|
|
{
|
2021-09-06 21:59:17 +02:00
|
|
|
if (HasLegacyPathEntry())
|
|
|
|
{
|
|
|
|
const auto* legacyPathEntry = GetLegacyPathEntry();
|
|
|
|
if (legacyPathEntry == nullptr)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return &legacyPathEntry->GetPathSurfaceDescriptor();
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto* surfaceEntry = GetSurfaceEntry();
|
|
|
|
if (surfaceEntry == nullptr)
|
2021-09-05 18:44:43 +02:00
|
|
|
return nullptr;
|
|
|
|
|
2021-09-06 21:59:17 +02:00
|
|
|
return &surfaceEntry->GetDescriptor();
|
2021-09-05 18:44:43 +02:00
|
|
|
}
|