]> git.pond.sub.org Git - empserver/commitdiff
Use sctstr member sct_uid instead of recomputing it
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 24 Mar 2008 09:53:56 +0000 (10:53 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 26 Mar 2008 21:10:29 +0000 (22:10 +0100)
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
src/lib/commands/bdes.c
src/lib/commands/navi.c
src/lib/common/bestpath.c
src/lib/subs/maps.c
src/lib/subs/move.c
src/lib/update/bp.c
src/lib/update/finish.c

index d2220d3e6d4024f166250a9c8153f85f16144da7..8ff95cab1b9b1f6b8efa48eb020b1f51d2dd174d 100644 (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))
 
index 450a50fcd24a9ee1eaff9eb314f25b24edac163c..1bf068421e1c99b2828fe1ddd6abb72f6ab95bd4 100644 (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 : ' ');
index 3a5c8c5709d423b66ea797046e06d6519623f333..122c8ac5e2423a41c14668c3d5b22a775a470140 100644 (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);
index 5003082aa589ae1a45f6df290742022f47fda804..41b0e83086e4accfdfb105f251880dd6acee819e 100644 (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;
 }
index 73e815e3a1a074be8a758509a60d62a2a8b2b045..6d5957e748465e7b00b0ed461a4a57ab4c5c2528 100644 (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)
index 03cf9c5065bea8339339534be155985cf0767bed..938d35961fe2865f5698b1a9c72a24879420491d 100644 (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++;
     }
index e22a65b3eb79fd7ad193e7ffb288274454ad7a96..3dd7b0d5e3b46d6d5202a45217d421accea5b0e7 100644 (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];
 }
 
 /*
index 2f6d222de169e5de53cfc9109a3694089f9f651c..da03cee164c04f4ca5299c9fd797a34cd007f864 100644 (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) {