Author: sveinung
Date: Thu Dec 24 16:32:34 2015
New Revision: 31192

URL: http://svn.gna.org/viewcvs/freeciv?rev=31192&view=rev
Log:
Make "Do..." apply to all selected units.

The player can ask what actions a unit can perform to its own tile. This is
done via the "Do..." menu item or by pressing "d".

Pressing "d" when more than one unit is selected would result in the client
asking about the first selected unit capable of performing an action. Ask
about all the selected units instead. (The action selection dialogs are
queued)

See patch #6720

Modified:
    trunk/client/control.c
    trunk/common/actions.h
    trunk/fc_version
    trunk/server/unithand.c

Modified: trunk/client/control.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/control.c?rev=31192&r1=31191&r2=31192&view=diff
==============================================================================
--- trunk/client/control.c      (original)
+++ trunk/client/control.c      Thu Dec 24 16:32:34 2015
@@ -2840,12 +2840,10 @@
   unit_list_iterate(get_units_in_focus(), punit) {
     if (utype_may_act_at_all(unit_type_get(punit))
         && (ptile = unit_tile(punit))) {
-      /* Data for ask_server_for_actions() */
-      punit->action_decision_tile = ptile;
-
-      ask_server_for_actions(punit);
-      return;
-      /* FIXME: diplomat dialog for more than one unit at a time. */
+      /* Have the server record that an action decision is wanted for this
+       * unit. */
+      request_do_action(ACTION_COUNT, punit->id, tile_index(ptile),
+                        ACTSIG_QUEUE, "");
     }
   } unit_list_iterate_end;
 }

Modified: trunk/common/actions.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.h?rev=31192&r1=31191&r2=31192&view=diff
==============================================================================
--- trunk/common/actions.h      (original)
+++ trunk/common/actions.h      Thu Dec 24 16:32:34 2015
@@ -104,6 +104,13 @@
 /* Used in searches to signal that any action at all is OK. */
 #define ACTION_ANY ACTION_COUNT
 
+/* Used in the network protocol */
+#define SPECENUM_NAME action_proto_signal
+/* The player wants to be reminded to ask what actions the unit can perform
+ * to a certain target tile. */
+#define SPECENUM_VALUE0 ACTSIG_QUEUE
+#include "specenum_gen.h"
+
 /*
  * Action probability
  *

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=31192&r1=31191&r2=31192&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Thu Dec 24 16:32:34 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.Dec.22"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Dec.24"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=31192&r1=31191&r2=31192&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Thu Dec 24 16:32:34 2015
@@ -1430,16 +1430,42 @@
 
 /**************************************************************************
   Handle a request to do an action.
+
+  action_type can be a valid action or a ACTION_COUNT. ACTION_COUNT signals
+  that a special value used for in band signaling can be found in value.
+  The in band signaling values are:
+    ACTSIG_QUEUE - remind the player to ask what actions the unit can do
+                   to the target tile.
 **************************************************************************/
 void handle_unit_do_action(struct player *pplayer,
                           const int actor_id,
                           const int target_id,
                           const int value,
                            const char *name,
-                          const enum gen_action action_type)
-{
-  (void) unit_perform_action(pplayer, actor_id, target_id, value, name,
-                             action_type, ACT_REQ_PLAYER);
+                           const enum gen_action action_type)
+{
+  struct unit *actor_unit = player_unit_by_number(pplayer, actor_id);
+  struct tile *target_tile = index_to_tile(target_id);
+
+  switch (action_type) {
+  case ACTION_COUNT:
+    switch ((enum action_proto_signal)value) {
+    case ACTSIG_QUEUE:
+      actor_unit->action_decision_want = ACT_DEC_ACTIVE;
+      actor_unit->action_decision_tile = target_tile;
+
+      /* Let the client know that this unit needs the player to decide
+       * what to do. */
+      send_unit_info(player_reply_dest(pplayer), actor_unit);
+
+      break;
+    }
+    break;
+  default:
+    (void) unit_perform_action(pplayer, actor_id, target_id, value, name,
+                               action_type, ACT_REQ_PLAYER);
+    break;
+  }
 }
 
 /**************************************************************************


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

Reply via email to