home *** CD-ROM | disk | FTP | other *** search
/ Gambler 19 / GAMBLERCD19.BIN / UTILS / 3D / BRONIE / DUAL_LAU.ZIP / src / game.h < prev    next >
C/C++ Source or Header  |  1998-01-13  |  7KB  |  213 lines

  1.  
  2. // game.h -- game dll information visible to server
  3.  
  4. #define GAME_API_VERSION      2
  5.  
  6. // edict->svflags
  7.  
  8. #define    SVF_NOCLIENT            0x00000001    // don't send entity to clients, even if it has effects
  9. #define    SVF_DEADMONSTER            0x00000002    // treat as CONTENTS_DEADMONSTER for collision
  10. #define    SVF_MONSTER                0x00000004    // treat as CONTENTS_MONSTER for collision
  11.  
  12. // edict->solid values
  13.  
  14. typedef enum
  15. {
  16. SOLID_NOT,            // no interaction with other objects
  17. SOLID_TRIGGER,        // only touch when inside, after moving
  18. SOLID_BBOX,            // touch on edge
  19. SOLID_BSP            // bsp clip, touch on edge
  20. } solid_t;
  21.  
  22. //===============================================================
  23.  
  24. // link_t is only used for entity area links now
  25. typedef struct link_s
  26. {
  27.     struct link_s    *prev, *next;
  28. } link_t;
  29.  
  30. #define    MAX_ENT_CLUSTERS    16
  31.  
  32.  
  33. typedef struct edict_s edict_t;
  34. typedef struct gclient_s gclient_t;
  35.  
  36.  
  37. #ifndef GAME_INCLUDE
  38.  
  39. typedef struct gclient_s
  40. {
  41.     player_state_t    ps;        // communicated by server to clients
  42.     int                ping;
  43.     // the game dll can add anything it wants after
  44.     // this point in the structure
  45. } gclient_t;
  46.  
  47.  
  48. struct edict_s
  49. {
  50.     entity_state_t    s;
  51.     struct gclient_s    *client;
  52.     qboolean    inuse;
  53.     int            linkcount;
  54.  
  55.     // FIXME: move these fields to a server private sv_entity_t
  56.     link_t        area;                // linked to a division node or leaf
  57.     
  58.     int            num_clusters;        // if -1, use headnode instead
  59.     int            clusternums[MAX_ENT_CLUSTERS];
  60.     int            headnode;            // unused if num_clusters != -1
  61.     int            areanum, areanum2;
  62.  
  63.     //================================
  64.  
  65.     int            svflags;            // SVF_NOCLIENT, SVF_DEADMONSTER, SVF_MONSTER, etc
  66.     vec3_t        mins, maxs;
  67.     vec3_t        absmin, absmax, size;
  68.     solid_t        solid;
  69.     int            clipmask;
  70.     edict_t        *owner;
  71.  
  72.     // the game dll can add anything it wants after
  73.     // this point in the structure
  74. };
  75.  
  76. #endif        // GAME_INCLUDE
  77.  
  78. //===============================================================
  79.  
  80. //
  81. // functions provided by the main engine
  82. //
  83. typedef struct
  84. {
  85.     // special messages
  86.     void    (*bprintf) (int printlevel, char *fmt, ...);
  87.     void    (*dprintf) (char *fmt, ...);
  88.     void    (*cprintf) (edict_t *ent, int printlevel, char *fmt, ...);
  89.     void    (*centerprintf) (edict_t *ent, char *fmt, ...);
  90.     void    (*sound) (edict_t *ent, int channel, int soundindex, float volume, float attenuation, float timeofs);
  91.     void    (*positioned_sound) (vec3_t origin, edict_t *ent, int channel, int soundinedex, float volume, float attenuation, float timeofs);
  92.  
  93.     // config strings hold all the index strings, the lightstyles,
  94.     // and misc data like the sky definition and cdtrack.
  95.     // All of the current configstrings are sent to clients when
  96.     // they connect, and changes are sent to all connected clients.
  97.     void    (*configstring) (int num, char *string);
  98.  
  99.     void    (*error) (char *fmt, ...);
  100.  
  101.     // new names can only be added during spawning
  102.     // existing names can be looked up at any time
  103.     int        (*modelindex) (char *name);
  104.     int        (*soundindex) (char *name);
  105.     int        (*imageindex) (char *name);
  106.  
  107.     void    (*setmodel) (edict_t *ent, char *name);
  108.  
  109.     // collision detection
  110.     trace_t    (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, edict_t *passent, int contentmask);
  111.     int        (*pointcontents) (vec3_t point);
  112.     qboolean    (*inPVS) (vec3_t p1, vec3_t p2);
  113.     qboolean    (*inPHS) (vec3_t p1, vec3_t p2);
  114.     void        (*SetAreaPortalState) (int portalnum, qboolean open);
  115.     qboolean    (*AreasConnected) (int area1, int area2);
  116.  
  117.     // an entity will never be sent to a client or used for collision
  118.     // if it is not passed to linkentity.  If the size, position, or
  119.     // solidity changes, it must be relinked.
  120.     void    (*linkentity) (edict_t *ent);
  121.     void    (*unlinkentity) (edict_t *ent);        // call before removing an interactive edict
  122.     int        (*BoxEdicts) (vec3_t mins, vec3_t maxs, edict_t **list,    int maxcount, int areatype);
  123.     void    (*Pmove) (pmove_t *pmove);        // player movement code common with client prediction
  124.  
  125.     // network messaging
  126.     void    (*multicast) (vec3_t origin, multicast_t to);
  127.     void    (*unicast) (edict_t *ent, qboolean reliable);
  128.     void    (*WriteChar) (int c);
  129.     void    (*WriteByte) (int c);
  130.     void    (*WriteShort) (int c);
  131.     void    (*WriteLong) (int c);
  132.     void    (*WriteFloat) (float f);
  133.     void    (*WriteString) (char *s);
  134.     void    (*WritePosition) (vec3_t pos);    // some fractional bits
  135.     void    (*WriteDir) (vec3_t pos);        // single byte encoded, very coarse
  136.     void    (*WriteAngle) (float f);
  137.  
  138.     // managed memory allocation
  139.     void    *(*TagMalloc) (int size, int tag);
  140.     void    (*TagFree) (void *block);
  141.     void    (*FreeTags) (int tag);
  142.  
  143.     // console variable interaction
  144.     cvar_t    *(*cvar) (char *var_name, char *value, int flags);
  145.     cvar_t    *(*cvar_set) (char *var_name, char *value);
  146.     cvar_t    *(*cvar_forceset) (char *var_name, char *value);
  147.  
  148.     // ClientCommand and coneole command parameter checking
  149.     int        (*argc) (void);
  150.     char    *(*argv) (int n);
  151.     char    *(*args) (void);
  152.  
  153.     // add commands to the server console as if they were typed in
  154.     // for map changing, etc
  155.     void    (*AddCommandString) (char *text);
  156.  
  157.     void    (*DebugGraph) (float value, int color);
  158. } game_import_t;
  159.  
  160. //
  161. // functions exported by the game subsystem
  162. //
  163. typedef struct
  164. {
  165.     int            apiversion;
  166.  
  167.     // the init function will only be called when a game starts,
  168.     // not each time a level is loaded.  Persistant data for clients
  169.     // and the server can be allocated in init
  170.     void        (*Init) (void);
  171.     void        (*Shutdown) (void);
  172.  
  173.     // each new level entered will cause a call to SpawnEntities
  174.     void        (*SpawnEntities) (char *mapname, char *entstring, char *spawnpoint);
  175.  
  176.     // Read/Write Game is for storing persistant cross level information
  177.     // about the world state and the clients.
  178.     // WriteGame is called every time a level is exited.
  179.     // ReadGame is called on a loadgame.
  180.     void        (*WriteGame) (char *filename);
  181.     void        (*ReadGame) (char *filename);
  182.  
  183.     // ReadLevel is called after the default map information has been
  184.     // loaded with SpawnEntities, so any stored client spawn spots will
  185.     // be used when the clients reconnect.
  186.     void        (*WriteLevel) (char *filename);
  187.     void        (*ReadLevel) (char *filename);
  188.  
  189.     qboolean    (*ClientConnect) (edict_t *ent, char *userinfo, qboolean loadgame);
  190.     void        (*ClientBegin) (edict_t *ent, qboolean loadgame);
  191.     void        (*ClientUserinfoChanged) (edict_t *ent, char *userinfo);
  192.     void        (*ClientDisconnect) (edict_t *ent);
  193.     void        (*ClientCommand) (edict_t *ent);
  194.     void        (*ClientThink) (edict_t *ent, usercmd_t *cmd);
  195.  
  196.     void        (*RunFrame) (void);
  197.  
  198.     //
  199.     // global variables shared between game and server
  200.     //
  201.  
  202.     // The edict array is allocated in the game dll so it
  203.     // can vary in size from one game to another.
  204.     // 
  205.     // The size will be fixed when ge->Init() is called
  206.     struct edict_s    *edicts;
  207.     int            edict_size;
  208.     int            num_edicts;        // current number, <= max_edicts
  209.     int            max_edicts;
  210. } game_export_t;
  211.  
  212. game_export_t *GetGameApi (game_import_t *import);
  213.