Author: cazfi Date: Fri Jan 9 21:29:49 2015 New Revision: 27596 URL: http://svn.gna.org/viewcvs/freeciv?rev=27596&view=rev Log: Optimized unit upkeep calculation for the usual case of Shield2Gold not being active for it.
See patch #5663 Modified: branches/S2_6/common/unittype.c Modified: branches/S2_6/common/unittype.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/unittype.c?rev=27596&r1=27595&r2=27596&view=diff ============================================================================== --- branches/S2_6/common/unittype.c (original) +++ branches/S2_6/common/unittype.c Fri Jan 9 21:29:49 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