Files
0ad/binaries
Fabio Pedretti 88f5cbc922 Compute the data about the foes once per army and turn in DefenseArmy.assignUnit
assignUnit looped over all the foes of the army for every unit assigned
and, for each (unit, foe) pair, fetched the foe entity and its position,
tested its class, read its UnitAI order data (up to four times) and, when
the foe was close to saturation, tested the Hero and siege classes again.
None of this depends on the unit being assigned.

- Add the module function getFoeInfo(), which gathers once for all the
  foes of the army the entity, its position, the unit it is attacking (if
  any) and, lazily, whether it is a hero or a siege unit and its access
  index. The army keeps the result in foeInfo, which is reset when a foe
  is added, removed or renamed, and at the beginning of update(), as
  positions and orders change from one turn to the next.
- assignUnit reads that table instead of querying the entities. The foes
  are still visited in the same order and with the same checks, so the
  chosen foe is unchanged. assignedAgainst is still read live, as it
  changes while units are assigned.
- Read ent.position() only once.
2026-10-21 11:42:19 +02:00
..
…