X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=actions.c;h=3e6933c615943bac7b8298132b736a852b6806c2;hb=d80abbce02cade54cdee4dc536c4e7ec7121e30d;hp=c539554def21da2147568e2423cb5782aa131470;hpb=8cdbf034a2601025c04d8080455abbc1c0aad3c0;p=open-adventure.git diff --git a/actions.c b/actions.c index c539554..3e6933c 100644 --- a/actions.c +++ b/actions.c @@ -3,6 +3,11 @@ #include "advent.h" #include "database.h" +/* Limit visibility of ugly globals. Eventually these should go away. */ +extern long WD1, WD1X, WD2, WD2X; + +static long SPK; /* This should go away too */ + /* * Action handlers. Eventually we'll do lookup through a method table * that calls these. Absolutely nothing like the original FORTRAN. @@ -101,7 +106,6 @@ static int attack(FILE *input, long verb, long obj) MOVE(obj,k); } game.loc=k; - K=NUL; /* FIXME: error if removed */ return(8); } @@ -118,7 +122,10 @@ static int bigwords(long foo) return 2012; } else { game.foobar=k; - if (k != 4) return(2009); + if (k != 4) { + RSPEAK(54); + return 2012; + } game.foobar=0; if (game.place[EGGS]==PLAC[EGGS] || (TOTING(EGGS) && game.loc==PLAC[EGGS])) { RSPEAK(SPK); @@ -140,28 +147,34 @@ static int bigwords(long foo) static int bivalve(token_t verb, token_t obj) /* Clam/oyster actions */ { - int k=0; + int spk, k=0; if (obj == OYSTER)k=1; - SPK=124+k; - if (TOTING(obj))SPK=120+k; - if (!TOTING(TRIDNT))SPK=122+k; - if (verb == LOCK)SPK=61; - if (SPK == 124) { + spk=124+k; + if (TOTING(obj))spk=120+k; + if (!TOTING(TRIDNT))spk=122+k; + if (verb == LOCK)spk=61; + if (spk == 124) { DSTROY(CLAM); DROP(OYSTER,game.loc); DROP(PEARL,105); } - RSPEAK(SPK); + RSPEAK(spk); return 2012; } static int blast(void) /* Blast. No effect unless you've got dynamite, which is a neat trick! */ { - if (game.prop[ROD2] < 0 || !game.closed) {RSPEAK(SPK); return 2012;} + if (game.prop[ROD2] < 0 || !game.closed) + { + RSPEAK(67); + return 2012; + } game.bonus=133; - if (game.loc == 115)game.bonus=134; - if (HERE(ROD2))game.bonus=135; + if (game.loc == 115) + game.bonus=134; + if (HERE(ROD2)) + game.bonus=135; RSPEAK(game.bonus); score(0); } @@ -169,6 +182,7 @@ static int blast(void) static int vbreak(token_t obj) /* Break. Only works for mirror in repository and, of course, the vase. */ { + /* FIXME: defaults from ACTSPK */ if (obj == MIRROR)SPK=148; if (obj == VASE && game.prop[VASE] == 0) { SPK=198; @@ -177,8 +191,8 @@ static int vbreak(token_t obj) game.fixed[VASE]= -1; } else { if (obj == MIRROR && game.closed) { - SPK=197; - return(18999); + RSPEAK(197); + return(190000); } } RSPEAK(SPK); @@ -188,10 +202,9 @@ static int vbreak(token_t obj) static int brief(void) /* Brief. Intransitive only. Suppress long descriptions after first time. */ { - SPK=156; game.abbnum=10000; game.detail=3; - RSPEAK(SPK); + RSPEAK(156); return 2012; } @@ -200,6 +213,7 @@ static int carry(long obj) * take one without the other). Liquids also special, since they depend on * status of bottle. Also various side effects, etc. */ { + int spk; if (obj == INTRANSITIVE) { /* Carry, no object given yet. OK if only one object present. */ if(game.atloc[game.loc] == 0 || @@ -209,39 +223,40 @@ static int carry(long obj) obj=game.atloc[game.loc]; } - if (TOTING(obj)) {RSPEAK(SPK); return 2012;} - SPK=25; - if (obj == PLANT && game.prop[PLANT] <= 0)SPK=115; - if (obj == BEAR && game.prop[BEAR] == 1)SPK=169; - if (obj == CHAIN && game.prop[BEAR] != 0)SPK=170; - if (obj == URN)SPK=215; - if (obj == CAVITY)SPK=217; - if (obj == BLOOD)SPK=239; - if (obj == RUG && game.prop[RUG] == 2)SPK=222; - if (obj == SIGN)SPK=196; + if (TOTING(obj)) {RSPEAK(24); return 2012;} + spk=25; + if (obj == PLANT && game.prop[PLANT] <= 0)spk=115; + if (obj == BEAR && game.prop[BEAR] == 1)spk=169; + if (obj == CHAIN && game.prop[BEAR] != 0)spk=170; + if (obj == URN)spk=215; + if (obj == CAVITY)spk=217; + if (obj == BLOOD)spk=239; + if (obj == RUG && game.prop[RUG] == 2)spk=222; + if (obj == SIGN)spk=196; if (obj == MESSAG) { - SPK=190; + spk=190; + return 2012; DSTROY(MESSAG); } if (game.fixed[obj] != 0) { - RSPEAK(SPK); + RSPEAK(spk); return 2012; } if (obj == WATER || obj == OIL) { if (!HERE(BOTTLE) || LIQUID() != obj) { if (TOTING(BOTTLE) && game.prop[BOTTLE] == 1) return(fill(BOTTLE)); - if (game.prop[BOTTLE] != 1)SPK=105; - if (!TOTING(BOTTLE))SPK=104; - RSPEAK(SPK); + if (game.prop[BOTTLE] != 1)spk=105; + if (!TOTING(BOTTLE))spk=104; + RSPEAK(spk); return 2012; } obj = BOTTLE; } - SPK=92; + spk=92; if (game.holdng >= INVLIMIT) { - RSPEAK(SPK); + RSPEAK(spk); return 2012; } else if (obj == BIRD && game.prop[BIRD] != 1 && -1-game.prop[BIRD] != 1) { @@ -250,10 +265,10 @@ static int carry(long obj) RSPEAK(238); return 2012; } - if (!TOTING(CAGE))SPK=27; - if (TOTING(ROD))SPK=26; - if (SPK/2 == 13) { - RSPEAK(SPK); + if (!TOTING(CAGE))spk=27; + if (TOTING(ROD))spk=26; + if (spk/2 == 13) { + RSPEAK(spk); return 2012; } game.prop[BIRD]=1; @@ -263,35 +278,37 @@ static int carry(long obj) CARRY(obj,game.loc); if (obj == BOTTLE && LIQUID() != 0) game.place[LIQUID()] = -1; - if (!GSTONE(obj) || game.prop[obj] == 0) - return(2009); - game.prop[obj]=0; - game.prop[CAVITY]=1; - return(2009); + if (GSTONE(obj) && game.prop[obj] != 0) { + game.prop[obj]=0; + game.prop[CAVITY]=1; + } + RSPEAK(54); + return(2012); } static int chain(token_t verb) /* Do something to the bear's chain */ { + int spk; if (verb != LOCK) { - SPK=171; - if (game.prop[BEAR] == 0)SPK=41; - if (game.prop[CHAIN] == 0)SPK=37; - if (SPK != 171) {RSPEAK(SPK); return 2012;} + spk=171; + if (game.prop[BEAR] == 0)spk=41; + if (game.prop[CHAIN] == 0)spk=37; + if (spk != 171) {RSPEAK(spk); return 2012;} game.prop[CHAIN]=0; game.fixed[CHAIN]=0; if (game.prop[BEAR] != 3)game.prop[BEAR]=2; game.fixed[BEAR]=2-game.prop[BEAR]; } else { - SPK=172; - if (game.prop[CHAIN] != 0)SPK=34; - if (game.loc != PLAC[CHAIN])SPK=173; - if (SPK != 172) {RSPEAK(SPK); return 2012;} + spk=172; + if (game.prop[CHAIN] != 0)spk=34; + if (game.loc != PLAC[CHAIN])spk=173; + if (spk != 172) {RSPEAK(spk); return 2012;} game.prop[CHAIN]=2; if (TOTING(CHAIN))DROP(CHAIN,game.loc); game.fixed[CHAIN]= -1; } - RSPEAK(SPK); + RSPEAK(spk); return 2012; } @@ -321,10 +338,10 @@ static int discard(long obj, bool just_do_it) if (obj == RUBY)SPK=221; RSPEAK(SPK); if (SPK != 220) { - K=2-game.prop[RUG]; - game.prop[RUG]=K; - if (K == 2)K=PLAC[SAPPH]; - MOVE(RUG+NOBJECTS,K); + int k = 2-game.prop[RUG]; + game.prop[RUG] = k; + if (k == 2) k = PLAC[SAPPH]; + MOVE(RUG+NOBJECTS, k); } } } else if (obj == COINS && HERE(VEND)) { @@ -354,9 +371,10 @@ static int discard(long obj, bool just_do_it) if (game.prop[VASE] != 0)game.fixed[VASE]= -1; } } - K=LIQUID(); - if (K == obj)obj=BOTTLE; - if (obj == BOTTLE && K != 0)game.place[K]=0; + int k = LIQUID(); + if (k == obj)obj=BOTTLE; + if (obj == BOTTLE && k != 0) + game.place[k]=0; if (obj == CAGE && game.prop[BIRD] == 1)DROP(BIRD,game.loc); DROP(obj,game.loc); if (obj != BIRD) return(2012); @@ -444,30 +462,33 @@ static int feed(long obj) * mad. Bear, special. */ { if (obj == BIRD) { - SPK=100; - RSPEAK(SPK); + RSPEAK(100); return 2012; } if (!(obj != SNAKE && obj != DRAGON && obj != TROLL)) { - SPK=102; - if (obj == DRAGON && game.prop[DRAGON] != 0)SPK=110; - if (obj == TROLL)SPK=182; + int spk=102; + if (obj == DRAGON && game.prop[DRAGON] != 0)spk=110; + if (obj == TROLL)spk=182; if (obj != SNAKE || game.closed || !HERE(BIRD)) - {RSPEAK(SPK); return 2012;} - SPK=101; + { + RSPEAK(spk); + return 2012; + } DSTROY(BIRD); game.prop[BIRD]=0; - RSPEAK(SPK); + RSPEAK(101); return 2012; } if (obj == DWARF) { if (!HERE(FOOD)) - {RSPEAK(SPK); return 2012;} - SPK=103; + { + RSPEAK(SPK); /* FIXME: Defaults from ACTSPK */ + return 2012; + } game.dflag=game.dflag+2; - RSPEAK(SPK); + RSPEAK(103); return 2012; } @@ -606,7 +627,8 @@ static int inven(token_t obj) for (i=1; i<=NOBJECTS; i++) { if (i == BEAR || !TOTING(i)) continue; - if (SPK == 98)RSPEAK(99); + if (SPK == 98) + RSPEAK(99); game.blklin=false; PSPEAK(i,-1); game.blklin=true; @@ -621,6 +643,7 @@ static int inven(token_t obj) int light(token_t obj) /* Light. Applicable only to lamp and urn. */ { + int spk; if (obj == INTRANSITIVE) { if (HERE(LAMP) && game.prop[LAMP] == 0 && game.limit >= 0)obj=LAMP; if (HERE(URN) && game.prop[URN] == 1)obj=obj*NOBJECTS+URN; @@ -628,22 +651,22 @@ int light(token_t obj) } if (obj == URN) { - SPK=38; + spk=38; if (game.prop[URN] == 0) - {RSPEAK(SPK); return 2012;} - SPK=209; + {RSPEAK(spk); return 2012;} + spk=209; game.prop[URN]=2; - RSPEAK(SPK); + RSPEAK(spk); return 2012; } else { if (obj != LAMP) { - RSPEAK(SPK); + RSPEAK(spk); return 2012; } - SPK=184; + spk=184; if (game.limit < 0) { - RSPEAK(SPK); + RSPEAK(spk); return 2012; } game.prop[LAMP]=1; @@ -658,23 +681,23 @@ static int listen(void) /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */ { int i, k; - SPK=228; + int spk=228; k=LOCSND[game.loc]; if (k != 0) { RSPEAK(labs(k)); if (k < 0) return(2012); - SPK=0; + spk=0; } SETPRM(1,game.zzword,0); for (i=1; i<=NOBJECTS; i++) { if (!HERE(i) || OBJSND[i] == 0 || game.prop[i] < 0) continue; PSPEAK(i,OBJSND[i]+game.prop[i]); - SPK=0; + spk=0; if (i == BIRD && OBJSND[i]+game.prop[i] == 8) DSTROY(BIRD); } - RSPEAK(SPK); + RSPEAK(spk); return 2012; } @@ -745,7 +768,6 @@ static int pour(token_t obj) PSPEAK(PLANT,game.prop[PLANT]+3); game.prop[PLANT]=MOD(game.prop[PLANT]+1,3); game.prop[PLANT2]=game.prop[PLANT]; - K=NUL; return(8); } else { game.prop[DOOR]=0; @@ -840,7 +862,6 @@ static int throw_support(long spk) { RSPEAK(spk); DROP(AXE,game.loc); - K=NUL; return(8); } @@ -851,8 +872,10 @@ static int throw(FILE *cmdin, long verb, long obj) * troll. Treasures special for troll. */ { if (TOTING(ROD2) && obj == ROD && !TOTING(ROD))obj=ROD2; - if (!TOTING(obj)) - {RSPEAK(SPK); return 2012;} + if (!TOTING(obj)) { + RSPEAK(SPK); /* FIXME: Defaults from ACTSPK */ + return 2012; + } if (obj >= 50 && obj <= MAXTRS && AT(TROLL)) { SPK=159; /* Snarf a treasure for the troll. */ @@ -922,8 +945,8 @@ static int wake(token_t obj) /* Wake. Only use is to disturb the dwarves. */ { if (obj != DWARF || !game.closed) {RSPEAK(SPK); return 2012;} - SPK=199; - return(18999); + RSPEAK(199); + return(19000); } static int wave(token_t obj) @@ -945,7 +968,10 @@ static int wave(token_t obj) RSPEAK(SPK); return 2012; } else { - if (game.closed) return(18999); + if (game.closed) { + RSPEAK(SPK); /* FIXME: How is SPK set here? */ + return(19000); + } if (game.closng || !AT(FISSUR)) {RSPEAK(SPK); return 2012;} if (HERE(BIRD))RSPEAK(SPK); game.prop[FISSUR]=1-game.prop[FISSUR]; @@ -1028,7 +1054,7 @@ int action(FILE *input, enum speechpart part, long verb, long obj) case 1: /* DROP */ return(8000); case 2: /* SAY */ return(8000); case 3: /* UNLOC */ return lock(verb, INTRANSITIVE); - case 4: /* NOTHI */ return(2009); + case 4: /* NOTHI */ {RSPEAK(54); return(20012);} case 5: /* LOCK */ return lock(verb, INTRANSITIVE); case 6: /* LIGHT */ return light(INTRANSITIVE); case 7: /* EXTIN */ return extinguish(INTRANSITIVE); @@ -1069,7 +1095,7 @@ int action(FILE *input, enum speechpart part, long verb, long obj) case 1: /* DROP */ return discard(obj, false); case 2: /* SAY */ return say(); case 3: /* UNLOC */ return lock(verb, obj); - case 4: /* NOTHI */ return(2009); + case 4: /* NOTHI */ {RSPEAK(54); return(20012);} case 5: /* LOCK */ return lock(verb, obj); case 6: /* LIGHT */ return light(obj); case 7: /* EXTI */ return extinguish(obj);