Fix #14172: Assertion hit in window_tile_inspector_swap_elements()

This commit is contained in:
Michael Steenbeek 2021-03-07 14:53:44 +01:00 committed by GitHub
parent 6a11dbf0c9
commit 55fea26a96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -599,8 +599,12 @@ static void window_tile_inspector_rotate_element(int32_t elementIndex)
// Swap element with its parent
static void window_tile_inspector_swap_elements(int16_t first, int16_t second)
{
openrct2_assert(first >= 0 && first < windowTileInspectorElementCount, "first out of range");
openrct2_assert(second >= 0 && second < windowTileInspectorElementCount, "second out of range");
bool firstInRange = first >= 0 && first < windowTileInspectorElementCount;
bool secondInRange = second >= 0 && second < windowTileInspectorElementCount;
// This might happen if two people are modifying the same tile.
if (!firstInRange || !secondInRange)
return;
auto modifyTile = TileModifyAction(windowTileInspectorToolMap, TileModifyType::AnySwap, first, second);
GameActions::Execute(&modifyTile);
}