| 1 |
/* |
| 2 |
=========================================================================== |
| 3 |
Copyright (C) 1999-2005 Id Software, Inc. |
| 4 |
|
| 5 |
This file is part of Quake III Arena source code. |
| 6 |
|
| 7 |
Quake III Arena source code is free software; you can redistribute it |
| 8 |
and/or modify it under the terms of the GNU General Public License as |
| 9 |
published by the Free Software Foundation; either version 2 of the License, |
| 10 |
or (at your option) any later version. |
| 11 |
|
| 12 |
Quake III Arena source code is distributed in the hope that it will be |
| 13 |
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with Quake III Arena source code; if not, write to the Free Software |
| 19 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 |
=========================================================================== |
| 21 |
*/ |
| 22 |
// qcommon.h -- definitions common between client and server, but not game.or ref modules |
| 23 |
#ifndef _QCOMMON_H_ |
| 24 |
#define _QCOMMON_H_ |
| 25 |
|
| 26 |
#include "../qcommon/cm_public.h" |
| 27 |
|
| 28 |
//Ignore __attribute__ on non-gcc platforms |
| 29 |
#ifndef __GNUC__ |
| 30 |
#ifndef __attribute__ |
| 31 |
#define __attribute__(x) |
| 32 |
#endif |
| 33 |
#endif |
| 34 |
|
| 35 |
//#define PRE_RELEASE_DEMO |
| 36 |
|
| 37 |
//============================================================================ |
| 38 |
|
| 39 |
// |
| 40 |
// msg.c |
| 41 |
// |
| 42 |
typedef struct { |
| 43 |
qboolean allowoverflow; // if false, do a Com_Error |
| 44 |
qboolean overflowed; // set to true if the buffer size failed (with allowoverflow set) |
| 45 |
qboolean oob; // set to true if the buffer size failed (with allowoverflow set) |
| 46 |
byte *data; |
| 47 |
int maxsize; |
| 48 |
int cursize; |
| 49 |
int readcount; |
| 50 |
int bit; // for bitwise reads and writes |
| 51 |
} msg_t; |
| 52 |
|
| 53 |
void MSG_Init (msg_t *buf, byte *data, int length); |
| 54 |
void MSG_InitOOB( msg_t *buf, byte *data, int length ); |
| 55 |
void MSG_Clear (msg_t *buf); |
| 56 |
void MSG_WriteData (msg_t *buf, const void *data, int length); |
| 57 |
void MSG_Bitstream( msg_t *buf ); |
| 58 |
|
| 59 |
// TTimo |
| 60 |
// copy a msg_t in case we need to store it as is for a bit |
| 61 |
// (as I needed this to keep an msg_t from a static var for later use) |
| 62 |
// sets data buffer as MSG_Init does prior to do the copy |
| 63 |
void MSG_Copy(msg_t *buf, byte *data, int length, msg_t *src); |
| 64 |
|
| 65 |
struct usercmd_s; |
| 66 |
struct entityState_s; |
| 67 |
struct playerState_s; |
| 68 |
|
| 69 |
void MSG_WriteBits( msg_t *msg, int value, int bits ); |
| 70 |
|
| 71 |
void MSG_WriteChar (msg_t *sb, int c); |
| 72 |
void MSG_WriteByte (msg_t *sb, int c); |
| 73 |
void MSG_WriteShort (msg_t *sb, int c); |
| 74 |
void MSG_WriteLong (msg_t *sb, int c); |
| 75 |
void MSG_WriteFloat (msg_t *sb, float f); |
| 76 |
void MSG_WriteString (msg_t *sb, const char *s); |
| 77 |
void MSG_WriteBigString (msg_t *sb, const char *s); |
| 78 |
void MSG_WriteAngle16 (msg_t *sb, float f); |
| 79 |
|
| 80 |
void MSG_BeginReading (msg_t *sb); |
| 81 |
void MSG_BeginReadingOOB(msg_t *sb); |
| 82 |
|
| 83 |
int MSG_ReadBits( msg_t *msg, int bits ); |
| 84 |
|
| 85 |
int MSG_ReadChar (msg_t *sb); |
| 86 |
int MSG_ReadByte (msg_t *sb); |
| 87 |
int MSG_ReadShort (msg_t *sb); |
| 88 |
int MSG_ReadLong (msg_t *sb); |
| 89 |
float MSG_ReadFloat (msg_t *sb); |
| 90 |
char *MSG_ReadString (msg_t *sb); |
| 91 |
char *MSG_ReadBigString (msg_t *sb); |
| 92 |
char *MSG_ReadStringLine (msg_t *sb); |
| 93 |
float MSG_ReadAngle16 (msg_t *sb); |
| 94 |
void MSG_ReadData (msg_t *sb, void *buffer, int size); |
| 95 |
int MSG_LookaheadByte (msg_t *msg); |
| 96 |
|
| 97 |
void MSG_WriteDeltaUsercmd( msg_t *msg, struct usercmd_s *from, struct usercmd_s *to ); |
| 98 |
void MSG_ReadDeltaUsercmd( msg_t *msg, struct usercmd_s *from, struct usercmd_s *to ); |
| 99 |
|
| 100 |
void MSG_WriteDeltaUsercmdKey( msg_t *msg, int key, usercmd_t *from, usercmd_t *to ); |
| 101 |
void MSG_ReadDeltaUsercmdKey( msg_t *msg, int key, usercmd_t *from, usercmd_t *to ); |
| 102 |
|
| 103 |
void MSG_WriteDeltaEntity( msg_t *msg, struct entityState_s *from, struct entityState_s *to |
| 104 |
, qboolean force ); |
| 105 |
void MSG_ReadDeltaEntity( msg_t *msg, entityState_t *from, entityState_t *to, |
| 106 |
int number ); |
| 107 |
|
| 108 |
void MSG_WriteDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct playerState_s *to ); |
| 109 |
void MSG_ReadDeltaPlayerstate( msg_t *msg, struct playerState_s *from, struct playerState_s *to ); |
| 110 |
|
| 111 |
|
| 112 |
void MSG_ReportChangeVectors_f( void ); |
| 113 |
|
| 114 |
//============================================================================ |
| 115 |
|
| 116 |
/* |
| 117 |
============================================================== |
| 118 |
|
| 119 |
NET |
| 120 |
|
| 121 |
============================================================== |
| 122 |
*/ |
| 123 |
|
| 124 |
#define PACKET_BACKUP 32 // number of old messages that must be kept on client and |
| 125 |
// server for delta comrpession and ping estimation |
| 126 |
#define PACKET_MASK (PACKET_BACKUP-1) |
| 127 |
|
| 128 |
#define MAX_PACKET_USERCMDS 32 // max number of usercmd_t in a packet |
| 129 |
|
| 130 |
#define PORT_ANY -1 |
| 131 |
|
| 132 |
#define MAX_RELIABLE_COMMANDS 64 // max string commands buffered for restransmit |
| 133 |
|
| 134 |
typedef enum { |
| 135 |
NA_BOT, |
| 136 |
NA_BAD, // an address lookup failed |
| 137 |
NA_LOOPBACK, |
| 138 |
NA_BROADCAST, |
| 139 |
NA_IP, |
| 140 |
NA_IP6, |
| 141 |
NA_MULTICAST6, |
| 142 |
NA_UNSPEC |
| 143 |
} netadrtype_t; |
| 144 |
|
| 145 |
typedef enum { |
| 146 |
NS_CLIENT, |
| 147 |
NS_SERVER |
| 148 |
} netsrc_t; |
| 149 |
|
| 150 |
#define NET_ADDRSTRMAXLEN 48 // maximum length of an IPv6 address string including trailing '\0' |
| 151 |
typedef struct { |
| 152 |
netadrtype_t type; |
| 153 |
|
| 154 |
byte ip[4]; |
| 155 |
byte ip6[16]; |
| 156 |
|
| 157 |
unsigned short port; |
| 158 |
} netadr_t; |
| 159 |
|
| 160 |
void NET_Init( void ); |
| 161 |
void NET_Shutdown( void ); |
| 162 |
void NET_Restart( void ); |
| 163 |
void NET_Config( qboolean enableNetworking ); |
| 164 |
void NET_FlushPacketQueue(void); |
| 165 |
void NET_SendPacket (netsrc_t sock, int length, const void *data, netadr_t to); |
| 166 |
void QDECL NET_OutOfBandPrint( netsrc_t net_socket, netadr_t adr, const char *format, ...) __attribute__ ((format (printf, 3, 4))); |
| 167 |
void QDECL NET_OutOfBandData( netsrc_t sock, netadr_t adr, byte *format, int len ); |
| 168 |
|
| 169 |
qboolean NET_CompareAdr (netadr_t a, netadr_t b); |
| 170 |
qboolean NET_CompareBaseAdr (netadr_t a, netadr_t b); |
| 171 |
qboolean NET_IsLocalAddress (netadr_t adr); |
| 172 |
const char *NET_AdrToString (netadr_t a); |
| 173 |
const char *NET_AdrToStringwPort (netadr_t a); |
| 174 |
int NET_StringToAdr ( const char *s, netadr_t *a, netadrtype_t family); |
| 175 |
qboolean NET_GetLoopPacket (netsrc_t sock, netadr_t *net_from, msg_t *net_message); |
| 176 |
void NET_JoinMulticast6(void); |
| 177 |
void NET_LeaveMulticast6(void); |
| 178 |
void NET_Sleep(int msec); |
| 179 |
|
| 180 |
|
| 181 |
#define MAX_MSGLEN 16384 // max length of a message, which may |
| 182 |
// be fragmented into multiple packets |
| 183 |
|
| 184 |
#define MAX_DOWNLOAD_WINDOW 8 // max of eight download frames |
| 185 |
#define MAX_DOWNLOAD_BLKSIZE 2048 // 2048 byte block chunks |
| 186 |
|
| 187 |
|
| 188 |
/* |
| 189 |
Netchan handles packet fragmentation and out of order / duplicate suppression |
| 190 |
*/ |
| 191 |
|
| 192 |
typedef struct { |
| 193 |
netsrc_t sock; |
| 194 |
|
| 195 |
int dropped; // between last packet and previous |
| 196 |
|
| 197 |
netadr_t remoteAddress; |
| 198 |
int qport; // qport value to write when transmitting |
| 199 |
|
| 200 |
// sequencing variables |
| 201 |
int incomingSequence; |
| 202 |
int outgoingSequence; |
| 203 |
|
| 204 |
// incoming fragment assembly buffer |
| 205 |
int fragmentSequence; |
| 206 |
int fragmentLength; |
| 207 |
byte fragmentBuffer[MAX_MSGLEN]; |
| 208 |
|
| 209 |
// outgoing fragment buffer |
| 210 |
// we need to space out the sending of large fragmented messages |
| 211 |
qboolean unsentFragments; |
| 212 |
int unsentFragmentStart; |
| 213 |
int unsentLength; |
| 214 |
byte unsentBuffer[MAX_MSGLEN]; |
| 215 |
} netchan_t; |
| 216 |
|
| 217 |
void Netchan_Init( int qport ); |
| 218 |
void Netchan_Setup( netsrc_t sock, netchan_t *chan, netadr_t adr, int qport ); |
| 219 |
|
| 220 |
void Netchan_Transmit( netchan_t *chan, int length, const byte *data ); |
| 221 |
void Netchan_TransmitNextFragment( netchan_t *chan ); |
| 222 |
|
| 223 |
qboolean Netchan_Process( netchan_t *chan, msg_t *msg ); |
| 224 |
|
| 225 |
|
| 226 |
/* |
| 227 |
============================================================== |
| 228 |
|
| 229 |
PROTOCOL |
| 230 |
|
| 231 |
============================================================== |
| 232 |
*/ |
| 233 |
|
| 234 |
//Open Arena up to 0.7.6 used 68 |
| 235 |
//Open Arena 0.7.7 uses 69 |
| 236 |
//Open Arena 0.8.0 used protocol 70 |
| 237 |
//Open Arena 0.8.1+ uses protocol 71 |
| 238 |
#define PROTOCOL_VERSION 71 |
| 239 |
// 1.31 - 67 |
| 240 |
|
| 241 |
// maintain a list of compatible protocols for demo playing |
| 242 |
// NOTE: that stuff only works with two digits protocols |
| 243 |
extern int demo_protocols[]; |
| 244 |
|
| 245 |
#define UPDATE_SERVER_NAME "" |
| 246 |
// override on command line, config files etc. |
| 247 |
#ifndef MASTER_SERVER_NAME |
| 248 |
#define MASTER_SERVER_NAME "dpmaster.deathmask.net" |
| 249 |
#endif |
| 250 |
|
| 251 |
#ifndef STANDALONE |
| 252 |
#ifndef AUTHORIZE_SERVER_NAME |
| 253 |
#define AUTHORIZE_SERVER_NAME "authorize.quake3arena.com" |
| 254 |
#endif |
| 255 |
#ifndef PORT_AUTHORIZE |
| 256 |
#define PORT_AUTHORIZE 27952 |
| 257 |
#endif |
| 258 |
#endif |
| 259 |
|
| 260 |
#define PORT_MASTER 27950 |
| 261 |
#define PORT_UPDATE 27951 |
| 262 |
#define PORT_SERVER 27960 |
| 263 |
#define NUM_SERVER_PORTS 4 // broadcast scan this many ports after |
| 264 |
// PORT_SERVER so a single machine can |
| 265 |
// run multiple servers |
| 266 |
|
| 267 |
|
| 268 |
// the svc_strings[] array in cl_parse.c should mirror this |
| 269 |
// |
| 270 |
// server to client |
| 271 |
// |
| 272 |
enum svc_ops_e { |
| 273 |
svc_bad, |
| 274 |
svc_nop, |
| 275 |
svc_gamestate, |
| 276 |
svc_configstring, // [short] [string] only in gamestate messages |
| 277 |
svc_baseline, // only in gamestate messages |
| 278 |
svc_serverCommand, // [string] to be executed by client game module |
| 279 |
svc_download, // [short] size [size bytes] |
| 280 |
svc_snapshot, |
| 281 |
svc_EOF, |
| 282 |
|
| 283 |
// svc_extension follows a svc_EOF, followed by another svc_* ... |
| 284 |
// this keeps legacy clients compatible. |
| 285 |
svc_extension, |
| 286 |
svc_voip, // not wrapped in USE_VOIP, so this value is reserved. |
| 287 |
}; |
| 288 |
|
| 289 |
|
| 290 |
// |
| 291 |
// client to server |
| 292 |
// |
| 293 |
enum clc_ops_e { |
| 294 |
clc_bad, |
| 295 |
clc_nop, |
| 296 |
clc_move, // [[usercmd_t] |
| 297 |
clc_moveNoDelta, // [[usercmd_t] |
| 298 |
clc_clientCommand, // [string] message |
| 299 |
clc_EOF, |
| 300 |
|
| 301 |
// clc_extension follows a clc_EOF, followed by another clc_* ... |
| 302 |
// this keeps legacy servers compatible. |
| 303 |
clc_extension, |
| 304 |
clc_voip, // not wrapped in USE_VOIP, so this value is reserved. |
| 305 |
}; |
| 306 |
|
| 307 |
/* |
| 308 |
============================================================== |
| 309 |
|
| 310 |
VIRTUAL MACHINE |
| 311 |
|
| 312 |
============================================================== |
| 313 |
*/ |
| 314 |
|
| 315 |
typedef struct vm_s vm_t; |
| 316 |
|
| 317 |
typedef enum { |
| 318 |
VMI_NATIVE, |
| 319 |
VMI_BYTECODE, |
| 320 |
VMI_COMPILED |
| 321 |
} vmInterpret_t; |
| 322 |
|
| 323 |
typedef enum { |
| 324 |
TRAP_MEMSET = 100, |
| 325 |
TRAP_MEMCPY, |
| 326 |
TRAP_STRNCPY, |
| 327 |
TRAP_SIN, |
| 328 |
TRAP_COS, |
| 329 |
TRAP_ATAN2, |
| 330 |
TRAP_SQRT, |
| 331 |
TRAP_MATRIXMULTIPLY, |
| 332 |
TRAP_ANGLEVECTORS, |
| 333 |
TRAP_PERPENDICULARVECTOR, |
| 334 |
TRAP_FLOOR, |
| 335 |
TRAP_CEIL, |
| 336 |
|
| 337 |
TRAP_TESTPRINTINT, |
| 338 |
TRAP_TESTPRINTFLOAT |
| 339 |
} sharedTraps_t; |
| 340 |
|
| 341 |
void VM_Init( void ); |
| 342 |
vm_t *VM_Create( const char *module, intptr_t (*systemCalls)(intptr_t *), |
| 343 |
vmInterpret_t interpret ); |
| 344 |
// module should be bare: "cgame", not "cgame.dll" or "vm/cgame.qvm" |
| 345 |
|
| 346 |
void VM_Free( vm_t *vm ); |
| 347 |
void VM_Clear(void); |
| 348 |
void VM_Forced_Unload_Start(void); |
| 349 |
void VM_Forced_Unload_Done(void); |
| 350 |
vm_t *VM_Restart( vm_t *vm ); |
| 351 |
|
| 352 |
intptr_t QDECL VM_Call( vm_t *vm, int callNum, ... ); |
| 353 |
|
| 354 |
void VM_Debug( int level ); |
| 355 |
|
| 356 |
void *VM_ArgPtr( intptr_t intValue ); |
| 357 |
void *VM_ExplicitArgPtr( vm_t *vm, intptr_t intValue ); |
| 358 |
|
| 359 |
#define VMA(x) VM_ArgPtr(args[x]) |
| 360 |
static ID_INLINE float _vmf(intptr_t x) |
| 361 |
{ |
| 362 |
floatint_t fi; |
| 363 |
fi.i = (int) x; |
| 364 |
return fi.f; |
| 365 |
} |
| 366 |
#define VMF(x) _vmf(args[x]) |
| 367 |
|
| 368 |
|
| 369 |
/* |
| 370 |
============================================================== |
| 371 |
|
| 372 |
CMD |
| 373 |
|
| 374 |
Command text buffering and command execution |
| 375 |
|
| 376 |
============================================================== |
| 377 |
*/ |
| 378 |
|
| 379 |
/* |
| 380 |
|
| 381 |
Any number of commands can be added in a frame, from several different sources. |
| 382 |
Most commands come from either keybindings or console line input, but entire text |
| 383 |
files can be execed. |
| 384 |
|
| 385 |
*/ |
| 386 |
|
| 387 |
void Cbuf_Init (void); |
| 388 |
// allocates an initial text buffer that will grow as needed |
| 389 |
|
| 390 |
void Cbuf_AddText( const char *text ); |
| 391 |
// Adds command text at the end of the buffer, does NOT add a final \n |
| 392 |
|
| 393 |
void Cbuf_ExecuteText( int exec_when, const char *text ); |
| 394 |
// this can be used in place of either Cbuf_AddText or Cbuf_InsertText |
| 395 |
|
| 396 |
void Cbuf_Execute (void); |
| 397 |
// Pulls off \n terminated lines of text from the command buffer and sends |
| 398 |
// them through Cmd_ExecuteString. Stops when the buffer is empty. |
| 399 |
// Normally called once per frame, but may be explicitly invoked. |
| 400 |
// Do not call inside a command function, or current args will be destroyed. |
| 401 |
|
| 402 |
//=========================================================================== |
| 403 |
|
| 404 |
/* |
| 405 |
|
| 406 |
Command execution takes a null terminated string, breaks it into tokens, |
| 407 |
then searches for a command or variable that matches the first token. |
| 408 |
|
| 409 |
*/ |
| 410 |
|
| 411 |
typedef void (*xcommand_t) (void); |
| 412 |
|
| 413 |
void Cmd_Init (void); |
| 414 |
|
| 415 |
void Cmd_AddCommand( const char *cmd_name, xcommand_t function ); |
| 416 |
// called by the init functions of other parts of the program to |
| 417 |
// register commands and functions to call for them. |
| 418 |
// The cmd_name is referenced later, so it should not be in temp memory |
| 419 |
// if function is NULL, the command will be forwarded to the server |
| 420 |
// as a clc_clientCommand instead of executed locally |
| 421 |
|
| 422 |
void Cmd_RemoveCommand( const char *cmd_name ); |
| 423 |
|
| 424 |
void Cmd_CommandCompletion( void(*callback)(const char *s) ); |
| 425 |
// callback with each valid string |
| 426 |
|
| 427 |
int Cmd_Argc (void); |
| 428 |
char *Cmd_Argv (int arg); |
| 429 |
void Cmd_ArgvBuffer( int arg, char *buffer, int bufferLength ); |
| 430 |
char *Cmd_Args (void); |
| 431 |
char *Cmd_ArgsFrom( int arg ); |
| 432 |
void Cmd_ArgsBuffer( char *buffer, int bufferLength ); |
| 433 |
char *Cmd_Cmd (void); |
| 434 |
// The functions that execute commands get their parameters with these |
| 435 |
// functions. Cmd_Argv () will return an empty string, not a NULL |
| 436 |
// if arg > argc, so string operations are allways safe. |
| 437 |
|
| 438 |
void Cmd_TokenizeString( const char *text ); |
| 439 |
void Cmd_TokenizeStringIgnoreQuotes( const char *text_in ); |
| 440 |
// Takes a null terminated string. Does not need to be /n terminated. |
| 441 |
// breaks the string up into arg tokens. |
| 442 |
|
| 443 |
void Cmd_ExecuteString( const char *text ); |
| 444 |
// Parses a single line of text into arguments and tries to execute it |
| 445 |
// as if it was typed at the console |
| 446 |
|
| 447 |
|
| 448 |
/* |
| 449 |
============================================================== |
| 450 |
|
| 451 |
CVAR |
| 452 |
|
| 453 |
============================================================== |
| 454 |
*/ |
| 455 |
|
| 456 |
/* |
| 457 |
|
| 458 |
cvar_t variables are used to hold scalar or string variables that can be changed |
| 459 |
or displayed at the console or prog code as well as accessed directly |
| 460 |
in C code. |
| 461 |
|
| 462 |
The user can access cvars from the console in three ways: |
| 463 |
r_draworder prints the current value |
| 464 |
r_draworder 0 sets the current value to 0 |
| 465 |
set r_draworder 0 as above, but creates the cvar if not present |
| 466 |
|
| 467 |
Cvars are restricted from having the same names as commands to keep this |
| 468 |
interface from being ambiguous. |
| 469 |
|
| 470 |
The are also occasionally used to communicated information between different |
| 471 |
modules of the program. |
| 472 |
|
| 473 |
*/ |
| 474 |
|
| 475 |
cvar_t *Cvar_Get( const char *var_name, const char *value, int flags ); |
| 476 |
// creates the variable if it doesn't exist, or returns the existing one |
| 477 |
// if it exists, the value will not be changed, but flags will be ORed in |
| 478 |
// that allows variables to be unarchived without needing bitflags |
| 479 |
// if value is "", the value will not override a previously set value. |
| 480 |
|
| 481 |
void Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ); |
| 482 |
// basically a slightly modified Cvar_Get for the interpreted modules |
| 483 |
|
| 484 |
void Cvar_Update( vmCvar_t *vmCvar ); |
| 485 |
// updates an interpreted modules' version of a cvar |
| 486 |
|
| 487 |
void Cvar_Set( const char *var_name, const char *value ); |
| 488 |
// will create the variable with no flags if it doesn't exist |
| 489 |
|
| 490 |
void Cvar_SetLatched( const char *var_name, const char *value); |
| 491 |
// don't set the cvar immediately |
| 492 |
|
| 493 |
void Cvar_SetValue( const char *var_name, float value ); |
| 494 |
// expands value to a string and calls Cvar_Set |
| 495 |
|
| 496 |
float Cvar_VariableValue( const char *var_name ); |
| 497 |
int Cvar_VariableIntegerValue( const char *var_name ); |
| 498 |
// returns 0 if not defined or non numeric |
| 499 |
|
| 500 |
char *Cvar_VariableString( const char *var_name ); |
| 501 |
void Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ); |
| 502 |
// returns an empty string if not defined |
| 503 |
|
| 504 |
int Cvar_Flags(const char *var_name); |
| 505 |
// returns CVAR_NONEXISTENT if cvar doesn't exist or the flags of that particular CVAR. |
| 506 |
|
| 507 |
void Cvar_CommandCompletion( void(*callback)(const char *s) ); |
| 508 |
// callback with each valid string |
| 509 |
|
| 510 |
void Cvar_Reset( const char *var_name ); |
| 511 |
void Cvar_ForceReset(const char *var_name); |
| 512 |
|
| 513 |
void Cvar_SetCheatState( void ); |
| 514 |
// reset all testing vars to a safe value |
| 515 |
|
| 516 |
qboolean Cvar_Command( void ); |
| 517 |
// called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known |
| 518 |
// command. Returns true if the command was a variable reference that |
| 519 |
// was handled. (print or change) |
| 520 |
|
| 521 |
void Cvar_WriteVariables( fileHandle_t f ); |
| 522 |
// writes lines containing "set variable value" for all variables |
| 523 |
// with the archive flag set to true. |
| 524 |
|
| 525 |
void Cvar_Init( void ); |
| 526 |
|
| 527 |
char *Cvar_InfoString( int bit ); |
| 528 |
char *Cvar_InfoString_Big( int bit ); |
| 529 |
// returns an info string containing all the cvars that have the given bit set |
| 530 |
// in their flags ( CVAR_USERINFO, CVAR_SERVERINFO, CVAR_SYSTEMINFO, etc ) |
| 531 |
void Cvar_InfoStringBuffer( int bit, char *buff, int buffsize ); |
| 532 |
|
| 533 |
void Cvar_Restart_f( void ); |
| 534 |
|
| 535 |
extern int cvar_modifiedFlags; |
| 536 |
// whenever a cvar is modifed, its flags will be OR'd into this, so |
| 537 |
// a single check can determine if any CVAR_USERINFO, CVAR_SERVERINFO, |
| 538 |
// etc, variables have been modified since the last check. The bit |
| 539 |
// can then be cleared to allow another change detection. |
| 540 |
|
| 541 |
/* |
| 542 |
============================================================== |
| 543 |
|
| 544 |
FILESYSTEM |
| 545 |
|
| 546 |
No stdio calls should be used by any part of the game, because |
| 547 |
we need to deal with all sorts of directory and seperator char |
| 548 |
issues. |
| 549 |
============================================================== |
| 550 |
*/ |
| 551 |
|
| 552 |
// referenced flags |
| 553 |
// these are in loop specific order so don't change the order |
| 554 |
#define FS_GENERAL_REF 0x01 |
| 555 |
#define FS_UI_REF 0x02 |
| 556 |
#define FS_CGAME_REF 0x04 |
| 557 |
#define FS_QAGAME_REF 0x08 |
| 558 |
// number of id paks that will never be autodownloaded from baseq3 |
| 559 |
#define NUM_ID_PAKS 9 |
| 560 |
|
| 561 |
#define MAX_FILE_HANDLES 64 |
| 562 |
|
| 563 |
#ifdef DEDICATED |
| 564 |
# define Q3CONFIG_CFG "q3config_server.cfg" |
| 565 |
#else |
| 566 |
# define Q3CONFIG_CFG "q3config.cfg" |
| 567 |
#endif |
| 568 |
|
| 569 |
qboolean FS_Initialized( void ); |
| 570 |
|
| 571 |
void FS_InitFilesystem ( void ); |
| 572 |
void FS_Shutdown( qboolean closemfp ); |
| 573 |
|
| 574 |
qboolean FS_ConditionalRestart( int checksumFeed ); |
| 575 |
void FS_Restart( int checksumFeed ); |
| 576 |
// shutdown and restart the filesystem so changes to fs_gamedir can take effect |
| 577 |
|
| 578 |
void FS_AddGameDirectory( const char *path, const char *dir ); |
| 579 |
|
| 580 |
char **FS_ListFiles( const char *directory, const char *extension, int *numfiles ); |
| 581 |
// directory should not have either a leading or trailing / |
| 582 |
// if extension is "/", only subdirectories will be returned |
| 583 |
// the returned files will not include any directories or / |
| 584 |
|
| 585 |
void FS_FreeFileList( char **list ); |
| 586 |
|
| 587 |
qboolean FS_FileExists( const char *file ); |
| 588 |
|
| 589 |
char *FS_BuildOSPath( const char *base, const char *game, const char *qpath ); |
| 590 |
|
| 591 |
int FS_LoadStack( void ); |
| 592 |
|
| 593 |
int FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize ); |
| 594 |
int FS_GetModList( char *listbuf, int bufsize ); |
| 595 |
|
| 596 |
fileHandle_t FS_FOpenFileWrite( const char *qpath ); |
| 597 |
fileHandle_t FS_FOpenFileAppend( const char *filename ); |
| 598 |
// will properly create any needed paths and deal with seperater character issues |
| 599 |
|
| 600 |
int FS_filelength( fileHandle_t f ); |
| 601 |
fileHandle_t FS_SV_FOpenFileWrite( const char *filename ); |
| 602 |
int FS_SV_FOpenFileRead( const char *filename, fileHandle_t *fp ); |
| 603 |
void FS_SV_Rename( const char *from, const char *to ); |
| 604 |
int FS_FOpenFileRead( const char *qpath, fileHandle_t *file, qboolean uniqueFILE ); |
| 605 |
// if uniqueFILE is true, then a new FILE will be fopened even if the file |
| 606 |
// is found in an already open pak file. If uniqueFILE is false, you must call |
| 607 |
// FS_FCloseFile instead of fclose, otherwise the pak FILE would be improperly closed |
| 608 |
// It is generally safe to always set uniqueFILE to true, because the majority of |
| 609 |
// file IO goes through FS_ReadFile, which Does The Right Thing already. |
| 610 |
|
| 611 |
int FS_FileIsInPAK(const char *filename, int *pChecksum ); |
| 612 |
// returns 1 if a file is in the PAK file, otherwise -1 |
| 613 |
|
| 614 |
int FS_Write( const void *buffer, int len, fileHandle_t f ); |
| 615 |
|
| 616 |
int FS_Read2( void *buffer, int len, fileHandle_t f ); |
| 617 |
int FS_Read( void *buffer, int len, fileHandle_t f ); |
| 618 |
// properly handles partial reads and reads from other dlls |
| 619 |
|
| 620 |
void FS_FCloseFile( fileHandle_t f ); |
| 621 |
// note: you can't just fclose from another DLL, due to MS libc issues |
| 622 |
|
| 623 |
int FS_ReadFile( const char *qpath, void **buffer ); |
| 624 |
// returns the length of the file |
| 625 |
// a null buffer will just return the file length without loading |
| 626 |
// as a quick check for existance. -1 length == not present |
| 627 |
// A 0 byte will always be appended at the end, so string ops are safe. |
| 628 |
// the buffer should be considered read-only, because it may be cached |
| 629 |
// for other uses. |
| 630 |
|
| 631 |
void FS_ForceFlush( fileHandle_t f ); |
| 632 |
// forces flush on files we're writing to. |
| 633 |
|
| 634 |
void FS_FreeFile( void *buffer ); |
| 635 |
// frees the memory returned by FS_ReadFile |
| 636 |
|
| 637 |
void FS_WriteFile( const char *qpath, const void *buffer, int size ); |
| 638 |
// writes a complete file, creating any subdirectories needed |
| 639 |
|
| 640 |
int FS_filelength( fileHandle_t f ); |
| 641 |
// doesn't work for files that are opened from a pack file |
| 642 |
|
| 643 |
int FS_FTell( fileHandle_t f ); |
| 644 |
// where are we? |
| 645 |
|
| 646 |
void FS_Flush( fileHandle_t f ); |
| 647 |
|
| 648 |
void QDECL FS_Printf( fileHandle_t f, const char *fmt, ... ) __attribute__ ((format (printf, 2, 3))); |
| 649 |
// like fprintf |
| 650 |
|
| 651 |
int FS_FOpenFileByMode( const char *qpath, fileHandle_t *f, fsMode_t mode ); |
| 652 |
// opens a file for reading, writing, or appending depending on the value of mode |
| 653 |
|
| 654 |
int FS_Seek( fileHandle_t f, long offset, int origin ); |
| 655 |
// seek on a file (doesn't work for zip files!!!!!!!!) |
| 656 |
|
| 657 |
qboolean FS_FilenameCompare( const char *s1, const char *s2 ); |
| 658 |
|
| 659 |
const char *FS_GamePureChecksum( void ); |
| 660 |
// Returns the checksum of the pk3 from which the server loaded the qagame.qvm |
| 661 |
|
| 662 |
const char *FS_LoadedPakNames( void ); |
| 663 |
const char *FS_LoadedPakChecksums( void ); |
| 664 |
const char *FS_LoadedPakPureChecksums( void ); |
| 665 |
// Returns a space separated string containing the checksums of all loaded pk3 files. |
| 666 |
// Servers with sv_pure set will get this string and pass it to clients. |
| 667 |
|
| 668 |
const char *FS_ReferencedPakNames( void ); |
| 669 |
const char *FS_ReferencedPakChecksums( void ); |
| 670 |
const char *FS_ReferencedPakPureChecksums( void ); |
| 671 |
// Returns a space separated string containing the checksums of all loaded |
| 672 |
// AND referenced pk3 files. Servers with sv_pure set will get this string |
| 673 |
// back from clients for pure validation |
| 674 |
|
| 675 |
void FS_ClearPakReferences( int flags ); |
| 676 |
// clears referenced booleans on loaded pk3s |
| 677 |
|
| 678 |
void FS_PureServerSetReferencedPaks( const char *pakSums, const char *pakNames ); |
| 679 |
void FS_PureServerSetLoadedPaks( const char *pakSums, const char *pakNames ); |
| 680 |
// If the string is empty, all data sources will be allowed. |
| 681 |
// If not empty, only pk3 files that match one of the space |
| 682 |
// separated checksums will be checked for files, with the |
| 683 |
// sole exception of .cfg files. |
| 684 |
|
| 685 |
qboolean FS_CheckDirTraversal(const char *checkdir); |
| 686 |
qboolean FS_idPak( char *pak, char *base ); |
| 687 |
qboolean FS_ComparePaks( char *neededpaks, int len, qboolean dlstring ); |
| 688 |
|
| 689 |
void FS_Rename( const char *from, const char *to ); |
| 690 |
|
| 691 |
void FS_Remove( const char *osPath ); |
| 692 |
void FS_HomeRemove( const char *homePath ); |
| 693 |
|
| 694 |
void FS_FilenameCompletion( const char *dir, const char *ext, |
| 695 |
qboolean stripExt, void(*callback)(const char *s) ); |
| 696 |
|
| 697 |
/* |
| 698 |
============================================================== |
| 699 |
|
| 700 |
Edit fields and command line history/completion |
| 701 |
|
| 702 |
============================================================== |
| 703 |
*/ |
| 704 |
|
| 705 |
#define MAX_EDIT_LINE 256 |
| 706 |
typedef struct { |
| 707 |
int cursor; |
| 708 |
int scroll; |
| 709 |
int widthInChars; |
| 710 |
char buffer[MAX_EDIT_LINE]; |
| 711 |
} field_t; |
| 712 |
|
| 713 |
void Field_Clear( field_t *edit ); |
| 714 |
void Field_AutoComplete( field_t *edit ); |
| 715 |
|
| 716 |
/* |
| 717 |
============================================================== |
| 718 |
|
| 719 |
MISC |
| 720 |
|
| 721 |
============================================================== |
| 722 |
*/ |
| 723 |
|
| 724 |
// centralizing the declarations for cl_cdkey |
| 725 |
// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=470 |
| 726 |
extern char cl_cdkey[34]; |
| 727 |
|
| 728 |
// returned by Sys_GetProcessorFeatures |
| 729 |
typedef enum |
| 730 |
{ |
| 731 |
CF_RDTSC = 1 << 0, |
| 732 |
CF_MMX = 1 << 1, |
| 733 |
CF_MMX_EXT = 1 << 2, |
| 734 |
CF_3DNOW = 1 << 3, |
| 735 |
CF_3DNOW_EXT = 1 << 4, |
| 736 |
CF_SSE = 1 << 5, |
| 737 |
CF_SSE2 = 1 << 6, |
| 738 |
CF_ALTIVEC = 1 << 7 |
| 739 |
} cpuFeatures_t; |
| 740 |
|
| 741 |
// centralized and cleaned, that's the max string you can send to a Com_Printf / Com_DPrintf (above gets truncated) |
| 742 |
#define MAXPRINTMSG 4096 |
| 743 |
|
| 744 |
|
| 745 |
typedef enum { |
| 746 |
// SE_NONE must be zero |
| 747 |
SE_NONE = 0, // evTime is still valid |
| 748 |
SE_KEY, // evValue is a key code, evValue2 is the down flag |
| 749 |
SE_CHAR, // evValue is an ascii char |
| 750 |
SE_MOUSE, // evValue and evValue2 are reletive signed x / y moves |
| 751 |
SE_JOYSTICK_AXIS, // evValue is an axis number and evValue2 is the current state (-127 to 127) |
| 752 |
SE_CONSOLE, // evPtr is a char* |
| 753 |
SE_PACKET // evPtr is a netadr_t followed by data bytes to evPtrLength |
| 754 |
} sysEventType_t; |
| 755 |
|
| 756 |
typedef struct { |
| 757 |
int evTime; |
| 758 |
sysEventType_t evType; |
| 759 |
int evValue, evValue2; |
| 760 |
int evPtrLength; // bytes of data pointed to by evPtr, for journaling |
| 761 |
void *evPtr; // this must be manually freed if not NULL |
| 762 |
} sysEvent_t; |
| 763 |
|
| 764 |
void Com_QueueEvent( int time, sysEventType_t type, int value, int value2, int ptrLength, void *ptr ); |
| 765 |
int Com_EventLoop( void ); |
| 766 |
sysEvent_t Com_GetSystemEvent( void ); |
| 767 |
|
| 768 |
char *CopyString( const char *in ); |
| 769 |
void Info_Print( const char *s ); |
| 770 |
|
| 771 |
void Com_BeginRedirect (char *buffer, int buffersize, void (*flush)(char *)); |
| 772 |
void Com_EndRedirect( void ); |
| 773 |
void QDECL Com_Printf( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2))); |
| 774 |
void QDECL Com_DPrintf( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2))); |
| 775 |
void QDECL Com_Error( int code, const char *fmt, ... ) __attribute__ ((format (printf, 2, 3))); |
| 776 |
void Com_Quit_f( void ); |
| 777 |
|
| 778 |
int Com_Milliseconds( void ); // will be journaled properly |
| 779 |
unsigned Com_BlockChecksum( const void *buffer, int length ); |
| 780 |
char *Com_MD5File(const char *filename, int length, const char *prefix, int prefix_len); |
| 781 |
int Com_HashKey(char *string, int maxlen); |
| 782 |
int Com_Filter(char *filter, char *name, int casesensitive); |
| 783 |
int Com_FilterPath(char *filter, char *name, int casesensitive); |
| 784 |
int Com_RealTime(qtime_t *qtime); |
| 785 |
qboolean Com_SafeMode( void ); |
| 786 |
|
| 787 |
void Com_StartupVariable( const char *match ); |
| 788 |
// checks for and removes command line "+set var arg" constructs |
| 789 |
// if match is NULL, all set commands will be executed, otherwise |
| 790 |
// only a set with the exact name. Only used during startup. |
| 791 |
|
| 792 |
|
| 793 |
extern cvar_t *com_developer; |
| 794 |
extern cvar_t *com_dedicated; |
| 795 |
extern cvar_t *com_speeds; |
| 796 |
extern cvar_t *com_timescale; |
| 797 |
extern cvar_t *com_sv_running; |
| 798 |
extern cvar_t *com_cl_running; |
| 799 |
extern cvar_t *com_version; |
| 800 |
extern cvar_t *com_blood; |
| 801 |
extern cvar_t *com_buildScript; // for building release pak files |
| 802 |
extern cvar_t *com_journal; |
| 803 |
extern cvar_t *com_cameraMode; |
| 804 |
extern cvar_t *com_ansiColor; |
| 805 |
extern cvar_t *com_unfocused; |
| 806 |
extern cvar_t *com_minimized; |
| 807 |
extern cvar_t *com_altivec; |
| 808 |
|
| 809 |
// both client and server must agree to pause |
| 810 |
extern cvar_t *cl_paused; |
| 811 |
extern cvar_t *sv_paused; |
| 812 |
|
| 813 |
extern cvar_t *cl_packetdelay; |
| 814 |
extern cvar_t *sv_packetdelay; |
| 815 |
|
| 816 |
// com_speeds times |
| 817 |
extern int time_game; |
| 818 |
extern int time_frontend; |
| 819 |
extern int time_backend; // renderer backend time |
| 820 |
|
| 821 |
extern int com_frameTime; |
| 822 |
extern int com_frameMsec; |
| 823 |
|
| 824 |
extern qboolean com_errorEntered; |
| 825 |
|
| 826 |
extern fileHandle_t com_journalFile; |
| 827 |
extern fileHandle_t com_journalDataFile; |
| 828 |
|
| 829 |
typedef enum { |
| 830 |
TAG_FREE, |
| 831 |
TAG_GENERAL, |
| 832 |
TAG_BOTLIB, |
| 833 |
TAG_RENDERER, |
| 834 |
TAG_SMALL, |
| 835 |
TAG_STATIC |
| 836 |
} memtag_t; |
| 837 |
|
| 838 |
/* |
| 839 |
|
| 840 |
--- low memory ---- |
| 841 |
server vm |
| 842 |
server clipmap |
| 843 |
---mark--- |
| 844 |
renderer initialization (shaders, etc) |
| 845 |
UI vm |
| 846 |
cgame vm |
| 847 |
renderer map |
| 848 |
renderer models |
| 849 |
|
| 850 |
---free--- |
| 851 |
|
| 852 |
temp file loading |
| 853 |
--- high memory --- |
| 854 |
|
| 855 |
*/ |
| 856 |
|
| 857 |
#if defined(_DEBUG) && !defined(BSPC) |
| 858 |
#define ZONE_DEBUG |
| 859 |
#endif |
| 860 |
|
| 861 |
#ifdef ZONE_DEBUG |
| 862 |
#define Z_TagMalloc(size, tag) Z_TagMallocDebug(size, tag, #size, __FILE__, __LINE__) |
| 863 |
#define Z_Malloc(size) Z_MallocDebug(size, #size, __FILE__, __LINE__) |
| 864 |
#define S_Malloc(size) S_MallocDebug(size, #size, __FILE__, __LINE__) |
| 865 |
void *Z_TagMallocDebug( int size, int tag, char *label, char *file, int line ); // NOT 0 filled memory |
| 866 |
void *Z_MallocDebug( int size, char *label, char *file, int line ); // returns 0 filled memory |
| 867 |
void *S_MallocDebug( int size, char *label, char *file, int line ); // returns 0 filled memory |
| 868 |
#else |
| 869 |
void *Z_TagMalloc( int size, int tag ); // NOT 0 filled memory |
| 870 |
void *Z_Malloc( int size ); // returns 0 filled memory |
| 871 |
void *S_Malloc( int size ); // NOT 0 filled memory only for small allocations |
| 872 |
#endif |
| 873 |
void Z_Free( void *ptr ); |
| 874 |
void Z_FreeTags( int tag ); |
| 875 |
int Z_AvailableMemory( void ); |
| 876 |
void Z_LogHeap( void ); |
| 877 |
|
| 878 |
void Hunk_Clear( void ); |
| 879 |
void Hunk_ClearToMark( void ); |
| 880 |
void Hunk_SetMark( void ); |
| 881 |
qboolean Hunk_CheckMark( void ); |
| 882 |
void Hunk_ClearTempMemory( void ); |
| 883 |
void *Hunk_AllocateTempMemory( int size ); |
| 884 |
void Hunk_FreeTempMemory( void *buf ); |
| 885 |
int Hunk_MemoryRemaining( void ); |
| 886 |
void Hunk_Log( void); |
| 887 |
void Hunk_Trash( void ); |
| 888 |
|
| 889 |
void Com_TouchMemory( void ); |
| 890 |
|
| 891 |
// commandLine should not include the executable name (argv[0]) |
| 892 |
void Com_Init( char *commandLine ); |
| 893 |
void Com_Frame( void ); |
| 894 |
void Com_Shutdown( void ); |
| 895 |
|
| 896 |
|
| 897 |
/* |
| 898 |
============================================================== |
| 899 |
|
| 900 |
CLIENT / SERVER SYSTEMS |
| 901 |
|
| 902 |
============================================================== |
| 903 |
*/ |
| 904 |
|
| 905 |
// |
| 906 |
// client interface |
| 907 |
// |
| 908 |
void CL_InitKeyCommands( void ); |
| 909 |
// the keyboard binding interface must be setup before execing |
| 910 |
// config files, but the rest of client startup will happen later |
| 911 |
|
| 912 |
void CL_Init( void ); |
| 913 |
void CL_Disconnect( qboolean showMainMenu ); |
| 914 |
void CL_Shutdown( void ); |
| 915 |
void CL_Frame( int msec ); |
| 916 |
qboolean CL_GameCommand( void ); |
| 917 |
void CL_KeyEvent (int key, qboolean down, unsigned time); |
| 918 |
|
| 919 |
void CL_CharEvent( int key ); |
| 920 |
// char events are for field typing, not game control |
| 921 |
|
| 922 |
void CL_MouseEvent( int dx, int dy, int time ); |
| 923 |
|
| 924 |
void CL_JoystickEvent( int axis, int value, int time ); |
| 925 |
|
| 926 |
void CL_PacketEvent( netadr_t from, msg_t *msg ); |
| 927 |
|
| 928 |
void CL_ConsolePrint( char *text ); |
| 929 |
|
| 930 |
void CL_MapLoading( void ); |
| 931 |
// do a screen update before starting to load a map |
| 932 |
// when the server is going to load a new map, the entire hunk |
| 933 |
// will be cleared, so the client must shutdown cgame, ui, and |
| 934 |
// the renderer |
| 935 |
|
| 936 |
void CL_ForwardCommandToServer( const char *string ); |
| 937 |
// adds the current command line as a clc_clientCommand to the client message. |
| 938 |
// things like godmode, noclip, etc, are commands directed to the server, |
| 939 |
// so when they are typed in at the console, they will need to be forwarded. |
| 940 |
|
| 941 |
void CL_CDDialog( void ); |
| 942 |
// bring up the "need a cd to play" dialog |
| 943 |
|
| 944 |
void CL_ShutdownAll( void ); |
| 945 |
// shutdown all the client stuff |
| 946 |
|
| 947 |
void CL_FlushMemory( void ); |
| 948 |
// dump all memory on an error |
| 949 |
|
| 950 |
void CL_StartHunkUsers( qboolean rendererOnly ); |
| 951 |
// start all the client stuff using the hunk |
| 952 |
|
| 953 |
void Key_KeynameCompletion( void(*callback)(const char *s) ); |
| 954 |
// for keyname autocompletion |
| 955 |
|
| 956 |
void Key_WriteBindings( fileHandle_t f ); |
| 957 |
// for writing the config files |
| 958 |
|
| 959 |
void S_ClearSoundBuffer( void ); |
| 960 |
// call before filesystem access |
| 961 |
|
| 962 |
void SCR_DebugGraph (float value, int color); // FIXME: move logging to common? |
| 963 |
|
| 964 |
// |
| 965 |
// server interface |
| 966 |
// |
| 967 |
void SV_Init( void ); |
| 968 |
void SV_Shutdown( char *finalmsg ); |
| 969 |
void SV_Frame( int msec ); |
| 970 |
void SV_PacketEvent( netadr_t from, msg_t *msg ); |
| 971 |
qboolean SV_GameCommand( void ); |
| 972 |
|
| 973 |
|
| 974 |
// |
| 975 |
// UI interface |
| 976 |
// |
| 977 |
qboolean UI_GameCommand( void ); |
| 978 |
qboolean UI_usesUniqueCDKey(void); |
| 979 |
|
| 980 |
/* |
| 981 |
============================================================== |
| 982 |
|
| 983 |
NON-PORTABLE SYSTEM SERVICES |
| 984 |
|
| 985 |
============================================================== |
| 986 |
*/ |
| 987 |
|
| 988 |
typedef enum { |
| 989 |
AXIS_SIDE, |
| 990 |
AXIS_FORWARD, |
| 991 |
AXIS_UP, |
| 992 |
AXIS_ROLL, |
| 993 |
AXIS_YAW, |
| 994 |
AXIS_PITCH, |
| 995 |
MAX_JOYSTICK_AXIS |
| 996 |
} joystickAxis_t; |
| 997 |
|
| 998 |
void Sys_Init (void); |
| 999 |
|
| 1000 |
// general development dll loading for virtual machine testing |
| 1001 |
void * QDECL Sys_LoadDll( const char *name, char *fqpath , intptr_t (QDECL **entryPoint)(int, ...), |
| 1002 |
intptr_t (QDECL *systemcalls)(intptr_t, ...) ); |
| 1003 |
void Sys_UnloadDll( void *dllHandle ); |
| 1004 |
|
| 1005 |
void Sys_UnloadGame( void ); |
| 1006 |
void *Sys_GetGameAPI( void *parms ); |
| 1007 |
|
| 1008 |
void Sys_UnloadCGame( void ); |
| 1009 |
void *Sys_GetCGameAPI( void ); |
| 1010 |
|
| 1011 |
void Sys_UnloadUI( void ); |
| 1012 |
void *Sys_GetUIAPI( void ); |
| 1013 |
|
| 1014 |
//bot libraries |
| 1015 |
void Sys_UnloadBotLib( void ); |
| 1016 |
void *Sys_GetBotLibAPI( void *parms ); |
| 1017 |
|
| 1018 |
char *Sys_GetCurrentUser( void ); |
| 1019 |
|
| 1020 |
void QDECL Sys_Error( const char *error, ...) __attribute__ ((format (printf, 1, 2))); |
| 1021 |
void Sys_Quit (void); |
| 1022 |
char *Sys_GetClipboardData( void ); // note that this isn't journaled... |
| 1023 |
|
| 1024 |
void Sys_Print( const char *msg ); |
| 1025 |
|
| 1026 |
// Sys_Milliseconds should only be used for profiling purposes, |
| 1027 |
// any game related timing information should come from event timestamps |
| 1028 |
int Sys_Milliseconds (void); |
| 1029 |
|
| 1030 |
void Sys_SnapVector( float *v ); |
| 1031 |
|
| 1032 |
qboolean Sys_RandomBytes( byte *string, int len ); |
| 1033 |
|
| 1034 |
// the system console is shown when a dedicated server is running |
| 1035 |
void Sys_DisplaySystemConsole( qboolean show ); |
| 1036 |
|
| 1037 |
cpuFeatures_t Sys_GetProcessorFeatures( void ); |
| 1038 |
|
| 1039 |
void Sys_SetErrorText( const char *text ); |
| 1040 |
|
| 1041 |
void Sys_SendPacket( int length, const void *data, netadr_t to ); |
| 1042 |
qboolean Sys_GetPacket( netadr_t *net_from, msg_t *net_message ); |
| 1043 |
|
| 1044 |
qboolean Sys_StringToAdr( const char *s, netadr_t *a, netadrtype_t family ); |
| 1045 |
//Does NOT parse port numbers, only base addresses. |
| 1046 |
|
| 1047 |
qboolean Sys_IsLANAddress (netadr_t adr); |
| 1048 |
void Sys_ShowIP(void); |
| 1049 |
|
| 1050 |
void Sys_Mkdir( const char *path ); |
| 1051 |
char *Sys_Cwd( void ); |
| 1052 |
void Sys_SetDefaultInstallPath(const char *path); |
| 1053 |
char *Sys_DefaultInstallPath(void); |
| 1054 |
|
| 1055 |
#ifdef MACOS_X |
| 1056 |
char *Sys_DefaultAppPath(void); |
| 1057 |
#endif |
| 1058 |
|
| 1059 |
void Sys_SetDefaultHomePath(const char *path); |
| 1060 |
char *Sys_DefaultHomePath(void); |
| 1061 |
const char *Sys_Dirname( char *path ); |
| 1062 |
const char *Sys_Basename( char *path ); |
| 1063 |
char *Sys_ConsoleInput(void); |
| 1064 |
|
| 1065 |
char **Sys_ListFiles( const char *directory, const char *extension, char *filter, int *numfiles, qboolean wantsubs ); |
| 1066 |
void Sys_FreeFileList( char **list ); |
| 1067 |
void Sys_Sleep(int msec); |
| 1068 |
|
| 1069 |
qboolean Sys_LowPhysicalMemory( void ); |
| 1070 |
|
| 1071 |
/* This is based on the Adaptive Huffman algorithm described in Sayood's Data |
| 1072 |
* Compression book. The ranks are not actually stored, but implicitly defined |
| 1073 |
* by the location of a node within a doubly-linked list */ |
| 1074 |
|
| 1075 |
#define NYT HMAX /* NYT = Not Yet Transmitted */ |
| 1076 |
#define INTERNAL_NODE (HMAX+1) |
| 1077 |
|
| 1078 |
typedef struct nodetype { |
| 1079 |
struct nodetype *left, *right, *parent; /* tree structure */ |
| 1080 |
struct nodetype *next, *prev; /* doubly-linked list */ |
| 1081 |
struct nodetype **head; /* highest ranked node in block */ |
| 1082 |
int weight; |
| 1083 |
int symbol; |
| 1084 |
} node_t; |
| 1085 |
|
| 1086 |
#define HMAX 256 /* Maximum symbol */ |
| 1087 |
|
| 1088 |
typedef struct { |
| 1089 |
int blocNode; |
| 1090 |
int blocPtrs; |
| 1091 |
|
| 1092 |
node_t* tree; |
| 1093 |
node_t* lhead; |
| 1094 |
node_t* ltail; |
| 1095 |
node_t* loc[HMAX+1]; |
| 1096 |
node_t** freelist; |
| 1097 |
|
| 1098 |
node_t nodeList[768]; |
| 1099 |
node_t* nodePtrs[768]; |
| 1100 |
} huff_t; |
| 1101 |
|
| 1102 |
typedef struct { |
| 1103 |
huff_t compressor; |
| 1104 |
huff_t decompressor; |
| 1105 |
} huffman_t; |
| 1106 |
|
| 1107 |
void Huff_Compress(msg_t *buf, int offset); |
| 1108 |
void Huff_Decompress(msg_t *buf, int offset); |
| 1109 |
void Huff_Init(huffman_t *huff); |
| 1110 |
void Huff_addRef(huff_t* huff, byte ch); |
| 1111 |
int Huff_Receive (node_t *node, int *ch, byte *fin); |
| 1112 |
void Huff_transmit (huff_t *huff, int ch, byte *fout); |
| 1113 |
void Huff_offsetReceive (node_t *node, int *ch, byte *fin, int *offset); |
| 1114 |
void Huff_offsetTransmit (huff_t *huff, int ch, byte *fout, int *offset); |
| 1115 |
void Huff_putBit( int bit, byte *fout, int *offset); |
| 1116 |
int Huff_getBit( byte *fout, int *offset); |
| 1117 |
|
| 1118 |
// don't use if you don't know what you're doing. |
| 1119 |
int Huff_getBloc(void); |
| 1120 |
void Huff_setBloc(int _bloc); |
| 1121 |
|
| 1122 |
|
| 1123 |
extern huffman_t clientHuffTables; |
| 1124 |
|
| 1125 |
#define SV_ENCODE_START 4 |
| 1126 |
#define SV_DECODE_START 12 |
| 1127 |
#define CL_ENCODE_START 12 |
| 1128 |
#define CL_DECODE_START 4 |
| 1129 |
|
| 1130 |
// flags for sv_allowDownload and cl_allowDownload |
| 1131 |
#define DLF_ENABLE 1 |
| 1132 |
#define DLF_NO_REDIRECT 2 |
| 1133 |
#define DLF_NO_UDP 4 |
| 1134 |
#define DLF_NO_DISCONNECT 8 |
| 1135 |
|
| 1136 |
#endif // _QCOMMON_H_ |