Fix non-structures being deleteable (#4385)

Resolves #4307

## Description:
Adds a check for the "delete" element of the raidial menu, to make sure
the unit attemped to be removed is a structure.
Previously, non-structure units such as trains could be deleted using
the menu.

## Please complete the following:

- [ ] I have added screenshots for all UI updates (No UI updates)
- [ ] I process any text displayed to the user through translateText()
and I've added it to the en.json file (No text added)
- [ ] I have added relevant tests to the test directory (Not sure how
this works or if it's needed)

## Please put your Discord username so you can be contacted if a bug or
regression is found:

unne27

---------

Co-authored-by: unne27 <uno.gunnar.johansson@gmail.com>
This commit is contained in:
unne27
2026-06-24 02:17:57 +02:00
committed by GitHub
parent c55ea6bb5a
commit 06cc01668b
+5 -1
View File
@@ -528,6 +528,7 @@ export const deleteUnitElement: MenuElement = {
(unit) =>
!unit.isUnderConstruction() &&
unit.markedForDeletion() === false &&
Structures.has(unit.type()) &&
params.game.manhattanDist(unit.tile(), params.tile) <=
DELETE_SELECTION_RADIUS,
);
@@ -552,8 +553,11 @@ export const deleteUnitElement: MenuElement = {
.units()
.filter(
(unit) =>
!unit.isUnderConstruction() &&
unit.markedForDeletion() === false &&
Structures.has(unit.type()) &&
params.game.manhattanDist(unit.tile(), params.tile) <=
DELETE_SELECTION_RADIUS,
DELETE_SELECTION_RADIUS,
);
const closestUnit = findClosestBy(myUnits, (unit) =>