File: data.h

package info (click to toggle)
gltron 0.61-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,948 kB
  • ctags: 1,175
  • sloc: ansic: 7,580; perl: 168; makefile: 149; sh: 15
file content (342 lines) | stat: -rw-r--r-- 6,610 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
#ifndef DATA_H
#define DATA_H

#include "gltron.h"

/* general data structures */

typedef struct list list;
struct list {
  void *data;
  list* next;
};

typedef struct {
  float x, y;
} Point;

/* game specific data structures */

typedef struct Grid {
  int width, height;
  unsigned char *data;
} Grid;

typedef struct RuleSet {
  int eraseCrashed;
  float speed;
} RuleSet;

typedef struct Time {
  int current;
  int lastFrame;
  int offset; /* from SystemGetElapsedTime() */
  int dt; /* current - lastFrame */

  /* float timeScale; */
} Time;

enum {
  EVENT_TURN_LEFT = 1,
  EVENT_TURN_RIGHT = 2,
  EVENT_CRASH = 4,
  EVENT_STOP = 8
};

enum {
  TURN_LEFT = 3,
  TURN_RIGHT = 1
};

typedef struct GameEvent {
  int type; /* what */
  int player; /* who */
  int x; /* where */
  int y;
  int timestamp;
} GameEvent;
  
enum {
  GAME_SINGLE = 1,
  GAME_SINGLE_RECORD = 2,
  GAME_PLAY = 4,
  GAME_PLAY_NETWORK = 8,
  GAME_NETWORK_RECORD
};

enum {
  NET_EVENT = 'e'
};

typedef struct NetData {
  char type[2];
  char *data;
  int length;
} NetData;

typedef struct Network {
  list *data;
  int status;
} Network;

typedef struct Input {
  int mouse1;
  int mouse2;
  int mousex;
  int mousey;
} Input;
  
typedef struct Game2 {
  Grid grid;
  RuleSet rules;
  int mode;
  int players;
  int *startPositions;
  Time time;
  list events;
  FILE *record;
  FILE *play;
  Network network;
  Input input;
} Game2;
  
typedef struct line {
  int sx, sy, ex, ey;
} line;

typedef struct fontbmp {
  int texwidth; /* texture width */
  int width; /* character width */

  int lower; /* lowest ascii character (normally: 32) */
  int upper; /* highest ascii character (normally: 126) */

  texture *tex;
} fontbmp;

typedef struct fonttex {
  // sgi_texture **textures;
  int nTextures;
  
  int texwidth; /* texture width */
  int width; /* character width */

  int lower; /* lowest ascii character (normally: 32) */
  int upper; /* highest ascii character (normally: 126) */

  unsigned int *texID;

  char *fontname;
  char *bitmapname;
  int bitmapTexwidth;
  int bitmapWidth; /* character width */
} fonttex;

typedef struct Model {
  Mesh **mesh; /* models (lod) */
  int lod; /* number of models */
  // int *lod_dist;
  
  float color_alpha[4]; /* alpha trail */
  float color_trail[4]; /* solid edges of trail */
  float color_model[4]; /* model color */
} Model;

typedef struct Data {
  int iposx, iposy;
  float posx, posy;
  float t;
  
  int dir; int last_dir;

  int turn;
  int turn_time; /* for cycle animation */
  
  int score;
  float speed; /* set to -1 when dead */
  float trail_height; /* countdown to zero when dead */
  float exp_radius; /* explosion of the cycle model */
  line *trails;
  line *trail; /* current trail */
} Data;

enum { 
  CAM_FREE_R = 0,
  CAM_FREE_PHI,
  CAM_FREE_CHI 
};

typedef struct CameraType {
  int interpolated_cam;
  int interpolated_target;
  int coupled;
  int freedom[3];
  int type;
} CameraType;

typedef struct Camera {
  float cam[3];
  float target[3];
  float movement[3]; /* indices CAM_R, CAM_CHI, CAM_PHI */
  CameraType *type;
} Camera;

typedef struct AI {
  int active;
  int tdiff; /*  */
  int moves;
  long lasttime;
  int danger;
  int lastx, lasty;
} AI;

typedef struct {
  char *path;
  /* char *name; currently ignored */
} Artpack;

typedef struct gDisplay {
  int win_id;     /* nur das globale Window hat eine */
  int h, w;       /* window */
  int vp_x, vp_y; /* viewport */
  int vp_h, vp_w;
  int blending;
  int fog;
  int shademodel;
  int wall;
  int onScreen;

  /* texture ID */
  unsigned int *textures;

  /* software rendering stuff */
  unsigned char *pixelGui;
  fontbmp *bitfont;
  Artpack artpack;
} gDisplay;

typedef struct Player {
  Model *model;
  Data *data;
  Camera *camera;
  gDisplay *display;
  AI *ai;
} Player;

/* if you want to add something and make it permanent (via
   .gltronrc) then
   1) add it to Settings in data.h
   2) add it to settings.txt
   3) add pointer to initSettingData() in settings.c
   4) add a default to initMainGameSettings() in settings.c
   5) make a menu entry in menu.txt
*/

enum {
  BILINEAR = 0,
  TRILINEAR = 1
};

typedef struct Settings {
  /* these settings affect the visuals and sound etc.
     and are client side only */

  int show_help;
  int show_fps;
  int show_wall;
  int show_2d;
  int show_alpha;
  int alpha_trails;
  int light_cycles;

  int show_skybox;
  int show_floor_texture;
  int show_glow;
  int show_scores;
  int show_ai_status;
  int show_model;
  int show_recognizer;
  int show_decals; /* disable on G200/G400/win32 due to a driver bug */
  int lod;
  int shadow_lod;
  int show_crash_texture;
  int show_gl_logo;
  int model_backwards;
  int turn_cycle; /* smooth turning */
  int line_spacing; /* space between lines when the floor texture is
		       disabled */

  int stretch_textures;
  int use_mipmaps; /* enable / disable mipmapping */
  int mipmap_filter; /* bilinear / trilinear */

  int softwareRendering;
  int camType;
  int mouse_warp;

  int display_type; /* 0-2 -> 1, 2 or 4 displays on the screen */
  int content[4]; /* max. 4 individual viewports on the screen */
  int windowMode; /* 0: fullscreen, non-zero: window mode */
  int bitdepth_32; /* 1: 32 bit rendering */

  int fov; /* field ov view (vertical angle) */
  float znear; /* the near z-Plane */
  int width; /* screen width & height */
  int height;

  int playMusic;
  int playEffects;

  float musicVolume;
  float fxVolume;

  list* soundList;
  int soundIndex;
  int soundSongCount;
  /* these two are ignored in multiplayer mode */
  int fast_finish;
  int screenSaver; /* 1: all for players are AIs when the game starts */

  /* no AI in multiplayer yet */
  int ai_player1;
  int ai_player2;
  int ai_player3;
  int ai_player4;
  int ai_level;

  /* these gettings affect the gameplay */
  int erase_crashed;
  int game_speed; /* index */
  float current_speed;
  int grid_size;
  int arena_size; /* index */
} Settings;

typedef struct Game {
  gDisplay *screen;
  Settings *settings;
  Player *player;
  int players; /* number of players - currently limited to 4 somewhere */
  int winner; /* who won this round */
  int pauseflag; /* if the game is finished: the PAUSE_GAME_FINISHED flag
		    is set */
  int running; /* the amount of players that are still alive */
} Game;

typedef struct settings_int {
  char name[32];
  int *value;
} settings_int;

typedef struct settings_float {
  char name[32];
  float *value;
} settings_float;


typedef struct settings_v {
  char name[32];
  void (*value)(char*, FILE*);
} settings_v;

#endif