-void score(long mode) {
-/* arg is <0 if scoring, >0 if quitting, =0 if died or won */
- long i, score = 0, mxscor = 0;
-
-/* The present scoring algorithm is as follows:
- * Objective: Points: Present total possible:
- * Getting well into cave 25 25
- * Each treasure < chest 12 60
- * Treasure chest itself 14 14
- * Each treasure > chest 16 224
- * Surviving (MAX-NUM)*10 30
- * Not quitting 4 4
- * Reaching "game.closng" 25 25
- * "Closed": Quit/Killed 10
- * Klutzed 25
- * Wrong way 30
- * Success 45 45
- * Came to Witt's End 1 1
- * Round out the total 2 2
- * TOTAL: 430
- * Points can also be deducted for using hints or too many turns, or for
- * saving intermediate positions. */
-
-/* First tally up the treasures. Must be in building and not broken.
- * Give the poor guy 2 points just for finding each treasure. */
-
- for (i=MINTRS; i<=MAXTRS; i++) {
- if(PTEXT[i] != 0) {
- K=12;
- if(i == CHEST)K=14;
- if(i > CHEST)K=16;
- if(game.prop[i] >= 0)
- score=score+2;
- if(game.place[i] == 3 && game.prop[i] == 0)
- score=score+K-2;
- mxscor=mxscor+K;
+static int mxscor; /* ugh..the price for having score() not exit. */
+
+int score(enum termination mode) {
+ /* mode is 'scoregame' if scoring, 'quitgame' if quitting, 'endgame' if
+ * died or won */
+ int score = 0;
+
+ /* The present scoring algorithm is as follows:
+ * Objective: Points: Present total possible:
+ * Getting well into cave 25 25
+ * Each treasure < chest 12 60
+ * Treasure chest itself 14 14
+ * Each treasure > chest 16 224
+ * Surviving (MAX-NUM)*10 30
+ * Not quitting 4 4
+ * Reaching "game.closng" 25 25
+ * "Closed": Quit/Killed 10
+ * Klutzed 25
+ * Wrong way 30
+ * Success 45 45
+ * Came to Witt's End 1 1
+ * Round out the total 2 2
+ * TOTAL: 430
+ * Points can also be deducted for using hints or too many turns, or
+ * for saving intermediate positions. */
+
+ /* 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 (int i = 1; i <= NOBJECTS; i++) {
+ if (!objects[i].is_treasure) {
+ continue;
+ }
+ if (objects[i].inventory != 0) {
+ int k = 12;
+ if (i == CHEST) {
+ k = 14;
+ }
+ if (i > CHEST) {
+ k = 16;
+ }
+ if (!PROP_IS_STASHED(i) && !PROP_IS_NOTFOUND(i)) {
+ score += 2;
+ }
+ if (game.objects[i].place == LOC_BUILDING &&
+ PROP_IS_FOUND(i)) {
+ score += k - 2;
+ }
+ mxscor += k;