}
static int brief(void)
-/* Brief. Intransitive only. Suppress long descriptions after first time. */
+/* Brief. Intransitive only. Suppress full descriptions after first time. */
{
game.abbnum = 10000;
game.detail = 3;
switch (game.prop[BEAR]) {
// LCOV_EXCL_START
case BEAR_DEAD:
- /* Can't be reached as long as the only way for the bear to die
- * is from a bridge collapse. Leave in in case this changes, but
+ /* Can't be reached until the bear can die in some way other
+ * than a bridge collapse. Leave in in case this changes, but
* exclude from coverage testing. */
game.fixed[BEAR] = IS_FIXED;
break;
extern struct settings_t settings;
extern bool get_command_input(struct command_t *);
-extern void wordclear(token_t *);
extern void speak(const char*, ...);
extern void sspeak(int msg, ...);
extern void pspeak(vocab_t, enum speaktype, int, bool, ...);
extern loc_t put(obj_t, long, long);
extern void carry(obj_t, loc_t);
extern void drop(obj_t, loc_t);
-extern long atdwrf(loc_t);
-extern long setbit(long);
+extern int atdwrf(loc_t);
+extern long setbit(int);
extern bool tstbit(long, int);
-extern void make_zzword(char*);
extern void set_seed(long);
-extern unsigned long get_next_lcg_value(void);
extern long randrange(long);
extern long score(enum termination);
extern void terminate(enum termination) __attribute__((noreturn));
extern int restore(FILE *);
extern long initialise(void);
extern int action(struct command_t *command);
-extern void state_change(obj_t, long);
+extern void state_change(obj_t, int);
void bug(enum bugtype, const char *) __attribute__((__noreturn__));
/* fallback handler for commands not handled by FORTRANish parser */
{
long sv;
+ turn_t turnlimit;
char buf[DIM(command.raw1) + DIM(command.raw2) + 1];
sprintf(buf, "%s %s", command.raw1, command.raw2);
// autogenerated, so don't charge user time for it.
--game.turns;
return true;
- } else if (sscanf(buf, "waste %ld", &sv) == 1) {
- game.limit -= sv;
+ } else if (sscanf(buf, "waste %ld", &turnlimit) == 1) {
+ game.limit -= turnlimit;
printf("Game limit is now %ld\n", game.limit);
return true;
}
/* We arrive here on conditional failure.
* Skip to next non-matching destination */
- long te_tmp = travel_entry;
+ int te_tmp = travel_entry;
do {
if (travel[te_tmp].stop)
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE
}
} else {
i++;
- // Integer specifier. In order to accommodate the fact
- // that PARMS can have both legitimate integers *and*
- // packed tokens, stringify everything. Future work may
- // eliminate the need for this.
+ // Integer specifier.
if (msg[i] == 'd') {
long arg = va_arg(ap, long);
int ret = snprintf(renderp, size, "%ld", arg);
void pspeak(vocab_t msg, enum speaktype mode, int skip, bool blank, ...)
/* Find the skip+1st message from msg and print it. Modes are:
* feel = for inventory, what you can touch
- * look = the long description for the state the object is in
+ * look = the full description for the state the object is in
* listen = the sound for the state the object is in
* study = text on the object. */
{
/* Bound prefix on the %s would be needed to prevent buffer
* overflow. but we shortstop this more simply by making each
- * raw-input buffer as long as the enrire inout buffer. */
+ * raw-input buffer as long as the entire input buffer. */
sscanf(raw, "%s%s", cmd->raw1, cmd->raw2);
/* (ESR) In oldstyle mode, simulate the uppercasing and truncating
cmd->raw2[i] = toupper(cmd->raw2[i]);
}
- /* populate command with parsed vocab metadata */
+ /* populate command with parsed vocabulary metadata */
get_vocab_metadata(cmd->raw1, &(cmd->id1), &(cmd->type1));
get_vocab_metadata(cmd->raw2, &(cmd->id2), &(cmd->type2));
}
game.atloc[where] = object;
}
-long atdwrf(loc_t where)
+int atdwrf(loc_t where)
/* Return the index of first dwarf at the given location, zero if no dwarf is
* there (or if dwarves not active yet), -1 if all dwarves are dead. Ignore
* the pirate (6th dwarf). */
{
- long at;
+ int at;
at = 0;
if (game.dflag < 2)
- return (at);
+ return at;
at = -1;
for (long i = 1; i <= NDWARVES - 1; i++) {
if (game.dloc[i] == where)
if (game.dloc[i] != 0)
at = 0;
}
- return (at);
+ return at;
}
/* Utility routines (setbit, tstbit, set_seed, get_next_lcg_value,
* randrange) */
-long setbit(long bit)
+long setbit(int bit)
/* Returns 2**bit for use in constructing bit-masks. */
{
return (1L << bit);
game.lcg_x = (unsigned long) seedval % game.lcg_m;
// once seed is set, we need to generate the Z`ZZZ word
- make_zzword(game.zzword);
+ for (int i = 0; i < 5; ++i) {
+ game.zzword[i] = 'A' + randrange(26);
+ }
+ game.zzword[1] = '\''; // force second char to apostrophe
+ game.zzword[5] = '\0';
}
unsigned long get_next_lcg_value(void)
return range * get_next_lcg_value() / game.lcg_m;
}
-void make_zzword(char zzword[TOKLEN + 1])
-{
- for (int i = 0; i < 5; ++i) {
- zzword[i] = 'A' + randrange(26);
- }
- zzword[1] = '\''; // force second char to apostrophe
- zzword[5] = '\0';
-}
-
// LCOV_EXCL_START
void bug(enum bugtype num, const char *error_string)
{
/* end */
-void state_change(obj_t obj, long state)
+void state_change(obj_t obj, int state)
/* Object must have a change-message list for this to be useful; only some do */
{
game.prop[obj] = state;
if (points + game.saved + 1 >= mxscor && game.saved != 0)
rspeak(WITHOUT_SUSPENDS);
rspeak(TOTAL_SCORE, points, mxscor, game.turns, game.turns);
- for (long i = 1; i <= (long)NCLASSES; i++) {
+ for (int i = 1; i <= (long)NCLASSES; i++) {
if (classes[i].threshold >= points) {
speak(classes[i].message);
i = classes[i].threshold + 1 - points;