2008-06-09 22:00:00 +02:00
|
|
|
|
//=======================================================================
|
|
|
|
|
// Copyright XashXT Group 2007 <20>
|
|
|
|
|
// common.h - definitions common between client and server
|
|
|
|
|
//=======================================================================
|
|
|
|
|
#ifndef COMMON_H
|
|
|
|
|
#define COMMON_H
|
|
|
|
|
|
|
|
|
|
#include <setjmp.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
2008-10-27 22:00:00 +01:00
|
|
|
|
#include "launch_api.h"
|
2008-11-25 22:00:00 +01:00
|
|
|
|
#include "qfiles_ref.h"
|
2008-11-09 22:00:00 +01:00
|
|
|
|
#include "engine_api.h"
|
2009-11-03 22:00:00 +01:00
|
|
|
|
#include "render_api.h"
|
2008-11-25 22:00:00 +01:00
|
|
|
|
#include "vsound_api.h"
|
2010-01-08 22:00:00 +01:00
|
|
|
|
#include "com_export.h"
|
2010-08-07 22:00:00 +02:00
|
|
|
|
#include "com_model.h"
|
2008-06-09 22:00:00 +02:00
|
|
|
|
#include "net_msg.h"
|
|
|
|
|
|
2010-06-20 22:00:00 +02:00
|
|
|
|
// PERFORMANCE INFO
|
|
|
|
|
#define MIN_FPS 0.1 // host minimum fps value for maxfps.
|
|
|
|
|
#define MAX_FPS 1000.0 // upper limit for maxfps.
|
|
|
|
|
|
|
|
|
|
#define MAX_FRAMETIME 0.1
|
|
|
|
|
#define MIN_FRAMETIME 0.001
|
|
|
|
|
|
2010-01-02 22:00:00 +01:00
|
|
|
|
#define MAX_RENDERS 8 // max libraries to keep tracking
|
2008-07-04 22:00:00 +02:00
|
|
|
|
#define MAX_ENTNUMBER 99999 // for server and client parsing
|
|
|
|
|
#define MAX_HEARTBEAT -99999 // connection time
|
2008-06-09 22:00:00 +02:00
|
|
|
|
|
2010-08-05 22:00:00 +02:00
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
void DBG_AssertFunction( BOOL fExpr, const char* szExpr, const char* szFile, int szLine, const char* szMessage );
|
|
|
|
|
#define Assert( f ) DBG_AssertFunction( f, #f, __FILE__, __LINE__, NULL )
|
|
|
|
|
#else
|
|
|
|
|
#define Assert( f )
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-12-20 22:00:00 +01:00
|
|
|
|
extern cvar_t *scr_width;
|
|
|
|
|
extern cvar_t *scr_height;
|
|
|
|
|
extern cvar_t *allow_download;
|
2010-07-17 22:00:00 +02:00
|
|
|
|
extern cvar_t *host_maxfps;
|
2008-06-09 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
==============================================================
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2008-06-09 22:00:00 +02:00
|
|
|
|
HOST INTERFACE
|
|
|
|
|
|
|
|
|
|
==============================================================
|
2007-06-21 22:00:00 +02:00
|
|
|
|
*/
|
2008-06-09 22:00:00 +02:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2008-06-12 22:00:00 +02:00
|
|
|
|
HOST_INIT = 0, // initalize operations
|
2008-06-09 22:00:00 +02:00
|
|
|
|
HOST_FRAME, // host running
|
|
|
|
|
HOST_SHUTDOWN, // shutdown operations
|
|
|
|
|
HOST_ERROR, // host stopped by error
|
|
|
|
|
HOST_SLEEP, // sleeped by different reason, e.g. minimize window
|
|
|
|
|
HOST_NOFOCUS, // same as HOST_FRAME, but disable mouse
|
2010-03-25 22:00:00 +01:00
|
|
|
|
HOST_RESTART, // during the changes video mode
|
|
|
|
|
HOST_CRASHED // an exception handler called
|
2008-06-09 22:00:00 +02:00
|
|
|
|
} host_state;
|
|
|
|
|
|
2008-07-12 22:00:00 +02:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
RD_NONE = 0,
|
|
|
|
|
RD_CLIENT,
|
2010-06-20 22:00:00 +02:00
|
|
|
|
RD_PACKET
|
2008-08-04 22:00:00 +02:00
|
|
|
|
} rdtype_t;
|
2008-07-12 22:00:00 +02:00
|
|
|
|
|
2010-08-15 22:00:00 +02:00
|
|
|
|
// game print level
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
PRINT_LOW, // pickup messages
|
|
|
|
|
PRINT_MEDIUM, // death messages
|
|
|
|
|
PRINT_HIGH, // critical messages
|
|
|
|
|
PRINT_CHAT, // chat messages
|
|
|
|
|
} messagelevel_t;
|
|
|
|
|
|
2008-06-09 22:00:00 +02:00
|
|
|
|
typedef struct host_redirect_s
|
|
|
|
|
{
|
2009-10-28 22:00:00 +01:00
|
|
|
|
rdtype_t target;
|
|
|
|
|
char *buffer;
|
|
|
|
|
int buffersize;
|
|
|
|
|
netadr_t address;
|
|
|
|
|
void (*flush)( netadr_t adr, rdtype_t target, char *buffer );
|
2008-06-09 22:00:00 +02:00
|
|
|
|
} host_redirect_t;
|
|
|
|
|
|
|
|
|
|
typedef struct host_parm_s
|
|
|
|
|
{
|
|
|
|
|
host_state state; // global host state
|
|
|
|
|
uint type; // running at
|
|
|
|
|
jmp_buf abortframe; // abort current frame
|
2008-11-04 22:00:00 +01:00
|
|
|
|
dword errorframe; // to avoid each-frame host error
|
2009-11-03 22:00:00 +01:00
|
|
|
|
byte *mempool; // static mempool for misc allocations
|
2008-06-09 22:00:00 +02:00
|
|
|
|
string finalmsg; // server shutdown final message
|
2010-06-20 22:00:00 +02:00
|
|
|
|
host_redirect_t rd; // remote console
|
|
|
|
|
|
2010-07-24 22:00:00 +02:00
|
|
|
|
int inputmsec; // time for buttons
|
2010-07-23 22:00:00 +02:00
|
|
|
|
int frametime; // time between engine frames
|
2009-09-20 22:00:00 +02:00
|
|
|
|
uint framecount; // global framecount
|
|
|
|
|
|
|
|
|
|
int events_head;
|
|
|
|
|
int events_tail;
|
|
|
|
|
sys_event_t events[MAX_EVENTS];
|
2009-09-16 22:00:00 +02:00
|
|
|
|
|
2008-07-11 22:00:00 +02:00
|
|
|
|
HWND hWnd; // main window
|
|
|
|
|
int developer; // show all developer's message
|
2010-06-20 22:00:00 +02:00
|
|
|
|
bool key_overstrike; // key overstrike mode
|
2010-07-01 22:00:00 +02:00
|
|
|
|
|
2010-07-18 22:00:00 +02:00
|
|
|
|
// renderers info
|
|
|
|
|
char *video_dlls[MAX_RENDERS];
|
|
|
|
|
char *audio_dlls[MAX_RENDERS];
|
|
|
|
|
int num_video_dlls;
|
|
|
|
|
int num_audio_dlls;
|
|
|
|
|
|
2010-07-01 22:00:00 +02:00
|
|
|
|
decallist_t *decalList; // used for keep decals, when renderer is restarted or changed
|
|
|
|
|
int numdecals;
|
2008-06-09 22:00:00 +02:00
|
|
|
|
} host_parm_t;
|
|
|
|
|
|
2009-11-02 22:00:00 +01:00
|
|
|
|
extern host_parm_t host;
|
2008-08-04 22:00:00 +02:00
|
|
|
|
|
2010-03-07 22:00:00 +01:00
|
|
|
|
//
|
|
|
|
|
// build.c
|
|
|
|
|
//
|
|
|
|
|
int com_buildnum( void );
|
|
|
|
|
|
2008-08-04 22:00:00 +02:00
|
|
|
|
//
|
|
|
|
|
// host.c
|
|
|
|
|
//
|
2010-07-23 22:00:00 +02:00
|
|
|
|
void Host_Init( const int argc, const char **argv );
|
|
|
|
|
void Host_Main( void );
|
|
|
|
|
void Host_Free( void );
|
2008-06-09 22:00:00 +02:00
|
|
|
|
void Host_SetServerState( int state );
|
|
|
|
|
int Host_ServerState( void );
|
2009-09-28 22:00:00 +02:00
|
|
|
|
int Host_CompareFileTime( long ft1, long ft2 );
|
2010-03-25 22:00:00 +01:00
|
|
|
|
bool Host_NewGame( const char *mapName, bool loadGame );
|
2009-10-16 22:00:00 +02:00
|
|
|
|
void Host_EndGame( const char *message, ... );
|
2008-06-09 22:00:00 +02:00
|
|
|
|
void Host_AbortCurrentFrame( void );
|
2010-07-30 22:00:00 +02:00
|
|
|
|
void Host_WriteServerConfig( const char *name );
|
|
|
|
|
void Host_WriteOpenGLConfig( void );
|
2009-09-10 22:00:00 +02:00
|
|
|
|
void Host_WriteConfig( void );
|
2010-07-24 22:00:00 +02:00
|
|
|
|
bool Host_IsLocalGame( void );
|
2009-10-13 22:00:00 +02:00
|
|
|
|
void Host_ShutdownServer( void );
|
2009-10-02 22:00:00 +02:00
|
|
|
|
void Host_CheckChanges( void );
|
2009-09-10 22:00:00 +02:00
|
|
|
|
void Host_Print( const char *txt );
|
2008-06-09 22:00:00 +02:00
|
|
|
|
void Host_Error( const char *error, ... );
|
2009-11-25 22:00:00 +01:00
|
|
|
|
void Host_Credits( void );
|
2008-06-09 22:00:00 +02:00
|
|
|
|
|
2007-06-21 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
==============================================================
|
|
|
|
|
|
2008-06-09 22:00:00 +02:00
|
|
|
|
CLIENT / SERVER SYSTEMS
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
==============================================================
|
|
|
|
|
*/
|
2008-06-09 22:00:00 +02:00
|
|
|
|
void CL_Init( void );
|
|
|
|
|
void CL_Shutdown( void );
|
2010-07-23 22:00:00 +02:00
|
|
|
|
void CL_Frame( int time );
|
2009-11-02 22:00:00 +01:00
|
|
|
|
bool CL_Active( void );
|
2008-06-09 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
void SV_Init( void );
|
|
|
|
|
void SV_Shutdown( bool reconnect );
|
2010-07-23 22:00:00 +02:00
|
|
|
|
void SV_Frame( int time );
|
2008-12-15 22:00:00 +01:00
|
|
|
|
bool SV_Active( void );
|
|
|
|
|
|
2008-06-09 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
==============================================================
|
|
|
|
|
|
2009-11-02 22:00:00 +01:00
|
|
|
|
SHARED ENGFUNCS
|
2008-06-09 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
==============================================================
|
|
|
|
|
*/
|
2009-01-22 22:00:00 +01:00
|
|
|
|
cvar_t *pfnCVarRegister( const char *szName, const char *szValue, int flags, const char *szDesc );
|
2009-11-10 22:00:00 +01:00
|
|
|
|
char *pfnMemFgets( byte *pMemFile, int fileSize, int *filePos, char *pBuffer, int bufferSize );
|
2009-01-02 22:00:00 +01:00
|
|
|
|
byte* pfnLoadFile( const char *filename, int *pLength );
|
2009-11-10 22:00:00 +01:00
|
|
|
|
char *pfnParseToken( const char **data_p );
|
2009-12-04 22:00:00 +01:00
|
|
|
|
void pfnCVarSetString( const char *szName, const char *szValue );
|
|
|
|
|
void pfnCVarSetValue( const char *szName, float flValue );
|
|
|
|
|
float pfnCVarGetValue( const char *szName );
|
|
|
|
|
char* pfnCVarGetString( const char *szName );
|
2010-08-15 22:00:00 +02:00
|
|
|
|
cvar_t *pfnCVarGetPointer( const char *szVarName );
|
2009-09-22 22:00:00 +02:00
|
|
|
|
void pfnFreeFile( void *buffer );
|
2009-01-02 22:00:00 +01:00
|
|
|
|
int pfnFileExists( const char *filename );
|
2009-11-23 22:00:00 +01:00
|
|
|
|
void *pfnLoadLibrary( const char *name );
|
|
|
|
|
void *pfnGetProcAddress( void *hInstance, const char *name );
|
|
|
|
|
void pfnFreeLibrary( void *hInstance );
|
2009-01-02 22:00:00 +01:00
|
|
|
|
long pfnRandomLong( long lLow, long lHigh );
|
|
|
|
|
float pfnRandomFloat( float flLow, float flHigh );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
void pfnAddCommand( const char *cmd_name, xcommand_t func, const char *cmd_desc );
|
|
|
|
|
void pfnDelCommand( const char *cmd_name );
|
2010-08-12 22:00:00 +02:00
|
|
|
|
void *Cache_Check( byte *mempool, cache_user_t *c );
|
2010-04-09 22:00:00 +02:00
|
|
|
|
void pfnGetGameDir( char *szGetGameDir );
|
2009-12-05 22:00:00 +01:00
|
|
|
|
const char *pfnCmd_Args( void );
|
|
|
|
|
const char *pfnCmd_Argv( int argc );
|
2010-08-15 22:00:00 +02:00
|
|
|
|
void pfnCon_DPrintf( char *fmt, ... );
|
|
|
|
|
void pfnCon_Printf( char *szFmt, ... );
|
2009-12-05 22:00:00 +01:00
|
|
|
|
int pfnCmd_Argc( void );
|
2010-04-21 22:00:00 +02:00
|
|
|
|
int pfnIsInGame( void );
|
2009-09-22 22:00:00 +02:00
|
|
|
|
float pfnTime( void );
|
2009-01-02 22:00:00 +01:00
|
|
|
|
|
2008-06-09 22:00:00 +02:00
|
|
|
|
/*
|
|
|
|
|
==============================================================
|
|
|
|
|
|
2009-11-02 22:00:00 +01:00
|
|
|
|
MISC COMMON FUNCTIONS
|
2008-06-09 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
==============================================================
|
|
|
|
|
*/
|
2008-07-23 22:00:00 +02:00
|
|
|
|
#define MAX_INFO_STRING 512
|
|
|
|
|
|
2009-11-03 22:00:00 +01:00
|
|
|
|
#define Z_Malloc(size) Mem_Alloc( host.mempool, size )
|
|
|
|
|
#define Z_Realloc( ptr, size ) Mem_Realloc( host.mempool, ptr, size )
|
2009-11-02 22:00:00 +01:00
|
|
|
|
#define Z_Free( ptr ) if( ptr ) Mem_Free( ptr )
|
2008-07-30 22:00:00 +02:00
|
|
|
|
|
2009-11-02 22:00:00 +01:00
|
|
|
|
//
|
2009-11-03 22:00:00 +01:00
|
|
|
|
// keys.c
|
2009-11-02 22:00:00 +01:00
|
|
|
|
//
|
2009-11-03 22:00:00 +01:00
|
|
|
|
bool Key_IsDown( int keynum );
|
2010-01-08 22:00:00 +01:00
|
|
|
|
const char *Key_IsBind( int keynum );
|
2010-07-24 22:00:00 +02:00
|
|
|
|
void Key_Event( int key, bool down, int time );
|
2009-11-03 22:00:00 +01:00
|
|
|
|
void Key_Init( void );
|
|
|
|
|
void Key_WriteBindings( file_t *f );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
const char *Key_GetBinding( int keynum );
|
|
|
|
|
void Key_SetBinding( int keynum, const char *binding );
|
2009-11-03 22:00:00 +01:00
|
|
|
|
void Key_ClearStates( void );
|
2010-01-08 22:00:00 +01:00
|
|
|
|
const char *Key_KeynumToString( int keynum );
|
2010-01-02 22:00:00 +01:00
|
|
|
|
int Key_StringToKeynum( const char *str );
|
2009-11-03 22:00:00 +01:00
|
|
|
|
int Key_GetKey( const char *binding );
|
|
|
|
|
void Key_EnumCmds_f( void );
|
|
|
|
|
void Key_SetKeyDest( int key_dest );
|
|
|
|
|
|
2009-11-23 22:00:00 +01:00
|
|
|
|
//
|
|
|
|
|
// cinematic.c
|
|
|
|
|
//
|
|
|
|
|
void CIN_Init( void );
|
|
|
|
|
void CIN_ReadChunk( cinematics_t *cin );
|
|
|
|
|
byte *CIN_ReadNextFrame( cinematics_t *cin, bool silent );
|
|
|
|
|
|
2009-12-20 22:00:00 +01:00
|
|
|
|
// shared calls
|
2010-03-25 22:00:00 +01:00
|
|
|
|
bool CL_IsInGame( void );
|
2010-07-01 22:00:00 +02:00
|
|
|
|
bool CL_IsInMenu( void );
|
2010-06-24 22:00:00 +02:00
|
|
|
|
float CL_GetServerTime( void );
|
2009-11-03 22:00:00 +01:00
|
|
|
|
float CL_GetLerpFrac( void );
|
|
|
|
|
void CL_CharEvent( int key );
|
2009-12-07 22:00:00 +01:00
|
|
|
|
void Tri_DrawTriangles( int fTrans );
|
2009-11-03 22:00:00 +01:00
|
|
|
|
int CL_PointContents( const vec3_t point );
|
2010-08-07 22:00:00 +02:00
|
|
|
|
void CL_StudioFxTransform( struct cl_entity_s *ent, float transform[4][4] );
|
2010-06-27 22:00:00 +02:00
|
|
|
|
void CL_GetEntitySpatialization( int entnum, vec3_t origin, vec3_t velocity );
|
2010-08-07 22:00:00 +02:00
|
|
|
|
void CL_StudioEvent( mstudioevent_t *event, struct cl_entity_s *ent );
|
2010-01-07 22:00:00 +01:00
|
|
|
|
bool CL_GetComment( const char *demoname, char *comment );
|
2010-08-12 22:00:00 +02:00
|
|
|
|
struct pmtrace_s *PM_TraceLine( float *start, float *end, int flags, int usehull, int ignore_pe );
|
2010-08-07 22:00:00 +02:00
|
|
|
|
struct cl_entity_s *CL_GetEntityByIndex( int index );
|
|
|
|
|
struct cl_entity_s *CL_GetLocalPlayer( void );
|
|
|
|
|
struct player_info_s *CL_GetPlayerInfo( int playerIndex );
|
2009-11-03 22:00:00 +01:00
|
|
|
|
int CL_GetMaxClients( void );
|
2010-06-20 22:00:00 +02:00
|
|
|
|
bool CL_IsPlaybackDemo( void );
|
2009-12-10 22:00:00 +01:00
|
|
|
|
bool SV_GetComment( const char *savename, char *comment );
|
2010-03-25 22:00:00 +01:00
|
|
|
|
bool SV_NewGame( const char *mapName, bool loadGame );
|
2010-08-15 22:00:00 +02:00
|
|
|
|
void SV_SysError( const char *error_string );
|
2010-07-22 22:00:00 +02:00
|
|
|
|
void SV_InitGameProgs( void );
|
2010-03-27 22:00:00 +01:00
|
|
|
|
void SV_ForceError( void );
|
|
|
|
|
void CL_WriteMessageHistory( void );
|
2009-02-03 22:00:00 +01:00
|
|
|
|
void CL_MouseEvent( int mx, int my );
|
2010-06-20 22:00:00 +02:00
|
|
|
|
void CL_SendCmd( void );
|
2009-11-03 22:00:00 +01:00
|
|
|
|
void CL_Disconnect( void );
|
|
|
|
|
bool CL_NextDemo( void );
|
2008-06-09 22:00:00 +02:00
|
|
|
|
void CL_Drop( void );
|
2009-11-03 22:00:00 +01:00
|
|
|
|
void CL_ForceVid( void );
|
|
|
|
|
void CL_ForceSnd( void );
|
|
|
|
|
void SCR_Init( void );
|
|
|
|
|
void SCR_UpdateScreen( void );
|
|
|
|
|
void SCR_Shutdown( void );
|
|
|
|
|
void Con_Print( const char *txt );
|
2009-11-10 22:00:00 +01:00
|
|
|
|
char *Info_ValueForKey( const char *s, const char *key );
|
2009-12-04 22:00:00 +01:00
|
|
|
|
void Info_RemovePrefixedKeys( char *start, char prefix );
|
2009-11-23 22:00:00 +01:00
|
|
|
|
bool Info_RemoveKey( char *s, const char *key );
|
|
|
|
|
bool Info_SetValueForKey( char *s, const char *key, const char *value );
|
|
|
|
|
bool Info_Validate( const char *s );
|
|
|
|
|
void Info_Print( const char *s );
|
2008-06-09 22:00:00 +02:00
|
|
|
|
char *Cvar_Userinfo( void );
|
|
|
|
|
char *Cvar_Serverinfo( void );
|
|
|
|
|
void Cmd_WriteVariables( file_t *f );
|
2010-07-18 22:00:00 +02:00
|
|
|
|
bool Cmd_CheckMapsList( bool fRefresh );
|
2010-02-02 22:00:00 +01:00
|
|
|
|
void Cmd_ForwardToServer( void );
|
2010-02-18 22:00:00 +01:00
|
|
|
|
void Cmd_AutoComplete( char *complete_string );
|
2008-06-09 22:00:00 +02:00
|
|
|
|
|
2008-08-03 22:00:00 +02:00
|
|
|
|
typedef struct autocomplete_list_s
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
bool (*func)( const char *s, char *name, int length );
|
|
|
|
|
} autocomplete_list_t;
|
2007-11-25 22:00:00 +01:00
|
|
|
|
|
2008-08-03 22:00:00 +02:00
|
|
|
|
extern autocomplete_list_t cmd_list[];
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
#endif//COMMON_H
|