URL:
  <http://gna.org/patch/?3671>

                 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

    _______________________________________________________

Details:

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

<http://gna.org/patch/download.php?file_id=17139>

    _______________________________________________________

Reply to this item at:

  <http://gna.org/patch/?3671>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to