Author: sveinung
Date: Sun Oct 11 19:18:45 2015
New Revision: 30048

URL: http://svn.gna.org/viewcvs/freeciv?rev=30048&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:
    trunk/client/control.c
    trunk/client/goto.c
    trunk/common/fc_types.h

Modified: trunk/client/control.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/control.c?rev=30048&r1=30047&r2=30048&view=diff
==============================================================================
--- trunk/client/control.c      (original)
+++ trunk/client/control.c      Sun Oct 11 19:18:45 2015
@@ -1395,7 +1395,7 @@
       struct unit_order order;
 
       order.order = ORDER_ACTIVITY;
-      order.dir = -1;
+      order.dir = DIR8_ORIGIN;
       order.activity = ACTIVITY_SENTRY;
       order.target = EXTRA_NONE;
       order.action = ACTION_COUNT;

Modified: trunk/client/goto.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/goto.c?rev=30048&r1=30047&r2=30048&view=diff
==============================================================================
--- trunk/client/goto.c (original)
+++ trunk/client/goto.c Sun Oct 11 19:18:45 2015
@@ -1382,7 +1382,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;
       p.action[i] = ACTION_COUNT;
@@ -1518,7 +1518,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->action[p->length] = ACTION_COUNT;
@@ -1567,7 +1567,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.action[p.length] = ACTION_COUNT;
@@ -1633,7 +1633,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;
       order.action = goto_last_action;

Modified: trunk/common/fc_types.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/fc_types.h?rev=30048&r1=30047&r2=30048&view=diff
==============================================================================
--- trunk/common/fc_types.h     (original)
+++ trunk/common/fc_types.h     Sun Oct 11 19:18:45 2015
@@ -212,6 +212,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