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:
parent
f18502a1d1
commit
a0fa4550a8
8 changed files with 11 additions and 11 deletions
|
@ -158,7 +158,7 @@ struct dchrstr {
|
||||||
#define SCT_TYPE_MAX 38
|
#define SCT_TYPE_MAX 38
|
||||||
|
|
||||||
#define getsect(x, y, p) ef_read(EF_SECTOR, sctoff((x), (y)), (p))
|
#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 getsectp(x, y) (struct sctstr *)ef_ptr(EF_SECTOR, sctoff((x), (y)))
|
||||||
#define getsectid(id) (struct sctstr *)ef_ptr(EF_SECTOR, (id))
|
#define getsectid(id) (struct sctstr *)ef_ptr(EF_SECTOR, (id))
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ bdes(void)
|
||||||
while (!player->aborted && nxtsct(&nstr, §)) {
|
while (!player->aborted && nxtsct(&nstr, §)) {
|
||||||
if ((nstr.ncond > 0) && (sect.sct_own != player->cnum))
|
if ((nstr.ncond > 0) && (sect.sct_own != player->cnum))
|
||||||
continue;
|
continue;
|
||||||
d = player->map[sctoff(nstr.x, nstr.y)];
|
d = player->map[sect.sct_uid];
|
||||||
sprintf(prompt, "%s '%c' desig? ",
|
sprintf(prompt, "%s '%c' desig? ",
|
||||||
xyas(nstr.x, nstr.y, player->cnum),
|
xyas(nstr.x, nstr.y, player->cnum),
|
||||||
d ? d : ' ');
|
d ? d : ' ');
|
||||||
|
|
|
@ -327,7 +327,7 @@ nav_map(int x, int y, int show_designations)
|
||||||
* in which case they'll see that.
|
* in which case they'll see that.
|
||||||
* --ts
|
* --ts
|
||||||
*/
|
*/
|
||||||
*ptr = player->bmap[sctoff(sect.sct_x, sect.sct_y)];
|
*ptr = player->bmap[sect.sct_uid];
|
||||||
}
|
}
|
||||||
if (changed)
|
if (changed)
|
||||||
writemap(player->cnum);
|
writemap(player->cnum);
|
||||||
|
|
|
@ -221,6 +221,6 @@ owned_and_navigable(char *bigmap, int x, int y, int own)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Can only check bigmap */
|
/* Can only check bigmap */
|
||||||
mapspot = bigmap[sctoff(x, y)];
|
mapspot = bigmap[sect.sct_uid];
|
||||||
return mapspot == '.' || mapspot == ' ' || mapspot == 0;
|
return mapspot == '.' || mapspot == ' ' || mapspot == 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -431,9 +431,9 @@ share_bmap(natid from, natid to, struct nstr_sect *ns, char des,
|
||||||
from_des &= ~0x20;
|
from_des &= ~0x20;
|
||||||
|
|
||||||
while (nxtsct(ns, §)) {
|
while (nxtsct(ns, §)) {
|
||||||
if (!(fromdes = from_bmap[sctoff(ns->x, ns->y)]))
|
if (!(fromdes = from_bmap[sect.sct_uid]))
|
||||||
continue;
|
continue;
|
||||||
todes = to_bmap[sctoff(ns->x, ns->y)];
|
todes = to_bmap[sect.sct_uid];
|
||||||
if (todes &&
|
if (todes &&
|
||||||
todes != '?' &&
|
todes != '?' &&
|
||||||
todes != '.' && todes != ' ' && todes != from_des)
|
todes != '.' && todes != ' ' && todes != from_des)
|
||||||
|
|
|
@ -300,7 +300,7 @@ fly_map(coord curx, coord cury)
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < 7 && nxtsct(&ns, §)) {
|
while (i < 7 && nxtsct(&ns, §)) {
|
||||||
/* Nasty: this relies on the iteration order */
|
/* 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] = ' ';
|
view[i] = ' ';
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ static enum bp_item_idx bud_key[I_MAX + 1] = {
|
||||||
static struct bp *
|
static struct bp *
|
||||||
bp_ref(struct bp *bp, struct sctstr *sp)
|
bp_ref(struct bp *bp, struct sctstr *sp)
|
||||||
{
|
{
|
||||||
return &bp[XYOFFSET(sp->sct_x, sp->sct_y)];
|
return &bp[sp->sct_uid];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -125,7 +125,7 @@ finish_sects(int etu)
|
||||||
if (np->nat_money < 0)
|
if (np->nat_money < 0)
|
||||||
continue;
|
continue;
|
||||||
/* Get the pointer */
|
/* Get the pointer */
|
||||||
infptr = &g_distptrs[XYOFFSET(sp->sct_x, sp->sct_y)];
|
infptr = &g_distptrs[sp->sct_uid];
|
||||||
dodistribute(sp, EXPORT,
|
dodistribute(sp, EXPORT,
|
||||||
infptr->path, infptr->imcost, infptr->excost);
|
infptr->path, infptr->imcost, infptr->excost);
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ finish_sects(int etu)
|
||||||
logerror("importing...");
|
logerror("importing...");
|
||||||
for (n = 0; NULL != (sp = getsectid(n)); n++) {
|
for (n = 0; NULL != (sp = getsectid(n)); n++) {
|
||||||
/* Get the pointer (we do it first so we can free if needed) */
|
/* 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) {
|
if (sp->sct_type == SCT_WATER || sp->sct_own == 0) {
|
||||||
#ifdef SAVE_FINISH_PATHS
|
#ifdef SAVE_FINISH_PATHS
|
||||||
if (infptr->path)
|
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))
|
if ((sp->sct_dist_x == sp->sct_x) && (sp->sct_dist_y == sp->sct_y))
|
||||||
continue;
|
continue;
|
||||||
/* Set the pointer */
|
/* Set the pointer */
|
||||||
infptr = &distptrs[XYOFFSET(sp->sct_x, sp->sct_y)];
|
infptr = &distptrs[sp->sct_uid];
|
||||||
/* now, get the dist sector */
|
/* now, get the dist sector */
|
||||||
dist = getsectp(sp->sct_dist_x, sp->sct_dist_y);
|
dist = getsectp(sp->sct_dist_x, sp->sct_dist_y);
|
||||||
if (dist == NULL) {
|
if (dist == NULL) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue