OBJS = bestpath.o bridgefall.o check.o damage.o file.o fsize.o getvar.o \
hap_fact.o hours.o keyword.o land.o log.o mailbox.o maps.o move.o \
- nat.o nstr_subs.o path.o res_pop.o sectdamage.o snxtit_subs.o \
- snxtsct_subs.o stmtch.o tfact.o type.o vlist.o wantupd.o xy.o
+ nat.o path.o res_pop.o sectdamage.o \
+ stmtch.o tfact.o type.o vlist.o wantupd.o xy.o
NTOBJS = bestpath.obj bridgefall.obj check.obj damage.obj file.obj fsize.obj \
getvar.obj hap_fact.obj hours.obj keyword.obj land.obj log.obj \
- mailbox.obj maps.obj move.obj nat.obj nstr_subs.obj path.obj res_pop.obj \
- sectdamage.obj snxtit_subs.obj snxtsct_subs.obj stmtch.obj tfact.obj \
+ mailbox.obj maps.obj move.obj nat.obj path.obj res_pop.obj \
+ sectdamage.obj stmtch.obj tfact.obj \
type.obj vlist.obj wantupd.obj xy.obj
all: $(LIB)
+++ /dev/null
-/*
- * Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
- * Ken Stevens, Steve McClure
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * ---
- *
- * 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.
- *
- * ---
- *
- * nstr.c: Compile and execute the item selections on sectors
- *
- * Known contributors to this file:
- * Dave Pare, 1989
- */
-
-#include <ctype.h>
-#include "struct.h"
-#include "misc.h"
-#include "var.h"
-#include "xy.h"
-#include "sect.h"
-#include "nsc.h"
-#include "nat.h"
-#include "match.h"
-#include "file.h"
-#include "player.h"
-#include "common.h"
-#include "gen.h"
-
-/*
- * return true if the conditions on this item
- * are all true.
- */
-int
-nstr_exec(struct nscstr *conds, register int ncond, void *ptr, int type)
-{
- register struct nscstr *nsc;
- register int op;
- register int lhs;
- register int rhs;
- register int oper;
-
- for (nsc = conds; --ncond >= 0; nsc++) {
- oper = nsc->oper;
- if (oper > 65535) {
- oper = oper - 65535;
- rhs = nsc->fld2;
- } else
- rhs = decode(player->cnum, nsc->fld2, ptr, type);
-
- if (oper > 255) {
- oper = oper - 255;
- lhs = nsc->fld1;
- } else
- lhs = decode(player->cnum, nsc->fld1, ptr, type);
-
- op = oper;
- if ((op == '<' && lhs >= rhs)
- || (op == '=' && lhs != rhs)
- || (op == '>' && lhs <= rhs)
- || (op == '#' && lhs == rhs))
- return 0;
- }
- return 1;
-}
-
-int
-decode(natid cnum, long int code, void *addr, int type)
-{
- register int val;
- register int nsc_code;
- struct natstr *np;
- long code_type = (code & NSC_TMASK);
-
- val = (code & ~NSC_MASK) & 0xffff;
-
- /* handle negative numbers properly */
- /* this assumes a binary two's complement number representation */
- if (val >= 0x8000)
- val -= 0x10000;
-
- nsc_code = code & NSC_CMASK;
- if (nsc_code == NSC_VAR) {
- val = getvar(val, addr, type);
- } else if (nsc_code == NSC_OFF) {
- /*
- * add offset to value
- */
- addr = (s_char *)addr + val;
- switch (code_type) {
- case NSC_TIME:
- val = *((time_t *) addr);
- break;
- case NSC_CHAR:
- val = *((s_char *)addr);
- break;
- case NSC_UCHAR:
- val = (int)*((unsigned char *)addr);
- break;
- case NSC_SHORT:
- val = *((short *)addr);
- break;
- case NSC_USHORT:
- val = *((u_short *)addr);
- break;
- case NSC_INT:
- val = *((int *)addr);
- break;
- case NSC_LONG:
- val = *((long *)addr);
- break;
- case NSC_XCOORD:
- val = *((short *)addr);
- np = getnatp(cnum);
- val = xrel(np, val);
- break;
- case NSC_YCOORD:
- val = *((short *)addr);
- np = getnatp(cnum);
- val = yrel(np, val);
- break;
- default:
- logerror("bad type in decode: %x!\n", code & NSC_TMASK);
- val = 0;
- break;
- }
- }
- if (code & NSC_ROUND)
- val = roundintby(val, 10);
- return val;
-}
-
-s_char *
-decodep(long int code, void *addr)
-{
- addr = (char *)addr + ((code & ~NSC_MASK) & 0xffff);
-
- if ((code & NSC_TMASK) == NSC_CHARP)
- return *(s_char **)addr ? *((s_char **)addr) : (s_char *)"";
- return addr;
-}
+++ /dev/null
-/*
- * Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
- * Ken Stevens, Steve McClure
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * ---
- *
- * 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.
- *
- * ---
- *
- * snxtit_subs.c: arrange item selection using one of many criteria.
- *
- * Known contributors to this file:
- * Dave Pare, 1989
- */
-
-#include "misc.h"
-#include "var.h"
-#include "xy.h"
-#include "sect.h"
-#include "nsc.h"
-#include "file.h"
-#include "common.h"
-
-void
-snxtitem_area(register struct nstr_item *np, int type, struct range *range)
-{
- memset(np, 0, sizeof(*np));
- np->cur = -1;
- np->type = type;
- np->sel = NS_AREA;
- np->index = -1;
- np->range = *range;
- np->read = ef_read;
- np->flags = ef_flags(type);
- xysize_range(&np->range);
- ef_zapcache(type);
-}
-
-void
-snxtitem_dist(register struct nstr_item *np, int type, int cx, int cy,
- int dist)
-{
- struct range range;
-
- memset(np, 0, sizeof(*np));
- xydist_range(cx, cy, dist, &range);
- np->cur = -1;
- np->type = type;
- np->sel = NS_DIST;
- np->cx = cx;
- np->cy = cy;
- np->index = -1;
- np->range = range;
- np->dist = dist;
- np->read = ef_read;
- np->flags = ef_flags(type);
-#if 0
- /* This is no longer proper. */
- /* It did the wrong thing for small, hitech worlds. */
- xysize_range(&np->range);
-#endif
- ef_zapcache(type);
-}
-
-void
-snxtitem_xy(register struct nstr_item *np, int type, coord x, coord y)
-{
- memset(np, 0, sizeof(*np));
- np->cur = -1;
- np->type = type;
- np->sel = NS_XY;
- np->cx = xnorm(x);
- np->cy = ynorm(y);
- np->index = -1;
- np->dist = 0;
- np->read = ef_read;
- np->flags = ef_flags(type);
- ef_zapcache(type);
-}
-
-void
-snxtitem_all(register struct nstr_item *np, int type)
-{
- memset(np, 0, sizeof(*np));
- np->cur = -1;
- np->sel = NS_ALL;
- np->type = type;
- np->index = -1;
- np->read = ef_read;
- np->flags = ef_flags(type);
- xysize_range(&np->range);
- ef_zapcache(type);
-}
-
-void
-snxtitem_group(register struct nstr_item *np, int type, s_char group)
-{
- if (group == '~')
- group = ' ';
- memset(np, 0, sizeof(*np));
- np->cur = -1;
- np->sel = NS_GROUP;
- np->group = group;
- np->type = type;
- np->index = -1;
- np->read = ef_read;
- np->flags = ef_flags(type);
- xysize_range(&np->range);
- ef_zapcache(type);
-}
-
-void
-snxtitem_rewind(struct nstr_item *np)
-{
- np->cur = -1;
- np->index = -1;
- ef_zapcache(np->type);
-}
-
-int
-snxtitem_list(register struct nstr_item *np, int type, int *list, int len)
-{
- int i;
-
- memset(np, 0, sizeof(*np));
- np->cur = -1;
- np->type = type;
- np->sel = NS_LIST;
- np->index = -1;
- np->read = ef_read;
- np->flags = ef_flags(type);
- if (len <= 0 || len > NS_LSIZE)
- return 0;
- for (i = 0; i < len; i++)
- np->list[i] = list[i];
- np->size = len;
- ef_zapcache(type);
- return 1;
-}
+++ /dev/null
-/*
- * Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
- * Ken Stevens, Steve McClure
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * ---
- *
- * 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.
- *
- * ---
- *
- * snxtsct_subs.c: arrange sector selection using either distance or area
- *
- * Known contributors to this file:
- * Dave Pare, 1989
- */
-/*
- * XXX we can *almost* treat sectors as items, but not quite.
- * Items are retrieved using id's, and sectors still use x,y.
- */
-
-#include "misc.h"
-#include "var.h"
-#include "xy.h"
-#include "sect.h"
-#include "nsc.h"
-#include "file.h"
-#include "common.h"
-#include "optlist.h"
-
-void
-snxtsct_all(struct nstr_sect *np)
-{
- struct range worldrange;
-
- worldrange.lx = -WORLD_X / 2;
- worldrange.ly = -WORLD_Y / 2;
- worldrange.hx = WORLD_X / 2;
- worldrange.hy = WORLD_Y / 2;
- worldrange.width = worldrange.height = 0;
- snxtsct_area(np, &worldrange);
-}
-
-void
-snxtsct_area(register struct nstr_sect *np, struct range *range)
-{
- memset(np, 0, sizeof(*np));
- np->range = *range;
- np->ncond = 0;
- np->type = NS_AREA;
- np->read = ef_read;
- np->x = np->range.lx - 1;
- np->y = np->range.ly;
- np->dx = -1;
- np->dy = 0;
- xysize_range(&np->range);
- ef_zapcache(EF_SECTOR);
-}
-
-void
-snxtsct_rewind(struct nstr_sect *np)
-{
- np->x = np->range.lx - 1;
- np->y = np->range.ly;
- np->dx = -1;
- np->dy = 0;
- np->id = -1;
- ef_zapcache(EF_SECTOR);
-}
-
-void
-snxtsct_dist(register struct nstr_sect *np, coord cx, coord cy, int dist)
-{
- memset(np, 0, sizeof(*np));
- xydist_range(cx, cy, dist, &np->range);
- np->cx = cx;
- np->cy = cy;
- np->ncond = 0;
- np->dist = dist;
- np->type = NS_DIST;
- np->read = ef_read;
- np->x = np->range.lx - 1;
- np->y = np->range.ly;
- np->dx = -1;
- np->dy = 0;
-#if 0
- /* This function is now done elsewhere. */
- /* It was not doing the right thing when the world was small */
- xysize_range(&np->range);
-#endif
- ef_zapcache(EF_SECTOR);
-}
-
-void
-xysize_range(register struct range *rp)
-{
- if (rp->lx >= rp->hx)
- rp->width = WORLD_X + rp->hx - rp->lx;
- else
- rp->width = rp->hx - rp->lx;
-#ifndef HAY
- /* This is a necessary check for small, hitech worlds. */
- if (rp->width > WORLD_X)
- rp->width = WORLD_X;
-#endif
- if (rp->ly >= rp->hy)
- rp->height = WORLD_Y + rp->hy - rp->ly;
- else
- rp->height = rp->hy - rp->ly;
-#ifndef HAY
- /* This is a necessary check for small, hitech worlds. */
- if (rp->height > WORLD_Y)
- rp->height = WORLD_Y;
-#endif
-}
-
-/* This is called also called in snxtitem.c */
-void
-xydist_range(coord x, coord y, register int dist, struct range *rp)
-{
- if (dist < WORLD_X / 4) {
- rp->lx = xnorm((coord)(x - 2 * dist));
- rp->hx = xnorm((coord)(x + 2 * dist) + 1);
- rp->width = 4 * dist + 1;
- } else {
- /* Range is larger than the world */
- /* Make sure we get lx in the right place. */
- rp->lx = xnorm((coord)(x - WORLD_X / 2));
- rp->hx = xnorm((coord)(rp->lx + WORLD_X - 1));
- rp->width = WORLD_X;
- }
-
- if (dist < WORLD_Y / 2) {
- rp->ly = ynorm((coord)(y - dist));
- rp->hy = ynorm((coord)(y + dist) + 1);
- rp->height = 2 * dist + 1;
- } else {
- /* Range is larger than the world */
- rp->ly = ynorm((coord)(y - WORLD_Y / 2));
- rp->hy = ynorm((coord)(rp->ly + WORLD_Y - 1));
- rp->height = WORLD_Y;
- }
-}
return str + (cp - arg);
}
+/*
+ * return true if the conditions on this item
+ * are all true.
+ */
+int
+nstr_exec(struct nscstr *conds, register int ncond, void *ptr, int type)
+{
+ register struct nscstr *nsc;
+ register int op;
+ register int lhs;
+ register int rhs;
+ register int oper;
+
+ for (nsc = conds; --ncond >= 0; nsc++) {
+ oper = nsc->oper;
+ if (oper > 65535) {
+ oper = oper - 65535;
+ rhs = nsc->fld2;
+ } else
+ rhs = decode(player->cnum, nsc->fld2, ptr, type);
+
+ if (oper > 255) {
+ oper = oper - 255;
+ lhs = nsc->fld1;
+ } else
+ lhs = decode(player->cnum, nsc->fld1, ptr, type);
+
+ op = oper;
+ if ((op == '<' && lhs >= rhs)
+ || (op == '=' && lhs != rhs)
+ || (op == '>' && lhs <= rhs)
+ || (op == '#' && lhs == rhs))
+ return 0;
+ }
+ return 1;
+}
+
int
encode(register s_char *str, long int *val, int type)
{
return 1;
}
+int
+decode(natid cnum, long int code, void *addr, int type)
+{
+ register int val;
+ register int nsc_code;
+ struct natstr *np;
+ long code_type = (code & NSC_TMASK);
-/*
- * The rest of this stuff has been moved to libcommon
- * so it can be used elsewhere (emp_update, mostly)
- */
+ val = (code & ~NSC_MASK) & 0xffff;
+
+ /* handle negative numbers properly */
+ /* this assumes a binary two's complement number representation */
+ if (val >= 0x8000)
+ val -= 0x10000;
+
+ nsc_code = code & NSC_CMASK;
+ if (nsc_code == NSC_VAR) {
+ val = getvar(val, addr, type);
+ } else if (nsc_code == NSC_OFF) {
+ /*
+ * add offset to value
+ */
+ addr = (s_char *)addr + val;
+ switch (code_type) {
+ case NSC_TIME:
+ val = *((time_t *) addr);
+ break;
+ case NSC_CHAR:
+ val = *((s_char *)addr);
+ break;
+ case NSC_UCHAR:
+ val = (int)*((unsigned char *)addr);
+ break;
+ case NSC_SHORT:
+ val = *((short *)addr);
+ break;
+ case NSC_USHORT:
+ val = *((u_short *)addr);
+ break;
+ case NSC_INT:
+ val = *((int *)addr);
+ break;
+ case NSC_LONG:
+ val = *((long *)addr);
+ break;
+ case NSC_XCOORD:
+ val = *((short *)addr);
+ np = getnatp(cnum);
+ val = xrel(np, val);
+ break;
+ case NSC_YCOORD:
+ val = *((short *)addr);
+ np = getnatp(cnum);
+ val = yrel(np, val);
+ break;
+ default:
+ logerror("bad type in decode: %x!\n", code & NSC_TMASK);
+ val = 0;
+ break;
+ }
+ }
+ if (code & NSC_ROUND)
+ val = roundintby(val, 10);
+ return val;
+}
+
+s_char *
+decodep(long int code, void *addr)
+{
+ addr = (char *)addr + ((code & ~NSC_MASK) & 0xffff);
+
+ if ((code & NSC_TMASK) == NSC_CHARP)
+ return *(s_char **)addr ? *((s_char **)addr) : (s_char *)"";
+ return addr;
+}
return 1;
}
-/*
- * The rest of these (snxtitem_area, snxtitem_dist, etc, have been moved
- * into the common lib, since they don't use condargs, and are useful
- * elsewhere (update, chiefly). ---ts
- *
- */
+void
+snxtitem_area(register struct nstr_item *np, int type, struct range *range)
+{
+ memset(np, 0, sizeof(*np));
+ np->cur = -1;
+ np->type = type;
+ np->sel = NS_AREA;
+ np->index = -1;
+ np->range = *range;
+ np->read = ef_read;
+ np->flags = ef_flags(type);
+ xysize_range(&np->range);
+ ef_zapcache(type);
+}
+
+void
+snxtitem_dist(register struct nstr_item *np, int type, int cx, int cy,
+ int dist)
+{
+ struct range range;
+
+ memset(np, 0, sizeof(*np));
+ xydist_range(cx, cy, dist, &range);
+ np->cur = -1;
+ np->type = type;
+ np->sel = NS_DIST;
+ np->cx = cx;
+ np->cy = cy;
+ np->index = -1;
+ np->range = range;
+ np->dist = dist;
+ np->read = ef_read;
+ np->flags = ef_flags(type);
+#if 0
+ /* This is no longer proper. */
+ /* It did the wrong thing for small, hitech worlds. */
+ xysize_range(&np->range);
+#endif
+ ef_zapcache(type);
+}
+
+void
+snxtitem_xy(register struct nstr_item *np, int type, coord x, coord y)
+{
+ memset(np, 0, sizeof(*np));
+ np->cur = -1;
+ np->type = type;
+ np->sel = NS_XY;
+ np->cx = xnorm(x);
+ np->cy = ynorm(y);
+ np->index = -1;
+ np->dist = 0;
+ np->read = ef_read;
+ np->flags = ef_flags(type);
+ ef_zapcache(type);
+}
+
+void
+snxtitem_all(register struct nstr_item *np, int type)
+{
+ memset(np, 0, sizeof(*np));
+ np->cur = -1;
+ np->sel = NS_ALL;
+ np->type = type;
+ np->index = -1;
+ np->read = ef_read;
+ np->flags = ef_flags(type);
+ xysize_range(&np->range);
+ ef_zapcache(type);
+}
+
+void
+snxtitem_group(register struct nstr_item *np, int type, s_char group)
+{
+ if (group == '~')
+ group = ' ';
+ memset(np, 0, sizeof(*np));
+ np->cur = -1;
+ np->sel = NS_GROUP;
+ np->group = group;
+ np->type = type;
+ np->index = -1;
+ np->read = ef_read;
+ np->flags = ef_flags(type);
+ xysize_range(&np->range);
+ ef_zapcache(type);
+}
+
+void
+snxtitem_rewind(struct nstr_item *np)
+{
+ np->cur = -1;
+ np->index = -1;
+ ef_zapcache(np->type);
+}
+
+int
+snxtitem_list(register struct nstr_item *np, int type, int *list, int len)
+{
+ int i;
+
+ memset(np, 0, sizeof(*np));
+ np->cur = -1;
+ np->type = type;
+ np->sel = NS_LIST;
+ np->index = -1;
+ np->read = ef_read;
+ np->flags = ef_flags(type);
+ if (len <= 0 || len > NS_LSIZE)
+ return 0;
+ for (i = 0; i < len; i++)
+ np->list[i] = list[i];
+ np->size = len;
+ ef_zapcache(type);
+ return 1;
+}
return 1;
}
-/*
- * The rest of these (snxtsct_all, snxtsct_area, etc, have been moved
- * into the common lib, since they don't use condargs, and are useful
- * elsewhere (update, chiefly). ---ts
- *
- */
+void
+snxtsct_all(struct nstr_sect *np)
+{
+ struct range worldrange;
+
+ worldrange.lx = -WORLD_X / 2;
+ worldrange.ly = -WORLD_Y / 2;
+ worldrange.hx = WORLD_X / 2;
+ worldrange.hy = WORLD_Y / 2;
+ worldrange.width = worldrange.height = 0;
+ snxtsct_area(np, &worldrange);
+}
+
+void
+snxtsct_area(register struct nstr_sect *np, struct range *range)
+{
+ memset(np, 0, sizeof(*np));
+ np->range = *range;
+ np->ncond = 0;
+ np->type = NS_AREA;
+ np->read = ef_read;
+ np->x = np->range.lx - 1;
+ np->y = np->range.ly;
+ np->dx = -1;
+ np->dy = 0;
+ xysize_range(&np->range);
+ ef_zapcache(EF_SECTOR);
+}
+
+void
+snxtsct_rewind(struct nstr_sect *np)
+{
+ np->x = np->range.lx - 1;
+ np->y = np->range.ly;
+ np->dx = -1;
+ np->dy = 0;
+ np->id = -1;
+ ef_zapcache(EF_SECTOR);
+}
+
+void
+snxtsct_dist(register struct nstr_sect *np, coord cx, coord cy, int dist)
+{
+ memset(np, 0, sizeof(*np));
+ xydist_range(cx, cy, dist, &np->range);
+ np->cx = cx;
+ np->cy = cy;
+ np->ncond = 0;
+ np->dist = dist;
+ np->type = NS_DIST;
+ np->read = ef_read;
+ np->x = np->range.lx - 1;
+ np->y = np->range.ly;
+ np->dx = -1;
+ np->dy = 0;
+#if 0
+ /* This function is now done elsewhere. */
+ /* It was not doing the right thing when the world was small */
+ xysize_range(&np->range);
+#endif
+ ef_zapcache(EF_SECTOR);
+}
+
+void
+xysize_range(register struct range *rp)
+{
+ if (rp->lx >= rp->hx)
+ rp->width = WORLD_X + rp->hx - rp->lx;
+ else
+ rp->width = rp->hx - rp->lx;
+#ifndef HAY
+ /* This is a necessary check for small, hitech worlds. */
+ if (rp->width > WORLD_X)
+ rp->width = WORLD_X;
+#endif
+ if (rp->ly >= rp->hy)
+ rp->height = WORLD_Y + rp->hy - rp->ly;
+ else
+ rp->height = rp->hy - rp->ly;
+#ifndef HAY
+ /* This is a necessary check for small, hitech worlds. */
+ if (rp->height > WORLD_Y)
+ rp->height = WORLD_Y;
+#endif
+}
+
+/* This is called also called in snxtitem.c */
+void
+xydist_range(coord x, coord y, register int dist, struct range *rp)
+{
+ if (dist < WORLD_X / 4) {
+ rp->lx = xnorm((coord)(x - 2 * dist));
+ rp->hx = xnorm((coord)(x + 2 * dist) + 1);
+ rp->width = 4 * dist + 1;
+ } else {
+ /* Range is larger than the world */
+ /* Make sure we get lx in the right place. */
+ rp->lx = xnorm((coord)(x - WORLD_X / 2));
+ rp->hx = xnorm((coord)(rp->lx + WORLD_X - 1));
+ rp->width = WORLD_X;
+ }
+
+ if (dist < WORLD_Y / 2) {
+ rp->ly = ynorm((coord)(y - dist));
+ rp->hy = ynorm((coord)(y + dist) + 1);
+ rp->height = 2 * dist + 1;
+ } else {
+ /* Range is larger than the world */
+ rp->ly = ynorm((coord)(y - WORLD_Y / 2));
+ rp->hy = ynorm((coord)(rp->ly + WORLD_Y - 1));
+ rp->height = WORLD_Y;
+ }
+}