1 #ifndef _h_defs 2 #define _h_defs 3 4 #include "copyright.h" 5 6 /* #$!@$#% length of address field of messages */ 7 #define ADDRLEN 10 8 9 #ifdef NBT 10 #define MAX_MACRO 500 11 #endif 12 13 #ifndef MAXPLAYER 14 #define MAXPLAYER 36 /* Defined in config.h as well */ 15 #endif 16 17 #define TESTERS 4 /* Priveledged slots for 18 * robots and game 'testers' */ 19 #define MAXPLANETS 40 20 #define MAXTORP 8 21 #define MAXPLASMA 1 22 #define PKEY 128 23 24 25 #define GWINSIDE (small_screen ? 400 : 500) /* size of strategic window */ 26 #define TWINSIDE 500 /* size of tactical window */ 27 28 #define BORDER 3 /* border width for option * 29 * 30 * * windows */ 31 #define PSEUDOSIZE 16 32 /*! @brief number of drawing phases in a cloak engage and disengage 33 @details refer to udcloak() in server source, once p_cloakphases 34 reaches one less than this value, position is randomised and 35 updated slowly by server. This value was 7 for COW 2.02 with a 36 server configured for five updates per second. Server changed to 37 ten updates per second and broke the calculations. Now matches 38 server value adjusted for updates per second. */ 39 #define CLOAK_PHASES (12 * server_ups / 10) 40 #define DEFAULT_NUMRANKS 9 41 42 /* These are configuration definitions */ 43 44 #define GWIDTH 100000 /* galaxy is 100000 spaces * 45 * 46 * * on a side */ 47 #define WARP1 20 /* warp one will move 20 * * 48 * spaces per update */ 49 #define SCALE 40 /* Window will be one pixel 50 * * * for 20 spaces */ 51 #define EXPDIST 350 /* At this range a torp will 52 * * * explode */ 53 #define DETDIST 1700 /* At this range a player * 54 * * can detonate a torp */ 55 #define NUM_PLANET_BITMAPS 7 56 #define NUM_PLANET_BITMAPS2 8 57 58 #define PHASEDIST 6000 /* At this range a player * 59 * * can do damage with * * 60 * phasers */ 61 #define ENTORBDIST 900 /* At this range a player * 62 * * can orbit a planet */ 63 #define ORBDIST 800 /* A player will orbit at * 64 * * this radius */ 65 #define ORBSPEED 2 /* This is the fastest a * * 66 * person can go into orbit */ 67 #define PFIREDIST 1500 /* At this range a planet * 68 * * will shoot at a player */ 69 70 /* 6 minutes is maximum for autoquit -- anything more causes problems in the 71 * server. (?) */ 72 #define AUTOQUIT 9*60 /* auto logout in 5 minutes */ 73 74 #define VACANT -1 /* indicates vacant port on 75 * a starbase */ 76 #define DOCKDIST 600 77 #define DOCKSPEED 2 /* If base is moving, there 78 * will be some finesse 79 * involved to dock */ 80 #define NUMPORTS 4 81 #define SBFUELMIN 10000 /* If starbase's fuel is 82 * less than this, it will 83 * not refuel docked vessels */ 84 #define TRACTDIST 6000 /* maximum effective tractor 85 * beam range */ 86 #define TRACTEHEAT 5 /* ammount tractor beams 87 * heat engines */ 88 #define TRACTCOST 20 /* fuel cost of activated 89 * tractor beam */ 90 91 92 #define KEY_SIZE 32 93 #define RESERVED_SIZE 16 94 #define NAME_LEN 16 95 #define KEYMAP_LEN 96 96 97 #define MSG_LEN 80 98 99 100 /* These are memory sections */ 101 #define PLAYER 1 102 #define MAXMESSAGE 50 103 #define MAXREVIEWMESSAGE 20 104 105 #define rosette(x) ((((x) + 8) / 16) & 15) 106 /* #define rosette(x) ((((x) + 256/VIEWS/2) / (256/VIEWS) + VIEWS) % VIEWS) */ 107 /* (((x + 8) / 16 + 16) % 16) */ 108 109 /* These are the teams */ 110 /* Note that I used bit types for these mostly for messages and war status. 111 * This was probably a mistake. It meant that Ed had to add the 'remap' area 112 * to map these (which are used throughout the code as the proper team 113 * variable) into a nice four team deep array for his color stuff. Oh well. */ 114 #define NOBODY 0x0 115 #define FED 0x1 116 #define ROM 0x2 117 #define KLI 0x4 118 #define ORI 0x8 119 #define ALLTEAM (FED|ROM|KLI|ORI) 120 #define MAXTEAM (ORI) 121 #define NUMTEAM 4 122 /* * These are random configuration variables */ 123 #define VICTORY 3 /* Number of systems needed 124 * to conquer the galaxy */ 125 #define WARNTIME 30 /* Number of 1/10th seconds to have 126 * a warning on the screen */ 127 128 #define TARG_PLAYER 0x1 /* Flags for gettarget */ 129 #define TARG_PLANET 0x2 130 #define TARG_CLOAK 0x4 /* Include cloaked ships in 131 * search */ 132 #define TARG_SELF 0x8 133 #define TARG_ENEMY 0x10 134 #define TARG_FRIEND 0x20 135 136 137 #define DEFAULT_PORT 2592 138 139 /* Other stuff that Ed added */ 140 141 #define ABS(a) /* abs(a) */ (((a) < 0) ? -(a) : (a)) 142 143 #ifndef MAX 144 #define MAX(a,b) ((a) > (b) ? (a) : (b)) 145 #endif 146 147 #ifndef MIN 148 #define MIN(a,b) ((a) < (b) ? (a) : (b)) 149 #endif 150 151 #define myPlasmaTorp(t) (me->p_no == (t)->pt_owner) 152 #define myTorp(t) (me->p_no == (t)->t_owner) 153 #define friendlyPlasmaTorp(t) ((!(me->p_team & (t)->pt_war)) || (myPlasmaTorp(t))) 154 #define friendlyTorp(t) ((!(me->p_team & (t)->t_war)) || (myTorp(t))) 155 #define myPhaser(p) (&phasers[me->p_no] == (p)) 156 #define friendlyPhaser(p) (me->p_team == players[(p) - phasers].p_team) 157 #define myPlayer(p) (me == (p)) 158 #define myPlanet(p) (me->p_team == (p)->pl_owner) 159 #define friendlyPlayer(p) ((!(me->p_team & \ 160 ((p)->p_swar | (p)->p_hostile))) && \ 161 (!((p)->p_team & \ 162 (me->p_swar | me->p_hostile)))) 163 #define isAlive(p) (((p)->p_status == PALIVE) || ((p)->p_status == POBSERV)) 164 #define friendlyPlanet(p) ((p)->pl_info & me->p_team && \ 165 !((p)->pl_owner & (me->p_swar | me->p_hostile))) 166 167 #define isLockPlanet(p) ((me->p_flags & PFPLLOCK) && (me->p_planet == p->pl_no)) 168 #define isLockPlayer(p) ((me->p_flags & PFPLOCK) && (me->p_playerl == p->p_no)) 169 #define isObsLockPlayer(p) ((me->p_flags & PFOBSERV) && (me->p_flags & PFPLOCK) && \ 170 (me->p_playerl == (p)->p_no)) 171 #define torpColor(t) \ 172 ((myTorp(t) || isObsLockPlayer(&players[(t)->t_owner])) ? myColor : shipCol[remap[players[(t)->t_owner].p_team]]) 173 #define plasmatorpColor(t) \ 174 ((myPlasmaTorp(t) || isObsLockPlayer(&players[(t)->pt_owner])) ? myColor : shipCol[remap[players[(t)->pt_owner].p_team]]) 175 #define phaserColor(p) \ 176 ((myPhaser(p) || isObsLockPlayer(&players[(p) - phasers])) ? myColor : shipCol[remap[players[(p) - phasers].p_team]]) 177 /* Cloaking phase (and not the cloaking flag) is the factor in determining 178 * the color of the ship. Color 0 is white (same as 'myColor' used to be). */ 179 #define playerColor(p) \ 180 ((myPlayer(p) || isObsLockPlayer(p)) ? myColor : shipCol[remap[(p)->p_team]]) 181 182 #ifdef RECORDGAME 183 #define planetColor(p) \ 184 ((((p)->pl_info & me->p_team) || playback) \ 185 ? shipCol[remap[(p)->pl_owner]] : unColor) 186 #else 187 #define planetColor(p) \ 188 (((p)->pl_info & me->p_team) ? shipCol[remap[(p)->pl_owner]] : unColor) 189 #endif 190 191 #define planetFont(p) \ 192 (myPlanet(p) ? W_BoldFont : friendlyPlanet(p) ? W_HighlightFont \ 193 : W_RegularFont) 194 195 //SRS - changed this from UnderlineFont to HighlightFont 196 #define shipFont(p) \ 197 (myPlayer(p) ? W_BoldFont : friendlyPlayer(p) ? W_HighlightFont \ 198 : W_RegularFont) 199 #define bombingRating(p) \ 200 ((float) (p)->p_stats.st_tarmsbomb * status->timeprod / \ 201 ((float) (p)->p_stats.st_tticks * status->armsbomb)) 202 #define planetRating(p) \ 203 ((float) (p)->p_stats.st_tplanets * status->timeprod / \ 204 ((float) (p)->p_stats.st_tticks * status->planets)) 205 #define offenseRating(p) \ 206 ((float) (p)->p_stats.st_tkills * status->timeprod / \ 207 ((float) (p)->p_stats.st_tticks * status->kills)) 208 #define defenseRating(p) \ 209 ((float) (p)->p_stats.st_tticks * status->losses / \ 210 ((p)->p_stats.st_tlosses!=0 ? \ 211 ((float) (p)->p_stats.st_tlosses * status->timeprod) : \ 212 (status->timeprod))) 213 214 #define INVISIBLE(j) (((j)->p_flags & PFCLOAK) && \ 215 ((j)->p_cloakphase == (CLOAK_PHASES-1))) 216 217 #if !defined(_IBMR2) 218 /* typedef enum { FALSE = 0, TRUE } 219 * 220 * boolean; */ 221 #else 222 /* Hmmm, this will only work if TRUE/FALSE were undef'ed first. Would that 223 * break things? I don't know. Since "boolean" type is never used, we will 224 * just leave it commented out for now. 225 * 226 * typedef enum {FALSE=0, TRUE} boolean; */ 227 #endif 228 229 #ifndef ROTATERACE 230 #define sendTorpReq(dir) sendShortPacket(CP_TORP, (char) dir) 231 #define sendPhaserReq(dir) sendShortPacket(CP_PHASER, (char) dir) 232 #define sendDirReq(dir) sendShortPacket(CP_DIRECTION, (char) dir) 233 #define sendPlasmaReq(dir) sendShortPacket(CP_PLASMA, (char) dir) 234 #else 235 #define sendTorpReq(dir) sendShortPacket(CP_TORP, (char) RotateDirSend(dir)) 236 #define sendPhaserReq(dir) sendShortPacket(CP_PHASER, (char) RotateDirSend(dir)) 237 #define sendDirReq(dir) sendShortPacket(CP_DIRECTION, (char) RotateDirSend(dir)) 238 #define sendPlasmaReq(dir) sendShortPacket(CP_PLASMA, (char) RotateDirSend(dir)) 239 #endif /* ROTATERACE */ 240 241 #define sendSpeedReq(speed) sendShortPacket(CP_SPEED, (char) speed) 242 #define sendShieldReq(state) sendShortPacket(CP_SHIELD, (char) state) 243 #define sendOrbitReq(state) sendShortPacket(CP_ORBIT, (char) state) 244 #define sendRepairReq(state) sendShortPacket(CP_REPAIR, (char) state) 245 #define sendBeamReq(state) sendShortPacket(CP_BEAM, (char) state) 246 #define sendCopilotReq(state) sendShortPacket(CP_COPILOT, (char) state) 247 #define sendDetonateReq() sendShortPacket(CP_DET_TORPS, 0) 248 #define sendCloakReq(state) sendShortPacket(CP_CLOAK, (char) state) 249 #define sendBombReq(state) sendShortPacket(CP_BOMB, (char) state) 250 #define sendPractrReq() sendShortPacket(CP_PRACTR, 0) 251 #define sendWarReq(mask) sendShortPacket(CP_WAR, (char) mask) 252 #define sendRefitReq(ship) {sendShortPacket(CP_REFIT, (char) ship); shipchange(ship);} 253 #define sendPlaylockReq(pnum) sendShortPacket(CP_PLAYLOCK, (char) pnum) 254 #define sendPlanlockReq(pnum) sendShortPacket(CP_PLANLOCK, (char) pnum) 255 #define sendCoupReq() sendShortPacket(CP_COUP, 0) 256 #define sendQuitReq() sendShortPacket(CP_QUIT, 0) 257 #define sendByeReq() sendShortPacket(CP_BYE, 0) 258 #define sendDockingReq(state) sendShortPacket(CP_DOCKPERM, (char) state) 259 #define sendResetStatsReq(verify) sendShortPacket(CP_RESETSTATS, (char) verify) 260 #define sendScanReq(who) sendShortPacket(CP_SCAN, (char) who) /* ATM */ 261 262 #ifdef SHORT_PACKETS 263 /* #define sendShortReq(state) sendShortPacket(CP_S_REQ, state) */ 264 #endif 265 266 /* This macro allows us to time things based upon # frames / sec. */ 267 #define ticks(x) ((x)*200000/timerDelay) 268 269 char *getdefault(char *str); 270 271 272 /* UDP control stuff */ 273 274 #ifdef GATEWAY 275 #define UDP_NUMOPTS 11 276 #define UDP_GW UDP_NUMOPTS-1 277 #else 278 #define UDP_NUMOPTS 10 279 #endif 280 281 #define UDP_CURRENT 0 282 #define UDP_STATUS 1 283 #define UDP_DROPPED 2 284 #define UDP_SEQUENCE 3 285 #define UDP_SEND 4 286 #define UDP_RECV 5 287 #define UDP_DEBUG 6 288 #define UDP_FORCE_RESET 7 289 #define UDP_UPDATE_ALL 8 290 #define UDP_DONE 9 291 #define COMM_TCP 0 292 #define COMM_UDP 1 293 #define COMM_VERIFY 2 294 #define COMM_UPDATE 3 295 #define COMM_MODE 4 296 #define SWITCH_TCP_OK 0 297 #define SWITCH_UDP_OK 1 298 #define SWITCH_DENIED 2 299 #define SWITCH_VERIFY 3 300 #define CONNMODE_PORT 0 301 #define CONNMODE_PACKET 1 302 #define STAT_CONNECTED 0 303 #define STAT_SWITCH_UDP 1 304 #define STAT_SWITCH_TCP 2 305 #define STAT_VERIFY_UDP 3 306 #define MODE_TCP 0 307 #define MODE_SIMPLE 1 308 #define MODE_FAT 2 309 #define MODE_DOUBLE 3 310 311 #define UDP_RECENT_INTR 300 312 #define UDP_UPDATE_WAIT 5 313 314 /* client version of UDPDIAG */ 315 #define UDPDIAG(x) { if (udpDebug == 2) { printf("UDP: "); printf x; }} 316 #define V_UDPDIAG(x) UDPDIAG(x) 317 318 #ifdef ROTATERACE 319 #define RotateDirSend(d) (rotate?d-rotate_deg:d) 320 #endif 321 322 #ifdef nodef 323 #define RotateDir(d) d -= 64 324 325 #define RotateDirSend(d) (rotate?(d+64):d) 326 327 #define RotateCoord(x,y) _RotateCoord(x,y,(3.1415927/2.)) 328 329 #define UnrotateCoord(x,y) _RotateCoord(x,y,-(3.1415927/2.)) 330 331 #define _RotateCoord(x,y,rd) \ 332 { \ 333 extern double atan2(), hypot(), sin(), cos(); \ 334 double __dir; \ 335 double __r, __dx, __dy; \ 336 \ 337 __dx = (double)(x - GWIDTH/2); \ 338 __dy = (double)(GWIDTH/2 - y); \ 339 __dir = atan2(__dx, __dy) - 3.1415927/2.; \ 340 __r = hypot(__dx, __dy); \ 341 __dir -= rd; \ 342 x = (int)(__r * cos(__dir) + GWIDTH/2); \ 343 y = (int)(__r * sin(__dir) + GWIDTH/2); \ 344 } 345 #endif /* nodef */ 346 347 #define NETSTAT_NUMFIELDS 7 348 349 /* field names */ 350 #define NETSTAT_SWITCH 0 351 #define NETSTAT_RESET 1 352 #define NETSTAT_TOTAL 2 353 #define NETSTAT_LOCAL 3 354 #define NETSTAT_FAILURES 4 355 #define NETSTAT_NFTHRESH 5 356 #define NETSTAT_DONE 6 357 358 /* misc */ 359 360 #define NETSTAT_DF_NFT 2000 361 #define NETSTAT_DF_NFT_S "2000" 362 363 364 #ifdef SHORT_PACKETS 365 #define SPK_VOFF 0 /* variable packets off */ 366 #define SPK_VON 1 /* variable packets on */ 367 #define SPK_MOFF 2 /* message packets off */ 368 #define SPK_MON 3 /* message packets on */ 369 #define SPK_M_KILLS 4 /* send kill mesgs */ 370 #define SPK_M_NOKILLS 5 /* don't send kill mesgs */ 371 #define SPK_THRESHOLD 6 /* threshold */ 372 #define SPK_M_WARN 7 /* warnings */ 373 #define SPK_M_NOWARN 8 /* no warnings */ 374 #define SPK_SALL 9 /* only planets,kills and 375 * weapons */ 376 #define SPK_ALL 10 /* Full Update - SP_STATS */ 377 378 #define SPK_NUMFIELDS 6 379 380 #define SPK_VFIELD 0 381 #define SPK_MFIELD 1 382 #define SPK_KFIELD 2 383 #define SPK_WFIELD 3 384 #define SPK_TFIELD 4 385 #define SPK_DONE 5 386 #endif 387 388 #ifndef NBT 389 #define NBT 390 #endif /* NBT */ 391 392 #define MAXMACLEN 85 393 #define NBTM 0 394 #define NEWM 1 395 #define NEWMSPEC 2 396 #define NEWMMOUSE 3 397 #define NEWMULTIM 4 398 399 #define MACRO_ME 0 400 #define MACRO_PLAYER 1 401 #define MACRO_TEAM 2 402 #define MACRO_FRIEND 3 403 #define MACRO_ENEMY 4 404 405 #ifdef TOOLS 406 #define TOOLSWINLEN 25 407 #define MAX_KEY 20 408 #endif 409 410 #ifdef HOCKEY_LINES 411 #define NUM_HOCKEY_LINES 13 412 #define S_LINE_HORIZONTAL 1 413 #define S_LINE_VERTICAL 2 414 #endif 415 416 #ifdef BEEPLITE 417 #define LITE_PLAYERS_MAP 0x01 418 #define LITE_PLAYERS_LOCAL 0x02 419 #define LITE_SELF 0x04 420 #define LITE_PLANETS 0x08 421 #define LITE_SOUNDS 0x10 422 #define LITE_COLOR 0x20 423 #define LITE_TTS 0x40 424 #endif 425 426 #ifdef WARP_DEAD 427 #define DEADPACKETS 3 428 #endif 429 430 #define EXIT_FORK_FAILURE -2 431 #define EXIT_UNKNOWN -1 432 #define EXIT_OK 0 433 #define EXIT_CONNECT_FAILURE 1 434 #define EXIT_LOGIN_FAILURE 2 435 #define EXIT_DISCONNECTED 3 436 #define EXIT_BADVERSION_BASE 10 437 438 #endif /* _h_defs */ 439