Annoying special cases for Mines.
[sgt/puzzles] / nullgame.c
... / ...
CommitLineData
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>
18#include <ctype.h>
19#include <math.h>
20
21#include "puzzles.h"
22
23enum {
24 COL_BACKGROUND,
25 NCOLOURS
26};
27
28struct game_params {
29 int FIXME;
30};
31
32struct game_state {
33 int FIXME;
34};
35
36static game_params *default_params(void)
37{
38 game_params *ret = snew(game_params);
39
40 ret->FIXME = 0;
41
42 return ret;
43}
44
45static int game_fetch_preset(int i, char **name, game_params **params)
46{
47 return FALSE;
48}
49
50static void free_params(game_params *params)
51{
52 sfree(params);
53}
54
55static game_params *dup_params(game_params *params)
56{
57 game_params *ret = snew(game_params);
58 *ret = *params; /* structure copy */
59 return ret;
60}
61
62static void decode_params(game_params *params, char const *string)
63{
64}
65
66static char *encode_params(game_params *params, int full)
67{
68 return dupstr("FIXME");
69}
70
71static config_item *game_configure(game_params *params)
72{
73 return NULL;
74}
75
76static game_params *custom_params(config_item *cfg)
77{
78 return NULL;
79}
80
81static char *validate_params(game_params *params)
82{
83 return NULL;
84}
85
86static char *new_game_desc(game_params *params, random_state *rs,
87 game_aux_info **aux, int interactive)
88{
89 return dupstr("FIXME");
90}
91
92static void game_free_aux_info(game_aux_info *aux)
93{
94 assert(!"Shouldn't happen");
95}
96
97static char *validate_desc(game_params *params, char *desc)
98{
99 return NULL;
100}
101
102static game_state *new_game(midend_data *me, game_params *params, char *desc)
103{
104 game_state *state = snew(game_state);
105
106 state->FIXME = 0;
107
108 return state;
109}
110
111static game_state *dup_game(game_state *state)
112{
113 game_state *ret = snew(game_state);
114
115 ret->FIXME = state->FIXME;
116
117 return ret;
118}
119
120static void free_game(game_state *state)
121{
122 sfree(state);
123}
124
125static char *solve_game(game_state *state, game_state *currstate,
126 game_aux_info *aux, char **error)
127{
128 return NULL;
129}
130
131static char *game_text_format(game_state *state)
132{
133 return NULL;
134}
135
136static game_ui *new_ui(game_state *state)
137{
138 return NULL;
139}
140
141static void free_ui(game_ui *ui)
142{
143}
144
145static void game_changed_state(game_ui *ui, game_state *oldstate,
146 game_state *newstate)
147{
148}
149
150struct game_drawstate {
151 int FIXME;
152};
153
154static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
155 int x, int y, int button)
156{
157 return NULL;
158}
159
160static game_state *execute_move(game_state *state, char *move)
161{
162 return NULL;
163}
164
165/* ----------------------------------------------------------------------
166 * Drawing routines.
167 */
168
169static void game_size(game_params *params, game_drawstate *ds,
170 int *x, int *y, int expand)
171{
172 *x = *y = 200; /* FIXME */
173}
174
175static float *game_colours(frontend *fe, game_state *state, int *ncolours)
176{
177 float *ret = snewn(3 * NCOLOURS, float);
178
179 frontend_default_colour(fe, &ret[COL_BACKGROUND * 3]);
180
181 *ncolours = NCOLOURS;
182 return ret;
183}
184
185static game_drawstate *game_new_drawstate(game_state *state)
186{
187 struct game_drawstate *ds = snew(struct game_drawstate);
188
189 ds->FIXME = 0;
190
191 return ds;
192}
193
194static void game_free_drawstate(game_drawstate *ds)
195{
196 sfree(ds);
197}
198
199static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
200 game_state *state, int dir, game_ui *ui,
201 float animtime, float flashtime)
202{
203 /*
204 * The initial contents of the window are not guaranteed and
205 * can vary with front ends. To be on the safe side, all games
206 * should start by drawing a big background-colour rectangle
207 * covering the whole window.
208 */
209 draw_rect(fe, 0, 0, 200, 200, COL_BACKGROUND);
210}
211
212static float game_anim_length(game_state *oldstate, game_state *newstate,
213 int dir, game_ui *ui)
214{
215 return 0.0F;
216}
217
218static float game_flash_length(game_state *oldstate, game_state *newstate,
219 int dir, game_ui *ui)
220{
221 return 0.0F;
222}
223
224static int game_wants_statusbar(void)
225{
226 return FALSE;
227}
228
229static int game_timing_state(game_state *state)
230{
231 return TRUE;
232}
233
234#ifdef COMBINED
235#define thegame nullgame
236#endif
237
238const struct game thegame = {
239 "Null Game", NULL,
240 default_params,
241 game_fetch_preset,
242 decode_params,
243 encode_params,
244 free_params,
245 dup_params,
246 FALSE, game_configure, custom_params,
247 validate_params,
248 new_game_desc,
249 game_free_aux_info,
250 validate_desc,
251 new_game,
252 dup_game,
253 free_game,
254 FALSE, solve_game,
255 FALSE, game_text_format,
256 new_ui,
257 free_ui,
258 game_changed_state,
259 interpret_move,
260 execute_move,
261 game_size,
262 game_colours,
263 game_new_drawstate,
264 game_free_drawstate,
265 game_redraw,
266 game_anim_length,
267 game_flash_length,
268 game_wants_statusbar,
269 FALSE, game_timing_state,
270 0, /* mouse_priorities */
271};