comparison src/defs.h @ 3:cafa94d86546

Initial revision
author darius
date Sat, 06 Dec 1997 04:37:01 +0000
parents
children b7fe2e0e4b86
comparison
equal deleted inserted replaced
2:2719a89505ba 3:cafa94d86546
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 */
99 #define DETDIST 1800 /* At this range a torp can be detonated */
100 /* was 1600. 6/29/92 TC */
101 /* was 1800 8/1/92 TC */
102 #define NEWDETDIST 1800
103
104 #define PHASEDIST 6000 /* At this range a player can do damage with
105 * phasers -- outdated */
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
110 * orbit */
111 #define PFIREDIST 1500 /* At this range a planet will shoot at a
112 * player */
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
116 * asteroid per speed factor */
117 #define MIN_AST_HIT 2 /* the minimum chance of hitting an asteroid */
118
119 #define TORP_HIT_AST 8
120 #define PLASMA_HIT_AST 12 /* percent for asteroid collisions. */
121 #define FIGHTER_HIT_AST 3
122 #define MISSILE_HIT_AST 5
123
124 #define VACANT -1 /* indicates vacant port on a starbase */
125 #define PDAMAGE -2 /* indicates damaged port on a starbase */
126 #define DOCKDIST 600
127
128 #define TRACTDIST 6000 /* maximum effective tractor beam range */
129
130 #define TICKSPERSEC 10 /* clock ticks per second */
131 #define UPDATE (1000000/TICKSPERSEC) /* Update time is 100000
132 * micro-seconds */
133 #define AUTOQUIT 60 /* auto logout in 60 secs */
134 #define SECONDS(s) (TICKSPERSEC*s)
135 #define MINUTES(s) (60*SECONDS(s))
136
137 /* These are memory sections */
138 #define PLAYER 1
139 #define MAXMESSAGE 50
140 #define MAXREVIEWMESSAGE 20
141
142 #define rosette(x) ((((x) + 8) / 16) & 15)
143 /* #define rosette(x) ((((x) + 256/VIEWS/2) / (256/VIEWS) + VIEWS) % VIEWS) */
144 /* (((x + 8) / 16 + 16) % 16) */
145
146 /* These are the teams */
147 /*
148 * Note that I used bit types for these mostly for messages and war status.
149 * This was probably a mistake. It meant that Ed had to add the 'remap' area
150 * to map these (which are used throughout the code as the proper team
151 * variable) into a nice four team deep array for his color stuff. Oh well.
152 */
153 #define NOBODY 0x0
154 #define FED 0x1
155 #define ROM 0x2
156 #define KLI 0x4
157 #define ORI 0x8
158 #define ALLTEAM (FED|ROM|KLI|ORI)
159 #define MAXTEAM (ORI) /* was ALLTEAM (overkill?) 6/22/92 TMC */
160 #define NUMTEAM 4
161 /*
162 * * These are random configuration variables
163 */
164 #define VICTORY 3 /* Number of systems needed to conquer the
165 * galaxy */
166 #define WARNTIME 30 /* Number of updates to have a warning on the
167 * screen */
168 #define MESSTIME 30 /* Number of updates to have a message on the
169 * screen */
170
171 #define BUILD_SB_TIME 30 /* Minutes to rebuild an SB */
172 #define BUILD_JS_TIME 15 /* Minutes to rebuild an JS 1-24 bjg */
173 #define BUILD_WA_TIME 45 /* Minutes to rebuild an WA 1-24 bjg */
174
175 #define TARG_PLAYER 0x1 /* Flags for gettarget */
176 #define TARG_PLANET 0x2
177 #define TARG_CLOAK 0x4 /* Include cloaked ships in search */
178 #define TARG_SELF 0x8
179
180 /* Data files to make the game play across daemon restarts. */
181
182 #ifdef LEAGUE_SUPPORT
183 #define PLAYERFILE (status2->league ? "/tmp/tourney.players":"etc/db.players")
184 #else
185 #define PLAYERFILE "etc/db.players"
186 #endif
187 #define GLOBAL "etc/db.global"
188 #define PLFILE "etc/planets"
189 #define MOTD "etc/motd"
190 #define WCMOTD "etc/motd.wc" /* wrong client message */
191 #define CLOSEDMOTD "etc/motd.closed" /* if doesn't exist, MOTD is
192 * used. */
193 #define PICS "etc/conf.pics"
194 #define NTSERV "bin/ntserv"
195 #define DAEMON "bin/daemonII"
196 #define ROBOT "bin/robotII"
197 #define LOGFILENAME "logs/server.log"
198 #define CONQFILE "logs/conquer"
199 #define SYSDEF_FILE "etc/conf.sysdef"
200 #define RSA_KEY_FILE "etc/rsa.keys"
201 #define GODLOGFILE "logs/god.log"
202 #define CLUEPHRASEFILE "etc/cluephrases"
203 #define MAILCLUECHECK "bin/mailcluecheck"
204
205 /*
206 * If this isn't defined, the "Count: n players" messages will go into
207 * logfile, as before. Otherwise, they'll go into this file:
208 */
209 /* #define COUNTFILENAME "logs/countfile" */
210
211 /* Listen stuff */
212 #define METASERVER "metaserver.ecst.csuchico.edu"
213 #define PORT 2592 /* port to listen on */
214
215 /* Other stuff that Ed added */
216
217 #define ABS(a) /* abs(a) */ (((a) < 0) ? -(a) : (a))
218 #ifndef MAX
219 #define MAX(a,b) ((a) > (b) ? (a) : (b))
220 #endif
221 #ifndef MIN
222 #define MIN(a,b) ((a) < (b) ? (a) : (b))
223 #endif
224
225 #define myPlasmaTorp(t) (me->p_no == (t)->pt_owner)
226 #define myTorp(t) (me->p_no == (t)->t_owner)
227 #define myMissile(t) (me->p_no == (t)->ms_owner)
228 #define friendlyPlasmaTorp(t) ((!(me->p_team & (t)->pt_war)) || (myPlasmaTorp(t)))
229 #define friendlyTorp(t) (((!(me->p_team & (t)->t_war)) && \
230 (!(t->t_team & (me->p_swar | me->p_hostile)))) || \
231 (myTorp(t)))
232 #define friendlyMissile(t) (((!(me->p_team & (t)->ms_war)) && \
233 (!(t->ms_team & (me->p_swar | me->p_hostile)))) || \
234 (myMissile(t)))
235 #define myPhaser(p) (&phasers[me->p_no] == (p))
236 #define friendlyPhaser(p) (me->p_team == players[(p) - phasers].p_team)
237 #define myPlayer(p) (me == (p))
238 #define myPlanet(p) (me->p_team == (p)->pl_owner)
239 #define friendlyPlayer(p) ((!(me->p_team & \
240 ((p)->p_swar | (p)->p_hostile))) && \
241 (!((p)->p_team & \
242 (me->p_swar | me->p_hostile))))
243 #define isAlive(p) ((p)->p_status == PALIVE)
244 #define friendlyPlanet(p) ((p)->pl_info & me->p_team && \
245 !((p)->pl_owner & (me->p_swar | me->p_hostile)))
246
247 #if 0
248 #define torpColor(t) \
249 (myTorp(t) ? myColor : shipCol[remap[players[(t)->t_owner].p_team]])
250 #define plasmatorpColor(t) \
251 (myPlasmaTorp(t) ? myColor : shipCol[remap[players[(t)->pt_owner].p_team]])
252 #define phaserColor(p) \
253 (myPhaser(p) ? myColor : shipCol[remap[players[(p) - phasers].p_team]])
254 /*
255 * Cloaking phase (and not the cloaking flag) is the factor in determining
256 * the color of the ship. Color 0 is white (same as 'myColor' used to be).
257 */
258 #define playerColor(p) \
259 (myPlayer(p) ? \
260 (cloak_pixels[0][me->p_cloakphase]) \
261 : (cloak_pixels[remap[(p)->p_team]][(p)->p_cloakphase]))
262 #define planetColor(p) \
263 (((p)->pl_info & me->p_team) ? shipCol[remap[(p)->pl_owner]] : unColor)
264
265 #define planetFont(p) \
266 (myPlanet(p) ? bfont : friendlyPlanet(p) ? ifont : dfont)
267 #define shipFont(p) \
268 (myPlayer(p) ? bfont : friendlyPlayer(p) ? ifont : dfont)
269 #endif
270
271 /*
272 * This macro allows us to time things based upon the SIGALRM signal. Given a
273 * number of 1/5 seconds, it will return the number of SIGALRMs we will
274 * receive in that period.
275 */
276 #define efticks(x) ((x)*200000/timerDelay)
277
278 /*
279 * UDP control stuff
280 */
281 #ifdef GATEWAY
282 #define UDP_NUMOPTS 11
283 #define UDP_GW UDP_NUMOPTS-1
284 #else
285 #define UDP_NUMOPTS 10
286 #endif
287 #define UDP_CURRENT 0
288 #define UDP_STATUS 1
289 #define UDP_DROPPED 2
290 #define UDP_SEQUENCE 3
291 #define UDP_SEND 4
292 #define UDP_RECV 5
293 #define UDP_DEBUG 6
294 #define UDP_FORCE_RESET 7
295 #define UDP_UPDATE_ALL 8
296 #define UDP_DONE 9
297 #define COMM_TCP 0
298 #define COMM_UDP 1
299 #define COMM_VERIFY 2
300 #define COMM_UPDATE 3
301 #define COMM_MODE 4 /* put this one last */
302 #define SWITCH_TCP_OK 0
303 #define SWITCH_UDP_OK 1
304 #define SWITCH_DENIED 2
305 #define SWITCH_VERIFY 3
306 #define CONNMODE_PORT 0
307 #define CONNMODE_PACKET 1
308 #define STAT_CONNECTED 0
309 #define STAT_SWITCH_UDP 1
310 #define STAT_SWITCH_TCP 2
311 #define STAT_VERIFY_UDP 3
312 #define MODE_TCP 0
313 #define MODE_SIMPLE 1
314 #define MODE_FAT 2
315 #define MODE_DOUBLE 3 /* put this one last */
316
317 #define UDP_RECENT_INTR 300
318 #define UDP_UPDATE_WAIT 5 /* 5 second wait */
319
320 /* server version of UDPDIAG */
321 /* (change these to "#define UDPDIAG(x) <return>" for smaller & faster code) */
322 #define UDPDIAG(x) { if (configvals->udpAllowed > 1) { printf("UDP: "); printf x; }}
323 #define V_UDPDIAG(x) { if (configvals->udpAllowed > 2) { printf("UDP: "); printf x; }}
324
325 #define FAE_RATE 8 /* The Fighter-Army exchange rate */
326 #define FTORP_DAMAGE 50
327 #define FTORP_SPEED 12
328 #define FTORP_FUSE 40
329 #define FTORP_TRACK 1
330
331 #define RSA_VERSION "RSA v2.0 SERVER" /* String must begin with "RSA v" */
332 #define KEY_SIZE 32
333 #define RESERVED_SIZE 16
334 #define MSG_LEN 80
335 #define NAME_LEN 16
336 #define KEYMAP_LEN 96
337
338 struct player;
339
340 void warning( /* char * */ );
341 int in_warp( /**/ );
342 void get_ship_for_player( /* struct player *me, int s_type */ );
343 void switch_special_weapon( /**/ );
344 void declare_war( /* int mask */ );
345 char *twoletters( /* struct player * */ );
346 void updateClient();
347
348
349 /* random number stuff */
350 #include <stdlib.h>
351
352 #ifdef HAVE_RAND48
353
354 #define MAXRAND 2147483648
355 extern long lrand48();
356 extern void srand48();
357 extern double drand48();
358
359 #else /* HAVE_RAND48 */
360
361 #ifdef HAVE_RANDOM
362
363 #define MAXRAND 2147483648
364 extern long random();
365 extern void srandom();
366
367 #else /* HAVE_RANDOM */
368
369 #define MAXRAND (RAND_MAX+1)
370 #define random rand
371 #define srandom srand
372 extern int rand();
373 #ifdef sparc
374 extern srand();
375 #else
376 extern void srand();
377 #endif
378
379 #endif /* HAVE_RANDOM */
380
381 #define lrand48 random
382 #define srand48(s) srandom((int)s)
383 #define drand48() ((double)random() / (double)MAXRAND)
384
385 #endif /* HAVE_RAND48 */
386
387
388 #endif /* defs_h_ */