1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 20:43:04 +01:00

Create function for map_can_build_at

This commit is contained in:
duncanspumpkin
2017-03-13 21:47:43 +00:00
parent 6878341214
commit 132721128e
3 changed files with 18 additions and 10 deletions

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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);