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

00001 
00002 
00003 
00004 /* struct.h for the client of an xtrek socket protocol.
00005  * 
00006  * Most of the unneeded stuff in the structures has been thrown away.
00007  *
00008  * $Log: struct.h,v $
00009  * Revision 1.3  2002/06/21 00:26:03  quozl
00010  * fix description of PFOBSERV
00011  *
00012  * Revision 1.2  1999/08/05 16:46:32  siegl
00013  * remove several defines (BRMH, RABBITEARS, NEWDASHBOARD2)
00014  *
00015  * Revision 1.1.1.1  1998/11/01 17:24:11  siegl
00016  * COW 3.0 initial revision
00017  * */
00018 
00019 #ifndef _h_struct
00020 #define _h_struct
00021 
00022 struct distress
00023   {
00024     unsigned char sender;
00025     unsigned char dam, shld, arms, wtmp, etmp, fuelp, sts;
00026     unsigned char wtmpflag, etempflag, cloakflag, distype, macroflag;
00027     unsigned char close_pl, close_en, tclose_pl, tclose_en, pre_app, i;
00028     unsigned char close_j, close_fr, tclose_j, tclose_fr;
00029     unsigned char cclist[6];                     /* allow us some day to cc a
00030                                                   * message up to 5 people */
00031     /* sending this to the server allows the server to do the cc action */
00032     /* otherwise it would have to be the client ... less BW this way */
00033     char    preappend[80];                       /* text which we pre or append */
00034   };
00035 
00036 struct dmacro_list
00037   {
00038     unsigned char c;
00039     char   *name;
00040     char   *macro;
00041   };
00042 
00043 struct status
00044   {
00045     unsigned char tourn;                         /* Tournament mode? */
00046     /* These stats only updated during tournament mode */
00047     unsigned int armsbomb, planets, kills, losses, time;
00048     /* Use LONG for this, so it never wraps */
00049     unsigned long timeprod;
00050   };
00051 
00052 enum dist_type
00053   {
00054     /* help me do series */
00055     take = 1, ogg, bomb, space_control,
00056     save_planet,
00057     base_ogg,
00058     help3, help4,
00059 
00060     /* doing series */
00061     escorting, ogging, bombing, controlling,
00062     asw,
00063     asbomb,
00064     doing3, doing4,
00065 
00066     /* other info series */
00067     free_beer,                                   /* ie. player x is totally 
00068                                                   * hosed now */
00069     no_gas,                                      /* ie. player x has no gas */
00070     crippled,                                    /* ie. player x is way hurt
00071                                                   * but may have gas */
00072     pickup,                                      /* player x picked up armies 
00073                                                   */
00074     pop,                                         /* there was a pop somewhere 
00075                                                   */
00076     carrying,                                    /* I am carrying */
00077     other1, other2,
00078 
00079     /* just a generic distress call */
00080     generic
00081 
00082 #ifdef RCM
00083     ,rcm
00084 #endif
00085   };
00086 
00087 /* The General distress has format:
00088  * 
00089  * byte1: 00yzzzzz where zzzzz is dist_type, and y is 1 if this is a more
00090  * complicated macro and not just a simple distress (a simple distress will
00091  * ONLY send ship info like shields, armies, status, location, etc.). I guess
00092  * y=1 can be for !    future expansion.
00093  * 
00094  * byte2: 1fff ffff - f = percentage fuel remaining (0-100) byte3: 1ddd dddd - %
00095  * damage byte4: 1sss ssss - % shields remaining byte5: 1eee eeee - % etemp
00096  * byte6: 1www wwww - % wtemp byte7: 100a aaaa - armies carried byte8: (lsb
00097  * of me->p_status) & 0x80 byte9: 1ppp pppp - planet closest to me byte10:
00098  * 1eee eeee - enemy closest to me byte11: 1ppp pppp - planet closest to
00099  * target byte12: 1eee eeee - enemy closest to target byte13: 1ttt tttt -
00100  * tclose_j byte14: 1jjj jjjj - close_j byte15: 1fff ffff - tclose_fr byte16:
00101  * 1ccc cccc - close_fr byte17+: cc list (each player to cc this message to
00102  * is 11pp ppp) cc list is terminated by 0x80 (pre-pend) or 0100 0000
00103  * (append) ) byte18++: the text to pre or append .. depending on termination
00104  * above. text is null terminated and the last thing in this distress */
00105 
00106 #define PFREE 0
00107 #define POUTFIT 1
00108 #define PALIVE 2
00109 #define PEXPLODE 3
00110 #define PDEAD 4
00111 
00112 #define PFSHIELD        0x0001
00113 #define PFREPAIR        0x0002
00114 #define PFBOMB          0x0004
00115 #define PFORBIT         0x0008
00116 #define PFCLOAK         0x0010
00117 #define PFWEP           0x0020
00118 #define PFENG           0x0040
00119 #define PFROBOT         0x0080
00120 #define PFBEAMUP        0x0100
00121 #define PFBEAMDOWN      0x0200
00122 #define PFSELFDEST      0x0400
00123 #define PFGREEN         0x0800
00124 #define PFYELLOW        0x1000
00125 #define PFRED           0x2000
00126 #define PFPLOCK         0x4000                   /* Locked on a player */
00127 #define PFPLLOCK        0x8000                   /* Locked on a planet */
00128 #define PFCOPILOT       0x10000                  /* Allow copilots */
00129 #define PFWAR           0x20000                  /* computer reprogramming
00130                                                   * for war */
00131 #define PFPRACTR        0x40000                  /* practice type robot (no
00132                                                   * kills) */
00133 #define PFDOCK          0x80000                  /* true if docked to a
00134                                                   * starbase */
00135 #define PFREFIT         0x100000                 /* true if about to refit */
00136 #define PFREFITTING     0x200000                 /* true if currently
00137                                                   * refitting */
00138 #define PFTRACT         0x400000                 /* tractor beam activated */
00139 #define PFPRESS         0x800000                 /* pressor beam activated */
00140 #define PFDOCKOK        0x1000000                /* docking permission */
00141 #define PFOBSERV        0x8000000                /* observer */
00142 
00143 #define KQUIT           0x01                     /* Player quit */
00144 #define KTORP           0x02                     /* killed by torp */
00145 #define KPHASER         0x03                     /* killed by phaser */
00146 #define KPLANET         0x04                     /* killed by planet */
00147 #define KSHIP           0x05                     /* killed by other ship */
00148 #define KDAEMON         0x06                     /* killed by dying daemon */
00149 #define KWINNER         0x07                     /* killed by a winner */
00150 #define KGHOST          0x08                     /* killed because a ghost */
00151 #define KGENOCIDE       0x09                     /* killed by genocide */
00152 #define KPROVIDENCE     0x0a                     /* killed by a hacker */
00153 #define KPLASMA         0x0b                     /* killed by a plasma * *
00154                                                   * torpedo */
00155 #define TOURNEND        0x0c                     /* tournament game ended */
00156 #define KOVER           0x0d                     /* game over  */
00157 #define TOURNSTART      0x0e                     /* tournament game starting */
00158 #define KBADBIN         0x0f                     /* bad binary */
00159 
00160 #define NUM_TYPES 8
00161 #define SCOUT 0
00162 #define DESTROYER 1
00163 #define CRUISER 2
00164 #define BATTLESHIP 3
00165 #define ASSAULT 4
00166 #define STARBASE 5
00167 #define SGALAXY 6
00168 #define ATT     7
00169 
00170 struct ship
00171   {
00172     short   s_phaserdamage;
00173     int     s_maxspeed;
00174     int     s_maxfuel;
00175     int     s_maxshield;
00176     int     s_maxdamage;
00177     int     s_maxegntemp;
00178     int     s_maxwpntemp;
00179     short   s_maxarmies;
00180     short   s_width;
00181     short   s_height;
00182     short   s_type;
00183     int     s_torpspeed;
00184   };
00185 
00186 struct stats
00187   {
00188     double  st_maxkills;                         /* max kills ever */
00189     int     st_kills;                            /* how many kills */
00190     int     st_losses;                           /* times killed */
00191     int     st_armsbomb;                         /* armies bombed */
00192     int     st_planets;                          /* planets conquered */
00193     int     st_ticks;                            /* Ticks I've been in game */
00194     int     st_tkills;                           /* Kills in tournament play */
00195     int     st_tlosses;                          /* Losses in tournament play */
00196     int     st_tarmsbomb;                        /* Tournament armies bombed */
00197     int     st_tplanets;                         /* Tournament planets
00198                                                   * conquered */
00199     int     st_tticks;                           /* Tournament ticks */
00200     /* SB stats are entirely separate */
00201     int     st_sbkills;                          /* Kills as starbase */
00202     int     st_sblosses;                         /* Losses as starbase */
00203     int     st_sbticks;                          /* Time as starbase */
00204     double  st_sbmaxkills;                       /* Max kills as starbase */
00205     long    st_lastlogin;                        /* Last time this player was played */
00206     int     st_flags;                            /* Misc option flags */
00207 
00208 #ifdef MOUSE_AS_SHIFT
00209     unsigned char st_keymap[480];                /* keymap for this player */
00210 #else
00211     unsigned char st_keymap[96];                 /* keymap for this player */
00212 #endif
00213     int     st_rank;                             /* Ranking of the player */
00214   };
00215 
00216 #define ST_MAPMODE      1
00217 #define ST_NAMEMODE     2
00218 #define ST_SHOWSHIELDS  4
00219 #define ST_KEEPPEACE    8
00220 #define ST_SHOWLOCAL    16                       /* two bits for these two */
00221 #define ST_SHOWGLOBAL   64
00222 
00223 struct player
00224   {
00225     int     p_no;
00226     int     p_updates;                           /* Number of updates ship
00227                                                   * has survived */
00228     int     p_status;                            /* Player status */
00229     unsigned int p_flags;                        /* Player flags */
00230     char    p_name[16];
00231     char    p_login[16];
00232     char    p_monitor[16];                       /* Monitor being played on */
00233     char    p_mapchars[2];                       /* Cache for map window
00234                                                   * image */
00235     struct ship p_ship;                          /* Personal ship statistics */
00236     int     p_x;
00237     int     p_y;
00238     unsigned char p_dir;                         /* Real direction */
00239     unsigned char p_desdir;                      /* desired direction */
00240     int     p_subdir;                            /* fraction direction change 
00241                                                   */
00242     int     p_speed;                             /* Real speed */
00243     short   p_desspeed;                          /* Desired speed */
00244     int     p_subspeed;                          /* Fractional speed */
00245     short   p_team;                              /* Team I'm on */
00246     int     p_damage;                            /* Current damage */
00247     int     p_subdamage;                         /* Fractional damage repair */
00248     int     p_shield;                            /* Current shield power */
00249     int     p_subshield;                         /* Fractional shield
00250                                                   * recharge */
00251     short   p_cloakphase;                        /* Drawing stage of cloaking
00252                                                   * engage/disengage. */
00253     short   p_ntorp;                             /* Number of torps flying */
00254     short   p_nplasmatorp;                       /* Number of plasma torps
00255                                                   * active */
00256     char    p_hostile;                           /* Who my torps will hurt */
00257     char    p_swar;                              /* Who am I at sticky war
00258                                                   * with */
00259     float   p_kills;                             /* Enemies killed */
00260     short   p_planet;                            /* Planet orbiting or locked
00261                                                   * onto */
00262     short   p_playerl;                           /* Player locked onto */
00263 
00264 #ifdef ARMY_SLIDER
00265     int     p_armies;                            /* XXX: for stats */
00266 #else
00267     short   p_armies;
00268 #endif                                           /* ARMY_SLIDER */
00269     int     p_fuel;
00270     short   p_explode;                           /* Keeps track of final
00271                                                   * explosion */
00272     int     p_etemp;
00273     short   p_etime;
00274     int     p_wtemp;
00275     short   p_wtime;
00276     short   p_whydead;                           /* Tells you why you died */
00277     short   p_whodead;                           /* Tells you who killed you */
00278     struct stats p_stats;                        /* player statistics */
00279     short   p_genoplanets;                       /* planets taken since last
00280                                                   * genocide */
00281     short   p_genoarmsbomb;                      /* armies bombed since last
00282                                                   * genocide */
00283     short   p_planets;                           /* planets taken this game */
00284     short   p_armsbomb;                          /* armies bombed this game */
00285     int     p_ghostbuster;
00286     int     p_docked;                            /* If starbase, # docked to,
00287                                                   * else pno base host */
00288     int     p_port[4];                           /* If starbase, pno of ship
00289                                                   * docked to that port,
00290                                                   * else p_port[0] = port 
00291                                                   * # docked to on host. 
00292                                                   */
00293     short   p_tractor;                           /* What player is in tractor
00294                                                   * lock */
00295     int     p_pos;                               /* My position in the player
00296                                                   * file */
00297   };
00298 
00299 struct statentry
00300   {
00301     char    name[16], password[16];
00302     struct stats stats;
00303   };
00304 
00305 /* Torpedo states */
00306 
00307 #define TFREE 0
00308 #define TMOVE 1
00309 #define TEXPLODE 2
00310 #define TDET 3
00311 #define TOFF 4
00312 #define TSTRAIGHT 5                              /* Non-wobbling torp */
00313 
00314 
00315 struct torp
00316   {
00317     unsigned char t_status;                      /* State information */
00318     short   t_owner;
00319     char    t_war;                               /* enemies */
00320     int     t_x;
00321     int     t_y;
00322     short   t_fuse;                              /* Life left in current *
00323                                                   * state */
00324     unsigned char t_updateFuse;                  /* Updates before torp will
00325                                                   * expire */
00326     unsigned char t_dir;                         /* direction */
00327   };
00328 
00329 
00330 /* Plasma Torpedo states */
00331 
00332 #define PTFREE 0
00333 #define PTMOVE 1
00334 #define PTEXPLODE 2
00335 #define PTDET 3
00336 
00337 struct plasmatorp
00338   {
00339     unsigned char pt_status;                     /* State information */
00340     char    pt_war;                              /* enemies */
00341     short   pt_owner;
00342     short   pt_fuse;                             /* Life left in current * *
00343                                                   * state */
00344     short   pt_updateFuse;                       /* Time till expiry */
00345     int     pt_x;
00346     int     pt_y;
00347   };
00348 
00349 #define PHFREE 0x00
00350 #define PHHIT  0x01                              /* When it hits a person */
00351 #define PHMISS 0x02
00352 #define PHHIT2 0x04                              /* When it hits a photon */
00353 
00354 struct phaser
00355   {
00356     unsigned char ph_status;                     /* What it's up to */
00357     unsigned char ph_dir;                        /* direction */
00358     short   ph_target;                           /* Who's being hit (for * *
00359                                                   * drawing) */
00360     short   ph_updateFuse;                       /* Time till expiry */
00361     short   ph_fuse;                             /* Life left for drawing */
00362     int     ph_x, ph_y;                          /* For when it hits a torp */
00363   };
00364 
00365 
00366 #ifdef RSA
00367 struct rsa_key
00368   {
00369     unsigned char client_type[KEY_SIZE];
00370     unsigned char architecture[KEY_SIZE];
00371     unsigned char global[KEY_SIZE];
00372     unsigned char public[KEY_SIZE];
00373   };
00374 
00375 #endif
00376 
00377 /* An important note concerning planets:  The game assumes that the planets
00378  * are in a 'known' order.  Ten planets per team, the first being the home
00379  * planet. */
00380 
00381 /* the lower bits represent the original owning team */
00382 #define PLREPAIR 0x010
00383 #define PLFUEL 0x020
00384 #define PLAGRI 0x040
00385 #define PLREDRAW 0x080                           /* Player close for redraw */
00386 #define PLHOME 0x100                             /* home planet for a given
00387                                                   * team */
00388 #define PLCOUP 0x200                             /* Coup has occured */
00389 #define PLCHEAP 0x400                            /* Planet was taken from 
00390                                                   * undefended team */
00391 #define PLCLEAR 0x800
00392 
00393 struct planet
00394   {
00395     int     pl_no;
00396     int     pl_flags;                            /* State information */
00397     int     pl_owner;
00398     int     pl_x;
00399     int     pl_y;
00400     char    pl_name[16];
00401     int     pl_namelen;                          /* Cuts back on strlen's */
00402     int     pl_armies;
00403     int     pl_info;                             /* Teams which have info on
00404                                                   * planets */
00405     int     pl_deadtime;                         /* Time before planet will 
00406                                                   * support life */
00407     int     pl_couptime;                         /* Time before coup may take
00408                                                   * place */
00409   };
00410 
00411 #define MVALID 0x01
00412 #define MGOD   0x10
00413 #define MMOO   0x12
00414 
00415 #ifdef TOOLS
00416 #define MTOOLS 0x14
00417 #endif
00418 
00419 /* order flags by importance (0x100 - 0x400) */
00420 /* restructuring of message flags to squeeze them all into 1 byte - jmn */
00421 /* hopefully quasi-back-compatible: MVALID, MINDIV, MTEAM, MALL, MGOD use up
00422  * 5 bits. this leaves us 3 bits. since the server only checks for those
00423  * flags when deciding message related things and since each of the above
00424  * cases only has 1 flag on at a time we can overlap the meanings of the
00425  * flags */
00426 
00427 #define MINDIV 0x02
00428 /* these go with MINDIV flag */
00429 
00430 #ifdef STDBG
00431 #define MDBG   0x20
00432 #endif
00433 
00434 #define MCONFIG 0x40                             /* config messages from * *
00435                                                   * server */
00436 #define MDIST 0x60                               /* flag distress type * *
00437                                                   * messages properly */
00438 
00439 #ifdef MULTILINE_MACROS
00440 #define MMACRO 0x80
00441 #endif
00442 
00443 #define MTEAM  0x04
00444 /* these go with MTEAM flag */
00445 #define MTAKE  0x20
00446 #define MDEST  0x40
00447 #define MBOMB  0x60
00448 #define MCOUP1 0x80
00449 #define MCOUP2 0xA0
00450 #define MDISTR 0xC0                              /* flag distress type
00451                                                   * messages */
00452 
00453 #define MALL   0x08
00454 /* these go with MALL flag */
00455 #define MGENO  0x20                              /* MGENO is not used in INL
00456                                                   * server but beLONGs
00457                                                   * here  */
00458 #define MCONQ  0x20                              /* not enought bits to 
00459                                                   * distinguish MCONQ/MGENO :-( */
00460 #define MKILLA 0x40
00461 #define MKILLP 0x60
00462 #define MKILL  0x80
00463 #define MLEAVE 0xA0
00464 #define MJOIN  0xC0
00465 #define MGHOST 0xE0
00466 /* MMASK not used in INL server */
00467 
00468 #define MWHOMSK  0x1f                            /* mask with this to find
00469                                                   * who msg to */
00470 #define MWHATMSK 0xe0                            /* mask with this to find
00471                                                   * what message about */
00472 
00473 /* old flags... 
00474  * #define MVALID 0x01 
00475  * #define MINDIV 0x02 
00476  * #define MTEAM  0x04
00477  * #define MALL   0x08 
00478  * #define MGOD   0x10
00479  * 
00480  * #define MGENO  0x100            order these by importance (0x100 - 0x400)
00481  * #define MCONQ  0x110 
00482  * #define MTAKE  0x120 
00483  * #define MDEST  0x130 
00484  * #define MKILLA 0x200 
00485  * #define MBOMB  0x210 
00486  * #define MKILLP 0x220 
00487  * #define MKILL  0x230
00488  * #define MLEAVE 0x300 
00489  * #define MJOIN  0x310 
00490  * #define MGHOST 0x320 
00491  * #define MCOUP1 0x330 
00492  * #define MCOUP2 0x340    
00493  * end of old flags  */
00494 
00495 
00496 
00497 struct message
00498   {
00499     int     m_no;
00500     int     m_flags;
00501     int     m_time;
00502     int     m_recpt;
00503     char    m_data[80];
00504   };
00505 
00506 /* message control structure */
00507 
00508 struct mctl
00509   {
00510     int     mc_current;
00511   };
00512 
00513 /* This is a structure used for objects returned by mouse pointing */
00514 
00515 #define PLANETTYPE 0x1
00516 #define PLAYERTYPE 0x2
00517 
00518 struct obtype
00519   {
00520     int     o_type;
00521     int     o_num;
00522   };
00523 
00524 struct rank
00525   {
00526     float   hours, ratings, defense;
00527     char   *name, *cname;
00528   };
00529 
00530 struct memory
00531   {
00532     struct player players[MAXPLAYER];
00533     struct torp torps[MAXPLAYER * MAXTORP];
00534     struct plasmatorp plasmatorps[MAXPLAYER * MAXPLASMA];
00535     struct status status[1];
00536     struct planet planets[MAXPLANETS];
00537     struct phaser phasers[MAXPLAYER];
00538     struct mctl mctl[1];
00539     struct message messages[MAXMESSAGE];
00540     struct ship shipvals[NUM_TYPES];
00541   };
00542 
00543 struct plupdate
00544   {
00545     int     plu_update;
00546     int     plu_x, plu_y;
00547   };
00548 
00549 struct macro_list
00550   {
00551     int     type;
00552     unsigned char key;
00553     char    who;
00554     char   *string;
00555   };
00556 
00557 /******************************************************************************/
00558 /***                   Distress structure definitions                       ***/
00559 /***                                                                        ***/
00560 /***  The LOW_DISTRESS, MID_DISTRESS, and HIGH_DISTRESS are all used to     ***/
00561 /***  index the correct items within the DISTRESS_BLOCK's item array.  The  ***/
00562 /***  distress block contains a minimum and maximum value for each item, a  ***/
00563 /***  flag to indicate whether the distress on this value is active or not, ***/
00564 /***  and three single character pointers for different severity levels.    ***/
00565 /******************************************************************************/
00566 
00567 #define DIST_LOW            ( 0 )
00568 #define DIST_MID            ( 1 )
00569 #define DIST_HIGH           ( 2 )
00570 
00571 #define DIST_SHIELDS        ( 0 )
00572 #define DIST_DAMAGE         ( 1 )
00573 #define DIST_WTEMP          ( 2 )
00574 #define DIST_ETEMP          ( 3 )
00575 #define DIST_ARMYS          ( 4 )
00576 #define DIST_FUEL           ( 5 )
00577 
00578 typedef struct distress_block
00579   {
00580     int     min, max;
00581     int     on;
00582     char   *item[3];
00583   }
00584 
00585 DISTRESS_DESC;
00586 
00587 struct distress_list
00588   {                                              /* need one for ships and *
00589                                                   * * one for SBs */
00590     DISTRESS_DESC problem[6];
00591   };
00592 
00593 #ifdef HOCKEY_LINES
00594 struct s_line
00595   {
00596     int     begin_x, begin_y;                    /* Start point of the line */
00597     int     end_x, end_y;                        /* End point of the line   */
00598 //W_Color color;                                 /* The color of the line   */
00599     int     orientation;                         /* Horizontal or Vertical? */
00600     int    *flag;                                /* Should line be drawn?   */
00601   };
00602 
00603 #endif /* HOCKEY_LINES */
00604 
00605 struct shipdef
00606   {
00607     char   *name;
00608     char   *rcfile;
00609     unsigned char *keymap;
00610     unsigned char *buttonmap;
00611     unsigned char *ckeymap;
00612   };
00613 
00614 #ifdef TOOLS
00615 struct key_list
00616   {
00617     unsigned char dest;
00618     char   *name;
00619   };
00620 
00621 #endif
00622 
00623 #endif /* _h_struct */
00624 
00625 
00626 
00627 
00628 
00629 
00630 
00631 
00632 
00633 
00634 
00635 
00636 
00637 

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