/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
#include <config.h>
-#include "misc.h"
-#include "xy.h"
-#include "sect.h"
#include "file.h"
+#include "misc.h"
#include "nat.h"
-#include "path.h"
-#include "common.h"
#include "optlist.h"
+#include "path.h"
+#include "prototypes.h"
+#include "sect.h"
+#include "xy.h"
static int owned_and_navigable(char *, int, int, int);
* the usual rules.
* Other sectors are assumed to be passable when BIGMAP shows '.' or
* nothing.
- * Return path or a null pointer.
+ * Return a path if found, else a null pointer.
+ * Wart: the path isn't terminated with 'h', except when if X,Y equals
+ * EX,EY.
*/
char *
bestownedpath(char *bpath, char *bigmap,
maxy = y + 1;
do {
- if (++routelen == MAXROUTE - 1)
+ if (++routelen == MAXROUTE)
return NULL;
markedsectors = 0;
for (scanx = minx; scanx <= maxx; scanx++) {
if (!valid(x, y))
continue;
if (((mapindex[x][y] & 0x1FFF) == routelen - 1)) {
- for (i = DIR_FIRST; i < DIR_LAST; i++) {
+ for (i = DIR_FIRST; i <= DIR_LAST; i++) {
tx = x + diroff[i][0];
ty = y + diroff[i][1];
tx = XNORM(tx);
}
}
if (tx == ex && ty == ey) {
- bpath[routelen] = 'h';
- bpath[routelen + 1] = 0;
+ bpath[routelen] = 0;
while (routelen--) {
i = (mapindex[tx][ty] >> 13)
- 1 + DIR_FIRST;