More more globals into the game state block.
This commit is contained in:
parent
07c0020a7a
commit
ab04fe4d41
3 changed files with 38 additions and 35 deletions
14
actions1.c
14
actions1.c
|
@ -536,9 +536,9 @@ L8305: DATIME(&I,&K);
|
||||||
SAVWDS(ABBNUM,BLKLIN,BONUS,CLOCK1,CLOCK2,CLOSED,CLOSNG);
|
SAVWDS(ABBNUM,BLKLIN,BONUS,CLOCK1,CLOCK2,CLOSED,CLOSNG);
|
||||||
SAVWDS(DETAIL,DFLAG,DKILL,DTOTAL,FOOBAR,HOLDNG,IWEST);
|
SAVWDS(DETAIL,DFLAG,DKILL,DTOTAL,FOOBAR,HOLDNG,IWEST);
|
||||||
SAVWDS(KNFLOC,LIMIT,LL,LMWARN,LOC,NEWLOC,NUMDIE);
|
SAVWDS(KNFLOC,LIMIT,LL,LMWARN,LOC,NEWLOC,NUMDIE);
|
||||||
SAVWDS(OBJ,OLDLC2,OLDLOC,OLDOBJ,PANIC,SAVED,SETUP);
|
SAVWDS(OBJ,game.oldlc2,game.oldloc,OLDOBJ,PANIC,SAVED,SETUP);
|
||||||
SAVWDS(SPK,TALLY,THRESH,TRNDEX,TRNLUZ,TURNS,OBJTXT[OYSTER]);
|
SAVWDS(SPK,TALLY,THRESH,TRNDEX,TRNLUZ,TURNS,OBJTXT[OYSTER]);
|
||||||
SAVWDS(VERB,WD1,WD1X,WD2,WZDARK,ZZWORD,OBJSND[BIRD]);
|
SAVWDS(VERB,WD1,WD1X,WD2,WZDARK,game.zzword,OBJSND[BIRD]);
|
||||||
SAVWDS(OBJTXT[SIGN],CLSHNT,NOVICE,K,K,K,K);
|
SAVWDS(OBJTXT[SIGN],CLSHNT,NOVICE,K,K,K,K);
|
||||||
SAVARR(ABB,LOCSIZ);
|
SAVARR(ABB,LOCSIZ);
|
||||||
SAVARR(ATLOC,LOCSIZ);
|
SAVARR(ATLOC,LOCSIZ);
|
||||||
|
@ -554,7 +554,7 @@ L8305: DATIME(&I,&K);
|
||||||
SAVWRD(KK,K);
|
SAVWRD(KK,K);
|
||||||
if(K != 0) goto L8318;
|
if(K != 0) goto L8318;
|
||||||
K=NUL;
|
K=NUL;
|
||||||
ZZWORD=RNDVOC(3,ZZWORD);
|
game.zzword=RNDVOC(3,game.zzword);
|
||||||
if(KK > 0) return(8);
|
if(KK > 0) return(8);
|
||||||
RSPEAK(266);
|
RSPEAK(266);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -585,8 +585,8 @@ L8320: if(PROP[RUG] != 2)SPK=224;
|
||||||
L9320: if(OBJ != RUG) return(2011);
|
L9320: if(OBJ != RUG) return(2011);
|
||||||
SPK=223;
|
SPK=223;
|
||||||
if(PROP[RUG] != 2) return(2011);
|
if(PROP[RUG] != 2) return(2011);
|
||||||
OLDLC2=OLDLOC;
|
game.oldlc2=game.oldloc;
|
||||||
OLDLOC=LOC;
|
game.oldloc=LOC;
|
||||||
NEWLOC=PLACE[RUG]+FIXED[RUG]-LOC;
|
NEWLOC=PLACE[RUG]+FIXED[RUG]-LOC;
|
||||||
SPK=226;
|
SPK=226;
|
||||||
if(PROP[SAPPH] >= 0)SPK=227;
|
if(PROP[SAPPH] >= 0)SPK=227;
|
||||||
|
@ -601,7 +601,7 @@ L8330: SPK=228;
|
||||||
RSPEAK(labs(K));
|
RSPEAK(labs(K));
|
||||||
if(K < 0) return(2012);
|
if(K < 0) return(2012);
|
||||||
SPK=0;
|
SPK=0;
|
||||||
L8332: SETPRM(1,ZZWORD,0);
|
L8332: SETPRM(1,game.zzword,0);
|
||||||
/* 8335 */ for (I=1; I<=NOBJECTS; I++) {
|
/* 8335 */ for (I=1; I<=NOBJECTS; I++) {
|
||||||
if(!HERE(I) || OBJSND[I] == 0 || PROP[I] < 0) goto L8335;
|
if(!HERE(I) || OBJSND[I] == 0 || PROP[I] < 0) goto L8335;
|
||||||
PSPEAK(I,OBJSND[I]+PROP[I]);
|
PSPEAK(I,OBJSND[I]+PROP[I]);
|
||||||
|
@ -617,7 +617,7 @@ L8340: if(!AT(RESER) && LOC != FIXED[RESER]-1) return(2011);
|
||||||
PSPEAK(RESER,PROP[RESER]+1);
|
PSPEAK(RESER,PROP[RESER]+1);
|
||||||
PROP[RESER]=1-PROP[RESER];
|
PROP[RESER]=1-PROP[RESER];
|
||||||
if(AT(RESER)) return(2012);
|
if(AT(RESER)) return(2012);
|
||||||
OLDLC2=LOC;
|
game.oldlc2=LOC;
|
||||||
NEWLOC=0;
|
NEWLOC=0;
|
||||||
RSPEAK(241);
|
RSPEAK(241);
|
||||||
return(2);
|
return(2);
|
||||||
|
|
9
advent.h
9
advent.h
|
@ -14,6 +14,9 @@ typedef long token_t; /* word token - someday this will be a character array */
|
||||||
typedef long vocab_t; /* index into a vocabulary array */
|
typedef long vocab_t; /* index into a vocabulary array */
|
||||||
|
|
||||||
struct game_t {
|
struct game_t {
|
||||||
|
long oldloc;
|
||||||
|
long oldlc2;
|
||||||
|
long zzword;
|
||||||
long dseen[NDWARVES+1];
|
long dseen[NDWARVES+1];
|
||||||
long dloc[NDWARVES+1];
|
long dloc[NDWARVES+1];
|
||||||
long odloc[NDWARVES+1];
|
long odloc[NDWARVES+1];
|
||||||
|
@ -90,7 +93,7 @@ extern long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
|
||||||
BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2,
|
BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2,
|
||||||
CLAM, CLOCK1, CLOCK2, CLOSED, CLOSNG, CLSHNT,
|
CLAM, CLOCK1, CLOCK2, CLOSED, CLOSNG, CLSHNT,
|
||||||
COINS, CONDS, DALTLC, DETAIL,
|
COINS, CONDS, DALTLC, DETAIL,
|
||||||
DKILL, DOOR, DPRSSN, DRAGON, DTOTAL, DWARF, EGGS,
|
DKILL, DOOR, DPRSSN, DRAGON, DTOTAL, DWARF, EGGS,
|
||||||
EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOBAR, FOOD,
|
EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOBAR, FOOD,
|
||||||
GRATE, HINT, HINTED[], HINTLC[],
|
GRATE, HINT, HINTED[], HINTLC[],
|
||||||
I, INVENT, IGO, IWEST, J, JADE, K, K2, KEYS, KK,
|
I, INVENT, IGO, IWEST, J, JADE, K, K2, KEYS, KK,
|
||||||
|
@ -98,7 +101,7 @@ extern long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
|
||||||
LMWARN, LOC, LOCK, LOOK,
|
LMWARN, LOC, LOCK, LOOK,
|
||||||
MAGZIN, MAXDIE, MAXTRS, MESSAG, MIRROR, MXSCOR,
|
MAGZIN, MAXDIE, MAXTRS, MESSAG, MIRROR, MXSCOR,
|
||||||
NEWLOC, NOVICE, NUGGET, NUL, NUMDIE, OBJ,
|
NEWLOC, NOVICE, NUGGET, NUL, NUMDIE, OBJ,
|
||||||
OGRE, OIL, OLDLC2, OLDLOC, OLDOBJ, OYSTER,
|
OGRE, OIL, OLDOBJ, OYSTER,
|
||||||
PANIC, PEARL, PILLOW, PLANT, PLANT2, PROP[], PYRAM,
|
PANIC, PEARL, PILLOW, PLANT, PLANT2, PROP[], PYRAM,
|
||||||
RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAVED, SAY,
|
RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAVED, SAY,
|
||||||
SCORE, SECT, SETUP, SIGN, SNAKE, SPK, STEPS, STICK,
|
SCORE, SECT, SETUP, SIGN, SNAKE, SPK, STEPS, STICK,
|
||||||
|
@ -106,5 +109,5 @@ extern long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
|
||||||
TRNDEX, TRNLUZ, TROLL, TROLL2,
|
TRNDEX, TRNLUZ, TROLL, TROLL2,
|
||||||
TURNS, URN, V1, V2, VASE, VEND, VERB,
|
TURNS, URN, V1, V2, VASE, VEND, VERB,
|
||||||
VOLCAN, VRSION, WATER, WD1, WD1X, WD2, WD2X,
|
VOLCAN, VRSION, WATER, WD1, WD1X, WD2, WD2X,
|
||||||
WZDARK, ZZWORD;
|
WZDARK;
|
||||||
|
|
||||||
|
|
50
main.c
50
main.c
|
@ -34,15 +34,15 @@ long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BONUS,
|
||||||
MAGZIN, MAXDIE, MAXTRS,
|
MAGZIN, MAXDIE, MAXTRS,
|
||||||
MESSAG, MIRROR, MXSCOR,
|
MESSAG, MIRROR, MXSCOR,
|
||||||
NEWLOC, NOVICE, NUGGET, NUL, NUMDIE, OBJ,
|
NEWLOC, NOVICE, NUGGET, NUL, NUMDIE, OBJ,
|
||||||
OGRE, OIL, OLDLC2, OLDLOC, OLDOBJ, OYSTER,
|
OGRE, OIL, OLDOBJ, OYSTER,
|
||||||
PANIC, PEARL, PILLOW, PLANT, PLANT2, PROP[NOBJECTS+1], PYRAM,
|
PANIC, PEARL, PILLOW, PLANT, PLANT2, PROP[NOBJECTS+1], PYRAM,
|
||||||
RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAVED, SAY,
|
RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAVED, SAY,
|
||||||
SCORE, SECT, SIGN, SNAKE, SPK, STEPS, STICK,
|
SCORE, SECT, SIGN, SNAKE, SPK, STEPS, STICK,
|
||||||
STREAM, TALLY, THRESH, THROW, TK[21], TRIDNT,
|
STREAM, TALLY, THRESH, THROW, TK[21], TRIDNT,
|
||||||
TRNDEX, TRNLUZ, TROLL, TROLL2,
|
TRNDEX, TRNLUZ, TROLL, TROLL2,
|
||||||
TURNS, URN, V1, V2, VASE, VEND, VERB,
|
TURNS, URN, V1, V2, VASE, VEND, VERB,
|
||||||
VOLCAN, VRSION = 25, WATER, WD1, WD1X, WD2, WD2X,
|
VOLCAN, VRSION = 25, WATER, WD1, WD1X, WD2, WD2X,
|
||||||
WZDARK = false, ZZWORD;
|
WZDARK = false;
|
||||||
FILE *logfp;
|
FILE *logfp;
|
||||||
bool oldstyle = false;
|
bool oldstyle = false;
|
||||||
lcg_state lcgstate;
|
lcg_state lcgstate;
|
||||||
|
@ -133,7 +133,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
L1: SETUP= -1;
|
L1: SETUP= -1;
|
||||||
I=0;
|
I=0;
|
||||||
ZZWORD=RNDVOC(3,0);
|
game.zzword=RNDVOC(3,0);
|
||||||
NOVICE=YES(stdin, 65,1,0);
|
NOVICE=YES(stdin, 65,1,0);
|
||||||
NEWLOC=1;
|
NEWLOC=1;
|
||||||
LOC=1;
|
LOC=1;
|
||||||
|
@ -160,7 +160,7 @@ static bool fallback_handler(char *buf)
|
||||||
// autogenerated, so don't charge user time for it.
|
// autogenerated, so don't charge user time for it.
|
||||||
--TURNS;
|
--TURNS;
|
||||||
// here we reconfigure any global game state that uses random numbers
|
// here we reconfigure any global game state that uses random numbers
|
||||||
ZZWORD=RNDVOC(3,0);
|
game.zzword=RNDVOC(3,0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -323,7 +323,7 @@ L6030: /*etc*/ ;
|
||||||
SETPRM(1,STICK,0);
|
SETPRM(1,STICK,0);
|
||||||
RSPEAK(K+1+2/(1+STICK));
|
RSPEAK(K+1+2/(1+STICK));
|
||||||
if(STICK == 0) goto L2000;
|
if(STICK == 0) goto L2000;
|
||||||
OLDLC2=LOC;
|
game.oldlc2=LOC;
|
||||||
goto L99;
|
goto L99;
|
||||||
|
|
||||||
|
|
||||||
|
@ -521,9 +521,9 @@ L8000: SETPRM(1,WD1,WD1X);
|
||||||
*
|
*
|
||||||
* Given the current location in "LOC", and a motion verb number in "K", put
|
* 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
|
* 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 OLDLC2, in case he
|
* 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
|
* dies. (if he does, NEWLOC will be limbo, and OLgame.dloc will be what killed
|
||||||
* him, so we need OLDLC2, which is the last place he was safe.) */
|
* him, so we need game.oldlc2, which is the last place he was safe.) */
|
||||||
|
|
||||||
L8: KK=KEY[LOC];
|
L8: KK=KEY[LOC];
|
||||||
NEWLOC=LOC;
|
NEWLOC=LOC;
|
||||||
|
@ -532,8 +532,8 @@ L8: KK=KEY[LOC];
|
||||||
if(K == BACK) goto L20;
|
if(K == BACK) goto L20;
|
||||||
if(K == LOOK) goto L30;
|
if(K == LOOK) goto L30;
|
||||||
if(K == CAVE) goto L40;
|
if(K == CAVE) goto L40;
|
||||||
OLDLC2=OLDLOC;
|
game.oldlc2=game.oldloc;
|
||||||
OLDLOC=LOC;
|
game.oldloc=LOC;
|
||||||
|
|
||||||
L9: LL=labs(TRAVEL[KK]);
|
L9: LL=labs(TRAVEL[KK]);
|
||||||
if(MOD(LL,1000) == 1 || MOD(LL,1000) == K) goto L10;
|
if(MOD(LL,1000) == 1 || MOD(LL,1000) == K) goto L10;
|
||||||
|
@ -616,18 +616,18 @@ L30310: NEWLOC=PLAC[TROLL]+FIXD[TROLL]-LOC;
|
||||||
DROP(BEAR,NEWLOC);
|
DROP(BEAR,NEWLOC);
|
||||||
FIXED[BEAR]= -1;
|
FIXED[BEAR]= -1;
|
||||||
PROP[BEAR]=3;
|
PROP[BEAR]=3;
|
||||||
OLDLC2=NEWLOC;
|
game.oldlc2=NEWLOC;
|
||||||
goto L99;
|
goto L99;
|
||||||
|
|
||||||
/* End of specials. */
|
/* End of specials. */
|
||||||
|
|
||||||
/* Handle "go back". Look for verb which goes from LOC to OLDLOC, or to OLDLC2
|
/* Handle "go back". Look for verb which goes from LOC to game.oldloc, or to game.oldlc2
|
||||||
* If OLDLOC has forced-motion. K2 saves entry -> forced loc -> previous loc. */
|
* If game.oldloc has forced-motion. K2 saves entry -> forced loc -> previous loc. */
|
||||||
|
|
||||||
L20: K=OLDLOC;
|
L20: K=game.oldloc;
|
||||||
if(FORCED(K))K=OLDLC2;
|
if(FORCED(K))K=game.oldlc2;
|
||||||
OLDLC2=OLDLOC;
|
game.oldlc2=game.oldloc;
|
||||||
OLDLOC=LOC;
|
game.oldloc=LOC;
|
||||||
K2=0;
|
K2=0;
|
||||||
if(K == LOC)K2=91;
|
if(K == LOC)K2=91;
|
||||||
if(CNDBIT(LOC,4))K2=274;
|
if(CNDBIT(LOC,4))K2=274;
|
||||||
|
@ -693,7 +693,7 @@ L50: SPK=12;
|
||||||
* snide messages available. Each death results in a message (81, 83, etc.)
|
* snide messages available. Each death results in a message (81, 83, etc.)
|
||||||
* which offers reincarnation; if accepted, this results in message 82, 84,
|
* which offers reincarnation; if accepted, this results in message 82, 84,
|
||||||
* etc. The last time, if he wants another chance, he gets a snide remark as
|
* etc. The last time, if he wants another chance, he gets a snide remark as
|
||||||
* we exit. When reincarnated, all objects being carried get dropped at OLDLC2
|
* we exit. When reincarnated, all objects being carried get dropped at game.oldlc2
|
||||||
* (presumably the last place prior to being killed) without change of props.
|
* (presumably the last place prior to being killed) without change of props.
|
||||||
* the loop runs backwards to assure that the bird is dropped before the cage.
|
* the loop runs backwards to assure that the bird is dropped before the cage.
|
||||||
* (this kluge could be changed once we're sure all references to bird and cage
|
* (this kluge could be changed once we're sure all references to bird and cage
|
||||||
|
@ -701,12 +701,12 @@ L50: SPK=12;
|
||||||
* it in the cave). It is turned off and left outside the building (only if he
|
* it in the cave). It is turned off and left outside the building (only if he
|
||||||
* was carrying it, of course). He himself is left inside the building (and
|
* was carrying it, of course). He himself is left inside the building (and
|
||||||
* heaven help him if he tries to xyzzy back into the cave without the lamp!).
|
* heaven help him if he tries to xyzzy back into the cave without the lamp!).
|
||||||
* OLDLOC is zapped so he can't just "retreat". */
|
* game.oldloc is zapped so he can't just "retreat". */
|
||||||
|
|
||||||
/* The easiest way to get killed is to fall into a pit in pitch darkness. */
|
/* The easiest way to get killed is to fall into a pit in pitch darkness. */
|
||||||
|
|
||||||
L90: RSPEAK(23);
|
L90: RSPEAK(23);
|
||||||
OLDLC2=LOC;
|
game.oldlc2=LOC;
|
||||||
|
|
||||||
/* Okay, he's dead. Let's get on with it. */
|
/* Okay, he's dead. Let's get on with it. */
|
||||||
|
|
||||||
|
@ -720,13 +720,13 @@ L99: if(CLOSNG) goto L95;
|
||||||
/* 98 */ for (J=1; J<=NOBJECTS; J++) {
|
/* 98 */ for (J=1; J<=NOBJECTS; J++) {
|
||||||
I=NOBJECTS + 1 - J;
|
I=NOBJECTS + 1 - J;
|
||||||
if(!TOTING(I)) goto L98;
|
if(!TOTING(I)) goto L98;
|
||||||
K=OLDLC2;
|
K=game.oldlc2;
|
||||||
if(I == LAMP)K=1;
|
if(I == LAMP)K=1;
|
||||||
DROP(I,K);
|
DROP(I,K);
|
||||||
L98: /*etc*/ ;
|
L98: /*etc*/ ;
|
||||||
} /* end loop */
|
} /* end loop */
|
||||||
LOC=3;
|
LOC=3;
|
||||||
OLDLOC=LOC;
|
game.oldloc=LOC;
|
||||||
goto L2000;
|
goto L2000;
|
||||||
|
|
||||||
/* He died during closing time. No resurrection. Tally up a death and exit. */
|
/* He died during closing time. No resurrection. Tally up a death and exit. */
|
||||||
|
@ -774,7 +774,7 @@ L40200: if(PLACE[BIRD] == LOC && TOTING(ROD) && OLDOBJ == BIRD) goto L40010;
|
||||||
L40300: if(HERE(SNAKE) && !HERE(BIRD)) goto L40010;
|
L40300: if(HERE(SNAKE) && !HERE(BIRD)) goto L40010;
|
||||||
goto L40020;
|
goto L40020;
|
||||||
|
|
||||||
L40400: if(ATLOC[LOC] == 0 && ATLOC[OLDLOC] == 0 && ATLOC[OLDLC2] == 0 && HOLDNG >
|
L40400: if(ATLOC[LOC] == 0 && ATLOC[game.oldloc] == 0 && ATLOC[game.oldlc2] == 0 && HOLDNG >
|
||||||
1) goto L40010;
|
1) goto L40010;
|
||||||
goto L40020;
|
goto L40020;
|
||||||
|
|
||||||
|
@ -786,7 +786,7 @@ L40600: goto L40010;
|
||||||
L40700: if(DFLAG == 0) goto L40010;
|
L40700: if(DFLAG == 0) goto L40010;
|
||||||
goto L40020;
|
goto L40020;
|
||||||
|
|
||||||
L40800: if(ATLOC[LOC] == 0 && ATLOC[OLDLOC] == 0 && ATLOC[OLDLC2] == 0) goto
|
L40800: if(ATLOC[LOC] == 0 && ATLOC[game.oldloc] == 0 && ATLOC[game.oldlc2] == 0) goto
|
||||||
L40010;
|
L40010;
|
||||||
goto L40030;
|
goto L40030;
|
||||||
|
|
||||||
|
@ -875,7 +875,7 @@ L11000: PROP[BOTTLE]=PUT(BOTTLE,115,1);
|
||||||
PROP[ROD]=PUT(ROD,115,0);
|
PROP[ROD]=PUT(ROD,115,0);
|
||||||
PROP[DWARF]=PUT(DWARF,115,0);
|
PROP[DWARF]=PUT(DWARF,115,0);
|
||||||
LOC=115;
|
LOC=115;
|
||||||
OLDLOC=115;
|
game.oldloc=115;
|
||||||
NEWLOC=115;
|
NEWLOC=115;
|
||||||
|
|
||||||
/* Leave the grate with normal (non-negative) property. Reuse sign. */
|
/* Leave the grate with normal (non-negative) property. Reuse sign. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue