Fix a memory leak.
[sgt/puzzles] / nullgame.c
CommitLineData
699b896a 1/*
2 * nullgame.c [FIXME]: Template defining the null game (in which no
3 * moves are permitted and nothing is ever drawn). This file exists
4 * solely as a basis for constructing new game definitions - it
5 * helps to have something which will compile from the word go and
6 * merely doesn't _do_ very much yet.
7 *
8 * Parts labelled FIXME actually want _removing_ (e.g. the dummy
9 * field in each of the required data structures, and this entire
10 * comment itself) when converting this source file into one
11 * describing a real game.
12 */
13
14#include <stdio.h>
15#include <stdlib.h>
16#include <string.h>
17#include <assert.h>
b0e26073 18#include <ctype.h>
699b896a 19#include <math.h>
20
21#include "puzzles.h"
22
23const char *const game_name = "Null Game";
c8230524 24const int game_can_configure = FALSE;
699b896a 25
26enum {
27 COL_BACKGROUND,
28 NCOLOURS
29};
30
31struct game_params {
32 int FIXME;
33};
34
35struct game_state {
36 int FIXME;
37};
38
39game_params *default_params(void)
40{
41 game_params *ret = snew(game_params);
42
43 ret->FIXME = 0;
44
45 return ret;
46}
47
48int game_fetch_preset(int i, char **name, game_params **params)
49{
50 return FALSE;
51}
52
53void free_params(game_params *params)
54{
55 sfree(params);
56}
57
58game_params *dup_params(game_params *params)
59{
60 game_params *ret = snew(game_params);
61 *ret = *params; /* structure copy */
62 return ret;
63}
64
b0e26073 65game_params *decode_params(char const *string)
66{
67 game_params *ret = snew(game_params);
68
69 ret->FIXME = 0;
70
71 return ret;
72}
73
74char *encode_params(game_params *params)
75{
76 return dupstr("FIXME");
77}
78
c8230524 79config_item *game_configure(game_params *params)
80{
81 return NULL;
82}
83
84game_params *custom_params(config_item *cfg)
85{
86 return NULL;
87}
88
89char *validate_params(game_params *params)
90{
91 return NULL;
92}
93
48d70ca9 94char *new_game_seed(game_params *params, random_state *rs)
699b896a 95{
96 return dupstr("FIXME");
97}
98
5928817c 99char *validate_seed(game_params *params, char *seed)
100{
101 return NULL;
102}
103
699b896a 104game_state *new_game(game_params *params, char *seed)
105{
106 game_state *state = snew(game_state);
107
108 state->FIXME = 0;
109
110 return state;
111}
112
113game_state *dup_game(game_state *state)
114{
115 game_state *ret = snew(game_state);
116
117 ret->FIXME = state->FIXME;
118
119 return ret;
120}
121
122void free_game(game_state *state)
123{
124 sfree(state);
125}
126
74a4e547 127game_ui *new_ui(game_state *state)
128{
129 return NULL;
130}
131
132void free_ui(game_ui *ui)
133{
134}
135
136game_state *make_move(game_state *from, game_ui *ui, int x, int y, int button)
699b896a 137{
138 return NULL;
139}
140
141/* ----------------------------------------------------------------------
142 * Drawing routines.
143 */
144
145struct game_drawstate {
146 int FIXME;
147};
148
149void game_size(game_params *params, int *x, int *y)
150{
151 *x = *y = 200; /* FIXME */
152}
153
154float *game_colours(frontend *fe, game_state *state, int *ncolours)
155{
156 float *ret = snewn(3 * NCOLOURS, float);
157
158 frontend_default_colour(fe, &ret[COL_BACKGROUND * 3]);
159
160 *ncolours = NCOLOURS;
161 return ret;
162}
163
164game_drawstate *game_new_drawstate(game_state *state)
165{
166 struct game_drawstate *ds = snew(struct game_drawstate);
167
168 ds->FIXME = 0;
169
170 return ds;
171}
172
173void game_free_drawstate(game_drawstate *ds)
174{
175 sfree(ds);
176}
177
178void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
74a4e547 179 game_state *state, game_ui *ui,
180 float animtime, float flashtime)
699b896a 181{
1d30357e 182 /*
183 * The initial contents of the window are not guaranteed and
184 * can vary with front ends. To be on the safe side, all games
185 * should start by drawing a big background-colour rectangle
186 * covering the whole window.
187 */
188 draw_rect(fe, 0, 0, 200, 200, COL_BACKGROUND);
699b896a 189}
190
191float game_anim_length(game_state *oldstate, game_state *newstate)
192{
193 return 0.0F;
194}
195
196float game_flash_length(game_state *oldstate, game_state *newstate)
197{
198 return 0.0F;
199}
fd1a1a2b 200
201int game_wants_statusbar(void)
202{
203 return FALSE;
204}