share/cmd: kill stray struct member
[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_ROTATE,
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
68     CMD_MAX
69 };
70
71 /*
72  * Here are the members common to all structures.  Note that it
73  * explicitly says "enum cmd_type", not "int".  This allows GCC to
74  * catch and warn about unhandled command types in switch constructs
75  * (handy when adding new commands).
76  */
77
78 #define HEADER                                  \
79     enum cmd_type type
80
81 struct cmd_end_of_update
82 {
83     HEADER;
84 };
85
86 struct cmd_make_ball
87 {
88     HEADER;
89 };
90
91 struct cmd_make_item
92 {
93     HEADER;
94     float p[3];
95     int   t;
96     int   n;
97 };
98
99 struct cmd_pick_item
100 {
101     HEADER;
102     int   hi;
103 };
104
105 struct cmd_rotate
106 {
107     HEADER;
108     float x;
109     float z;
110 };
111
112 struct cmd_sound
113 {
114     HEADER;
115     char  *n;
116     float  a;
117 };
118
119 struct cmd_timer
120 {
121     HEADER;
122     float t;
123 };
124
125 struct cmd_status
126 {
127     HEADER;
128     int t;
129 };
130
131 struct cmd_coins
132 {
133     HEADER;
134     int n;
135 };
136
137 struct cmd_jump_enter
138 {
139     HEADER;
140 };
141
142 struct cmd_jump_exit
143 {
144     HEADER;
145 };
146
147 struct cmd_body_path
148 {
149     HEADER;
150     int bi;
151     int pi;
152 };
153
154 struct cmd_body_time
155 {
156     HEADER;
157     int   bi;
158     float t;
159 };
160
161 struct cmd_goal_open
162 {
163     HEADER;
164 };
165
166 struct cmd_swch_enter
167 {
168     HEADER;
169     int xi;
170 };
171
172 struct cmd_swch_toggle
173 {
174     HEADER;
175     int xi;
176 };
177
178 struct cmd_swch_exit
179 {
180     HEADER;
181     int xi;
182 };
183
184 struct cmd_updates_per_second
185 {
186     HEADER;
187     int n;
188 };
189
190 struct cmd_ball_radius
191 {
192     HEADER;
193     float r;
194 };
195
196 struct cmd_clear_items
197 {
198     HEADER;
199 };
200
201 struct cmd_clear_balls
202 {
203     HEADER;
204 };
205
206 struct cmd_ball_position
207 {
208     HEADER;
209     float p[3];
210 };
211
212 struct cmd_ball_basis
213 {
214     HEADER;
215     float e[2][3];
216 };
217
218 struct cmd_ball_pend_basis
219 {
220     HEADER;
221     float E[2][3];
222 };
223
224 struct cmd_view_position
225 {
226     HEADER;
227     float p[3];
228 };
229
230 struct cmd_view_center
231 {
232     HEADER;
233     float c[3];
234 };
235
236 struct cmd_view_basis
237 {
238     HEADER;
239     float e[2][3];
240 };
241
242 struct cmd_current_ball
243 {
244     HEADER;
245     int ui;
246 };
247
248 struct cmd_path_flag
249 {
250     HEADER;
251     int pi;
252     int f;
253 };
254
255 struct cmd_step_simulation
256 {
257     HEADER;
258     float dt;
259 };
260
261 struct cmd_map
262 {
263     HEADER;
264     char *name;
265     struct
266     {
267         int x, y;
268     } version;
269 };
270
271 union cmd
272 {
273     HEADER;
274     struct cmd_end_of_update      eou;
275     struct cmd_make_ball          mkball;
276     struct cmd_make_item          mkitem;
277     struct cmd_pick_item          pkitem;
278     struct cmd_rotate             rotate;
279     struct cmd_sound              sound;
280     struct cmd_timer              timer;
281     struct cmd_status             status;
282     struct cmd_coins              coins;
283     struct cmd_jump_enter         jumpenter;
284     struct cmd_jump_exit          jumpexit;
285     struct cmd_body_path          bodypath;
286     struct cmd_body_time          bodytime;
287     struct cmd_goal_open          goalopen;
288     struct cmd_swch_enter         swchenter;
289     struct cmd_swch_toggle        swchtoggle;
290     struct cmd_swch_exit          swchexit;
291     struct cmd_updates_per_second ups;
292     struct cmd_ball_radius        ballradius;
293     struct cmd_clear_items        clritems;
294     struct cmd_clear_balls        clrballs;
295     struct cmd_ball_position      ballpos;
296     struct cmd_ball_basis         ballbasis;
297     struct cmd_ball_pend_basis    ballpendbasis;
298     struct cmd_view_position      viewpos;
299     struct cmd_view_center        viewcenter;
300     struct cmd_view_basis         viewbasis;
301     struct cmd_current_ball       currball;
302     struct cmd_path_flag          pathflag;
303     struct cmd_step_simulation    stepsim;
304     struct cmd_map                map;
305 };
306
307 /* No module should see this. */
308 #undef HEADER
309
310 #include "fs.h"
311
312 int cmd_put(fs_file, const union cmd *);
313 int cmd_get(fs_file, union cmd *);
314
315 #endif