|
|
1.1 ! root 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: ! 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: 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: }; ! 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: // the *index functions create configstrings and some internal server state ! 102: int (*modelindex) (char *name); ! 103: int (*soundindex) (char *name); ! 104: int (*imageindex) (char *name); ! 105: ! 106: void (*setmodel) (edict_t *ent, char *name); ! 107: ! 108: // collision detection ! 109: trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, edict_t *passent, int contentmask); ! 110: int (*pointcontents) (vec3_t point); ! 111: qboolean (*inPVS) (vec3_t p1, vec3_t p2); ! 112: qboolean (*inPHS) (vec3_t p1, vec3_t p2); ! 113: void (*SetAreaPortalState) (int portalnum, qboolean open); ! 114: qboolean (*AreasConnected) (int area1, int area2); ! 115: ! 116: // an entity will never be sent to a client or used for collision ! 117: // if it is not passed to linkentity. If the size, position, or ! 118: // solidity changes, it must be relinked. ! 119: void (*linkentity) (edict_t *ent); ! 120: void (*unlinkentity) (edict_t *ent); // call before removing an interactive edict ! 121: int (*BoxEdicts) (vec3_t mins, vec3_t maxs, edict_t **list, int maxcount, int areatype); ! 122: void (*Pmove) (pmove_t *pmove); // player movement code common with client prediction ! 123: ! 124: // network messaging ! 125: void (*multicast) (vec3_t origin, multicast_t to); ! 126: void (*unicast) (edict_t *ent, qboolean reliable); ! 127: void (*WriteChar) (int c); ! 128: void (*WriteByte) (int c); ! 129: void (*WriteShort) (int c); ! 130: void (*WriteLong) (int c); ! 131: void (*WriteFloat) (float f); ! 132: void (*WriteString) (char *s); ! 133: void (*WritePosition) (vec3_t pos); // some fractional bits ! 134: void (*WriteDir) (vec3_t pos); // single byte encoded, very coarse ! 135: void (*WriteAngle) (float f); ! 136: ! 137: // managed memory allocation ! 138: void *(*TagMalloc) (int size, int tag); ! 139: void (*TagFree) (void *block); ! 140: void (*FreeTags) (int tag); ! 141: ! 142: // console variable interaction ! 143: cvar_t *(*cvar) (char *var_name, char *value, int flags); ! 144: cvar_t *(*cvar_set) (char *var_name, char *value); ! 145: cvar_t *(*cvar_forceset) (char *var_name, char *value); ! 146: ! 147: // ClientCommand and ServerCommand parameter access ! 148: int (*argc) (void); ! 149: char *(*argv) (int n); ! 150: char *(*args) (void); // concatenation of all argv >= 1 ! 151: ! 152: // add commands to the server console as if they were typed in ! 153: // for map changing, etc ! 154: void (*AddCommandString) (char *text); ! 155: ! 156: void (*DebugGraph) (float value, int color); ! 157: } game_import_t; ! 158: ! 159: // ! 160: // functions exported by the game subsystem ! 161: // ! 162: typedef struct ! 163: { ! 164: int apiversion; ! 165: ! 166: // the init function will only be called when a game starts, ! 167: // not each time a level is loaded. Persistant data for clients ! 168: // and the server can be allocated in init ! 169: void (*Init) (void); ! 170: void (*Shutdown) (void); ! 171: ! 172: // each new level entered will cause a call to SpawnEntities ! 173: void (*SpawnEntities) (char *mapname, char *entstring, char *spawnpoint); ! 174: ! 175: // Read/Write Game is for storing persistant cross level information ! 176: // about the world state and the clients. ! 177: // WriteGame is called every time a level is exited. ! 178: // ReadGame is called on a loadgame. ! 179: void (*WriteGame) (char *filename, qboolean autosave); ! 180: void (*ReadGame) (char *filename); ! 181: ! 182: // ReadLevel is called after the default map information has been ! 183: // loaded with SpawnEntities ! 184: void (*WriteLevel) (char *filename); ! 185: void (*ReadLevel) (char *filename); ! 186: ! 187: qboolean (*ClientConnect) (edict_t *ent, char *userinfo); ! 188: void (*ClientBegin) (edict_t *ent); ! 189: void (*ClientUserinfoChanged) (edict_t *ent, char *userinfo); ! 190: void (*ClientDisconnect) (edict_t *ent); ! 191: void (*ClientCommand) (edict_t *ent); ! 192: void (*ClientThink) (edict_t *ent, usercmd_t *cmd); ! 193: ! 194: void (*RunFrame) (void); ! 195: ! 196: // ServerCommand will be called when an "sv <command>" command is issued on the ! 197: // server console. ! 198: // The game can issue gi.argc() / gi.argv() commands to get the rest ! 199: // of the parameters ! 200: void (*ServerCommand) (void); ! 201: ! 202: // ! 203: // global variables shared between game and server ! 204: // ! 205: ! 206: // The edict array is allocated in the game dll so it ! 207: // can vary in size from one game to another. ! 208: // ! 209: // The size will be fixed when ge->Init() is called ! 210: struct edict_s *edicts; ! 211: int edict_size; ! 212: int num_edicts; // current number, <= max_edicts ! 213: int max_edicts; ! 214: } game_export_t; ! 215: ! 216: game_export_t *GetGameApi (game_import_t *import);
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.