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