Add a limited-shuffle mode like that added to Sixteen and Twiddle in r5769,
[sgt/puzzles] / nullgame.c
index 5ce6f07..da57bac 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
+#include <ctype.h>
 #include <math.h>
 
 #include "puzzles.h"
 
-const char *const game_name = "Null Game";
-
 enum {
     COL_BACKGROUND,
     NCOLOURS
@@ -34,7 +33,7 @@ struct game_state {
     int FIXME;
 };
 
-game_params *default_params(void)
+static game_params *default_params(void)
 {
     game_params *ret = snew(game_params);
 
@@ -43,29 +42,64 @@ game_params *default_params(void)
     return ret;
 }
 
-int game_fetch_preset(int i, char **name, game_params **params)
+static int game_fetch_preset(int i, char **name, game_params **params)
 {
     return FALSE;
 }
 
-void free_params(game_params *params)
+static void free_params(game_params *params)
 {
     sfree(params);
 }
 
-game_params *dup_params(game_params *params)
+static game_params *dup_params(game_params *params)
 {
     game_params *ret = snew(game_params);
     *ret = *params;                   /* structure copy */
     return ret;
 }
 
-char *new_game_seed(game_params *params)
+static void decode_params(game_params *params, char const *string)
+{
+}
+
+static char *encode_params(game_params *params, int full)
+{
+    return dupstr("FIXME");
+}
+
+static config_item *game_configure(game_params *params)
+{
+    return NULL;
+}
+
+static game_params *custom_params(config_item *cfg)
+{
+    return NULL;
+}
+
+static char *validate_params(game_params *params)
+{
+    return NULL;
+}
+
+static char *new_game_desc(game_params *params, random_state *rs,
+                          game_aux_info **aux)
 {
     return dupstr("FIXME");
 }
 
-game_state *new_game(game_params *params, char *seed)
+static void game_free_aux_info(game_aux_info *aux)
+{
+    assert(!"Shouldn't happen");
+}
+
+static char *validate_desc(game_params *params, char *desc)
+{
+    return NULL;
+}
+
+static game_state *new_game(game_params *params, char *desc)
 {
     game_state *state = snew(game_state);
 
@@ -74,7 +108,7 @@ game_state *new_game(game_params *params, char *seed)
     return state;
 }
 
-game_state *dup_game(game_state *state)
+static game_state *dup_game(game_state *state)
 {
     game_state *ret = snew(game_state);
 
@@ -83,12 +117,33 @@ game_state *dup_game(game_state *state)
     return ret;
 }
 
-void free_game(game_state *state)
+static void free_game(game_state *state)
 {
     sfree(state);
 }
 
-game_state *make_move(game_state *from, int x, int y, int button)
+static game_state *solve_game(game_state *state, game_aux_info *aux,
+                             char **error)
+{
+    return NULL;
+}
+
+static char *game_text_format(game_state *state)
+{
+    return NULL;
+}
+
+static game_ui *new_ui(game_state *state)
+{
+    return NULL;
+}
+
+static void free_ui(game_ui *ui)
+{
+}
+
+static game_state *make_move(game_state *from, game_ui *ui, int x, int y,
+                            int button)
 {
     return NULL;
 }
@@ -101,12 +156,12 @@ struct game_drawstate {
     int FIXME;
 };
 
-void game_size(game_params *params, int *x, int *y)
+static void game_size(game_params *params, int *x, int *y)
 {
     *x = *y = 200;                     /* FIXME */
 }
 
-float *game_colours(frontend *fe, game_state *state, int *ncolours)
+static float *game_colours(frontend *fe, game_state *state, int *ncolours)
 {
     float *ret = snewn(3 * NCOLOURS, float);
 
@@ -116,7 +171,7 @@ float *game_colours(frontend *fe, game_state *state, int *ncolours)
     return ret;
 }
 
-game_drawstate *game_new_drawstate(game_state *state)
+static game_drawstate *game_new_drawstate(game_state *state)
 {
     struct game_drawstate *ds = snew(struct game_drawstate);
 
@@ -125,22 +180,72 @@ game_drawstate *game_new_drawstate(game_state *state)
     return ds;
 }
 
-void game_free_drawstate(game_drawstate *ds)
+static void game_free_drawstate(game_drawstate *ds)
 {
     sfree(ds);
 }
 
-void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
-                 game_state *state, float animtime, float flashtime)
+static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
+                       game_state *state, int dir, game_ui *ui,
+                       float animtime, float flashtime)
 {
+    /*
+     * The initial contents of the window are not guaranteed and
+     * can vary with front ends. To be on the safe side, all games
+     * should start by drawing a big background-colour rectangle
+     * covering the whole window.
+     */
+    draw_rect(fe, 0, 0, 200, 200, COL_BACKGROUND);
 }
 
-float game_anim_length(game_state *oldstate, game_state *newstate)
+static float game_anim_length(game_state *oldstate, game_state *newstate,
+                             int dir)
 {
     return 0.0F;
 }
 
-float game_flash_length(game_state *oldstate, game_state *newstate)
+static float game_flash_length(game_state *oldstate, game_state *newstate,
+                              int dir)
 {
     return 0.0F;
 }
+
+static int game_wants_statusbar(void)
+{
+    return FALSE;
+}
+
+#ifdef COMBINED
+#define thegame nullgame
+#endif
+
+const struct game thegame = {
+    "Null Game", NULL,
+    default_params,
+    game_fetch_preset,
+    decode_params,
+    encode_params,
+    free_params,
+    dup_params,
+    FALSE, game_configure, custom_params,
+    validate_params,
+    new_game_desc,
+    game_free_aux_info,
+    validate_desc,
+    new_game,
+    dup_game,
+    free_game,
+    FALSE, solve_game,
+    FALSE, game_text_format,
+    new_ui,
+    free_ui,
+    make_move,
+    game_size,
+    game_colours,
+    game_new_drawstate,
+    game_free_drawstate,
+    game_redraw,
+    game_anim_length,
+    game_flash_length,
+    game_wants_statusbar,
+};