Skip to content

Commit

Permalink
Refactored calls to finalizeScenario for consistency
Browse files Browse the repository at this point in the history
Consolidated static import usage for finalizeScenario and updated its calls to ensure better clarity and prevent redundant re-finalization. Added a check to avoid re-finalizing already finalized scenarios within Stratcon operations.
  • Loading branch information
IllianiCBT committed Jan 8, 2025
1 parent adb33bd commit 4964496
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import static megamek.common.UnitType.*;
import static mekhq.campaign.force.Force.FORCE_NONE;
import static mekhq.campaign.icons.enums.OperationalStatus.determineLayeredForceIconOperationalStatus;
import static mekhq.campaign.mission.AtBDynamicScenarioFactory.finalizeScenario;
import static mekhq.campaign.mission.ScenarioForceTemplate.ForceAlignment.Allied;
import static mekhq.campaign.mission.ScenarioForceTemplate.ForceAlignment.Opposing;
import static mekhq.campaign.mission.ScenarioMapParameters.MapLocation.AllGroundTerrain;
Expand Down Expand Up @@ -594,7 +595,7 @@ private static void finalizeBackingScenario(Campaign campaign, AtBContract contr
}

// Finally, finish scenario set up
AtBDynamicScenarioFactory.finalizeScenario(backingScenario, contract, campaign);
finalizeScenario(backingScenario, contract, campaign);
setScenarioParametersFromBiome(track, scenario);
swapInPlayerUnits(scenario, campaign, FORCE_NONE);

Expand Down Expand Up @@ -973,9 +974,11 @@ public static void deployForceToCoords(StratconCoords coords, int forceID, Campa
// afterward
StratconScenario revealedScenario = track.getScenario(coords);
if (revealedScenario != null) {
if (!revealedScenario.getBackingScenario().isFinalized()) {
finalizeScenario(revealedScenario.getBackingScenario(), contract, campaign);
setScenarioParametersFromBiome(track, revealedScenario);
}
revealedScenario.addPrimaryForce(forceID);
AtBDynamicScenarioFactory.finalizeScenario(revealedScenario.getBackingScenario(), contract, campaign);
setScenarioParametersFromBiome(track, revealedScenario);
commitPrimaryForces(campaign, revealedScenario, track);
return;
}
Expand Down

0 comments on commit 4964496

Please sign in to comment.