Author: cazfi
Date: Fri Jan  9 21:29:42 2015
New Revision: 27595

URL: http://svn.gna.org/viewcvs/freeciv?rev=27595&view=rev
Log:
Optimized unit upkeep calculation for the usual case of Shield2Gold not being 
active for it.

See patch #5663

Modified:
    trunk/common/unittype.c

Modified: trunk/common/unittype.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/unittype.c?rev=27595&r1=27594&r2=27595&view=diff
==============================================================================
--- trunk/common/unittype.c     (original)
+++ trunk/common/unittype.c     Fri Jan  9 21:29:42 2015
@@ -143,10 +143,11 @@
        conversion factor in percent) and
      - the unit has the corresponding flag set (UTYF_SHIELD2GOLD)
      FIXME: Should the ai know about this? */
-  gold_upkeep_factor = get_player_bonus(pplayer, EFT_SHIELD2GOLD_FACTOR);
-  gold_upkeep_factor = (gold_upkeep_factor > 0) ? gold_upkeep_factor : 0;
-  if (gold_upkeep_factor > 0 && utype_has_flag(ut, UTYF_SHIELD2GOLD)) {
-    switch (otype) {
+  if (utype_has_flag(ut, UTYF_SHIELD2GOLD)
+      && (otype == O_GOLD || otype == O_SHIELD)) {
+    gold_upkeep_factor = get_player_bonus(pplayer, EFT_SHIELD2GOLD_FACTOR);
+    if (gold_upkeep_factor > 0) {
+      switch (otype) {
       case O_GOLD:
         val = ceil((0.01 * gold_upkeep_factor) * ut->upkeep[O_SHIELD]);
         break;
@@ -154,8 +155,9 @@
         val = 0;
         break;
       default:
-        /* fall through */
+        fc_assert(otype == O_GOLD || otype == O_SHIELD);
         break;
+      }
     }
   }
 


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

Reply via email to