Take FORTRANish upper-case function names to C-style lowercase...

...except for a few we're planning to get rid of.  This will avoid some
upcoming collisions with macros defined from YAML.
This commit is contained in:
Eric S. Raymond 2017-06-26 10:19:33 -04:00
parent b626371b6c
commit 59243cf8bc
6 changed files with 131 additions and 131 deletions

View file

@ -16,7 +16,7 @@ static int attack(FILE *input, struct command_t *command)
vocab_t obj = command->obj; vocab_t obj = command->obj;
int spk = actspk[verb]; int spk = actspk[verb];
if (obj == 0 || obj == INTRANSITIVE) { if (obj == 0 || obj == INTRANSITIVE) {
if (ATDWRF(game.loc) > 0) if (atdwrf(game.loc) > 0)
obj = DWARF; obj = DWARF;
if (HERE(SNAKE))obj = obj * NOBJECTS + SNAKE; if (HERE(SNAKE))obj = obj * NOBJECTS + SNAKE;
if (AT(DRAGON) && game.prop[DRAGON] == 0)obj = obj * NOBJECTS + DRAGON; if (AT(DRAGON) && game.prop[DRAGON] == 0)obj = obj * NOBJECTS + DRAGON;
@ -58,7 +58,7 @@ static int attack(FILE *input, struct command_t *command)
if (obj == DRAGON)spk = ALREADY_DEAD; if (obj == DRAGON)spk = ALREADY_DEAD;
if (obj == TROLL)spk = ROCKY_TROLL; if (obj == TROLL)spk = ROCKY_TROLL;
if (obj == OGRE)spk = OGRE_DODGE; if (obj == OGRE)spk = OGRE_DODGE;
if (obj == OGRE && ATDWRF(game.loc) > 0) { if (obj == OGRE && atdwrf(game.loc) > 0) {
rspeak(spk); rspeak(spk);
rspeak(KNIFE_THROWN); rspeak(KNIFE_THROWN);
DESTROY(OGRE); DESTROY(OGRE);
@ -87,14 +87,14 @@ static int attack(FILE *input, struct command_t *command)
game.prop[DRAGON] = 1; game.prop[DRAGON] = 1;
game.prop[RUG] = 0; game.prop[RUG] = 0;
int k = (object_descriptions[DRAGON].plac + object_descriptions[DRAGON].fixd) / 2; int k = (object_descriptions[DRAGON].plac + object_descriptions[DRAGON].fixd) / 2;
MOVE(DRAGON + NOBJECTS, -1); move(DRAGON + NOBJECTS, -1);
MOVE(RUG + NOBJECTS, 0); move(RUG + NOBJECTS, 0);
MOVE(DRAGON, k); move(DRAGON, k);
MOVE(RUG, k); move(RUG, k);
DROP(BLOOD, k); drop(BLOOD, k);
for (obj = 1; obj <= NOBJECTS; obj++) { for (obj = 1; obj <= NOBJECTS; obj++) {
if (game.place[obj] == object_descriptions[DRAGON].plac || game.place[obj] == object_descriptions[DRAGON].fixd) if (game.place[obj] == object_descriptions[DRAGON].plac || game.place[obj] == object_descriptions[DRAGON].fixd)
MOVE(obj, k); move(obj, k);
} }
game.loc = k; game.loc = k;
return GO_MOVE; return GO_MOVE;
@ -109,7 +109,7 @@ static int bigwords(token_t foo)
* Look up foo in section 3 of vocab to determine which word we've got. Last * Look up foo in section 3 of vocab to determine which word we've got. Last
* word zips the eggs back to the giant room (unless already there). */ * word zips the eggs back to the giant room (unless already there). */
{ {
int k = VOCAB(foo, 3); int k = vocab(foo, 3);
int spk = NOTHING_HAPPENS; int spk = NOTHING_HAPPENS;
if (game.foobar != 1 - k) { if (game.foobar != 1 - k) {
if (game.foobar != 0 && game.loc == LOC_GIANTROOM)spk = START_OVER; if (game.foobar != 0 && game.loc == LOC_GIANTROOM)spk = START_OVER;
@ -133,7 +133,7 @@ static int bigwords(token_t foo)
k = 2; k = 2;
if (HERE(EGGS))k = 1; if (HERE(EGGS))k = 1;
if (game.loc == object_descriptions[EGGS].plac)k = 0; if (game.loc == object_descriptions[EGGS].plac)k = 0;
MOVE(EGGS, object_descriptions[EGGS].plac); move(EGGS, object_descriptions[EGGS].plac);
pspeak(EGGS, look, k); pspeak(EGGS, look, k);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
@ -151,8 +151,8 @@ static int bivalve(token_t verb, token_t obj)
if (verb == LOCK)spk = HUH_MAN; if (verb == LOCK)spk = HUH_MAN;
if (spk == PEARL_FALLS) { if (spk == PEARL_FALLS) {
DESTROY(CLAM); DESTROY(CLAM);
DROP(OYSTER, game.loc); drop(OYSTER, game.loc);
DROP(PEARL, LOC_CULDESAC); drop(PEARL, LOC_CULDESAC);
} }
rspeak(spk); rspeak(spk);
return GO_CLEAROBJ; return GO_CLEAROBJ;
@ -180,7 +180,7 @@ static int vbreak(token_t verb, token_t obj)
int spk = actspk[verb]; int spk = actspk[verb];
if (obj == MIRROR)spk = TOO_FAR; if (obj == MIRROR)spk = TOO_FAR;
if (obj == VASE && game.prop[VASE] == 0) { if (obj == VASE && game.prop[VASE] == 0) {
if (TOTING(VASE))DROP(VASE, game.loc); if (TOTING(VASE))drop(VASE, game.loc);
game.prop[VASE] = 2; game.prop[VASE] = 2;
game.fixed[VASE] = -1; game.fixed[VASE] = -1;
spk = BREAK_VASE; spk = BREAK_VASE;
@ -203,7 +203,7 @@ static int brief(void)
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
static int carry(token_t verb, token_t obj) static int vcarry(token_t verb, token_t obj)
/* Carry an object. Special cases for bird and cage (if bird in cage, can't /* Carry an object. Special cases for bird and cage (if bird in cage, can't
* take one without the other). Liquids also special, since they depend on * take one without the other). Liquids also special, since they depend on
* status of bottle. Also various side effects, etc. */ * status of bottle. Also various side effects, etc. */
@ -213,7 +213,7 @@ static int carry(token_t verb, token_t obj)
/* Carry, no object given yet. OK if only one object present. */ /* Carry, no object given yet. OK if only one object present. */
if (game.atloc[game.loc] == 0 || if (game.atloc[game.loc] == 0 ||
game.link[game.atloc[game.loc]] != 0 || game.link[game.atloc[game.loc]] != 0 ||
ATDWRF(game.loc) > 0) atdwrf(game.loc) > 0)
return GO_UNKNOWN; return GO_UNKNOWN;
obj = game.atloc[game.loc]; obj = game.atloc[game.loc];
} }
@ -274,8 +274,8 @@ static int carry(token_t verb, token_t obj)
game.prop[BIRD] = BIRD_CAGED; game.prop[BIRD] = BIRD_CAGED;
} }
if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1)) if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
CARRY(BIRD + CAGE - obj, game.loc); carry(BIRD + CAGE - obj, game.loc);
CARRY(obj, game.loc); carry(obj, game.loc);
if (obj == BOTTLE && LIQUID() != 0) if (obj == BOTTLE && LIQUID() != 0)
game.place[LIQUID()] = CARRIED; game.place[LIQUID()] = CARRIED;
if (GSTONE(obj) && game.prop[obj] != 0) { if (GSTONE(obj) && game.prop[obj] != 0) {
@ -311,7 +311,7 @@ static int chain(token_t verb)
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
game.prop[CHAIN] = 2; game.prop[CHAIN] = 2;
if (TOTING(CHAIN))DROP(CHAIN, game.loc); if (TOTING(CHAIN))drop(CHAIN, game.loc);
game.fixed[CHAIN] = -1; game.fixed[CHAIN] = -1;
} }
rspeak(spk); rspeak(spk);
@ -351,12 +351,12 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
int k = 2 - game.prop[RUG]; int k = 2 - game.prop[RUG];
game.prop[RUG] = k; game.prop[RUG] = k;
if (k == 2) k = object_descriptions[SAPPH].plac; if (k == 2) k = object_descriptions[SAPPH].plac;
MOVE(RUG + NOBJECTS, k); move(RUG + NOBJECTS, k);
} }
} }
} else if (obj == COINS && HERE(VEND)) { } else if (obj == COINS && HERE(VEND)) {
DESTROY(COINS); DESTROY(COINS);
DROP(BATTERY, game.loc); drop(BATTERY, game.loc);
pspeak(BATTERY, look, FRESH_BATTERIES); pspeak(BATTERY, look, FRESH_BATTERIES);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == 0) { } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == 0) {
@ -365,11 +365,11 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
return GO_CLEAROBJ; return GO_CLEAROBJ;
} else if (obj == BEAR && AT(TROLL)) { } else if (obj == BEAR && AT(TROLL)) {
rspeak(TROLL_SCAMPERS); rspeak(TROLL_SCAMPERS);
MOVE(TROLL, 0); move(TROLL, 0);
MOVE(TROLL + NOBJECTS, 0); move(TROLL + NOBJECTS, 0);
MOVE(TROLL2, object_descriptions[TROLL].plac); move(TROLL2, object_descriptions[TROLL].plac);
MOVE(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd); move(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd);
JUGGLE(CHASM); juggle(CHASM);
game.prop[TROLL] = 2; game.prop[TROLL] = 2;
} else if (obj != VASE || game.loc == object_descriptions[PILLOW].plac) { } else if (obj != VASE || game.loc == object_descriptions[PILLOW].plac) {
rspeak(OK_MAN); rspeak(OK_MAN);
@ -385,8 +385,8 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
if (obj == BOTTLE && k != 0) if (obj == BOTTLE && k != 0)
game.place[k] = LOC_NOWHERE; game.place[k] = LOC_NOWHERE;
if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED) if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
DROP(BIRD, game.loc); drop(BIRD, game.loc);
DROP(obj, game.loc); drop(obj, game.loc);
if (obj != BIRD) return GO_CLEAROBJ; if (obj != BIRD) return GO_CLEAROBJ;
game.prop[BIRD] = BIRD_UNCAGED; game.prop[BIRD] = BIRD_UNCAGED;
if (FOREST(game.loc)) if (FOREST(game.loc))
@ -573,7 +573,7 @@ static int find(token_t verb, token_t obj)
if (AT(obj) || if (AT(obj) ||
(LIQUID() == obj && AT(BOTTLE)) || (LIQUID() == obj && AT(BOTTLE)) ||
obj == LIQLOC(game.loc) || obj == LIQLOC(game.loc) ||
(obj == DWARF && ATDWRF(game.loc) > 0)) (obj == DWARF && atdwrf(game.loc) > 0))
spk = YOU_HAVEIT; spk = YOU_HAVEIT;
if (game.closed)spk = NEEDED_NEARBY; if (game.closed)spk = NEEDED_NEARBY;
if (TOTING(obj))spk = ALREADY_CARRYING; if (TOTING(obj))spk = ALREADY_CARRYING;
@ -793,7 +793,7 @@ static int pour(token_t verb, token_t obj)
static int quit(void) static int quit(void)
/* Quit. Intransitive only. Verify intent and exit if that's what he wants. */ /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
{ {
if (YES(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN])) if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
terminate(quitgame); terminate(quitgame);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
@ -814,7 +814,7 @@ static int read(struct command_t command)
if (DARK(game.loc)) { if (DARK(game.loc)) {
rspeak(NO_SEE, command.wd1, command.wd1x); rspeak(NO_SEE, command.wd1, command.wd1x);
} else if (command.obj == OYSTER && !game.clshnt && game.closed) { } else if (command.obj == OYSTER && !game.clshnt && game.closed) {
game.clshnt = YES(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]); game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
} else if (object_descriptions[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) { } else if (object_descriptions[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
rspeak(actspk[command.verb]); rspeak(actspk[command.verb]);
} else } else
@ -850,10 +850,10 @@ static int rub(token_t verb, token_t obj)
spk = PECULIAR_NOTHING; spk = PECULIAR_NOTHING;
if (obj == URN && game.prop[URN] == 2) { if (obj == URN && game.prop[URN] == 2) {
DESTROY(URN); DESTROY(URN);
DROP(AMBER, game.loc); drop(AMBER, game.loc);
game.prop[AMBER] = 1; game.prop[AMBER] = 1;
--game.tally; --game.tally;
DROP(CAVITY, game.loc); drop(CAVITY, game.loc);
spk = URN_GENIES; spk = URN_GENIES;
} }
rspeak(spk); rspeak(spk);
@ -869,7 +869,7 @@ static int say(struct command_t *command)
b = command->wd2x; b = command->wd2x;
command->wd1 = command->wd2; command->wd1 = command->wd2;
} }
int wd = VOCAB(command->wd1, -1); int wd = vocab(command->wd1, -1);
/* FIXME: Magic numbers */ /* FIXME: Magic numbers */
if (wd == 62 || wd == 65 || wd == 71 || wd == 2025 || wd == 2034) { if (wd == 62 || wd == 65 || wd == 71 || wd == 2025 || wd == 2034) {
/* FIXME: scribbles on the interpreter's command block */ /* FIXME: scribbles on the interpreter's command block */
@ -883,7 +883,7 @@ static int say(struct command_t *command)
static int throw_support(long spk) static int throw_support(long spk)
{ {
rspeak(spk); rspeak(spk);
DROP(AXE, game.loc); drop(AXE, game.loc);
return GO_MOVE; return GO_MOVE;
} }
@ -902,12 +902,12 @@ static int throw (FILE *cmdin, struct command_t *command)
if (object_descriptions[command->obj].is_treasure && AT(TROLL)) { if (object_descriptions[command->obj].is_treasure && AT(TROLL)) {
spk = TROLL_SATISFIED; spk = TROLL_SATISFIED;
/* Snarf a treasure for the troll. */ /* Snarf a treasure for the troll. */
DROP(command->obj, 0); drop(command->obj, 0);
MOVE(TROLL, 0); move(TROLL, 0);
MOVE(TROLL + NOBJECTS, 0); move(TROLL + NOBJECTS, 0);
DROP(TROLL2, object_descriptions[TROLL].plac); drop(TROLL2, object_descriptions[TROLL].plac);
DROP(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd); drop(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd);
JUGGLE(CHASM); juggle(CHASM);
rspeak(spk); rspeak(spk);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
@ -919,7 +919,7 @@ static int throw (FILE *cmdin, struct command_t *command)
if (command->obj != AXE) if (command->obj != AXE)
return (discard(command->verb, command->obj, false)); return (discard(command->verb, command->obj, false));
else { else {
int i = ATDWRF(game.loc); int i = atdwrf(game.loc);
if (i <= 0) { if (i <= 0) {
if (AT(DRAGON) && game.prop[DRAGON] == 0) if (AT(DRAGON) && game.prop[DRAGON] == 0)
return throw_support(DRAGON_SCALES); return throw_support(DRAGON_SCALES);
@ -929,10 +929,10 @@ static int throw (FILE *cmdin, struct command_t *command)
return throw_support(OGRE_DODGE); return throw_support(OGRE_DODGE);
else if (HERE(BEAR) && game.prop[BEAR] == 0) { else if (HERE(BEAR) && game.prop[BEAR] == 0) {
/* This'll teach him to throw the axe at the bear! */ /* This'll teach him to throw the axe at the bear! */
DROP(AXE, game.loc); drop(AXE, game.loc);
game.fixed[AXE] = -1; game.fixed[AXE] = -1;
game.prop[AXE] = 1; game.prop[AXE] = 1;
JUGGLE(BEAR); juggle(BEAR);
rspeak(AXE_LOST); rspeak(AXE_LOST);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
@ -978,7 +978,7 @@ static int wave(token_t verb, token_t obj)
if (HERE(BIRD)) if (HERE(BIRD))
spk = FREE_FLY + MOD(game.prop[BIRD], 2); spk = FREE_FLY + MOD(game.prop[BIRD], 2);
if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) { if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
DROP(JADE, game.loc); drop(JADE, game.loc);
game.prop[JADE] = 0; game.prop[JADE] = 0;
--game.tally; --game.tally;
spk = NECKLACE_FLY; spk = NECKLACE_FLY;
@ -1023,7 +1023,7 @@ int action(FILE *input, struct command_t *command)
if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD || if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD ||
game.loc == LOC_BIRD || game.loc == LOC_PITTOP) game.loc == LOC_BIRD || game.loc == LOC_PITTOP)
command->obj = ENTRNC; command->obj = ENTRNC;
} else if (command->obj == DWARF && ATDWRF(game.loc) > 0) } else if (command->obj == DWARF && atdwrf(game.loc) > 0)
/* FALL THROUGH */; /* FALL THROUGH */;
else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc)) else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc))
/* FALL THROUGH */; /* FALL THROUGH */;
@ -1063,7 +1063,7 @@ int action(FILE *input, struct command_t *command)
/* Analyse an intransitive verb (ie, no object given yet). */ /* Analyse an intransitive verb (ie, no object given yet). */
switch (command->verb - 1) { switch (command->verb - 1) {
case 0: /* CARRY */ case 0: /* CARRY */
return carry(command->verb, INTRANSITIVE); return vcarry(command->verb, INTRANSITIVE);
case 1: /* DROP */ case 1: /* DROP */
return GO_UNKNOWN; return GO_UNKNOWN;
case 2: /* SAY */ case 2: /* SAY */
@ -1145,7 +1145,7 @@ int action(FILE *input, struct command_t *command)
/* Analyse a transitive verb. */ /* Analyse a transitive verb. */
switch (command->verb - 1) { switch (command->verb - 1) {
case 0: /* CARRY */ case 0: /* CARRY */
return carry(command->verb, command->obj); return vcarry(command->verb, command->obj);
case 1: /* DROP */ case 1: /* DROP */
return discard(command->verb, command->obj, false); return discard(command->verb, command->obj, false);
case 2: /* SAY */ case 2: /* SAY */

View file

@ -104,21 +104,21 @@ extern void rspeak(vocab_t, ...);
extern bool GETIN(FILE *, token_t*, token_t*, token_t*, token_t*); extern bool GETIN(FILE *, token_t*, token_t*, token_t*, token_t*);
extern void echo_input(FILE*, char*, char*); extern void echo_input(FILE*, char*, char*);
extern char* get_input(void); extern char* get_input(void);
extern bool YES(const char*, const char*, const char*); extern bool yes(const char*, const char*, const char*);
extern long GETTXT(bool, bool, bool); extern long GETTXT(bool, bool, bool);
extern token_t MAKEWD(long); extern token_t MAKEWD(long);
extern long VOCAB(long, long); extern long vocab(long, long);
extern void JUGGLE(long); extern void juggle(long);
extern void MOVE(long, long); extern void move(long, long);
extern long PUT(long, long, long); extern long put(long, long, long);
extern void CARRY(long, long); extern void carry(long, long);
extern void DROP(long, long); extern void drop(long, long);
extern long ATDWRF(long); extern long atdwrf(long);
extern long SETBIT(long); extern long setbit(long);
extern bool TSTBIT(long, int); extern bool tstbit(long, int);
extern long RNDVOC(long, long); extern long rndvoc(long, long);
extern bool MAPLIN(FILE *); extern bool MAPLIN(FILE *);
extern void DATIME(long*, long*); extern void datime(long*, long*);
enum termination {endgame, quitgame, scoregame}; enum termination {endgame, quitgame, scoregame};
@ -145,7 +145,7 @@ extern int restore(FILE *);
* PCT(N) = true N% of the time (N integer from 0 to 100) * PCT(N) = true N% of the time (N integer from 0 to 100)
* TOTING(OBJ) = true if the OBJ is being carried */ * TOTING(OBJ) = true if the OBJ is being carried */
#define DESTROY(N) MOVE(N, LOC_NOWHERE) #define DESTROY(N) move(N, LOC_NOWHERE)
#define MOD(N,M) ((N) % (M)) #define MOD(N,M) ((N) % (M))
#define TOTING(OBJ) (game.place[OBJ] == CARRIED) #define TOTING(OBJ) (game.place[OBJ] == CARRIED)
#define AT(OBJ) (game.place[OBJ] == game.loc || game.fixed[OBJ] == game.loc) #define AT(OBJ) (game.place[OBJ] == game.loc || game.fixed[OBJ] == game.loc)
@ -153,13 +153,13 @@ extern int restore(FILE *);
#define LIQ2(PBOTL) ((1-(PBOTL))*WATER+((PBOTL)/2)*(WATER+OIL)) #define LIQ2(PBOTL) ((1-(PBOTL))*WATER+((PBOTL)/2)*(WATER+OIL))
#define LIQUID() (LIQ2(game.prop[BOTTLE]<0 ? -1-game.prop[BOTTLE] : game.prop[BOTTLE])) #define LIQUID() (LIQ2(game.prop[BOTTLE]<0 ? -1-game.prop[BOTTLE] : game.prop[BOTTLE]))
#define LIQLOC(LOC) (LIQ2((MOD(conditions[LOC]/2*2,8)-5)*MOD(conditions[LOC]/4,2)+1)) #define LIQLOC(LOC) (LIQ2((MOD(conditions[LOC]/2*2,8)-5)*MOD(conditions[LOC]/4,2)+1))
#define CNDBIT(L,N) (TSTBIT(conditions[L],N)) #define CNDBIT(L,N) (tstbit(conditions[L],N))
#define FORCED(LOC) CNDBIT(LOC, COND_FORCED) #define FORCED(LOC) CNDBIT(LOC, COND_FORCED)
#define DARK(DUMMY) ((!TSTBIT(conditions[game.loc],COND_LIT)) && (game.prop[LAMP] == LAMP_DARK || !HERE(LAMP))) #define DARK(DUMMY) ((!tstbit(conditions[game.loc],COND_LIT)) && (game.prop[LAMP] == LAMP_DARK || !HERE(LAMP)))
#define PCT(N) (randrange(100) < (N)) #define PCT(N) (randrange(100) < (N))
#define GSTONE(OBJ) ((OBJ) == EMERALD || (OBJ) == RUBY || (OBJ) == AMBER || (OBJ) == SAPPH) #define GSTONE(OBJ) ((OBJ) == EMERALD || (OBJ) == RUBY || (OBJ) == AMBER || (OBJ) == SAPPH)
#define FOREST(LOC) CNDBIT(LOC, COND_FOREST) #define FOREST(LOC) CNDBIT(LOC, COND_FOREST)
#define VOCWRD(LETTRS,SECT) (VOCAB(MAKEWD(LETTRS),SECT)) #define VOCWRD(LETTRS,SECT) (vocab(MAKEWD(LETTRS),SECT))
#define SPECIAL(LOC) ((LOC) > SPECIALBASE) #define SPECIAL(LOC) ((LOC) > SPECIALBASE)
#define OUTSID(LOC) (CNDBIT(LOC, COND_ABOVE) || FOREST(LOC)) #define OUTSID(LOC) (CNDBIT(LOC, COND_ABOVE) || FOREST(LOC))

8
init.c
View file

@ -40,8 +40,8 @@ void initialise(void)
* described last, we'll drop them first. */ * described last, we'll drop them first. */
for (int i = NOBJECTS; i >= 1; i--) { for (int i = NOBJECTS; i >= 1; i--) {
if (object_descriptions[i].fixd > 0) { if (object_descriptions[i].fixd > 0) {
DROP(i + NOBJECTS, object_descriptions[i].fixd); drop(i + NOBJECTS, object_descriptions[i].fixd);
DROP(i, object_descriptions[i].plac); drop(i, object_descriptions[i].plac);
} }
} }
@ -49,7 +49,7 @@ void initialise(void)
int k = NOBJECTS + 1 - i; int k = NOBJECTS + 1 - i;
game.fixed[k] = object_descriptions[k].fixd; game.fixed[k] = object_descriptions[k].fixd;
if (object_descriptions[k].plac != 0 && object_descriptions[k].fixd <= 0) if (object_descriptions[k].plac != 0 && object_descriptions[k].fixd <= 0)
DROP(k, object_descriptions[k].plac); drop(k, object_descriptions[k].plac);
} }
/* Treasure props are initially -1, and are set to 0 the first time /* Treasure props are initially -1, and are set to 0 the first time
@ -191,7 +191,7 @@ void initialise(void)
game.bonus = 0; game.bonus = 0;
game.clock1 = WARNTIME; game.clock1 = WARNTIME;
game.clock2 = FLASHTIME; game.clock2 = FLASHTIME;
game.conds = SETBIT(11); game.conds = setbit(11);
game.saved = 0; game.saved = 0;
game.closng = false; game.closng = false;
game.panic = false; game.panic = false;

86
main.c
View file

@ -156,12 +156,12 @@ int main(int argc, char *argv[])
initialise(); initialise();
/* Start-up, dwarf stuff */ /* Start-up, dwarf stuff */
game.zzword = RNDVOC(3, 0); game.zzword = rndvoc(3, 0);
game.newloc = LOC_START; game.newloc = LOC_START;
game.loc = LOC_START; game.loc = LOC_START;
game.limit = GAMELIMIT; game.limit = GAMELIMIT;
if (!rfp) { if (!rfp) {
game.novice = YES(arbitrary_messages[WELCOME_YOU], arbitrary_messages[CAVE_NEARBY], arbitrary_messages[NO_MESSAGE]); game.novice = yes(arbitrary_messages[WELCOME_YOU], arbitrary_messages[CAVE_NEARBY], arbitrary_messages[NO_MESSAGE]);
if (game.novice) if (game.novice)
game.limit = NOVICELIMIT; game.limit = NOVICELIMIT;
} else { } else {
@ -190,7 +190,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.
--game.turns; --game.turns;
// here we reconfigure any global game state that uses random numbers // here we reconfigure any global game state that uses random numbers
game.zzword = RNDVOC(3, 0); game.zzword = rndvoc(3, 0);
return true; return true;
} }
return false; return false;
@ -256,7 +256,7 @@ static void checkhints(void)
break; break;
return; return;
case 8: /* ogre */ case 8: /* ogre */
i = ATDWRF(game.loc); i = atdwrf(game.loc);
if (i < 0) { if (i < 0) {
game.hintlc[hint] = 0; game.hintlc[hint] = 0;
return; return;
@ -276,10 +276,10 @@ static void checkhints(void)
/* Fall through to hint display */ /* Fall through to hint display */
game.hintlc[hint] = 0; game.hintlc[hint] = 0;
if (!YES(hints[hint].question, arbitrary_messages[NO_MESSAGE], arbitrary_messages[OK_MAN])) if (!yes(hints[hint].question, arbitrary_messages[NO_MESSAGE], arbitrary_messages[OK_MAN]))
return; return;
rspeak(HINT_COST, hints[hint].penalty, hints[hint].penalty); rspeak(HINT_COST, hints[hint].penalty, hints[hint].penalty);
game.hinted[hint] = YES(arbitrary_messages[WANT_HINT], hints[hint].hint, arbitrary_messages[OK_MAN]); game.hinted[hint] = yes(arbitrary_messages[WANT_HINT], hints[hint].hint, arbitrary_messages[OK_MAN]);
if (game.hinted[hint] && game.limit > WARNTIME) if (game.hinted[hint] && game.limit > WARNTIME)
game.limit += WARNTIME * hints[hint].penalty; game.limit += WARNTIME * hints[hint].penalty;
} }
@ -325,8 +325,8 @@ static bool spotted_by_pirate(int i)
/* Do things in this order (chest move before robbery) so chest is listed /* Do things in this order (chest move before robbery) so chest is listed
* last at the maze location. */ * last at the maze location. */
if (movechest) { if (movechest) {
MOVE(CHEST, game.chloc); move(CHEST, game.chloc);
MOVE(MESSAG, game.chloc2); move(MESSAG, game.chloc2);
game.dloc[PIRATE] = game.chloc; game.dloc[PIRATE] = game.chloc;
game.odloc[PIRATE] = game.chloc; game.odloc[PIRATE] = game.chloc;
game.dseen[PIRATE] = false; game.dseen[PIRATE] = false;
@ -343,9 +343,9 @@ static bool spotted_by_pirate(int i)
continue; continue;
if (!(treasure == PYRAMID && (game.loc == object_descriptions[PYRAMID].plac || game.loc == object_descriptions[EMERALD].plac))) { if (!(treasure == PYRAMID && (game.loc == object_descriptions[PYRAMID].plac || game.loc == object_descriptions[EMERALD].plac))) {
if (AT(treasure) && game.fixed[treasure] == 0) if (AT(treasure) && game.fixed[treasure] == 0)
CARRY(treasure, game.loc); carry(treasure, game.loc);
if (TOTING(treasure)) if (TOTING(treasure))
DROP(treasure, game.chloc); drop(treasure, game.chloc);
} }
} }
} }
@ -400,7 +400,7 @@ static bool dwarfmove(void)
game.odloc[i] = game.dloc[i]; game.odloc[i] = game.dloc[i];
} }
rspeak(DWARF_RAN); rspeak(DWARF_RAN);
DROP(AXE, game.loc); drop(AXE, game.loc);
return true; return true;
} }
@ -513,7 +513,7 @@ static void croak(void)
* death and exit. */ * death and exit. */
rspeak(DEATH_CLOSING); rspeak(DEATH_CLOSING);
terminate(endgame); terminate(endgame);
} else if (game.numdie == NDEATHS || !YES(query, yes_response, arbitrary_messages[OK_MAN])) } else if (game.numdie == NDEATHS || !yes(query, yes_response, arbitrary_messages[OK_MAN]))
terminate(endgame); terminate(endgame);
else { else {
game.place[WATER] = game.place[OIL] = LOC_NOWHERE; game.place[WATER] = game.place[OIL] = LOC_NOWHERE;
@ -523,7 +523,7 @@ static void croak(void)
int i = NOBJECTS + 1 - j; int i = NOBJECTS + 1 - j;
if (TOTING(i)) { if (TOTING(i)) {
/* Always leave lamp where it's accessible aboveground */ /* Always leave lamp where it's accessible aboveground */
DROP(i, (i == LAMP) ? LOC_START : game.oldlc2); drop(i, (i == LAMP) ? LOC_START : game.oldlc2);
} }
} }
game.loc = LOC_BUILDING; game.loc = LOC_BUILDING;
@ -686,7 +686,7 @@ static bool playermove(token_t verb, int motion)
* special travel if toting it), so he's forced to use the * special travel if toting it), so he's forced to use the
* plover-passage to get it out. Having dropped it, go back and * plover-passage to get it out. Having dropped it, go back and
* pretend he wasn't carrying it after all. */ * pretend he wasn't carrying it after all. */
DROP(EMERALD, game.loc); drop(EMERALD, game.loc);
do { do {
if (TRAVEL[kk] < 0) if (TRAVEL[kk] < 0)
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION);
@ -707,11 +707,11 @@ static bool playermove(token_t verb, int motion)
if (game.prop[TROLL] == 1) { if (game.prop[TROLL] == 1) {
pspeak(TROLL,look, 1); pspeak(TROLL,look, 1);
game.prop[TROLL] = 0; game.prop[TROLL] = 0;
MOVE(TROLL2, 0); move(TROLL2, 0);
MOVE(TROLL2 + NOBJECTS, 0); move(TROLL2 + NOBJECTS, 0);
MOVE(TROLL, object_descriptions[TROLL].plac); move(TROLL, object_descriptions[TROLL].plac);
MOVE(TROLL + NOBJECTS, object_descriptions[TROLL].fixd); move(TROLL + NOBJECTS, object_descriptions[TROLL].fixd);
JUGGLE(CHASM); juggle(CHASM);
game.newloc = game.loc; game.newloc = game.loc;
return true; return true;
} else { } else {
@ -721,7 +721,7 @@ static bool playermove(token_t verb, int motion)
rspeak(BRIDGE_COLLAPSE); rspeak(BRIDGE_COLLAPSE);
game.prop[CHASM] = 1; game.prop[CHASM] = 1;
game.prop[TROLL] = 2; game.prop[TROLL] = 2;
DROP(BEAR, game.newloc); drop(BEAR, game.newloc);
game.fixed[BEAR] = -1; game.fixed[BEAR] = -1;
game.prop[BEAR] = 3; game.prop[BEAR] = 3;
game.oldlc2 = game.newloc; game.oldlc2 = game.newloc;
@ -786,11 +786,11 @@ static bool closecheck(void)
game.dseen[i] = false; game.dseen[i] = false;
game.dloc[i] = 0; game.dloc[i] = 0;
} }
MOVE(TROLL, 0); move(TROLL, 0);
MOVE(TROLL + NOBJECTS, 0); move(TROLL + NOBJECTS, 0);
MOVE(TROLL2, object_descriptions[TROLL].plac); move(TROLL2, object_descriptions[TROLL].plac);
MOVE(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd); move(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd);
JUGGLE(CHASM); juggle(CHASM);
if (game.prop[BEAR] != 3)DESTROY(BEAR); if (game.prop[BEAR] != 3)DESTROY(BEAR);
game.prop[CHAIN] = 0; game.prop[CHAIN] = 0;
game.fixed[CHAIN] = 0; game.fixed[CHAIN] = 0;
@ -818,27 +818,27 @@ static bool closecheck(void)
* objects he might be carrying (lest he have some which * objects he might be carrying (lest he have some which
* could cause trouble, such as the keys). We describe the * could cause trouble, such as the keys). We describe the
* flash of light and trundle back. */ * flash of light and trundle back. */
game.prop[BOTTLE] = PUT(BOTTLE, LOC_NE, EMPTY_BOTTLE); game.prop[BOTTLE] = put(BOTTLE, LOC_NE, EMPTY_BOTTLE);
game.prop[PLANT] = PUT(PLANT, LOC_NE, 0); game.prop[PLANT] = put(PLANT, LOC_NE, 0);
game.prop[OYSTER] = PUT(OYSTER, LOC_NE, 0); game.prop[OYSTER] = put(OYSTER, LOC_NE, 0);
game.prop[LAMP] = PUT(LAMP, LOC_NE, 0); game.prop[LAMP] = put(LAMP, LOC_NE, 0);
game.prop[ROD] = PUT(ROD, LOC_NE, 0); game.prop[ROD] = put(ROD, LOC_NE, 0);
game.prop[DWARF] = PUT(DWARF, LOC_NE, 0); game.prop[DWARF] = put(DWARF, LOC_NE, 0);
game.loc = LOC_NE; game.loc = LOC_NE;
game.oldloc = LOC_NE; game.oldloc = LOC_NE;
game.newloc = LOC_NE; game.newloc = LOC_NE;
/* Leave the grate with normal (non-negative) property. /* Leave the grate with normal (non-negative) property.
* Reuse sign. */ * Reuse sign. */
PUT(GRATE, LOC_SW, 0); put(GRATE, LOC_SW, 0);
PUT(SIGN, LOC_SW, 0); put(SIGN, LOC_SW, 0);
game.prop[SIGN] = ENDGAME_SIGN; game.prop[SIGN] = ENDGAME_SIGN;
game.prop[SNAKE] = PUT(SNAKE, LOC_SW, 1); game.prop[SNAKE] = put(SNAKE, LOC_SW, 1);
game.prop[BIRD] = PUT(BIRD, LOC_SW, 1); game.prop[BIRD] = put(BIRD, LOC_SW, 1);
game.prop[CAGE] = PUT(CAGE, LOC_SW, 0); game.prop[CAGE] = put(CAGE, LOC_SW, 0);
game.prop[ROD2] = PUT(ROD2, LOC_SW, 0); game.prop[ROD2] = put(ROD2, LOC_SW, 0);
game.prop[PILLOW] = PUT(PILLOW, LOC_SW, 0); game.prop[PILLOW] = put(PILLOW, LOC_SW, 0);
game.prop[MIRROR] = PUT(MIRROR, LOC_NE, 0); game.prop[MIRROR] = put(MIRROR, LOC_NE, 0);
game.fixed[MIRROR] = LOC_SW; game.fixed[MIRROR] = LOC_SW;
for (int i = 1; i <= NOBJECTS; i++) { for (int i = 1; i <= NOBJECTS; i++) {
@ -870,7 +870,7 @@ static void lampcheck(void)
rspeak(REPLACE_BATTERIES); rspeak(REPLACE_BATTERIES);
game.prop[BATTERY] = DEAD_BATTERIES; game.prop[BATTERY] = DEAD_BATTERIES;
if (TOTING(BATTERY)) if (TOTING(BATTERY))
DROP(BATTERY, game.loc); drop(BATTERY, game.loc);
game.limit += BATTERYLIFE; game.limit += BATTERYLIFE;
game.lmwarn = false; game.lmwarn = false;
} else if (game.limit == 0) { } else if (game.limit == 0) {
@ -1062,8 +1062,8 @@ L2607:
} else } else
lampcheck(); lampcheck();
V1 = VOCAB(command.wd1, -1); V1 = vocab(command.wd1, -1);
V2 = VOCAB(command.wd2, -1); V2 = vocab(command.wd2, -1);
if (V1 == ENTER && (V2 == STREAM || V2 == 1000 + WATER)) { if (V1 == ENTER && (V2 == STREAM || V2 == 1000 + WATER)) {
if (LIQLOC(game.loc) == WATER) { if (LIQLOC(game.loc) == WATER) {
rspeak(FEET_WET); rspeak(FEET_WET);
@ -1097,7 +1097,7 @@ L2620:
rspeak(GO_UNNEEDED); rspeak(GO_UNNEEDED);
} }
Lookup: Lookup:
defn = VOCAB(command.wd1, -1); defn = vocab(command.wd1, -1);
if (defn == -1) { if (defn == -1) {
/* Gee, I don't understand. */ /* Gee, I don't understand. */
if (fallback_handler(rawbuf)) if (fallback_handler(rawbuf))

34
misc.c
View file

@ -287,7 +287,7 @@ char* get_input()
return (input); return (input);
} }
bool YES(const char* question, const char* yes_response, const char* no_response) bool yes(const char* question, const char* yes_response, const char* no_response)
/* Print message X, wait for yes/no answer. If yes, print Y and return true; /* Print message X, wait for yes/no answer. If yes, print Y and return true;
* if no, print Z and return false. */ * if no, print Z and return false. */
{ {
@ -405,7 +405,7 @@ token_t MAKEWD(long letters)
/* Data structure routines */ /* Data structure routines */
long VOCAB(long id, long init) long vocab(long id, long init)
/* Look up ID in the vocabulary (ATAB) and return its "definition" (KTAB), or /* Look up ID in the vocabulary (ATAB) and return its "definition" (KTAB), or
* -1 if not found. If INIT is positive, this is an initialisation call setting * -1 if not found. If INIT is positive, this is an initialisation call setting
* up a keyword variable, and not finding it constitutes a bug. It also means * up a keyword variable, and not finding it constitutes a bug. It also means
@ -434,7 +434,7 @@ long VOCAB(long id, long init)
BUG(RAN_OFF_END_OF_VOCABULARY_TABLE); BUG(RAN_OFF_END_OF_VOCABULARY_TABLE);
} }
void JUGGLE(long object) void juggle(long object)
/* Juggle an object by picking it up and putting it down again, the purpose /* Juggle an object by picking it up and putting it down again, the purpose
* being to get the object to the front of the chain of things at its loc. */ * being to get the object to the front of the chain of things at its loc. */
{ {
@ -442,11 +442,11 @@ void JUGGLE(long object)
i = game.place[object]; i = game.place[object];
j = game.fixed[object]; j = game.fixed[object];
MOVE(object, i); move(object, i);
MOVE(object + NOBJECTS, j); move(object + NOBJECTS, j);
} }
void MOVE(long object, long where) void move(long object, long where)
/* Place any object anywhere by picking it up and dropping it. May /* Place any object anywhere by picking it up and dropping it. May
* already be toting, in which case the carry is a no-op. Mustn't * already be toting, in which case the carry is a no-op. Mustn't
* pick up objects which are not at any loc, since carry wants to * pick up objects which are not at any loc, since carry wants to
@ -459,19 +459,19 @@ void MOVE(long object, long where)
else else
from = game.place[object]; from = game.place[object];
if (from != LOC_NOWHERE && from != CARRIED && !SPECIAL(from)) if (from != LOC_NOWHERE && from != CARRIED && !SPECIAL(from))
CARRY(object, from); carry(object, from);
DROP(object, where); drop(object, where);
} }
long PUT(long object, long where, long pval) long put(long object, long where, long pval)
/* PUT is the same as MOVE, except it returns a value used to set up the /* PUT is the same as MOVE, except it returns a value used to set up the
* negated game.prop values for the repository objects. */ * negated game.prop values for the repository objects. */
{ {
MOVE(object, where); move(object, where);
return (-1) - pval;; return (-1) - pval;;
} }
void CARRY(long object, long where) void carry(long object, long where)
/* Start toting an object, removing it from the list of things at its former /* Start toting an object, removing it from the list of things at its former
* location. Incr holdng unless it was already being toted. If object>NOBJECTS * location. Incr holdng unless it was already being toted. If object>NOBJECTS
* (moving "fixed" second loc), don't change game.place or game.holdng. */ * (moving "fixed" second loc), don't change game.place or game.holdng. */
@ -495,7 +495,7 @@ void CARRY(long object, long where)
game.link[temp] = game.link[object]; game.link[temp] = game.link[object];
} }
void DROP(long object, long where) void drop(long object, long where)
/* Place an object at a given loc, prefixing it onto the game.atloc list. Decr /* Place an object at a given loc, prefixing it onto the game.atloc list. Decr
* game.holdng if the object was being toted. */ * game.holdng if the object was being toted. */
{ {
@ -512,7 +512,7 @@ void DROP(long object, long where)
game.atloc[where] = object; game.atloc[where] = object;
} }
long ATDWRF(long where) long atdwrf(long where)
/* Return the index of first dwarf at the given location, zero if no dwarf is /* Return the index of first dwarf at the given location, zero if no dwarf is
* there (or if dwarves not active yet), -1 if all dwarves are dead. Ignore * there (or if dwarves not active yet), -1 if all dwarves are dead. Ignore
* the pirate (6th dwarf). */ * the pirate (6th dwarf). */
@ -535,13 +535,13 @@ long ATDWRF(long where)
/* Utility routines (SETBIT, TSTBIT, set_seed, get_next_lcg_value, /* Utility routines (SETBIT, TSTBIT, set_seed, get_next_lcg_value,
* randrange, RNDVOC) */ * randrange, RNDVOC) */
long SETBIT(long bit) long setbit(long bit)
/* Returns 2**bit for use in constructing bit-masks. */ /* Returns 2**bit for use in constructing bit-masks. */
{ {
return (1 << bit); return (1 << bit);
} }
bool TSTBIT(long mask, int bit) bool tstbit(long mask, int bit)
/* Returns true if the specified bit is set in the mask. */ /* Returns true if the specified bit is set in the mask. */
{ {
return (mask & (1 << bit)) != 0; return (mask & (1 << bit)) != 0;
@ -567,7 +567,7 @@ long randrange(long range)
return range * get_next_lcg_value() / game.lcg_m; return range * get_next_lcg_value() / game.lcg_m;
} }
long RNDVOC(long second, long force) long rndvoc(long second, long force)
/* Searches the vocabulary ATAB for a word whose second character is /* Searches the vocabulary ATAB for a word whose second character is
* char, and changes that word such that each of the other four * char, and changes that word such that each of the other four
* characters is a random letter. If force is non-zero, it is used * characters is a random letter. If force is non-zero, it is used
@ -691,7 +691,7 @@ bool MAPLIN(FILE *fp)
} }
} }
void DATIME(long* d, long* t) void datime(long* d, long* t)
{ {
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);

View file

@ -42,7 +42,7 @@ int suspend(void)
FILE *fp = NULL; FILE *fp = NULL;
rspeak(SUSPEND_WARNING); rspeak(SUSPEND_WARNING);
if (!YES(arbitrary_messages[THIS_ACCEPTABLE], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN])) return GO_CLEAROBJ; if (!yes(arbitrary_messages[THIS_ACCEPTABLE], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN])) return GO_CLEAROBJ;
game.saved = game.saved + 5; game.saved = game.saved + 5;
while (fp == NULL) { while (fp == NULL) {
@ -55,7 +55,7 @@ int suspend(void)
linenoiseFree(name); linenoiseFree(name);
} }
DATIME(&i, &k); datime(&i, &k);
k = i + 650 * k; k = i + 650 * k;
save.savetime = k; save.savetime = k;
save.mode = -1; save.mode = -1;
@ -79,7 +79,7 @@ int resume(void)
if (game.loc != 1 || game.abbrev[1] != 1) { if (game.loc != 1 || game.abbrev[1] != 1) {
rspeak(RESUME_ABANDON); rspeak(RESUME_ABANDON);
if (!YES(arbitrary_messages[THIS_ACCEPTABLE], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN])) return GO_CLEAROBJ; if (!yes(arbitrary_messages[THIS_ACCEPTABLE], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN])) return GO_CLEAROBJ;
} }
while (fp == NULL) { while (fp == NULL) {
@ -110,7 +110,7 @@ int restore(FILE* fp)
rspeak(VERSION_SKEW, save.version / 10, MOD(save.version, 10), VRSION / 10, MOD(VRSION, 10)); rspeak(VERSION_SKEW, save.version / 10, MOD(save.version, 10), VRSION / 10, MOD(VRSION, 10));
} else { } else {
memcpy(&game, &save.game, sizeof(struct game_t)); memcpy(&game, &save.game, sizeof(struct game_t));
game.zzword = RNDVOC(3, game.zzword); game.zzword = rndvoc(3, game.zzword);
} }
return GO_TOP; return GO_TOP;
} }