diff --git a/actions.c b/actions.c index 062c372..5de7cb0 100644 --- a/actions.c +++ b/actions.c @@ -21,7 +21,8 @@ static int attack(struct command_t *command) vocab_t obj = command->obj; long spk = actions[verb].message; - if (obj == NO_OBJECT || obj == INTRANSITIVE) { + if (obj == NO_OBJECT || + obj == INTRANSITIVE) { int changes = 0; if (atdwrf(game.loc) > 0) { obj = DWARF; @@ -84,7 +85,8 @@ static int attack(struct command_t *command) if (obj == NO_OBJECT) spk = NO_TARGET; - if (obj == CLAM || obj == OYSTER) + if (obj == CLAM || + obj == OYSTER) spk = SHELL_IMPERVIOUS; if (obj == SNAKE) spk = SNAKE_WARNING; @@ -110,7 +112,9 @@ static int attack(struct command_t *command) game.dseen[i] = false; } } - spk = (dwarves > 1) ? OGRE_PANIC1 : OGRE_PANIC2; + spk = (dwarves > 1) ? + OGRE_PANIC1 : + OGRE_PANIC2; } else if (obj == BEAR) { switch (game.prop[BEAR]) { case UNTAMED_BEAR: @@ -150,7 +154,8 @@ static int attack(struct command_t *command) move(RUG, k); drop(BLOOD, k); for (obj = 1; obj <= NOBJECTS; obj++) { - if (game.place[obj] == objects[DRAGON].plac || game.place[obj] == objects[DRAGON].fixd) + if (game.place[obj] == objects[DRAGON].plac || + game.place[obj] == objects[DRAGON].fixd) move(obj, k); } game.loc = k; @@ -182,7 +187,8 @@ static int bigwords(token_t foo) return GO_CLEAROBJ; } game.foobar = 0; - if (game.place[EGGS] == objects[EGGS].plac || (TOTING(EGGS) && game.loc == objects[EGGS].plac)) { + if (game.place[EGGS] == objects[EGGS].plac || + (TOTING(EGGS) && game.loc == objects[EGGS].plac)) { rspeak(spk); return GO_CLEAROBJ; } else { @@ -211,11 +217,15 @@ static int bivalve(token_t verb, token_t obj) return GO_CLEAROBJ; } if (!TOTING(TRIDENT)) { - rspeak(is_oyster ? OYSTER_OPENER : CLAM_OPENER); + rspeak(is_oyster ? + OYSTER_OPENER : + CLAM_OPENER); return GO_CLEAROBJ; } if (TOTING(obj)) { - rspeak( is_oyster ? DROP_OYSTER : DROP_CLAM); + rspeak( is_oyster ? + DROP_OYSTER : + DROP_CLAM); return GO_CLEAROBJ; } @@ -224,14 +234,17 @@ static int bivalve(token_t verb, token_t obj) drop(OYSTER, game.loc); drop(PEARL, LOC_CULDESAC); } - rspeak(is_oyster ? OYSTER_OPENS : PEARL_FALLS); + rspeak(is_oyster ? + OYSTER_OPENS : + PEARL_FALLS); return GO_CLEAROBJ; } static void blast(void) /* Blast. No effect unless you've got dynamite, which is a neat trick! */ { - if (game.prop[ROD2] < 0 || !game.closed) + if (game.prop[ROD2] < 0 || + !game.closed) rspeak(REQUIRES_DYNAMITE); else { game.bonus = VICTORY_MESSAGE; @@ -321,8 +334,10 @@ static int vcarry(token_t verb, token_t obj) rspeak(spk); return GO_CLEAROBJ; } - if (obj == WATER || obj == OIL) { - if (!HERE(BOTTLE) || LIQUID() != obj) { + if (obj == WATER || + obj == OIL) { + if (!HERE(BOTTLE) || + LIQUID() != obj) { if (TOTING(BOTTLE) && game.prop[BOTTLE] == EMPTY_BOTTLE) return (fill(verb, BOTTLE)); else { @@ -351,13 +366,18 @@ static int vcarry(token_t verb, token_t obj) spk = CANNOT_CARRY; if (TOTING(ROD)) spk = BIRD_EVADES; - if (spk == CANNOT_CARRY || spk == BIRD_EVADES) { + if (spk == CANNOT_CARRY || + spk == BIRD_EVADES) { rspeak(spk); return GO_CLEAROBJ; } game.prop[BIRD] = BIRD_CAGED; } - if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1)) + /* FIXME: Arithmetic on state numbers */ + 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); if (obj == BOTTLE && LIQUID() != 0) @@ -434,8 +454,8 @@ static int discard(token_t verb, token_t obj, bool just_do_it) rspeak(GEM_FITS); game.prop[obj] = 1; game.prop[CAVITY] = CAVITY_FULL; - if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) || (obj == RUBY && - game.prop[RUG] == RUG_HOVER))) { + if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) || + (obj == RUBY && game.prop[RUG] == RUG_HOVER))) { spk = RUG_RISES; if (TOTING(RUG)) spk = RUG_WIGGLES; @@ -468,7 +488,8 @@ static int discard(token_t verb, token_t obj, bool just_do_it) move(TROLL2 + NOBJECTS, objects[TROLL].fixd); juggle(CHASM); game.prop[TROLL] = TROLL_GONE; - } else if (obj != VASE || game.loc == objects[PILLOW].plac) { + } else if (obj != VASE || + game.loc == objects[PILLOW].plac) { rspeak(OK_MAN); } else { game.prop[VASE] = VASE_BROKEN; @@ -499,7 +520,8 @@ static int drink(token_t verb, token_t obj) /* Drink. If no object, assume water and look for it here. If water is in * the bottle, drink that, else must be at a water loc, so drink stream. */ { - if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || !HERE(BOTTLE))) + if (obj == NO_OBJECT && LIQLOC(game.loc) != WATER && (LIQUID() != WATER || + !HERE(BOTTLE))) return GO_UNKNOWN; if (obj != BLOOD) { if (obj != NO_OBJECT && obj != WATER) { @@ -535,9 +557,15 @@ static int eat(token_t verb, token_t obj) rspeak(THANKS_DELICIOUS); return GO_CLEAROBJ; } - if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj == - DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj == - OGRE) { + if (obj == BIRD || + obj == SNAKE || + obj == CLAM || + obj == OYSTER || + obj == DWARF || + obj == DRAGON || + obj == TROLL || + obj == BEAR || + obj == OGRE) { rspeak(LOST_APPETITE); return GO_CLEAROBJ; } @@ -568,8 +596,12 @@ static int extinguish(token_t verb, int obj) } else if (obj == LAMP) { state_change(LAMP, LAMP_DARK); - rspeak(DARK(game.loc) ? PITCH_DARK : NO_MESSAGE); - } else if (obj == DRAGON || obj == VOLCANO) { + rspeak(DARK(game.loc) ? + PITCH_DARK : + NO_MESSAGE); + + } else if (obj == DRAGON || + obj == VOLCANO) { rspeak(BEYOND_POWER); } else { @@ -586,7 +618,9 @@ static int feed(token_t verb, token_t obj) if (obj == BIRD) { rspeak(BIRD_PINING); return GO_CLEAROBJ; - } else if (obj == SNAKE || obj == DRAGON || obj == TROLL) { + } else if (obj == SNAKE || + obj == DRAGON || + obj == TROLL) { spk = NOTHING_EDIBLE; if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS) spk = RIDICULOUS_ATTEMPT; @@ -633,7 +667,8 @@ int fill(token_t verb, token_t obj) spk = ARENT_CARRYING; if (LIQLOC(game.loc) == 0) spk = FILL_INVALID; - if (LIQLOC(game.loc) == 0 || !TOTING(VASE)) { + if (LIQLOC(game.loc) == 0 || + !TOTING(VASE)) { rspeak(spk); return GO_CLEAROBJ; } @@ -649,7 +684,8 @@ int fill(token_t verb, token_t obj) } spk = FILL_INVALID; k = LIQUID(); - if (k == 0 || !HERE(BOTTLE)) { + if (k == 0 || + !HERE(BOTTLE)) { rspeak(spk); return GO_CLEAROBJ; } @@ -743,7 +779,8 @@ static int inven(void) { int spk = NO_CARRY; for (int i = 1; i <= NOBJECTS; i++) { - if (i == BEAR || !TOTING(i)) + if (i == BEAR || + !TOTING(i)) continue; if (spk == NO_CARRY) rspeak(NOW_HOLDING); @@ -771,7 +808,9 @@ static int light(token_t verb, token_t obj) } if (obj == URN) { - state_change(URN, game.prop[URN] == URN_EMPTY ? URN_EMPTY : URN_LIT); + state_change(URN, game.prop[URN] == URN_EMPTY ? + URN_EMPTY : + URN_LIT); return GO_CLEAROBJ; } else { if (obj != LAMP) { @@ -801,7 +840,9 @@ static int listen(void) return GO_CLEAROBJ; } for (int i = 1; i <= NOBJECTS; i++) { - if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0) + if (!HERE(i) || + objects[i].sounds[0] == NULL || + game.prop[i] < 0) continue; int mi = game.prop[i]; if (i == BIRD) @@ -832,7 +873,8 @@ static int lock(token_t verb, token_t obj) obj = GRATE; if (HERE(CHAIN)) obj = CHAIN; - if (obj == NO_OBJECT || obj == INTRANSITIVE) { + if (obj == NO_OBJECT || + obj == INTRANSITIVE) { rspeak(NOTHING_LOCKED); return GO_CLEAROBJ; } @@ -849,7 +891,8 @@ static int lock(token_t verb, token_t obj) spk = NO_LOCK; if (obj == KEYS) spk = CANNOT_UNLOCK; - if (obj == GRATE || obj == CHAIN) { + if (obj == GRATE || + obj == CHAIN) { spk = NO_KEYS; if (HERE(KEYS)) { if (obj == CHAIN) @@ -860,7 +903,9 @@ static int lock(token_t verb, token_t obj) game.clock2 = PANICTIME; game.panic = true; } else { - state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN); + state_change(GRATE, (verb == LOCK) ? + GRATE_CLOSED : + GRATE_OPEN); return GO_CLEAROBJ; } } @@ -873,7 +918,8 @@ static int pour(token_t verb, token_t obj) /* Pour. If no object, or object is bottle, assume contents of bottle. * special tests for pouring water or oil on plant or rusty door. */ { - if (obj == BOTTLE || obj == NO_OBJECT) + if (obj == BOTTLE || + obj == NO_OBJECT) obj = LIQUID(); if (obj == NO_OBJECT) return GO_UNKNOWN; @@ -890,7 +936,8 @@ static int pour(token_t verb, token_t obj) return fill(verb, URN); game.prop[BOTTLE] = EMPTY_BOTTLE; game.place[obj] = LOC_NOWHERE; - if (!(AT(PLANT) || AT(DOOR))) { + if (!(AT(PLANT) || + AT(DOOR))) { rspeak(GROUND_WET); return GO_CLEAROBJ; } @@ -899,12 +946,15 @@ static int pour(token_t verb, token_t obj) rspeak(SHAKING_LEAVES); return GO_CLEAROBJ; } + /* FIXME: Arithmetic on state numbers */ pspeak(PLANT, look, game.prop[PLANT] + 3, true); game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3); game.prop[PLANT2] = game.prop[PLANT]; return GO_MOVE; } else { - state_change(DOOR, (obj == OIL) ? DOOR_UNRUSTED : DOOR_RUSTED); + state_change(DOOR, (obj == OIL) ? + DOOR_UNRUSTED : + DOOR_RUSTED); return GO_CLEAROBJ; } } @@ -926,7 +976,9 @@ static int read(struct command_t command) if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0) command.obj = command.obj * NOBJECTS + i; } - if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc)) + if (command.obj > NOBJECTS || + command.obj == 0 || + DARK(game.loc)) return GO_UNKNOWN; } @@ -934,7 +986,8 @@ static int read(struct command_t command) 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]); - } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) { + } else if (objects[command.obj].texts[0] == NULL || + game.prop[command.obj] < 0) { rspeak(actions[command.verb].message); } else pspeak(command.obj, study, game.prop[command.obj], true); @@ -944,17 +997,19 @@ static int read(struct command_t command) static int reservoir(void) /* Z'ZZZ (word gets recomputed at startup; different each game). */ { + /* FIXME: Arithmetic on state numbers */ if (!AT(RESER) && game.loc != game.fixed[RESER] - 1) { rspeak(NOTHING_HAPPENS); return GO_CLEAROBJ; } else { + /* FIXME: Arithmetic on state numbers */ pspeak(RESER, look, game.prop[RESER] + 1, true); game.prop[RESER] = 1 - game.prop[RESER]; if (AT(RESER)) return GO_CLEAROBJ; else { game.oldlc2 = game.loc; - game.newloc = 0; + game.newloc = LOC_NOWHERE; rspeak(NOT_BRIGHT); return GO_TERMINATE; } @@ -992,7 +1047,11 @@ static int say(struct command_t *command) packed_to_token(command->wd1, word1); int wd = (int) get_vocab_id(word1); /* FIXME: magic numbers */ - if (wd == MOTION_WORD(XYZZY) || wd == MOTION_WORD(PLUGH) || wd == MOTION_WORD(PLOVER) || wd == ACTION_WORD(GIANTWORDS) || wd == ACTION_WORD(PART)) { + if (wd == MOTION_WORD(XYZZY) || + wd == MOTION_WORD(PLUGH) || + wd == MOTION_WORD(PLOVER) || + wd == ACTION_WORD(GIANTWORDS) || + wd == ACTION_WORD(PART)) { /* FIXME: scribbles on the interpreter's command block */ wordclear(&command->wd2); return GO_LOOKUP; @@ -1063,9 +1122,10 @@ static int throw (struct command_t *command) } else { long i = atdwrf(game.loc); game.dseen[i] = false; - game.dloc[i] = 0; - return throw_support((++game.dkill == 1) - ? DWARF_SMOKE : KILLED_DWARF); + game.dloc[i] = LOC_NOWHERE; + return throw_support((++game.dkill == 1) ? + DWARF_SMOKE : + KILLED_DWARF); } } } @@ -1073,7 +1133,8 @@ static int throw (struct command_t *command) static int wake(token_t verb, token_t obj) /* Wake. Only use is to disturb the dwarves. */ { - if (obj != DWARF || !game.closed) { + if (obj != DWARF || + !game.closed) { rspeak(actions[verb].message); return GO_CLEAROBJ; } else { @@ -1087,8 +1148,13 @@ static int wave(token_t verb, token_t obj) { if (obj != ROD || !TOTING(obj) || - (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) { - rspeak(((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2))) ? ARENT_CARRYING : actions[verb].message); + (!HERE(BIRD) && + (game.closng || + !AT(FISSURE)))) { + rspeak(((!TOTING(obj)) && (obj != ROD || + !TOTING(ROD2))) ? + ARENT_CARRYING : + actions[verb].message); return GO_CLEAROBJ; } @@ -1100,15 +1166,22 @@ static int wave(token_t verb, token_t obj) return GO_CLEAROBJ; } else { if (game.closed) { - rspeak((game.prop[BIRD] == BIRD_CAGED) ? CAGE_FLY : FREE_FLY); + rspeak((game.prop[BIRD] == BIRD_CAGED) ? + CAGE_FLY : + FREE_FLY); return GO_DWARFWAKE; } - if (game.closng || !AT(FISSURE)) { - rspeak((game.prop[BIRD] == BIRD_CAGED) ? CAGE_FLY : FREE_FLY); + if (game.closng || + !AT(FISSURE)) { + rspeak((game.prop[BIRD] == BIRD_CAGED) ? + CAGE_FLY : + FREE_FLY); return GO_CLEAROBJ; } if (HERE(BIRD)) - rspeak((game.prop[BIRD] == BIRD_CAGED) ? CAGE_FLY : FREE_FLY); + rspeak((game.prop[BIRD] == BIRD_CAGED) ? + CAGE_FLY : + FREE_FLY); /* FIXME: Arithemetic on property values */ game.prop[FISSURE] = 1 - game.prop[FISSURE]; @@ -1133,14 +1206,22 @@ int action(struct command_t *command) if (HERE(command->obj)) /* FALL THROUGH */; else if (command->obj == GRATE) { - if (game.loc == LOC_START || game.loc == LOC_VALLEY || game.loc == LOC_SLIT) + if (game.loc == LOC_START || + game.loc == LOC_VALLEY || + game.loc == LOC_SLIT) { command->obj = DPRSSN; - if (game.loc == LOC_COBBLE || game.loc == LOC_DEBRIS || game.loc == LOC_AWKWARD || - game.loc == LOC_BIRD || game.loc == LOC_PITTOP) + } + 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) /* 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 */; else if (command->obj == OIL && HERE(URN) && game.prop[URN] != 0) { command->obj = URN; @@ -1155,7 +1236,8 @@ int action(struct command_t *command) } else if (command->obj == ROD && HERE(ROD2)) { command->obj = ROD2; /* FALL THROUGH */; - } else if ((command->verb == FIND || command->verb == INVENTORY) && command->wd2 <= 0) + } else if ((command->verb == FIND || + command->verb == INVENTORY) && command->wd2 <= 0) /* FALL THROUGH */; else { rspeak(NO_SEE, command->wd1, command->wd1x); @@ -1174,7 +1256,8 @@ int action(struct command_t *command) return GO_WORD2; if (command->verb == SAY) command->obj = command->wd2; - if (command->obj == 0 || command->obj == INTRANSITIVE) { + if (command->obj == 0 || + command->obj == INTRANSITIVE) { /* Analyse an intransitive verb (ie, no object given yet). */ switch (command->verb) { case CARRY: diff --git a/init.c b/init.c index 2fffc27..b3f984d 100644 --- a/init.c +++ b/init.c @@ -58,7 +58,8 @@ long initialise(void) } for (int i = 1; i <= NLOCATIONS; i++) { - if (!(locations[i].description.big == 0 || tkey[i] == 0)) { + if (!(locations[i].description.big == 0 || + tkey[i] == 0)) { int k = tkey[i]; if (T_TERMINATE(travel[k])) conditions[i] |= (1 << COND_FORCED); diff --git a/main.c b/main.c index 53da082..d25e43e 100644 --- a/main.c +++ b/main.c @@ -245,7 +245,8 @@ static bool spotted_by_pirate(int i) * that game.place[CHEST] = LOC_NOWHERE might mean that he's thrown * it to the troll, but in that case he's seen the chest * (game.prop=0). */ - if (game.loc == game.chloc || game.prop[CHEST] >= 0) + if (game.loc == game.chloc || + game.prop[CHEST] >= 0) return true; int snarfed = 0; bool movechest = false, robplayer = false; @@ -254,10 +255,12 @@ static bool spotted_by_pirate(int i) continue; /* Pirate won't take pyramid from plover room or dark * room (too easy!). */ - if (treasure == PYRAMID && (game.loc == objects[PYRAMID].plac || game.loc == objects[EMERALD].plac)) { + if (treasure == PYRAMID && (game.loc == objects[PYRAMID].plac || + game.loc == objects[EMERALD].plac)) { continue; } - if (TOTING(treasure) || HERE(treasure)) + if (TOTING(treasure) || + HERE(treasure)) ++snarfed; if (TOTING(treasure)) { movechest = true; @@ -288,7 +291,8 @@ static bool spotted_by_pirate(int i) for (int treasure = 1; treasure <= NOBJECTS; treasure++) { if (!objects[treasure].is_treasure) continue; - if (!(treasure == PYRAMID && (game.loc == objects[PYRAMID].plac || game.loc == objects[EMERALD].plac))) { + if (!(treasure == PYRAMID && (game.loc == objects[PYRAMID].plac || + game.loc == objects[EMERALD].plac))) { if (AT(treasure) && game.fixed[treasure] == 0) carry(treasure, game.loc); if (TOTING(treasure)) @@ -319,7 +323,9 @@ static bool dwarfmove(void) * means dwarves won't follow him into dead end in maze, but * c'est la vie. They'll wait for him outside the dead * end. */ - if (game.loc == 0 || FORCED(game.loc) || CNDBIT(game.newloc, COND_NOARRR)) + if (game.loc == 0 || + FORCED(game.loc) || + CNDBIT(game.newloc, COND_NOARRR)) return true; /* Dwarf activity level ratchets up */ @@ -333,7 +339,9 @@ static bool dwarfmove(void) * the 5 dwarves. If any of the survivors is at loc, * replace him with the alternate. */ if (game.dflag == 1) { - if (!INDEEP(game.loc) || (PCT(95) && (!CNDBIT(game.loc, COND_NOBACK) || PCT(85)))) + if (!INDEEP(game.loc) || + (PCT(95) && (!CNDBIT(game.loc, COND_NOBACK) || + PCT(85)))) return true; game.dflag = 2; for (int i = 1; i <= 2; i++) { @@ -400,7 +408,9 @@ static bool dwarfmove(void) j = 1 + randrange(j); game.odloc[i] = game.dloc[i]; game.dloc[i] = tk[j]; - game.dseen[i] = (game.dseen[i] && INDEEP(game.loc)) || (game.dloc[i] == game.loc || game.odloc[i] == game.loc); + game.dseen[i] = (game.dseen[i] && INDEEP(game.loc)) || + (game.dloc[i] == game.loc || + game.odloc[i] == game.loc); if (!game.dseen[i]) continue; game.dloc[i] = game.loc; @@ -471,7 +481,8 @@ 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; @@ -578,7 +589,8 @@ static bool playermove( int motion) /* Look for a way to fulfil the motion verb passed in - travel_entry indexes * the beginning of the motion entries for here (game.loc). */ for (;;) { - if (T_TERMINATE(travel[travel_entry]) || travel[travel_entry].motion == motion) + if (T_TERMINATE(travel[travel_entry]) || + travel[travel_entry].motion == motion) break; if (travel[travel_entry].stop) { /* Couldn't find an entry matching the motion word passed @@ -586,13 +598,18 @@ static bool playermove( int motion) int spk = CANT_APPLY; if (motion >= EAST && motion <= NW) spk = BAD_DIRECTION; - if (motion == UP || motion == DOWN) + if (motion == UP || + motion == DOWN) spk = BAD_DIRECTION; - if (motion == FORWARD || motion == LEFT || motion == RIGHT) + if (motion == FORWARD || + motion == LEFT || + motion == RIGHT) spk = UNSURE_FACING; - if (motion == OUTSIDE || motion == INSIDE) + if (motion == OUTSIDE || + motion == INSIDE) spk = NO_INOUT_HERE; - if (motion == XYZZY || motion == PLUGH) + if (motion == XYZZY || + motion == PLUGH) spk = NOTHING_HAPPENS; if (motion == CRAWL) spk = WHICH_WAY; @@ -614,12 +631,14 @@ static bool playermove( int motion) if (!SPECIAL(cond)) { /* YAML N and [pct N] conditionals */ if (cond <= 100) { - if (cond == 0 || PCT(cond)) + if (cond == 0 || + PCT(cond)) break; /* else fall through */ } /* YAML [with OBJ] clause */ - if (TOTING(arg) || (cond > 200 && AT(arg))) + if (TOTING(arg) || + (cond > 200 && AT(arg))) break; /* else fall through to check [not OBJ STATE] */ } else if (game.prop[arg] != cond / 100 - 3) @@ -657,7 +676,8 @@ static bool playermove( int motion) * for actual motion, but can be spotted by "go back". */ /* FIXME: Arithmetic on location numbers */ game.newloc = 99 + 100 - game.loc; - if (game.holdng > 1 || (game.holdng == 1 && !TOTING(EMERALD))) { + if (game.holdng > 1 || + (game.holdng == 1 && !TOTING(EMERALD))) { game.newloc = game.loc; rspeak(MUST_DROP); } @@ -964,7 +984,8 @@ static bool do_command() if (game.loc == 0) croak(); const char* msg = locations[game.loc].description.small; - if (MOD(game.abbrev[game.loc], game.abbnum) == 0 || msg == 0) + if (MOD(game.abbrev[game.loc], game.abbnum) == 0 || + msg == 0) msg = locations[game.loc].description.big; if (!FORCED(game.loc) && DARK(game.loc)) { /* The easiest way to get killed is to fall into a pit in @@ -1076,7 +1097,8 @@ L2607: packed_to_token(command.wd2, word2); V1 = get_vocab_id(word1); V2 = get_vocab_id(word2); - if (V1 == ENTER && (V2 == STREAM || V2 == PROMOTE_WORD(WATER))) { + if (V1 == ENTER && (V2 == STREAM || + V2 == PROMOTE_WORD(WATER))) { if (LIQLOC(game.loc) == WATER) { rspeak(FEET_WET); } else { diff --git a/misc.c b/misc.c index 3d306b6..b1c50d1 100644 --- a/misc.c +++ b/misc.c @@ -60,7 +60,8 @@ void packed_to_token(long packed, char token[6]) // Replace trailing whitespace with \0. for (int i = 4; i >= 0; --i) { - if (token[i] == ' ' || token[i] == '\t') + if (token[i] == ' ' || + token[i] == '\t') token[i] = '\0'; else break; @@ -225,7 +226,8 @@ void vspeak(const char* msg, bool blank, va_list ap) } // All-lowercase specifier. - if (msg[i] == 'L' || msg[i] == 'C') { + if (msg[i] == 'L' || + msg[i] == 'C') { packed_to_token(arg, renderp); /* unpack directly to destination */ int len = strlen(renderp); for (int j = 0; j < len; ++j) { @@ -387,10 +389,12 @@ bool silent_yes() free(firstword); - if (yes == 0 || y == 0) { + if (yes == 0 || + y == 0) { outcome = true; break; - } else if (no == 0 || n == 0) { + } else if (no == 0 || + n == 0) { outcome = false; break; } else @@ -434,11 +438,13 @@ bool yes(const char* question, const char* yes_response, const char* no_response free(firstword); - if (yes == 0 || y == 0) { + if (yes == 0 || + y == 0) { speak(yes_response); outcome = true; break; - } else if (no == 0 || n == 0) { + } else if (no == 0 || + n == 0) { speak(no_response); outcome = false; break; @@ -457,7 +463,9 @@ int get_motion_vocab_id(const char* word) { for (int i = 0; i < NMOTIONS; ++i) { for (int j = 0; j < motions[i].words.n; ++j) { - if (strcasecmp(word, motions[i].words.strs[j]) == 0 && (strlen(word) > 1 || strchr(ignore, word[0]) == NULL || !settings.oldstyle)) + if (strcasecmp(word, motions[i].words.strs[j]) == 0 && (strlen(word) > 1 || + strchr(ignore, word[0]) == NULL || + !settings.oldstyle)) return (i); } } @@ -483,7 +491,9 @@ int get_action_vocab_id(const char* word) { for (int i = 0; i < NACTIONS; ++i) { for (int j = 0; j < actions[i].words.n; ++j) { - if (strcasecmp(word, actions[i].words.strs[j]) == 0 && (strlen(word) > 1 || strchr(ignore, word[0]) == NULL || !settings.oldstyle)) + if (strcasecmp(word, actions[i].words.strs[j]) == 0 && (strlen(word) > 1 || + strchr(ignore, word[0]) == NULL || + !settings.oldstyle)) return (i); } } diff --git a/saveresume.c b/saveresume.c index 276667d..a3dbe96 100644 --- a/saveresume.c +++ b/saveresume.c @@ -85,7 +85,8 @@ int resume(void) #endif FILE *fp = NULL; - if (game.loc != 1 || game.abbrev[1] != 1) { + 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;