mirror of https://github.com/FreeCol/freecol.git
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:
parent
18c969071e
commit
146923ee2e
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue