Begin gathering saveable game state into a structure. Not yet complete.

No logic changes.  A bunch of globals turn into fields (with the same names
except for lowercasing) in struct game_t.

Eventually this will allow drastic simplification of the save/load logic.
This commit is contained in:
Eric S. Raymond 2017-05-23 18:47:04 -04:00
parent dc9d9e467b
commit 42189d79d7
11 changed files with 260 additions and 231 deletions

View file

@ -31,7 +31,7 @@ L9011: if(FIXED[OBJ] != 0) return(2011);
if(!TOTING(BOTTLE))SPK=104;
return(2011);
L9017: SPK=92;
if(HOLDNG >= 7) return(2011);
if(game.holdng >= 7) return(2011);
if(OBJ != BIRD || PROP[BIRD] == 1 || -1-PROP[BIRD] == 1) goto L9014;
if(PROP[BIRD] == 2) goto L9015;
if(!TOTING(CAGE))SPK=27;
@ -63,7 +63,7 @@ int discard(bool just_do_it) {
if(!TOTING(OBJ)) return(2011);
if(OBJ != BIRD || !HERE(SNAKE)) goto L9023;
RSPEAK(30);
if(CLOSED) return(19000);
if(game.closed) return(19000);
DSTROY(SNAKE);
/* SET PROP FOR USE BY TRAVEL OPTIONS */
PROP[SNAKE]=1;
@ -150,7 +150,7 @@ int attack(FILE *input) {
if(OBJ > 100) return(8000);
L9124: if(OBJ != BIRD) goto L9125;
SPK=137;
if(CLOSED) return(2011);
if(game.closed) return(2011);
DSTROY(BIRD);
PROP[BIRD]=0;
SPK=45;
@ -163,7 +163,7 @@ L9126: if(OBJ == 0)SPK=44;
if(OBJ == CLAM || OBJ == OYSTER)SPK=150;
if(OBJ == SNAKE)SPK=46;
if(OBJ == DWARF)SPK=49;
if(OBJ == DWARF && CLOSED) return(19000);
if(OBJ == DWARF && game.closed) return(19000);
if(OBJ == DRAGON)SPK=167;
if(OBJ == TROLL)SPK=157;
if(OBJ == OGRE)SPK=203;
@ -233,12 +233,12 @@ int throw(FILE *cmdin) {
return(attack(cmdin));
L9172: SPK=48;
if(RAN(7) < DFLAG) goto L9175;
if(RAN(7) < game.dflag) goto L9175;
DSEEN[I]=false;
DLOC[I]=0;
SPK=47;
DKILL=DKILL+1;
if(DKILL == 1)SPK=149;
game.dkill=game.dkill+1;
if(game.dkill == 1)SPK=149;
L9175: RSPEAK(SPK);
DROP(AXE,LOC);
K=NUL;
@ -279,7 +279,7 @@ L9212: if(OBJ != SNAKE && OBJ != DRAGON && OBJ != TROLL) goto L9213;
SPK=102;
if(OBJ == DRAGON && PROP[DRAGON] != 0)SPK=110;
if(OBJ == TROLL)SPK=182;
if(OBJ != SNAKE || CLOSED || !HERE(BIRD)) return(2011);
if(OBJ != SNAKE || game.closed || !HERE(BIRD)) return(2011);
SPK=101;
DSTROY(BIRD);
PROP[BIRD]=0;
@ -288,7 +288,7 @@ L9212: if(OBJ != SNAKE && OBJ != DRAGON && OBJ != TROLL) goto L9213;
L9213: if(OBJ != DWARF) goto L9214;
if(!HERE(FOOD)) return(2011);
SPK=103;
DFLAG=DFLAG+2;
game.dflag=game.dflag+2;
return(2011);
L9214: if(OBJ != BEAR) goto L9215;