From 829c13d1d56e398e5b47186c31b2e2146f26dc6a Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 6 Apr 2023 21:29:39 -0400 Subject: [PATCH] Fix some screwy formatting of conditionals... ...probably by the original FOTRAN-to-C translator. --- actions.c | 52 ++++++++++++++++------------------------------------ init.c | 3 +-- main.c | 25 ++++++++----------------- misc.c | 9 +++------ 4 files changed, 28 insertions(+), 61 deletions(-) diff --git a/actions.c b/actions.c index 8b3891b..d8b1546 100644 --- a/actions.c +++ b/actions.c @@ -243,8 +243,7 @@ static phase_codes_t bigwords(vocab_t id) static void blast(void) /* Blast. No effect unless you've got dynamite, which is a neat trick! */ { - if (game.prop[ROD2] == STATE_NOTFOUND || - !game.closed) + if (game.prop[ROD2] == STATE_NOTFOUND || !game.closed) rspeak(REQUIRES_DYNAMITE); else { if (HERE(ROD2)) { @@ -355,10 +354,8 @@ static phase_codes_t vcarry(verb_t verb, obj_t obj) 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)) { rspeak(NO_CONTAINER); return GO_CLEAROBJ; @@ -394,8 +391,7 @@ static phase_codes_t vcarry(verb_t verb, obj_t obj) } game.prop[BIRD] = BIRD_CAGED; } - if ((obj == BIRD || - obj == CAGE) && + if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED)) { /* expression maps BIRD to CAGE and CAGE to BIRD */ carry(BIRD + CAGE - obj, game.loc); @@ -815,10 +811,8 @@ static phase_codes_t find(verb_t verb, obj_t obj) return GO_CLEAROBJ; } - if (AT(obj) || - (LIQUID() == obj && AT(BOTTLE)) || - obj == LIQLOC(game.loc) || - (obj == DWARF && atdwrf(game.loc) > 0)) { + if (AT(obj) || (LIQUID() == obj && AT(BOTTLE)) || + obj == LIQLOC(game.loc) || (obj == DWARF && atdwrf(game.loc) > 0)) { rspeak(YOU_HAVEIT); return GO_CLEAROBJ; } @@ -876,8 +870,7 @@ static phase_codes_t inven(void) { bool empty = true; for (obj_t i = 1; i <= NOBJECTS; i++) { - if (i == BEAR || - !TOTING(i)) + if (i == BEAR || !TOTING(i)) continue; if (empty) { rspeak(NOW_HOLDING); @@ -942,9 +935,7 @@ static phase_codes_t listen(void) soundlatch = true; } for (obj_t 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]; /* (ESR) Some unpleasant magic on object states here. Ideally @@ -1054,9 +1045,8 @@ static phase_codes_t pour(verb_t verb, obj_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 == INTRANSITIVE) - obj = LIQUID(); + if (obj == BOTTLE || obj == INTRANSITIVE) + obj = LIQUID(); if (obj == NO_OBJECT) return GO_UNKNOWN; if (!TOTING(obj)) { @@ -1072,8 +1062,7 @@ static phase_codes_t pour(verb_t verb, obj_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; } @@ -1112,9 +1101,7 @@ static phase_codes_t read(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 == NO_OBJECT || - DARK(game.loc)) + if (command.obj > NOBJECTS || command.obj == NO_OBJECT || DARK(game.loc)) return GO_UNKNOWN; } @@ -1270,8 +1257,7 @@ static phase_codes_t throwit(command_t command) static phase_codes_t wake(verb_t verb, obj_t obj) /* Wake. Only use is to disturb the dwarves. */ { - if (obj != DWARF || - !game.closed) { + if (obj != DWARF || !game.closed) { speak(actions[verb].message); return GO_CLEAROBJ; } else { @@ -1301,11 +1287,7 @@ static phase_codes_t waste(verb_t verb, turn_t turns) static phase_codes_t wave(verb_t verb, obj_t obj) /* Wave. No effect unless waving rod at fissure or at bird. */ { - if (obj != ROD || - !TOTING(obj) || - (!HERE(BIRD) && - (game.closng || - !AT(FISSURE)))) { + if (obj != ROD || !TOTING(obj) || (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) { speak(((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2))) ? arbitrary_messages[ARENT_CARRYING] : @@ -1326,8 +1308,7 @@ static phase_codes_t wave(verb_t verb, obj_t obj) FREE_FLY); return GO_DWARFWAKE; } - if (game.closng || - !AT(FISSURE)) { + if (game.closng || !AT(FISSURE)) { rspeak((game.prop[BIRD] == BIRD_CAGED) ? CAGE_FLY : FREE_FLY); @@ -1406,8 +1387,7 @@ phase_codes_t action(command_t command) * will do here. We're preventing interpretation as an intransitive * verb when the word is unknown. */ command.obj = command.word[1].raw[0] != '\0' ? KEYS : NO_OBJECT; - if (command.obj == NO_OBJECT || - command.obj == INTRANSITIVE) { + if (command.obj == NO_OBJECT || 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 dbdfb11..202bf65 100644 --- a/init.c +++ b/init.c @@ -57,8 +57,7 @@ int 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 (travel[k].motion == HERE) conditions[i] |= (1 << COND_FORCED); diff --git a/main.c b/main.c index a162463..cdc83ba 100644 --- a/main.c +++ b/main.c @@ -199,8 +199,7 @@ 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[CHEST] == STATE_FOUND). */ - if (game.loc == game.chloc || - game.prop[CHEST] != STATE_NOTFOUND) + if (game.loc == game.chloc || game.prop[CHEST] != STATE_NOTFOUND) return true; int snarfed = 0; bool movechest = false, robplayer = false; @@ -213,8 +212,7 @@ static bool spotted_by_pirate(int i) game.loc == objects[EMERALD].plac)) { continue; } - if (TOTING(treasure) || - HERE(treasure)) + if (TOTING(treasure) || HERE(treasure)) ++snarfed; if (TOTING(treasure)) { movechest = true; @@ -276,9 +274,7 @@ static bool dwarfmove(void) * steal return toll, and dwarves can't meet the bear. Also * 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 == LOC_NOWHERE || - FORCED(game.loc) || - CNDBIT(game.newloc, COND_NOARRR)) + if (game.loc == LOC_NOWHERE || FORCED(game.loc) || CNDBIT(game.newloc, COND_NOARRR)) return true; /* Dwarf activity level ratchets up */ @@ -293,8 +289,7 @@ static bool dwarfmove(void) * replace him with the alternate. */ if (game.dflag == 1) { if (!INDEEP(game.loc) || - (PCT(95) && (!CNDBIT(game.loc, COND_NOBACK) || - PCT(85)))) + (PCT(95) && (!CNDBIT(game.loc, COND_NOBACK) || PCT(85)))) return true; game.dflag = 2; for (int i = 1; i <= 2; i++) { @@ -571,8 +566,7 @@ static void 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 ((travel[travel_entry].motion == HERE) || - travel[travel_entry].motion == motion) + if ((travel[travel_entry].motion == HERE) || travel[travel_entry].motion == motion) break; if (travel[travel_entry].stop) { /* Couldn't find an entry matching the motion word passed @@ -626,14 +620,12 @@ static void playermove(int motion) if (condtype < cond_not) { /* YAML N and [pct N] conditionals */ if (condtype == cond_goto || condtype == cond_pct) { - if (condarg1 == 0 || - PCT(condarg1)) + if (condarg1 == 0 || PCT(condarg1)) break; /* else fall through */ } /* YAML [with OBJ] clause */ - else if (TOTING(condarg1) || - (condtype == cond_with && AT(condarg1))) + else if (TOTING(condarg1) || (condtype == cond_with && AT(condarg1))) break; /* else fall through to check [not OBJ STATE] */ } else if (game.prop[condarg1] != condarg2) @@ -672,8 +664,7 @@ static void playermove(int motion) game.newloc = (game.loc == LOC_PLOVER) ? LOC_ALCOVE : LOC_PLOVER; - 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); } diff --git a/misc.c b/misc.c index 9a8d2e5..9971cb5 100644 --- a/misc.c +++ b/misc.c @@ -335,13 +335,11 @@ bool yes_or_no(const char* question, const char* yes_response, const char* no_re 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; @@ -656,8 +654,7 @@ void drop(obj_t object, loc_t where) --game.holdng; game.place[object] = where; } - if (where == LOC_NOWHERE || - where == CARRIED) + if (where == LOC_NOWHERE || where == CARRIED) return; game.link[object] = game.atloc[where]; game.atloc[where] = object; -- 2.31.1