]> git.pond.sub.org Git - empserver/blobdiff - src/lib/common/xy.c
Update copyright notice
[empserver] / src / lib / common / xy.c
index 1f7021770b0076f6b884bfe87c34d49b6bd47aa0..f6f84389377f4b16876a829134872d682d570651 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
  *  ---
  *
  *  xy.c: x-y related conversion routines
- * 
+ *
  *  Known contributors to this file:
  *     Dave Pare, 1989
+ *     Markus Armbruster, 2004-2008
  */
 
 #include <config.h>
@@ -71,8 +72,6 @@ xrel(struct natstr *np, coord absx)
     x = XNORM(absx - np->nat_xorg);
     if (x >= WORLD_X / 2)
        x -= WORLD_X;
-    else if (x < -WORLD_X / 2)
-       x += WORLD_X;
     return x;
 }
 
@@ -84,8 +83,6 @@ yrel(struct natstr *np, coord absy)
     y = YNORM(absy - np->nat_yorg);
     if (y >= WORLD_Y / 2)
        y -= WORLD_Y;
-    else if (y < -WORLD_Y / 2)
-       y += WORLD_Y;
     return y;
 }
 
@@ -174,23 +171,19 @@ sctoff(coord x, coord y)
 coord
 xnorm(coord x)
 {
-    if (x < 0)
-       x = WORLD_X - (-x % WORLD_X);
-    return x % WORLD_X;
+    return XNORM(x);
 }
 
 coord
 ynorm(coord y)
 {
-    if (y < 0)
-       y = WORLD_Y - (-y % WORLD_Y);
-    return y % WORLD_Y;
+    return YNORM(y);
 }
 
 int
 xyinrange(coord x, coord y, struct range *rp)
 {
-    if (rp->lx < rp->hx) {
+    if (rp->lx <= rp->hx) {
        /* xrange doesn't wrap */
        if (x < rp->lx || x > rp->hx)
            return 0;
@@ -198,7 +191,7 @@ xyinrange(coord x, coord y, struct range *rp)
        if (x < rp->lx && x > rp->hx)
            return 0;
     }
-    if (rp->ly < rp->hy) {
+    if (rp->ly <= rp->hy) {
        /* yrange doesn't wrap */
        if (y < rp->ly || y > rp->hy)
            return 0;