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

Make MapPlaceClearFunc() return bool, fix name of CLEAR_FUNC

This commit is contained in:
Gymnasiast
2025-11-29 13:50:17 +01:00
parent 4828fbd918
commit c90ce582fd
4 changed files with 23 additions and 24 deletions

View File

@@ -347,16 +347,16 @@ namespace OpenRCT2::GameActions
MapInvalidateTileFull(_coords); MapInvalidateTileFull(_coords);
} }
int32_t LandSetHeightAction::MapSetLandHeightClearFunc( bool LandSetHeightAction::MapSetLandHeightClearFunc(
TileElement** tile_element, [[maybe_unused]] const CoordsXY& coords, [[maybe_unused]] uint8_t flags, TileElement** tile_element, [[maybe_unused]] const CoordsXY& coords, [[maybe_unused]] uint8_t flags,
[[maybe_unused]] money64* price) [[maybe_unused]] money64* price)
{ {
if ((*tile_element)->GetType() == TileElementType::Surface) if ((*tile_element)->GetType() == TileElementType::Surface)
return 0; return true;
if ((*tile_element)->GetType() == TileElementType::SmallScenery) if ((*tile_element)->GetType() == TileElementType::SmallScenery)
return 0; return true;
return 1; return false;
} }
} // namespace OpenRCT2::GameActions } // namespace OpenRCT2::GameActions

View File

@@ -46,7 +46,7 @@ namespace OpenRCT2::GameActions
* *
* rct2: 0x00663CB9 * rct2: 0x00663CB9
*/ */
static int32_t MapSetLandHeightClearFunc( static bool MapSetLandHeightClearFunc(
TileElement** tile_element, [[maybe_unused]] const CoordsXY& coords, [[maybe_unused]] uint8_t flags, TileElement** tile_element, [[maybe_unused]] const CoordsXY& coords, [[maybe_unused]] uint8_t flags,
[[maybe_unused]] money64* price); [[maybe_unused]] money64* price);
}; };

View File

@@ -35,14 +35,14 @@
using namespace OpenRCT2; using namespace OpenRCT2;
static int32_t MapPlaceClearFunc( static bool MapPlaceClearFunc(
TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price, bool is_scenery) TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price, bool is_scenery)
{ {
if ((*tile_element)->GetType() != TileElementType::SmallScenery) if ((*tile_element)->GetType() != TileElementType::SmallScenery)
return 1; return false;
if (is_scenery && !(flags & GAME_COMMAND_FLAG_TRACK_DESIGN)) if (is_scenery && !(flags & GAME_COMMAND_FLAG_TRACK_DESIGN))
return 1; return false;
auto* scenery = (*tile_element)->AsSmallScenery()->GetEntry(); auto* scenery = (*tile_element)->AsSmallScenery()->GetEntry();
@@ -50,31 +50,31 @@ static int32_t MapPlaceClearFunc(
if (park.flags & PARK_FLAGS_FORBID_TREE_REMOVAL) if (park.flags & PARK_FLAGS_FORBID_TREE_REMOVAL)
{ {
if (scenery != nullptr && scenery->HasFlag(SMALL_SCENERY_FLAG_IS_TREE)) if (scenery != nullptr && scenery->HasFlag(SMALL_SCENERY_FLAG_IS_TREE))
return 1; return false;
} }
if (!(park.flags & PARK_FLAGS_NO_MONEY) && scenery != nullptr) if (!(park.flags & PARK_FLAGS_NO_MONEY) && scenery != nullptr)
*price += scenery->removal_price; *price += scenery->removal_price;
if (flags & GAME_COMMAND_FLAG_GHOST) if (flags & GAME_COMMAND_FLAG_GHOST)
return 0; return true;
if (!(flags & GAME_COMMAND_FLAG_APPLY)) if (!(flags & GAME_COMMAND_FLAG_APPLY))
return 0; return true;
MapInvalidateTile({ coords, (*tile_element)->GetBaseZ(), (*tile_element)->GetClearanceZ() }); MapInvalidateTile({ coords, (*tile_element)->GetBaseZ(), (*tile_element)->GetClearanceZ() });
TileElementRemove(*tile_element); TileElementRemove(*tile_element);
(*tile_element)--; (*tile_element)--;
return 0; return true;
} }
/** /**
* *
* rct2: 0x006E0D6E, 0x006B8D88 * rct2: 0x006E0D6E, 0x006B8D88
*/ */
int32_t MapPlaceSceneryClearFunc(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price) bool MapPlaceSceneryClearFunc(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price)
{ {
return MapPlaceClearFunc(tile_element, coords, flags, price, /*is_scenery=*/true); return MapPlaceClearFunc(tile_element, coords, flags, price, /*is_scenery=*/true);
} }
@@ -83,7 +83,7 @@ int32_t MapPlaceSceneryClearFunc(TileElement** tile_element, const CoordsXY& coo
* *
* rct2: 0x006C5A4F, 0x006CDE57, 0x006A6733, 0x0066637E * rct2: 0x006C5A4F, 0x006CDE57, 0x006A6733, 0x0066637E
*/ */
int32_t MapPlaceNonSceneryClearFunc(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price) bool MapPlaceNonSceneryClearFunc(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price)
{ {
return MapPlaceClearFunc(tile_element, coords, flags, price, /*is_scenery=*/false); return MapPlaceClearFunc(tile_element, coords, flags, price, /*is_scenery=*/false);
} }
@@ -122,12 +122,12 @@ static bool landSlopeFitsUnderPath(int32_t baseZ, uint8_t slope, const PathEleme
} }
static bool MapLoc68BABCShouldContinue( static bool MapLoc68BABCShouldContinue(
TileElement** tileElementPtr, const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, const uint8_t flags, money64& price, TileElement** tileElementPtr, const CoordsXYRangedZ& pos, ClearingFunction clearFunc, const uint8_t flags, money64& price,
const CreateCrossingMode crossingMode, const bool canBuildCrossing, const uint8_t slope) const CreateCrossingMode crossingMode, const bool canBuildCrossing, const uint8_t slope)
{ {
if (clearFunc != nullptr) if (clearFunc != nullptr)
{ {
if (!clearFunc(tileElementPtr, pos, flags, &price)) if (clearFunc(tileElementPtr, pos, flags, &price))
{ {
return true; return true;
} }
@@ -182,8 +182,8 @@ static bool MapLoc68BABCShouldContinue(
* bl = bl * bl = bl
*/ */
GameActions::Result MapCanConstructWithClearAt( GameActions::Result MapCanConstructWithClearAt(
const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, const QuarterTile quarterTile, const uint8_t flags, const uint8_t slope, const CoordsXYRangedZ& pos, ClearingFunction clearFunc, const QuarterTile quarterTile, const uint8_t flags,
const CreateCrossingMode crossingMode, const bool isTree) const uint8_t slope, const CreateCrossingMode crossingMode, const bool isTree)
{ {
auto res = GameActions::Result(); auto res = GameActions::Result();
@@ -241,7 +241,7 @@ GameActions::Result MapCanConstructWithClearAt(
groundFlags |= ELEMENT_IS_UNDERWATER; groundFlags |= ELEMENT_IS_UNDERWATER;
if (waterHeight < pos.clearanceZ) if (waterHeight < pos.clearanceZ)
{ {
if (clearFunc != nullptr && clearFunc(&tileElement, pos, flags, &res.Cost)) if (clearFunc != nullptr && !clearFunc(&tileElement, pos, flags, &res.Cost))
{ {
res.Error = GameActions::Status::NoClearance; res.Error = GameActions::Status::NoClearance;
res.ErrorMessage = STR_CANNOT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_WATER; res.ErrorMessage = STR_CANNOT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_WATER;

View File

@@ -23,7 +23,7 @@ struct CoordsXY;
struct CoordsXYRangedZ; struct CoordsXYRangedZ;
class QuarterTile; class QuarterTile;
using CLEAR_FUNC = int32_t (*)(OpenRCT2::TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price); using ClearingFunction = bool (*)(OpenRCT2::TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price);
enum enum
{ {
@@ -42,9 +42,8 @@ enum class CreateCrossingMode
pathOverTrack, pathOverTrack,
}; };
int32_t MapPlaceNonSceneryClearFunc( bool MapPlaceNonSceneryClearFunc(OpenRCT2::TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price);
OpenRCT2::TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price); bool MapPlaceSceneryClearFunc(OpenRCT2::TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price);
int32_t MapPlaceSceneryClearFunc(OpenRCT2::TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money64* price);
struct ConstructClearResult struct ConstructClearResult
{ {
@@ -52,7 +51,7 @@ struct ConstructClearResult
}; };
[[nodiscard]] OpenRCT2::GameActions::Result MapCanConstructWithClearAt( [[nodiscard]] OpenRCT2::GameActions::Result MapCanConstructWithClearAt(
const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, uint8_t slope, const CoordsXYRangedZ& pos, ClearingFunction clearFunc, QuarterTile quarterTile, uint8_t flags, uint8_t slope,
CreateCrossingMode crossingMode = CreateCrossingMode::none, bool isTree = false); CreateCrossingMode crossingMode = CreateCrossingMode::none, bool isTree = false);
[[nodiscard]] OpenRCT2::GameActions::Result MapCanConstructAt(const CoordsXYRangedZ& pos, QuarterTile bl); [[nodiscard]] OpenRCT2::GameActions::Result MapCanConstructAt(const CoordsXYRangedZ& pos, QuarterTile bl);