From 71cfcc6229ac2a6d241f70ff45f237f5a55b57c3 Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 9 May 2024 11:43:01 -0700 Subject: [PATCH] simplify simplify #overview shop handling --- src/dungeon.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/dungeon.c b/src/dungeon.c index d1ead30cd..8b3730bfd 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -2556,14 +2556,16 @@ save_exclusions(NHFILE *nhfp) struct exclusion_zone *ez; int nez; - for (nez = 0, ez = ge.exclusion_zones; ez; ez = ez->next, ++nez) ; + for (nez = 0, ez = ge.exclusion_zones; ez; ez = ez->next, ++nez) + ; if (nhfp->structlevel) bwrite(nhfp->fd, (genericptr_t) &nez, sizeof nez); for (ez = ge.exclusion_zones; ez; ez = ez->next) { if (nhfp->structlevel) { - bwrite(nhfp->fd, (genericptr_t) &ez->zonetype, sizeof ez->zonetype); + bwrite(nhfp->fd, (genericptr_t) &ez->zonetype, + sizeof ez->zonetype); bwrite(nhfp->fd, (genericptr_t) &ez->lx, sizeof ez->lx); bwrite(nhfp->fd, (genericptr_t) &ez->ly, sizeof ez->ly); bwrite(nhfp->fd, (genericptr_t) &ez->hx, sizeof ez->hx); @@ -3409,14 +3411,15 @@ staticfn const char * shop_string(int rtype) { extern const struct shclass shtypes[]; /* defined in shknam.c */ + int shoptype = rtype - SHOPBASE; /* convert room type to shop type */ const char *str = "shop?"; /* catchall */ - if (rtype < SHOPBASE) { + if (shoptype < 0) { str = "untended shop"; - } else if (shtypes[rtype - SHOPBASE].annotation) { - str = shtypes[rtype - SHOPBASE].annotation; - } else if (shtypes[rtype - SHOPBASE].name) { - str = shtypes[rtype - SHOPBASE].name; + } else if (shtypes[shoptype].annotation) { + str = shtypes[shoptype].annotation; + } else if (shtypes[shoptype].name) { + str = shtypes[shoptype].name; } return str; }