Author: cazfi
Date: Mon Aug 22 21:30:31 2016
New Revision: 33669

URL: http://svn.gna.org/viewcvs/freeciv?rev=33669&view=rev
Log:
Made Base DiplomatDefence flag to work correctly when base is within city.

See bug #24975

Modified:
    branches/S2_6/common/actions.c
    branches/S2_6/server/diplomats.c

Modified: branches/S2_6/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/actions.c?rev=33669&r1=33668&r2=33669&view=diff
==============================================================================
--- branches/S2_6/common/actions.c      (original)
+++ branches/S2_6/common/actions.c      Mon Aug 22 21:30:31 2016
@@ -1003,7 +1003,7 @@
   See diplomat_success_vs_defender() in server/diplomats.c
 **************************************************************************/
 static struct act_prob ap_dipl_battle_win(const struct unit *pattacker,
-                                             const struct unit *pdefender)
+                                          const struct unit *pdefender)
 {
   struct city *pcity;
 
@@ -1045,7 +1045,12 @@
     chance += vatt->power_fact - vdef->power_fact;
   }
 
-  /* City and base defense bonus */
+  /* City and base defense bonuses */
+  if (tile_has_base_flag_for_unit(pdefender->tile, unit_type_get(pdefender),
+                                  BF_DIPLOMAT_DEFENSE)) {
+    chance -= chance * 25 / 100;
+  }
+
   pcity = tile_city(pdefender->tile);
   if (pcity) {
     if (!is_effect_val_known(EFT_SPY_RESISTANT, unit_owner(pattacker),
@@ -1056,11 +1061,6 @@
 
     chance -= chance * get_city_bonus(tile_city(pdefender->tile),
                                       EFT_SPY_RESISTANT) / 100;
-  } else {
-    if (tile_has_base_flag_for_unit(pdefender->tile, unit_type_get(pdefender),
-                                    BF_DIPLOMAT_DEFENSE)) {
-      chance -= chance * 25 / 100;
-    }
   }
 
   /* Convert to action probability */

Modified: branches/S2_6/server/diplomats.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/diplomats.c?rev=33669&r1=33668&r2=33669&view=diff
==============================================================================
--- branches/S2_6/server/diplomats.c    (original)
+++ branches/S2_6/server/diplomats.c    Mon Aug 22 21:30:31 2016
@@ -1267,16 +1267,16 @@
     chance += vatt->power_fact - vdef->power_fact;
   }
 
+  /* Reduce the chance of an attack if BF_DIPLOMAT_DEFENSE is active. */
+  if (tile_has_base_flag_for_unit(pdefender_tile, unit_type_get(pdefender),
+                                  BF_DIPLOMAT_DEFENSE)) {
+    chance -= chance * 25 / 100; /* 25% penalty */
+  }
+
   if (tile_city(pdefender_tile)) {
     /* Reduce the chance of an attack by EFT_SPY_RESISTANT percent. */
     chance -= chance * get_city_bonus(tile_city(pdefender_tile),
                                       EFT_SPY_RESISTANT) / 100;
-  } else {
-    /* Reduce the chance of an attack if BF_DIPLOMAT_DEFENSE is active. */
-    if (tile_has_base_flag_for_unit(pdefender_tile, unit_type_get(pdefender),
-                                    BF_DIPLOMAT_DEFENSE)) {
-      chance -= chance * 25 / 100; /* 25% penalty */
-    }
   }
 
   return (int)fc_rand(100) < chance;


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

Reply via email to