From bb78ca96ce24d30df54f3f8319d9d43129979c59 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 7 Jun 2017 00:15:31 -0400 Subject: [PATCH] Capture clock variables into the game-state block. --- actions1.c | 4 ++-- advent.h | 4 +++- funcs.h | 2 +- init.c | 8 ++++---- main.c | 31 ++++++++++++++++--------------- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/actions1.c b/actions1.c index d9fa2e5..d12052f 100644 --- a/actions1.c +++ b/actions1.c @@ -201,7 +201,7 @@ L9040: if(OBJ == CLAM || OBJ == OYSTER) goto L9046; if(OBJ == CHAIN) goto L9048; if(!CLOSNG) goto L9043; K=130; - if(!PANIC)CLOCK2=15; + if(!PANIC)game.clock2=15; PANIC=true; return(2010); @@ -533,7 +533,7 @@ L8305: DATIME(&I,&K); * suspended or resumed are guaranteed to match. If unsure whether a value * needs to be saved, include it. Overkill can't hurt. Pad the last savwds * with junk variables to bring it up to 7 values. */ - SAVWDS(ABBNUM,BLKLIN,BONUS,CLOCK1,CLOCK2,CLOSED,CLOSNG); + SAVWDS(ABBNUM,BLKLIN,BONUS,game.clock1,game.clock2,CLOSED,CLOSNG); SAVWDS(DETAIL,DFLAG,DKILL,DTOTAL,FOOBAR,HOLDNG,IWEST); SAVWDS(KNFLOC,LIMIT,LL,LMWARN,LOC,NEWLOC,NUMDIE); SAVWDS(OBJ,game.oldlc2,game.oldloc,OLDOBJ,PANIC,SAVED,SETUP); diff --git a/advent.h b/advent.h index 47548b6..0f82f37 100644 --- a/advent.h +++ b/advent.h @@ -14,6 +14,8 @@ typedef long token_t; /* word token - someday this will be char[TOKLEN+1] */ typedef long vocab_t; /* index into a vocabulary array */ struct game_t { + long clock1; + long clock2; long oldloc; long oldlc2; long zzword; @@ -91,7 +93,7 @@ extern void score(long); extern long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BONUS, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2, - CLAM, CLOCK1, CLOCK2, CLOSED, CLOSNG, CLSHNT, + CLAM, CLOSED, CLOSNG, CLSHNT, COINS, CONDS, DALTLC, DETAIL, DKILL, DOOR, DPRSSN, DRAGON, DTOTAL, DWARF, EGGS, EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOBAR, FOOD, diff --git a/funcs.h b/funcs.h index 34f69cd..3aa7c90 100644 --- a/funcs.h +++ b/funcs.h @@ -29,7 +29,7 @@ #define FOREST(LOC) ((LOC) >= 145 && (LOC) <= 166) #define VOCWRD(LETTRS,SECT) (VOCAB(MAKEWD(LETTRS),SECT)) -/* The following two functions were added to fix a bug (CLOCK1 decremented +/* The following two functions were added to fix a bug (game.clock1 decremented * while in forest). They should probably be replaced by using another * "cond" bit. For now, however, a quick fix... OUTSID(LOC) is true if * LOC is outside, INDEEP(LOC) is true if LOC is "deep" in the cave (hall diff --git a/init.c b/init.c index 2a71464..8b2b1b0 100644 --- a/init.c +++ b/init.c @@ -345,8 +345,8 @@ L1106: /*etc*/ ; /* Other random flags and counters, as follows: * ABBNUM How often we should print non-abbreviated descriptions * BONUS Used to determine amount of bonus if he reaches closing - * CLOCK1 Number of turns from finding last treasure till closing - * CLOCK2 Number of turns from first warning till blinding flash + * game.clock1 Number of turns from finding last treasure till closing + * game.clock2 Number of turns from first warning till blinding flash * CONDS Min value for cond(loc) if loc has any hints * DETAIL How often we've said "not allowed to give more detail" * DKILL Number of dwarves killed (unused in scoring, needed for msg) @@ -383,8 +383,8 @@ L1106: /*etc*/ ; DKILL=0; FOOBAR=0; BONUS=0; - CLOCK1=30; - CLOCK2=50; + game.clock1=30; + game.clock2=50; CONDS=SETBIT(11); SAVED=0; CLOSNG=false; diff --git a/main.c b/main.c index c5b4523..951c90f 100644 --- a/main.c +++ b/main.c @@ -22,9 +22,8 @@ long ABB[186], ATLOC[186], BLKLIN = true, DFLAG, char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[129], MAP2[129]; long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BONUS, - BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2, - CLAM, CLOCK1, CLOCK2, CLOSED, CLOSNG, CLSHNT, - COINS, CONDS, DALTLC, DETAIL, + BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2, + CLAM, CLOSED, CLOSNG, CLSHNT, COINS, CONDS, DALTLC, DETAIL, DKILL, DOOR, DPRSSN, DRAGON, DTOTAL, DWARF, EGGS, EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOBAR, FOOD, GRATE, HINT, HINTED[21], HINTLC[21], @@ -173,7 +172,7 @@ static bool do_command(FILE *cmdin) { if(!OUTSID(NEWLOC) || NEWLOC == 0 || !CLOSNG) goto L71; RSPEAK(130); NEWLOC=LOC; - if(!PANIC)CLOCK2=15; + if(!PANIC)game.clock2=15; PANIC=true; /* See if a dwarf has seen him and has come from where he wants to go. If so, @@ -407,7 +406,7 @@ L2602: /*etc*/ ; /* If closing time, check for any objects being toted with PROP < 0 and set * the prop to -1-PROP. This way objects won't be described until they've * been picked up and put down separate from their respective piles. Don't - * tick CLOCK1 unless well into cave (and not at Y2). */ + * tick game.clock1 unless well into cave (and not at Y2). */ L2603: if(!CLOSED) goto L2605; if(PROP[OYSTER] < 0 && TOTING(OYSTER))PSPEAK(OYSTER,1); @@ -435,10 +434,10 @@ L2607: FOOBAR=(FOOBAR>0 ? -FOOBAR : 0); } if(VERB == SAY && WD2 > 0)VERB=0; if(VERB == SAY) goto L4090; - if(TALLY == 0 && INDEEP(LOC) && LOC != 33)CLOCK1=CLOCK1-1; - if(CLOCK1 == 0) goto L10000; - if(CLOCK1 < 0)CLOCK2=CLOCK2-1; - if(CLOCK2 == 0) goto L11000; + if(TALLY == 0 && INDEEP(LOC) && LOC != 33)game.clock1=game.clock1-1; + if(game.clock1 == 0) goto L10000; + if(game.clock1 < 0)game.clock2=game.clock2-1; + if(game.clock2 == 0) goto L11000; if(PROP[LAMP] == 1)LIMIT=LIMIT-1; if(LIMIT <= 30 && HERE(BATTER) && PROP[BATTER] == 0 && HERE(LAMP)) goto L12000; @@ -519,11 +518,13 @@ L8000: SETPRM(1,WD1,WD1X); /* Figure out the new location * - * Given the current location in "LOC", and a motion verb number in "K", put - * the new location in "NEWLOC". The current loc is saved in "OLgame.dloc" in case - * he wants to retreat. The current OLgame.dloc is saved in game.oldlc2, in case he - * dies. (if he does, NEWLOC will be limbo, and OLgame.dloc will be what killed - * him, so we need game.oldlc2, which is the last place he was safe.) */ + * Given the current location in "LOC", and a motion verb number in + * "K", put the new location in "NEWLOC". The current loc is saved + * in "game.olddloc" in case he wants to retreat. The current + * game.oldloc is saved in game.oldlc2, in case he dies. (if he + * does, NEWLOC will be limbo, and OLgame.dloc will be what killed + * him, so we need game.oldlc2, which is the last place he was + * safe.) */ L8: KK=KEY[LOC]; NEWLOC=LOC; @@ -851,7 +852,7 @@ L10000: PROP[GRATE]=0; PROP[AXE]=0; FIXED[AXE]=0; RSPEAK(129); - CLOCK1= -1; + game.clock1= -1; CLOSNG=true; goto L19999; -- 2.31.1