mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-17 20:13:07 +01:00
committed by
GitHub
parent
57a6b0a00c
commit
5407ba2d55
@@ -154,8 +154,7 @@ GameActions::Result FootpathLayoutPlaceAction::ElementInsertQuery(GameActions::R
|
||||
|
||||
// Do not attempt to build a crossing with a queue or a sloped path.
|
||||
auto isQueue = _constructFlags & PathConstructFlag::IsQueue;
|
||||
uint8_t crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CREATE_CROSSING_MODE_NONE
|
||||
: CREATE_CROSSING_MODE_PATH_OVER_TRACK;
|
||||
auto crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CreateCrossingMode::none : CreateCrossingMode::pathOverTrack;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc, zLow, zHigh }, &MapPlaceNonSceneryClearFunc, quarterTile, GetFlags(), crossingMode);
|
||||
if (!entrancePath && canBuild.Error != GameActions::Status::Ok)
|
||||
@@ -225,8 +224,7 @@ GameActions::Result FootpathLayoutPlaceAction::ElementInsertExecute(GameActions:
|
||||
|
||||
// Do not attempt to build a crossing with a queue or a sloped path.
|
||||
auto isQueue = _constructFlags & PathConstructFlag::IsQueue;
|
||||
uint8_t crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CREATE_CROSSING_MODE_NONE
|
||||
: CREATE_CROSSING_MODE_PATH_OVER_TRACK;
|
||||
auto crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CreateCrossingMode::none : CreateCrossingMode::pathOverTrack;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc, zLow, zHigh }, &MapPlaceNonSceneryClearFunc, quarterTile, GAME_COMMAND_FLAG_APPLY | GetFlags(), crossingMode);
|
||||
if (!entrancePath && canBuild.Error != GameActions::Status::Ok)
|
||||
|
||||
@@ -303,8 +303,7 @@ GameActions::Result FootpathPlaceAction::ElementInsertQuery(GameActions::Result
|
||||
|
||||
// Do not attempt to build a crossing with a queue or a sloped path.
|
||||
auto isQueue = _constructFlags & PathConstructFlag::IsQueue;
|
||||
uint8_t crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CREATE_CROSSING_MODE_NONE
|
||||
: CREATE_CROSSING_MODE_PATH_OVER_TRACK;
|
||||
auto crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CreateCrossingMode::none : CreateCrossingMode::pathOverTrack;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc, zLow, zHigh }, &MapPlaceNonSceneryClearFunc, quarterTile, GetFlags(), crossingMode);
|
||||
if (!entrancePath && canBuild.Error != GameActions::Status::Ok)
|
||||
@@ -373,8 +372,7 @@ GameActions::Result FootpathPlaceAction::ElementInsertExecute(GameActions::Resul
|
||||
|
||||
// Do not attempt to build a crossing with a queue or a sloped.
|
||||
auto isQueue = _constructFlags & PathConstructFlag::IsQueue;
|
||||
uint8_t crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CREATE_CROSSING_MODE_NONE
|
||||
: CREATE_CROSSING_MODE_PATH_OVER_TRACK;
|
||||
auto crossingMode = isQueue || (_slope != kTileSlopeFlat) ? CreateCrossingMode::none : CreateCrossingMode::pathOverTrack;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc, zLow, zHigh }, &MapPlaceNonSceneryClearFunc, quarterTile, GAME_COMMAND_FLAG_APPLY | GetFlags(), crossingMode);
|
||||
if (!entrancePath && canBuild.Error != GameActions::Status::Ok)
|
||||
|
||||
@@ -139,7 +139,7 @@ GameActions::Result LandSetHeightAction::Query() const
|
||||
|
||||
auto clearResult = MapCanConstructWithClearAt(
|
||||
{ _coords, _height * COORDS_Z_STEP, zCorner * COORDS_Z_STEP }, &MapSetLandHeightClearFunc, { 0b1111, 0 }, 0,
|
||||
CREATE_CROSSING_MODE_NONE);
|
||||
CreateCrossingMode::none);
|
||||
if (clearResult.Error != GameActions::Status::Ok)
|
||||
{
|
||||
clearResult.Error = GameActions::Status::Disallowed;
|
||||
|
||||
@@ -135,7 +135,7 @@ GameActions::Result LargeSceneryPlaceAction::Query() const
|
||||
QuarterTile quarterTile = QuarterTile{ static_cast<uint8_t>(tile->flags >> 12), 0 }.Rotate(_loc.direction);
|
||||
const auto isTree = (sceneryEntry->flags & LARGE_SCENERY_FLAG_IS_TREE) != 0;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ curTile, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags(), CREATE_CROSSING_MODE_NONE, isTree);
|
||||
{ curTile, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags(), CreateCrossingMode::none, isTree);
|
||||
if (canBuild.Error != GameActions::Status::Ok)
|
||||
{
|
||||
canBuild.ErrorTitle = STR_CANT_POSITION_THIS_HERE;
|
||||
@@ -273,7 +273,7 @@ GameActions::Result LargeSceneryPlaceAction::Execute() const
|
||||
QuarterTile quarterTile = QuarterTile{ static_cast<uint8_t>(tile->flags >> 12), 0 }.Rotate(_loc.direction);
|
||||
const auto isTree = (sceneryEntry->flags & LARGE_SCENERY_FLAG_IS_TREE) != 0;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ curTile, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags(), CREATE_CROSSING_MODE_NONE, isTree);
|
||||
{ curTile, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags(), CreateCrossingMode::none, isTree);
|
||||
if (canBuild.Error != GameActions::Status::Ok)
|
||||
{
|
||||
if (banner != nullptr)
|
||||
|
||||
@@ -271,7 +271,7 @@ GameActions::Result SmallSceneryPlaceAction::Query() const
|
||||
QuarterTile quarterTile = QuarterTile{ collisionQuadrants, supports }.Rotate(quadRotation);
|
||||
const auto isTree = sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_IS_TREE);
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags(), CREATE_CROSSING_MODE_NONE, isTree);
|
||||
{ _loc, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags(), CreateCrossingMode::none, isTree);
|
||||
if (canBuild.Error != GameActions::Status::Ok)
|
||||
{
|
||||
canBuild.ErrorTitle = STR_CANT_POSITION_THIS_HERE;
|
||||
@@ -411,7 +411,7 @@ GameActions::Result SmallSceneryPlaceAction::Execute() const
|
||||
const auto isTree = sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_IS_TREE);
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ _loc, zLow, zHigh }, &MapPlaceSceneryClearFunc, quarterTile, GetFlags() | GAME_COMMAND_FLAG_APPLY,
|
||||
CREATE_CROSSING_MODE_NONE, isTree);
|
||||
CreateCrossingMode::none, isTree);
|
||||
if (canBuild.Error != GameActions::Status::Ok)
|
||||
{
|
||||
canBuild.ErrorTitle = STR_CANT_POSITION_THIS_HERE;
|
||||
|
||||
@@ -261,10 +261,10 @@ GameActions::Result TrackPlaceAction::Query() const
|
||||
GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TOO_HIGH);
|
||||
}
|
||||
|
||||
uint8_t crossingMode = (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS)
|
||||
&& _trackType == TrackElemType::Flat)
|
||||
? CREATE_CROSSING_MODE_TRACK_OVER_PATH
|
||||
: CREATE_CROSSING_MODE_NONE;
|
||||
auto crossingMode = (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS)
|
||||
&& _trackType == TrackElemType::Flat)
|
||||
? CreateCrossingMode::trackOverPath
|
||||
: CreateCrossingMode::none;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
{ mapLoc, baseZ, clearanceZ }, &MapPlaceNonSceneryClearFunc, quarterTile, GetFlags(), crossingMode);
|
||||
if (canBuild.Error != GameActions::Status::Ok)
|
||||
@@ -477,10 +477,10 @@ GameActions::Result TrackPlaceAction::Execute() const
|
||||
clearanceZ = Floor2(clearanceZ, COORDS_Z_STEP) + baseZ;
|
||||
const auto mapLocWithClearance = CoordsXYRangedZ(mapLoc, baseZ, clearanceZ);
|
||||
|
||||
uint8_t crossingMode = (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS)
|
||||
&& _trackType == TrackElemType::Flat)
|
||||
? CREATE_CROSSING_MODE_TRACK_OVER_PATH
|
||||
: CREATE_CROSSING_MODE_NONE;
|
||||
auto crossingMode = (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS)
|
||||
&& _trackType == TrackElemType::Flat)
|
||||
? CreateCrossingMode::trackOverPath
|
||||
: CreateCrossingMode::none;
|
||||
auto canBuild = MapCanConstructWithClearAt(
|
||||
mapLocWithClearance, &MapPlaceNonSceneryClearFunc, quarterTile, GetFlags() | GAME_COMMAND_FLAG_APPLY, crossingMode);
|
||||
if (canBuild.Error != GameActions::Status::Ok)
|
||||
@@ -491,7 +491,7 @@ GameActions::Result TrackPlaceAction::Execute() const
|
||||
costs += canBuild.Cost;
|
||||
|
||||
// When building a level crossing, remove any pre-existing path furniture.
|
||||
if (crossingMode == CREATE_CROSSING_MODE_TRACK_OVER_PATH && !(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
if (crossingMode == CreateCrossingMode::trackOverPath && !(GetFlags() & GAME_COMMAND_FLAG_GHOST))
|
||||
{
|
||||
auto footpathElement = MapGetFootpathElement(mapLoc);
|
||||
if (footpathElement != nullptr && footpathElement->HasAddition())
|
||||
|
||||
@@ -80,7 +80,7 @@ int32_t MapPlaceNonSceneryClearFunc(TileElement** tile_element, const CoordsXY&
|
||||
|
||||
static bool MapLoc68BABCShouldContinue(
|
||||
TileElement** tileElementPtr, const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, uint8_t flags, money64& price,
|
||||
uint8_t crossingMode, bool canBuildCrossing)
|
||||
CreateCrossingMode crossingMode, bool canBuildCrossing)
|
||||
{
|
||||
if (clearFunc != nullptr)
|
||||
{
|
||||
@@ -90,17 +90,16 @@ static bool MapLoc68BABCShouldContinue(
|
||||
}
|
||||
}
|
||||
|
||||
// Crossing mode 1: building track over path
|
||||
auto tileElement = *tileElementPtr;
|
||||
if (crossingMode == 1 && canBuildCrossing && tileElement->GetType() == TileElementType::Path
|
||||
if (crossingMode == CreateCrossingMode::trackOverPath && canBuildCrossing && tileElement->GetType() == TileElementType::Path
|
||||
&& tileElement->GetBaseZ() == pos.baseZ && !tileElement->AsPath()->IsQueue() && !tileElement->AsPath()->IsSloped())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// Crossing mode 2: building path over track
|
||||
else if (
|
||||
crossingMode == 2 && canBuildCrossing && tileElement->GetType() == TileElementType::Track
|
||||
&& tileElement->GetBaseZ() == pos.baseZ && tileElement->AsTrack()->GetTrackType() == TrackElemType::Flat)
|
||||
crossingMode == CreateCrossingMode::pathOverTrack && canBuildCrossing
|
||||
&& tileElement->GetType() == TileElementType::Track && tileElement->GetBaseZ() == pos.baseZ
|
||||
&& tileElement->AsTrack()->GetTrackType() == TrackElemType::Flat)
|
||||
{
|
||||
auto ride = GetRide(tileElement->AsTrack()->GetRideIndex());
|
||||
if (ride != nullptr && ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS))
|
||||
@@ -123,7 +122,8 @@ static bool MapLoc68BABCShouldContinue(
|
||||
* bl = bl
|
||||
*/
|
||||
GameActions::Result MapCanConstructWithClearAt(
|
||||
const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, uint8_t crossingMode, bool isTree)
|
||||
const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, CreateCrossingMode crossingMode,
|
||||
bool isTree)
|
||||
{
|
||||
auto res = GameActions::Result();
|
||||
|
||||
|
||||
@@ -22,6 +22,16 @@ class QuarterTile;
|
||||
|
||||
using CLEAR_FUNC = int32_t (*)(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price);
|
||||
|
||||
// Used when calling MapCanConstructWithClearAt();
|
||||
// This assumes that the caller has already done the check on the element it wants to place,
|
||||
// as this function can only check the element the player wants to build through.
|
||||
enum class CreateCrossingMode
|
||||
{
|
||||
none,
|
||||
trackOverPath,
|
||||
pathOverTrack,
|
||||
};
|
||||
|
||||
int32_t MapPlaceNonSceneryClearFunc(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price);
|
||||
int32_t MapPlaceSceneryClearFunc(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price);
|
||||
|
||||
@@ -32,7 +42,7 @@ struct ConstructClearResult
|
||||
|
||||
[[nodiscard]] GameActions::Result MapCanConstructWithClearAt(
|
||||
const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags,
|
||||
uint8_t crossingMode = CREATE_CROSSING_MODE_NONE, bool isTree = false);
|
||||
CreateCrossingMode crossingMode = CreateCrossingMode::none, bool isTree = false);
|
||||
|
||||
[[nodiscard]] GameActions::Result MapCanConstructAt(const CoordsXYRangedZ& pos, QuarterTile bl);
|
||||
|
||||
|
||||
@@ -91,16 +91,6 @@ enum
|
||||
MAP_SELECT_TYPE_EDGE_3,
|
||||
};
|
||||
|
||||
// Used when calling MapCanConstructWithClearAt();
|
||||
// This assumes that the caller has already done the check on the element it wants to place,
|
||||
// as this function can only check the element the player wants to build through.
|
||||
enum
|
||||
{
|
||||
CREATE_CROSSING_MODE_NONE,
|
||||
CREATE_CROSSING_MODE_TRACK_OVER_PATH,
|
||||
CREATE_CROSSING_MODE_PATH_OVER_TRACK,
|
||||
};
|
||||
|
||||
extern const std::array<CoordsXY, 8> CoordsDirectionDelta;
|
||||
extern const TileCoordsXY TileDirectionDelta[];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user