Author: sveinung
Date: Sun Oct 11 19:21:40 2015
New Revision: 30052

URL: http://svn.gna.org/viewcvs/freeciv?rev=30052&view=rev
Log:
Define the constant DIR8_ORIGIN

Use it, rather than the magic value -1, in situations where the lack of a
direction in an enum direction8 variable means the tile a direction would
have been relative to.

The reason for using DIR8_ORIGIN rather than using direction8_invalid()
directly is to make it easier to separate "set to this tile" from "invalid
or buggy value" in the future. At the moment DIR8_ORIGIN is set to -1 via
direction8_invalid().

See patch #6393

Modified:
    branches/S2_6/client/control.c
    branches/S2_6/client/goto.c
    branches/S2_6/common/fc_types.h

Modified: branches/S2_6/client/control.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/control.c?rev=30052&r1=30051&r2=30052&view=diff
==============================================================================
--- branches/S2_6/client/control.c      (original)
+++ branches/S2_6/client/control.c      Sun Oct 11 19:21:40 2015
@@ -1347,7 +1347,7 @@
       struct unit_order order;
 
       order.order = ORDER_ACTIVITY;
-      order.dir = -1;
+      order.dir = DIR8_ORIGIN;
       order.activity = ACTIVITY_SENTRY;
       order.target = EXTRA_NONE;
       send_goto_path(punit, path, &order);

Modified: branches/S2_6/client/goto.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/goto.c?rev=30052&r1=30051&r2=30052&view=diff
==============================================================================
--- branches/S2_6/client/goto.c (original)
+++ branches/S2_6/client/goto.c Sun Oct 11 19:21:40 2015
@@ -1381,7 +1381,7 @@
 
     if (same_pos(new_tile, old_tile)) {
       p.orders[i] = ORDER_FULL_MP;
-      p.dir[i] = -1;
+      p.dir[i] = DIR8_ORIGIN;
       p.activity[i] = ACTIVITY_LAST;
       p.target[i] = EXTRA_NONE;
       log_goto_packet("  packet[%d] = wait: %d,%d", i, TILE_XY(old_tile));
@@ -1501,7 +1501,7 @@
   } extra_deps_iterate_end;
 
   p->orders[p->length] = ORDER_ACTIVITY;
-  p->dir[p->length] = -1;
+  p->dir[p->length] = DIR8_ORIGIN;
   p->activity[p->length] = ACTIVITY_GEN_ROAD;
   p->target[p->length] = extra_index(pextra);
   p->length++;
@@ -1549,7 +1549,7 @@
        if (!tile_has_extra(old_tile, tgt)) {
          /* Assume the unit can irrigate or we wouldn't be here. */
          p.orders[p.length] = ORDER_ACTIVITY;
-          p.dir[p.length] = -1;
+          p.dir[p.length] = DIR8_ORIGIN;
          p.activity[p.length] = ACTIVITY_IRRIGATE;
           p.target[p.length] = extra_index(tgt);
          p.length++;
@@ -1613,7 +1613,7 @@
       struct unit_order order;
 
       order.order = goto_last_order;
-      order.dir = -1;
+      order.dir = DIR8_ORIGIN;
       order.activity = ACTIVITY_LAST;
       order.target = EXTRA_NONE;
 

Modified: branches/S2_6/common/fc_types.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/fc_types.h?rev=30052&r1=30051&r2=30052&view=diff
==============================================================================
--- branches/S2_6/common/fc_types.h     (original)
+++ branches/S2_6/common/fc_types.h     Sun Oct 11 19:21:40 2015
@@ -211,6 +211,10 @@
 #define SPECENUM_VALUE7 DIR8_SOUTHEAST
 #define SPECENUM_VALUE7NAME "Southeast"
 #include "specenum_gen.h"
+
+/* No direction. Understood as the origin tile that a direction would have
+ * been relative to. */
+#define DIR8_ORIGIN direction8_invalid()
 
 /* Used in the network protocol. */
 #define SPECENUM_NAME free_tech_method


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

Reply via email to