From 4cab9da226096cfc2f46129bc0582de6eb1622f0 Mon Sep 17 00:00:00 2001 From: Starkku Date: Wed, 19 Jun 2024 18:32:14 +0300 Subject: [PATCH] Add missing cell height checks --- .../Mutations/Classes/HeightMutations/LowerCellsMutation.cs | 4 ++++ .../Mutations/Classes/HeightMutations/RaiseCellsMutation.cs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/TSMapEditor/Mutations/Classes/HeightMutations/LowerCellsMutation.cs b/src/TSMapEditor/Mutations/Classes/HeightMutations/LowerCellsMutation.cs index 3b0f4a99..2985b0ef 100644 --- a/src/TSMapEditor/Mutations/Classes/HeightMutations/LowerCellsMutation.cs +++ b/src/TSMapEditor/Mutations/Classes/HeightMutations/LowerCellsMutation.cs @@ -45,6 +45,10 @@ public override void Perform() else { var targetTile = MutationTarget.Map.GetTile(targetCellCoords); + + if (targetTile == null || targetTile.Level <= 0) + return; + var tilesToProcess = Helpers.GetFillAreaTiles(targetTile, MutationTarget.Map, MutationTarget.TheaterGraphics); // Process tiles diff --git a/src/TSMapEditor/Mutations/Classes/HeightMutations/RaiseCellsMutation.cs b/src/TSMapEditor/Mutations/Classes/HeightMutations/RaiseCellsMutation.cs index 6251103a..82253d4d 100644 --- a/src/TSMapEditor/Mutations/Classes/HeightMutations/RaiseCellsMutation.cs +++ b/src/TSMapEditor/Mutations/Classes/HeightMutations/RaiseCellsMutation.cs @@ -46,6 +46,10 @@ public override void Perform() else { var targetTile = MutationTarget.Map.GetTile(targetCellCoords); + + if (targetTile == null || targetTile.Level >= Constants.MaxMapHeightLevel) + return; + var tilesToProcess = Helpers.GetFillAreaTiles(targetTile, MutationTarget.Map, MutationTarget.TheaterGraphics); // Process tiles