Skip to content

Commit 6f2a1f8

Browse files
committed
Fix edge case where ground raising tools did not consider Morphable when checking for incorrect cell heights
1 parent d794e59 commit 6f2a1f8

3 files changed

Lines changed: 29 additions & 58 deletions

File tree

src/TSMapEditor/Mutations/Classes/HeightMutations/AlterElevationMutationBase.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,35 @@ protected void ProcessCells()
127127

128128
protected abstract void ApplyRamps();
129129

130+
protected void CellHeightFix_DifferentHeightDiffsOnStraightLine(Point2D cellCoords, Point2D offset1, Point2D offset2)
131+
{
132+
var cell = Map.GetTile(cellCoords);
133+
if (cell == null)
134+
return;
135+
136+
if (!IsCellMorphable(cell))
137+
return;
138+
139+
int totalLevelDifference = 0;
140+
141+
Point2D otherCellCoords = cellCoords + offset1;
142+
var otherCell = Map.GetTile(otherCellCoords);
143+
if (otherCell != null && IsCellMorphable(otherCell))
144+
totalLevelDifference += otherCell.Level - cell.Level;
145+
146+
otherCellCoords = cellCoords + offset2;
147+
otherCell = Map.GetTile(otherCellCoords);
148+
if (otherCell != null && IsCellMorphable(otherCell))
149+
totalLevelDifference += otherCell.Level - cell.Level;
150+
151+
if (totalLevelDifference >= 3)
152+
{
153+
AddCellToUndoData(cell.CoordsToPoint());
154+
cell.ChangeTileIndex(0, 0);
155+
cell.Level++;
156+
}
157+
}
158+
130159
private void RefreshLighting()
131160
{
132161
for (int i = 0; i < totalProcessedCells.Count; i++)

src/TSMapEditor/Mutations/Classes/HeightMutations/FlattenGroundMutation.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -291,35 +291,6 @@ private void CellHeightFix_CheckStraightDiagonalLine(Point2D cellCoords, List<Po
291291
}
292292
}
293293

294-
private void CellHeightFix_DifferentHeightDiffsOnStraightLine(Point2D cellCoords, Point2D offset1, Point2D offset2)
295-
{
296-
var cell = Map.GetTile(cellCoords);
297-
if (cell == null)
298-
return;
299-
300-
if (!IsCellMorphable(cell))
301-
return;
302-
303-
int totalLevelDifference = 0;
304-
305-
Point2D otherCellCoords = cellCoords + offset1;
306-
var otherCell = Map.GetTile(otherCellCoords);
307-
if (otherCell != null && IsCellMorphable(otherCell))
308-
totalLevelDifference += otherCell.Level - cell.Level;
309-
310-
otherCellCoords = cellCoords + offset2;
311-
otherCell = Map.GetTile(otherCellCoords);
312-
if (otherCell != null && IsCellMorphable(otherCell))
313-
totalLevelDifference += otherCell.Level - cell.Level;
314-
315-
if (totalLevelDifference >= 3)
316-
{
317-
AddCellToUndoData(cell.CoordsToPoint());
318-
cell.ChangeTileIndex(0, 0);
319-
cell.Level++;
320-
}
321-
}
322-
323294
/// <summary>
324295
/// Applies miscellaneous fixes to height data of processed cells.
325296
/// </summary>

src/TSMapEditor/Mutations/Classes/HeightMutations/RaiseGroundMutationBase.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -222,35 +222,6 @@ private void CellHeightFix_CheckStraightDiagonalLine(Point2D cellCoords, List<Po
222222
}
223223
}
224224

225-
private void CellHeightFix_DifferentHeightDiffsOnStraightLine(Point2D cellCoords, Point2D offset1, Point2D offset2)
226-
{
227-
var cell = Map.GetTile(cellCoords);
228-
if (cell == null)
229-
return;
230-
231-
if (!IsCellMorphable(cell))
232-
return;
233-
234-
int totalLevelDifference = 0;
235-
236-
Point2D otherCellCoords = cellCoords + offset1;
237-
var otherCell = Map.GetTile(otherCellCoords);
238-
if (otherCell != null)
239-
totalLevelDifference += otherCell.Level - cell.Level;
240-
241-
otherCellCoords = cellCoords + offset2;
242-
otherCell = Map.GetTile(otherCellCoords);
243-
if (otherCell != null)
244-
totalLevelDifference += otherCell.Level - cell.Level;
245-
246-
if (totalLevelDifference >= 3)
247-
{
248-
AddCellToUndoData(cell.CoordsToPoint());
249-
cell.ChangeTileIndex(0, 0);
250-
cell.Level++;
251-
}
252-
}
253-
254225
protected override void ApplyRamps()
255226
{
256227
foreach (var cellCoords in totalProcessedCells)

0 commit comments

Comments
 (0)