diff --git a/src/openrct2/world/banner.cpp b/src/openrct2/world/banner.cpp index 2033fac8bd..acb576f075 100644 --- a/src/openrct2/world/banner.cpp +++ b/src/openrct2/world/banner.cpp @@ -79,7 +79,7 @@ static money32 BannerRemove(sint16 x, sint16 y, uint8 baseHeight, uint8 directio return MONEY32_UNDEFINED; } - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode && !map_is_location_owned(x, y, z - 16)) + if (!map_can_build_at(x, y, z - 16)) { return MONEY32_UNDEFINED; } @@ -131,13 +131,11 @@ static money32 BannerSetColour(sint16 x, sint16 y, uint8 baseHeight, uint8 direc gCommandPosition.y = y + 16; gCommandPosition.z = z; - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode) + if (!map_can_build_at(x, y, z - 16)) { - if (!map_is_location_owned(x, y, z - 16)) - { - return MONEY32_UNDEFINED; - } + return MONEY32_UNDEFINED; } + if (flags & GAME_COMMAND_FLAG_APPLY) { @@ -190,7 +188,7 @@ static money32 BannerPlace(sint16 x, sint16 y, uint8 pathBaseHeight, uint8 direc return MONEY32_UNDEFINED; } - if (x >= 256 * 32 || y >= 256 * 32) + if (!map_is_location_valid(x, y)) { return MONEY32_UNDEFINED; } @@ -219,9 +217,7 @@ static money32 BannerPlace(sint16 x, sint16 y, uint8 pathBaseHeight, uint8 direc return MONEY32_UNDEFINED; } - if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && - !gCheatsSandboxMode && - !map_is_location_owned(x, y, pathBaseHeight * 16)) + if (!map_can_build_at(x, y, pathBaseHeight * 16)) { return MONEY32_UNDEFINED; } diff --git a/src/openrct2/world/map.c b/src/openrct2/world/map.c index 44fcc1eaa5..391f8aede6 100644 --- a/src/openrct2/world/map.c +++ b/src/openrct2/world/map.c @@ -788,6 +788,17 @@ bool map_is_location_valid(sint32 x, sint32 y) return false; } +bool map_can_build_at(sint32 x, sint32 y, sint32 z) +{ + if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) + return true; + if (gCheatsSandboxMode) + return true; + if (map_is_location_owned(x, y, z)) + return true; + return false; +} + /** * * rct2: 0x00664F72 diff --git a/src/openrct2/world/map.h b/src/openrct2/world/map.h index ca88007207..ad8833559d 100644 --- a/src/openrct2/world/map.h +++ b/src/openrct2/world/map.h @@ -436,6 +436,7 @@ void map_remove_provisional_elements(); void map_restore_provisional_elements(); void map_update_path_wide_flags(); bool map_is_location_valid(sint32 x, sint32 y); +bool map_can_build_at(sint32 x, sint32 y, sint32 z); bool map_is_location_owned(sint32 x, sint32 y, sint32 z); bool map_is_location_in_park(sint32 x, sint32 y); bool map_is_location_owned_or_has_rights(sint32 x, sint32 y);