From a0fa4550a8010b5cb841d69751fb3686912b5aea Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 24 Mar 2008 10:53:56 +0100 Subject: [PATCH] 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. --- include/sect.h | 2 +- src/lib/commands/bdes.c | 2 +- src/lib/commands/navi.c | 2 +- src/lib/common/bestpath.c | 2 +- src/lib/subs/maps.c | 4 ++-- src/lib/subs/move.c | 2 +- src/lib/update/bp.c | 2 +- src/lib/update/finish.c | 6 +++--- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/sect.h b/include/sect.h index d2220d3e..8ff95cab 100644 --- a/include/sect.h +++ b/include/sect.h @@ -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)) diff --git a/src/lib/commands/bdes.c b/src/lib/commands/bdes.c index 450a50fc..1bf06842 100644 --- a/src/lib/commands/bdes.c +++ b/src/lib/commands/bdes.c @@ -53,7 +53,7 @@ bdes(void) while (!player->aborted && nxtsct(&nstr, §)) { 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 : ' '); diff --git a/src/lib/commands/navi.c b/src/lib/commands/navi.c index 3a5c8c57..122c8ac5 100644 --- a/src/lib/commands/navi.c +++ b/src/lib/commands/navi.c @@ -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); diff --git a/src/lib/common/bestpath.c b/src/lib/common/bestpath.c index 5003082a..41b0e830 100644 --- a/src/lib/common/bestpath.c +++ b/src/lib/common/bestpath.c @@ -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; } diff --git a/src/lib/subs/maps.c b/src/lib/subs/maps.c index 73e815e3..6d5957e7 100644 --- a/src/lib/subs/maps.c +++ b/src/lib/subs/maps.c @@ -431,9 +431,9 @@ share_bmap(natid from, natid to, struct nstr_sect *ns, char des, from_des &= ~0x20; while (nxtsct(ns, §)) { - 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) diff --git a/src/lib/subs/move.c b/src/lib/subs/move.c index 03cf9c50..938d3596 100644 --- a/src/lib/subs/move.c +++ b/src/lib/subs/move.c @@ -300,7 +300,7 @@ fly_map(coord curx, coord cury) i = 0; while (i < 7 && nxtsct(&ns, §)) { /* 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++; } diff --git a/src/lib/update/bp.c b/src/lib/update/bp.c index e22a65b3..3dd7b0d5 100644 --- a/src/lib/update/bp.c +++ b/src/lib/update/bp.c @@ -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]; } /* diff --git a/src/lib/update/finish.c b/src/lib/update/finish.c index 2f6d222d..da03cee1 100644 --- a/src/lib/update/finish.c +++ b/src/lib/update/finish.c @@ -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) {