/*
* 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>
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;
}
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;
}
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;
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;