Author: sveinung
Date: Tue Dec 22 15:52:15 2015
New Revision: 31154

URL: http://svn.gna.org/viewcvs/freeciv?rev=31154&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:
    branches/S2_6/client/control.c
    branches/S2_6/client/control.h
    branches/S2_6/client/gui-gtk-2.0/action_dialog.c
    branches/S2_6/client/gui-gtk-3.0/action_dialog.c
    branches/S2_6/client/gui-qt/dialogs.cpp
    branches/S2_6/client/gui-sdl/action_dialog.c
    branches/S2_6/client/gui-sdl2/action_dialog.c
    branches/S2_6/client/gui-xaw/action_dialog.c
    branches/S2_6/common/actions.h
    branches/S2_6/fc_version
    branches/S2_6/server/actiontools.c
    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=31154&r1=31153&r2=31154&view=diff
==============================================================================
--- branches/S2_6/client/control.c      (original)
+++ branches/S2_6/client/control.c      Tue Dec 22 15:52:15 2015
@@ -1539,6 +1539,43 @@
 }
 
 /**************************************************************************
+  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;
+
+  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: branches/S2_6/client/control.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/control.h?rev=31154&r1=31153&r2=31154&view=diff
==============================================================================
--- branches/S2_6/client/control.h      (original)
+++ branches/S2_6/client/control.h      Tue Dec 22 15:52:15 2015
@@ -72,6 +72,8 @@
                      struct extra_type *tgt,
                     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: branches/S2_6/client/gui-gtk-2.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/action_dialog.c?rev=31154&r1=31153&r2=31154&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/action_dialog.c    (original)
+++ branches/S2_6/client/gui-gtk-2.0/action_dialog.c    Tue Dec 22 15:52:15 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
@@ -910,8 +910,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: branches/S2_6/client/gui-gtk-3.0/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/action_dialog.c?rev=31154&r1=31153&r2=31154&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/action_dialog.c    (original)
+++ branches/S2_6/client/gui-gtk-3.0/action_dialog.c    Tue Dec 22 15:52:15 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
@@ -920,8 +920,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: branches/S2_6/client/gui-qt/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/dialogs.cpp?rev=31154&r1=31153&r2=31154&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/dialogs.cpp     (original)
+++ branches/S2_6/client/gui-qt/dialogs.cpp     Tue Dec 22 15:52:15 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
 
@@ -1707,8 +1707,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: branches/S2_6/client/gui-sdl/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl/action_dialog.c?rev=31154&r1=31153&r2=31154&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl/action_dialog.c        (original)
+++ branches/S2_6/client/gui-sdl/action_dialog.c        Tue Dec 22 15:52:15 2015
@@ -639,8 +639,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: branches/S2_6/client/gui-sdl2/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl2/action_dialog.c?rev=31154&r1=31153&r2=31154&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl2/action_dialog.c       (original)
+++ branches/S2_6/client/gui-sdl2/action_dialog.c       Tue Dec 22 15:52:15 2015
@@ -639,8 +639,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: branches/S2_6/client/gui-xaw/action_dialog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-xaw/action_dialog.c?rev=31154&r1=31153&r2=31154&view=diff
==============================================================================
--- branches/S2_6/client/gui-xaw/action_dialog.c        (original)
+++ branches/S2_6/client/gui-xaw/action_dialog.c        Tue Dec 22 15:52:15 2015
@@ -806,8 +806,7 @@
   if ((punit = game_unit_by_number(diplomat_id))
       && (ptile = (struct tile *)client_data)
       && !same_pos(unit_tile(punit), ptile)) {
-    request_do_action(ACTION_MOVE, diplomat_id,
-                      ptile->index, 0);
+    request_unit_non_action_move(punit, ptile);
   }
   action_decision_taken(diplomat_id);
 }

Modified: branches/S2_6/common/actions.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/actions.h?rev=31154&r1=31153&r2=31154&view=diff
==============================================================================
--- branches/S2_6/common/actions.h      (original)
+++ branches/S2_6/common/actions.h      Tue Dec 22 15:52:15 2015
@@ -70,10 +70,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: branches/S2_6/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/fc_version?rev=31154&r1=31153&r2=31154&view=diff
==============================================================================
--- branches/S2_6/fc_version    (original)
+++ branches/S2_6/fc_version    Tue Dec 22 15:52:15 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.20"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2015.Dec.22"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: branches/S2_6/server/actiontools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/actiontools.c?rev=31154&r1=31153&r2=31154&view=diff
==============================================================================
--- branches/S2_6/server/actiontools.c  (original)
+++ branches/S2_6/server/actiontools.c  Tue Dec 22 15:52:15 2015
@@ -123,7 +123,7 @@
                       " stealing gold from %s."),
                     nation_plural_for_player(offender), victim_link);
       break;
-    case ACTION_MOVE:
+    case ACTION_COUNT:
     case ACTION_ESTABLISH_EMBASSY:
     case ACTION_SPY_INVESTIGATE_CITY:
     case ACTION_TRADE_ROUTE:

Modified: branches/S2_6/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/unithand.c?rev=31154&r1=31153&r2=31154&view=diff
==============================================================================
--- branches/S2_6/server/unithand.c     (original)
+++ branches/S2_6/server/unithand.c     Tue Dec 22 15:52:15 2015
@@ -1043,12 +1043,10 @@
                           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);
   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);
@@ -1294,11 +1292,10 @@
       }
     }
     break;
-  case ACTION_MOVE:
-    if (target_tile
-        && may_non_act_move(actor_unit, pcity, target_tile, FALSE)) {
-      (void) 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