mirror of https://github.com/FreeCol/freecol.git
Uses changeMission instead of setMission since the former handles dispose and setting transportation priority.
This commit is contained in:
parent
146923ee2e
commit
18ec0e754a
|
@ -677,7 +677,7 @@ public final class NativeAIPlayer extends MissionAIPlayer {
|
|||
for (AIUnit au : getAIUnits()) {
|
||||
Mission mission = au.getMission();
|
||||
String reason = (mission == null) ? null : mission.invalidReason();
|
||||
if (reason != null) au.setMission(null);
|
||||
if (reason != null) au.changeMission(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -205,11 +205,11 @@ public final class MilitaryCoordinator {
|
|||
continue;
|
||||
}
|
||||
|
||||
artillery.setMission(new UnitSeekAndDestroyMission(artillery.getAIMain(), artillery, possibleTarget));
|
||||
artillery.changeMission(new UnitSeekAndDestroyMission(artillery.getAIMain(), artillery, possibleTarget));
|
||||
artilleryUnits.remove(artillery);
|
||||
unusedUnits.remove(artillery);
|
||||
|
||||
escort.setMission(new EscortUnitMission(escort.getAIMain(), escort, artillery.getUnit()));
|
||||
escort.changeMission(new EscortUnitMission(escort.getAIMain(), escort, artillery.getUnit()));
|
||||
dragoonUnits.remove(escort);
|
||||
unusedUnits.remove(escort);
|
||||
|
||||
|
@ -247,7 +247,7 @@ public final class MilitaryCoordinator {
|
|||
|
||||
final PathNode path = dragoon.getUnit().findPath(enemy.getTile()); // TODO: add max turns to the search.
|
||||
if (path != null && path.getTurns() <= turns) {
|
||||
dragoon.setMission(new UnitSeekAndDestroyMission(dragoon.getAIMain(), dragoon, enemy));
|
||||
dragoon.changeMission(new UnitSeekAndDestroyMission(dragoon.getAIMain(), dragoon, enemy));
|
||||
unusedUnits.remove(dragoon);
|
||||
dragoonUnits.remove(dragoon);
|
||||
targetedEnemies.add(enemy);
|
||||
|
@ -268,7 +268,7 @@ public final class MilitaryCoordinator {
|
|||
|
||||
final PathNode path = dragoon.getUnit().findPath(enemy.getTile()); // TODO: add max turns to the search.
|
||||
if (path != null && path.getTurns() <= turns) {
|
||||
dragoon.setMission(new UnitSeekAndDestroyMission(dragoon.getAIMain(), dragoon, enemy));
|
||||
dragoon.changeMission(new UnitSeekAndDestroyMission(dragoon.getAIMain(), dragoon, enemy));
|
||||
unusedUnits.remove(dragoon);
|
||||
dragoonUnits.remove(dragoon);
|
||||
targetedEnemies.add(enemy);
|
||||
|
@ -296,7 +296,7 @@ public final class MilitaryCoordinator {
|
|||
|
||||
final PathNode path = dragoon.getUnit().findPath(enemy.getTile()); // TODO: add max turns to the search.
|
||||
if (path != null && path.getTurns() <= turns) {
|
||||
dragoon.setMission(new UnitSeekAndDestroyMission(dragoon.getAIMain(), dragoon, enemy));
|
||||
dragoon.changeMission(new UnitSeekAndDestroyMission(dragoon.getAIMain(), dragoon, enemy));
|
||||
unusedUnits.remove(dragoon);
|
||||
dragoonUnits.remove(dragoon);
|
||||
targetedEnemies.add(enemy);
|
||||
|
@ -311,7 +311,7 @@ public final class MilitaryCoordinator {
|
|||
for (AIUnit unit : new HashSet<>(unusedUnits)) {
|
||||
final Mission mission = player.getDefendSettlementMission(unit, true, true);
|
||||
if (mission != null) {
|
||||
unit.setMission(mission);
|
||||
unit.changeMission(mission);
|
||||
unusedUnits.remove(unit);
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ public final class MilitaryCoordinator {
|
|||
if (unit.getUnit().getTile() != null) {
|
||||
continue;
|
||||
}
|
||||
unit.setMission(new DefendSettlementMission(unit.getAIMain(), unit, destination.getColony()));
|
||||
unit.changeMission(new DefendSettlementMission(unit.getAIMain(), unit, destination.getColony()));
|
||||
unusedUnits.remove(unit);
|
||||
}
|
||||
}
|
||||
|
@ -357,15 +357,14 @@ public final class MilitaryCoordinator {
|
|||
|
||||
private void assignWanderHostile() {
|
||||
for (AIUnit unit : new HashSet<>(unusedUnits)) {
|
||||
unit.setMission(new UnitWanderHostileMission(unit.getAIMain(), unit));
|
||||
unit.changeMission(new UnitWanderHostileMission(unit.getAIMain(), unit));
|
||||
unusedUnits.remove(unit);
|
||||
}
|
||||
assert unusedUnits.isEmpty();
|
||||
}
|
||||
|
||||
private void placeDefender(AIUnit unit, AIColony colony) {
|
||||
unit.setMission(null);
|
||||
unit.setMission(new DefendSettlementMission(unit.getAIMain(), unit, colony.getColony()));
|
||||
unit.changeMission(new DefendSettlementMission(unit.getAIMain(), unit, colony.getColony()));
|
||||
final List<AIUnit> units = defenders.get(colony);
|
||||
units.add(unit);
|
||||
unusedUnits.remove(unit);
|
||||
|
|
|
@ -168,7 +168,7 @@ public class MissionAssignmentTest extends FreeColTestCase {
|
|||
assertTrue(colonyTile.getSettlement() == colony);
|
||||
assertTrue(colony.getOwner() == dutch);
|
||||
assertTrue(colony.getUnitCount() == 1);
|
||||
aiUnit.setMission(null);
|
||||
aiUnit.changeMission(null);
|
||||
assertEquals("DefendSettlementMission should be possible", null,
|
||||
DefendSettlementMission.invalidMissionReason(aiUnit));
|
||||
assertEquals("DefendSettlementMission should work with colony", null,
|
||||
|
|
|
@ -78,7 +78,7 @@ public class PioneeringMissionTest extends FreeColTestCase {
|
|||
colonistType);
|
||||
final AIUnit aiUnit = aiMain.getAIUnit(colonist);
|
||||
assertNotNull(aiUnit);
|
||||
aiUnit.setMission(null);
|
||||
aiUnit.changeMission(null);
|
||||
|
||||
// Check there are improvements to be made.
|
||||
aiColony.updateTileImprovementPlans(lb);
|
||||
|
|
|
@ -105,7 +105,7 @@ public class PrivateerMissionTest extends FreeColTestCase {
|
|||
AIUnit privateerAI = aiMain.getAIUnit(privateer);
|
||||
assertNotNull("Setup error, could not get privateerAI", privateerAI);
|
||||
|
||||
privateerAI.setMission(null);
|
||||
privateerAI.changeMission(null);
|
||||
assertFalse("Privateer has no mission", privateerAI.hasMission());
|
||||
assertEquals("PrivateeringMission valid", null,
|
||||
PrivateerMission.invalidMissionReason(privateerAI));
|
||||
|
|
|
@ -79,7 +79,7 @@ public class ScoutingMissionTest extends FreeColTestCase {
|
|||
assertEquals(scoutRole, scout.getRole());
|
||||
|
||||
AIUnit aiUnit = aiMain.getAIUnit(scout);
|
||||
aiUnit.setMission(null);
|
||||
aiUnit.changeMission(null);
|
||||
assertNotNull("The scout should be an AI unit", aiUnit);
|
||||
assertEquals("Scout should have the scout role", scoutRole,
|
||||
scout.getRole());
|
||||
|
|
|
@ -296,7 +296,7 @@ public class TransportMissionTest extends FreeColTestCase {
|
|||
AIUnit wagon = aiMain.getAIUnit(wagonTrain);
|
||||
assertNotNull(wagon);
|
||||
|
||||
wagon.setMission(null);
|
||||
wagon.changeMission(null);
|
||||
assertNull("Transport mission should be valid.",
|
||||
TransportMission.invalidMissionReason(wagon));
|
||||
TransportMission mission = new TransportMission(aiMain, wagon);
|
||||
|
|
Loading…
Reference in New Issue