Author: sveinung
Date: Tue May 16 13:32:29 2017
New Revision: 35612

URL: http://svn.gna.org/viewcvs/freeciv?rev=35612&view=rev
Log:
Gtk clients: add action to action data.

Use it in unit bribery, city inciting, building sabotage and targeted tech
theft. Don't use it in the action selection dialog since the action data of
all actions are shared.

See hrm Feature #660487

Modified:
    branches/S3_0/client/gui-gtk-2.0/action_dialog.c
    branches/S3_0/client/gui-gtk-3.0/action_dialog.c
    branches/S3_0/client/gui-gtk-3.22/action_dialog.c

Modified: branches/S3_0/client/gui-gtk-2.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/client/gui-gtk-2.0/action_dialog.c?rev=35612&r1=35611&r2=35612&view=diff
==============================================================================
--- branches/S3_0/client/gui-gtk-2.0/action_dialog.c    (original)
+++ branches/S3_0/client/gui-gtk-2.0/action_dialog.c    Tue May 16 13:32:29 2017
@@ -73,6 +73,7 @@
 /* A structure to hold parameters for actions inside the GUI in stead of
  * storing the needed data in a global variable. */
 struct action_data {
+  int action_id;
   int actor_unit_id;
   int target_city_id;
   int target_unit_id;
@@ -84,7 +85,8 @@
   Create a new action data structure that can be stored in the
   dialogs.
 *****************************************************************/
-static struct action_data *act_data(int actor_id,
+static struct action_data *act_data(int action_id,
+                                    int actor_id,
                                     int target_city_id,
                                     int target_unit_id,
                                     int target_tile_id,
@@ -92,6 +94,7 @@
 {
   struct action_data *data = fc_malloc(sizeof(*data));
 
+  data->action_id = action_id;
   data->actor_unit_id = actor_id;
   data->target_city_id = target_city_id;
   data->target_unit_id = target_unit_id;
@@ -401,7 +404,7 @@
   struct action_data *args = (struct action_data *)data;
 
   if (response == GTK_RESPONSE_YES) {
-    request_do_action(ACTION_SPY_BRIBE_UNIT, args->actor_unit_id,
+    request_do_action(args->action_id, args->actor_unit_id,
                       args->target_unit_id, 0, "");
   }
 
@@ -466,7 +469,8 @@
   gtk_window_present(GTK_WINDOW(shell));
   
   g_signal_connect(shell, "response", G_CALLBACK(bribe_response),
-                   act_data(actor->id, 0, punit->id, 0, cost));
+                   act_data(ACTION_SPY_BRIBE_UNIT,
+                            actor->id, 0, punit->id, 0, cost));
 }
 
 /****************************************************************
@@ -758,7 +762,7 @@
                           args->value, "");
       } else {
         /* This is the targeted version. */
-        request_do_action(ACTION_SPY_TARGETED_STEAL_TECH,
+        request_do_action(args->action_id,
                           args->actor_unit_id, args->target_city_id,
                           args->value, "");
       }
@@ -937,7 +941,7 @@
                           args->value + 1, "");
       } else {
         /* This is the targeted version. */
-        request_do_action(ACTION_SPY_TARGETED_SABOTAGE_CITY,
+        request_do_action(args->action_id,
                           args->actor_unit_id,
                           args->target_city_id,
                           args->value + 1, "");
@@ -1092,6 +1096,8 @@
 {
   struct action_data *args = (struct action_data *)data;
 
+  args->action_id = ACTION_SPY_TARGETED_STEAL_TECH;
+
   struct city *pvcity = game_city_by_number(args->target_city_id);
   struct player *pvictim = NULL;
 
@@ -1150,7 +1156,8 @@
   /* FIXME: Don't discard the second target choice dialog. */
   if (!spy_sabotage_shell) {
     create_improvements_list(client.conn.playing, pcity,
-                             act_data(actor->id, pcity->id, 0, 0, 0));
+                             act_data(ACTION_SPY_TARGETED_SABOTAGE_CITY,
+                                      actor->id, pcity->id, 0, 0, 0));
     gtk_window_present(GTK_WINDOW(spy_sabotage_shell));
   }
 }
@@ -1184,7 +1191,7 @@
   struct action_data *args = (struct action_data *)data;
 
   if (response == GTK_RESPONSE_YES) {
-    request_do_action(ACTION_SPY_INCITE_CITY, args->actor_unit_id,
+    request_do_action(args->action_id, args->actor_unit_id,
                       args->target_city_id, 0, "");
   }
 
@@ -1236,7 +1243,8 @@
   gtk_window_present(GTK_WINDOW(shell));
   
   g_signal_connect(shell, "response", G_CALLBACK(incite_response),
-                   act_data(actor->id, pcity->id, 0, 0, cost));
+                   act_data(ACTION_SPY_INCITE_CITY,
+                            actor->id, pcity->id, 0, 0, cost));
 }
 
 
@@ -1470,7 +1478,8 @@
   int button_id;
 
   struct action_data *data =
-      act_data(actor_unit->id,
+      act_data(ACTION_ANY, /* Not decided yet */
+               actor_unit->id,
                (target_city) ? target_city->id : 0,
                (target_unit) ? target_unit->id : 0,
                (target_tile) ? target_tile->index : 0,
@@ -1718,7 +1727,8 @@
     return;
   }
 
-  data = act_data(actor_unit->id,
+  data = act_data(ACTION_ANY, /* Not decided yet */
+                  actor_unit->id,
                   (target_city) ? target_city->id : IDENTITY_NUMBER_ZERO,
                   (target_unit) ? target_unit->id : IDENTITY_NUMBER_ZERO,
                   (target_tile) ? target_tile->index : 0,

Modified: branches/S3_0/client/gui-gtk-3.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/client/gui-gtk-3.0/action_dialog.c?rev=35612&r1=35611&r2=35612&view=diff
==============================================================================
--- branches/S3_0/client/gui-gtk-3.0/action_dialog.c    (original)
+++ branches/S3_0/client/gui-gtk-3.0/action_dialog.c    Tue May 16 13:32:29 2017
@@ -76,6 +76,7 @@
 /* A structure to hold parameters for actions inside the GUI in stead of
  * storing the needed data in a global variable. */
 struct action_data {
+  int action_id;
   int actor_unit_id;
   int target_city_id;
   int target_unit_id;
@@ -87,7 +88,8 @@
   Create a new action data structure that can be stored in the
   dialogs.
 *****************************************************************/
-static struct action_data *act_data(int actor_id,
+static struct action_data *act_data(int action_id,
+                                    int actor_id,
                                     int target_city_id,
                                     int target_unit_id,
                                     int target_tile_id,
@@ -95,6 +97,7 @@
 {
   struct action_data *data = fc_malloc(sizeof(*data));
 
+  data->action_id = action_id;
   data->actor_unit_id = actor_id;
   data->target_city_id = target_city_id;
   data->target_unit_id = target_unit_id;
@@ -411,7 +414,7 @@
   struct action_data *args = (struct action_data *)data;
 
   if (response == GTK_RESPONSE_YES) {
-    request_do_action(ACTION_SPY_BRIBE_UNIT, args->actor_unit_id,
+    request_do_action(args->action_id, args->actor_unit_id,
                       args->target_unit_id, 0, "");
   }
 
@@ -476,7 +479,8 @@
   gtk_window_present(GTK_WINDOW(shell));
   
   g_signal_connect(shell, "response", G_CALLBACK(bribe_response),
-                   act_data(actor->id, 0, punit->id, 0, cost));
+                   act_data(ACTION_SPY_BRIBE_UNIT,
+                            actor->id, 0, punit->id, 0, cost));
 }
 
 /****************************************************************
@@ -768,7 +772,7 @@
                           args->value, "");
       } else {
         /* This is the targeted version. */
-        request_do_action(ACTION_SPY_TARGETED_STEAL_TECH,
+        request_do_action(args->action_id,
                           args->actor_unit_id, args->target_city_id,
                           args->value, "");
       }
@@ -952,7 +956,7 @@
                           args->value + 1, "");
       } else {
         /* This is the targeted version. */
-        request_do_action(ACTION_SPY_TARGETED_SABOTAGE_CITY,
+        request_do_action(args->action_id,
                           args->actor_unit_id,
                           args->target_city_id,
                           args->value + 1, "");
@@ -1112,6 +1116,8 @@
 {
   struct action_data *args = (struct action_data *)data;
 
+  args->action_id = ACTION_SPY_TARGETED_STEAL_TECH;
+
   struct city *pvcity = game_city_by_number(args->target_city_id);
   struct player *pvictim = NULL;
 
@@ -1170,7 +1176,8 @@
   /* FIXME: Don't discard the second target choice dialog. */
   if (!spy_sabotage_shell) {
     create_improvements_list(client.conn.playing, pcity,
-                             act_data(actor->id, pcity->id, 0, 0, 0));
+                             act_data(ACTION_SPY_TARGETED_SABOTAGE_CITY,
+                                      actor->id, pcity->id, 0, 0, 0));
     gtk_window_present(GTK_WINDOW(spy_sabotage_shell));
   }
 }
@@ -1204,7 +1211,7 @@
   struct action_data *args = (struct action_data *)data;
 
   if (response == GTK_RESPONSE_YES) {
-    request_do_action(ACTION_SPY_INCITE_CITY, args->actor_unit_id,
+    request_do_action(args->action_id, args->actor_unit_id,
                       args->target_city_id, 0, "");
   }
 
@@ -1256,7 +1263,8 @@
   gtk_window_present(GTK_WINDOW(shell));
   
   g_signal_connect(shell, "response", G_CALLBACK(incite_response),
-                   act_data(actor->id, pcity->id, 0, 0, cost));
+                   act_data(ACTION_SPY_INCITE_CITY,
+                            actor->id, pcity->id, 0, 0, cost));
 }
 
 /**************************************************************************
@@ -1558,7 +1566,8 @@
   int button_id;
 
   struct action_data *data =
-      act_data(actor_unit->id,
+      act_data(ACTION_ANY, /* Not decided yet */
+               actor_unit->id,
                (target_city) ? target_city->id : 0,
                (target_unit) ? target_unit->id : 0,
                (target_tile) ? target_tile->index : 0,
@@ -1815,7 +1824,8 @@
     return;
   }
 
-  data = act_data(actor_unit->id,
+  data = act_data(ACTION_ANY, /* Not decided yet */
+                  actor_unit->id,
                   (target_city) ? target_city->id : IDENTITY_NUMBER_ZERO,
                   (target_unit) ? target_unit->id : IDENTITY_NUMBER_ZERO,
                   (target_tile) ? target_tile->index : 0,

Modified: branches/S3_0/client/gui-gtk-3.22/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/client/gui-gtk-3.22/action_dialog.c?rev=35612&r1=35611&r2=35612&view=diff
==============================================================================
--- branches/S3_0/client/gui-gtk-3.22/action_dialog.c   (original)
+++ branches/S3_0/client/gui-gtk-3.22/action_dialog.c   Tue May 16 13:32:29 2017
@@ -76,6 +76,7 @@
 /* A structure to hold parameters for actions inside the GUI in stead of
  * storing the needed data in a global variable. */
 struct action_data {
+  int action_id;
   int actor_unit_id;
   int target_city_id;
   int target_unit_id;
@@ -87,7 +88,8 @@
   Create a new action data structure that can be stored in the
   dialogs.
 *****************************************************************/
-static struct action_data *act_data(int actor_id,
+static struct action_data *act_data(int action_id,
+                                    int actor_id,
                                     int target_city_id,
                                     int target_unit_id,
                                     int target_tile_id,
@@ -95,6 +97,7 @@
 {
   struct action_data *data = fc_malloc(sizeof(*data));
 
+  data->action_id = action_id;
   data->actor_unit_id = actor_id;
   data->target_city_id = target_city_id;
   data->target_unit_id = target_unit_id;
@@ -411,7 +414,7 @@
   struct action_data *args = (struct action_data *)data;
 
   if (response == GTK_RESPONSE_YES) {
-    request_do_action(ACTION_SPY_BRIBE_UNIT, args->actor_unit_id,
+    request_do_action(args->action_id, args->actor_unit_id,
                       args->target_unit_id, 0, "");
   }
 
@@ -476,7 +479,8 @@
   gtk_window_present(GTK_WINDOW(shell));
   
   g_signal_connect(shell, "response", G_CALLBACK(bribe_response),
-                   act_data(actor->id, 0, punit->id, 0, cost));
+                   act_data(ACTION_SPY_BRIBE_UNIT,
+                            actor->id, 0, punit->id, 0, cost));
 }
 
 /****************************************************************
@@ -768,7 +772,7 @@
                           args->value, "");
       } else {
         /* This is the targeted version. */
-        request_do_action(ACTION_SPY_TARGETED_STEAL_TECH,
+        request_do_action(args->action_id,
                           args->actor_unit_id, args->target_city_id,
                           args->value, "");
       }
@@ -949,7 +953,7 @@
                           args->value + 1, "");
       } else {
         /* This is the targeted version. */
-        request_do_action(ACTION_SPY_TARGETED_SABOTAGE_CITY,
+        request_do_action(args->action_id,
                           args->actor_unit_id,
                           args->target_city_id,
                           args->value + 1, "");
@@ -1106,6 +1110,8 @@
 {
   struct action_data *args = (struct action_data *)data;
 
+  args->action_id = ACTION_SPY_TARGETED_STEAL_TECH;
+
   struct city *pvcity = game_city_by_number(args->target_city_id);
   struct player *pvictim = NULL;
 
@@ -1164,7 +1170,8 @@
   /* FIXME: Don't discard the second target choice dialog. */
   if (!spy_sabotage_shell) {
     create_improvements_list(client.conn.playing, pcity,
-                             act_data(actor->id, pcity->id, 0, 0, 0));
+                             act_data(ACTION_SPY_TARGETED_SABOTAGE_CITY,
+                                      actor->id, pcity->id, 0, 0, 0));
     gtk_window_present(GTK_WINDOW(spy_sabotage_shell));
   }
 }
@@ -1198,7 +1205,7 @@
   struct action_data *args = (struct action_data *)data;
 
   if (response == GTK_RESPONSE_YES) {
-    request_do_action(ACTION_SPY_INCITE_CITY, args->actor_unit_id,
+    request_do_action(args->action_id, args->actor_unit_id,
                       args->target_city_id, 0, "");
   }
 
@@ -1250,7 +1257,8 @@
   gtk_window_present(GTK_WINDOW(shell));
   
   g_signal_connect(shell, "response", G_CALLBACK(incite_response),
-                   act_data(actor->id, pcity->id, 0, 0, cost));
+                   act_data(ACTION_SPY_INCITE_CITY,
+                            actor->id, pcity->id, 0, 0, cost));
 }
 
 /**************************************************************************
@@ -1552,7 +1560,8 @@
   int button_id;
 
   struct action_data *data =
-      act_data(actor_unit->id,
+      act_data(ACTION_ANY, /* Not decided yet */
+               actor_unit->id,
                (target_city) ? target_city->id : 0,
                (target_unit) ? target_unit->id : 0,
                (target_tile) ? target_tile->index : 0,
@@ -1809,7 +1818,8 @@
     return;
   }
 
-  data = act_data(actor_unit->id,
+  data = act_data(ACTION_ANY, /* Not decided yet */
+                  actor_unit->id,
                   (target_city) ? target_city->id : IDENTITY_NUMBER_ZERO,
                   (target_unit) ? target_unit->id : IDENTITY_NUMBER_ZERO,
                   (target_tile) ? target_tile->index : 0,


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

Reply via email to