From 4069bf210b68d0aaa44ca30eff264d7eb93d8d70 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 13 Apr 2022 20:55:57 -0400 Subject: [PATCH] cppcheck cleanup. --- actions.c | 12 ++++++------ advent.h | 4 ++-- main.c | 10 +++++----- misc.c | 4 ++-- saveresume.c | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/actions.c b/actions.c index fc85e0e..6110eb7 100644 --- a/actions.c +++ b/actions.c @@ -111,7 +111,7 @@ static phase_codes_t attack(command_t command) * fixed), move rug there (not fixed), and move him there, * too. Then do a null motion to get new description. */ rspeak(BARE_HANDS_QUERY); - if (!silent_yes()) { + if (!silent_yes_or_no()) { speak(arbitrary_messages[NASTY_DRAGON]); return GO_MOVE; } @@ -1096,7 +1096,7 @@ static phase_codes_t pour(verb_t verb, obj_t obj) static phase_codes_t 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_or_no(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN])) terminate(quitgame); return GO_CLEAROBJ; } @@ -1122,8 +1122,8 @@ static phase_codes_t read(command_t command) if (!TOTING(OYSTER) || !game.closed) { rspeak(DONT_UNDERSTAND); } else if (!game.clshnt) { - game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]); - } else if (game.clshnt) { + game.clshnt = yes_or_no(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]); + } else { pspeak(OYSTER, hear, true, 1); // Not really a sound, but oh well. } } else if (objects[command.obj].texts[0] == NULL || @@ -1204,7 +1204,7 @@ static phase_codes_t throw_support(vocab_t spk) return GO_MOVE; } -static phase_codes_t throw (command_t command) +static phase_codes_t throwit(command_t command) /* Throw. Same as discard unless axe. Then same as attack except * ignore bird, and if dwarf is present then one might be killed. * (Only way to do so!) Axe also special for dragon, bear, and @@ -1539,7 +1539,7 @@ phase_codes_t action(command_t command) case RUB: return rub(command.verb, command.obj); case THROW: - return throw (command); + return throwit(command); case QUIT: { speak(actions[command.verb].message); return GO_CLEAROBJ; diff --git a/advent.h b/advent.h index 8409749..c740c53 100644 --- a/advent.h +++ b/advent.h @@ -229,8 +229,8 @@ extern void sspeak(int msg, ...); extern void pspeak(vocab_t, enum speaktype, bool, int, ...); extern void rspeak(vocab_t, ...); extern void echo_input(FILE*, const char*, const char*); -extern bool silent_yes(void); -extern bool yes(const char*, const char*, const char*); +extern bool silent_yes_or_no(void); +extern bool yes_or_no(const char*, const char*, const char*); extern void juggle(obj_t); extern void move(obj_t, loc_t); extern loc_t put(obj_t, int, int); diff --git a/main.c b/main.c index ea03b8e..0bc737b 100644 --- a/main.c +++ b/main.c @@ -107,14 +107,14 @@ int main(int argc, char *argv[]) #ifndef ADVENT_NOSAVE if (!rfp) { - game.novice = yes(arbitrary_messages[WELCOME_YOU], arbitrary_messages[CAVE_NEARBY], arbitrary_messages[NO_MESSAGE]); + game.novice = yes_or_no(arbitrary_messages[WELCOME_YOU], arbitrary_messages[CAVE_NEARBY], arbitrary_messages[NO_MESSAGE]); if (game.novice) game.limit = NOVICELIMIT; } else { restore(rfp); } #else - game.novice = yes(arbitrary_messages[WELCOME_YOU], arbitrary_messages[CAVE_NEARBY], arbitrary_messages[NO_MESSAGE]); + game.novice = yes_or_no(arbitrary_messages[WELCOME_YOU], arbitrary_messages[CAVE_NEARBY], arbitrary_messages[NO_MESSAGE]); if (game.novice) game.limit = NOVICELIMIT; #endif @@ -261,10 +261,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_or_no(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_or_no(arbitrary_messages[WANT_HINT], hints[hint].hint, arbitrary_messages[OK_MAN]); if (game.hinted[hint] && game.limit > WARNTIME) game.limit += WARNTIME * hints[hint].penalty; } @@ -519,7 +519,7 @@ static void croak(void) * death and exit. */ rspeak(DEATH_CLOSING); terminate(endgame); - } else if (!yes(query, yes_response, arbitrary_messages[OK_MAN]) + } else if (!yes_or_no(query, yes_response, arbitrary_messages[OK_MAN]) || game.numdie == NDEATHS) { /* Player is asked if he wants to try again. If not, or if * he's already used all of his lives, we end the game */ diff --git a/misc.c b/misc.c index a0f6c36..fac28e3 100644 --- a/misc.c +++ b/misc.c @@ -246,7 +246,7 @@ static char* get_input(void) return (input); } -bool silent_yes(void) +bool silent_yes_or_no(void) { bool outcome = false; @@ -295,7 +295,7 @@ bool silent_yes(void) } -bool yes(const char* question, const char* yes_response, const char* no_response) +bool yes_or_no(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. */ { diff --git a/saveresume.c b/saveresume.c index 2305077..f4d986a 100644 --- a/saveresume.c +++ b/saveresume.c @@ -68,7 +68,7 @@ int suspend(void) FILE *fp = NULL; rspeak(SUSPEND_WARNING); - if (!yes(arbitrary_messages[THIS_ACCEPTABLE], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN])) + if (!yes_or_no(arbitrary_messages[THIS_ACCEPTABLE], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN])) return GO_CLEAROBJ; game.saved = game.saved + 5; @@ -101,7 +101,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])) + if (!yes_or_no(arbitrary_messages[THIS_ACCEPTABLE], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN])) return GO_CLEAROBJ; } -- 2.31.1