1 /*
2 ===========================================================================
3 
4 Return to Castle Wolfenstein single player GPL Source Code
5 Copyright (C) 1999-2010 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Return to Castle Wolfenstein single player GPL Source Code (“RTCW SP Source Code”).
8 
9 RTCW SP Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 RTCW SP Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with RTCW SP Source Code.  If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the RTCW SP Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the RTCW SP Source Code.  If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 
30 
31 #define CMD_BACKUP          64
32 #define CMD_MASK            ( CMD_BACKUP - 1 )
33 // allow a lot of command backups for very fast systems
34 // multiple commands may be combined into a single packet, so this
35 // needs to be larger than PACKET_BACKUP
36 
37 
38 #define MAX_ENTITIES_IN_SNAPSHOT    256
39 
40 // snapshots are a view of the server at a given time
41 
42 // Snapshots are generated at regular time intervals by the server,
43 // but they may not be sent if a client's rate level is exceeded, or
44 // they may be dropped by the network.
45 typedef struct {
46 	int snapFlags;                      // SNAPFLAG_RATE_DELAYED, etc
47 	int ping;
48 
49 	int serverTime;                 // server time the message is valid for (in msec)
50 
51 	byte areamask[MAX_MAP_AREA_BYTES];                  // portalarea visibility bits
52 
53 	playerState_t ps;                       // complete information about the current player at this time
54 
55 	int numEntities;                        // all of the entities that need to be presented
56 	entityState_t entities[MAX_ENTITIES_IN_SNAPSHOT];   // at the time of this snapshot
57 
58 	int numServerCommands;                  // text based server commands to execute when this
59 	int serverCommandSequence;              // snapshot becomes current
60 } snapshot_t;
61 
62 enum {
63 	CGAME_EVENT_NONE,
64 	CGAME_EVENT_TEAMMENU,
65 	CGAME_EVENT_SCOREBOARD,
66 	CGAME_EVENT_EDITHUD
67 };
68 
69 
70 /*
71 ==================================================================
72 
73 functions imported from the main executable
74 
75 ==================================================================
76 */
77 
78 #define CGAME_IMPORT_API_VERSION    3
79 
80 typedef enum {
81 	CG_PRINT,
82 	CG_ERROR,
83 	CG_MILLISECONDS,
84 	CG_CVAR_REGISTER,
85 	CG_CVAR_UPDATE,
86 	CG_CVAR_SET,
87 	CG_CVAR_VARIABLESTRINGBUFFER,
88 	CG_ARGC,
89 	CG_ARGV,
90 	CG_ARGS,
91 	CG_FS_FOPENFILE,
92 	CG_FS_READ,
93 	CG_FS_WRITE,
94 	CG_FS_FCLOSEFILE,
95 	CG_SENDCONSOLECOMMAND,
96 	CG_ADDCOMMAND,
97 	CG_SENDCLIENTCOMMAND,
98 	CG_UPDATESCREEN,
99 	CG_CM_LOADMAP,
100 	CG_CM_NUMINLINEMODELS,
101 	CG_CM_INLINEMODEL,
102 	CG_CM_LOADMODEL,
103 	CG_CM_TEMPBOXMODEL,
104 	CG_CM_POINTCONTENTS,
105 	CG_CM_TRANSFORMEDPOINTCONTENTS,
106 	CG_CM_BOXTRACE,
107 	CG_CM_TRANSFORMEDBOXTRACE,
108 // MrE:
109 	CG_CM_CAPSULETRACE,
110 	CG_CM_TRANSFORMEDCAPSULETRACE,
111 	CG_CM_TEMPCAPSULEMODEL,
112 // done.
113 	CG_CM_MARKFRAGMENTS,
114 	CG_S_STARTSOUND,
115 	CG_S_STARTSOUNDEX,  //----(SA)	added
116 	CG_S_STARTLOCALSOUND,
117 	CG_S_CLEARLOOPINGSOUNDS,
118 	CG_S_ADDLOOPINGSOUND,
119 	CG_S_UPDATEENTITYPOSITION,
120 // Ridah, talking animations
121 	CG_S_GETVOICEAMPLITUDE,
122 // done.
123 	CG_S_RESPATIALIZE,
124 	CG_S_REGISTERSOUND,
125 	CG_S_STARTBACKGROUNDTRACK,
126 	CG_S_FADESTREAMINGSOUND,    //----(SA)	modified
127 	CG_S_FADEALLSOUNDS,         //----(SA)	added for fading out everything
128 	CG_S_STARTSTREAMINGSOUND,
129 	CG_R_LOADWORLDMAP,
130 	CG_R_REGISTERMODEL,
131 	CG_R_REGISTERSKIN,
132 	CG_R_REGISTERSHADER,
133 
134 	CG_R_GETSKINMODEL,      // client allowed to view what the .skin loaded so they can set their model appropriately
135 	CG_R_GETMODELSHADER,    // client allowed the shader handle for given model/surface (for things like debris inheriting shader from explosive)
136 
137 	CG_R_REGISTERFONT,
138 	CG_R_CLEARSCENE,
139 	CG_R_ADDREFENTITYTOSCENE,
140 	CG_GET_ENTITY_TOKEN,
141 	CG_R_ADDPOLYTOSCENE,
142 // Ridah
143 	CG_R_ADDPOLYSTOSCENE,
144 	CG_RB_ZOMBIEFXADDNEWHIT,
145 // done.
146 	CG_R_ADDLIGHTTOSCENE,
147 
148 	CG_R_ADDCORONATOSCENE,
149 	CG_R_SETFOG,
150 
151 	CG_R_RENDERSCENE,
152 	CG_R_SETCOLOR,
153 	CG_R_DRAWSTRETCHPIC,
154 	CG_R_DRAWSTRETCHPIC_GRADIENT,   //----(SA)	added
155 	CG_R_MODELBOUNDS,
156 	CG_R_LERPTAG,
157 	CG_GETGLCONFIG,
158 	CG_GETGAMESTATE,
159 	CG_GETCURRENTSNAPSHOTNUMBER,
160 	CG_GETSNAPSHOT,
161 	CG_GETSERVERCOMMAND,
162 	CG_GETCURRENTCMDNUMBER,
163 	CG_GETUSERCMD,
164 	CG_SETUSERCMDVALUE,
165 	CG_R_REGISTERSHADERNOMIP,
166 	CG_MEMORY_REMAINING,
167 
168 	CG_KEY_ISDOWN,
169 	CG_KEY_GETCATCHER,
170 	CG_KEY_SETCATCHER,
171 	CG_KEY_GETKEY,
172 
173 	CG_PC_ADD_GLOBAL_DEFINE,
174 	CG_PC_LOAD_SOURCE,
175 	CG_PC_FREE_SOURCE,
176 	CG_PC_READ_TOKEN,
177 	CG_PC_SOURCE_FILE_AND_LINE,
178 	CG_S_STOPBACKGROUNDTRACK,
179 	CG_REAL_TIME,
180 	CG_SNAPVECTOR,
181 	CG_REMOVECOMMAND,
182 //	CG_R_LIGHTFORPOINT,	// not currently used (sorry, trying to keep CG_MEMSET @ 100)
183 
184 	CG_SENDMOVESPEEDSTOGAME,
185 
186 	CG_CIN_PLAYCINEMATIC,
187 	CG_CIN_STOPCINEMATIC,
188 	CG_CIN_RUNCINEMATIC,
189 	CG_CIN_DRAWCINEMATIC,
190 	CG_CIN_SETEXTENTS,
191 	CG_R_REMAP_SHADER,
192 //	CG_S_ADDREALLOOPINGSOUND,	// not currently used (sorry, trying to keep CG_MEMSET @ 100)
193 	CG_S_STOPLOOPINGSOUND,
194 	CG_S_STOPSTREAMINGSOUND,    //----(SA)	added
195 
196 	CG_LOADCAMERA,
197 	CG_STARTCAMERA,
198 	CG_STOPCAMERA,  //----(SA)	added
199 	CG_GETCAMERAINFO,
200 
201 	CG_MEMSET = 110,
202 	CG_MEMCPY,
203 	CG_STRNCPY,
204 	CG_SIN,
205 	CG_COS,
206 	CG_ATAN2,
207 	CG_SQRT,
208 	CG_FLOOR,
209 	CG_CEIL,
210 
211 	CG_TESTPRINTINT,
212 	CG_TESTPRINTFLOAT,
213 	CG_ACOS,
214 
215 	CG_INGAME_POPUP,        //----(SA)	added
216 	CG_INGAME_CLOSEPOPUP,   // NERVE - SMF
217 	CG_LIMBOCHAT,           // NERVE - SMF
218 
219 	CG_GETMODELINFO,
220 
221 	// New in IORTCW
222 	CG_ALLOC = 900
223 
224 } cgameImport_t;
225 
226 
227 /*
228 ==================================================================
229 
230 functions exported to the main executable
231 
232 ==================================================================
233 */
234 
235 typedef enum {
236 	CG_INIT,
237 //	void CG_Init( int serverMessageNum, int serverCommandSequence )
238 	// called when the level loads or when the renderer is restarted
239 	// all media should be registered at this time
240 	// cgame will display loading status by calling SCR_Update, which
241 	// will call CG_DrawInformation during the loading process
242 	// reliableCommandSequence will be 0 on fresh loads, but higher for
243 	// demos, tourney restarts, or vid_restarts
244 
245 	CG_SHUTDOWN,
246 //	void (*CG_Shutdown)( void );
247 	// oportunity to flush and close any open files
248 
249 	CG_CONSOLE_COMMAND,
250 //	qboolean (*CG_ConsoleCommand)( void );
251 	// a console command has been issued locally that is not recognized by the
252 	// main game system.
253 	// use Cmd_Argc() / Cmd_Argv() to read the command, return qfalse if the
254 	// command is not known to the game
255 
256 	CG_DRAW_ACTIVE_FRAME,
257 //	void (*CG_DrawActiveFrame)( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback );
258 	// Generates and draws a game scene and status information at the given time.
259 	// If demoPlayback is set, local movement prediction will not be enabled
260 
261 	CG_CROSSHAIR_PLAYER,
262 //	int (*CG_CrosshairPlayer)( void );
263 
264 	CG_LAST_ATTACKER,
265 //	int (*CG_LastAttacker)( void );
266 
267 	CG_KEY_EVENT,
268 //	void	(*CG_KeyEvent)( int key, qboolean down );
269 
270 	CG_MOUSE_EVENT,
271 //	void	(*CG_MouseEvent)( int dx, int dy );
272 	CG_EVENT_HANDLING,
273 //	void (*CG_EventHandling)(int type);
274 
275 	CG_GET_TAG,
276 //	qboolean CG_GetTag( int clientNum, char *tagname, orientation_t *or );
277 
278 	MAX_CGAME_EXPORT
279 
280 } cgameExport_t;
281 
282 //----------------------------------------------
283