/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2006, 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
*
* path.c: Empire/A* Interface code.
* Define AS_STATS for A* statistics.
- *
+ *
* Known contributors to this file:
* Phil Lapsley, 1991
* Dave Pare, 1991
#include <config.h>
#include <stdio.h>
-#include <stdlib.h>
#include "../as/as.h"
+#include "file.h"
#include "misc.h"
+#include "optlist.h"
#include "path.h"
-#include "xy.h"
+#include "prototypes.h"
#include "sect.h"
-#include "file.h"
-#include "common.h"
-#include "gen.h"
-#include "optlist.h"
+#include "xy.h"
#define BP_ASHASHSIZE 128 /* A* queue hash table size */
#define BP_NEIGHBORS 6 /* max number of neighbors */
return NULL;
if (neighsects == NULL)
- neighsects = calloc(((WORLD_X * WORLD_Y) / 2) * 6,
- sizeof(struct sctstr *));
+ neighsects = calloc(WORLD_SZ() * 6, sizeof(struct sctstr *));
return bp;
}
y = c.y;
sx = XNORM(x);
sy = YNORM(y);
- offset = (sy * WORLD_X + sx) / 2;
+ offset = XYOFFSET(sx, sy);
from = §p[offset];
if (neighsects == NULL)
ny = y + diroff[q][1];
sx = XNORM(nx);
sy = YNORM(ny);
- offset = (sy * WORLD_X + sx) / 2;
+ offset = XYOFFSET(sx, sy);
sp = §p[offset];
*ssp = sp;
} else {
}
/* No need to calculate cost each time, just make sure we can
move through it. We calculate it later. */
- if (dchr[sp->sct_type].d_mcst == 0)
+ if (dchr[sp->sct_type].d_mob0 < 0)
continue;
- if (bp->bp_mobtype == MOB_RAIL && sp->sct_rail == 0)
+ if (bp->bp_mobtype == MOB_RAIL && !SCT_HAS_RAIL(sp))
continue;
if (sp->sct_own != from->sct_own)
continue;
y = to.y;
sx = XNORM(x);
sy = YNORM(y);
- offset = (sy * WORLD_X + sx) / 2;
+ offset = XYOFFSET(sx, sy);
return sector_mcost(§p[offset], bp->bp_mobtype);
}
cy += diroff[o][1];
sx = XNORM(cx);
sy = YNORM(cy);
- offset = (sy * WORLD_X + sx) / 2;
+ offset = XYOFFSET(sx, sy);
sp = §p[offset];
cost += sector_mcost(sp, mob_type);
path++;
struct sctstr *from,
struct sctstr *to, double *cost)
{
- return BestLandPath(path, from, to, cost, MOB_ROAD);
+ return BestLandPath(path, from, to, cost, MOB_MOVE);
}
char *