Follow-up Comment #2, patch #3887 (project freeciv):
In pf_fuel_map_iterate(), the function exits early in the event that there
aren't enough moves to return to a refueling point unless either the unit in
question is a missle or it has no moves anyway (as mentioned, I don't really
understand the purpose of this OR condition: I would think it just wastes
cycles processing the rest of the function for units that can't move anyway).
If the unit is a missile, we can perform suicidal attacks (we don't care if we
will later be able to return to base because we wouldn't survive anyway). We
later exit early in the event that we're targeting an enemy tile and wouldn't
be safe to attack (with pf_fuel_map_attack_is_possible()).
In pf_fuel_map_attack_is_possible(), we check to see if it makes sense for
the unit to attack: for missiles, we always attack (the unit would die anyway,
so we don't care about fuel), for bombers, we only attack if we have more
moves left than our move_rate (moves_left is initialised with pf_move_rate(),
so fueled units are treated as having many more moves per turn than move_rate
to simplify the pathfinding logic), which means that we are not on the last
turn of fuel. If we are on the last turn of fuel, we don't attack, otherwise
it is safe to attack.
I agree there may be remaining issues with bombers (the logic doesn't
check to make sure that there will be enough moves_left to return to base
after the attack has been performed), but this patch doesn't change the
conditionals for bombers except in the case where fuel == 1, in which case it
is a bit more conservative (and won't actually attack: committing suicide is
only permitted for UCF_MISSILE units).
Reply to this item at:
Message sent via/by Gna!
Freeciv-dev mailing list