cppcheck cleanup.

This commit is contained in:
Eric S. Raymond 2022-04-13 20:55:57 -04:00
parent ceba6482a1
commit 4069bf210b
5 changed files with 17 additions and 17 deletions

View file

@ -111,7 +111,7 @@ static phase_codes_t attack(command_t command)
* fixed), move rug there (not fixed), and move him there, * fixed), move rug there (not fixed), and move him there,
* too. Then do a null motion to get new description. */ * too. Then do a null motion to get new description. */
rspeak(BARE_HANDS_QUERY); rspeak(BARE_HANDS_QUERY);
if (!silent_yes()) { if (!silent_yes_or_no()) {
speak(arbitrary_messages[NASTY_DRAGON]); speak(arbitrary_messages[NASTY_DRAGON]);
return GO_MOVE; return GO_MOVE;
} }
@ -1096,7 +1096,7 @@ static phase_codes_t pour(verb_t verb, obj_t obj)
static phase_codes_t quit(void) static phase_codes_t 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_or_no(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
terminate(quitgame); terminate(quitgame);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
@ -1122,8 +1122,8 @@ static phase_codes_t read(command_t command)
if (!TOTING(OYSTER) || !game.closed) { if (!TOTING(OYSTER) || !game.closed) {
rspeak(DONT_UNDERSTAND); rspeak(DONT_UNDERSTAND);
} else if (!game.clshnt) { } else if (!game.clshnt) {
game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]); game.clshnt = yes_or_no(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
} else if (game.clshnt) { } else {
pspeak(OYSTER, hear, true, 1); // Not really a sound, but oh well. pspeak(OYSTER, hear, true, 1); // Not really a sound, but oh well.
} }
} else if (objects[command.obj].texts[0] == NULL || } else if (objects[command.obj].texts[0] == NULL ||
@ -1204,7 +1204,7 @@ static phase_codes_t throw_support(vocab_t spk)
return GO_MOVE; 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 /* Throw. Same as discard unless axe. Then same as attack except
* ignore bird, and if dwarf is present then one might be killed. * ignore bird, and if dwarf is present then one might be killed.
* (Only way to do so!) Axe also special for dragon, bear, and * (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: case RUB:
return rub(command.verb, command.obj); return rub(command.verb, command.obj);
case THROW: case THROW:
return throw (command); return throwit(command);
case QUIT: { case QUIT: {
speak(actions[command.verb].message); speak(actions[command.verb].message);
return GO_CLEAROBJ; return GO_CLEAROBJ;

View file

@ -229,8 +229,8 @@ extern void sspeak(int msg, ...);
extern void pspeak(vocab_t, enum speaktype, bool, int, ...); extern void pspeak(vocab_t, enum speaktype, bool, int, ...);
extern void rspeak(vocab_t, ...); extern void rspeak(vocab_t, ...);
extern void echo_input(FILE*, const char*, const char*); extern void echo_input(FILE*, const char*, const char*);
extern bool silent_yes(void); extern bool silent_yes_or_no(void);
extern bool yes(const char*, const char*, const char*); extern bool yes_or_no(const char*, const char*, const char*);
extern void juggle(obj_t); extern void juggle(obj_t);
extern void move(obj_t, loc_t); extern void move(obj_t, loc_t);
extern loc_t put(obj_t, int, int); extern loc_t put(obj_t, int, int);

10
main.c
View file

@ -107,14 +107,14 @@ int main(int argc, char *argv[])
#ifndef ADVENT_NOSAVE #ifndef ADVENT_NOSAVE
if (!rfp) { 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) if (game.novice)
game.limit = NOVICELIMIT; game.limit = NOVICELIMIT;
} else { } else {
restore(rfp); restore(rfp);
} }
#else #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) if (game.novice)
game.limit = NOVICELIMIT; game.limit = NOVICELIMIT;
#endif #endif
@ -261,10 +261,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_or_no(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_or_no(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;
} }
@ -519,7 +519,7 @@ static void croak(void)
* death and exit. */ * death and exit. */
rspeak(DEATH_CLOSING); rspeak(DEATH_CLOSING);
terminate(endgame); 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) { || game.numdie == NDEATHS) {
/* Player is asked if he wants to try again. If not, or if /* 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 */ * he's already used all of his lives, we end the game */

4
misc.c
View file

@ -246,7 +246,7 @@ static char* get_input(void)
return (input); return (input);
} }
bool silent_yes(void) bool silent_yes_or_no(void)
{ {
bool outcome = false; 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; /* 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. */
{ {

View file

@ -68,7 +68,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])) if (!yes_or_no(arbitrary_messages[THIS_ACCEPTABLE], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
return GO_CLEAROBJ; return GO_CLEAROBJ;
game.saved = game.saved + 5; game.saved = game.saved + 5;
@ -101,7 +101,7 @@ int resume(void)
if (game.loc != 1 || if (game.loc != 1 ||
game.abbrev[1] != 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])) if (!yes_or_no(arbitrary_messages[THIS_ACCEPTABLE], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN]))
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }