From cf897d9293c0e13281cc2755e452df4d0116cc45 Mon Sep 17 00:00:00 2001 From: nhmall Date: Thu, 3 Nov 2022 16:50:25 -0400 Subject: [PATCH] prefix some macro names --- src/extralev.c | 56 +++++++++++++++++++++++++------------------------- src/objnam.c | 22 ++++++++++---------- src/sp_lev.c | 40 ++++++++++++++++++------------------ 3 files changed, 59 insertions(+), 59 deletions(-) diff --git a/src/extralev.c b/src/extralev.c index 86180178b..24e95505a 100644 --- a/src/extralev.c +++ b/src/extralev.c @@ -8,10 +8,10 @@ #include "hack.h" -#define UP 1 -#define DOWN 2 -#define LEFT 4 -#define RIGHT 8 +#define XL_UP 1 +#define XL_DOWN 2 +#define XL_LEFT 4 +#define XL_RIGHT 8 static void roguejoin(coordxy, coordxy, coordxy, coordxy, int); static void roguecorr(coordxy, coordxy, int); @@ -48,8 +48,8 @@ roguecorr(coordxy x, coordxy y, int dir) { register coordxy fromx, fromy, tox, toy; - if (dir == DOWN) { - g.r[x][y].doortable &= ~DOWN; + if (dir == XL_DOWN) { + g.r[x][y].doortable &= ~XL_DOWN; if (!g.r[x][y].real) { fromx = g.r[x][y].rlx; fromy = g.r[x][y].rly; @@ -71,7 +71,7 @@ roguecorr(coordxy x, coordxy y, int dir) return; } y++; - g.r[x][y].doortable &= ~UP; + g.r[x][y].doortable &= ~XL_UP; if (!g.r[x][y].real) { tox = g.r[x][y].rlx; toy = g.r[x][y].rly; @@ -90,8 +90,8 @@ roguecorr(coordxy x, coordxy y, int dir) } roguejoin(fromx, fromy, tox, toy, FALSE); return; - } else if (dir == RIGHT) { - g.r[x][y].doortable &= ~RIGHT; + } else if (dir == XL_RIGHT) { + g.r[x][y].doortable &= ~XL_RIGHT; if (!g.r[x][y].real) { fromx = g.r[x][y].rlx; fromy = g.r[x][y].rly; @@ -113,7 +113,7 @@ roguecorr(coordxy x, coordxy y, int dir) return; } x++; - g.r[x][y].doortable &= ~LEFT; + g.r[x][y].doortable &= ~XL_LEFT; if (!g.r[x][y].real) { tox = g.r[x][y].rlx; toy = g.r[x][y].rly; @@ -147,16 +147,16 @@ miniwalk(coordxy x, coordxy y) while (1) { q = 0; #define doorhere (g.r[x][y].doortable) - if (x > 0 && (!(doorhere & LEFT)) + if (x > 0 && (!(doorhere & XL_LEFT)) && (!g.r[x - 1][y].doortable || !rn2(10))) dirs[q++] = 0; - if (x < 2 && (!(doorhere & RIGHT)) + if (x < 2 && (!(doorhere & XL_RIGHT)) && (!g.r[x + 1][y].doortable || !rn2(10))) dirs[q++] = 1; - if (y > 0 && (!(doorhere & UP)) + if (y > 0 && (!(doorhere & XL_UP)) && (!g.r[x][y - 1].doortable || !rn2(10))) dirs[q++] = 2; - if (y < 2 && (!(doorhere & DOWN)) + if (y < 2 && (!(doorhere & XL_DOWN)) && (!g.r[x][y + 1].doortable || !rn2(10))) dirs[q++] = 3; /* Rogue levels aren't just 3 by 3 mazes; they have some extra @@ -167,24 +167,24 @@ miniwalk(coordxy x, coordxy y) dir = dirs[rn2(q)]; switch (dir) { /* Move in direction */ case 0: - doorhere |= LEFT; + doorhere |= XL_LEFT; x--; - doorhere |= RIGHT; + doorhere |= XL_RIGHT; break; case 1: - doorhere |= RIGHT; + doorhere |= XL_RIGHT; x++; - doorhere |= LEFT; + doorhere |= XL_LEFT; break; case 2: - doorhere |= UP; + doorhere |= XL_UP; y--; - doorhere |= DOWN; + doorhere |= XL_DOWN; break; case 3: - doorhere |= DOWN; + doorhere |= XL_DOWN; y++; - doorhere |= UP; + doorhere |= XL_UP; break; } miniwalk(x, y); @@ -265,13 +265,13 @@ makeroguerooms(void) /* Now, add connecting corridors. */ for (y = 0; y < 3; y++) for (x = 0; x < 3; x++) { - if (here.doortable & DOWN) - roguecorr(x, y, DOWN); - if (here.doortable & RIGHT) - roguecorr(x, y, RIGHT); - if (here.doortable & LEFT) + if (here.doortable & XL_DOWN) + roguecorr(x, y, XL_DOWN); + if (here.doortable & XL_RIGHT) + roguecorr(x, y, XL_RIGHT); + if (here.doortable & XL_LEFT) impossible("left end of %d, %d never connected?", x, y); - if (here.doortable & UP) + if (here.doortable & XL_UP) impossible("up end of %d, %d never connected?", x, y); } #undef here diff --git a/src/objnam.c b/src/objnam.c index 8e93985fe..6e6f48f51 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -3518,9 +3518,9 @@ wizterrainwish(struct _readobjnam_data *d) return (struct obj *) 0; } -#define UNDEFINED 0 -#define EMPTY 1 -#define SPINACH 2 +#define TIN_UNDEFINED 0 +#define TIN_EMPTY 1 +#define TIN_SPINACH 2 static void readobjnam_init(char *bp, struct _readobjnam_data *d) @@ -3539,7 +3539,7 @@ readobjnam_init(char *bp, struct _readobjnam_data *d) d->tvariety = RANDOM_TIN; d->mgend = -1; /* not specified, aka random */ d->mntmp = NON_PM; - d->contents = UNDEFINED; + d->contents = TIN_UNDEFINED; d->oclass = 0; d->actualn = d->dn = d->un = 0; d->wetness = 0; @@ -3687,7 +3687,7 @@ readobjnam_preparse(struct _readobjnam_data *d) } else if (!strncmpi(d->bp, "diluted ", l = 8)) { d->isdiluted = 1; } else if (!strncmpi(d->bp, "empty ", l = 6)) { - d->contents = EMPTY; + d->contents = TIN_EMPTY; } else if (!strncmpi(d->bp, "small ", l = 6)) { /* glob sizes */ /* "small" might be part of monster name (mimic, if wishing for its corpse) rather than prefix for glob size; when @@ -3865,7 +3865,7 @@ readobjnam_postparse1(struct _readobjnam_data *d) } if ((d->p = strstri(d->bp, " of spinach")) != 0) { *d->p = 0; - d->contents = SPINACH; + d->contents = TIN_SPINACH; } /* real vs fake is only useful for wizard mode but we'll accept its parsing in normal play (result is never real Amulet for that case) */ @@ -3968,7 +3968,7 @@ readobjnam_postparse1(struct _readobjnam_data *d) && !strstri(d->bp, "finger ")) { if ((d->p = strstri(d->bp, "tin of ")) != 0) { if (!strcmpi(d->p + 7, "spinach")) { - d->contents = SPINACH; + d->contents = TIN_SPINACH; d->mntmp = NON_PM; } else { d->tmp = tin_variety_txt(d->p + 7, &d->tinv); @@ -4354,7 +4354,7 @@ readobjnam_postparse3(struct _readobjnam_data *d) return 6; /*goto retry;*/ } if (!strcmpi(d->bp, "spinach")) { - d->contents = SPINACH; + d->contents = TIN_SPINACH; d->typ = TIN; return 2; /*goto typfnd;*/ } @@ -4682,9 +4682,9 @@ readobjnam(char *bp, struct obj *no_wish) switch (d.typ) { case TIN: d.otmp->spe = 0; /* default: not spinach */ - if (d.contents == EMPTY) { + if (d.contents == TIN_EMPTY) { d.otmp->corpsenm = NON_PM; - } else if (d.contents == SPINACH) { + } else if (d.contents == TIN_SPINACH) { d.otmp->corpsenm = NON_PM; d.otmp->spe = 1; /* spinach after all */ } @@ -4862,7 +4862,7 @@ readobjnam(char *bp, struct obj *no_wish) d.otmp->otrapped = (d.trapped == 1); } /* empty for containers rather than for tins */ - if (d.contents == EMPTY) { + if (d.contents == TIN_EMPTY) { if (d.otmp->otyp == BAG_OF_TRICKS || d.otmp->otyp == HORN_OF_PLENTY) { if (d.otmp->spe > 0) d.otmp->spe = 0; diff --git a/src/sp_lev.c b/src/sp_lev.c index 46d5d8295..142ad63f6 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -163,11 +163,11 @@ int lspo_trap(lua_State *); int lspo_wall_property(lua_State *); int lspo_wallify(lua_State *); -#define LEFT 1 -#define H_LEFT 2 -#define CENTER 3 -#define H_RIGHT 4 -#define RIGHT 5 +#define SPLEV_LEFT 1 +#define SPLEV_H_LEFT 2 +#define SPLEV_CENTER 3 +#define SPLEV_H_RIGHT 4 +#define SPLEV_RIGHT 5 #define TOP 1 #define BOTTOM 5 @@ -1561,12 +1561,12 @@ create_room( xabs = (((xtmp - 1) * COLNO) / 5) + 1; yabs = (((ytmp - 1) * ROWNO) / 5) + 1; switch (xaltmp) { - case LEFT: + case SPLEV_LEFT: break; - case RIGHT: + case SPLEV_RIGHT: xabs += (COLNO / 5) - wtmp; break; - case CENTER: + case SPLEV_CENTER: xabs += ((COLNO / 5) - wtmp) / 2; break; } @@ -1576,7 +1576,7 @@ create_room( case BOTTOM: yabs += (ROWNO / 5) - htmp; break; - case CENTER: + case SPLEV_CENTER: yabs += ((ROWNO / 5) - htmp) / 2; break; } @@ -3892,12 +3892,12 @@ lspo_room(lua_State *L) "none", "random", NULL }; static const int l_or_r2i[] = { - LEFT, H_LEFT, CENTER, H_RIGHT, RIGHT, -1, -1, -1 + SPLEV_LEFT, SPLEV_H_LEFT, SPLEV_CENTER, SPLEV_H_RIGHT, SPLEV_RIGHT, -1, -1, -1 }; static const char *const top_or_bot[] = { "top", "center", "bottom", "none", "random", NULL }; - static const int t_or_b2i[] = { TOP, CENTER, BOTTOM, -1, -1, -1 }; + static const int t_or_b2i[] = { TOP, SPLEV_CENTER, BOTTOM, -1, -1, -1 }; room tmproom; struct mkroom *tmpcr; lua_Integer rx, ry; @@ -6445,12 +6445,12 @@ TODO: g.coder->croom needs to be updated "left", "half-left", "center", "half-right", "right", "none", NULL }; static const int l_or_r2i[] = { - LEFT, H_LEFT, CENTER, H_RIGHT, RIGHT, -1, -1 + SPLEV_LEFT, SPLEV_H_LEFT, SPLEV_CENTER, SPLEV_H_RIGHT, SPLEV_RIGHT, -1, -1 }; static const char *const top_or_bot[] = { "top", "center", "bottom", "none", NULL }; - static const int t_or_b2i[] = { TOP, CENTER, BOTTOM, -1, -1 }; + static const int t_or_b2i[] = { TOP, SPLEV_CENTER, BOTTOM, -1, -1 }; int lr, tb; lua_Integer x = -1, y = -1; struct mapfragment *mf; @@ -6467,7 +6467,7 @@ TODO: g.coder->croom needs to be updated if (argc == 1 && lua_type(L, 1) == LUA_TSTRING) { tmpstr = dupstr(luaL_checkstring(L, 1)); - lr = tb = CENTER; + lr = tb = SPLEV_CENTER; mf = mapfrag_fromstr(tmpstr); free(tmpstr); } else { @@ -6545,19 +6545,19 @@ TODO: g.coder->croom needs to be updated } else { /* place map starting at halign,valign */ switch (lr) { - case LEFT: + case SPLEV_LEFT: g.xstart = splev_init_present ? 1 : 3; break; - case H_LEFT: + case SPLEV_H_LEFT: g.xstart = 2 + ((g.x_maze_max - 2 - g.xsize) / 4); break; - case CENTER: + case SPLEV_CENTER: g.xstart = 2 + ((g.x_maze_max - 2 - g.xsize) / 2); break; - case H_RIGHT: + case SPLEV_H_RIGHT: g.xstart = 2 + ((g.x_maze_max - 2 - g.xsize) * 3 / 4); break; - case RIGHT: + case SPLEV_RIGHT: g.xstart = g.x_maze_max - g.xsize - 1; break; } @@ -6565,7 +6565,7 @@ TODO: g.coder->croom needs to be updated case TOP: g.ystart = 3; break; - case CENTER: + case SPLEV_CENTER: g.ystart = 2 + ((g.y_maze_max - 2 - g.ysize) / 2); break; case BOTTOM: