chiark / gitweb /
New infrastructure feature. Games are now permitted to be
[sgt-puzzles.git] / blackbox.c
index dda036c8689498db153895201de10e920968be22..a8c6d5a2cb5c0c303452585a77aaec855e09f782 100644 (file)
@@ -463,6 +463,11 @@ static char *solve_game(game_state *state, game_state *currstate,
     return dupstr("S");
 }
 
+static int game_can_format_as_text_now(game_params *params)
+{
+    return TRUE;
+}
+
 static char *game_text_format(game_state *state)
 {
     return NULL;
@@ -692,9 +697,9 @@ static int check_guesses(game_state *state, int cagey)
             * grid, so that repeating the same marking will give
             * the same answer instead of a different one.
             */
-           random_state *rs = random_init((char *)guesses->grid,
-                                          (state->w+2)*(state->h+2) *
-                                          sizeof(unsigned int));
+           random_state *rs = random_new((char *)guesses->grid,
+                                         (state->w+2)*(state->h+2) *
+                                         sizeof(unsigned int));
            n = random_upto(rs, n);
            random_free(rs);
            for (i = 0; i < guesses->nlasers; i++) {
@@ -727,9 +732,9 @@ static int check_guesses(game_state *state, int cagey)
             * grid, so that repeating the same marking will give
             * the same answer instead of a different one.
             */
-           random_state *rs = random_init((char *)guesses->grid,
-                                          (state->w+2)*(state->h+2) *
-                                          sizeof(unsigned int));
+           random_state *rs = random_new((char *)guesses->grid,
+                                         (state->w+2)*(state->h+2) *
+                                         sizeof(unsigned int));
            n = random_upto(rs, n);
            random_free(rs);
            for (i = 0; i < guesses->nlasers; i++) {
@@ -813,7 +818,9 @@ static int check_guesses(game_state *state, int cagey)
             ret = 0;
         }
     }
-    if (ret == 0) goto done;
+    if (ret == 0 ||
+       state->nguesses < state->minballs ||
+       state->nguesses > state->maxballs) goto done;
 
     /* fix up original state so the 'correct' balls end up matching the guesses,
      * as we've just proved that they were equivalent. */
@@ -1060,7 +1067,7 @@ static void game_set_size(drawing *dr, game_drawstate *ds,
     ds->rrad = (3*tilesize)/8;
 }
 
-static float *game_colours(frontend *fe, game_state *state, int *ncolours)
+static float *game_colours(frontend *fe, int *ncolours)
 {
     float *ret = snewn(3 * NCOLOURS, float);
     int i;
@@ -1378,11 +1385,6 @@ static float game_flash_length(game_state *oldstate, game_state *newstate,
         return 0.0F;
 }
 
-static int game_wants_statusbar(void)
-{
-    return TRUE;
-}
-
 static int game_timing_state(game_state *state, game_ui *ui)
 {
     return TRUE;
@@ -1401,7 +1403,7 @@ static void game_print(drawing *dr, game_state *state, int tilesize)
 #endif
 
 const struct game thegame = {
-    "Black Box", "games.blackbox",
+    "Black Box", "games.blackbox", "blackbox",
     default_params,
     game_fetch_preset,
     decode_params,
@@ -1416,7 +1418,7 @@ const struct game thegame = {
     dup_game,
     free_game,
     TRUE, solve_game,
-    FALSE, game_text_format,
+    FALSE, game_can_format_as_text_now, game_text_format,
     new_ui,
     free_ui,
     encode_ui,
@@ -1432,9 +1434,9 @@ const struct game thegame = {
     game_anim_length,
     game_flash_length,
     FALSE, FALSE, game_print_size, game_print,
-    game_wants_statusbar,
+    TRUE,                             /* wants_statusbar */
     FALSE, game_timing_state,
-    0,                                /* mouse_priorities */
+    REQUIRE_RBUTTON,                  /* flags */
 };
 
 /* vim: set shiftwidth=4 tabstop=8: */