Summary: Minor optimization to has_defense()
                 Project: Freeciv
            Submitted by: cazfi
            Submitted on: Wed 06 Feb 2013 05:08:56 AM EET
                Category: ai
                Priority: 5 - Normal
                  Status: Ready For Test
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: 2.5.0



As has_defense() wants to know only if unit has any defense power at all, call
base_get_defense_power() instead of get_defense_power(). Latter only
multiplies result of former with positive value -> if former returns 0, so
does multiplied, if former returns non-zero, so does multiplied.

This alone is minor optimization, but getting rid of one call to
get_defense_power() is also step towards rivers as road types. Currently river
defense bonus is applied in get_defense_bonus(), while road bonuses apply in
defense_multiplication(). Any call to get_defense_bonus() without
defense_multiplication() call would get different result when river is handled
as road type. I want to clean up that interface a bit.


File Attachments:

Date: Wed 06 Feb 2013 05:08:56 AM EET  Name: HasDefenseOptimization.patch 
Size: 558B   By: cazfi



Reply to this item at:


  Message sent via/by Gna!

Freeciv-dev mailing list

Reply via email to