#define DIM(a) (sizeof(a)/sizeof(a[0]))
-FILE *logfp = NULL, *rfp = NULL;
-bool oldstyle = false;
-bool prompt = true;
-
// LCOV_EXCL_START
// exclude from coverage analysis because it requires interactivity to test
static void sig_handler(int signo)
{
if (signo == SIGINT) {
- if (logfp != NULL)
- fflush(logfp);
+ if (settings.logfp != NULL)
+ fflush(settings.logfp);
}
exit(EXIT_FAILURE);
}
#ifndef ADVENT_NOSAVE
const char* opts = "l:or:";
const char* usage = "Usage: %s [-l logfilename] [-o] [-r restorefilename]\n";
+ FILE *rfp = NULL;
#else
const char* opts = "l:o";
const char* usage = "Usage: %s [-l logfilename] [-o]\n";
while ((ch = getopt(argc, argv, opts)) != EOF) {
switch (ch) {
case 'l':
- logfp = fopen(optarg, "w");
- if (logfp == NULL)
+ settings.logfp = fopen(optarg, "w");
+ if (settings.logfp == NULL)
fprintf(stderr,
"advent: can't open logfile %s for write\n",
optarg);
signal(SIGINT, sig_handler);
break;
case 'o':
- oldstyle = true;
- prompt = false;
+ settings.oldstyle = true;
+ settings.prompt = false;
break;
#ifndef ADVENT_NOSAVE
case 'r':
}
#endif
- if (logfp)
- fprintf(logfp, "seed %ld\n", seedval);
+ if (settings.logfp)
+ fprintf(settings.logfp, "seed %ld\n", seedval);
/* interpret commands until EOF or interrupt */
for (;;) {
game.hintlc[hint] = 0;
return;
case 4: /* dark */
- if (game.prop[EMERALD] != -1 && game.prop[PYRAMID] == -1)
+ if (game.prop[EMERALD] != NOT_YET_FOUND && game.prop[PYRAMID] == NOT_YET_FOUND)
break;
game.hintlc[hint] = 0;
return;
game.newloc = travel[kk].dest;
/* Have we avoided a dwarf encounter? */
if (SPECIAL(game.newloc))
- continue;
+ continue;
else if (!INDEEP(game.newloc))
- continue;
- else if (game.newloc == game.odloc[i])
- continue;
+ continue;
+ else if (game.newloc == game.odloc[i])
+ continue;
else if (j > 1 && game.newloc == tk[j - 1])
- continue;
- else if (j >= DIM(tk) - 1)
- continue;
- else if (game.newloc == game.dloc[i])
- continue;
- else if (FORCED(game.newloc))
- continue;
- else if (i == PIRATE && CNDBIT(game.newloc, COND_NOARRR))
- continue;
- else if (travel[kk].nodwarves)
- continue;
- tk[j++] = game.newloc;
+ continue;
+ else if (j >= DIM(tk) - 1)
+ continue;
+ else if (game.newloc == game.dloc[i])
+ continue;
+ else if (FORCED(game.newloc))
+ continue;
+ else if (i == PIRATE && CNDBIT(game.newloc, COND_NOARRR))
+ continue;
+ else if (travel[kk].nodwarves)
+ continue;
+ tk[j++] = game.newloc;
} while
- (!travel[kk++].stop);
+ (!travel[kk++].stop);
tk[j] = game.odloc[i];
if (j >= 2)
--j;
/* Are two travel entries equal for purposes of skip after failed condition? */
{
return (travel[a].cond == travel[b].cond)
- && (travel[a].dest == travel[b].dest);
+ && (travel[a].dest == travel[b].dest);
}
/* Given the current location in "game.loc", and a motion verb number in
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE
++te_tmp;
} while
- (traveleq(travel_entry, te_tmp));
+ (traveleq(travel_entry, te_tmp));
travel_entry = te_tmp;
}
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE
++te_tmp;
} while
- (traveleq(travel_entry, te_tmp));
+ (traveleq(travel_entry, te_tmp));
travel_entry = te_tmp;
continue; /* goto L12 */
case 3: