Do not reject 1.5 format SOLs
[neverball] / share / cmd.h
1 /*
2  * Copyright (C) 2009 Neverball contributors
3  *
4  * NEVERBALL is  free software; you can redistribute  it and/or modify
5  * it under the  terms of the GNU General  Public License as published
6  * by the Free  Software Foundation; either version 2  of the License,
7  * or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT  ANY  WARRANTY;  without   even  the  implied  warranty  of
11  * MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU
12  * General Public License for more details.
13  */
14
15 #ifndef CMD_H
16 #define CMD_H
17
18 /*
19  * In an attempt to improve replay compatibility, a few guidelines
20  * apply to command addition, removal, and modification:
21  *
22  * - New commands are added at the bottom of the list.
23  *
24  * - Existing commands are never modified nor removed.
25  *
26  * - The list is never reordered.  (It's tempting...)
27  *
28  * However, commands can be renamed (e.g., to add a "deprecated" tag,
29  * because it's superseded by another command).
30  */
31
32 enum cmd_type
33 {
34     CMD_NONE = 0,
35
36     CMD_END_OF_UPDATE,
37     CMD_MAKE_BALL,
38     CMD_MAKE_ITEM,
39     CMD_PICK_ITEM,
40     CMD_TILT_ANGLES,
41     CMD_SOUND,
42     CMD_TIMER,
43     CMD_STATUS,
44     CMD_COINS,
45     CMD_JUMP_ENTER,
46     CMD_JUMP_EXIT,
47     CMD_BODY_PATH,
48     CMD_BODY_TIME,
49     CMD_GOAL_OPEN,
50     CMD_SWCH_ENTER,
51     CMD_SWCH_TOGGLE,
52     CMD_SWCH_EXIT,
53     CMD_UPDATES_PER_SECOND,
54     CMD_BALL_RADIUS,
55     CMD_CLEAR_ITEMS,
56     CMD_CLEAR_BALLS,
57     CMD_BALL_POSITION,
58     CMD_BALL_BASIS,
59     CMD_BALL_PEND_BASIS,
60     CMD_VIEW_POSITION,
61     CMD_VIEW_CENTER,
62     CMD_VIEW_BASIS,
63     CMD_CURRENT_BALL,
64     CMD_PATH_FLAG,
65     CMD_STEP_SIMULATION,
66     CMD_MAP,
67     CMD_TILT_AXES,
68     CMD_BODY_ORIENTATION,
69
70     CMD_MAX
71 };
72
73 /*
74  * Here are the members common to all structures.  Note that it
75  * explicitly says "enum cmd_type", not "int".  This allows GCC to
76  * catch and warn about unhandled command types in switch constructs
77  * (handy when adding new commands).
78  */
79
80 #define HEADER                                  \
81     enum cmd_type type
82
83 struct cmd_end_of_update
84 {
85     HEADER;
86 };
87
88 struct cmd_make_ball
89 {
90     HEADER;
91 };
92
93 struct cmd_make_item
94 {
95     HEADER;
96     float p[3];
97     int   t;
98     int   n;
99 };
100
101 struct cmd_pick_item
102 {
103     HEADER;
104     int   hi;
105 };
106
107 struct cmd_tilt_angles
108 {
109     HEADER;
110     float x;
111     float z;
112 };
113
114 struct cmd_sound
115 {
116     HEADER;
117     char  *n;
118     float  a;
119 };
120
121 struct cmd_timer
122 {
123     HEADER;
124     float t;
125 };
126
127 struct cmd_status
128 {
129     HEADER;
130     int t;
131 };
132
133 struct cmd_coins
134 {
135     HEADER;
136     int n;
137 };
138
139 struct cmd_jump_enter
140 {
141     HEADER;
142 };
143
144 struct cmd_jump_exit
145 {
146     HEADER;
147 };
148
149 struct cmd_body_path
150 {
151     HEADER;
152     int bi;
153     int pi;
154 };
155
156 struct cmd_body_time
157 {
158     HEADER;
159     int   bi;
160     float t;
161 };
162
163 struct cmd_goal_open
164 {
165     HEADER;
166 };
167
168 struct cmd_swch_enter
169 {
170     HEADER;
171     int xi;
172 };
173
174 struct cmd_swch_toggle
175 {
176     HEADER;
177     int xi;
178 };
179
180 struct cmd_swch_exit
181 {
182     HEADER;
183     int xi;
184 };
185
186 struct cmd_updates_per_second
187 {
188     HEADER;
189     int n;
190 };
191
192 struct cmd_ball_radius
193 {
194     HEADER;
195     float r;
196 };
197
198 struct cmd_clear_items
199 {
200     HEADER;
201 };
202
203 struct cmd_clear_balls
204 {
205     HEADER;
206 };
207
208 struct cmd_ball_position
209 {
210     HEADER;
211     float p[3];
212 };
213
214 struct cmd_ball_basis
215 {
216     HEADER;
217     float e[2][3];
218 };
219
220 struct cmd_ball_pend_basis
221 {
222     HEADER;
223     float E[2][3];
224 };
225
226 struct cmd_view_position
227 {
228     HEADER;
229     float p[3];
230 };
231
232 struct cmd_view_center
233 {
234     HEADER;
235     float c[3];
236 };
237
238 struct cmd_view_basis
239 {
240     HEADER;
241     float e[2][3];
242 };
243
244 struct cmd_current_ball
245 {
246     HEADER;
247     int ui;
248 };
249
250 struct cmd_path_flag
251 {
252     HEADER;
253     int pi;
254     int f;
255 };
256
257 struct cmd_step_simulation
258 {
259     HEADER;
260     float dt;
261 };
262
263 struct cmd_map
264 {
265     HEADER;
266     char *name;
267     struct
268     {
269         int x, y;
270     } version;
271 };
272
273 struct cmd_tilt_axes
274 {
275     HEADER;
276     float x[3], z[3];
277 };
278
279 struct cmd_body_orientation
280 {
281     HEADER;
282     int bi;
283     float e[4];
284 };
285
286 union cmd
287 {
288     HEADER;
289     struct cmd_end_of_update      eou;
290     struct cmd_make_ball          mkball;
291     struct cmd_make_item          mkitem;
292     struct cmd_pick_item          pkitem;
293     struct cmd_tilt_angles        tiltangles;
294     struct cmd_sound              sound;
295     struct cmd_timer              timer;
296     struct cmd_status             status;
297     struct cmd_coins              coins;
298     struct cmd_jump_enter         jumpenter;
299     struct cmd_jump_exit          jumpexit;
300     struct cmd_body_path          bodypath;
301     struct cmd_body_time          bodytime;
302     struct cmd_goal_open          goalopen;
303     struct cmd_swch_enter         swchenter;
304     struct cmd_swch_toggle        swchtoggle;
305     struct cmd_swch_exit          swchexit;
306     struct cmd_updates_per_second ups;
307     struct cmd_ball_radius        ballradius;
308     struct cmd_clear_items        clritems;
309     struct cmd_clear_balls        clrballs;
310     struct cmd_ball_position      ballpos;
311     struct cmd_ball_basis         ballbasis;
312     struct cmd_ball_pend_basis    ballpendbasis;
313     struct cmd_view_position      viewpos;
314     struct cmd_view_center        viewcenter;
315     struct cmd_view_basis         viewbasis;
316     struct cmd_current_ball       currball;
317     struct cmd_path_flag          pathflag;
318     struct cmd_step_simulation    stepsim;
319     struct cmd_map                map;
320     struct cmd_tilt_axes          tiltaxes;
321     struct cmd_body_orientation   bodyorient;
322 };
323
324 /* No module should see this. */
325 #undef HEADER
326
327 #include "fs.h"
328
329 int cmd_put(fs_file, const union cmd *);
330 int cmd_get(fs_file, union cmd *);
331
332 #endif