Author: sveinung
Date: Wed May 17 12:45:42 2017
New Revision: 35622

URL: http://svn.gna.org/viewcvs/freeciv?rev=35622&view=rev
Log:
Prepare popup_bribe_dialog() for gen actions.

Make popup_bribe_dialog() take the action it is a response to as a
parameter. This allows more than one action to use it.

See hrm Feature #660895

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

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=35622&r1=35621&r2=35622&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-3.0/action_dialog.c    Wed May 17 12:45:42 2017
@@ -449,7 +449,8 @@
 /*************************************************************************
   Popup unit bribe dialog
 **************************************************************************/
-void popup_bribe_dialog(struct unit *actor, struct unit *punit, int cost)
+void popup_bribe_dialog(struct unit *actor, struct unit *punit, int cost,
+                        const struct action *paction)
 {
   GtkWidget *shell;
   char buf[1024];
@@ -479,8 +480,7 @@
   gtk_window_present(GTK_WINDOW(shell));
   
   g_signal_connect(shell, "response", G_CALLBACK(bribe_response),
-                   act_data(ACTION_SPY_BRIBE_UNIT,
-                            actor->id, 0, punit->id, 0, cost));
+                   act_data(paction->id, actor->id, 0, punit->id, 0, cost));
 }
 
 /****************************************************************

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=35622&r1=35621&r2=35622&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.22/action_dialog.c   (original)
+++ trunk/client/gui-gtk-3.22/action_dialog.c   Wed May 17 12:45:42 2017
@@ -449,7 +449,8 @@
 /*************************************************************************
   Popup unit bribe dialog
 **************************************************************************/
-void popup_bribe_dialog(struct unit *actor, struct unit *punit, int cost)
+void popup_bribe_dialog(struct unit *actor, struct unit *punit, int cost,
+                        const struct action *paction)
 {
   GtkWidget *shell;
   char buf[1024];
@@ -479,8 +480,7 @@
   gtk_window_present(GTK_WINDOW(shell));
   
   g_signal_connect(shell, "response", G_CALLBACK(bribe_response),
-                   act_data(ACTION_SPY_BRIBE_UNIT,
-                            actor->id, 0, punit->id, 0, cost));
+                   act_data(paction->id, actor->id, 0, punit->id, 0, cost));
 }
 
 /****************************************************************

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=35622&r1=35621&r2=35622&view=diff
==============================================================================
--- trunk/client/gui-gtk-4.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-4.0/action_dialog.c    Wed May 17 12:45:42 2017
@@ -449,7 +449,8 @@
 /*************************************************************************
   Popup unit bribe dialog
 **************************************************************************/
-void popup_bribe_dialog(struct unit *actor, struct unit *punit, int cost)
+void popup_bribe_dialog(struct unit *actor, struct unit *punit, int cost,
+                        const struct action *paction)
 {
   GtkWidget *shell;
   char buf[1024];
@@ -479,8 +480,7 @@
   gtk_window_present(GTK_WINDOW(shell));
   
   g_signal_connect(shell, "response", G_CALLBACK(bribe_response),
-                   act_data(ACTION_SPY_BRIBE_UNIT,
-                            actor->id, 0, punit->id, 0, cost));
+                   act_data(paction->id, actor->id, 0, punit->id, 0, cost));
 }
 
 /****************************************************************

Modified: trunk/client/gui-qt/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/dialogs.cpp?rev=35622&r1=35621&r2=35622&view=diff
==============================================================================
--- trunk/client/gui-qt/dialogs.cpp     (original)
+++ trunk/client/gui-qt/dialogs.cpp     Wed May 17 12:45:42 2017
@@ -2584,7 +2584,8 @@
   Popup a dialog asking a diplomatic unit if it wishes to bribe the
   given enemy unit.
 **************************************************************************/
-void popup_bribe_dialog(struct unit *actor, struct unit *tunit, int cost)
+void popup_bribe_dialog(struct unit *actor, struct unit *tunit, int cost,
+                        const struct action *paction)
 {
   hud_message_box ask(gui()->central_wdg);
   int ret;
@@ -2613,7 +2614,7 @@
     case QMessageBox::Cancel:
       break;
     case QMessageBox::Ok:
-      request_do_action(ACTION_SPY_BRIBE_UNIT, diplomat_id,
+      request_do_action(paction->id, diplomat_id,
                         diplomat_target_id, 0, "");
       break;
     default:

Modified: trunk/client/gui-sdl2/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/action_dialog.c?rev=35622&r1=35621&r2=35622&view=diff
==============================================================================
--- trunk/client/gui-sdl2/action_dialog.c       (original)
+++ trunk/client/gui-sdl2/action_dialog.c       Wed May 17 12:45:42 2017
@@ -2250,7 +2250,8 @@
   Popup a dialog asking a diplomatic unit if it wishes to bribe the
   given enemy unit.
 **************************************************************************/
-void popup_bribe_dialog(struct unit *actor, struct unit *pUnit, int cost)
+void popup_bribe_dialog(struct unit *actor, struct unit *pUnit, int cost,
+                        const struct action *paction)
 {
   struct widget *pWindow = NULL, *pBuf = NULL;
   utf8_str *pstr;
@@ -2265,7 +2266,7 @@
   /* Should be set before sending request to the server. */
   fc_assert(is_more_user_input_needed);
 
-  if (!actor || !unit_can_do_action(actor, ACTION_SPY_BRIBE_UNIT)) {
+  if (!actor || !unit_can_do_action(actor, paction->id)) {
     act_sel_done_secondary(actor ? actor->id : IDENTITY_NUMBER_ZERO);
     return;
   }
@@ -2273,7 +2274,7 @@
   is_unit_move_blocked = TRUE;
 
   pBribe_Dlg = fc_calloc(1, sizeof(struct small_diplomat_dialog));
-  pBribe_Dlg->action_id = ACTION_SPY_BRIBE_UNIT;
+  pBribe_Dlg->action_id = paction->id;
   pBribe_Dlg->actor_unit_id = actor->id;
   pBribe_Dlg->target_id = pUnit->id;
   pBribe_Dlg->pdialog = fc_calloc(1, sizeof(struct SMALL_DLG));

Modified: trunk/client/gui-stub/dialogs.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-stub/dialogs.c?rev=35622&r1=35621&r2=35622&view=diff
==============================================================================
--- trunk/client/gui-stub/dialogs.c     (original)
+++ trunk/client/gui-stub/dialogs.c     Wed May 17 12:45:42 2017
@@ -138,7 +138,8 @@
   Popup a dialog asking a diplomatic unit if it wishes to bribe the
   given enemy unit.
 **************************************************************************/
-void popup_bribe_dialog(struct unit *actor, struct unit *punit, int cost)
+void popup_bribe_dialog(struct unit *actor, struct unit *punit, int cost,
+                        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=35622&r1=35621&r2=35622&view=diff
==============================================================================
--- trunk/client/include/dialogs_g.h    (original)
+++ trunk/client/include/dialogs_g.h    Wed May 17 12:45:42 2017
@@ -65,7 +65,7 @@
 GUI_FUNC_PROTO(void, popup_incite_dialog, struct unit *actor,
                struct city *pcity, int cost, const struct action *paction)
 GUI_FUNC_PROTO(void, popup_bribe_dialog, struct unit *actor,
-               struct unit *punit, int cost)
+               struct unit *punit, int cost, const struct action *paction)
 GUI_FUNC_PROTO(void, popup_sabotage_dialog, struct unit *actor,
                struct city *pcity)
 GUI_FUNC_PROTO(void, popup_pillage_dialog, struct unit *punit, bv_extras 
extras)

Modified: trunk/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=35622&r1=35621&r2=35622&view=diff
==============================================================================
--- trunk/client/packhand.c     (original)
+++ trunk/client/packhand.c     Wed May 17 12:45:42 2017
@@ -4442,7 +4442,7 @@
       /* Focus on the unit so the player knows where it is */
       unit_focus_set(pdiplomat);
 
-      popup_bribe_dialog(pdiplomat, punit, cost);
+      popup_bribe_dialog(pdiplomat, punit, cost, paction);
     } else {
       log_debug("Bad target %d.", target_id);
       action_selection_no_longer_in_progress(diplomat_id);


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

Reply via email to