/*
- * Copyright (c) 1977, 2005 by Will Crowther and Don Woods
- * Copyright (c) 2017 by Eric S. Raymond
- * SPDX-License-Identifier: BSD-2-clause
+ * SPDX-FileCopyrightText: 1977, 2005 by Will Crowther and Don Woods
+ * SPDX-FileCopyrightText: 2017 by Eric S. Raymond
+ * SPDX-License-Identifier: BSD-2-Clause
*/
#include <stdlib.h>
{
if (autosave_fp != NULL) {
rewind(autosave_fp);
- savefile(autosave_fp, /* version (auto): */0);
+ savefile(autosave_fp);
fflush(autosave_fp);
}
}
* logfiles for testing purposes.
*/
/* Normal case - no script arguments */
- if (settings.argc == 0)
- return readline(prompt);
+ if (settings.argc == 0) {
+ char *ln = readline(prompt);
+ if (ln == NULL) {
+ fputs(prompt, stdout);
+ }
+ return ln;
+ }
char *buf = malloc(LINESIZE + 1);
for (;;) {
} else {
char *ln = fgets(buf, LINESIZE, settings.scriptfp);
if (ln != NULL) {
- fputs(PROMPT, stdout);
+ fputs(prompt, stdout);
fputs(ln, stdout);
- return ln;
+ return ln;
}
}
}
{
const char* msg = locations[game.loc].description.small;
- if (MOD(game.abbrev[game.loc], game.abbnum) == 0 ||
- msg == NO_MESSAGE)
+ if (MOD(game.abbrev[game.loc], game.abbnum) == 0 || msg == NO_MESSAGE)
msg = locations[game.loc].description.big;
if (!FORCED(game.loc) && DARK(game.loc)) {
game.prop[RUG] = RUG_DRAGON;
if (obj == CHAIN)
game.prop[CHAIN] = CHAINING_BEAR;
+ if (obj == EGGS)
+ game.seenbigwords = true;
--game.tally;
/* Note: There used to be a test here to see whether the
* player had blown it so badly that he could never ever see
/* The easiest way to get killed is to fall into a pit in
* pitch darkness. */
- if (!FORCED(game.loc) && DARK(game.loc) && game.wzdark && PCT(35)) { // FIXME: magic number
+ if (!FORCED(game.loc) && DARK(game.loc) && game.wzdark && PCT(PIT_KILL_PROB)) {
rspeak(PIT_FALL);
game.oldlc2 = game.loc;
croak();
/* Options. */
#if defined ADVENT_AUTOSAVE
- const char* opts = "l:oa:";
+ const char* opts = "dl:oa:";
const char* usage = "Usage: %s [-l logfilename] [-o] [-a filename] [script...]\n";
FILE *rfp = NULL;
const char* autosave_filename = NULL;
#elif !defined ADVENT_NOSAVE
- const char* opts = "l:or:";
+ const char* opts = "dl:or:";
const char* usage = "Usage: %s [-l logfilename] [-o] [-r restorefilename] [script...]\n";
FILE *rfp = NULL;
#else
- const char* opts = "l:o";
+ const char* opts = "dl:o";
const char* usage = "Usage: %s [-l logfilename] [-o] [script...]\n";
#endif
while ((ch = getopt(argc, argv, opts)) != EOF) {
switch (ch) {
+ case 'd': // LCOV_EXCL_LINE
+ settings.debug +=1; // LCOV_EXCL_LINE
+ break; // LCOV_EXCL_LINE
case 'l':
settings.logfp = fopen(optarg, "w");
if (settings.logfp == NULL)