if (HERE(ROD2))
game.bonus = SPLATTER_MESSAGE;
RSPEAK(game.bonus);
- score(endgame);
+ terminate(endgame);
}
}
/* Quit. Intransitive only. Verify intent and exit if that's what he wants. */
{
if (YES(input, REALLY_QUIT, OK_MAN, OK_MAN))
- score(quitgame);
+ terminate(quitgame);
return GO_CLEAROBJ;
}
return throw_support((++game.dkill == 1) ? DWARF_SMOKE : KILLED_DWARF);
}
-static int vscore(void)
-/* Score. Call scoring routine but tell it to return. */
-{
- score(scoregame);
- return GO_CLEAROBJ;
-}
-
static int wake(token_t verb, token_t obj)
/* Wake. Only use is to disturb the dwarves. */
{
blast();
return GO_CLEAROBJ;
case 23: /* SCOR */
- return vscore();
+ score(scoregame);
+ return GO_CLEAROBJ;
case 24: /* FOO */
return bigwords(WD1);
case 25: /* BRIEF */
extern void set_seed(long);
extern unsigned long get_next_lcg_value(void);
extern long randrange(long);
-extern void score(enum termination);
+extern long score(enum termination);
+extern void terminate(enum termination) __attribute__((noreturn));
extern int suspend(FILE *);
extern int resume(FILE *);
extern int restore(FILE *);
break;
}
/* show score and exit */
- score(quitgame);
+ terminate(quitgame);
}
static bool fallback_handler(char *buf)
/* He died during closing time. No resurrection. Tally up a
* death and exit. */
RSPEAK(DEATH_CLOSING);
- score(endgame);
-
+ terminate(endgame);
}
/* FIXME: Arithmetic on message numbers */
else if (game.numdie == MAXDIE || !YES(cmdin, WATCH_IT + game.numdie * 2, WHICH_WAY + game.numdie * 2, OK_MAN))
- score(endgame);
+ terminate(endgame);
else {
game.place[WATER] = game.place[OIL] = NOWHERE;
if (TOTING(LAMP))
case GO_DWARFWAKE:
/* Oh dear, he's disturbed the dwarves. */
RSPEAK(DWARVES_AWAKEN);
- score(endgame);
- return true;
+ terminate(endgame);
default:
BUG(99);
}
* scoring and wrap-up
*/
-void score(enum termination mode)
+static long mxscor; /* ugh..the price for having score() not exit. */
+
+long score(enum termination mode)
/* mode is 'scoregame' if scoring, 'quitgame' if quitting, 'endgame' if died
* or won */
{
- long score = 0, mxscor = 0;
+ long score = 0;
/* The present scoring algorithm is as follows:
* Objective: Points: Present total possible:
/* First tally up the treasures. Must be in building and not broken.
* Give the poor guy 2 points just for finding each treasure. */
+ mxscor = 0;
for (long i = MINTRS; i <= MAXTRS; i++) {
if (object_descriptions[i].inventory != 0) {
long k = 12;
SETPRM(1, score, mxscor);
SETPRM(3, game.turns, game.turns);
RSPEAK(GARNERED_POINTS);
- return;
}
- /* that should be good enough. Let's tell him all about it. */
- if (score + game.trnluz + 1 >= mxscor && game.trnluz != 0)
+ return score;
+}
+
+void terminate(enum termination mode)
+/* End of game. Let's tell him all about it. */
+{
+ long points = score(mode);
+
+ if (points + game.trnluz + 1 >= mxscor && game.trnluz != 0)
RSPEAK(TOOK_LONG);
- if (score + game.saved + 1 >= mxscor && game.saved != 0)
+ if (points + game.saved + 1 >= mxscor && game.saved != 0)
RSPEAK(WITHOUT_SUSPENDS);
- SETPRM(1, score, mxscor);
+ SETPRM(1, points, mxscor);
SETPRM(3, game.turns, game.turns);
RSPEAK(TOTAL_SCORE);
for (long i = 1; i <= (long)CLSSES; i++) {
- if (CVAL[i] >= score) {
+ if (CVAL[i] >= points) {
newspeak(class_messages[i]);
- i = CVAL[i] + 1 - score;
+ i = CVAL[i] + 1 - points;
SETPRM(1, i, i);
RSPEAK(NEXT_HIGHER);
exit(0);
RSPEAK(OFF_SCALE);
RSPEAK(NO_HIGHER);
exit(0);
-
}
+
+/* end */