Fixes slow AI turns caused by not being able to build new colonies. This is a temporary fix that should be removed when BuildColonyMissions are building colonies according to a grand plan (and the costly searches per unit therefor can be avoided).

This commit is contained in:
Stian Grenborgen 2023-05-02 19:01:17 +02:00
parent 18c969071e
commit 146923ee2e
1 changed files with 11 additions and 0 deletions

View File

@ -1795,11 +1795,22 @@ public class EuropeanAIPlayer extends MissionAIPlayer {
done.clear(); done.clear();
} }
if (nBuilders > 0) { if (nBuilders > 0) {
/*
* Temporary fix for endless amount of colonists not being assigned
* any mission. See BR#3322
*/
final int MAX_BUILDING_MISSION_TRIES = 50;
int tries = 0;
for (AIUnit aiUnit : sort(aiUnits, builderComparator)) { for (AIUnit aiUnit : sort(aiUnits, builderComparator)) {
if (aiUnit.getUnit().isArmed() && getGame().getTurn().getNumber() > 20) { if (aiUnit.getUnit().isArmed() && getGame().getTurn().getNumber() > 20) {
// Quickfix to avoid having all soldies being given a BuildColonyMission. // Quickfix to avoid having all soldies being given a BuildColonyMission.
continue; continue;
} }
tries++;
if (tries > MAX_BUILDING_MISSION_TRIES) {
break;
}
final Location oldTarget = ((m = aiUnit.getMission()) == null) final Location oldTarget = ((m = aiUnit.getMission()) == null)
? null : m.getTarget(); ? null : m.getTarget();
if ((m = getBuildColonyMission(aiUnit, null)) == null) if ((m = getBuildColonyMission(aiUnit, null)) == null)