mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Consistently sort the build order
When the returned value of the compare function is `0` the order is preserved. Before the sort, the order between joining clients and non-joining clients differ. Now everything important (which is used later on) is included in the comparison. If still `0` is returned it's not importent which element is taken. Another solution would be to have one array per category.
This commit is contained in:
parent
c4dd0040ee
commit
b572fed672
1 changed files with 10 additions and 1 deletions
|
|
@ -642,7 +642,16 @@ AttackPlan.prototype.trainMoreUnits = function(gameState)
|
|||
let vb = b[0]/b[3].targetSize - b[3].priority;
|
||||
if (b[0] >= b[3].targetSize)
|
||||
vb += 1000;
|
||||
return va - vb;
|
||||
|
||||
const calcResult = va - vb;
|
||||
if (calcResult !== 0)
|
||||
return calcResult;
|
||||
|
||||
if (a[4] < b[4])
|
||||
return 1;
|
||||
if (a[4] > b[4])
|
||||
return -1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
if (this.Config.debug > 1 && gameState.ai.playedTurn%50 === 0)
|
||||
|
|
|
|||
Loading…
Reference in a new issue