Author: sveinung
Date: Tue Dec 22 15:51:43 2015
New Revision: 31152

URL: http://svn.gna.org/viewcvs/freeciv?rev=31152&view=rev
Log:
Get rid of ACTION_MOVE.

Replace sending the special value ACTION_MOVE in a unit_do_action packet
with sending a unit_orders packet with the special value ORDER_MOVE.

See patch #6710

Modified:
    trunk/client/control.c
    trunk/client/control.h
    trunk/client/gui-gtk-2.0/action_dialog.c
    trunk/client/gui-gtk-3.0/action_dialog.c
    trunk/client/gui-gtk-3.x/action_dialog.c
    trunk/client/gui-qt/dialogs.cpp
    trunk/client/gui-sdl2/action_dialog.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=31152&r1=31151&r2=31152&view=diff
==============================================================================
--- trunk/client/control.c      (original)
+++ trunk/client/control.c      Tue Dec 22 15:51:43 2015
@@ -1592,6 +1592,44 @@
 }
 
 /**************************************************************************
+  Order a unit to move to a neighboring tile without performing an action.
+
+  Does nothing it the destination tile isn't next to the tile where the
+  unit currently is located.
+**************************************************************************/
+void request_unit_non_action_move(struct unit *punit,
+                                  struct tile *dest_tile)
+{
+  struct packet_unit_orders p;
+  int dir;
+
+  dir = get_direction_for_step(unit_tile(punit), dest_tile);
+
+  if (dir == -1) {
+    /* The unit isn't located next to the destination tile. */
+    return;
+  }
+
+  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_MOVE;
+  p.dir[0] = dir;
+  p.activity[0] = ACTIVITY_LAST;
+  p.target[0] = EXTRA_NONE;
+  p.action[0] = ACTION_COUNT;
+
+  send_packet_unit_orders(&client.conn, &p);
+}
+
+/**************************************************************************
   This function is called whenever the player pressed an arrow key.
 
   We do NOT take into account that punit might be a caravan or a diplomat

Modified: trunk/client/control.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/control.h?rev=31152&r1=31151&r2=31152&view=diff
==============================================================================
--- trunk/client/control.h      (original)
+++ trunk/client/control.h      Tue Dec 22 15:51:43 2015
@@ -72,6 +72,8 @@
                      int goto_last_action,
                      enum unit_orders goto_last_order);
 void request_center_focus_unit(void);
+void request_unit_non_action_move(struct unit *punit,
+                                  struct tile *dest_tile);
 void request_move_unit_direction(struct unit *punit, int dir);
 void request_new_unit_activity(struct unit *punit, enum unit_activity act);
 void request_new_unit_activity_targeted(struct unit *punit,

Modified: trunk/client/gui-gtk-2.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/action_dialog.c?rev=31152&r1=31151&r2=31152&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-2.0/action_dialog.c    Tue Dec 22 15:51:43 2015
@@ -49,7 +49,7 @@
 #include "wldlg.h"
 
 /* Locations for non action enabler controlled buttons. */
-#define BUTTON_MOVE ACTION_MOVE
+#define BUTTON_MOVE ACTION_COUNT
 #define BUTTON_LOCATION BUTTON_MOVE + 1
 #define BUTTON_CANCEL BUTTON_MOVE + 2
 #define BUTTON_COUNT BUTTON_MOVE + 3
@@ -1079,8 +1079,7 @@
   if ((punit = game_unit_by_number(args->actor_unit_id))
       && (ptile = index_to_tile(args->target_tile_id))
       && !same_pos(unit_tile(punit), ptile)) {
-    request_do_action(ACTION_MOVE, args->actor_unit_id,
-                      args->target_tile_id, 0, "");
+    request_unit_non_action_move(punit, ptile);
   }
 
   gtk_widget_destroy(act_sel_dialog);

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=31152&r1=31151&r2=31152&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/action_dialog.c    (original)
+++ trunk/client/gui-gtk-3.0/action_dialog.c    Tue Dec 22 15:51:43 2015
@@ -49,7 +49,7 @@
 #include "wldlg.h"
 
 /* Locations for non action enabler controlled buttons. */
-#define BUTTON_MOVE ACTION_MOVE
+#define BUTTON_MOVE ACTION_COUNT
 #define BUTTON_LOCATION BUTTON_MOVE + 1
 #define BUTTON_CANCEL BUTTON_MOVE + 2
 #define BUTTON_COUNT BUTTON_MOVE + 3
@@ -1089,8 +1089,7 @@
   if ((punit = game_unit_by_number(args->actor_unit_id))
       && (ptile = index_to_tile(args->target_tile_id))
       && !same_pos(unit_tile(punit), ptile)) {
-    request_do_action(ACTION_MOVE, args->actor_unit_id,
-                      args->target_tile_id, 0, "");
+    request_unit_non_action_move(punit, ptile);
   }
 
   gtk_widget_destroy(act_sel_dialog);

Modified: trunk/client/gui-gtk-3.x/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/action_dialog.c?rev=31152&r1=31151&r2=31152&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.x/action_dialog.c    (original)
+++ trunk/client/gui-gtk-3.x/action_dialog.c    Tue Dec 22 15:51:43 2015
@@ -49,7 +49,7 @@
 #include "wldlg.h"
 
 /* Locations for non action enabler controlled buttons. */
-#define BUTTON_MOVE ACTION_MOVE
+#define BUTTON_MOVE ACTION_COUNT
 #define BUTTON_LOCATION BUTTON_MOVE + 1
 #define BUTTON_CANCEL BUTTON_MOVE + 2
 #define BUTTON_COUNT BUTTON_MOVE + 3
@@ -1089,8 +1089,7 @@
   if ((punit = game_unit_by_number(args->actor_unit_id))
       && (ptile = index_to_tile(args->target_tile_id))
       && !same_pos(unit_tile(punit), ptile)) {
-    request_do_action(ACTION_MOVE, args->actor_unit_id,
-                      args->target_tile_id, 0, "");
+    request_unit_non_action_move(punit, ptile);
   }
 
   gtk_widget_destroy(act_sel_dialog);

Modified: trunk/client/gui-qt/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/dialogs.cpp?rev=31152&r1=31151&r2=31152&view=diff
==============================================================================
--- trunk/client/gui-qt/dialogs.cpp     (original)
+++ trunk/client/gui-qt/dialogs.cpp     Tue Dec 22 15:51:43 2015
@@ -50,7 +50,7 @@
 #include "sprite.h"
 
 /* Locations for non action enabler controlled buttons. */
-#define BUTTON_MOVE ACTION_MOVE
+#define BUTTON_MOVE ACTION_COUNT
 #define BUTTON_CANCEL BUTTON_MOVE + 1
 #define BUTTON_COUNT BUTTON_MOVE + 2
 
@@ -1953,8 +1953,7 @@
   if ((punit = game_unit_by_number(diplomat_id))
       && (ptile = index_to_tile(diplomat_target_id))
       && !same_pos(unit_tile(punit), ptile)) {
-    request_do_action(ACTION_MOVE, diplomat_id,
-                      diplomat_target_id, 0, "");
+    request_unit_non_action_move(punit, ptile);
   }
 }
 

Modified: trunk/client/gui-sdl2/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/action_dialog.c?rev=31152&r1=31151&r2=31152&view=diff
==============================================================================
--- trunk/client/gui-sdl2/action_dialog.c       (original)
+++ trunk/client/gui-sdl2/action_dialog.c       Tue Dec 22 15:51:43 2015
@@ -725,8 +725,7 @@
 
     if ((punit = game_unit_by_number(pDiplomat_Dlg->actor_unit_id))
         && !same_pos(unit_tile(punit), pWidget->data.tile)) {
-      request_do_action(ACTION_MOVE, pDiplomat_Dlg->actor_unit_id,
-                        pWidget->data.tile->index, 0, "");
+      request_unit_non_action_move(punit, pWidget->data.tile);
     }
 
     action_decision_taken(pDiplomat_Dlg->actor_unit_id);

Modified: trunk/common/actions.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.h?rev=31152&r1=31151&r2=31152&view=diff
==============================================================================
--- trunk/common/actions.h      (original)
+++ trunk/common/actions.h      Tue Dec 22 15:51:43 2015
@@ -101,10 +101,6 @@
 #define SPECENUM_COUNT ACTION_COUNT
 #include "specenum_gen.h"
 
-/* Used in the network protocol to signal that the unit should move in
- * stead of trying to act. */
-#define ACTION_MOVE ACTION_COUNT
-
 /* Used in searches to signal that any action at all is OK. */
 #define ACTION_ANY ACTION_COUNT
 

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=31152&r1=31151&r2=31152&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Tue Dec 22 15:51:43 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.20"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Dec.22"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=31152&r1=31151&r2=31152&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Tue Dec 22 15:51:43 2015
@@ -1425,9 +1425,7 @@
   Execute a request to perform an action and let the caller know if it was
   performed or not.
 
-  The action can be a valid action or the special value ACTION_MOVE.
-  ACTION_MOVE will move the unit even if it may be able to perform an
-  action against something at the target tile.
+  The action must be a valid action.
 
   Returns TRUE iff action could be done, FALSE if it couldn't. Even if
   this returns TRUE, unit may have died during the action.
@@ -1445,8 +1443,7 @@
   struct unit *punit = game_unit_by_number(target_id);
   struct city *pcity = game_city_by_number(target_id);
 
-  if (!(action_type == ACTION_MOVE
-        || action_id_is_valid(action_type))) {
+  if (!action_id_is_valid(action_type)) {
     /* Non existing action */
     log_error("unit_perform_action() the action %d doesn't exist.",
               action_type);
@@ -1896,11 +1893,10 @@
       }
     }
     break;
-  case ACTION_MOVE:
-    if (target_tile
-        && may_non_act_move(actor_unit, pcity, target_tile, FALSE)) {
-      return unit_move_handling(actor_unit, target_tile, FALSE, TRUE);
-    }
+  case ACTION_COUNT:
+    log_error("handle_unit_do_action() %s (%d) ordered to perform an "
+              "invalid action.",
+              unit_rule_name(actor_unit), actor_id);
     break;
   }
 


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

Reply via email to