Follow-up Comment #2, patch #4658 (project freeciv):

My initial thought (without exploring all potential uses) is that the caching
probably should happen on a per-turn basis, rather than at ruleset loading
time.  move_rate, attack, and defense already are dynamic, CanFortify,
CanOccupy, AttFromNonNative, AttackNonNative, Settlers, Cities, etc. could
presumably end up being handled by the action enablement framework, and the
various hardcoded roles would probably become obsolete with this patch (or at
least this patch would provide mechanisms by which they could become

Running once/turn is probably better than running the iterations N times per
turn in each function.  It may be sensible to have the caching obscured from
the callers, so that users of the cache call functions like
is_unit_role(L_FERRY, punit), or select_unit_for_role(L_FERRY) and the
implementations of these functions check to see if there is a cached value for
this turn, and if not, populate the cache.  Caches should be cleared on
turn-change and tech-gain.

It may be worth ignoring some specific local effects (e.g. units that have
lower move_rate when starting a turn on a mountain tile): given that there is
poor support for that class of effect in other places anyway (e.g. pathfinding
doesn't recalculate move_rate depending on the tile under consideration), this
has precedent.


Reply to this item at:


  Message sent via/by Gna!

Freeciv-dev mailing list

Reply via email to