Author: sveinung
Date: Sun Feb 22 12:42:12 2015
New Revision: 28285

URL: http://svn.gna.org/viewcvs/freeciv?rev=28285&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:
    branches/S2_6/ai/default/aidiplomat.c
    branches/S2_6/client/gui-gtk-2.0/action_dialog.c
    branches/S2_6/client/gui-gtk-3.0/action_dialog.c
    branches/S2_6/client/gui-qt/dialogs.cpp
    branches/S2_6/client/gui-sdl/action_dialog.c
    branches/S2_6/client/gui-sdl2/action_dialog.c
    branches/S2_6/client/gui-xaw/action_dialog.c
    branches/S2_6/doc/README.actions
    branches/S2_6/fc_version
    branches/S2_6/server/unithand.c

Modified: branches/S2_6/ai/default/aidiplomat.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/default/aidiplomat.c?rev=28285&r1=28284&r2=28285&view=diff
==============================================================================
--- branches/S2_6/ai/default/aidiplomat.c       (original)
+++ branches/S2_6/ai/default/aidiplomat.c       Sun Feb 22 12:42:12 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: branches/S2_6/client/gui-gtk-2.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/action_dialog.c?rev=28285&r1=28284&r2=28285&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/action_dialog.c    (original)
+++ branches/S2_6/client/gui-gtk-2.0/action_dialog.c    Sun Feb 22 12:42:12 2015
@@ -570,10 +570,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);
+      }
     }
   }
 
@@ -686,13 +695,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: branches/S2_6/client/gui-gtk-3.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/action_dialog.c?rev=28285&r1=28284&r2=28285&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/action_dialog.c    (original)
+++ branches/S2_6/client/gui-gtk-3.0/action_dialog.c    Sun Feb 22 12:42:12 2015
@@ -575,10 +575,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);
+      }
     }
   }
 
@@ -696,13 +705,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: branches/S2_6/client/gui-qt/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/dialogs.cpp?rev=28285&r1=28284&r2=28285&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/dialogs.cpp     (original)
+++ branches/S2_6/client/gui-qt/dialogs.cpp     Sun Feb 22 12:42:12 2015
@@ -1836,10 +1836,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);
+    }
+  }
 }
 
 /**************************************************************************
@@ -1881,11 +1888,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: branches/S2_6/client/gui-sdl/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl/action_dialog.c?rev=28285&r1=28284&r2=28285&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl/action_dialog.c        (original)
+++ branches/S2_6/client/gui-sdl/action_dialog.c        Sun Feb 22 12:42:12 2015
@@ -1077,8 +1077,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();
@@ -1189,8 +1196,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);
     
@@ -1198,22 +1206,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: branches/S2_6/client/gui-sdl2/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl2/action_dialog.c?rev=28285&r1=28284&r2=28285&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl2/action_dialog.c       (original)
+++ branches/S2_6/client/gui-sdl2/action_dialog.c       Sun Feb 22 12:42:12 2015
@@ -1080,8 +1080,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();
@@ -1192,7 +1199,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);
 
@@ -1201,7 +1209,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 */
@@ -1209,14 +1218,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: branches/S2_6/client/gui-xaw/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-xaw/action_dialog.c?rev=28285&r1=28284&r2=28285&view=diff
==============================================================================
--- branches/S2_6/client/gui-xaw/action_dialog.c        (original)
+++ branches/S2_6/client/gui-xaw/action_dialog.c        Sun Feb 22 12:42:12 2015
@@ -430,9 +430,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: branches/S2_6/doc/README.actions
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/doc/README.actions?rev=28285&r1=28284&r2=28285&view=diff
==============================================================================
--- branches/S2_6/doc/README.actions    (original)
+++ branches/S2_6/doc/README.actions    Sun Feb 22 12:42:12 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: branches/S2_6/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/fc_version?rev=28285&r1=28284&r2=28285&view=diff
==============================================================================
--- branches/S2_6/fc_version    (original)
+++ branches/S2_6/fc_version    Sun Feb 22 12:42:12 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-2.6-2015.Jan.27"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2015.Feb.22"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: branches/S2_6/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/unithand.c?rev=28285&r1=28284&r2=28285&view=diff
==============================================================================
--- branches/S2_6/server/unithand.c     (original)
+++ branches/S2_6/server/unithand.c     Sun Feb 22 12:42:12 2015
@@ -861,7 +861,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