Author: sveinung
Date: Thu May 18 11:25:20 2017
New Revision: 35638

URL: http://svn.gna.org/viewcvs/freeciv?rev=35638&view=rev
Log:
Prepare targeted sabotage for generic actions.

Return the action id with the lists of buildings that can be targeted in the
target city. Forward the action to the clients in popup_sabotage_dialog().
Have the clients use the specified action (rather than hard coding
ACTION_SPY_TARGETED_SABOTAGE_CITY) when ordering the action to take place.

See hrm Feature #661177

Modified:
    trunk/client/gui-gtk-3.0/action_dialog.c
    trunk/client/gui-gtk-3.22/action_dialog.c
    trunk/client/gui-gtk-4.0/action_dialog.c
    trunk/client/gui-qt/dialogs.cpp
    trunk/client/gui-sdl2/action_dialog.c
    trunk/client/gui-stub/dialogs.c
    trunk/client/include/dialogs_g.h
    trunk/client/packhand.c
    trunk/common/networking/packets.def
    trunk/fc_version
    trunk/server/diplomats.c

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=35638&r1=35637&r2=35638&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-3.0/action_dialog.c    Thu May 18 11:25:20 2017
@@ -1171,12 +1171,13 @@
  Pops-up the Spy sabotage dialog, upon return of list of
  available improvements requested by the above function.
 **************************************************************************/
-void popup_sabotage_dialog(struct unit *actor, struct city *pcity)
+void popup_sabotage_dialog(struct unit *actor, struct city *pcity,
+                           const struct action *paction)
 {
   /* FIXME: Don't discard the second target choice dialog. */
   if (!spy_sabotage_shell) {
     create_improvements_list(client.conn.playing, pcity,
-                             act_data(ACTION_SPY_TARGETED_SABOTAGE_CITY,
+                             act_data(paction->id,
                                       actor->id, pcity->id, 0, 0, 0));
     gtk_window_present(GTK_WINDOW(spy_sabotage_shell));
   }

Modified: trunk/client/gui-gtk-3.22/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.22/action_dialog.c?rev=35638&r1=35637&r2=35638&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.22/action_dialog.c   (original)
+++ trunk/client/gui-gtk-3.22/action_dialog.c   Thu May 18 11:25:20 2017
@@ -1165,12 +1165,13 @@
  Pops-up the Spy sabotage dialog, upon return of list of
  available improvements requested by the above function.
 **************************************************************************/
-void popup_sabotage_dialog(struct unit *actor, struct city *pcity)
+void popup_sabotage_dialog(struct unit *actor, struct city *pcity,
+                           const struct action *paction)
 {
   /* FIXME: Don't discard the second target choice dialog. */
   if (!spy_sabotage_shell) {
     create_improvements_list(client.conn.playing, pcity,
-                             act_data(ACTION_SPY_TARGETED_SABOTAGE_CITY,
+                             act_data(paction->id,
                                       actor->id, pcity->id, 0, 0, 0));
     gtk_window_present(GTK_WINDOW(spy_sabotage_shell));
   }

Modified: trunk/client/gui-gtk-4.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-4.0/action_dialog.c?rev=35638&r1=35637&r2=35638&view=diff
==============================================================================
--- trunk/client/gui-gtk-4.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-4.0/action_dialog.c    Thu May 18 11:25:20 2017
@@ -1165,12 +1165,13 @@
  Pops-up the Spy sabotage dialog, upon return of list of
  available improvements requested by the above function.
 **************************************************************************/
-void popup_sabotage_dialog(struct unit *actor, struct city *pcity)
+void popup_sabotage_dialog(struct unit *actor, struct city *pcity,
+                           const struct action *paction)
 {
   /* FIXME: Don't discard the second target choice dialog. */
   if (!spy_sabotage_shell) {
     create_improvements_list(client.conn.playing, pcity,
-                             act_data(ACTION_SPY_TARGETED_SABOTAGE_CITY,
+                             act_data(paction->id,
                                       actor->id, pcity->id, 0, 0, 0));
     gtk_window_present(GTK_WINDOW(spy_sabotage_shell));
   }

Modified: trunk/client/gui-qt/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/dialogs.cpp?rev=35638&r1=35637&r2=35638&view=diff
==============================================================================
--- trunk/client/gui-qt/dialogs.cpp     (original)
+++ trunk/client/gui-qt/dialogs.cpp     Thu May 18 11:25:20 2017
@@ -2658,6 +2658,7 @@
 {
   int diplomat_id = data1.toList().at(0).toInt();
   int diplomat_target_id = data1.toList().at(1).toInt();
+  int action_id = data1.toList().at(2).toInt();
 
   if (NULL != game_unit_by_number(diplomat_id)
       && NULL != game_city_by_number(diplomat_target_id)) {
@@ -2667,7 +2668,7 @@
                         diplomat_target_id, data2.toInt() + 1, "");
     } else {
       /* This is the targeted version. */
-      request_do_action(ACTION_SPY_TARGETED_SABOTAGE_CITY, diplomat_id,
+      request_do_action((gen_action)action_id, diplomat_id,
                         diplomat_target_id, data2.toInt() + 1, "");
     }
   }
@@ -2677,9 +2678,9 @@
   Popup a dialog asking a diplomatic unit if it wishes to sabotage the
   given enemy city.
 **************************************************************************/
-void popup_sabotage_dialog(struct unit *actor, struct city *tcity)
-{
-
+void popup_sabotage_dialog(struct unit *actor, struct city *tcity,
+                           const struct action *paction)
+{
   QString str;
   QVariant qv1, qv2;
   int diplomat_id = actor->id;
@@ -2696,9 +2697,10 @@
   /* Should be set before sending request to the server. */
   fc_assert(is_more_user_input_needed);
 
-  /* Put both actor and target city in qv1 since qv2 is taken */
+  /* Put both actor, target city and action in qv1 since qv2 is taken */
   actor_and_target.append(diplomat_id);
   actor_and_target.append(diplomat_target_id);
+  actor_and_target.append(paction->id);
   qv1 = QVariant::fromValue(actor_and_target);
 
   func = spy_sabotage;

Modified: trunk/client/gui-sdl2/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/action_dialog.c?rev=35638&r1=35637&r2=35638&view=diff
==============================================================================
--- trunk/client/gui-sdl2/action_dialog.c       (original)
+++ trunk/client/gui-sdl2/action_dialog.c       Thu May 18 11:25:20 2017
@@ -1657,6 +1657,7 @@
     int sabotage_improvement = MAX_ID - pWidget->ID;
     int diplomat_target_id = pWidget->data.cont->id0;
     int diplomat_id = pWidget->data.cont->id1;
+    int action_id = pWidget->data.cont->value;
 
     fc_assert(is_more_user_input_needed);
     popdown_diplomat_dialog();
@@ -1674,7 +1675,7 @@
                           sabotage_improvement + 1, "");
       } else {
         /* This is the targeted version. */
-        request_do_action(ACTION_SPY_TARGETED_SABOTAGE_CITY,
+        request_do_action(action_id,
                           diplomat_id, diplomat_target_id,
                           sabotage_improvement + 1, "");
       }
@@ -1690,7 +1691,8 @@
  Pops-up the Spy sabotage dialog, upon return of list of
  available improvements requested by the above function.
 **************************************************************************/
-void popup_sabotage_dialog(struct unit *actor, struct city *pCity)
+void popup_sabotage_dialog(struct unit *actor, struct city *pCity,
+                           const struct action *paction)
 {
   struct widget *pWindow = NULL, *pBuf = NULL , *pLast = NULL;
   struct CONTAINER *pCont;
@@ -1718,6 +1720,7 @@
   pCont = fc_calloc(1, sizeof(struct CONTAINER));
   pCont->id0 = pCity->id;
   pCont->id1 = actor->id; /* spy id */
+  pCont->value = paction->id;
 
   pstr = create_utf8_from_char(_("Select Improvement to Sabotage") , 
adj_font(12));
   pstr->style |= TTF_STYLE_BOLD;

Modified: trunk/client/gui-stub/dialogs.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-stub/dialogs.c?rev=35638&r1=35637&r2=35638&view=diff
==============================================================================
--- trunk/client/gui-stub/dialogs.c     (original)
+++ trunk/client/gui-stub/dialogs.c     Thu May 18 11:25:20 2017
@@ -148,7 +148,8 @@
   Popup a dialog asking a diplomatic unit if it wishes to sabotage the
   given enemy city.
 **************************************************************************/
-void popup_sabotage_dialog(struct unit *actor, struct city *pcity)
+void popup_sabotage_dialog(struct unit *actor, struct city *pcity,
+                           const struct action *paction)
 {
   /* PORTME */
 }

Modified: trunk/client/include/dialogs_g.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/include/dialogs_g.h?rev=35638&r1=35637&r2=35638&view=diff
==============================================================================
--- trunk/client/include/dialogs_g.h    (original)
+++ trunk/client/include/dialogs_g.h    Thu May 18 11:25:20 2017
@@ -67,7 +67,7 @@
 GUI_FUNC_PROTO(void, popup_bribe_dialog, struct unit *actor,
                struct unit *punit, int cost, const struct action *paction)
 GUI_FUNC_PROTO(void, popup_sabotage_dialog, struct unit *actor,
-               struct city *pcity)
+               struct city *pcity, const struct action *paction)
 GUI_FUNC_PROTO(void, popup_pillage_dialog, struct unit *punit, bv_extras 
extras)
 GUI_FUNC_PROTO(void, popup_upgrade_dialog, struct unit_list *punits)
 GUI_FUNC_PROTO(void, popup_disband_dialog, struct unit_list *punits)

Modified: trunk/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=35638&r1=35637&r2=35638&view=diff
==============================================================================
--- trunk/client/packhand.c     (original)
+++ trunk/client/packhand.c     Thu May 18 11:25:20 2017
@@ -4661,11 +4661,13 @@
   Handle list of potenttial buildings to sabotage.
 **************************************************************************/
 void handle_city_sabotage_list(int diplomat_id, int city_id,
-                               bv_imprs improvements)
+                               bv_imprs improvements,
+                               enum gen_action action_id)
 {
   struct city *pcity = game_city_by_number(city_id);
   struct unit *pdiplomat = player_unit_by_number(client_player(),
                                                  diplomat_id);
+  struct action *paction = action_by_number(action_id);
 
   if (!pdiplomat) {
     log_debug("Bad diplomat %d.", diplomat_id);
@@ -4694,7 +4696,7 @@
     /* Focus on the unit so the player knows where it is */
     unit_focus_set(pdiplomat);
 
-    popup_sabotage_dialog(pdiplomat, pcity);
+    popup_sabotage_dialog(pdiplomat, pcity, paction);
   } else {
     log_debug("Can't issue orders");
     action_selection_no_longer_in_progress(diplomat_id);

Modified: trunk/common/networking/packets.def
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/networking/packets.def?rev=35638&r1=35637&r2=35638&view=diff
==============================================================================
--- trunk/common/networking/packets.def (original)
+++ trunk/common/networking/packets.def Thu May 18 11:25:20 2017
@@ -801,6 +801,7 @@
   UNIT diplomat_id;
   CITY city_id;
   BV_IMPRS improvements;
+  GEN_ACTION action_id;
 end
 
 PACKET_WORKER_TASK = 241; cs, sc, lsend, handle-via-packet

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=35638&r1=35637&r2=35638&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Thu May 18 11:25:20 2017
@@ -56,7 +56,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.1-2017.May.17"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.1-2017.May.18"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/diplomats.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/diplomats.c?rev=35638&r1=35637&r2=35638&view=diff
==============================================================================
--- trunk/server/diplomats.c    (original)
+++ trunk/server/diplomats.c    Thu May 18 11:25:20 2017
@@ -280,6 +280,7 @@
 
   packet.diplomat_id = pdiplomat->id;
   packet.city_id = pcity->id;
+  packet.action_id = paction->id;
   send_packet_city_sabotage_list(pc, &packet);
 }
 


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

Reply via email to