File: netmaze.h

package info (click to toggle)
netmaze 0.81+jpg0.82-14.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,208 kB
  • ctags: 915
  • sloc: ansic: 8,277; tcl: 1,223; makefile: 66; sh: 26
file content (311 lines) | stat: -rw-r--r-- 8,624 bytes parent folder | download | duplicates (5)
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
#include <sys/param.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

/*********************/

#include "config.h"   /* check out config.h for configuration */

/*********************/

#define NETMAZEPORT 12346

#define RS6000 1

#define TRUE  1
#define FALSE 0

#define DRAWWAIT 1       /* 1 = Draw 3D-view every 'heart-beat' (if possible)*/
#define DRAWTIME 36000L  /* time per 'heart-beat' in microsec */

#define WINKEL_STEP 4    /* Rotate-Step (don't change) */
#define MAX_WINKEL 256   /* maximum-angel (don't change) */

#define XMAX 320*4096	/* internal x-resolution (right-border)  */
#define XMIN -320*4096	/* internal X-resolution (left-border)*/

#define IMAGEWIDTH 1280
#define IMAGEHEIGHT 810

#define WXSIZE (sm->grafix.gamewidth)
#define WYSIZE (sm->grafix.gameheight)
#define WXHALF (WXSIZE>>1)
#define WYHALF (WYSIZE>>1)

#define SCREEN 360	/* relativ position of the Screen (3D) */
#define FLUCHT (-80)	/*  */
#define WALLHEIGHT 80   /* wall-height / 2  */
#define SMILEYHEIGHT 100 /* Smileyheight */
#define SHOTHEIGHT 40   /* shotheight */
#define SMSCALE 1.6
#define STSCALE 4.0

#define MAXPLAYERS 32	 /* max. players (don't change) */
#define MAXSHOTS 16
#define MAZEDIMENSION 64 /* Groesse eines Mazes (maximal) */
#define BPL 128		 /* Bytes per Line (Maze) */
#define SCALE 20	 /* Vergroesserungsfaktor (Screen) */

#define SICHTWEITE 11	/* visual range in fields */

#define JOY_UP     0x01	/* OR-Codes for Joy-Values */
#define JOY_DOWN   0x02
#define JOY_LEFT   0x04
#define JOY_RIGHT  0x08
#define JOY_RADAR  0x10
#define JOY_HIDE   0x20
#define JOY_SLOW   0x40
#define JOY_BUTTON 0x80

#define PRADIUS 0x40
#define SRADIUS 0x20

#define SHOTPOWER 1000 /* classic */
#define STARTFITNESS 2000
#define RECHARGETIME 36 /* classic */
#define REFITSPEED  2
#define DEADTIME 200

#define WINNERANZ 10

#define MAXNAME 16
#define MAXCOMMENT 70

#define MAPSIZE 100

/* GAME-MODES ('-' = not used) */
#define GM_CLASSIC         0x0000 /* no options selectd */
#define GM_REFLECTINGSHOTS 0x0001 /* shots can bounce */
#define GM_DECAYINGSHOTS   0x0002 /* shots lose power */
#define GM_MULTIPLESHOTS   0x0004 /* allow more than one shot */
#define GM_WEAKINGSHOTS    0x0008 /* shooting weaks the player */
#define GM_REPOWERONKILL   0x0010 /* - repower player, if he kills an enemy */
#define GM_FASTRECHARGE    0x0020 /* faster recharg */
#define GM_FASTWALKING     0x0040 /* double-speed-walking */
#define GM_SHOWGHOST       0x0080 /* - ghostmode */
#define GM_ALLOWHIDE       0x0100 /* allow hideing */
#define GM_ALLOWRADAR      0x0200 /* allow radar */
#define GM_DESTRUCTSHOTS   0x1000 /* - destruct shots on kill */
#define GM_DECSCORE        0x2000 /* - decrease score of a killed player */
#define GM_RANKSCORE       0x4000 /* - rankingdependend score-bonus */
#define GM_TEAMSHOTHURT   0x8000 /* Shots from others on team hurt */

/* maze-data defines: */
#define MAZE_TYPEMASK     0x000f
#define MAZE_BLOCK_PLAYER 0x0010
#define MAZE_BLOCK_SHOT   0x0020


struct fd_mask
{
  u_int fds_bits[NOFILE/32+1];
};

/* Structur auf MAZE. Here is all important maze-stuff */

typedef struct {
 /*
  MAZE *prev_maze;
  MAZE *next_maze;
 */
  int hwalls[MAZEDIMENSION][MAZEDIMENSION];
  int vwalls[MAZEDIMENSION][MAZEDIMENSION];

  int xdim;
  int ydim;
  char *setlist;
  int *bitlist;
} MAZE;

/* PLAYER-Struct */

typedef struct {
  int sx;
  int sy;
  int sxd;
  int syd;
  int  salive;
  int power;
  int  next; /* next shot in chain */
  int  last; /* last shot in chain */
} SHOT;

typedef struct {
  int gamemode;
  int shots;
  int hits;
  int kills;
  int ownhits;
  int ownkills;
  int hitpnt;
  int hitby[64];
  int hitpower[64];
} STATISTIC;

typedef struct {
  short shot_power;
  short shot_weaking;
  short bounce_decay; /* 16384 = 1.0 */
  short shot_decay;   /* ! */
  short startfitness; /* ! */
  short deadtime;     /* ! */
  short max_shots;
  short repower; /* ! */
  short rechargetime; /* ! */
  short recolour_delay; /* ! */
  short angle_step; /* ! */
  short kills2win; /* ! */
  int   divider; /* ! */
  int   armageddon; /* time before armageddon is activated */
} CONFIG;

typedef struct {
  char name[MAXNAME+1];
  char comment[MAXCOMMENT+1];
  int team;
  int x;
  int y;
  int winkel;
  int fitness;
  int follow;
  int hide,radar;
  int ownkills;       /* number of deaths */
  int ownkiller;      /* playernumber of latest killer */
  int killanz;        /* number of kills */
  int killtable[256]; /* table of killed players */
  int alive;          /* alive? */

  SHOT shots[MAXSHOTS];
  int shotqueue1;
  int shotqueue2;
  int numofshots;

  int  recharge;
  int  hitbycnt;
  int  hitby;
  int  statchg; /* Status changed .. (redraw) */
  int  killchg;
  int  active;

  STATISTIC stat;
} PLAYER;

typedef struct {
  int kills;
  char teamname[MAXNAME+1];
} TEAM;

typedef struct {
  int x1,h1;
  int x2,h2;
  int ident;
  int rclip,lclip;
  int xd,yd;
  int rmax,rmin;
  int  clipped; /* need for texture */
} WALL;

typedef struct {
  Display    *display;
  Display    *display1;
  int        screen;
  Window     root;
  Drawable   gamefg;
  Drawable   gamebg;
  int        gamewidth;
  int        gameheight;
  Drawable   statusfg;
  Drawable   killfg;
  Drawable   mapfg;
  Drawable   mapbg;
  Colormap   cmap;
  GC         gc;
  XImage    *ximg;
  char      *imagebuf;
  XWindowAttributes attribute;
  XSizeHints shint;
  XSizeHints sthint;
  XSizeHints khint;
} GRAFIX;

typedef struct {
 GC xgc;
 GC facegc;
 XColor col;
} PGRAFIX;

struct texture 
{
  char *data;     /* buffer */
  char **datatab; /* pointertab */
  char *jmptab;   /* jumptab */
  char *jmptabh;  /* jmptab , halfheight */
  short (*divtab)[2];
  short (*divtabh)[2];
  int width;      /* texturewidth */
  int height;     /* tetxureheight */
  int hshift;     /* textureheight shift (*height) */
  int hshifth;    /* hshift, halfheight */
  int wshift;     /* widthshift */
  int jshift;     /* jumptableshift */
  int jshifth;    /* jumptableshifthalf */
  int hhalf;      /* half height */
  int whalf;      /* half width */
  int hmask;      /* height mask (height-1) */
  int wmask;      /* width mask */
  int hmaskh;     /* hmask half height */
  int precalc;    /* have precalculated datas? */
};

typedef struct mapmark {
        int     x,y;
        int     player;
} mapmark;

struct shared_struct /* the most should be volatile */
{
  int shmid;                       /* Shared Memory id */
  char ownname[MAXNAME+1];         /* Playername */
  char owncomment[MAXCOMMENT+1];   /* Comment, if you kill another one */
  char hostname[256];              /* Remotehostname */

  volatile int winner;             /* Winner-Number */
  int anzplayers;                  /* Number of Players */
  int numteams;                    /* Number of Teams */
  int shownumber,shownumbertmp;    /* Player-View-Number */
  int joynumber;                   /* Player-Joy-Number (Solo) */
  int gamemode;			   /* GAME-MODES: not supported yet */
  CONFIG config;                   /* important configurevalues */
  int armageddon;
  PLAYER playfeld[MAXPLAYERS];     /* Player-Data-Field */
  PLAYER playfeld1[MAXPLAYERS];    /* Copy */
  TEAM teams[MAXPLAYERS];          /* team-data */
  PGRAFIX pgfx[MAXPLAYERS];        /* Player-Grafix-datas */
  int sticks[MAXPLAYERS];          /* Stick/Cursor/Mouse-Data */
  int ownstick;                    /* Joystick-Data on this machine */
  MAZE std_maze;                   /* MAZE-DATA */
  GRAFIX grafix;                   /* Grafix-(X11)-Data */
  XSegment maplines[1000];         /* Map-Line-Buffer */
  int anzlines;
  int marks;                       /* # markers */
  mapmark markers[32];             /* Map markers */
  int rndshiftpos;                 /* Random */
  int rndshifttab[55];            /* more random-stuff */
  volatile unsigned int drawwait; /* delay Draw .. */

  /* flags */
  volatile int gameflag:1;             /* Game-is-running-flag */
  int exitprg:1;                       /* Exitflag */
  int bgdraw:1,redraw:1;               /* Mainwindowredrawflag */
  int screendraw:1,winnerdraw:1;       /* more Mainwindowredrawflags */
  int statchg:1,statchg1:1,statchg2:1; /* Statusredrawflags */
  int killchg:1;                       /* Killsredrawflags */
  int sologame:1,mapdraw:1,debug:1;    /* Solomode-,Mapdraw-,Debugflag */
  int newmap:1,locator:1;
  int monomode:1,graymode:1,dithermode:1; /* Screenoutputflags */
  int camera:1,directdraw:1,usesound:1;	  /* client in camera-mode,no bg,sound */
  int texturemode:1,privatecmap:1;
  int noshmem:1;
  int outputsize;                      /* Outputsize */
};