From 59243cf8bc1939348467810bc63e107728a680c4 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 26 Jun 2017 10:19:33 -0400 Subject: [PATCH] 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. --- actions.c | 94 ++++++++++++++++++++++++++-------------------------- advent.h | 32 +++++++++--------- init.c | 8 ++--- main.c | 86 +++++++++++++++++++++++------------------------ misc.c | 34 +++++++++---------- saveresume.c | 8 ++--- 6 files changed, 131 insertions(+), 131 deletions(-) diff --git a/actions.c b/actions.c index 0e09682..082b9f6 100644 --- a/actions.c +++ b/actions.c @@ -16,7 +16,7 @@ static int attack(FILE *input, struct command_t *command) vocab_t obj = command->obj; int spk = actspk[verb]; if (obj == 0 || obj == INTRANSITIVE) { - if (ATDWRF(game.loc) > 0) + if (atdwrf(game.loc) > 0) obj = DWARF; if (HERE(SNAKE))obj = obj * NOBJECTS + SNAKE; 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 == TROLL)spk = ROCKY_TROLL; if (obj == OGRE)spk = OGRE_DODGE; - if (obj == OGRE && ATDWRF(game.loc) > 0) { + if (obj == OGRE && atdwrf(game.loc) > 0) { rspeak(spk); rspeak(KNIFE_THROWN); DESTROY(OGRE); @@ -87,14 +87,14 @@ static int attack(FILE *input, struct command_t *command) game.prop[DRAGON] = 1; game.prop[RUG] = 0; int k = (object_descriptions[DRAGON].plac + object_descriptions[DRAGON].fixd) / 2; - MOVE(DRAGON + NOBJECTS, -1); - MOVE(RUG + NOBJECTS, 0); - MOVE(DRAGON, k); - MOVE(RUG, k); - DROP(BLOOD, k); + move(DRAGON + NOBJECTS, -1); + move(RUG + NOBJECTS, 0); + move(DRAGON, k); + move(RUG, k); + drop(BLOOD, k); for (obj = 1; obj <= NOBJECTS; obj++) { if (game.place[obj] == object_descriptions[DRAGON].plac || game.place[obj] == object_descriptions[DRAGON].fixd) - MOVE(obj, k); + move(obj, k); } game.loc = k; 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 * 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; if (game.foobar != 1 - k) { if (game.foobar != 0 && game.loc == LOC_GIANTROOM)spk = START_OVER; @@ -133,7 +133,7 @@ static int bigwords(token_t foo) k = 2; if (HERE(EGGS))k = 1; 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); return GO_CLEAROBJ; } @@ -151,8 +151,8 @@ static int bivalve(token_t verb, token_t obj) if (verb == LOCK)spk = HUH_MAN; if (spk == PEARL_FALLS) { DESTROY(CLAM); - DROP(OYSTER, game.loc); - DROP(PEARL, LOC_CULDESAC); + drop(OYSTER, game.loc); + drop(PEARL, LOC_CULDESAC); } rspeak(spk); return GO_CLEAROBJ; @@ -180,7 +180,7 @@ static int vbreak(token_t verb, token_t obj) int spk = actspk[verb]; if (obj == MIRROR)spk = TOO_FAR; 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.fixed[VASE] = -1; spk = BREAK_VASE; @@ -203,7 +203,7 @@ static int brief(void) 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 * take one without the other). Liquids also special, since they depend on * 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. */ if (game.atloc[game.loc] == 0 || game.link[game.atloc[game.loc]] != 0 || - ATDWRF(game.loc) > 0) + atdwrf(game.loc) > 0) return GO_UNKNOWN; obj = game.atloc[game.loc]; } @@ -274,8 +274,8 @@ static int carry(token_t verb, token_t obj) game.prop[BIRD] = BIRD_CAGED; } if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1)) - CARRY(BIRD + CAGE - obj, game.loc); - CARRY(obj, game.loc); + carry(BIRD + CAGE - obj, game.loc); + carry(obj, game.loc); if (obj == BOTTLE && LIQUID() != 0) game.place[LIQUID()] = CARRIED; if (GSTONE(obj) && game.prop[obj] != 0) { @@ -311,7 +311,7 @@ static int chain(token_t verb) return GO_CLEAROBJ; } game.prop[CHAIN] = 2; - if (TOTING(CHAIN))DROP(CHAIN, game.loc); + if (TOTING(CHAIN))drop(CHAIN, game.loc); game.fixed[CHAIN] = -1; } 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]; game.prop[RUG] = k; if (k == 2) k = object_descriptions[SAPPH].plac; - MOVE(RUG + NOBJECTS, k); + move(RUG + NOBJECTS, k); } } } else if (obj == COINS && HERE(VEND)) { DESTROY(COINS); - DROP(BATTERY, game.loc); + drop(BATTERY, game.loc); pspeak(BATTERY, look, FRESH_BATTERIES); return GO_CLEAROBJ; } 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; } else if (obj == BEAR && AT(TROLL)) { rspeak(TROLL_SCAMPERS); - MOVE(TROLL, 0); - MOVE(TROLL + NOBJECTS, 0); - MOVE(TROLL2, object_descriptions[TROLL].plac); - MOVE(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd); - JUGGLE(CHASM); + move(TROLL, 0); + move(TROLL + NOBJECTS, 0); + move(TROLL2, object_descriptions[TROLL].plac); + move(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd); + juggle(CHASM); game.prop[TROLL] = 2; } else if (obj != VASE || game.loc == object_descriptions[PILLOW].plac) { 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) game.place[k] = LOC_NOWHERE; if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED) - DROP(BIRD, game.loc); - DROP(obj, game.loc); + drop(BIRD, game.loc); + drop(obj, game.loc); if (obj != BIRD) return GO_CLEAROBJ; game.prop[BIRD] = BIRD_UNCAGED; if (FOREST(game.loc)) @@ -573,7 +573,7 @@ static int find(token_t verb, token_t obj) if (AT(obj) || (LIQUID() == obj && AT(BOTTLE)) || obj == LIQLOC(game.loc) || - (obj == DWARF && ATDWRF(game.loc) > 0)) + (obj == DWARF && atdwrf(game.loc) > 0)) spk = YOU_HAVEIT; if (game.closed)spk = NEEDED_NEARBY; if (TOTING(obj))spk = ALREADY_CARRYING; @@ -793,7 +793,7 @@ static int pour(token_t verb, token_t obj) static int quit(void) /* 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); return GO_CLEAROBJ; } @@ -814,7 +814,7 @@ static int read(struct command_t command) if (DARK(game.loc)) { rspeak(NO_SEE, command.wd1, command.wd1x); } 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) { rspeak(actspk[command.verb]); } else @@ -850,10 +850,10 @@ static int rub(token_t verb, token_t obj) spk = PECULIAR_NOTHING; if (obj == URN && game.prop[URN] == 2) { DESTROY(URN); - DROP(AMBER, game.loc); + drop(AMBER, game.loc); game.prop[AMBER] = 1; --game.tally; - DROP(CAVITY, game.loc); + drop(CAVITY, game.loc); spk = URN_GENIES; } rspeak(spk); @@ -869,7 +869,7 @@ static int say(struct command_t *command) b = command->wd2x; command->wd1 = command->wd2; } - int wd = VOCAB(command->wd1, -1); + int wd = vocab(command->wd1, -1); /* FIXME: Magic numbers */ if (wd == 62 || wd == 65 || wd == 71 || wd == 2025 || wd == 2034) { /* 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) { rspeak(spk); - DROP(AXE, game.loc); + drop(AXE, game.loc); 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)) { spk = TROLL_SATISFIED; /* Snarf a treasure for the troll. */ - DROP(command->obj, 0); - MOVE(TROLL, 0); - MOVE(TROLL + NOBJECTS, 0); - DROP(TROLL2, object_descriptions[TROLL].plac); - DROP(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd); - JUGGLE(CHASM); + drop(command->obj, 0); + move(TROLL, 0); + move(TROLL + NOBJECTS, 0); + drop(TROLL2, object_descriptions[TROLL].plac); + drop(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd); + juggle(CHASM); rspeak(spk); return GO_CLEAROBJ; } @@ -919,7 +919,7 @@ static int throw (FILE *cmdin, struct command_t *command) if (command->obj != AXE) return (discard(command->verb, command->obj, false)); else { - int i = ATDWRF(game.loc); + int i = atdwrf(game.loc); if (i <= 0) { if (AT(DRAGON) && game.prop[DRAGON] == 0) return throw_support(DRAGON_SCALES); @@ -929,10 +929,10 @@ static int throw (FILE *cmdin, struct command_t *command) return throw_support(OGRE_DODGE); else if (HERE(BEAR) && game.prop[BEAR] == 0) { /* This'll teach him to throw the axe at the bear! */ - DROP(AXE, game.loc); + drop(AXE, game.loc); game.fixed[AXE] = -1; game.prop[AXE] = 1; - JUGGLE(BEAR); + juggle(BEAR); rspeak(AXE_LOST); return GO_CLEAROBJ; } @@ -978,7 +978,7 @@ static int wave(token_t verb, token_t obj) if (HERE(BIRD)) spk = FREE_FLY + MOD(game.prop[BIRD], 2); 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.tally; 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 || game.loc == LOC_BIRD || game.loc == LOC_PITTOP) command->obj = ENTRNC; - } else if (command->obj == DWARF && ATDWRF(game.loc) > 0) + } else if (command->obj == DWARF && atdwrf(game.loc) > 0) /* FALL THROUGH */; else if ((LIQUID() == command->obj && HERE(BOTTLE)) || command->obj == LIQLOC(game.loc)) /* FALL THROUGH */; @@ -1063,7 +1063,7 @@ int action(FILE *input, struct command_t *command) /* Analyse an intransitive verb (ie, no object given yet). */ switch (command->verb - 1) { case 0: /* CARRY */ - return carry(command->verb, INTRANSITIVE); + return vcarry(command->verb, INTRANSITIVE); case 1: /* DROP */ return GO_UNKNOWN; case 2: /* SAY */ @@ -1145,7 +1145,7 @@ int action(FILE *input, struct command_t *command) /* Analyse a transitive verb. */ switch (command->verb - 1) { case 0: /* CARRY */ - return carry(command->verb, command->obj); + return vcarry(command->verb, command->obj); case 1: /* DROP */ return discard(command->verb, command->obj, false); case 2: /* SAY */ diff --git a/advent.h b/advent.h index d2b082c..d597872 100644 --- a/advent.h +++ b/advent.h @@ -104,21 +104,21 @@ extern void rspeak(vocab_t, ...); extern bool GETIN(FILE *, token_t*, token_t*, token_t*, token_t*); extern void echo_input(FILE*, char*, char*); 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 token_t MAKEWD(long); -extern long VOCAB(long, long); -extern void JUGGLE(long); -extern void MOVE(long, long); -extern long PUT(long, long, long); -extern void CARRY(long, long); -extern void DROP(long, long); -extern long ATDWRF(long); -extern long SETBIT(long); -extern bool TSTBIT(long, int); -extern long RNDVOC(long, long); +extern long vocab(long, long); +extern void juggle(long); +extern void move(long, long); +extern long put(long, long, long); +extern void carry(long, long); +extern void drop(long, long); +extern long atdwrf(long); +extern long setbit(long); +extern bool tstbit(long, int); +extern long rndvoc(long, long); extern bool MAPLIN(FILE *); -extern void DATIME(long*, long*); +extern void datime(long*, long*); 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) * 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 TOTING(OBJ) (game.place[OBJ] == CARRIED) #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 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 CNDBIT(L,N) (TSTBIT(conditions[L],N)) +#define CNDBIT(L,N) (tstbit(conditions[L],N)) #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 GSTONE(OBJ) ((OBJ) == EMERALD || (OBJ) == RUBY || (OBJ) == AMBER || (OBJ) == SAPPH) #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 OUTSID(LOC) (CNDBIT(LOC, COND_ABOVE) || FOREST(LOC)) diff --git a/init.c b/init.c index 194abe3..6582a74 100644 --- a/init.c +++ b/init.c @@ -40,8 +40,8 @@ void initialise(void) * described last, we'll drop them first. */ for (int i = NOBJECTS; i >= 1; i--) { if (object_descriptions[i].fixd > 0) { - DROP(i + NOBJECTS, object_descriptions[i].fixd); - DROP(i, object_descriptions[i].plac); + drop(i + NOBJECTS, object_descriptions[i].fixd); + drop(i, object_descriptions[i].plac); } } @@ -49,7 +49,7 @@ void initialise(void) int k = NOBJECTS + 1 - i; game.fixed[k] = object_descriptions[k].fixd; 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 @@ -191,7 +191,7 @@ void initialise(void) game.bonus = 0; game.clock1 = WARNTIME; game.clock2 = FLASHTIME; - game.conds = SETBIT(11); + game.conds = setbit(11); game.saved = 0; game.closng = false; game.panic = false; diff --git a/main.c b/main.c index a975a94..00a138f 100644 --- a/main.c +++ b/main.c @@ -156,12 +156,12 @@ int main(int argc, char *argv[]) initialise(); /* Start-up, dwarf stuff */ - game.zzword = RNDVOC(3, 0); + game.zzword = rndvoc(3, 0); game.newloc = LOC_START; game.loc = LOC_START; game.limit = GAMELIMIT; 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) game.limit = NOVICELIMIT; } else { @@ -190,7 +190,7 @@ static bool fallback_handler(char *buf) // autogenerated, so don't charge user time for it. --game.turns; // here we reconfigure any global game state that uses random numbers - game.zzword = RNDVOC(3, 0); + game.zzword = rndvoc(3, 0); return true; } return false; @@ -256,7 +256,7 @@ static void checkhints(void) break; return; case 8: /* ogre */ - i = ATDWRF(game.loc); + i = atdwrf(game.loc); if (i < 0) { game.hintlc[hint] = 0; return; @@ -276,10 +276,10 @@ static void checkhints(void) /* Fall through to hint display */ 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; 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) 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 * last at the maze location. */ if (movechest) { - MOVE(CHEST, game.chloc); - MOVE(MESSAG, game.chloc2); + move(CHEST, game.chloc); + move(MESSAG, game.chloc2); game.dloc[PIRATE] = game.chloc; game.odloc[PIRATE] = game.chloc; game.dseen[PIRATE] = false; @@ -343,9 +343,9 @@ static bool spotted_by_pirate(int i) continue; if (!(treasure == PYRAMID && (game.loc == object_descriptions[PYRAMID].plac || game.loc == object_descriptions[EMERALD].plac))) { if (AT(treasure) && game.fixed[treasure] == 0) - CARRY(treasure, game.loc); + carry(treasure, game.loc); 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]; } rspeak(DWARF_RAN); - DROP(AXE, game.loc); + drop(AXE, game.loc); return true; } @@ -513,7 +513,7 @@ static void croak(void) * death and exit. */ rspeak(DEATH_CLOSING); 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); else { game.place[WATER] = game.place[OIL] = LOC_NOWHERE; @@ -523,7 +523,7 @@ static void croak(void) int i = NOBJECTS + 1 - j; if (TOTING(i)) { /* 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; @@ -686,7 +686,7 @@ static bool playermove(token_t verb, int motion) * special travel if toting it), so he's forced to use the * plover-passage to get it out. Having dropped it, go back and * pretend he wasn't carrying it after all. */ - DROP(EMERALD, game.loc); + drop(EMERALD, game.loc); do { if (TRAVEL[kk] < 0) BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); @@ -707,11 +707,11 @@ static bool playermove(token_t verb, int motion) if (game.prop[TROLL] == 1) { pspeak(TROLL,look, 1); game.prop[TROLL] = 0; - MOVE(TROLL2, 0); - MOVE(TROLL2 + NOBJECTS, 0); - MOVE(TROLL, object_descriptions[TROLL].plac); - MOVE(TROLL + NOBJECTS, object_descriptions[TROLL].fixd); - JUGGLE(CHASM); + move(TROLL2, 0); + move(TROLL2 + NOBJECTS, 0); + move(TROLL, object_descriptions[TROLL].plac); + move(TROLL + NOBJECTS, object_descriptions[TROLL].fixd); + juggle(CHASM); game.newloc = game.loc; return true; } else { @@ -721,7 +721,7 @@ static bool playermove(token_t verb, int motion) rspeak(BRIDGE_COLLAPSE); game.prop[CHASM] = 1; game.prop[TROLL] = 2; - DROP(BEAR, game.newloc); + drop(BEAR, game.newloc); game.fixed[BEAR] = -1; game.prop[BEAR] = 3; game.oldlc2 = game.newloc; @@ -786,11 +786,11 @@ static bool closecheck(void) game.dseen[i] = false; game.dloc[i] = 0; } - MOVE(TROLL, 0); - MOVE(TROLL + NOBJECTS, 0); - MOVE(TROLL2, object_descriptions[TROLL].plac); - MOVE(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd); - JUGGLE(CHASM); + move(TROLL, 0); + move(TROLL + NOBJECTS, 0); + move(TROLL2, object_descriptions[TROLL].plac); + move(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd); + juggle(CHASM); if (game.prop[BEAR] != 3)DESTROY(BEAR); game.prop[CHAIN] = 0; game.fixed[CHAIN] = 0; @@ -818,27 +818,27 @@ static bool closecheck(void) * objects he might be carrying (lest he have some which * could cause trouble, such as the keys). We describe the * flash of light and trundle back. */ - game.prop[BOTTLE] = PUT(BOTTLE, LOC_NE, EMPTY_BOTTLE); - game.prop[PLANT] = PUT(PLANT, LOC_NE, 0); - game.prop[OYSTER] = PUT(OYSTER, LOC_NE, 0); - game.prop[LAMP] = PUT(LAMP, LOC_NE, 0); - game.prop[ROD] = PUT(ROD, LOC_NE, 0); - game.prop[DWARF] = PUT(DWARF, LOC_NE, 0); + game.prop[BOTTLE] = put(BOTTLE, LOC_NE, EMPTY_BOTTLE); + game.prop[PLANT] = put(PLANT, LOC_NE, 0); + game.prop[OYSTER] = put(OYSTER, LOC_NE, 0); + game.prop[LAMP] = put(LAMP, LOC_NE, 0); + game.prop[ROD] = put(ROD, LOC_NE, 0); + game.prop[DWARF] = put(DWARF, LOC_NE, 0); game.loc = LOC_NE; game.oldloc = LOC_NE; game.newloc = LOC_NE; /* Leave the grate with normal (non-negative) property. * Reuse sign. */ - PUT(GRATE, LOC_SW, 0); - PUT(SIGN, LOC_SW, 0); + put(GRATE, LOC_SW, 0); + put(SIGN, LOC_SW, 0); game.prop[SIGN] = ENDGAME_SIGN; - game.prop[SNAKE] = PUT(SNAKE, LOC_SW, 1); - game.prop[BIRD] = PUT(BIRD, LOC_SW, 1); - game.prop[CAGE] = PUT(CAGE, LOC_SW, 0); - game.prop[ROD2] = PUT(ROD2, LOC_SW, 0); - game.prop[PILLOW] = PUT(PILLOW, LOC_SW, 0); + game.prop[SNAKE] = put(SNAKE, LOC_SW, 1); + game.prop[BIRD] = put(BIRD, LOC_SW, 1); + game.prop[CAGE] = put(CAGE, LOC_SW, 0); + game.prop[ROD2] = put(ROD2, 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; for (int i = 1; i <= NOBJECTS; i++) { @@ -870,7 +870,7 @@ static void lampcheck(void) rspeak(REPLACE_BATTERIES); game.prop[BATTERY] = DEAD_BATTERIES; if (TOTING(BATTERY)) - DROP(BATTERY, game.loc); + drop(BATTERY, game.loc); game.limit += BATTERYLIFE; game.lmwarn = false; } else if (game.limit == 0) { @@ -1062,8 +1062,8 @@ L2607: } else lampcheck(); - V1 = VOCAB(command.wd1, -1); - V2 = VOCAB(command.wd2, -1); + V1 = vocab(command.wd1, -1); + V2 = vocab(command.wd2, -1); if (V1 == ENTER && (V2 == STREAM || V2 == 1000 + WATER)) { if (LIQLOC(game.loc) == WATER) { rspeak(FEET_WET); @@ -1097,7 +1097,7 @@ L2620: rspeak(GO_UNNEEDED); } Lookup: - defn = VOCAB(command.wd1, -1); + defn = vocab(command.wd1, -1); if (defn == -1) { /* Gee, I don't understand. */ if (fallback_handler(rawbuf)) diff --git a/misc.c b/misc.c index d4c9955..9068342 100644 --- a/misc.c +++ b/misc.c @@ -287,7 +287,7 @@ char* get_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; * if no, print Z and return false. */ { @@ -405,7 +405,7 @@ token_t MAKEWD(long letters) /* 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 * -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 @@ -434,7 +434,7 @@ long VOCAB(long id, long init) 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 * 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]; j = game.fixed[object]; - MOVE(object, i); - MOVE(object + NOBJECTS, j); + move(object, i); + 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 * 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 @@ -459,19 +459,19 @@ void MOVE(long object, long where) else from = game.place[object]; if (from != LOC_NOWHERE && from != CARRIED && !SPECIAL(from)) - CARRY(object, from); - DROP(object, where); + carry(object, from); + 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 * negated game.prop values for the repository objects. */ { - MOVE(object, where); + move(object, where); 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 * location. Incr holdng unless it was already being toted. If object>NOBJECTS * (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]; } -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 * game.holdng if the object was being toted. */ { @@ -512,7 +512,7 @@ void DROP(long object, long where) 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 * there (or if dwarves not active yet), -1 if all dwarves are dead. Ignore * the pirate (6th dwarf). */ @@ -535,13 +535,13 @@ long ATDWRF(long where) /* Utility routines (SETBIT, TSTBIT, set_seed, get_next_lcg_value, * randrange, RNDVOC) */ -long SETBIT(long bit) +long setbit(long bit) /* Returns 2**bit for use in constructing bit-masks. */ { 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. */ { return (mask & (1 << bit)) != 0; @@ -567,7 +567,7 @@ long randrange(long range) 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 * 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 @@ -691,7 +691,7 @@ bool MAPLIN(FILE *fp) } } -void DATIME(long* d, long* t) +void datime(long* d, long* t) { struct timeval tv; gettimeofday(&tv, NULL); diff --git a/saveresume.c b/saveresume.c index cf32746..3386158 100644 --- a/saveresume.c +++ b/saveresume.c @@ -42,7 +42,7 @@ int suspend(void) FILE *fp = NULL; 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; while (fp == NULL) { @@ -55,7 +55,7 @@ int suspend(void) linenoiseFree(name); } - DATIME(&i, &k); + datime(&i, &k); k = i + 650 * k; save.savetime = k; save.mode = -1; @@ -79,7 +79,7 @@ int resume(void) if (game.loc != 1 || game.abbrev[1] != 1) { 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) { @@ -110,7 +110,7 @@ int restore(FILE* fp) rspeak(VERSION_SKEW, save.version / 10, MOD(save.version, 10), VRSION / 10, MOD(VRSION, 10)); } else { memcpy(&game, &save.game, sizeof(struct game_t)); - game.zzword = RNDVOC(3, game.zzword); + game.zzword = rndvoc(3, game.zzword); } return GO_TOP; } -- 2.31.1