Mercurial > ~darius > hgwebdir.cgi > paradise_server
annotate src/defs.h @ 17:65de6eb6861a
Indenting...
author | darius |
---|---|
date | Wed, 24 Dec 1997 12:37:24 +0000 |
parents | b7fe2e0e4b86 |
children |
rev | line source |
---|---|
3 | 1 /*-------------------------------------------------------------------------- |
2 NETREK II -- Paradise | |
3 | |
4 Permission to use, copy, modify, and distribute this software and its | |
5 documentation, or any derivative works thereof, for any NON-COMMERCIAL | |
6 purpose and without fee is hereby granted, provided that this copyright | |
7 notice appear in all copies. No representations are made about the | |
8 suitability of this software for any purpose. This software is provided | |
9 "as is" without express or implied warranty. | |
10 | |
11 Xtrek Copyright 1986 Chris Guthrie | |
12 Netrek (Xtrek II) Copyright 1989 Kevin P. Smith | |
13 Scott Silvey | |
14 Paradise II (Netrek II) Copyright 1993 Larry Denys | |
15 Kurt Olsen | |
16 Brandon Gillespie | |
17 --------------------------------------------------------------------------*/ | |
18 | |
19 #ifndef defs_h_ | |
20 #define defs_h_ | |
21 | |
22 | |
23 #ifdef SVR4 /* to get it to work under Solaris [BDyess] */ | |
24 #define sigsetmask sigset | |
25 #endif /* SVR4 */ | |
26 | |
27 #define MAXPLAYER 32 | |
28 | |
29 #define MAXPLANETS 60 /* A new variable called NUMPLANETS takes the | |
30 * place of this #define in many parts of the | |
31 * code -- this one just sets the initial | |
32 * array sizes, so it is, literally, a | |
33 * maximum */ | |
34 | |
35 #define MAX_GWIDTH 200000 /* GWIDTH is used in most of the code -- this | |
36 * is a max value. */ | |
37 #define TGRID_GRANULARITY 800 /* The width and height, in the same units as | |
38 * GWIDTH, of one terrain_grid unit. */ | |
39 #define NTERRAIN 128 /* number of bytes of zipped terrain data to | |
40 * send */ | |
41 /* at once */ | |
42 #define LOG2NTERRAIN 7 /* well, you should be able to figure this | |
43 * out */ | |
44 #define TERRAIN_MASK NTERRAIN-1 /* NTERRAIN should always be a power of 2, | |
45 * otherwise */ | |
46 /* updateTerrain() in socket.c will break */ | |
47 /* | |
48 * NOTE! NTERRAIN can *NEVER* be greater than 128 due to the way the | |
49 * structure | |
50 */ | |
51 /* | |
52 * and socket code work. This may eventually be a bummer when higher | |
53 * bandwidths | |
54 */ | |
55 /* | |
56 * are around, but for now with me & my linux box, this is just fine. | |
57 * Besides, | |
58 */ | |
59 /* | |
60 * preliminary tests show that the gzipped terrain grid to be usually less | |
61 * than | |
62 */ | |
63 /* 350 bytes anyway. */ | |
64 | |
65 #define TGRID_SIZE (MAX_GWIDTH/TGRID_GRANULARITY) | |
66 | |
67 #define MAXTORP 8 | |
68 | |
69 /* Parnes's (Raynfala's) Butt Torp Code */ | |
70 /* HALFARC = (0-128), FACTOR = (0-16) */ | |
71 | |
72 #define TORP_PENALTY_HALFARC myship->s_torp.wtemp_halfarc | |
73 #define TORP_PENALTY_FACTOR myship->s_torp.wtemp_factor | |
74 | |
75 #define NPTHINGIES 8 | |
76 #define NGTHINGIES 40 | |
77 #define TOTALTHINGIES (MAXPLAYER*NPTHINGIES + NGTHINGIES) | |
78 #define MAXPLASMA 1 | |
79 #define WINSIDE 500 /* Size of strategic and tactical windows */ | |
80 #define BORDER 4 /* border width for option windows */ | |
81 #define PSEUDOSIZE 16 | |
82 #define CLOAK_PHASES 7 /* number of drawing phases in a cloak | |
83 * engage/disengage */ | |
84 #define NUMRANKS 18 | |
85 #ifdef CASSIUS_ROYALTY | |
86 #define NUMROYALRANKS 10 | |
87 #else | |
88 #define NUMROYALRANKS 5 | |
89 #endif | |
90 #define GODLIKE (NUMROYALRANKS-2) | |
91 | |
92 /* These are configuration definitions */ | |
93 /* GWIDTH was once a #define, now it's a variable in the configvals */ | |
94 | |
95 #define WARP1 20 /* warp one will move 20 spaces per update */ | |
96 #define SCALE 40 /* Window will be one pixel for 20 spaces */ | |
97 #define SHIPDAMDIST 3000 /* At this range, an exploding ship does | |
98 * damage */ | |
14
b7fe2e0e4b86
Added #defines which hold the chance of nebulous terrain affecting
darius
parents:
3
diff
changeset
|
99 #define DETDIST 1800 /* At this range a torp can be detonated |
b7fe2e0e4b86
Added #defines which hold the chance of nebulous terrain affecting
darius
parents:
3
diff
changeset
|
100 was 1600. 6/29/92 TC |
b7fe2e0e4b86
Added #defines which hold the chance of nebulous terrain affecting
darius
parents:
3
diff
changeset
|
101 was 1800 8/1/92 TC */ |
3 | 102 #define NEWDETDIST 1800 |
103 | |
104 #define PHASEDIST 6000 /* At this range a player can do damage with | |
14
b7fe2e0e4b86
Added #defines which hold the chance of nebulous terrain affecting
darius
parents:
3
diff
changeset
|
105 * phasers -- outdated */ |
3 | 106 #define ENTORBDIST 900 /* At this range a player can orbit a planet */ |
107 #define ORBDIST 800 /* A player will orbit at this radius */ | |
108 #define FORBDIST 7500 /* The radius at which fighters patrol */ | |
109 #define ORBSPEED 2 /* This is the fastest a person can go into | |
14
b7fe2e0e4b86
Added #defines which hold the chance of nebulous terrain affecting
darius
parents:
3
diff
changeset
|
110 * orbit */ |
3 | 111 #define PFIREDIST 1500 /* At this range a planet will shoot at a |
14
b7fe2e0e4b86
Added #defines which hold the chance of nebulous terrain affecting
darius
parents:
3
diff
changeset
|
112 * player */ |
3 | 113 |
114 #define MIN_AST_DAMAGE 10 /* the minimum damage caused by an asteroid */ | |
115 #define VAR_AST_DAMAGE 5 /* the max additional damage caused by an | |
14
b7fe2e0e4b86
Added #defines which hold the chance of nebulous terrain affecting
darius
parents:
3
diff
changeset
|
116 * asteroid per speed factor */ |
3 | 117 #define MIN_AST_HIT 2 /* the minimum chance of hitting an asteroid */ |
118 | |
14
b7fe2e0e4b86
Added #defines which hold the chance of nebulous terrain affecting
darius
parents:
3
diff
changeset
|
119 #define TORP_NEB_EFF 40 /* percent for nebulous terrain to screw up tracking */ |
b7fe2e0e4b86
Added #defines which hold the chance of nebulous terrain affecting
darius
parents:
3
diff
changeset
|
120 #define PLASMA_NEB_EFF 30 |
b7fe2e0e4b86
Added #defines which hold the chance of nebulous terrain affecting
darius
parents:
3
diff
changeset
|
121 #define FIGHTER_NEB_EFF 20 |
b7fe2e0e4b86
Added #defines which hold the chance of nebulous terrain affecting
darius
parents:
3
diff
changeset
|
122 #define MISSILE_NEB_EFF 30 |
b7fe2e0e4b86
Added #defines which hold the chance of nebulous terrain affecting
darius
parents:
3
diff
changeset
|
123 |
3 | 124 #define TORP_HIT_AST 8 |
125 #define PLASMA_HIT_AST 12 /* percent for asteroid collisions. */ | |
126 #define FIGHTER_HIT_AST 3 | |
127 #define MISSILE_HIT_AST 5 | |
128 | |
129 #define VACANT -1 /* indicates vacant port on a starbase */ | |
130 #define PDAMAGE -2 /* indicates damaged port on a starbase */ | |
131 #define DOCKDIST 600 | |
132 | |
133 #define TRACTDIST 6000 /* maximum effective tractor beam range */ | |
134 | |
135 #define TICKSPERSEC 10 /* clock ticks per second */ | |
136 #define UPDATE (1000000/TICKSPERSEC) /* Update time is 100000 | |
137 * micro-seconds */ | |
138 #define AUTOQUIT 60 /* auto logout in 60 secs */ | |
139 #define SECONDS(s) (TICKSPERSEC*s) | |
140 #define MINUTES(s) (60*SECONDS(s)) | |
141 | |
142 /* These are memory sections */ | |
143 #define PLAYER 1 | |
144 #define MAXMESSAGE 50 | |
145 #define MAXREVIEWMESSAGE 20 | |
146 | |
147 #define rosette(x) ((((x) + 8) / 16) & 15) | |
148 /* #define rosette(x) ((((x) + 256/VIEWS/2) / (256/VIEWS) + VIEWS) % VIEWS) */ | |
149 /* (((x + 8) / 16 + 16) % 16) */ | |
150 | |
151 /* These are the teams */ | |
152 /* | |
153 * Note that I used bit types for these mostly for messages and war status. | |
154 * This was probably a mistake. It meant that Ed had to add the 'remap' area | |
155 * to map these (which are used throughout the code as the proper team | |
156 * variable) into a nice four team deep array for his color stuff. Oh well. | |
157 */ | |
158 #define NOBODY 0x0 | |
159 #define FED 0x1 | |
160 #define ROM 0x2 | |
161 #define KLI 0x4 | |
162 #define ORI 0x8 | |
163 #define ALLTEAM (FED|ROM|KLI|ORI) | |
164 #define MAXTEAM (ORI) /* was ALLTEAM (overkill?) 6/22/92 TMC */ | |
165 #define NUMTEAM 4 | |
166 /* | |
167 * * These are random configuration variables | |
168 */ | |
169 #define VICTORY 3 /* Number of systems needed to conquer the | |
170 * galaxy */ | |
171 #define WARNTIME 30 /* Number of updates to have a warning on the | |
172 * screen */ | |
173 #define MESSTIME 30 /* Number of updates to have a message on the | |
174 * screen */ | |
175 | |
176 #define BUILD_SB_TIME 30 /* Minutes to rebuild an SB */ | |
177 #define BUILD_JS_TIME 15 /* Minutes to rebuild an JS 1-24 bjg */ | |
178 #define BUILD_WA_TIME 45 /* Minutes to rebuild an WA 1-24 bjg */ | |
179 | |
180 #define TARG_PLAYER 0x1 /* Flags for gettarget */ | |
181 #define TARG_PLANET 0x2 | |
182 #define TARG_CLOAK 0x4 /* Include cloaked ships in search */ | |
183 #define TARG_SELF 0x8 | |
184 | |
185 /* Data files to make the game play across daemon restarts. */ | |
186 | |
187 #ifdef LEAGUE_SUPPORT | |
188 #define PLAYERFILE (status2->league ? "/tmp/tourney.players":"etc/db.players") | |
189 #else | |
190 #define PLAYERFILE "etc/db.players" | |
191 #endif | |
192 #define GLOBAL "etc/db.global" | |
193 #define PLFILE "etc/planets" | |
194 #define MOTD "etc/motd" | |
195 #define WCMOTD "etc/motd.wc" /* wrong client message */ | |
196 #define CLOSEDMOTD "etc/motd.closed" /* if doesn't exist, MOTD is | |
197 * used. */ | |
198 #define PICS "etc/conf.pics" | |
199 #define NTSERV "bin/ntserv" | |
200 #define DAEMON "bin/daemonII" | |
201 #define ROBOT "bin/robotII" | |
202 #define LOGFILENAME "logs/server.log" | |
203 #define CONQFILE "logs/conquer" | |
204 #define SYSDEF_FILE "etc/conf.sysdef" | |
205 #define RSA_KEY_FILE "etc/rsa.keys" | |
206 #define GODLOGFILE "logs/god.log" | |
207 #define CLUEPHRASEFILE "etc/cluephrases" | |
208 #define MAILCLUECHECK "bin/mailcluecheck" | |
209 | |
210 /* | |
211 * If this isn't defined, the "Count: n players" messages will go into | |
212 * logfile, as before. Otherwise, they'll go into this file: | |
213 */ | |
214 /* #define COUNTFILENAME "logs/countfile" */ | |
215 | |
216 /* Listen stuff */ | |
217 #define METASERVER "metaserver.ecst.csuchico.edu" | |
218 #define PORT 2592 /* port to listen on */ | |
219 | |
220 /* Other stuff that Ed added */ | |
221 | |
222 #define ABS(a) /* abs(a) */ (((a) < 0) ? -(a) : (a)) | |
223 #ifndef MAX | |
224 #define MAX(a,b) ((a) > (b) ? (a) : (b)) | |
225 #endif | |
226 #ifndef MIN | |
227 #define MIN(a,b) ((a) < (b) ? (a) : (b)) | |
228 #endif | |
229 | |
230 #define myPlasmaTorp(t) (me->p_no == (t)->pt_owner) | |
231 #define myTorp(t) (me->p_no == (t)->t_owner) | |
232 #define myMissile(t) (me->p_no == (t)->ms_owner) | |
233 #define friendlyPlasmaTorp(t) ((!(me->p_team & (t)->pt_war)) || (myPlasmaTorp(t))) | |
234 #define friendlyTorp(t) (((!(me->p_team & (t)->t_war)) && \ | |
235 (!(t->t_team & (me->p_swar | me->p_hostile)))) || \ | |
236 (myTorp(t))) | |
237 #define friendlyMissile(t) (((!(me->p_team & (t)->ms_war)) && \ | |
238 (!(t->ms_team & (me->p_swar | me->p_hostile)))) || \ | |
239 (myMissile(t))) | |
240 #define myPhaser(p) (&phasers[me->p_no] == (p)) | |
241 #define friendlyPhaser(p) (me->p_team == players[(p) - phasers].p_team) | |
242 #define myPlayer(p) (me == (p)) | |
243 #define myPlanet(p) (me->p_team == (p)->pl_owner) | |
244 #define friendlyPlayer(p) ((!(me->p_team & \ | |
245 ((p)->p_swar | (p)->p_hostile))) && \ | |
246 (!((p)->p_team & \ | |
247 (me->p_swar | me->p_hostile)))) | |
248 #define isAlive(p) ((p)->p_status == PALIVE) | |
249 #define friendlyPlanet(p) ((p)->pl_info & me->p_team && \ | |
250 !((p)->pl_owner & (me->p_swar | me->p_hostile))) | |
251 | |
252 #if 0 | |
253 #define torpColor(t) \ | |
254 (myTorp(t) ? myColor : shipCol[remap[players[(t)->t_owner].p_team]]) | |
255 #define plasmatorpColor(t) \ | |
256 (myPlasmaTorp(t) ? myColor : shipCol[remap[players[(t)->pt_owner].p_team]]) | |
257 #define phaserColor(p) \ | |
258 (myPhaser(p) ? myColor : shipCol[remap[players[(p) - phasers].p_team]]) | |
259 /* | |
260 * Cloaking phase (and not the cloaking flag) is the factor in determining | |
261 * the color of the ship. Color 0 is white (same as 'myColor' used to be). | |
262 */ | |
263 #define playerColor(p) \ | |
264 (myPlayer(p) ? \ | |
265 (cloak_pixels[0][me->p_cloakphase]) \ | |
266 : (cloak_pixels[remap[(p)->p_team]][(p)->p_cloakphase])) | |
267 #define planetColor(p) \ | |
268 (((p)->pl_info & me->p_team) ? shipCol[remap[(p)->pl_owner]] : unColor) | |
269 | |
270 #define planetFont(p) \ | |
271 (myPlanet(p) ? bfont : friendlyPlanet(p) ? ifont : dfont) | |
272 #define shipFont(p) \ | |
273 (myPlayer(p) ? bfont : friendlyPlayer(p) ? ifont : dfont) | |
274 #endif | |
275 | |
276 /* | |
277 * This macro allows us to time things based upon the SIGALRM signal. Given a | |
278 * number of 1/5 seconds, it will return the number of SIGALRMs we will | |
279 * receive in that period. | |
280 */ | |
281 #define efticks(x) ((x)*200000/timerDelay) | |
282 | |
283 /* | |
284 * UDP control stuff | |
285 */ | |
286 #ifdef GATEWAY | |
287 #define UDP_NUMOPTS 11 | |
288 #define UDP_GW UDP_NUMOPTS-1 | |
289 #else | |
290 #define UDP_NUMOPTS 10 | |
291 #endif | |
292 #define UDP_CURRENT 0 | |
293 #define UDP_STATUS 1 | |
294 #define UDP_DROPPED 2 | |
295 #define UDP_SEQUENCE 3 | |
296 #define UDP_SEND 4 | |
297 #define UDP_RECV 5 | |
298 #define UDP_DEBUG 6 | |
299 #define UDP_FORCE_RESET 7 | |
300 #define UDP_UPDATE_ALL 8 | |
301 #define UDP_DONE 9 | |
302 #define COMM_TCP 0 | |
303 #define COMM_UDP 1 | |
304 #define COMM_VERIFY 2 | |
305 #define COMM_UPDATE 3 | |
306 #define COMM_MODE 4 /* put this one last */ | |
307 #define SWITCH_TCP_OK 0 | |
308 #define SWITCH_UDP_OK 1 | |
309 #define SWITCH_DENIED 2 | |
310 #define SWITCH_VERIFY 3 | |
311 #define CONNMODE_PORT 0 | |
312 #define CONNMODE_PACKET 1 | |
313 #define STAT_CONNECTED 0 | |
314 #define STAT_SWITCH_UDP 1 | |
315 #define STAT_SWITCH_TCP 2 | |
316 #define STAT_VERIFY_UDP 3 | |
317 #define MODE_TCP 0 | |
318 #define MODE_SIMPLE 1 | |
319 #define MODE_FAT 2 | |
320 #define MODE_DOUBLE 3 /* put this one last */ | |
321 | |
322 #define UDP_RECENT_INTR 300 | |
323 #define UDP_UPDATE_WAIT 5 /* 5 second wait */ | |
324 | |
325 /* server version of UDPDIAG */ | |
326 /* (change these to "#define UDPDIAG(x) <return>" for smaller & faster code) */ | |
327 #define UDPDIAG(x) { if (configvals->udpAllowed > 1) { printf("UDP: "); printf x; }} | |
328 #define V_UDPDIAG(x) { if (configvals->udpAllowed > 2) { printf("UDP: "); printf x; }} | |
329 | |
330 #define FAE_RATE 8 /* The Fighter-Army exchange rate */ | |
331 #define FTORP_DAMAGE 50 | |
332 #define FTORP_SPEED 12 | |
333 #define FTORP_FUSE 40 | |
334 #define FTORP_TRACK 1 | |
335 | |
336 #define RSA_VERSION "RSA v2.0 SERVER" /* String must begin with "RSA v" */ | |
337 #define KEY_SIZE 32 | |
338 #define RESERVED_SIZE 16 | |
339 #define MSG_LEN 80 | |
340 #define NAME_LEN 16 | |
341 #define KEYMAP_LEN 96 | |
342 | |
343 struct player; | |
344 | |
345 void warning( /* char * */ ); | |
346 int in_warp( /**/ ); | |
347 void get_ship_for_player( /* struct player *me, int s_type */ ); | |
348 void switch_special_weapon( /**/ ); | |
349 void declare_war( /* int mask */ ); | |
350 char *twoletters( /* struct player * */ ); | |
351 void updateClient(); | |
352 | |
353 | |
354 /* random number stuff */ | |
355 #include <stdlib.h> | |
356 | |
357 #ifdef HAVE_RAND48 | |
358 | |
359 #define MAXRAND 2147483648 | |
360 extern long lrand48(); | |
361 extern void srand48(); | |
362 extern double drand48(); | |
363 | |
364 #else /* HAVE_RAND48 */ | |
365 | |
366 #ifdef HAVE_RANDOM | |
367 | |
368 #define MAXRAND 2147483648 | |
369 extern long random(); | |
370 extern void srandom(); | |
371 | |
372 #else /* HAVE_RANDOM */ | |
373 | |
374 #define MAXRAND (RAND_MAX+1) | |
375 #define random rand | |
376 #define srandom srand | |
377 extern int rand(); | |
378 #ifdef sparc | |
379 extern srand(); | |
380 #else | |
381 extern void srand(); | |
382 #endif | |
383 | |
384 #endif /* HAVE_RANDOM */ | |
385 | |
386 #define lrand48 random | |
387 #define srand48(s) srandom((int)s) | |
388 #define drand48() ((double)random() / (double)MAXRAND) | |
389 | |
390 #endif /* HAVE_RAND48 */ | |
391 | |
392 | |
393 #endif /* defs_h_ */ |