Skip to content

Commit a94364f

Browse files
committed
Fix force updates after removal in TOEMouseAdapter
Ensured all forces are re-evaluated after a force is removed to account for potential changes in organization. This triggers an `OrganizationChangedEvent` for each force, maintaining consistency even in large campaigns.
1 parent 60328bb commit a94364f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
import mekhq.campaign.mission.Scenario;
4040
import mekhq.campaign.personnel.Person;
4141
import mekhq.campaign.personnel.enums.PersonnelRole;
42-
import mekhq.campaign.unit.*;
42+
import mekhq.campaign.unit.HangarSorter;
43+
import mekhq.campaign.unit.Unit;
4344
import mekhq.campaign.universe.Faction;
4445
import mekhq.gui.CampaignGUI;
4546
import mekhq.gui.baseComponents.JScrollableMenu;
@@ -510,6 +511,12 @@ public void actionPerformed(ActionEvent action) {
510511
gui.getCampaign().removeForce(force);
511512
}
512513
}
514+
515+
// We cycle through all forces because we need to assess how the removal affected them,
516+
// Even for truly huge campaigns this is still very cheap.
517+
for (Force force : forces) {
518+
MekHQ.triggerEvent(new OrganizationChangedEvent(gui.getCampaign(), force));
519+
}
513520
} else if (command.contains(TOEMouseAdapter.REMOVE_LANCE_TECH)) {
514521
if (null != singleForce && singleForce.getTechID() != null) {
515522
Person oldTech = gui.getCampaign().getPerson(singleForce.getTechID());

0 commit comments

Comments
 (0)