#include <stdlib.h>
#include <stdbool.h>
#include "advent.h"
-#include "funcs.h"
#include "database.h"
+/*
+ * Action handlers. Eventually we'll do lookup through a method table
+ * that calls these. Absolutely nothing like the original FORTRAN
+ */
+
+static int chain(int verb)
+{
+ if(verb != LOCK) {
+ SPK=171;
+ if(game.prop[BEAR] == 0)SPK=41;
+ if(game.prop[CHAIN] == 0)SPK=37;
+ if(SPK != 171) return(2011);
+ game.prop[CHAIN]=0;
+ game.fixed[CHAIN]=0;
+ if(game.prop[BEAR] != 3)game.prop[BEAR]=2;
+ game.fixed[BEAR]=2-game.prop[BEAR];
+ return(2011);
+ } else {
+ SPK=172;
+ if(game.prop[CHAIN] != 0)SPK=34;
+ if(game.loc != PLAC[CHAIN])SPK=173;
+ if(SPK != 172) return(2011);
+ game.prop[CHAIN]=2;
+ if(TOTING(CHAIN))DROP(CHAIN,game.loc);
+ game.fixed[CHAIN]= -1;
+ return(2011);
+ }
+}
+
/* This stuff was broken off as part of an effort to get the main program
* to compile without running out of memory. We're called with a number
* that says what label the caller wanted to "goto", and we return a
*/
int action(FILE *input, long STARTAT, long verb, long obj) {
+ int kk;
switch(STARTAT) {
case 4000: goto L4000;
case 4090: goto L4090;
return(2011);
/* Chain. */
-L9048: if(verb == LOCK) goto L9049;
- SPK=171;
- if(game.prop[BEAR] == 0)SPK=41;
- if(game.prop[CHAIN] == 0)SPK=37;
- if(SPK != 171) return(2011);
- game.prop[CHAIN]=0;
- game.fixed[CHAIN]=0;
- if(game.prop[BEAR] != 3)game.prop[BEAR]=2;
- game.fixed[BEAR]=2-game.prop[BEAR];
- return(2011);
-
-L9049: SPK=172;
- if(game.prop[CHAIN] != 0)SPK=34;
- if(game.loc != PLAC[CHAIN])SPK=173;
- if(SPK != 172) return(2011);
- game.prop[CHAIN]=2;
- if(TOTING(CHAIN))DROP(CHAIN,game.loc);
- game.fixed[CHAIN]= -1;
- return(2011);
+L9048: return chain(verb);
/* Light. Applicable only to lamp and urn. */
/* Score. Call scoring routine but tell it to return. */
L8240: score(-1);
- SETPRM(1,SCORE,MXSCOR);
- SETPRM(3,game.turns,game.turns);
- RSPEAK(259);
- return(2012);
+ return(2012);
/* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
* Look up WD1 in section 3 of vocab to determine which word we've got. Last
RSPEAK(260);
if(!YES(input,200,54,54)) return(2012);
game.saved=game.saved+5;
- KK= -1;
+ kk= -1;
/* This next part is shared with the "resume" code. The two cases are
* distinguished by the value of kk (-1 for suspend, +1 for resume). */
L8305: DATIME(&I,&K);
K=I+650*K;
- SAVWRD(KK,K);
+ SAVWRD(kk,K);
K=VRSION;
SAVWRD(0,K);
if(K != VRSION) goto L8312;
SAVARR(game.odloc,NDWARVES);
SAVARR(game.place,NOBJECTS);
SAVARR(game.prop,NOBJECTS);
- SAVWRD(KK,K);
+ SAVWRD(kk,K);
if(K != 0) goto L8318;
K=NUL;
game.zzword=RNDVOC(3,game.zzword);
- if(KK > 0) return(8);
+ if(kk > 0) return(8);
RSPEAK(266);
exit(0);
/* Resume. Read a suspended game back from a file. */
-L8310: KK=1;
+L8310: kk=1;
if(game.loc == 1 && game.abbrev[1] == 1) goto L8305;
RSPEAK(268);
if(!YES(input,200,54,54)) return(2012);