Use sctstr member sct_uid instead of recomputing it

The old code recomputed it with sctoff() in some places, without
checking for failure.  Not a bug, because it can't actually fail, just
confusing.
This commit is contained in:
Markus Armbruster 2008-03-24 10:53:56 +01:00
parent f18502a1d1
commit a0fa4550a8
8 changed files with 11 additions and 11 deletions

View file

@ -158,7 +158,7 @@ struct dchrstr {
#define SCT_TYPE_MAX 38
#define getsect(x, y, p) ef_read(EF_SECTOR, sctoff((x), (y)), (p))
#define putsect(p) ef_write(EF_SECTOR, sctoff((p)->sct_x, (p)->sct_y), (p))
#define putsect(p) ef_write(EF_SECTOR, (p)->sct_uid, (p))
#define getsectp(x, y) (struct sctstr *)ef_ptr(EF_SECTOR, sctoff((x), (y)))
#define getsectid(id) (struct sctstr *)ef_ptr(EF_SECTOR, (id))

View file

@ -53,7 +53,7 @@ bdes(void)
while (!player->aborted && nxtsct(&nstr, &sect)) {
if ((nstr.ncond > 0) && (sect.sct_own != player->cnum))
continue;
d = player->map[sctoff(nstr.x, nstr.y)];
d = player->map[sect.sct_uid];
sprintf(prompt, "%s '%c' desig? ",
xyas(nstr.x, nstr.y, player->cnum),
d ? d : ' ');

View file

@ -327,7 +327,7 @@ nav_map(int x, int y, int show_designations)
* in which case they'll see that.
* --ts
*/
*ptr = player->bmap[sctoff(sect.sct_x, sect.sct_y)];
*ptr = player->bmap[sect.sct_uid];
}
if (changed)
writemap(player->cnum);

View file

@ -221,6 +221,6 @@ owned_and_navigable(char *bigmap, int x, int y, int own)
}
/* Can only check bigmap */
mapspot = bigmap[sctoff(x, y)];
mapspot = bigmap[sect.sct_uid];
return mapspot == '.' || mapspot == ' ' || mapspot == 0;
}

View file

@ -431,9 +431,9 @@ share_bmap(natid from, natid to, struct nstr_sect *ns, char des,
from_des &= ~0x20;
while (nxtsct(ns, &sect)) {
if (!(fromdes = from_bmap[sctoff(ns->x, ns->y)]))
if (!(fromdes = from_bmap[sect.sct_uid]))
continue;
todes = to_bmap[sctoff(ns->x, ns->y)];
todes = to_bmap[sect.sct_uid];
if (todes &&
todes != '?' &&
todes != '.' && todes != ' ' && todes != from_des)

View file

@ -300,7 +300,7 @@ fly_map(coord curx, coord cury)
i = 0;
while (i < 7 && nxtsct(&ns, &sect)) {
/* Nasty: this relies on the iteration order */
if (!(view[i] = player->bmap[sctoff(ns.x, ns.y)]))
if (!(view[i] = player->bmap[sect.sct_uid]))
view[i] = ' ';
i++;
}

View file

@ -71,7 +71,7 @@ static enum bp_item_idx bud_key[I_MAX + 1] = {
static struct bp *
bp_ref(struct bp *bp, struct sctstr *sp)
{
return &bp[XYOFFSET(sp->sct_x, sp->sct_y)];
return &bp[sp->sct_uid];
}
/*

View file

@ -125,7 +125,7 @@ finish_sects(int etu)
if (np->nat_money < 0)
continue;
/* Get the pointer */
infptr = &g_distptrs[XYOFFSET(sp->sct_x, sp->sct_y)];
infptr = &g_distptrs[sp->sct_uid];
dodistribute(sp, EXPORT,
infptr->path, infptr->imcost, infptr->excost);
}
@ -135,7 +135,7 @@ finish_sects(int etu)
logerror("importing...");
for (n = 0; NULL != (sp = getsectid(n)); n++) {
/* Get the pointer (we do it first so we can free if needed) */
infptr = &g_distptrs[XYOFFSET(sp->sct_x, sp->sct_y)];
infptr = &g_distptrs[sp->sct_uid];
if (sp->sct_type == SCT_WATER || sp->sct_own == 0) {
#ifdef SAVE_FINISH_PATHS
if (infptr->path)
@ -179,7 +179,7 @@ assemble_dist_paths(struct distinfo *distptrs)
if ((sp->sct_dist_x == sp->sct_x) && (sp->sct_dist_y == sp->sct_y))
continue;
/* Set the pointer */
infptr = &distptrs[XYOFFSET(sp->sct_x, sp->sct_y)];
infptr = &distptrs[sp->sct_uid];
/* now, get the dist sector */
dist = getsectp(sp->sct_dist_x, sp->sct_dist_y);
if (dist == NULL) {