1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4 Copyright (C) 2000-2006 Tim Angus
5 
6 This file is part of Tremulous.
7 
8 Tremulous is free software; you can redistribute it
9 and/or modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the License,
11 or (at your option) any later version.
12 
13 Tremulous is distributed in the hope that it will be
14 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Tremulous; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 ===========================================================================
22 */
23 
24 
25 #define CMD_BACKUP      64
26 #define CMD_MASK      (CMD_BACKUP - 1)
27 // allow a lot of command backups for very fast systems
28 // multiple commands may be combined into a single packet, so this
29 // needs to be larger than PACKET_BACKUP
30 
31 
32 #define MAX_ENTITIES_IN_SNAPSHOT  256
33 
34 // snapshots are a view of the server at a given time
35 
36 // Snapshots are generated at regular time intervals by the server,
37 // but they may not be sent if a client's rate level is exceeded, or
38 // they may be dropped by the network.
39 typedef struct
40 {
41   int           snapFlags;                            // SNAPFLAG_RATE_DELAYED, etc
42   int           ping;
43 
44   int           serverTime;                           // server time the message is valid for (in msec)
45 
46   byte          areamask[ MAX_MAP_AREA_BYTES ];       // portalarea visibility bits
47 
48   playerState_t ps;                                   // complete information about the current player at this time
49 
50   int           numEntities;                          // all of the entities that need to be presented
51   entityState_t entities[ MAX_ENTITIES_IN_SNAPSHOT ]; // at the time of this snapshot
52 
53   int           numServerCommands;                    // text based server commands to execute when this
54   int           serverCommandSequence;                // snapshot becomes current
55 } snapshot_t;
56 
57 enum
58 {
59   CGAME_EVENT_NONE,
60   CGAME_EVENT_TEAMMENU,
61   CGAME_EVENT_SCOREBOARD,
62   CGAME_EVENT_EDITHUD
63 };
64 
65 /*
66 ==================================================================
67 
68 functions imported from the main executable
69 
70 ==================================================================
71 */
72 
73 #define CGAME_IMPORT_API_VERSION  4
74 
75 typedef enum
76 {
77   CG_PRINT,
78   CG_ERROR,
79   CG_MILLISECONDS,
80   CG_CVAR_REGISTER,
81   CG_CVAR_UPDATE,
82   CG_CVAR_SET,
83   CG_CVAR_VARIABLESTRINGBUFFER,
84   CG_ARGC,
85   CG_ARGV,
86   CG_ARGS,
87   CG_FS_FOPENFILE,
88   CG_FS_READ,
89   CG_FS_WRITE,
90   CG_FS_FCLOSEFILE,
91   CG_SENDCONSOLECOMMAND,
92   CG_ADDCOMMAND,
93   CG_SENDCLIENTCOMMAND,
94   CG_UPDATESCREEN,
95   CG_CM_LOADMAP,
96   CG_CM_NUMINLINEMODELS,
97   CG_CM_INLINEMODEL,
98   CG_CM_LOADMODEL,
99   CG_CM_TEMPBOXMODEL,
100   CG_CM_POINTCONTENTS,
101   CG_CM_TRANSFORMEDPOINTCONTENTS,
102   CG_CM_BOXTRACE,
103   CG_CM_TRANSFORMEDBOXTRACE,
104   CG_CM_MARKFRAGMENTS,
105   CG_S_STARTSOUND,
106   CG_S_STARTLOCALSOUND,
107   CG_S_CLEARLOOPINGSOUNDS,
108   CG_S_ADDLOOPINGSOUND,
109   CG_S_UPDATEENTITYPOSITION,
110   CG_S_RESPATIALIZE,
111   CG_S_REGISTERSOUND,
112   CG_S_STARTBACKGROUNDTRACK,
113   CG_R_LOADWORLDMAP,
114   CG_R_REGISTERMODEL,
115   CG_R_REGISTERSKIN,
116   CG_R_REGISTERSHADER,
117   CG_R_CLEARSCENE,
118   CG_R_ADDREFENTITYTOSCENE,
119   CG_R_ADDPOLYTOSCENE,
120   CG_R_ADDLIGHTTOSCENE,
121   CG_R_RENDERSCENE,
122   CG_R_SETCOLOR,
123   CG_R_DRAWSTRETCHPIC,
124   CG_R_MODELBOUNDS,
125   CG_R_LERPTAG,
126   CG_GETGLCONFIG,
127   CG_GETGAMESTATE,
128   CG_GETCURRENTSNAPSHOTNUMBER,
129   CG_GETSNAPSHOT,
130   CG_GETSERVERCOMMAND,
131   CG_GETCURRENTCMDNUMBER,
132   CG_GETUSERCMD,
133   CG_SETUSERCMDVALUE,
134   CG_R_REGISTERSHADERNOMIP,
135   CG_MEMORY_REMAINING,
136   CG_R_REGISTERFONT,
137   CG_KEY_ISDOWN,
138   CG_KEY_GETCATCHER,
139   CG_KEY_SETCATCHER,
140   CG_KEY_GETKEY,
141   CG_PC_ADD_GLOBAL_DEFINE,
142   CG_PC_LOAD_SOURCE,
143   CG_PC_FREE_SOURCE,
144   CG_PC_READ_TOKEN,
145   CG_PC_SOURCE_FILE_AND_LINE,
146   CG_S_STOPBACKGROUNDTRACK,
147   CG_REAL_TIME,
148   CG_SNAPVECTOR,
149   CG_REMOVECOMMAND,
150   CG_R_LIGHTFORPOINT,
151   CG_CIN_PLAYCINEMATIC,
152   CG_CIN_STOPCINEMATIC,
153   CG_CIN_RUNCINEMATIC,
154   CG_CIN_DRAWCINEMATIC,
155   CG_CIN_SETEXTENTS,
156   CG_R_REMAP_SHADER,
157   CG_S_ADDREALLOOPINGSOUND,
158   CG_S_STOPLOOPINGSOUND,
159 
160   CG_CM_TEMPCAPSULEMODEL,
161   CG_CM_CAPSULETRACE,
162   CG_CM_TRANSFORMEDCAPSULETRACE,
163   CG_R_ADDADDITIVELIGHTTOSCENE,
164   CG_GET_ENTITY_TOKEN,
165   CG_R_ADDPOLYSTOSCENE,
166   CG_R_INPVS,
167   CG_FS_SEEK,
168   CG_FS_GETFILELIST,
169   CG_LITERAL_ARGS,
170   CG_CM_BISPHERETRACE,
171   CG_CM_TRANSFORMEDBISPHERETRACE,
172   CG_GETDEMOSTATE,
173   CG_GETDEMOPOS,
174   CG_GETDEMONAME,
175 
176   CG_KEY_KEYNUMTOSTRINGBUF,
177   CG_KEY_GETBINDINGBUF,
178   CG_KEY_SETBINDING,
179 
180   CG_MEMSET = 200,
181   CG_MEMCPY,
182   CG_STRNCPY,
183   CG_SIN,
184   CG_COS,
185   CG_ATAN2,
186   CG_SQRT,
187   CG_FLOOR,
188   CG_CEIL,
189 
190   CG_TESTPRINTINT,
191   CG_TESTPRINTFLOAT,
192   CG_ACOS
193 } cgameImport_t;
194 
195 
196 /*
197 ==================================================================
198 
199 functions exported to the main executable
200 
201 ==================================================================
202 */
203 
204 typedef enum
205 {
206   CG_INIT,
207   // void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum )
208   // called when the level loads or when the renderer is restarted
209   // all media should be registered at this time
210   // cgame will display loading status by calling SCR_Update, which
211   // will call CG_DrawInformation during the loading process
212   // reliableCommandSequence will be 0 on fresh loads, but higher for
213   // demos, tourney restarts, or vid_restarts
214 
215   CG_SHUTDOWN,
216   // void (*CG_Shutdown)( void );
217   // oportunity to flush and close any open files
218 
219   CG_CONSOLE_COMMAND,
220   // qboolean (*CG_ConsoleCommand)( void );
221   // a console command has been issued locally that is not recognized by the
222   // main game system.
223   // use Cmd_Argc() / Cmd_Argv() to read the command, return qfalse if the
224   // command is not known to the game
225 
226   CG_DRAW_ACTIVE_FRAME,
227   // void (*CG_DrawActiveFrame)( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback );
228   // Generates and draws a game scene and status information at the given time.
229   // If demoPlayback is set, local movement prediction will not be enabled
230 
231   CG_CROSSHAIR_PLAYER,
232   // int (*CG_CrosshairPlayer)( void );
233 
234   CG_LAST_ATTACKER,
235   // int (*CG_LastAttacker)( void );
236 
237   CG_KEY_EVENT,
238   // void  (*CG_KeyEvent)( int key, qboolean down );
239 
240   CG_MOUSE_EVENT,
241   // void  (*CG_MouseEvent)( int dx, int dy );
242   CG_EVENT_HANDLING,
243   // void (*CG_EventHandling)(int type);
244 
245   CG_CONSOLE_TEXT
246   // void (*CG_ConsoleText)( void );
247   // pass text that has been printed to the console to cgame
248   // use Cmd_Argc() / Cmd_Argv() to read it
249 } cgameExport_t;
250 
251 //----------------------------------------------
252