]> git.pond.sub.org Git - empserver/blobdiff - include/xy.h
Update copyright notice
[empserver] / include / xy.h
index 8a4d3c2fe4e7fdfdfb2e5d7bc5d0211cf669d4d9..851d3d1cfd5b48f3af5a5ed8937039554b78011e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
  *
  *  ---
  *
- *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
- *  related information and legal notices. It is expected that any future
- *  projects/authors will amend these files as needed.
+ *  See files README, COPYING and CREDITS in the root of the source
+ *  tree for related information and legal notices.  It is expected
+ *  that future projects/authors will amend these files as needed.
  *
  *  ---
  *
  *  xy.h: Constants having to do with world locations.
- * 
+ *
  *  Known contributors to this file:
  *     Steve McClure, 1998
  */
 #ifndef XY_H
 #define XY_H
 
-#include "sect.h"
-#include "nat.h"
+#include "types.h"
+
+/* Return the number of sectors in the world */
+#define WORLD_SZ() (WORLD_X * WORLD_Y / 2)
 
-/* Used to calculate an offset into an array.  Used for
-   dynamically sizing the world. */
-#define XYOFFSET(x, y) ((y * WORLD_X) + x)
+/* Fast version of sctoff() for normalized arguments */
+#define XYOFFSET(x, y) (((y) * WORLD_X + (x)) / 2)
 
-#define XNORM(x) (((x)<0) ? ((WORLD_X-(-(x)%WORLD_X))%WORLD_X) : ((x)%WORLD_X))
-#define YNORM(y) (((y)<0) ? ((WORLD_Y-(-(y)%WORLD_Y))%WORLD_Y) : ((y)%WORLD_Y))
+#define XNORM(x) \
+    (((x) < 0) ? (WORLD_X - 1 - ((-(x) - 1) % WORLD_X)) : ((x) % WORLD_X))
+#define YNORM(y) \
+    (((y) < 0) ? (WORLD_Y - 1 - ((-(y) - 1) % WORLD_Y)) : ((y) % WORLD_Y))
 
 struct range {
-    coord lx;                  /* low-range x,y */
-    coord ly;
-    coord hx;                  /* high-range x,y */
-    coord hy;
-    int width;                 /* range width, height */
-    int height;
+    coord lx, ly;              /* low-range x,y (inclusive) */
+    coord hx, hy;              /* high-range x,y (inclusive) */
+    int width, height;
 };
 
 extern char *xyas(coord x, coord y, natid country);