Author: sveinung
Date: Sun Feb 22 12:22:55 2015
New Revision: 28284

URL: http://svn.gna.org/viewcvs/freeciv?rev=28284&view=rev
Log:
Don't allow untargeted sabotage city via the targeted sabotage city action.

Consequenze: The set of situations were the targeted version of sabotage
city is allowed is no longer guaranteed to be a subset of the situations
were the untargeted version of sabotage city is allowed.

See patch #5540

Modified:
    trunk/ai/default/aidiplomat.c
    trunk/client/gui-gtk-2.0/action_dialog.c
    trunk/client/gui-gtk-3.0/action_dialog.c
    trunk/client/gui-qt/dialogs.cpp
    trunk/client/gui-sdl/action_dialog.c
    trunk/client/gui-sdl2/action_dialog.c
    trunk/client/gui-xaw/action_dialog.c
    trunk/doc/README.actions
    trunk/fc_version
    trunk/server/unithand.c

Modified: trunk/ai/default/aidiplomat.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aidiplomat.c?rev=28284&r1=28283&r2=28284&view=diff
==============================================================================
--- trunk/ai/default/aidiplomat.c       (original)
+++ trunk/ai/default/aidiplomat.c       Sun Feb 22 12:22:55 2015
@@ -423,9 +423,14 @@
     T(ACTION_SPY_SABOTAGE_CITY, 0);
   }
 
-  /* In case untargeted isn't there. TODO: choose target */
+  /* Sabotage a specific city improvement. This has worse odds than
+   * sabotaging a random city improvement. */
   if (count_impr > 0) {
-    T(ACTION_SPY_TARGETED_SABOTAGE_CITY, B_LAST + 1);
+    /* TODO: consider target improvements in stead of always going after
+     * the current production. */
+    int tgt_impr = -1;
+
+    T(ACTION_SPY_TARGETED_SABOTAGE_CITY, tgt_impr + 1);
   }
 
   T(ACTION_SPY_STEAL_GOLD, 0);

Modified: trunk/client/gui-gtk-2.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/action_dialog.c?rev=28284&r1=28283&r2=28284&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-2.0/action_dialog.c    Sun Feb 22 12:22:55 2015
@@ -584,10 +584,19 @@
   if (response == GTK_RESPONSE_ACCEPT && args->value > -2) {
     if (NULL != game_unit_by_number(args->actor_unit_id)
         && NULL != game_city_by_number(args->target_city_id)) {
-      request_do_action(ACTION_SPY_TARGETED_SABOTAGE_CITY,
-                        args->actor_unit_id,
-                        args->target_city_id,
-                        args->value + 1);
+      if (args->value == B_LAST) {
+        /* This is the untargeted version. */
+        request_do_action(ACTION_SPY_SABOTAGE_CITY,
+                          args->actor_unit_id,
+                          args->target_city_id,
+                          args->value + 1);
+      } else {
+        /* This is the targeted version. */
+        request_do_action(ACTION_SPY_TARGETED_SABOTAGE_CITY,
+                          args->actor_unit_id,
+                          args->target_city_id,
+                          args->value + 1);
+      }
     }
   }
 
@@ -700,13 +709,17 @@
     }  
   } city_built_iterate_end;
 
-  gtk_list_store_append(store, &it);
-  {
+  if (action_prob_possible(
+        follow_up_act_probs[ACTION_SPY_SABOTAGE_CITY])) {
     struct astring str = ASTRING_INIT;
+
+    gtk_list_store_append(store, &it);
+
     /* TRANS: %s is a unit name, e.g., Spy */
     astr_set(&str, _("At %s's Discretion"),
              unit_name_translation(game_unit_by_number(args->actor_unit_id)));
     gtk_list_store_set(store, &it, 0, astr_str(&str), 1, B_LAST, -1);
+
     astr_free(&str);
   }
 

Modified: trunk/client/gui-gtk-3.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/action_dialog.c?rev=28284&r1=28283&r2=28284&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-3.0/action_dialog.c    Sun Feb 22 12:22:55 2015
@@ -589,10 +589,19 @@
   if (response == GTK_RESPONSE_ACCEPT && args->value > -2) {
     if (NULL != game_unit_by_number(args->actor_unit_id)
         && NULL != game_city_by_number(args->target_city_id)) {
-      request_do_action(ACTION_SPY_TARGETED_SABOTAGE_CITY,
-                        args->actor_unit_id,
-                        args->target_city_id,
-                        args->value + 1);
+      if (args->value == B_LAST) {
+        /* This is the untargeted version. */
+        request_do_action(ACTION_SPY_SABOTAGE_CITY,
+                          args->actor_unit_id,
+                          args->target_city_id,
+                          args->value + 1);
+      } else {
+        /* This is the targeted version. */
+        request_do_action(ACTION_SPY_TARGETED_SABOTAGE_CITY,
+                          args->actor_unit_id,
+                          args->target_city_id,
+                          args->value + 1);
+      }
     }
   }
 
@@ -710,13 +719,17 @@
     }  
   } city_built_iterate_end;
 
-  gtk_list_store_append(store, &it);
-  {
+  if (action_prob_possible(
+        follow_up_act_probs[ACTION_SPY_SABOTAGE_CITY])) {
     struct astring str = ASTRING_INIT;
+
+    gtk_list_store_append(store, &it);
+
     /* TRANS: %s is a unit name, e.g., Spy */
     astr_set(&str, _("At %s's Discretion"),
              unit_name_translation(game_unit_by_number(args->actor_unit_id)));
     gtk_list_store_set(store, &it, 0, astr_str(&str), 1, B_LAST, -1);
+
     astr_free(&str);
   }
 

Modified: trunk/client/gui-qt/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/dialogs.cpp?rev=28284&r1=28283&r2=28284&view=diff
==============================================================================
--- trunk/client/gui-qt/dialogs.cpp     (original)
+++ trunk/client/gui-qt/dialogs.cpp     Sun Feb 22 12:22:55 2015
@@ -1874,10 +1874,17 @@
   int diplomat_target_id = data1.toList().at(1).toInt();
 
   if (NULL != game_unit_by_number(diplomat_id)
-        && NULL != game_city_by_number(diplomat_target_id)) {
+      && NULL != game_city_by_number(diplomat_target_id)) {
+    if (data2.toInt() == B_LAST) {
+      /* This is the untargeted version. */
+      request_do_action(ACTION_SPY_SABOTAGE_CITY, diplomat_id,
+                        diplomat_target_id, data2.toInt() + 1);
+    } else {
+      /* This is the targeted version. */
       request_do_action(ACTION_SPY_TARGETED_SABOTAGE_CITY, diplomat_id,
-                        diplomat_target_id,  data2.toInt()+1);
-    }
+                        diplomat_target_id, data2.toInt() + 1);
+    }
+  }
 }
 
 /**************************************************************************
@@ -1919,11 +1926,15 @@
       nr++;
     }
   } city_built_iterate_end;
-  astr_set(&stra, _("At %s's Discretion"),
-           unit_name_translation(game_unit_by_number(diplomat_id)));
-  func = spy_sabotage;
-  str = astr_str(&stra);
-  cd->add_item(str, func, qv1, B_LAST);
+
+  if (action_prob_possible(follow_up_act_probs[ACTION_SPY_SABOTAGE_CITY])) {
+    astr_set(&stra, _("At %s's Discretion"),
+             unit_name_translation(game_unit_by_number(diplomat_id)));
+    func = spy_sabotage;
+    str = astr_str(&stra);
+    cd->add_item(str, func, qv1, B_LAST);
+  }
+
   cd->set_layout();
   cd->show_me();
   astr_free(&stra);

Modified: trunk/client/gui-sdl/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl/action_dialog.c?rev=28284&r1=28283&r2=28284&view=diff
==============================================================================
--- trunk/client/gui-sdl/action_dialog.c        (original)
+++ trunk/client/gui-sdl/action_dialog.c        Sun Feb 22 12:22:55 2015
@@ -1112,8 +1112,15 @@
 
     if (NULL != game_unit_by_number(diplomat_id)
         && NULL != game_city_by_number(diplomat_target_id)) {
-      request_do_action(ACTION_SPY_TARGETED_SABOTAGE_CITY, diplomat_id,
-                        diplomat_target_id, sabotage_improvement + 1);
+      if (sabotage_improvement == B_LAST) {
+        /* This is the untargeted version. */
+        request_do_action(ACTION_SPY_SABOTAGE_CITY, diplomat_id,
+                          diplomat_target_id, sabotage_improvement + 1);
+      } else {
+        /* This is the targeted version. */
+        request_do_action(ACTION_SPY_TARGETED_SABOTAGE_CITY, diplomat_id,
+                          diplomat_target_id, sabotage_improvement + 1);
+      }
     }
 
     choose_action_queue_next();
@@ -1224,8 +1231,9 @@
   } city_built_iterate_end;
 
   pDiplomat_Dlg->pdialog->pBeginActiveWidgetList = pBuf;
-  
-  if (n > 0) {
+
+  if (n > 0 && action_prob_possible(
+        follow_up_act_probs[ACTION_SPY_SABOTAGE_CITY])) {
     /* separator */
     pBuf = create_iconlabel(NULL, pWindow->dst, NULL, WF_FREE_THEME);
     
@@ -1233,22 +1241,26 @@
     area.h += pBuf->next->size.h;
   /* ------------------ */
   }
-  
-  {
+
+  if (action_prob_possible(
+        follow_up_act_probs[ACTION_SPY_SABOTAGE_CITY])) {
     struct astring str = ASTRING_INIT;
+
     /* TRANS: %s is a unit name, e.g., Spy */
     astr_set(&str, _("At %s's Discretion"), unit_name_translation(actor));
     create_active_iconlabel(pBuf, pWindow->dst, pStr, astr_str(&str),
                             sabotage_impr_callback);
     astr_free(&str);
-  }
-  pBuf->data.cont = pCont;  
-  set_wstate(pBuf, FC_WS_NORMAL);
-  
-  add_to_gui_list(MAX_ID - B_LAST, pBuf);
-    
-  area.w = MAX(area.w, pBuf->size.w);
-  area.h += pBuf->size.h;
+
+    pBuf->data.cont = pCont;
+    set_wstate(pBuf, FC_WS_NORMAL);
+
+    add_to_gui_list(MAX_ID - B_LAST, pBuf);
+
+    area.w = MAX(area.w, pBuf->size.w);
+    area.h += pBuf->size.h;
+  }
+
   /* ----------- */
   
   pLast = pBuf;

Modified: trunk/client/gui-sdl2/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/action_dialog.c?rev=28284&r1=28283&r2=28284&view=diff
==============================================================================
--- trunk/client/gui-sdl2/action_dialog.c       (original)
+++ trunk/client/gui-sdl2/action_dialog.c       Sun Feb 22 12:22:55 2015
@@ -1115,8 +1115,15 @@
 
     if (NULL != game_unit_by_number(diplomat_id)
         && NULL != game_city_by_number(diplomat_target_id)) {
-      request_do_action(ACTION_SPY_TARGETED_SABOTAGE_CITY, diplomat_id,
-                        diplomat_target_id, sabotage_improvement + 1);
+      if (sabotage_improvement == B_LAST) {
+        /* This is the untargeted version. */
+        request_do_action(ACTION_SPY_SABOTAGE_CITY, diplomat_id,
+                          diplomat_target_id, sabotage_improvement + 1);
+      } else {
+        /* This is the targeted version. */
+        request_do_action(ACTION_SPY_TARGETED_SABOTAGE_CITY, diplomat_id,
+                          diplomat_target_id, sabotage_improvement + 1);
+      }
     }
 
     choose_action_queue_next();
@@ -1227,7 +1234,8 @@
 
   pDiplomat_Dlg->pdialog->pBeginActiveWidgetList = pBuf;
 
-  if (n > 0) {
+  if (n > 0 && action_prob_possible(
+        follow_up_act_probs[ACTION_SPY_SABOTAGE_CITY])) {
     /* separator */
     pBuf = create_iconlabel(NULL, pWindow->dst, NULL, WF_FREE_THEME);
 
@@ -1236,7 +1244,8 @@
   /* ------------------ */
   }
 
-  {
+  if (action_prob_possible(
+        follow_up_act_probs[ACTION_SPY_SABOTAGE_CITY])) {
     struct astring str = ASTRING_INIT;
 
     /* TRANS: %s is a unit name, e.g., Spy */
@@ -1244,14 +1253,16 @@
     create_active_iconlabel(pBuf, pWindow->dst, pstr, astr_str(&str),
                             sabotage_impr_callback);
     astr_free(&str);
-  }
-  pBuf->data.cont = pCont;
-  set_wstate(pBuf, FC_WS_NORMAL);
-
-  add_to_gui_list(MAX_ID - B_LAST, pBuf);
-
-  area.w = MAX(area.w, pBuf->size.w);
-  area.h += pBuf->size.h;
+
+    pBuf->data.cont = pCont;
+    set_wstate(pBuf, FC_WS_NORMAL);
+
+    add_to_gui_list(MAX_ID - B_LAST, pBuf);
+
+    area.w = MAX(area.w, pBuf->size.w);
+    area.h += pBuf->size.h;
+  }
+
   /* ----------- */
 
   pLast = pBuf;

Modified: trunk/client/gui-xaw/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-xaw/action_dialog.c?rev=28284&r1=28283&r2=28284&view=diff
==============================================================================
--- trunk/client/gui-xaw/action_dialog.c        (original)
+++ trunk/client/gui-xaw/action_dialog.c        Sun Feb 22 12:22:55 2015
@@ -443,9 +443,17 @@
 
   if (NULL != game_unit_by_number(diplomat_id)
       && NULL != game_city_by_number(diplomat_target_id[ATK_CITY])) {
-    request_do_action(ACTION_SPY_TARGETED_SABOTAGE_CITY, diplomat_id,
-                      diplomat_target_id[ATK_CITY],
-                      sabotage_improvement + 1);
+    if (sabotage_improvement == B_LAST) {
+      /* This is the untargeted version. */
+      request_do_action(ACTION_SPY_SABOTAGE_CITY, diplomat_id,
+                        diplomat_target_id[ATK_CITY],
+                        sabotage_improvement + 1);
+    } else {
+      /* This is the targeted version. */
+      request_do_action(ACTION_SPY_TARGETED_SABOTAGE_CITY, diplomat_id,
+                        diplomat_target_id[ATK_CITY],
+                        sabotage_improvement + 1);
+    }
   }
 
   choose_action_queue_next();

Modified: trunk/doc/README.actions
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/doc/README.actions?rev=28284&r1=28283&r2=28284&view=diff
==============================================================================
--- trunk/doc/README.actions    (original)
+++ trunk/doc/README.actions    Sun Feb 22 12:22:55 2015
@@ -146,9 +146,8 @@
  * actor must be on the same tile as the target or on the tile next to it.
  * target must be foreign.
 
-"Targeted Sabotage City" - Optionally targeted version of the above.
+"Targeted Sabotage City" - Targeted version of the above.
  * UI name can be set using ui_name_targeted_sabotage_city
- * If a target is selected the action is less likely to succeed.
  * actor must be on the same tile as the target or on the tile next to it.
  * target must be foreign.
 

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=28284&r1=28283&r2=28284&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Sun Feb 22 12:22:55 2015
@@ -54,7 +54,7 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Feb.08"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Feb.22"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=28284&r1=28283&r2=28284&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Sun Feb 22 12:22:55 2015
@@ -913,7 +913,9 @@
     }
     break;
   case ACTION_SPY_TARGETED_SABOTAGE_CITY:
-    if (pcity) {
+    if (pcity
+        /* This isn't untargeted sabotage city. */
+        && value != (B_LAST + 1)) {
       if (is_action_enabled_unit_on_city(action_type, actor_unit, pcity)) {
         ACTION_STARTED_UNIT_CITY(action_type, actor_unit, pcity);
 


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

Reply via email to