123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827 |
- #include "../game/q_shared.h"
- #define VERSION 3.19
- #define BASEDIRNAME "baseq2"
- #ifdef WIN32
- #ifdef NDEBUG
- #define BUILDSTRING "Win32 RELEASE"
- #else
- #define BUILDSTRING "Win32 DEBUG"
- #endif
- #ifdef _M_IX86
- #define CPUSTRING "x86"
- #elif defined _M_ALPHA
- #define CPUSTRING "AXP"
- #endif
- #elif defined __linux__
- #define BUILDSTRING "Linux"
- #ifdef __i386__
- #define CPUSTRING "i386"
- #elif defined __alpha__
- #define CPUSTRING "axp"
- #else
- #define CPUSTRING "Unknown"
- #endif
- #elif defined __sun__
- #define BUILDSTRING "Solaris"
- #ifdef __i386__
- #define CPUSTRING "i386"
- #else
- #define CPUSTRING "sparc"
- #endif
- #else // !WIN32
- #define BUILDSTRING "NON-WIN32"
- #define CPUSTRING "NON-WIN32"
- #endif
- typedef struct sizebuf_s
- {
- qboolean allowoverflow;
- qboolean overflowed;
- byte *data;
- int maxsize;
- int cursize;
- int readcount;
- } sizebuf_t;
- void SZ_Init (sizebuf_t *buf, byte *data, int length);
- void SZ_Clear (sizebuf_t *buf);
- void *SZ_GetSpace (sizebuf_t *buf, int length);
- void SZ_Write (sizebuf_t *buf, void *data, int length);
- void SZ_Print (sizebuf_t *buf, char *data);
- struct usercmd_s;
- struct entity_state_s;
- void MSG_WriteChar (sizebuf_t *sb, int c);
- void MSG_WriteByte (sizebuf_t *sb, int c);
- void MSG_WriteShort (sizebuf_t *sb, int c);
- void MSG_WriteLong (sizebuf_t *sb, int c);
- void MSG_WriteFloat (sizebuf_t *sb, float f);
- void MSG_WriteString (sizebuf_t *sb, char *s);
- void MSG_WriteCoord (sizebuf_t *sb, float f);
- void MSG_WritePos (sizebuf_t *sb, vec3_t pos);
- void MSG_WriteAngle (sizebuf_t *sb, float f);
- void MSG_WriteAngle16 (sizebuf_t *sb, float f);
- void MSG_WriteDeltaUsercmd (sizebuf_t *sb, struct usercmd_s *from, struct usercmd_s *cmd);
- void MSG_WriteDeltaEntity (struct entity_state_s *from, struct entity_state_s *to, sizebuf_t *msg, qboolean force, qboolean newentity);
- void MSG_WriteDir (sizebuf_t *sb, vec3_t vector);
- void MSG_BeginReading (sizebuf_t *sb);
- int MSG_ReadChar (sizebuf_t *sb);
- int MSG_ReadByte (sizebuf_t *sb);
- int MSG_ReadShort (sizebuf_t *sb);
- int MSG_ReadLong (sizebuf_t *sb);
- float MSG_ReadFloat (sizebuf_t *sb);
- char *MSG_ReadString (sizebuf_t *sb);
- char *MSG_ReadStringLine (sizebuf_t *sb);
- float MSG_ReadCoord (sizebuf_t *sb);
- void MSG_ReadPos (sizebuf_t *sb, vec3_t pos);
- float MSG_ReadAngle (sizebuf_t *sb);
- float MSG_ReadAngle16 (sizebuf_t *sb);
- void MSG_ReadDeltaUsercmd (sizebuf_t *sb, struct usercmd_s *from, struct usercmd_s *cmd);
- void MSG_ReadDir (sizebuf_t *sb, vec3_t vector);
- void MSG_ReadData (sizebuf_t *sb, void *buffer, int size);
- extern qboolean bigendien;
- extern short BigShort (short l);
- extern short LittleShort (short l);
- extern int BigLong (int l);
- extern int LittleLong (int l);
- extern float BigFloat (float l);
- extern float LittleFloat (float l);
- int COM_Argc (void);
- char *COM_Argv (int arg);
- void COM_ClearArgv (int arg);
- int COM_CheckParm (char *parm);
- void COM_AddParm (char *parm);
- void COM_Init (void);
- void COM_InitArgv (int argc, char **argv);
- char *CopyString (char *in);
- void Info_Print (char *s);
- void CRC_Init(unsigned short *crcvalue);
- void CRC_ProcessByte(unsigned short *crcvalue, byte data);
- unsigned short CRC_Value(unsigned short crcvalue);
- unsigned short CRC_Block (byte *start, int count);
- #define PROTOCOL_VERSION 34
- #define PORT_MASTER 27900
- #define PORT_CLIENT 27901
- #define PORT_SERVER 27910
- #define UPDATE_BACKUP 16 // copies of entity_state_t to keep buffered
-
- #define UPDATE_MASK (UPDATE_BACKUP-1)
- enum svc_ops_e
- {
- svc_bad,
-
- svc_muzzleflash,
- svc_muzzleflash2,
- svc_temp_entity,
- svc_layout,
- svc_inventory,
-
- svc_nop,
- svc_disconnect,
- svc_reconnect,
- svc_sound,
- svc_print,
- svc_stufftext,
- svc_serverdata,
- svc_configstring,
- svc_spawnbaseline,
- svc_centerprint,
- svc_download,
- svc_playerinfo,
- svc_packetentities,
- svc_deltapacketentities,
- svc_frame
- };
- enum clc_ops_e
- {
- clc_bad,
- clc_nop,
- clc_move,
- clc_userinfo,
- clc_stringcmd
- };
- #define PS_M_TYPE (1<<0)
- #define PS_M_ORIGIN (1<<1)
- #define PS_M_VELOCITY (1<<2)
- #define PS_M_TIME (1<<3)
- #define PS_M_FLAGS (1<<4)
- #define PS_M_GRAVITY (1<<5)
- #define PS_M_DELTA_ANGLES (1<<6)
- #define PS_VIEWOFFSET (1<<7)
- #define PS_VIEWANGLES (1<<8)
- #define PS_KICKANGLES (1<<9)
- #define PS_BLEND (1<<10)
- #define PS_FOV (1<<11)
- #define PS_WEAPONINDEX (1<<12)
- #define PS_WEAPONFRAME (1<<13)
- #define PS_RDFLAGS (1<<14)
- #define CM_ANGLE1 (1<<0)
- #define CM_ANGLE2 (1<<1)
- #define CM_ANGLE3 (1<<2)
- #define CM_FORWARD (1<<3)
- #define CM_SIDE (1<<4)
- #define CM_UP (1<<5)
- #define CM_BUTTONS (1<<6)
- #define CM_IMPULSE (1<<7)
- #define SND_VOLUME (1<<0) // a byte
- #define SND_ATTENUATION (1<<1) // a byte
- #define SND_POS (1<<2) // three coordinates
- #define SND_ENT (1<<3) // a short 0-2: channel, 3-12: entity
- #define SND_OFFSET (1<<4) // a byte, msec offset from frame start
- #define DEFAULT_SOUND_PACKET_VOLUME 1.0
- #define DEFAULT_SOUND_PACKET_ATTENUATION 1.0
- #define U_ORIGIN1 (1<<0)
- #define U_ORIGIN2 (1<<1)
- #define U_ANGLE2 (1<<2)
- #define U_ANGLE3 (1<<3)
- #define U_FRAME8 (1<<4) // frame is a byte
- #define U_EVENT (1<<5)
- #define U_REMOVE (1<<6) // REMOVE this entity, don't add it
- #define U_MOREBITS1 (1<<7) // read one additional byte
- #define U_NUMBER16 (1<<8) // NUMBER8 is implicit if not set
- #define U_ORIGIN3 (1<<9)
- #define U_ANGLE1 (1<<10)
- #define U_MODEL (1<<11)
- #define U_RENDERFX8 (1<<12) // fullbright, etc
- #define U_EFFECTS8 (1<<14) // autorotate, trails, etc
- #define U_MOREBITS2 (1<<15) // read one additional byte
- #define U_SKIN8 (1<<16)
- #define U_FRAME16 (1<<17) // frame is a short
- #define U_RENDERFX16 (1<<18) // 8 + 16 = 32
- #define U_EFFECTS16 (1<<19) // 8 + 16 = 32
- #define U_MODEL2 (1<<20) // weapons, flags, etc
- #define U_MODEL3 (1<<21)
- #define U_MODEL4 (1<<22)
- #define U_MOREBITS3 (1<<23) // read one additional byte
- #define U_OLDORIGIN (1<<24) // FIXME: get rid of this
- #define U_SKIN16 (1<<25)
- #define U_SOUND (1<<26)
- #define U_SOLID (1<<27)
- #define EXEC_NOW 0 // don't return until completed
- #define EXEC_INSERT 1 // insert at current position, but don't run yet
- #define EXEC_APPEND 2 // add to end of the command buffer
- void Cbuf_Init (void);
- void Cbuf_AddText (char *text);
- void Cbuf_InsertText (char *text);
- void Cbuf_ExecuteText (int exec_when, char *text);
- void Cbuf_AddEarlyCommands (qboolean clear);
- qboolean Cbuf_AddLateCommands (void);
- void Cbuf_Execute (void);
- void Cbuf_CopyToDefer (void);
- void Cbuf_InsertFromDefer (void);
- typedef void (*xcommand_t) (void);
- void Cmd_Init (void);
- void Cmd_AddCommand (char *cmd_name, xcommand_t function);
- void Cmd_RemoveCommand (char *cmd_name);
- qboolean Cmd_Exists (char *cmd_name);
- char *Cmd_CompleteCommand (char *partial);
- int Cmd_Argc (void);
- char *Cmd_Argv (int arg);
- char *Cmd_Args (void);
- void Cmd_TokenizeString (char *text, qboolean macroExpand);
- void Cmd_ExecuteString (char *text);
- void Cmd_ForwardToServer (void);
- extern cvar_t *cvar_vars;
- cvar_t *Cvar_Get (char *var_name, char *value, int flags);
- cvar_t *Cvar_Set (char *var_name, char *value);
- cvar_t *Cvar_ForceSet (char *var_name, char *value);
- cvar_t *Cvar_FullSet (char *var_name, char *value, int flags);
- void Cvar_SetValue (char *var_name, float value);
- float Cvar_VariableValue (char *var_name);
- char *Cvar_VariableString (char *var_name);
- char *Cvar_CompleteVariable (char *partial);
- void Cvar_GetLatchedVars (void);
- qboolean Cvar_Command (void);
- void Cvar_WriteVariables (char *path);
- void Cvar_Init (void);
- char *Cvar_Userinfo (void);
- char *Cvar_Serverinfo (void);
- extern qboolean userinfo_modified;
- #define PORT_ANY -1
- #define MAX_MSGLEN 1400 // max length of a message
- #define PACKET_HEADER 10 // two ints and a short
- typedef enum {NA_LOOPBACK, NA_BROADCAST, NA_IP, NA_IPX, NA_BROADCAST_IPX} netadrtype_t;
- typedef enum {NS_CLIENT, NS_SERVER} netsrc_t;
- typedef struct
- {
- netadrtype_t type;
- byte ip[4];
- byte ipx[10];
- unsigned short port;
- } netadr_t;
- void NET_Init (void);
- void NET_Shutdown (void);
- void NET_Config (qboolean multiplayer);
- qboolean NET_GetPacket (netsrc_t sock, netadr_t *net_from, sizebuf_t *net_message);
- void NET_SendPacket (netsrc_t sock, int length, void *data, netadr_t to);
- qboolean NET_CompareAdr (netadr_t a, netadr_t b);
- qboolean NET_CompareBaseAdr (netadr_t a, netadr_t b);
- qboolean NET_IsLocalAddress (netadr_t adr);
- char *NET_AdrToString (netadr_t a);
- qboolean NET_StringToAdr (char *s, netadr_t *a);
- void NET_Sleep(int msec);
- #define OLD_AVG 0.99 // total = oldtotal*OLD_AVG + new*(1-OLD_AVG)
- #define MAX_LATENT 32
- typedef struct
- {
- qboolean fatal_error;
- netsrc_t sock;
- int dropped;
- int last_received;
- int last_sent;
- netadr_t remote_address;
- int qport;
- int incoming_sequence;
- int incoming_acknowledged;
- int incoming_reliable_acknowledged;
- int incoming_reliable_sequence;
- int outgoing_sequence;
- int reliable_sequence;
- int last_reliable_sequence;
- sizebuf_t message;
- byte message_buf[MAX_MSGLEN-16];
- int reliable_length;
- byte reliable_buf[MAX_MSGLEN-16];
- } netchan_t;
- extern netadr_t net_from;
- extern sizebuf_t net_message;
- extern byte net_message_buffer[MAX_MSGLEN];
- void Netchan_Init (void);
- void Netchan_Setup (netsrc_t sock, netchan_t *chan, netadr_t adr, int qport);
- qboolean Netchan_NeedReliable (netchan_t *chan);
- void Netchan_Transmit (netchan_t *chan, int length, byte *data);
- void Netchan_OutOfBand (int net_socket, netadr_t adr, int length, byte *data);
- void Netchan_OutOfBandPrint (int net_socket, netadr_t adr, char *format, ...);
- qboolean Netchan_Process (netchan_t *chan, sizebuf_t *msg);
- qboolean Netchan_CanReliable (netchan_t *chan);
- #include "../qcommon/qfiles.h"
- cmodel_t *CM_LoadMap (char *name, qboolean clientload, unsigned *checksum);
- cmodel_t *CM_InlineModel (char *name);
- int CM_NumClusters (void);
- int CM_NumInlineModels (void);
- char *CM_EntityString (void);
- int CM_HeadnodeForBox (vec3_t mins, vec3_t maxs);
- int CM_PointContents (vec3_t p, int headnode);
- int CM_TransformedPointContents (vec3_t p, int headnode, vec3_t origin, vec3_t angles);
- trace_t CM_BoxTrace (vec3_t start, vec3_t end,
- vec3_t mins, vec3_t maxs,
- int headnode, int brushmask);
- trace_t CM_TransformedBoxTrace (vec3_t start, vec3_t end,
- vec3_t mins, vec3_t maxs,
- int headnode, int brushmask,
- vec3_t origin, vec3_t angles);
- byte *CM_ClusterPVS (int cluster);
- byte *CM_ClusterPHS (int cluster);
- int CM_PointLeafnum (vec3_t p);
- int CM_BoxLeafnums (vec3_t mins, vec3_t maxs, int *list,
- int listsize, int *topnode);
- int CM_LeafContents (int leafnum);
- int CM_LeafCluster (int leafnum);
- int CM_LeafArea (int leafnum);
- void CM_SetAreaPortalState (int portalnum, qboolean open);
- qboolean CM_AreasConnected (int area1, int area2);
- int CM_WriteAreaBits (byte *buffer, int area);
- qboolean CM_HeadnodeVisible (int headnode, byte *visbits);
- void CM_WritePortalState (FILE *f);
- void CM_ReadPortalState (FILE *f);
- extern float pm_airaccelerate;
- void Pmove (pmove_t *pmove);
- void FS_InitFilesystem (void);
- void FS_SetGamedir (char *dir);
- char *FS_Gamedir (void);
- char *FS_NextPath (char *prevpath);
- void FS_ExecAutoexec (void);
- int FS_FOpenFile (char *filename, FILE **file);
- void FS_FCloseFile (FILE *f);
- int FS_LoadFile (char *path, void **buffer);
- void FS_Read (void *buffer, int len, FILE *f);
- void FS_FreeFile (void *buffer);
- void FS_CreatePath (char *path);
- #define ERR_FATAL 0 // exit the entire game with a popup window
- #define ERR_DROP 1 // print to console and disconnect from game
- #define ERR_QUIT 2 // not an error, just a normal exit
- #define EXEC_NOW 0 // don't return until completed
- #define EXEC_INSERT 1 // insert at current position, but don't run yet
- #define EXEC_APPEND 2 // add to end of the command buffer
- #define PRINT_ALL 0
- #define PRINT_DEVELOPER 1 // only print when "developer 1"
- void Com_BeginRedirect (int target, char *buffer, int buffersize, void (*flush));
- void Com_EndRedirect (void);
- void Com_Printf (char *fmt, ...);
- void Com_DPrintf (char *fmt, ...);
- void Com_Error (int code, char *fmt, ...);
- void Com_Quit (void);
- int Com_ServerState (void);
- void Com_SetServerState (int state);
- unsigned Com_BlockChecksum (void *buffer, int length);
- byte COM_BlockSequenceCRCByte (byte *base, int length, int sequence);
- float frand(void);
- float crand(void);
- extern cvar_t *developer;
- extern cvar_t *dedicated;
- extern cvar_t *host_speeds;
- extern cvar_t *log_stats;
- extern FILE *log_stats_file;
- extern int time_before_game;
- extern int time_after_game;
- extern int time_before_ref;
- extern int time_after_ref;
- void Z_Free (void *ptr);
- void *Z_Malloc (int size);
- void *Z_TagMalloc (int size, int tag);
- void Z_FreeTags (int tag);
- void Qcommon_Init (int argc, char **argv);
- void Qcommon_Frame (int msec);
- void Qcommon_Shutdown (void);
- #define NUMVERTEXNORMALS 162
- extern vec3_t bytedirs[NUMVERTEXNORMALS];
- void SCR_DebugGraph (float value, int color);
- void Sys_Init (void);
- void Sys_AppActivate (void);
- void Sys_UnloadGame (void);
- void *Sys_GetGameAPI (void *parms);
- char *Sys_ConsoleInput (void);
- void Sys_ConsoleOutput (char *string);
- void Sys_SendKeyEvents (void);
- void Sys_Error (char *error, ...);
- void Sys_Quit (void);
- char *Sys_GetClipboardData( void );
- void Sys_CopyProtect (void);
- void CL_Init (void);
- void CL_Drop (void);
- void CL_Shutdown (void);
- void CL_Frame (int msec);
- void Con_Print (char *text);
- void SCR_BeginLoadingPlaque (void);
- void SV_Init (void);
- void SV_Shutdown (char *finalmsg, qboolean reconnect);
- void SV_Frame (int msec);
|