From 94adc1406656df97e5fab4734ba477405e8c7589 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Mar 2019 06:30:28 -1100 Subject: [PATCH] Revert "Morph static variables" This reverts commit 0322f2d98cbd0dc2ddabd5cd83dc2a4e8f2c2df8. --- src/cc/rogue/command.c | 18 ++++++++-------- src/cc/rogue/init.c | 2 +- src/cc/rogue/monsters.c | 24 ++++++++++----------- src/cc/rogue/potions.c | 2 +- src/cc/rogue/rogue.h | 1 - src/cc/rogue/rooms.c | 37 ++++++++++++++++++++------------- src/cc/rogue/scrolls.c | 27 +++++++++++++++--------- src/cc/rogue/sticks.c | 46 +++++++++++++++++++++++------------------ src/cc/rogue/things.c | 17 ++++++++------- src/cc/rogue/weapons.c | 10 ++++----- 10 files changed, 104 insertions(+), 80 deletions(-) diff --git a/src/cc/rogue/command.c b/src/cc/rogue/command.c index 37bcedc74..568f4b8f8 100644 --- a/src/cc/rogue/command.c +++ b/src/cc/rogue/command.c @@ -24,7 +24,7 @@ command(struct rogue_state *rs) register int ntimes = 1; /* Number of player moves */ char *fp; THING *mp; - //static char countch, direction, newcount = FALSE; + static char countch, direction, newcount = FALSE; if (on(player, ISHASTE)) ntimes++; /* @@ -74,7 +74,7 @@ command(struct rogue_state *rs) if (running || to_death) ch = runch; else if (count) - ch = rs->countch; + ch = countch; else { ch = readchar(rs); @@ -98,11 +98,11 @@ command(struct rogue_state *rs) /* * check for prefixes */ - rs->newcount = FALSE; + newcount = FALSE; if (isdigit(ch)) { count = 0; - rs->newcount = TRUE; + newcount = TRUE; while (isdigit(ch)) { count = count * 10 + (ch - '0'); @@ -110,7 +110,7 @@ command(struct rogue_state *rs) count = 255; ch = readchar(rs); } - rs->countch = ch; + countch = ch; /* * turn off count for commands which don't make sense * to repeat @@ -205,12 +205,12 @@ over: door_stop = TRUE; firstmove = TRUE; } - if (count && !rs->newcount) - ch = rs->direction; + if (count && !newcount) + ch = direction; else { ch += ('A' - CTRL('A')); - rs->direction = ch; + direction = ch; } goto over; } @@ -372,7 +372,7 @@ over: else { ch = dir_ch; - rs->countch = dir_ch; + countch = dir_ch; goto over; } when ')': current(rs,cur_weapon, "wielding", NULL); diff --git a/src/cc/rogue/init.c b/src/cc/rogue/init.c index 635e95843..b11cfa80c 100644 --- a/src/cc/rogue/init.c +++ b/src/cc/rogue/init.c @@ -369,7 +369,7 @@ init_materials() { register int i, j; register const char *str; - bool metused[NMETAL]; + static bool metused[NMETAL]; memset(metused,0,sizeof(metused)); for (i = 0; i < NWOOD; i++) used[i] = FALSE; diff --git a/src/cc/rogue/monsters.c b/src/cc/rogue/monsters.c index 7d6d9a32e..7e1186e8d 100644 --- a/src/cc/rogue/monsters.c +++ b/src/cc/rogue/monsters.c @@ -18,12 +18,12 @@ /* * List of monsters in rough order of vorpalness */ -static const char lvl_mons[] = { +static char lvl_mons[] = { 'K', 'E', 'B', 'S', 'H', 'I', 'R', 'O', 'Z', 'L', 'C', 'Q', 'A', 'N', 'Y', 'F', 'T', 'W', 'P', 'X', 'U', 'M', 'V', 'G', 'J', 'D' }; -static const char wand_mons[] = { +static char wand_mons[] = { 'K', 'E', 'B', 'S', 'H', 0, 'R', 'O', 'Z', 0, 'C', 'Q', 'A', 0, 'Y', 0, 'T', 'W', 'P', 0, 'U', 'M', 'V', 'G', 'J', 0 }; @@ -119,27 +119,27 @@ void wanderer(struct rogue_state *rs) { THING *tp; - coord cp; - memset(&cp,0,sizeof(cp)); + static coord cp; + tp = new_item(); do { - find_floor(rs,(struct room *) NULL, &cp, FALSE, TRUE); + find_floor(rs,(struct room *) NULL, &cp, FALSE, TRUE); } while (roomin(rs,&cp) == proom); new_monster(rs,tp, randmonster(TRUE), &cp); if (on(player, SEEMONST)) { - standout(); - if (!on(player, ISHALU)) - addch(tp->t_type); - else - addch(rnd(26) + 'A'); - standend(); + standout(); + if (!on(player, ISHALU)) + addch(tp->t_type); + else + addch(rnd(26) + 'A'); + standend(); } runto(rs,&tp->t_pos); #ifdef MASTER if (wizard) - msg(rs,"started a wandering %s", monsters[tp->t_type-'A'].m_name); + msg(rs,"started a wandering %s", monsters[tp->t_type-'A'].m_name); #endif } diff --git a/src/cc/rogue/potions.c b/src/cc/rogue/potions.c index e503056d6..2425b051f 100644 --- a/src/cc/rogue/potions.c +++ b/src/cc/rogue/potions.c @@ -22,7 +22,7 @@ typedef struct char *pa_high, *pa_straight; } PACT; -static const PACT p_actions[] = +static PACT p_actions[] = { { ISHUH, unconfuse, HUHDURATION, /* P_CONFUSE */ "what a tripy feeling!", diff --git a/src/cc/rogue/rogue.h b/src/cc/rogue/rogue.h index f8117cb91..5540da2da 100644 --- a/src/cc/rogue/rogue.h +++ b/src/cc/rogue/rogue.h @@ -366,7 +366,6 @@ struct rogue_state uint32_t needflush,replaydone; int32_t numkeys,ind,num,guiflag,counter,sleeptime,playersize,restoring,lastnum; FILE *logfp; - char countch, direction, newcount; struct rogue_player P; char buffered[10000]; uint8_t playerdata[10000]; diff --git a/src/cc/rogue/rooms.c b/src/cc/rogue/rooms.c index f5454d501..67ca701d9 100644 --- a/src/cc/rogue/rooms.c +++ b/src/cc/rogue/rooms.c @@ -30,10 +30,14 @@ typedef struct spot { /* position matrix for maze positions */ void do_rooms(struct rogue_state *rs) { - int i,left_out; struct room *rp; THING *tp; - //static coord top; - coord mp,bsze,top; /* maximum room size */ - memset(&top,0,sizeof(top)); + int i; + struct room *rp; + THING *tp; + int left_out; + static coord top; + coord bsze; /* maximum room size */ + coord mp; + bsze.x = NUMCOLS / 3; bsze.y = NUMLINES / 3; /* @@ -202,18 +206,23 @@ horiz(struct room *rp, int starty) */ static int Maxy, Maxx, Starty, Startx; + static SPOT maze[NUMLINES/3+1][NUMCOLS/3+1]; -void do_maze(struct rogue_state *rs,struct room *rp) + +void +do_maze(struct rogue_state *rs,struct room *rp) { - SPOT *sp; int starty, startx; - coord pos; - memset(&pos,0,sizeof(pos)); + SPOT *sp; + int starty, startx; + static coord pos; + for (sp = &maze[0][0]; sp <= &maze[NUMLINES / 3][NUMCOLS / 3]; sp++) { - sp->used = FALSE; - sp->nexits = 0; + sp->used = FALSE; + sp->nexits = 0; } + Maxy = rp->r_max.y; Maxx = rp->r_max.x; Starty = rp->r_pos.y; @@ -236,11 +245,11 @@ dig(struct rogue_state *rs,int y, int x) { coord *cp; int cnt, newy, newx, nexty = 0, nextx = 0; - coord pos; - static const coord del[4] = { - {2, 0}, {-2, 0}, {0, 2}, {0, -2} + static coord pos; + static coord del[4] = { + {2, 0}, {-2, 0}, {0, 2}, {0, -2} }; - memset(&pos,0,sizeof(pos)); + for (;;) { if ( rs->replaydone != 0 ) diff --git a/src/cc/rogue/scrolls.c b/src/cc/rogue/scrolls.c index 49c427f67..8ed6d2648 100644 --- a/src/cc/rogue/scrolls.c +++ b/src/cc/rogue/scrolls.c @@ -22,19 +22,26 @@ void read_scroll(struct rogue_state *rs) { - THING *obj,*orig_obj; PLACE *pp; int i, y, x; char ch; - bool discardit = FALSE; struct room *cur_room; coord mp; - memset(&mp,0,sizeof(mp)); + THING *obj; + PLACE *pp; + int y, x; + char ch; + int i; + bool discardit = FALSE; + struct room *cur_room; + THING *orig_obj; + static coord mp; + obj = get_item(rs,"read", SCROLL); if (obj == NULL) - return; + return; if (obj->o_type != SCROLL) { - if (!terse) - msg(rs,"there is nothing on it to read"); - else - msg(rs,"nothing to read"); - return; + if (!terse) + msg(rs,"there is nothing on it to read"); + else + msg(rs,"nothing to read"); + return; } /* * Calculate the effect it has on the poor guy. @@ -142,7 +149,7 @@ read_scroll(struct rogue_state *rs) case S_ID_ARMOR: case S_ID_R_OR_S: { - static const char id_type[S_ID_R_OR_S + 1] = + static char id_type[S_ID_R_OR_S + 1] = { 0, 0, 0, 0, 0, POTION, SCROLL, WEAPON, ARMOR, R_OR_S }; /* * Identify, let him figure something out diff --git a/src/cc/rogue/sticks.c b/src/cc/rogue/sticks.c index 7ab33f03c..cd559daef 100644 --- a/src/cc/rogue/sticks.c +++ b/src/cc/rogue/sticks.c @@ -245,29 +245,35 @@ do_zap(struct rogue_state *rs) * Do drain hit points from player shtick */ -void drain(struct rogue_state *rs) +void +drain(struct rogue_state *rs) { - THING *mp,**dp; struct room *corp; int cnt; bool inpass; THING *drainee[40]; - memset(drainee,0,sizeof(drainee)); + THING *mp; + struct room *corp; + THING **dp; + int cnt; + bool inpass; + static THING *drainee[40]; + /* * First cnt how many things we need to spread the hit points among */ cnt = 0; if (chat(hero.y, hero.x) == DOOR) - corp = &passages[flat(hero.y, hero.x) & F_PNUM]; + corp = &passages[flat(hero.y, hero.x) & F_PNUM]; else - corp = NULL; + corp = NULL; inpass = (bool)(proom->r_flags & ISGONE); dp = drainee; for (mp = mlist; mp != NULL; mp = next(mp)) - if (mp->t_room == proom || mp->t_room == corp || - (inpass && chat(mp->t_pos.y, mp->t_pos.x) == DOOR && - &passages[flat(mp->t_pos.y, mp->t_pos.x) & F_PNUM] == proom)) - *dp++ = mp; + if (mp->t_room == proom || mp->t_room == corp || + (inpass && chat(mp->t_pos.y, mp->t_pos.x) == DOOR && + &passages[flat(mp->t_pos.y, mp->t_pos.x) & F_PNUM] == proom)) + *dp++ = mp; if ((cnt = (int)(dp - drainee)) == 0) { - msg(rs,"you have a tingling feeling"); - return; + msg(rs,"you have a tingling feeling"); + return; } *dp = NULL; pstats.s_hpt /= 2; @@ -277,11 +283,11 @@ void drain(struct rogue_state *rs) */ for (dp = drainee; *dp; dp++) { - mp = *dp; - if ((mp->t_stats.s_hpt -= cnt) <= 0) - killed(rs,mp, see_monst(mp)); - else - runto(rs,&mp->t_pos); + mp = *dp; + if ((mp->t_stats.s_hpt -= cnt) <= 0) + killed(rs,mp, see_monst(mp)); + else + runto(rs,&mp->t_pos); } } @@ -415,12 +421,12 @@ char * charge_str(THING *obj) { static char buf[20]; - + if (!(obj->o_flags & ISKNOW)) - buf[0] = '\0'; + buf[0] = '\0'; else if (terse) - sprintf(buf, " [%d]", obj->o_charges); + sprintf(buf, " [%d]", obj->o_charges); else - sprintf(buf, " [%d charges]", obj->o_charges); + sprintf(buf, " [%d charges]", obj->o_charges); return buf; } diff --git a/src/cc/rogue/things.c b/src/cc/rogue/things.c index e1ce2a2a8..39c7b94b7 100644 --- a/src/cc/rogue/things.c +++ b/src/cc/rogue/things.c @@ -334,9 +334,12 @@ pick_one(struct rogue_state *rs,struct obj_info *info, int nitems) * list what the player has discovered in this game of a certain type */ static int line_cnt = 0; + static bool newpage = FALSE; + static char *lastfmt, *lastarg; + void discovered(struct rogue_state *rs) { @@ -477,16 +480,16 @@ add_line(struct rogue_state *rs,char *fmt, char *arg) if (line_cnt == 0) { - wclear(hw); - if (inv_type == INV_SLOW) - mpos = 0; + wclear(hw); + if (inv_type == INV_SLOW) + mpos = 0; } if (inv_type == INV_SLOW) { - if (*fmt != '\0') - if (msg(rs,fmt, arg) == ESCAPE) - return ESCAPE; - line_cnt++; + if (*fmt != '\0') + if (msg(rs,fmt, arg) == ESCAPE) + return ESCAPE; + line_cnt++; } else { diff --git a/src/cc/rogue/weapons.c b/src/cc/rogue/weapons.c index 592b405f7..0a8b6016c 100644 --- a/src/cc/rogue/weapons.c +++ b/src/cc/rogue/weapons.c @@ -19,7 +19,7 @@ int group = 2; -static const struct init_weaps { +static struct init_weaps { char *iw_dam; /* Damage when wielded */ char *iw_hrl; /* Damage when thrown */ char iw_launch; /* Launching weapon */ @@ -125,8 +125,8 @@ void fall(struct rogue_state *rs,THING *obj, bool pr) { PLACE *pp; - coord fpos; - memset(&fpos,0,sizeof(fpos)); + static coord fpos; + if (fallpos(&obj->o_pos, &fpos)) { pp = INDEX(fpos.y, fpos.x); @@ -197,8 +197,8 @@ init_weapon(THING *weap, int which) int hit_monster(struct rogue_state *rs,int y, int x, THING *obj) { - coord mp; - memset(&mp,0,sizeof(mp)); + static coord mp; + mp.y = y; mp.x = x; return fight(rs,&mp, obj, TRUE);