Author: sveinung
Date: Thu Dec 24 16:33:31 2015
New Revision: 31193

URL: http://svn.gna.org/viewcvs/freeciv?rev=31193&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:
    branches/S2_6/client/control.c
    branches/S2_6/common/actions.h
    branches/S2_6/fc_version
    branches/S2_6/server/unithand.c

Modified: branches/S2_6/client/control.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/control.c?rev=31193&r1=31192&r2=31193&view=diff
==============================================================================
--- branches/S2_6/client/control.c      (original)
+++ branches/S2_6/client/control.c      Thu Dec 24 16:33:31 2015
@@ -2860,12 +2860,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: branches/S2_6/common/actions.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/actions.h?rev=31193&r1=31192&r2=31193&view=diff
==============================================================================
--- branches/S2_6/common/actions.h      (original)
+++ branches/S2_6/common/actions.h      Thu Dec 24 16:33:31 2015
@@ -73,6 +73,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: branches/S2_6/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/fc_version?rev=31193&r1=31192&r2=31193&view=diff
==============================================================================
--- branches/S2_6/fc_version    (original)
+++ branches/S2_6/fc_version    Thu Dec 24 16:33:31 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.Dec.22"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2015.Dec.24"
 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=31193&r1=31192&r2=31193&view=diff
==============================================================================
--- branches/S2_6/server/unithand.c     (original)
+++ branches/S2_6/server/unithand.c     Thu Dec 24 16:33:31 2015
@@ -1045,8 +1045,10 @@
   struct unit *actor_unit = player_unit_by_number(pplayer, actor_id);
   struct unit *punit = game_unit_by_number(target_id);
   struct city *pcity = game_city_by_number(target_id);
-
-  if (!action_id_is_valid(action_type)) {
+  struct tile *target_tile = index_to_tile(target_id);
+
+  if (!(action_type == ACTION_COUNT
+        || action_id_is_valid(action_type))) {
     /* Non existing action */
     log_error("unit_perform_action() the action %d doesn't exist.",
               action_type);
@@ -1293,9 +1295,17 @@
     }
     break;
   case ACTION_COUNT:
-    log_error("handle_unit_do_action() %s (%d) ordered to perform an "
-              "invalid action.",
-              unit_rule_name(actor_unit), actor_id);
+    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;
   }
 }


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

Reply via email to