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