Fix #14751: Height limitation also affects trees

This commit is contained in:
Michael Steenbeek 2021-06-08 22:02:17 +02:00 committed by GitHub
parent 072772af7b
commit 1031be9078
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 10 deletions

View File

@ -9,6 +9,7 @@
- Feature: [#14731] Opaque water (like in RCT1).
- Change: [#14496] [Plugin] Rename Object to LoadedObject to fix conflicts with Typescript's Object interface.
- Change: [#14536] [Plugin] Rename ListView to ListViewWidget to make it consistent with names of other widgets.
- Change: [#14751] “No construction above tree height” limitation now allows placing high trees.
- Fix: [#11829] Visual glitches and crashes when using RCT1 assets from mismatched or corrupt CSG1.DAT and CSG1i.DAT files.
- Fix: [#13581] Opening the Options menu causes a noticeable drop in FPS.
- Fix: [#13894] Block brakes do not animate.

View File

@ -162,7 +162,7 @@ GameActions::Result::Ptr LargeSceneryPlaceAction::Query() const
QuarterTile quarterTile = QuarterTile{ static_cast<uint8_t>(tile->flags >> 12), 0 }.Rotate(_loc.direction);
if (!map_can_construct_with_clear_at(
{ curTile, zLow, zHigh }, &map_place_scenery_clear_func, quarterTile, GetFlags(), &supportsCost,
CREATE_CROSSING_MODE_NONE))
CREATE_CROSSING_MODE_NONE, (sceneryEntry->flags & LARGE_SCENERY_FLAG_IS_TREE) != 0))
{
return std::make_unique<LargeSceneryPlaceActionResult>(
GameActions::Status::NoClearance, gGameCommandErrorText, gCommonFormatArgs);
@ -260,7 +260,7 @@ GameActions::Result::Ptr LargeSceneryPlaceAction::Execute() const
QuarterTile quarterTile = QuarterTile{ static_cast<uint8_t>(tile->flags >> 12), 0 }.Rotate(_loc.direction);
if (!map_can_construct_with_clear_at(
{ curTile, zLow, zHigh }, &map_place_scenery_clear_func, quarterTile, GetFlags(), &supportsCost,
CREATE_CROSSING_MODE_NONE))
CREATE_CROSSING_MODE_NONE, (sceneryEntry->flags & LARGE_SCENERY_FLAG_IS_TREE) != 0))
{
return std::make_unique<LargeSceneryPlaceActionResult>(
GameActions::Status::NoClearance, gGameCommandErrorText, gCommonFormatArgs);

View File

@ -280,7 +280,7 @@ GameActions::Result::Ptr SmallSceneryPlaceAction::Query() const
if (!map_can_construct_with_clear_at(
{ _loc, zLow, zHigh }, &map_place_scenery_clear_func, quarterTile, GetFlags(), &clearCost,
CREATE_CROSSING_MODE_NONE))
CREATE_CROSSING_MODE_NONE, scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_IS_TREE)))
{
return std::make_unique<SmallSceneryPlaceActionResult>(
GameActions::Status::Disallowed, gGameCommandErrorText, gCommonFormatArgs);
@ -418,7 +418,7 @@ GameActions::Result::Ptr SmallSceneryPlaceAction::Execute() const
if (!map_can_construct_with_clear_at(
{ _loc, zLow, zHigh }, &map_place_scenery_clear_func, quarterTile, GetFlags() | GAME_COMMAND_FLAG_APPLY, &clearCost,
CREATE_CROSSING_MODE_NONE))
CREATE_CROSSING_MODE_NONE, scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_IS_TREE)))
{
return std::make_unique<SmallSceneryPlaceActionResult>(
GameActions::Status::Disallowed, gGameCommandErrorText, gCommonFormatArgs);

View File

@ -144,6 +144,7 @@ void LargeSceneryObject::ReadJson(IReadObjectContext* context, json_t& root)
{ "hasSecondaryColour", LARGE_SCENERY_FLAG_HAS_SECONDARY_COLOUR },
{ "isAnimated", LARGE_SCENERY_FLAG_ANIMATED },
{ "isPhotogenic", LARGE_SCENERY_FLAG_PHOTOGENIC },
{ "isTree", LARGE_SCENERY_FLAG_IS_TREE },
});
// Tiles

View File

@ -1298,7 +1298,7 @@ void map_obstruction_set_error_text(TileElement* tileElement, GameActions::Resul
* bl = bl
*/
std::unique_ptr<GameActions::ConstructClearResult> MapCanConstructWithClearAt(
const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, uint8_t crossingMode)
const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, uint8_t crossingMode, bool isTree)
{
int32_t northZ, eastZ, baseHeight, southZ, westZ, water_height;
northZ = eastZ = baseHeight = southZ = westZ = water_height = 0;
@ -1350,7 +1350,7 @@ std::unique_ptr<GameActions::ConstructClearResult> MapCanConstructWithClearAt(
}
}
loc_68B9B7:
if (gParkFlags & PARK_FLAGS_FORBID_HIGH_CONSTRUCTION)
if (gParkFlags & PARK_FLAGS_FORBID_HIGH_CONSTRUCTION && !isTree)
{
auto heightFromGround = pos.clearanceZ - tileElement->GetBaseZ();
@ -1477,9 +1477,9 @@ std::unique_ptr<GameActions::ConstructClearResult> MapCanConstructWithClearAt(
bool map_can_construct_with_clear_at(
const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, money32* price,
uint8_t crossingMode)
uint8_t crossingMode, bool isTree)
{
auto res = MapCanConstructWithClearAt(pos, clearFunc, quarterTile, flags, crossingMode);
auto res = MapCanConstructWithClearAt(pos, clearFunc, quarterTile, flags, crossingMode, isTree);
if (auto message = res->ErrorMessage.AsStringId())
gGameCommandErrorText = *message;
else

View File

@ -237,9 +237,10 @@ int32_t map_place_non_scenery_clear_func(TileElement** tile_element, const Coord
int32_t map_place_scenery_clear_func(TileElement** tile_element, const CoordsXY& coords, uint8_t flags, money32* price);
bool map_can_construct_with_clear_at(
const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, money32* price,
uint8_t crossingMode);
uint8_t crossingMode, bool isTree = false);
std::unique_ptr<GameActions::ConstructClearResult> MapCanConstructWithClearAt(
const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, uint8_t crossingMode);
const CoordsXYRangedZ& pos, CLEAR_FUNC clearFunc, QuarterTile quarterTile, uint8_t flags, uint8_t crossingMode,
bool isTree = false);
std::unique_ptr<GameActions::ConstructClearResult> MapCanConstructAt(const CoordsXYRangedZ& pos, QuarterTile bl);
int32_t map_can_construct_at(const CoordsXYRangedZ& pos, QuarterTile bl);

View File

@ -96,6 +96,7 @@ enum LARGE_SCENERY_FLAGS
LARGE_SCENERY_FLAG_3D_TEXT = (1 << 2), // 0x4
LARGE_SCENERY_FLAG_ANIMATED = (1 << 3), // 0x8
LARGE_SCENERY_FLAG_PHOTOGENIC = (1 << 4), // 0x10
LARGE_SCENERY_FLAG_IS_TREE = (1 << 5), // 0x20
};
enum WALL_SCENERY_FLAGS