/Volumes/Plantain/MyDocuments/Projects/MacTrek/MacTrek/Design Stuff/COW/defs.h

00001 
00002 
00003 /* defs.h
00004  *
00005  * $Log: defs.h,v $
00006  * Revision 1.2  1999/08/05 16:46:32  siegl
00007  * remove several defines (BRMH, RABBITEARS, NEWDASHBOARD2)
00008  *
00009  * Revision 1.1.1.1  1998/11/01 17:24:09  siegl
00010  * COW 3.0 initial revision
00011  * */
00012 
00013 #ifndef _h_defs
00014 #define _h_defs
00015 
00016 
00017 
00018 /* #$!@$#% length of address field of messages */
00019 #define ADDRLEN 10
00020 
00021 #ifdef NBT
00022 #define MAX_MACRO       255
00023 #endif
00024 
00025 #ifndef MAXPLAYER
00026 #define MAXPLAYER 20
00027 #endif
00028 
00029 #define TESTERS 4                                /* Priveledged slots for * * 
00030                                                   * robots and game 'testers' 
00031                                                   * 
00032                                                   */
00033 #define MAXPLANETS 40
00034 #define MAXTORP 8
00035 #define MAXPLASMA 1
00036 #define PKEY 128
00037 
00038 
00039 #ifdef SMALL_SCREEN
00040 #define GWINSIDE 400
00041 #define TWINSIDE 500
00042 #else
00043 #define GWINSIDE 500
00044 #define TWINSIDE 500                             /* Size of strategic and * * 
00045                                                   * tactical windows */
00046 #endif
00047 
00048 #define BORDER 3                                 /* border width for option * 
00049                                                   * 
00050                                                   * * windows */
00051 #define PSEUDOSIZE 16
00052 #define CLOAK_PHASES 7                           /* number of drawing phases
00053                                                   * * * in a cloak * *
00054                                                   * engage/disengage */
00055 #define NUMRANKS 9
00056 
00057 /* These are configuration definitions */
00058 
00059 #define GWIDTH 100000                            /* galaxy is 100000 spaces * 
00060                                                   * 
00061                                                   * * on a side */
00062 #define WARP1 20                                 /* warp one will move 20 * * 
00063                                                   * spaces per update */
00064 #define SCALE 40                                 /* Window will be one pixel
00065                                                   * * * for 20 spaces */
00066 #define EXPDIST 350                              /* At this range a torp will
00067                                                   * * * explode */
00068 #define DETDIST 1600                             /* At this range a player *
00069                                                   * * can detonate a torp */
00070 #define NUM_PLANET_BITMAPS 7
00071 #define NUM_PLANET_BITMAPS2 8
00072 
00073 #define PHASEDIST 6000                           /* At this range a player *
00074                                                   * * can do damage with * *
00075                                                   * phasers */
00076 #define ENTORBDIST 900                           /* At this range a player *
00077                                                   * * can orbit a planet */
00078 #define ORBDIST 800                              /* A player will orbit at *
00079                                                   * * this radius */
00080 #define ORBSPEED 2                               /* This is the fastest a * * 
00081                                                   * person can go into orbit */
00082 #define PFIREDIST 1500                           /* At this range a planet *
00083                                                   * * will shoot at a player */
00084 #define UPDATE 100000                            /* Update time is 100000 * * 
00085                                                   * micro-seconds */
00086 
00087 /* 6 minutes is maximum for autoquit -- anything more causes problems in the
00088  * server.  (?) */
00089 #define AUTOQUIT 9*60                            /* auto logout in 5 minutes */
00090 
00091 #define VACANT -1                                /* indicates vacant port on
00092                                                   * * * a starbase */
00093 #define DOCKDIST 600
00094 #define DOCKSPEED 2                              /* If base is moving, there
00095                                                   * * * will be some finesse
00096                                                   * * * involved to dock */
00097 #define NUMPORTS 4
00098 #define SBFUELMIN 10000                          /* If starbase's fuel is * * 
00099                                                   * less than this, it will * 
00100                                                   * 
00101                                                   * * not refuel docked
00102                                                   * vessels  */
00103 #define TRACTDIST   6000                         /* maximum effective tractor
00104                                                   * * * beam range */
00105 #define TRACTEHEAT  5                            /* ammount tractor beams * * 
00106                                                   * heat engines */
00107 #define TRACTCOST   20                           /* fuel cost of activated *
00108                                                   * * tractor beam */
00109 
00110 
00111 /* RSA stuff */
00112 #define RSA_VERSION "RSA v2.0 CLIENT"            /* string must begin with *
00113                                                   * * characters "RSA" */
00114 #define KEY_SIZE 32
00115 #define RESERVED_SIZE 16
00116 #define NAME_LEN 16
00117 #define KEYMAP_LEN 96
00118 
00119 #define MSG_LEN 80
00120 
00121 
00122 /* These are memory sections */
00123 #define PLAYER 1
00124 #define MAXMESSAGE 50
00125 #define MAXREVIEWMESSAGE 20
00126 
00127 #define rosette(x)   ((((x) + 8) / 16) & 15)
00128 /* #define rosette(x)   ((((x) + 256/VIEWS/2) / (256/VIEWS) + VIEWS) % VIEWS) */
00129 /* (((x + 8) / 16 + 16)  %  16)  */
00130 
00131 /* These are the teams */
00132 /* Note that I used bit types for these mostly for messages and war status.
00133  * This was probably a mistake.  It meant that Ed had to add the 'remap' area
00134  * to map these (which are used throughout the code as the proper team
00135  * variable) into a nice four team deep array for his color stuff.  Oh well. */
00136 #define NOBODY 0x0
00137 #define FED 0x1
00138 #define ROM 0x2
00139 #define KLI 0x4
00140 #define ORI 0x8
00141 #define ALLTEAM (FED|ROM|KLI|ORI)
00142 #define MAXTEAM (ORI)
00143 #define NUMTEAM 4
00144 /* * These are random configuration variables */
00145 #define VICTORY 3                                /* Number of systems needed
00146                                                   * * * to conquer the galaxy 
00147                                                   */
00148 #define WARNTIME 30                              /* Number of updates to have
00149                                                   * * * a warning on the
00150                                                   * screen */
00151 #define MESSTIME 30                              /* Number of updates to have
00152                                                   * * * a message on the
00153                                                   * screen */
00154 
00155 #define TARG_PLAYER     0x1                      /* Flags for gettarget */
00156 #define TARG_PLANET     0x2
00157 #define TARG_CLOAK      0x4                      /* Include cloaked ships in
00158                                                   * * * search */
00159 #define TARG_SELF       0x8
00160 #define TARG_ENEMY      0x10
00161 #define TARG_FRIEND     0x20
00162 
00163 /* Data files to make the game play across daemon restarts. */
00164 
00165 
00166 #define GLOBAL          "/ch/ue/hadley/alternate/net/ntserv/.global"
00167 #define SCORES          "/ch/ue/hadley/alternate/net/ntserv/.scores"
00168 #define PLFILE          "/ch/ue/hadley/alternate/net/ntserv/.planets"
00169 #define MOTD            "/ch/ue/hadley/alternate/net/ntserv/.motd"
00170 #define DAEMON          "/ch/ue/hadley/alternate/net/ntserv/daemonII"
00171 #define ROBOT           "/ch/ue/hadley/alternate/net/ntserv/robotII"
00172 #define LOGFILENAME     "/ch/ue/hadley/alternate/net/ntserv/logfile"
00173 #define PLAYERFILE      "/ch/ue/hadley/alternate/net/ntserv/.players"
00174 #define CONQFILE        "/ch/ue/hadley/alternate/net/ntserv/.conquer"
00175 #define SYSDEF_FILE     "/ch/ue/hadley/alternate/net/ntserv/.sysdef"
00176 
00177 #define DEFAULT_PORT    2592
00178 
00179 /* Other stuff that Ed added */
00180 
00181 #define ABS(a)                  /* abs(a) */ (((a) < 0) ? -(a) : (a))
00182 
00183 #ifndef MAX
00184 #define MAX(a,b)                ((a) > (b) ? (a) : (b))
00185 #endif
00186 
00187 #define myPlasmaTorp(t)         (me->p_no == (t)->pt_owner)
00188 #define myTorp(t)               (me->p_no == (t)->t_owner)
00189 #define friendlyPlasmaTorp(t)   ((!(me->p_team & (t)->pt_war)) || (myPlasmaTorp(t)))
00190 #define friendlyTorp(t)         ((!(me->p_team & (t)->t_war)) || (myTorp(t)))
00191 #define myPhaser(p)             (&phasers[me->p_no] == (p))
00192 #define friendlyPhaser(p)       (me->p_team == players[(p) - phasers].p_team)
00193 #define myPlayer(p)             (me == (p))
00194 #define myPlanet(p)             (me->p_team == (p)->pl_owner)
00195 #define friendlyPlayer(p)       ((!(me->p_team & \
00196                                     ((p)->p_swar | (p)->p_hostile))) && \
00197                                     (!((p)->p_team & \
00198                                     (me->p_swar | me->p_hostile))))
00199 #define isAlive(p)              (((p)->p_status == PALIVE) || ((p)->p_status == PFOBSERV))
00200 #define friendlyPlanet(p)       ((p)->pl_info & me->p_team && \
00201                              !((p)->pl_owner & (me->p_swar | me->p_hostile)))
00202 
00203 #define isLockPlanet(p)         ((me->p_flags & PFPLLOCK) && (me->p_planet == p->pl_no))
00204 #define isLockPlayer(p)         ((me->p_flags & PFPLOCK) && (me->p_playerl == p->p_no))
00205 
00206 #define torpColor(t)            \
00207         (myTorp(t) ? myColor : shipCol[remap[players[(t)->t_owner].p_team]])
00208 #define plasmatorpColor(t)              \
00209         (myPlasmaTorp(t) ? myColor : shipCol[remap[players[(t)->pt_owner].p_team]])
00210 #define phaserColor(p)          \
00211         (myPhaser(p) ? myColor : shipCol[remap[players[(p) - phasers].p_team]])
00212 /* Cloaking phase (and not the cloaking flag) is the factor in determining
00213  * the color of the ship.  Color 0 is white (same as 'myColor' used to be). */
00214 #define playerColor(p)          \
00215         (myPlayer(p) ? myColor : shipCol[remap[(p)->p_team]])
00216 
00217 #ifdef RECORDGAME
00218 #define planetColor(p)          \
00219         ((((p)->pl_info & me->p_team) || playback) \
00220          ? shipCol[remap[(p)->pl_owner]] : unColor)
00221 #else
00222 #define planetColor(p)          \
00223         (((p)->pl_info & me->p_team) ? shipCol[remap[(p)->pl_owner]] : unColor)
00224 #endif
00225 
00226 #define planetFont(p)           \
00227         (myPlanet(p) ? W_BoldFont : friendlyPlanet(p) ? W_UnderlineFont \
00228             : W_RegularFont)
00229 
00230 #define shipFont(p)             \
00231         (myPlayer(p) ? W_BoldFont : friendlyPlayer(p) ? W_UnderlineFont \
00232             : W_RegularFont)
00233 #define bombingRating(p)        \
00234         ((float) (p)->p_stats.st_tarmsbomb * status->timeprod / \
00235          ((float) (p)->p_stats.st_tticks * status->armsbomb))
00236 #define planetRating(p)         \
00237         ((float) (p)->p_stats.st_tplanets * status->timeprod / \
00238          ((float) (p)->p_stats.st_tticks * status->planets))
00239 #define offenseRating(p)        \
00240         ((float) (p)->p_stats.st_tkills * status->timeprod / \
00241          ((float) (p)->p_stats.st_tticks * status->kills))
00242 #define defenseRating(p)        \
00243         ((float) (p)->p_stats.st_tticks * status->losses / \
00244          ((p)->p_stats.st_tlosses!=0 ? \
00245           ((float) (p)->p_stats.st_tlosses * status->timeprod) : \
00246           (status->timeprod)))
00247 
00248 #define INVISIBLE(j)        (((j)->p_flags & PFCLOAK) && \
00249         ((j)->p_cloakphase == (CLOAK_PHASES-1)))
00250 
00251 #define ANNOUNCESOCKET      if (me!=NULL)printf("***  socket %d, player %d  ***\n",nextSocket,me->p_no); else
00252 
00253 
00254 #if !defined(_IBMR2)
00255 /* typedef enum { FALSE = 0, TRUE }
00256  * 
00257  * boolean; */
00258 #else
00259 /* Hmmm, this will only work if TRUE/FALSE were undef'ed first. Would that
00260  * break things?  I don't know.  Since "boolean" type is never used, we will
00261  * just leave it commented out for now.
00262  * 
00263  * typedef enum {FALSE=0, TRUE} boolean; */
00264 #endif
00265 
00266 #ifndef ROTATERACE
00267 #define sendTorpReq(dir) sendShortPacket(CP_TORP, dir)
00268 #define sendPhaserReq(dir) sendShortPacket(CP_PHASER, dir)
00269 #define sendDirReq(dir) sendShortPacket(CP_DIRECTION, dir)
00270 #define sendPlasmaReq(dir) sendShortPacket(CP_PLASMA, dir)
00271 #else
00272 #define sendTorpReq(dir) sendShortPacket(CP_TORP, RotateDirSend(dir))
00273 #define sendPhaserReq(dir) sendShortPacket(CP_PHASER, RotateDirSend(dir))
00274 #define sendDirReq(dir) sendShortPacket(CP_DIRECTION, RotateDirSend(dir))
00275 #define sendPlasmaReq(dir) sendShortPacket(CP_PLASMA, RotateDirSend(dir))
00276 #endif /* ROTATERACE */
00277 
00278 #define sendSpeedReq(speed) sendShortPacket(CP_SPEED, speed)
00279 #define sendShieldReq(state) sendShortPacket(CP_SHIELD, state)
00280 #define sendOrbitReq(state) sendShortPacket(CP_ORBIT, state)
00281 #define sendRepairReq(state) sendShortPacket(CP_REPAIR, state)
00282 #define sendBeamReq(state) sendShortPacket(CP_BEAM, state)
00283 #define sendCopilotReq(state) sendShortPacket(CP_COPILOT, state)
00284 #define sendDetonateReq() sendShortPacket(CP_DET_TORPS, 0)
00285 #define sendCloakReq(state) sendShortPacket(CP_CLOAK, state)
00286 #define sendBombReq(state) sendShortPacket(CP_BOMB, state)
00287 #define sendPractrReq() sendShortPacket(CP_PRACTR, 0)
00288 #define sendWarReq(mask) sendShortPacket(CP_WAR, mask)
00289 #define sendRefitReq(ship) {sendShortPacket(CP_REFIT, ship); shipchange(ship);}
00290 #define sendPlaylockReq(pnum) sendShortPacket(CP_PLAYLOCK, pnum)
00291 #define sendPlanlockReq(pnum) sendShortPacket(CP_PLANLOCK, pnum)
00292 #define sendCoupReq() sendShortPacket(CP_COUP, 0)
00293 #define sendQuitReq() sendShortPacket(CP_QUIT, 0)
00294 #define sendByeReq() sendShortPacket(CP_BYE, 0)
00295 #define sendDockingReq(state) sendShortPacket(CP_DOCKPERM, state)
00296 #define sendResetStatsReq(verify) sendShortPacket(CP_RESETSTATS, verify)
00297 #define sendScanReq(who) sendShortPacket(CP_SCAN, who)  /* ATM */
00298 
00299 #ifdef SHORT_PACKETS
00300 /* #define sendShortReq(state)   sendShortPacket(CP_S_REQ, state) */
00301 #endif
00302 
00303 /* This macro allows us to time things based upon # frames / sec. */
00304 #define ticks(x) ((x)*200000/timerDelay)
00305 
00306 char   *getdefault(char *str);
00307 
00308 
00309 /* UDP control stuff */
00310 
00311 #ifdef GATEWAY
00312 #define UDP_NUMOPTS    11
00313 #define UDP_GW         UDP_NUMOPTS-1
00314 #else
00315 #define UDP_NUMOPTS    10
00316 #endif
00317 
00318 #define UDP_CURRENT     0
00319 #define UDP_STATUS      1
00320 #define UDP_DROPPED     2
00321 #define UDP_SEQUENCE    3
00322 #define UDP_SEND        4
00323 #define UDP_RECV        5
00324 #define UDP_DEBUG       6
00325 #define UDP_FORCE_RESET 7
00326 #define UDP_UPDATE_ALL  8
00327 #define UDP_DONE        9
00328 #define COMM_TCP        0
00329 #define COMM_UDP        1
00330 #define COMM_VERIFY     2
00331 #define COMM_UPDATE     3
00332 #define COMM_MODE       4
00333 #define SWITCH_TCP_OK   0
00334 #define SWITCH_UDP_OK   1
00335 #define SWITCH_DENIED   2
00336 #define SWITCH_VERIFY   3
00337 #define CONNMODE_PORT   0
00338 #define CONNMODE_PACKET 1
00339 #define STAT_CONNECTED  0
00340 #define STAT_SWITCH_UDP 1
00341 #define STAT_SWITCH_TCP 2
00342 #define STAT_VERIFY_UDP 3
00343 #define MODE_TCP        0
00344 #define MODE_SIMPLE     1
00345 #define MODE_FAT        2
00346 #define MODE_DOUBLE     3
00347 
00348 #define UDP_RECENT_INTR 300
00349 #define UDP_UPDATE_WAIT 5
00350 
00351 /* client version of UDPDIAG */
00352 #define UDPDIAG(x)      { if (udpDebug == 2) { printf("UDP: "); printf x; }}
00353 #define V_UDPDIAG(x)    UDPDIAG(x)
00354 
00355 #ifdef ROTATERACE
00356 #define RotateDirSend(d)        (rotate?d-rotate_deg:d)
00357 #endif
00358 
00359 #ifdef nodef
00360 #define RotateDir(d)            d -= 64
00361 
00362 #define RotateDirSend(d)        (rotate?(d+64):d)
00363 
00364 #define RotateCoord(x,y)        _RotateCoord(x,y,(3.1415927/2.))
00365 
00366 #define UnrotateCoord(x,y)      _RotateCoord(x,y,-(3.1415927/2.))
00367 
00368 #define _RotateCoord(x,y,rd)                            \
00369    {                                                    \
00370       extern double atan2(), hypot(), sin(), cos();     \
00371       double    __dir;                                  \
00372       double    __r, __dx, __dy;                        \
00373                                                         \
00374       __dx = (double)(x - GWIDTH/2);                    \
00375       __dy = (double)(GWIDTH/2 - y);                    \
00376       __dir = atan2(__dx,  __dy) - 3.1415927/2.;        \
00377       __r = hypot(__dx, __dy);                          \
00378       __dir -= rd;                                      \
00379       x = (int)(__r * cos(__dir) + GWIDTH/2);           \
00380       y = (int)(__r * sin(__dir) + GWIDTH/2);           \
00381    }
00382 #endif /* nodef */
00383 
00384 #define         NETSTAT_NUMFIELDS       7
00385 
00386 /* field names */
00387 #define         NETSTAT_SWITCH          0
00388 #define         NETSTAT_RESET           1
00389 #define         NETSTAT_TOTAL           2
00390 #define         NETSTAT_LOCAL           3
00391 #define         NETSTAT_FAILURES        4
00392 #define         NETSTAT_NFTHRESH        5
00393 #define         NETSTAT_DONE            6
00394 
00395 /* misc */
00396 
00397 #define         NETSTAT_DF_NFT          2000
00398 #define         NETSTAT_DF_NFT_S        "2000"
00399 
00400 
00401 #ifdef SHORT_PACKETS
00402 #define         SPK_VOFF        0                /* variable packets off */
00403 #define         SPK_VON         1                /* variable packets on */
00404 #define         SPK_MOFF        2                /* message packets off */
00405 #define         SPK_MON         3                /* message packets on */
00406 #define         SPK_M_KILLS     4                /* send kill mesgs */
00407 #define         SPK_M_NOKILLS   5                /* don't send kill mesgs */
00408 #define         SPK_THRESHOLD   6                /* threshold */
00409 #define         SPK_M_WARN      7                /* warnings */
00410 #define         SPK_M_NOWARN    8                /* no warnings */
00411 #define SPK_SALL 9                               /* only planets,kills and *
00412                                                   * * weapons */
00413 #define         SPK_ALL 10                       /* Full Update - SP_STATS */
00414 
00415 #define         SPK_NUMFIELDS   6
00416 
00417 #define         SPK_VFIELD      0
00418 #define         SPK_MFIELD      1
00419 #define         SPK_KFIELD      2
00420 #define         SPK_WFIELD      3
00421 #define         SPK_TFIELD      4
00422 #define         SPK_DONE        5
00423 #endif
00424 
00425 #ifndef NBT
00426 #define NBT
00427 #endif /* NBT */
00428 
00429 #define MAXMACLEN       85
00430 #define NBTM            0
00431 #define NEWM            1
00432 #define NEWMSPEC        2
00433 #define NEWMMOUSE       3
00434 #define NEWMULTIM       4
00435 
00436 #define MACRO_ME        0
00437 #define MACRO_PLAYER    1
00438 #define MACRO_TEAM      2
00439 #define MACRO_FRIEND    3
00440 #define MACRO_ENEMY     4
00441 
00442 #ifdef TOOLS
00443 #define TOOLSWINLEN 25
00444 #define MAX_KEY         20
00445 #endif
00446 
00447 #ifdef HOCKEY_LINES
00448 #define NUM_HOCKEY_LINES 13
00449 #define S_LINE_HORIZONTAL 1
00450 #define S_LINE_VERTICAL 2
00451 #endif
00452 
00453 #ifdef BEEPLITE
00454 #define LITE_PLAYERS_MAP        0x01
00455 #define LITE_PLAYERS_LOCAL      0x02
00456 #define LITE_SELF               0x04
00457 #define LITE_PLANETS            0x08
00458 #define LITE_SOUNDS             0x10
00459 #define LITE_COLOR              0x20
00460 #define LITE_TTS                0x40
00461 #endif
00462 
00463 #ifdef WARP_DEAD
00464 #define DEADPACKETS     3
00465 #endif
00466 
00467 #endif /* _h_defs */

Generated on Fri Jul 28 19:15:17 2006 for MacTrek by  doxygen 1.4.7