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