s_char *pp);
static int bp_coord_hash(struct as_coord c);
-struct empfile *ep;
-
/* We use this for caching neighbors. It never changes except
* at reboot time (maybe) so we never need to free it */
struct sctstr **neighsects = (struct sctstr **)0;
{
struct bestp *bp;
- ep = &empfile[EF_SECTOR];
-
bp = malloc(sizeof(*bp));
memset(bp, 0, sizeof(*bp));
bp->adp = as_init(BP_NEIGHBORS, BP_ASHASHSIZE, bp_coord_hash,
static int
bp_neighbors(struct as_coord c, struct as_coord *cp, s_char *pp)
{
+ struct sctstr *sectp = (void *)empfile[EF_SECTOR].cache;
coord x, y;
coord nx, ny;
int n = 0, q;
sx = XNORM(x);
sy = YNORM(y);
offset = (sy * WORLD_X + sx) / 2;
- from = (struct sctstr *)(ep->cache + ep->size * offset);
+ from = §p[offset];
if (neighsects == (struct sctstr **)0)
ssp = (struct sctstr **)&tsp[0];
sx = XNORM(nx);
sy = YNORM(ny);
offset = (sy * WORLD_X + sx) / 2;
- sp = (struct sctstr *)(ep->cache + ep->size * offset);
+ sp = §p[offset];
*ssp = sp;
} else {
sp = *ssp;
static double
bp_lbcost(struct as_coord from, struct as_coord to, s_char *pp)
{
+ struct sctstr *sectp = (void *)empfile[EF_SECTOR].cache;
struct bestp *bp = (struct bestp *)pp;
struct sctstr *ts;
float cost;
sx = XNORM(x);
sy = YNORM(y);
offset = (sy * WORLD_X + sx) / 2;
- ts = (struct sctstr *)(ep->cache + ep->size * offset);
+ ts = §p[offset];
cost = sector_mcost(ts, bp->bp_mobtype);
return cost;
}
double
pathcost(struct sctstr *start, s_char *path, int mob_type)
{
+ struct sctstr *sectp = (void *)empfile[EF_SECTOR].cache;
unsigned i;
int o;
int cx, cy;
sx = XNORM(cx);
sy = YNORM(cy);
offset = (sy * WORLD_X + sx) / 2;
- sp = (struct sctstr *)(ep->cache + ep->size * offset);
+ sp = §p[offset];
cost += sector_mcost(sp, mob_type);
path++;
}