qcommon.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. /*
  2. Copyright (C) 1997-2001 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. // qcommon.h -- definitions common between client and server, but not game.dll
  16. #include "../game/q_shared.h"
  17. #define VERSION 3.19
  18. #define BASEDIRNAME "baseq2"
  19. #ifdef WIN32
  20. #ifdef NDEBUG
  21. #define BUILDSTRING "Win32 RELEASE"
  22. #else
  23. #define BUILDSTRING "Win32 DEBUG"
  24. #endif
  25. #ifdef _M_IX86
  26. #define CPUSTRING "x86"
  27. #elif defined _M_ALPHA
  28. #define CPUSTRING "AXP"
  29. #endif
  30. #elif defined __linux__
  31. #define BUILDSTRING "Linux"
  32. #ifdef __i386__
  33. #define CPUSTRING "i386"
  34. #elif defined __alpha__
  35. #define CPUSTRING "axp"
  36. #else
  37. #define CPUSTRING "Unknown"
  38. #endif
  39. #elif defined __sun__
  40. #define BUILDSTRING "Solaris"
  41. #ifdef __i386__
  42. #define CPUSTRING "i386"
  43. #else
  44. #define CPUSTRING "sparc"
  45. #endif
  46. #else // !WIN32
  47. #define BUILDSTRING "NON-WIN32"
  48. #define CPUSTRING "NON-WIN32"
  49. #endif
  50. //============================================================================
  51. typedef struct sizebuf_s
  52. {
  53. qboolean allowoverflow; // if false, do a Com_Error
  54. qboolean overflowed; // set to true if the buffer size failed
  55. byte *data;
  56. int maxsize;
  57. int cursize;
  58. int readcount;
  59. } sizebuf_t;
  60. void SZ_Init (sizebuf_t *buf, byte *data, int length);
  61. void SZ_Clear (sizebuf_t *buf);
  62. void *SZ_GetSpace (sizebuf_t *buf, int length);
  63. void SZ_Write (sizebuf_t *buf, void *data, int length);
  64. void SZ_Print (sizebuf_t *buf, char *data); // strcats onto the sizebuf
  65. //============================================================================
  66. struct usercmd_s;
  67. struct entity_state_s;
  68. void MSG_WriteChar (sizebuf_t *sb, int c);
  69. void MSG_WriteByte (sizebuf_t *sb, int c);
  70. void MSG_WriteShort (sizebuf_t *sb, int c);
  71. void MSG_WriteLong (sizebuf_t *sb, int c);
  72. void MSG_WriteFloat (sizebuf_t *sb, float f);
  73. void MSG_WriteString (sizebuf_t *sb, char *s);
  74. void MSG_WriteCoord (sizebuf_t *sb, float f);
  75. void MSG_WritePos (sizebuf_t *sb, vec3_t pos);
  76. void MSG_WriteAngle (sizebuf_t *sb, float f);
  77. void MSG_WriteAngle16 (sizebuf_t *sb, float f);
  78. void MSG_WriteDeltaUsercmd (sizebuf_t *sb, struct usercmd_s *from, struct usercmd_s *cmd);
  79. void MSG_WriteDeltaEntity (struct entity_state_s *from, struct entity_state_s *to, sizebuf_t *msg, qboolean force, qboolean newentity);
  80. void MSG_WriteDir (sizebuf_t *sb, vec3_t vector);
  81. void MSG_BeginReading (sizebuf_t *sb);
  82. int MSG_ReadChar (sizebuf_t *sb);
  83. int MSG_ReadByte (sizebuf_t *sb);
  84. int MSG_ReadShort (sizebuf_t *sb);
  85. int MSG_ReadLong (sizebuf_t *sb);
  86. float MSG_ReadFloat (sizebuf_t *sb);
  87. char *MSG_ReadString (sizebuf_t *sb);
  88. char *MSG_ReadStringLine (sizebuf_t *sb);
  89. float MSG_ReadCoord (sizebuf_t *sb);
  90. void MSG_ReadPos (sizebuf_t *sb, vec3_t pos);
  91. float MSG_ReadAngle (sizebuf_t *sb);
  92. float MSG_ReadAngle16 (sizebuf_t *sb);
  93. void MSG_ReadDeltaUsercmd (sizebuf_t *sb, struct usercmd_s *from, struct usercmd_s *cmd);
  94. void MSG_ReadDir (sizebuf_t *sb, vec3_t vector);
  95. void MSG_ReadData (sizebuf_t *sb, void *buffer, int size);
  96. //============================================================================
  97. extern qboolean bigendien;
  98. extern short BigShort (short l);
  99. extern short LittleShort (short l);
  100. extern int BigLong (int l);
  101. extern int LittleLong (int l);
  102. extern float BigFloat (float l);
  103. extern float LittleFloat (float l);
  104. //============================================================================
  105. int COM_Argc (void);
  106. char *COM_Argv (int arg); // range and null checked
  107. void COM_ClearArgv (int arg);
  108. int COM_CheckParm (char *parm);
  109. void COM_AddParm (char *parm);
  110. void COM_Init (void);
  111. void COM_InitArgv (int argc, char **argv);
  112. char *CopyString (char *in);
  113. //============================================================================
  114. void Info_Print (char *s);
  115. /* crc.h */
  116. void CRC_Init(unsigned short *crcvalue);
  117. void CRC_ProcessByte(unsigned short *crcvalue, byte data);
  118. unsigned short CRC_Value(unsigned short crcvalue);
  119. unsigned short CRC_Block (byte *start, int count);
  120. /*
  121. ==============================================================
  122. PROTOCOL
  123. ==============================================================
  124. */
  125. // protocol.h -- communications protocols
  126. #define PROTOCOL_VERSION 34
  127. //=========================================
  128. #define PORT_MASTER 27900
  129. #define PORT_CLIENT 27901
  130. #define PORT_SERVER 27910
  131. //=========================================
  132. #define UPDATE_BACKUP 16 // copies of entity_state_t to keep buffered
  133. // must be power of two
  134. #define UPDATE_MASK (UPDATE_BACKUP-1)
  135. //==================
  136. // the svc_strings[] array in cl_parse.c should mirror this
  137. //==================
  138. //
  139. // server to client
  140. //
  141. enum svc_ops_e
  142. {
  143. svc_bad,
  144. // these ops are known to the game dll
  145. svc_muzzleflash,
  146. svc_muzzleflash2,
  147. svc_temp_entity,
  148. svc_layout,
  149. svc_inventory,
  150. // the rest are private to the client and server
  151. svc_nop,
  152. svc_disconnect,
  153. svc_reconnect,
  154. svc_sound, // <see code>
  155. svc_print, // [byte] id [string] null terminated string
  156. svc_stufftext, // [string] stuffed into client's console buffer, should be \n terminated
  157. svc_serverdata, // [long] protocol ...
  158. svc_configstring, // [short] [string]
  159. svc_spawnbaseline,
  160. svc_centerprint, // [string] to put in center of the screen
  161. svc_download, // [short] size [size bytes]
  162. svc_playerinfo, // variable
  163. svc_packetentities, // [...]
  164. svc_deltapacketentities, // [...]
  165. svc_frame
  166. };
  167. //==============================================
  168. //
  169. // client to server
  170. //
  171. enum clc_ops_e
  172. {
  173. clc_bad,
  174. clc_nop,
  175. clc_move, // [[usercmd_t]
  176. clc_userinfo, // [[userinfo string]
  177. clc_stringcmd // [string] message
  178. };
  179. //==============================================
  180. // plyer_state_t communication
  181. #define PS_M_TYPE (1<<0)
  182. #define PS_M_ORIGIN (1<<1)
  183. #define PS_M_VELOCITY (1<<2)
  184. #define PS_M_TIME (1<<3)
  185. #define PS_M_FLAGS (1<<4)
  186. #define PS_M_GRAVITY (1<<5)
  187. #define PS_M_DELTA_ANGLES (1<<6)
  188. #define PS_VIEWOFFSET (1<<7)
  189. #define PS_VIEWANGLES (1<<8)
  190. #define PS_KICKANGLES (1<<9)
  191. #define PS_BLEND (1<<10)
  192. #define PS_FOV (1<<11)
  193. #define PS_WEAPONINDEX (1<<12)
  194. #define PS_WEAPONFRAME (1<<13)
  195. #define PS_RDFLAGS (1<<14)
  196. //==============================================
  197. // user_cmd_t communication
  198. // ms and light always sent, the others are optional
  199. #define CM_ANGLE1 (1<<0)
  200. #define CM_ANGLE2 (1<<1)
  201. #define CM_ANGLE3 (1<<2)
  202. #define CM_FORWARD (1<<3)
  203. #define CM_SIDE (1<<4)
  204. #define CM_UP (1<<5)
  205. #define CM_BUTTONS (1<<6)
  206. #define CM_IMPULSE (1<<7)
  207. //==============================================
  208. // a sound without an ent or pos will be a local only sound
  209. #define SND_VOLUME (1<<0) // a byte
  210. #define SND_ATTENUATION (1<<1) // a byte
  211. #define SND_POS (1<<2) // three coordinates
  212. #define SND_ENT (1<<3) // a short 0-2: channel, 3-12: entity
  213. #define SND_OFFSET (1<<4) // a byte, msec offset from frame start
  214. #define DEFAULT_SOUND_PACKET_VOLUME 1.0
  215. #define DEFAULT_SOUND_PACKET_ATTENUATION 1.0
  216. //==============================================
  217. // entity_state_t communication
  218. // try to pack the common update flags into the first byte
  219. #define U_ORIGIN1 (1<<0)
  220. #define U_ORIGIN2 (1<<1)
  221. #define U_ANGLE2 (1<<2)
  222. #define U_ANGLE3 (1<<3)
  223. #define U_FRAME8 (1<<4) // frame is a byte
  224. #define U_EVENT (1<<5)
  225. #define U_REMOVE (1<<6) // REMOVE this entity, don't add it
  226. #define U_MOREBITS1 (1<<7) // read one additional byte
  227. // second byte
  228. #define U_NUMBER16 (1<<8) // NUMBER8 is implicit if not set
  229. #define U_ORIGIN3 (1<<9)
  230. #define U_ANGLE1 (1<<10)
  231. #define U_MODEL (1<<11)
  232. #define U_RENDERFX8 (1<<12) // fullbright, etc
  233. #define U_EFFECTS8 (1<<14) // autorotate, trails, etc
  234. #define U_MOREBITS2 (1<<15) // read one additional byte
  235. // third byte
  236. #define U_SKIN8 (1<<16)
  237. #define U_FRAME16 (1<<17) // frame is a short
  238. #define U_RENDERFX16 (1<<18) // 8 + 16 = 32
  239. #define U_EFFECTS16 (1<<19) // 8 + 16 = 32
  240. #define U_MODEL2 (1<<20) // weapons, flags, etc
  241. #define U_MODEL3 (1<<21)
  242. #define U_MODEL4 (1<<22)
  243. #define U_MOREBITS3 (1<<23) // read one additional byte
  244. // fourth byte
  245. #define U_OLDORIGIN (1<<24) // FIXME: get rid of this
  246. #define U_SKIN16 (1<<25)
  247. #define U_SOUND (1<<26)
  248. #define U_SOLID (1<<27)
  249. /*
  250. ==============================================================
  251. CMD
  252. Command text buffering and command execution
  253. ==============================================================
  254. */
  255. /*
  256. Any number of commands can be added in a frame, from several different sources.
  257. Most commands come from either keybindings or console line input, but remote
  258. servers can also send across commands and entire text files can be execed.
  259. The + command line options are also added to the command buffer.
  260. The game starts with a Cbuf_AddText ("exec quake.rc\n"); Cbuf_Execute ();
  261. */
  262. #define EXEC_NOW 0 // don't return until completed
  263. #define EXEC_INSERT 1 // insert at current position, but don't run yet
  264. #define EXEC_APPEND 2 // add to end of the command buffer
  265. void Cbuf_Init (void);
  266. // allocates an initial text buffer that will grow as needed
  267. void Cbuf_AddText (char *text);
  268. // as new commands are generated from the console or keybindings,
  269. // the text is added to the end of the command buffer.
  270. void Cbuf_InsertText (char *text);
  271. // when a command wants to issue other commands immediately, the text is
  272. // inserted at the beginning of the buffer, before any remaining unexecuted
  273. // commands.
  274. void Cbuf_ExecuteText (int exec_when, char *text);
  275. // this can be used in place of either Cbuf_AddText or Cbuf_InsertText
  276. void Cbuf_AddEarlyCommands (qboolean clear);
  277. // adds all the +set commands from the command line
  278. qboolean Cbuf_AddLateCommands (void);
  279. // adds all the remaining + commands from the command line
  280. // Returns true if any late commands were added, which
  281. // will keep the demoloop from immediately starting
  282. void Cbuf_Execute (void);
  283. // Pulls off \n terminated lines of text from the command buffer and sends
  284. // them through Cmd_ExecuteString. Stops when the buffer is empty.
  285. // Normally called once per frame, but may be explicitly invoked.
  286. // Do not call inside a command function!
  287. void Cbuf_CopyToDefer (void);
  288. void Cbuf_InsertFromDefer (void);
  289. // These two functions are used to defer any pending commands while a map
  290. // is being loaded
  291. //===========================================================================
  292. /*
  293. Command execution takes a null terminated string, breaks it into tokens,
  294. then searches for a command or variable that matches the first token.
  295. */
  296. typedef void (*xcommand_t) (void);
  297. void Cmd_Init (void);
  298. void Cmd_AddCommand (char *cmd_name, xcommand_t function);
  299. // called by the init functions of other parts of the program to
  300. // register commands and functions to call for them.
  301. // The cmd_name is referenced later, so it should not be in temp memory
  302. // if function is NULL, the command will be forwarded to the server
  303. // as a clc_stringcmd instead of executed locally
  304. void Cmd_RemoveCommand (char *cmd_name);
  305. qboolean Cmd_Exists (char *cmd_name);
  306. // used by the cvar code to check for cvar / command name overlap
  307. char *Cmd_CompleteCommand (char *partial);
  308. // attempts to match a partial command for automatic command line completion
  309. // returns NULL if nothing fits
  310. int Cmd_Argc (void);
  311. char *Cmd_Argv (int arg);
  312. char *Cmd_Args (void);
  313. // The functions that execute commands get their parameters with these
  314. // functions. Cmd_Argv () will return an empty string, not a NULL
  315. // if arg > argc, so string operations are always safe.
  316. void Cmd_TokenizeString (char *text, qboolean macroExpand);
  317. // Takes a null terminated string. Does not need to be /n terminated.
  318. // breaks the string up into arg tokens.
  319. void Cmd_ExecuteString (char *text);
  320. // Parses a single line of text into arguments and tries to execute it
  321. // as if it was typed at the console
  322. void Cmd_ForwardToServer (void);
  323. // adds the current command line as a clc_stringcmd to the client message.
  324. // things like godmode, noclip, etc, are commands directed to the server,
  325. // so when they are typed in at the console, they will need to be forwarded.
  326. /*
  327. ==============================================================
  328. CVAR
  329. ==============================================================
  330. */
  331. /*
  332. cvar_t variables are used to hold scalar or string variables that can be changed or displayed at the console or prog code as well as accessed directly
  333. in C code.
  334. The user can access cvars from the console in three ways:
  335. r_draworder prints the current value
  336. r_draworder 0 sets the current value to 0
  337. set r_draworder 0 as above, but creates the cvar if not present
  338. Cvars are restricted from having the same names as commands to keep this
  339. interface from being ambiguous.
  340. */
  341. extern cvar_t *cvar_vars;
  342. cvar_t *Cvar_Get (char *var_name, char *value, int flags);
  343. // creates the variable if it doesn't exist, or returns the existing one
  344. // if it exists, the value will not be changed, but flags will be ORed in
  345. // that allows variables to be unarchived without needing bitflags
  346. cvar_t *Cvar_Set (char *var_name, char *value);
  347. // will create the variable if it doesn't exist
  348. cvar_t *Cvar_ForceSet (char *var_name, char *value);
  349. // will set the variable even if NOSET or LATCH
  350. cvar_t *Cvar_FullSet (char *var_name, char *value, int flags);
  351. void Cvar_SetValue (char *var_name, float value);
  352. // expands value to a string and calls Cvar_Set
  353. float Cvar_VariableValue (char *var_name);
  354. // returns 0 if not defined or non numeric
  355. char *Cvar_VariableString (char *var_name);
  356. // returns an empty string if not defined
  357. char *Cvar_CompleteVariable (char *partial);
  358. // attempts to match a partial variable name for command line completion
  359. // returns NULL if nothing fits
  360. void Cvar_GetLatchedVars (void);
  361. // any CVAR_LATCHED variables that have been set will now take effect
  362. qboolean Cvar_Command (void);
  363. // called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known
  364. // command. Returns true if the command was a variable reference that
  365. // was handled. (print or change)
  366. void Cvar_WriteVariables (char *path);
  367. // appends lines containing "set variable value" for all variables
  368. // with the archive flag set to true.
  369. void Cvar_Init (void);
  370. char *Cvar_Userinfo (void);
  371. // returns an info string containing all the CVAR_USERINFO cvars
  372. char *Cvar_Serverinfo (void);
  373. // returns an info string containing all the CVAR_SERVERINFO cvars
  374. extern qboolean userinfo_modified;
  375. // this is set each time a CVAR_USERINFO variable is changed
  376. // so that the client knows to send it to the server
  377. /*
  378. ==============================================================
  379. NET
  380. ==============================================================
  381. */
  382. // net.h -- quake's interface to the networking layer
  383. #define PORT_ANY -1
  384. #define MAX_MSGLEN 1400 // max length of a message
  385. #define PACKET_HEADER 10 // two ints and a short
  386. typedef enum {NA_LOOPBACK, NA_BROADCAST, NA_IP, NA_IPX, NA_BROADCAST_IPX} netadrtype_t;
  387. typedef enum {NS_CLIENT, NS_SERVER} netsrc_t;
  388. typedef struct
  389. {
  390. netadrtype_t type;
  391. byte ip[4];
  392. byte ipx[10];
  393. unsigned short port;
  394. } netadr_t;
  395. void NET_Init (void);
  396. void NET_Shutdown (void);
  397. void NET_Config (qboolean multiplayer);
  398. qboolean NET_GetPacket (netsrc_t sock, netadr_t *net_from, sizebuf_t *net_message);
  399. void NET_SendPacket (netsrc_t sock, int length, void *data, netadr_t to);
  400. qboolean NET_CompareAdr (netadr_t a, netadr_t b);
  401. qboolean NET_CompareBaseAdr (netadr_t a, netadr_t b);
  402. qboolean NET_IsLocalAddress (netadr_t adr);
  403. char *NET_AdrToString (netadr_t a);
  404. qboolean NET_StringToAdr (char *s, netadr_t *a);
  405. void NET_Sleep(int msec);
  406. //============================================================================
  407. #define OLD_AVG 0.99 // total = oldtotal*OLD_AVG + new*(1-OLD_AVG)
  408. #define MAX_LATENT 32
  409. typedef struct
  410. {
  411. qboolean fatal_error;
  412. netsrc_t sock;
  413. int dropped; // between last packet and previous
  414. int last_received; // for timeouts
  415. int last_sent; // for retransmits
  416. netadr_t remote_address;
  417. int qport; // qport value to write when transmitting
  418. // sequencing variables
  419. int incoming_sequence;
  420. int incoming_acknowledged;
  421. int incoming_reliable_acknowledged; // single bit
  422. int incoming_reliable_sequence; // single bit, maintained local
  423. int outgoing_sequence;
  424. int reliable_sequence; // single bit
  425. int last_reliable_sequence; // sequence number of last send
  426. // reliable staging and holding areas
  427. sizebuf_t message; // writing buffer to send to server
  428. byte message_buf[MAX_MSGLEN-16]; // leave space for header
  429. // message is copied to this buffer when it is first transfered
  430. int reliable_length;
  431. byte reliable_buf[MAX_MSGLEN-16]; // unacked reliable message
  432. } netchan_t;
  433. extern netadr_t net_from;
  434. extern sizebuf_t net_message;
  435. extern byte net_message_buffer[MAX_MSGLEN];
  436. void Netchan_Init (void);
  437. void Netchan_Setup (netsrc_t sock, netchan_t *chan, netadr_t adr, int qport);
  438. qboolean Netchan_NeedReliable (netchan_t *chan);
  439. void Netchan_Transmit (netchan_t *chan, int length, byte *data);
  440. void Netchan_OutOfBand (int net_socket, netadr_t adr, int length, byte *data);
  441. void Netchan_OutOfBandPrint (int net_socket, netadr_t adr, char *format, ...);
  442. qboolean Netchan_Process (netchan_t *chan, sizebuf_t *msg);
  443. qboolean Netchan_CanReliable (netchan_t *chan);
  444. /*
  445. ==============================================================
  446. CMODEL
  447. ==============================================================
  448. */
  449. #include "../qcommon/qfiles.h"
  450. cmodel_t *CM_LoadMap (char *name, qboolean clientload, unsigned *checksum);
  451. cmodel_t *CM_InlineModel (char *name); // *1, *2, etc
  452. int CM_NumClusters (void);
  453. int CM_NumInlineModels (void);
  454. char *CM_EntityString (void);
  455. // creates a clipping hull for an arbitrary box
  456. int CM_HeadnodeForBox (vec3_t mins, vec3_t maxs);
  457. // returns an ORed contents mask
  458. int CM_PointContents (vec3_t p, int headnode);
  459. int CM_TransformedPointContents (vec3_t p, int headnode, vec3_t origin, vec3_t angles);
  460. trace_t CM_BoxTrace (vec3_t start, vec3_t end,
  461. vec3_t mins, vec3_t maxs,
  462. int headnode, int brushmask);
  463. trace_t CM_TransformedBoxTrace (vec3_t start, vec3_t end,
  464. vec3_t mins, vec3_t maxs,
  465. int headnode, int brushmask,
  466. vec3_t origin, vec3_t angles);
  467. byte *CM_ClusterPVS (int cluster);
  468. byte *CM_ClusterPHS (int cluster);
  469. int CM_PointLeafnum (vec3_t p);
  470. // call with topnode set to the headnode, returns with topnode
  471. // set to the first node that splits the box
  472. int CM_BoxLeafnums (vec3_t mins, vec3_t maxs, int *list,
  473. int listsize, int *topnode);
  474. int CM_LeafContents (int leafnum);
  475. int CM_LeafCluster (int leafnum);
  476. int CM_LeafArea (int leafnum);
  477. void CM_SetAreaPortalState (int portalnum, qboolean open);
  478. qboolean CM_AreasConnected (int area1, int area2);
  479. int CM_WriteAreaBits (byte *buffer, int area);
  480. qboolean CM_HeadnodeVisible (int headnode, byte *visbits);
  481. void CM_WritePortalState (FILE *f);
  482. void CM_ReadPortalState (FILE *f);
  483. /*
  484. ==============================================================
  485. PLAYER MOVEMENT CODE
  486. Common between server and client so prediction matches
  487. ==============================================================
  488. */
  489. extern float pm_airaccelerate;
  490. void Pmove (pmove_t *pmove);
  491. /*
  492. ==============================================================
  493. FILESYSTEM
  494. ==============================================================
  495. */
  496. void FS_InitFilesystem (void);
  497. void FS_SetGamedir (char *dir);
  498. char *FS_Gamedir (void);
  499. char *FS_NextPath (char *prevpath);
  500. void FS_ExecAutoexec (void);
  501. int FS_FOpenFile (char *filename, FILE **file);
  502. void FS_FCloseFile (FILE *f);
  503. // note: this can't be called from another DLL, due to MS libc issues
  504. int FS_LoadFile (char *path, void **buffer);
  505. // a null buffer will just return the file length without loading
  506. // a -1 length is not present
  507. void FS_Read (void *buffer, int len, FILE *f);
  508. // properly handles partial reads
  509. void FS_FreeFile (void *buffer);
  510. void FS_CreatePath (char *path);
  511. /*
  512. ==============================================================
  513. MISC
  514. ==============================================================
  515. */
  516. #define ERR_FATAL 0 // exit the entire game with a popup window
  517. #define ERR_DROP 1 // print to console and disconnect from game
  518. #define ERR_QUIT 2 // not an error, just a normal exit
  519. #define EXEC_NOW 0 // don't return until completed
  520. #define EXEC_INSERT 1 // insert at current position, but don't run yet
  521. #define EXEC_APPEND 2 // add to end of the command buffer
  522. #define PRINT_ALL 0
  523. #define PRINT_DEVELOPER 1 // only print when "developer 1"
  524. void Com_BeginRedirect (int target, char *buffer, int buffersize, void (*flush));
  525. void Com_EndRedirect (void);
  526. void Com_Printf (char *fmt, ...);
  527. void Com_DPrintf (char *fmt, ...);
  528. void Com_Error (int code, char *fmt, ...);
  529. void Com_Quit (void);
  530. int Com_ServerState (void); // this should have just been a cvar...
  531. void Com_SetServerState (int state);
  532. unsigned Com_BlockChecksum (void *buffer, int length);
  533. byte COM_BlockSequenceCRCByte (byte *base, int length, int sequence);
  534. float frand(void); // 0 ti 1
  535. float crand(void); // -1 to 1
  536. extern cvar_t *developer;
  537. extern cvar_t *dedicated;
  538. extern cvar_t *host_speeds;
  539. extern cvar_t *log_stats;
  540. extern FILE *log_stats_file;
  541. // host_speeds times
  542. extern int time_before_game;
  543. extern int time_after_game;
  544. extern int time_before_ref;
  545. extern int time_after_ref;
  546. void Z_Free (void *ptr);
  547. void *Z_Malloc (int size); // returns 0 filled memory
  548. void *Z_TagMalloc (int size, int tag);
  549. void Z_FreeTags (int tag);
  550. void Qcommon_Init (int argc, char **argv);
  551. void Qcommon_Frame (int msec);
  552. void Qcommon_Shutdown (void);
  553. #define NUMVERTEXNORMALS 162
  554. extern vec3_t bytedirs[NUMVERTEXNORMALS];
  555. // this is in the client code, but can be used for debugging from server
  556. void SCR_DebugGraph (float value, int color);
  557. /*
  558. ==============================================================
  559. NON-PORTABLE SYSTEM SERVICES
  560. ==============================================================
  561. */
  562. void Sys_Init (void);
  563. void Sys_AppActivate (void);
  564. void Sys_UnloadGame (void);
  565. void *Sys_GetGameAPI (void *parms);
  566. // loads the game dll and calls the api init function
  567. char *Sys_ConsoleInput (void);
  568. void Sys_ConsoleOutput (char *string);
  569. void Sys_SendKeyEvents (void);
  570. void Sys_Error (char *error, ...);
  571. void Sys_Quit (void);
  572. char *Sys_GetClipboardData( void );
  573. void Sys_CopyProtect (void);
  574. /*
  575. ==============================================================
  576. CLIENT / SERVER SYSTEMS
  577. ==============================================================
  578. */
  579. void CL_Init (void);
  580. void CL_Drop (void);
  581. void CL_Shutdown (void);
  582. void CL_Frame (int msec);
  583. void Con_Print (char *text);
  584. void SCR_BeginLoadingPlaque (void);
  585. void SV_Init (void);
  586. void SV_Shutdown (char *finalmsg, qboolean reconnect);
  587. void SV_Frame (int msec);