Author: sveinung
Date: Wed Dec 17 13:08:01 2014
New Revision: 27324

URL: http://svn.gna.org/viewcvs/freeciv?rev=27324&view=rev
Log:
Allow the client to select what target to get action probabilities for.

Use this to make sure that the targets won't accidentally change when the client
requests an update to an open action selection dialog.

See patch #5571

Modified:
    trunk/client/control.c
    trunk/client/packhand.c
    trunk/common/packets.def
    trunk/fc_version
    trunk/server/unithand.c

Modified: trunk/client/control.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/control.c?rev=27324&r1=27323&r2=27324&view=diff
==============================================================================
--- trunk/client/control.c      (original)
+++ trunk/client/control.c      Wed Dec 17 13:08:01 2014
@@ -958,7 +958,10 @@
     if (ptile && pdiplomat && is_actor_unit(pdiplomat)) {
       have_asked_server_for_actions = TRUE;
       dsend_packet_unit_get_actions(&client.conn,
-                                    diplomat_id, target_tile_id,
+                                    diplomat_id,
+                                    IDENTITY_NUMBER_ZERO,
+                                    IDENTITY_NUMBER_ZERO,
+                                    target_tile_id,
                                     TRUE);
       return;
     }

Modified: trunk/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=27324&r1=27323&r2=27324&view=diff
==============================================================================
--- trunk/client/packhand.c     (original)
+++ trunk/client/packhand.c     Wed Dec 17 13:08:01 2014
@@ -846,6 +846,8 @@
       && action_selection_target_city() == pcity->id) {   
     dsend_packet_unit_get_actions(&client.conn,
                                   action_selection_actor_unit(),
+                                  action_selection_target_unit(),
+                                  action_selection_target_city(),
                                   city_tile(pcity)->index,
                                   FALSE);
   }
@@ -2339,6 +2341,8 @@
        * the set of available actions. */
       dsend_packet_unit_get_actions(&client.conn,
                                     action_selection_actor_unit(),
+                                    action_selection_target_unit(),
+                                    action_selection_target_city(),
                                     tgt_tile->index,
                                     FALSE);
     }

Modified: trunk/common/packets.def
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/packets.def?rev=27324&r1=27323&r2=27324&view=diff
==============================================================================
--- trunk/common/packets.def    (original)
+++ trunk/common/packets.def    Wed Dec 17 13:08:01 2014
@@ -1027,6 +1027,8 @@
 
 PACKET_UNIT_GET_ACTIONS = 87; cs, handle-per-conn, dsend
   UNIT actor_unit_id;
+  UNIT target_unit_id;
+  CITY target_city_id;
   TILE target_tile_id;
 
   BOOL disturb_player;

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=27324&r1=27323&r2=27324&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Wed Dec 17 13:08:01 2014
@@ -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-2014.Dec.15"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2014.Dec.17"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=27324&r1=27323&r2=27324&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Wed Dec 17 13:08:01 2014
@@ -376,6 +376,8 @@
 **************************************************************************/
 void handle_unit_get_actions(struct connection *pc,
                              const int actor_unit_id,
+                             const int target_unit_id_client,
+                             const int target_city_id_client,
                              const int target_tile_id,
                              const bool disturb_player)
 {
@@ -414,9 +416,25 @@
     return;
   }
 
-  /* Find targets. */
-  target_unit = tgt_unit(actor_unit, target_tile);
-  target_city = tgt_city(actor_unit, target_tile);
+  /* Select the targets. */
+
+  if (target_unit_id_client == IDENTITY_NUMBER_ZERO) {
+    /* Find a new target unit. */
+    target_unit = tgt_unit(actor_unit, target_tile);
+  } else {
+    /* Prepare the client selected target unit. */
+    target_unit = game_unit_by_number(target_unit_id_client);
+  }
+
+  if (target_city_id_client == IDENTITY_NUMBER_ZERO) {
+    /* Find a new target city. */
+    target_city = tgt_city(actor_unit, target_tile);
+  } else {
+    /* Prepare the client selected target city. */
+    target_city = game_city_by_number(target_city_id_client);
+  }
+
+  /* Find out what can be done to the targets. */
 
   /* Set the probability for the actions. */
   action_iterate(act) {


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

Reply via email to