Author: sveinung
Date: Sun Jan 25 04:42:40 2015
New Revision: 27819

URL: http://svn.gna.org/viewcvs/freeciv?rev=27819&view=rev
Log:
Protocol: Get rid of the unit_move packet.

Send the order to move a single tile using the unit_orders packet in stead.

See patch #5729

Modified:
    trunk/client/control.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=27819&r1=27818&r2=27819&view=diff
==============================================================================
--- trunk/client/control.c      (original)
+++ trunk/client/control.c      Sun Jan 25 04:42:40 2015
@@ -1517,6 +1517,7 @@
 **************************************************************************/
 void request_move_unit_direction(struct unit *punit, int dir)
 {
+  struct packet_unit_orders p;
   struct tile *dest_tile;
 
   /* Catches attempts to move off map */
@@ -1525,12 +1526,29 @@
     return;
   }
 
-  if (punit->moves_left > 0) {
-    dsend_packet_unit_move(&client.conn, punit->id, tile_index(dest_tile));
-  } else {
-    /* Initiate a "goto" with direction keys for exhausted units. */
-    send_goto_tile(punit, dest_tile);
-  }
+  /* The goto system isn't used to send the order because that would
+   * prevent direction movement from overriding it.
+   * Example of a situation when overriding the goto system is useful:
+   * The goto system creates a longer path to make a move legal. The player
+   * wishes to order the illegal move so the server will explain why the
+   * short move is illegal. */
+
+  memset(&p, 0, sizeof(p));
+
+  p.repeat = FALSE;
+  p.vigilant = FALSE;
+
+  p.unit_id = punit->id;
+  p.src_tile = tile_index(unit_tile(punit));
+  p.dest_tile = tile_index(dest_tile);
+
+  p.length = 1;
+  p.orders[0] = ORDER_ACTION_MOVE;
+  p.dir[0] = dir;
+  p.activity[0] = ACTIVITY_LAST;
+  p.target[0] = EXTRA_NONE;
+
+  send_packet_unit_orders(&client.conn, &p);
 }
 
 /**************************************************************************

Modified: trunk/common/packets.def
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/packets.def?rev=27819&r1=27818&r2=27819&view=diff
==============================================================================
--- trunk/common/packets.def    (original)
+++ trunk/common/packets.def    Sun Jan 25 04:42:40 2015
@@ -925,11 +925,6 @@
   BOOL make_winner_veteran;
 end
 
-PACKET_UNIT_MOVE = 66;cs, dsend
-  UNIT unit_id;
-  TILE tile;
-end
-
 PACKET_UNIT_BUILD_CITY = 67; cs, dsend
   UNIT unit_id;
   STRING name[MAX_LEN_NAME];

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=27819&r1=27818&r2=27819&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Sun Jan 25 04:42:40 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.Jan.22"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Jan.25"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=27819&r1=27818&r2=27819&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Sun Jan 25 04:42:40 2015
@@ -1500,54 +1500,6 @@
   }
 
   handle_unit_change_activity_real(pplayer, unit_id, activity, 
activity_target);
-}
-
-/**************************************************************************
-  Handle unit move request.
-**************************************************************************/
-void handle_unit_move(struct player *pplayer, int unit_id, int tile)
-{
-  struct unit *punit = player_unit_by_number(pplayer, unit_id);
-  struct tile *ptile = index_to_tile(tile);
-
-  if (NULL == punit) {
-    /* Probably died or bribed. */
-    log_verbose("handle_unit_move() invalid unit %d", unit_id);
-    return;
-  }
-
-  if (NULL == ptile) {
-    /* Shouldn't happen */
-    log_error("handle_unit_move() invalid tile index (%d) for %s (%d)",
-              tile, unit_rule_name(punit), unit_id);
-    return;
-  }
-
-  if (!is_tiles_adjacent(unit_tile(punit), ptile)) {
-    /* Client is out of sync, ignore */
-    log_verbose("handle_unit_move() invalid %s (%d) move "
-                "from (%d, %d) to (%d, %d).",
-                unit_rule_name(punit), unit_id,
-                TILE_XY(unit_tile(punit)), TILE_XY(ptile));
-    return;
-  }
-
-  if (!is_player_phase(unit_owner(punit), game.info.phase)) {
-    /* Client is out of sync, ignore */
-    log_verbose("handle_unit_move() invalid %s (%d) %s != phase %d",
-                unit_rule_name(punit),
-                unit_id,
-                nation_rule_name(nation_of_unit(punit)),
-                game.info.phase);
-    return;
-  }
-
-  if (ACTIVITY_IDLE != punit->activity) {
-    /* Else, the unit cannot move. */
-    unit_activity_handling(punit, ACTIVITY_IDLE);
-  }
-
-  (void) unit_move_handling(punit, ptile, FALSE, FALSE);
 }
 
 /**************************************************************************


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

Reply via email to