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