2007-11-10 22:00:00 +01:00
|
|
|
|
//=======================================================================
|
|
|
|
|
// Copyright XashXT Group 2007 <20>
|
|
|
|
|
// launch.h - launch.dll main header
|
|
|
|
|
//=======================================================================
|
|
|
|
|
#ifndef LAUNCHER_H
|
|
|
|
|
#define LAUNCHER_H
|
|
|
|
|
|
2007-11-27 22:00:00 +01:00
|
|
|
|
#include <limits.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <direct.h>
|
|
|
|
|
#include <sys/stat.h>
|
2007-11-10 22:00:00 +01:00
|
|
|
|
#include <windows.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <io.h>
|
2007-11-27 22:00:00 +01:00
|
|
|
|
#include <time.h>
|
2007-11-10 22:00:00 +01:00
|
|
|
|
#include <winreg.h>
|
2008-10-27 22:00:00 +01:00
|
|
|
|
#include <math.h>
|
2007-11-10 22:00:00 +01:00
|
|
|
|
|
2008-10-27 22:00:00 +01:00
|
|
|
|
#define LAUNCH_DLL // ignore alias names
|
|
|
|
|
#include "launch_api.h"
|
2007-11-10 22:00:00 +01:00
|
|
|
|
|
2009-08-17 22:00:00 +02:00
|
|
|
|
#define XASH_VERSION 0.61f // current version will be shared across gameinfo struct
|
2007-11-10 22:00:00 +01:00
|
|
|
|
|
2008-07-23 22:00:00 +02:00
|
|
|
|
#define MAX_NUM_ARGVS 128
|
|
|
|
|
#define MAX_STRING_TOKENS 80
|
2008-08-04 22:00:00 +02:00
|
|
|
|
#define LOG_QUEUE_SIZE MAX_MSGLEN * 4 // 128 kb intermediate buffer
|
|
|
|
|
|
|
|
|
|
// just for last chanse to view message (debug only)
|
|
|
|
|
#define MSGBOX(x) MessageBox(NULL, x, "Xash Error", MB_OK|MB_SETFOREGROUND|MB_ICONSTOP );
|
2008-07-23 22:00:00 +02:00
|
|
|
|
|
2008-06-05 22:00:00 +02:00
|
|
|
|
enum state_e
|
|
|
|
|
{
|
|
|
|
|
SYS_SHUTDOWN = 0,
|
2008-08-04 22:00:00 +02:00
|
|
|
|
SYS_RESTART,
|
2008-06-05 22:00:00 +02:00
|
|
|
|
SYS_ABORT,
|
|
|
|
|
SYS_ERROR,
|
|
|
|
|
SYS_FRAME,
|
|
|
|
|
};
|
|
|
|
|
|
2007-11-10 22:00:00 +01:00
|
|
|
|
typedef struct system_s
|
|
|
|
|
{
|
2008-08-04 22:00:00 +02:00
|
|
|
|
char progname[64]; // instance keyword
|
|
|
|
|
char fmessage[64]; // shutdown final message
|
2007-11-10 22:00:00 +01:00
|
|
|
|
int app_name;
|
2008-06-05 22:00:00 +02:00
|
|
|
|
int app_state;
|
2007-11-10 22:00:00 +01:00
|
|
|
|
|
2008-08-04 22:00:00 +02:00
|
|
|
|
int developer;
|
|
|
|
|
int printlevel;
|
|
|
|
|
|
|
|
|
|
// log stuff
|
2007-11-10 22:00:00 +01:00
|
|
|
|
bool log_active;
|
|
|
|
|
char log_path[MAX_SYSPATH];
|
2008-08-04 22:00:00 +02:00
|
|
|
|
FILE *logfile;
|
|
|
|
|
|
2007-11-10 22:00:00 +01:00
|
|
|
|
bool hooked_out;
|
2007-11-25 22:00:00 +01:00
|
|
|
|
bool stuffcmdsrun;
|
2008-07-06 22:00:00 +02:00
|
|
|
|
byte packet_received[MAX_MSGLEN]; // network data
|
2008-07-31 22:00:00 +02:00
|
|
|
|
char ModuleName[4096]; // exe.filename
|
2007-11-10 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
HINSTANCE hInstance;
|
|
|
|
|
dll_info_t *linked_dll;
|
|
|
|
|
|
2008-08-04 22:00:00 +02:00
|
|
|
|
char caption[64];
|
2007-11-10 22:00:00 +01:00
|
|
|
|
bool con_readonly;
|
|
|
|
|
bool con_showalways;
|
|
|
|
|
bool con_showcredits;
|
|
|
|
|
bool con_silentmode;
|
|
|
|
|
byte *basepool;
|
2007-11-11 22:00:00 +01:00
|
|
|
|
byte *imagepool;
|
2008-10-29 22:00:00 +01:00
|
|
|
|
byte *scriptpool;
|
2007-11-14 22:00:00 +01:00
|
|
|
|
byte *stringpool;
|
2008-06-06 22:00:00 +02:00
|
|
|
|
bool shutdown_issued;
|
2008-06-05 22:00:00 +02:00
|
|
|
|
bool error;
|
2007-11-10 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
// simply profiling
|
|
|
|
|
double start, end;
|
|
|
|
|
|
|
|
|
|
void (*Con_Print)( const char *msg );
|
2008-07-30 22:00:00 +02:00
|
|
|
|
void ( *Init ) ( int argc, char **argv );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
void ( *Main ) ( void ); // host frame
|
|
|
|
|
void ( *Free ) ( void ); // close host
|
2008-07-11 22:00:00 +02:00
|
|
|
|
void (*CPrint)( const char *msg ); // console print
|
2007-11-10 22:00:00 +01:00
|
|
|
|
} system_t;
|
|
|
|
|
|
2008-08-04 22:00:00 +02:00
|
|
|
|
typedef struct timer_s
|
|
|
|
|
{
|
|
|
|
|
bool initialized; // any timer can be setup it
|
|
|
|
|
double oldtime;
|
|
|
|
|
double curtime;
|
|
|
|
|
dword timebase;
|
|
|
|
|
} timer_t;
|
|
|
|
|
|
2007-11-27 22:00:00 +01:00
|
|
|
|
typedef struct cvar_s
|
|
|
|
|
{
|
2008-11-04 22:00:00 +01:00
|
|
|
|
// shared part
|
2007-11-27 22:00:00 +01:00
|
|
|
|
char *name;
|
|
|
|
|
char *string; // normal string
|
|
|
|
|
float value; // atof( string )
|
|
|
|
|
int integer; // atoi( string )
|
|
|
|
|
bool modified; // set each time the cvar is changed
|
|
|
|
|
|
2008-11-04 22:00:00 +01:00
|
|
|
|
// private to launch.dll
|
2007-11-27 22:00:00 +01:00
|
|
|
|
char *reset_string; // cvar_restart will reset to this value
|
|
|
|
|
char *latched_string; // for CVAR_LATCH vars
|
|
|
|
|
char *description; // variable descrition info
|
|
|
|
|
uint flags; // state flags
|
|
|
|
|
uint modificationCount; // incremented each time the cvar is changed
|
|
|
|
|
|
|
|
|
|
struct cvar_s *next;
|
|
|
|
|
struct cvar_s *hash;
|
|
|
|
|
};
|
|
|
|
|
|
2007-11-11 22:00:00 +01:00
|
|
|
|
extern system_t Sys;
|
2008-08-04 22:00:00 +02:00
|
|
|
|
extern timer_t Msec;
|
2007-11-10 22:00:00 +01:00
|
|
|
|
extern gameinfo_t GI;
|
2007-11-30 22:00:00 +01:00
|
|
|
|
extern stdlib_api_t com;
|
2007-11-10 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// console.c
|
|
|
|
|
//
|
|
|
|
|
void Con_ShowConsole( bool show );
|
|
|
|
|
void Con_PrintA(const char *pMsg);
|
|
|
|
|
void Con_PrintW(const char *pMsg);
|
|
|
|
|
void Con_CreateConsole( void );
|
|
|
|
|
void Con_DestroyConsole( void );
|
|
|
|
|
char *Sys_Input( void );
|
|
|
|
|
void Con_RegisterHotkeys( void );
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// system.c
|
|
|
|
|
//
|
|
|
|
|
void Sys_InitCPU( void );
|
|
|
|
|
gameinfo_t Sys_GameInfo( void );
|
|
|
|
|
void Sys_ParseCommandLine (LPSTR lpCmdLine);
|
|
|
|
|
void Sys_LookupInstance( void );
|
2008-08-04 22:00:00 +02:00
|
|
|
|
void Sys_NewInstance( const char *name, const char *fmsg );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
double Sys_DoubleTime( void );
|
2008-07-03 22:00:00 +02:00
|
|
|
|
dword Sys_Milliseconds( void );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
char *Sys_GetClipboardData( void );
|
2008-07-12 22:00:00 +02:00
|
|
|
|
char *Sys_GetCurrentUser( void );
|
2008-07-31 22:00:00 +02:00
|
|
|
|
bool Sys_GetModuleName( char *buffer, size_t length );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
void Sys_Sleep( int msec );
|
|
|
|
|
void Sys_Init( void );
|
|
|
|
|
void Sys_Exit( void );
|
2008-06-05 22:00:00 +02:00
|
|
|
|
void Sys_Abort( void );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
bool Sys_LoadLibrary ( dll_info_t *dll );
|
|
|
|
|
void* Sys_GetProcAddress ( dll_info_t *dll, const char* name );
|
2008-07-24 22:00:00 +02:00
|
|
|
|
byte *Sys_LoadRes( const char *filename, size_t *size );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
bool Sys_FreeLibrary ( dll_info_t *dll );
|
|
|
|
|
void Sys_WaitForQuit( void );
|
|
|
|
|
void Sys_InitLog( void );
|
|
|
|
|
void Sys_CloseLog( void );
|
2007-11-14 22:00:00 +01:00
|
|
|
|
void Sys_Error(const char *error, ...);
|
2007-11-25 22:00:00 +01:00
|
|
|
|
void Sys_Break(const char *error, ...);
|
2007-11-10 22:00:00 +01:00
|
|
|
|
void Sys_PrintLog( const char *pMsg );
|
|
|
|
|
void Sys_Print(const char *pMsg);
|
|
|
|
|
void Sys_Msg( const char *pMsg, ... );
|
|
|
|
|
void Sys_MsgDev( int level, const char *pMsg, ... );
|
2008-07-06 22:00:00 +02:00
|
|
|
|
sys_event_t Sys_GetEvent( void );
|
2009-02-03 22:00:00 +01:00
|
|
|
|
void Sys_QueEvent( ev_type_t type, int value, int value2, int length, void *ptr );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
int Sys_GetThreadWork( void );
|
2009-02-03 22:00:00 +01:00
|
|
|
|
void Sys_ThreadWorkerFunction( int threadnum );
|
|
|
|
|
void Sys_ThreadSetDefault( void );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
void Sys_ThreadLock( void );
|
|
|
|
|
void Sys_ThreadUnlock( void );
|
|
|
|
|
int Sys_GetNumThreads( void );
|
2009-02-03 22:00:00 +01:00
|
|
|
|
void Sys_RunThreadsOnIndividual( int workcnt, bool showpacifier, void(*func)(int));
|
|
|
|
|
void Sys_RunThreadsOn( int workcnt, bool showpacifier, void(*func)(int));
|
2007-11-10 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
#define Msg Sys_Msg
|
|
|
|
|
#define MsgDev Sys_MsgDev
|
|
|
|
|
|
|
|
|
|
// registry common tools
|
|
|
|
|
bool REG_GetValue( HKEY hKey, const char *SubKey, const char *Value, char *pBuffer);
|
|
|
|
|
bool REG_SetValue( HKEY hKey, const char *SubKey, const char *Value, char *pBuffer);
|
|
|
|
|
|
2008-07-06 22:00:00 +02:00
|
|
|
|
//
|
|
|
|
|
// network.c
|
|
|
|
|
//
|
|
|
|
|
void NET_Init( void );
|
|
|
|
|
void NET_Shutdown( void );
|
2009-06-24 22:00:00 +02:00
|
|
|
|
void NET_Sleep( uint msec );
|
2008-07-06 22:00:00 +02:00
|
|
|
|
void NET_Config( bool net_enable );
|
2009-06-22 22:00:00 +02:00
|
|
|
|
bool NET_IsLocalAddress( netadr_t adr );
|
|
|
|
|
char *NET_AdrToString( const netadr_t a );
|
|
|
|
|
char *NET_BaseAdrToString( const netadr_t a );
|
|
|
|
|
bool NET_StringToAdr( const char *string, netadr_t *adr );
|
|
|
|
|
bool NET_CompareAdr( const netadr_t a, const netadr_t b );
|
|
|
|
|
bool NET_CompareBaseAdr( const netadr_t a, const netadr_t b );
|
|
|
|
|
bool NET_GetPacket( netsrc_t sock, netadr_t *from, sizebuf_t *msg );
|
|
|
|
|
void NET_SendPacket( netsrc_t sock, size_t length, const void *data, netadr_t to );
|
2008-07-06 22:00:00 +02:00
|
|
|
|
|
2007-11-10 22:00:00 +01:00
|
|
|
|
//
|
|
|
|
|
// stdlib.c
|
|
|
|
|
//
|
|
|
|
|
void com_strnupr(const char *in, char *out, size_t size_out);
|
|
|
|
|
void com_strupr(const char *in, char *out);
|
|
|
|
|
void com_strnlwr(const char *in, char *out, size_t size_out);
|
|
|
|
|
void com_strlwr(const char *in, char *out);
|
|
|
|
|
int com_strlen( const char *string );
|
|
|
|
|
int com_cstrlen( const char *string );
|
|
|
|
|
char com_toupper(const char in );
|
|
|
|
|
char com_tolower(const char in );
|
|
|
|
|
size_t com_strncat(char *dst, const char *src, size_t siz);
|
|
|
|
|
size_t com_strcat(char *dst, const char *src );
|
|
|
|
|
size_t com_strncpy(char *dst, const char *src, size_t siz);
|
|
|
|
|
size_t com_strcpy(char *dst, const char *src );
|
2008-07-26 22:00:00 +02:00
|
|
|
|
char *com_stralloc(byte *mempool, const char *s, const char *filename, int fileline);
|
2009-07-12 22:00:00 +02:00
|
|
|
|
bool com_isdigit( const char *str );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
int com_atoi(const char *str);
|
|
|
|
|
float com_atof(const char *str);
|
|
|
|
|
void com_atov( float *vec, const char *str, size_t siz );
|
|
|
|
|
char *com_strchr(const char *s, char c);
|
|
|
|
|
char *com_strrchr(const char *s, char c);
|
|
|
|
|
int com_strnicmp(const char *s1, const char *s2, int n);
|
|
|
|
|
int com_stricmp(const char *s1, const char *s2);
|
|
|
|
|
int com_strncmp (const char *s1, const char *s2, int n);
|
|
|
|
|
int com_strcmp (const char *s1, const char *s2);
|
2009-08-05 22:00:00 +02:00
|
|
|
|
bool com_stricmpext( const char *s1, const char *s2 );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
const char* com_timestamp( int format );
|
|
|
|
|
char *com_stristr( const char *string, const char *string2 );
|
2008-07-31 22:00:00 +02:00
|
|
|
|
char *com_strstr( const char *string, const char *string2 );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
size_t com_strpack( byte *buffer, size_t pos, char *string, int n );
|
|
|
|
|
size_t com_strunpack( byte *buffer, size_t pos, char *string );
|
|
|
|
|
int com_vsnprintf(char *buffer, size_t buffersize, const char *format, va_list args);
|
|
|
|
|
int com_vsprintf(char *buffer, const char *format, va_list args);
|
|
|
|
|
int com_snprintf(char *buffer, size_t buffersize, const char *format, ...);
|
|
|
|
|
int com_sprintf(char *buffer, const char *format, ...);
|
2007-11-14 22:00:00 +01:00
|
|
|
|
char *com_pretifymem( float value, int digitsafterdecimal );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
char *va(const char *format, ...);
|
2008-07-26 22:00:00 +02:00
|
|
|
|
#define copystring( str ) com_stralloc( NULL, str, __FILE__, __LINE__)
|
2008-10-29 22:00:00 +01:00
|
|
|
|
#define copystring2( pool, str ) com_stralloc( pool, str, __FILE__, __LINE__)
|
2007-11-25 22:00:00 +01:00
|
|
|
|
|
2008-06-14 22:00:00 +02:00
|
|
|
|
//
|
2008-11-18 22:00:00 +01:00
|
|
|
|
// utils.c
|
2008-06-14 22:00:00 +02:00
|
|
|
|
//
|
|
|
|
|
long Com_RandomLong( long lMin, long lMax );
|
|
|
|
|
float Com_RandomFloat( float fMin, float fMax );
|
2008-11-18 22:00:00 +01:00
|
|
|
|
uint Com_HashKey( const char *string, uint hashSize );
|
2008-06-14 22:00:00 +02:00
|
|
|
|
|
2008-10-27 22:00:00 +01:00
|
|
|
|
//
|
|
|
|
|
// math.c
|
|
|
|
|
//
|
|
|
|
|
void Com_BuildSqrtTable( void );
|
|
|
|
|
void Com_BuildSinCosTable( void );
|
|
|
|
|
|
|
|
|
|
float com_sqrt( float x );
|
|
|
|
|
float amd_sqrt( float x );
|
|
|
|
|
float sse_sqrt( float x );
|
|
|
|
|
|
|
|
|
|
_inline float sqrtf( float x ) { return ((float)sqrt((double)x)); }
|
|
|
|
|
_inline float sinf( float x ) { return ((float)sin((double)x)); }
|
|
|
|
|
_inline float asinf( float x ) { return ((float)asin((double)x)); }
|
|
|
|
|
_inline float cosf( float x ) { return ((float)cos((double)x)); }
|
|
|
|
|
_inline float acosf( float x ) { return ((float)acos((double)x)); }
|
|
|
|
|
_inline float tanf( float x ) { return ((float)tan((double)x)); }
|
|
|
|
|
_inline float atan2f( float x, float y ) { return ((float)atan2((double)x,(double)y)); }
|
|
|
|
|
void SinCos( float radians, float *sine, float *cosine );
|
|
|
|
|
|
2007-11-10 22:00:00 +01:00
|
|
|
|
//
|
|
|
|
|
// memlib.c
|
|
|
|
|
//
|
|
|
|
|
void Memory_Init( void );
|
|
|
|
|
void Memory_Shutdown( void );
|
2007-12-17 22:00:00 +01:00
|
|
|
|
void Memory_Init_Commands( void );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
void _mem_move(byte *poolptr, void **dest, void *src, size_t size, const char *filename, int fileline);
|
|
|
|
|
void *_mem_realloc(byte *poolptr, void *memptr, size_t size, const char *filename, int fileline);
|
2008-10-27 22:00:00 +01:00
|
|
|
|
void _com_mem_copy(void *dest, const void *src, size_t size, const char *filename, int fileline);
|
|
|
|
|
void _crt_mem_copy(void *dest, const void *src, size_t size, const char *filename, int fileline);
|
|
|
|
|
void _asm_mem_copy(void *dest, const void *src, size_t size, const char *filename, int fileline);
|
|
|
|
|
void _mmx_mem_copy(void *dest, const void *src, size_t size, const char *filename, int fileline);
|
|
|
|
|
void _amd_mem_copy(void *dest, const void *src, size_t size, const char *filename, int fileline);
|
|
|
|
|
void _com_mem_set(void *dest, int set, size_t size, const char *filename, int fileline);
|
|
|
|
|
void _crt_mem_set(void *dest, int set, size_t size, const char *filename, int fileline);
|
|
|
|
|
void _asm_mem_set(void* dest, int set, size_t size, const char *filename, int fileline);
|
|
|
|
|
void _mmx_mem_set(void* dest, int set, size_t size, const char *filename, int fileline);
|
2007-11-10 22:00:00 +01:00
|
|
|
|
void *_mem_alloc(byte *poolptr, size_t size, const char *filename, int fileline);
|
|
|
|
|
byte *_mem_allocpool(const char *name, const char *filename, int fileline);
|
|
|
|
|
void _mem_freepool(byte **poolptr, const char *filename, int fileline);
|
|
|
|
|
void _mem_emptypool(byte *poolptr, const char *filename, int fileline);
|
|
|
|
|
void _mem_free(void *data, const char *filename, int fileline);
|
2007-12-17 22:00:00 +01:00
|
|
|
|
byte *_mem_alloc_array( byte *poolptr, size_t recordsize, int count, const char *filename, int fileline );
|
|
|
|
|
void _mem_free_array( byte *arrayptr, const char *filename, int fileline );
|
|
|
|
|
void *_mem_alloc_array_element( byte *arrayptr, const char *filename, int fileline );
|
|
|
|
|
void _mem_free_array_element( byte *arrayptr, void *element, const char *filename, int fileline );
|
|
|
|
|
void *_mem_get_array_element( byte *arrayptr, size_t index );
|
|
|
|
|
size_t _mem_array_size( byte *arrayptr );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
void _mem_check(const char *filename, int fileline);
|
2007-12-17 22:00:00 +01:00
|
|
|
|
bool _is_allocated( byte *poolptr, void *data );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
#define Mem_Alloc(pool, size) _mem_alloc(pool, size, __FILE__, __LINE__)
|
|
|
|
|
#define Mem_Realloc(pool, ptr, size) _mem_realloc(pool, ptr, size, __FILE__, __LINE__)
|
|
|
|
|
#define Mem_Free(mem) _mem_free(mem, __FILE__, __LINE__)
|
|
|
|
|
#define Mem_AllocPool(name) _mem_allocpool(name, __FILE__, __LINE__)
|
|
|
|
|
#define Mem_FreePool(pool) _mem_freepool(pool, __FILE__, __LINE__)
|
|
|
|
|
#define Mem_EmptyPool(pool) _mem_emptypool(pool, __FILE__, __LINE__)
|
2007-11-11 22:00:00 +01:00
|
|
|
|
#define Mem_Move(pool, dest, src, size ) _mem_move(pool, dest, src, size, __FILE__, __LINE__)
|
2008-10-27 22:00:00 +01:00
|
|
|
|
#define Mem_Copy(dest, src, size ) com.memcpy(dest, src, size, __FILE__, __LINE__)
|
|
|
|
|
#define Mem_Set(dest, val, size ) com.memset(dest, val, size, __FILE__, __LINE__)
|
2007-12-17 22:00:00 +01:00
|
|
|
|
#define Mem_CreateArray( p, s, n ) _mem_alloc_array( p, s, n, __FILE__, __LINE__)
|
|
|
|
|
#define Mem_RemoveArray( array ) _mem_free_array( array, __FILE__, __LINE__)
|
|
|
|
|
#define Mem_AllocElement( array ) _mem_alloc_array_element( array, __FILE__, __LINE__)
|
|
|
|
|
#define Mem_FreeElement( array, el ) _mem_free_array_element( array, el, __FILE__, __LINE__ )
|
|
|
|
|
#define Mem_GetElement( array, idx ) _mem_get_array_element( array, idx )
|
|
|
|
|
#define Mem_ArraySize( array ) _mem_array_size( array )
|
|
|
|
|
#define Mem_IsAllocated( mem ) _is_allocated( NULL, mem )
|
2007-11-10 22:00:00 +01:00
|
|
|
|
#define Mem_Check() _mem_check(__FILE__, __LINE__)
|
2007-11-14 22:00:00 +01:00
|
|
|
|
#define Mem_Pretify( x ) com_pretifymem(x, 3)
|
|
|
|
|
#define Malloc( size ) Mem_Alloc( Sys.basepool, size )
|
2007-11-10 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// filesystem.c
|
|
|
|
|
//
|
|
|
|
|
void FS_Init( void );
|
|
|
|
|
void FS_Path( void );
|
|
|
|
|
void FS_Shutdown( void );
|
|
|
|
|
void FS_InitEditor( void );
|
|
|
|
|
void FS_InitRootDir( char *path );
|
2009-01-21 22:00:00 +01:00
|
|
|
|
void FS_ClearSearchPath( void );
|
|
|
|
|
void FS_AllowDirectPaths( bool enable );
|
2009-08-29 22:00:00 +02:00
|
|
|
|
void FS_AddGameHierarchy( const char *dir, int flags );
|
2009-01-21 22:00:00 +01:00
|
|
|
|
int FS_CheckParm( const char *parm );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
void FS_LoadGameInfo( const char *filename );
|
2009-01-21 22:00:00 +01:00
|
|
|
|
void FS_FileBase( const char *in, char *out );
|
|
|
|
|
const char *FS_FileExtension( const char *in );
|
|
|
|
|
void FS_DefaultExtension( char *path, const char *extension );
|
2008-11-22 22:00:00 +01:00
|
|
|
|
bool FS_GetParmFromCmdLine( char *parm, char *out, size_t size );
|
2009-01-21 22:00:00 +01:00
|
|
|
|
void FS_ExtractFilePath( const char* const path, char* dest );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
void FS_UpdateEnvironmentVariables( void );
|
2008-08-08 22:00:00 +02:00
|
|
|
|
const char *FS_FileWithoutPath( const char *in );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
extern char sys_rootdir[];
|
|
|
|
|
extern char *fs_argv[];
|
|
|
|
|
extern int fs_argc;
|
|
|
|
|
|
2008-08-13 22:00:00 +02:00
|
|
|
|
// wadsystem.c
|
|
|
|
|
wfile_t *W_Open( const char *filename, const char *mode );
|
2008-08-14 22:00:00 +02:00
|
|
|
|
byte *W_LoadLump( wfile_t *wad, const char *lumpname, size_t *lumpsizeptr, const char type );
|
|
|
|
|
fs_offset_t W_SaveLump( wfile_t *wad, const char *lump, const void* data, size_t datasize, char type, char cmp );
|
2008-08-15 22:00:00 +02:00
|
|
|
|
int W_Check( const char *filename );
|
2008-08-13 22:00:00 +02:00
|
|
|
|
void W_Close( wfile_t *wad );
|
|
|
|
|
|
2007-11-10 22:00:00 +01:00
|
|
|
|
// simply files managment interface
|
|
|
|
|
byte *FS_LoadFile (const char *path, fs_offset_t *filesizeptr );
|
2008-06-21 22:00:00 +02:00
|
|
|
|
bool FS_WriteFile (const char *filename, const void *data, fs_offset_t len);
|
2008-10-19 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
rgbdata_t *FS_LoadImage( const char *name, const byte *buffer, size_t size );
|
2009-08-01 22:00:00 +02:00
|
|
|
|
bool Image_Process( rgbdata_t **pix, int w, int h, uint flags );
|
2008-10-25 22:00:00 +02:00
|
|
|
|
bool FS_SaveImage( const char *name, rgbdata_t *image );
|
2008-10-22 22:00:00 +02:00
|
|
|
|
bpc_desc_t *Image_GetPixelFormat( pixformat_t type );
|
2007-11-11 22:00:00 +01:00
|
|
|
|
void FS_FreeImage( rgbdata_t *pack );
|
2008-10-19 22:00:00 +02:00
|
|
|
|
|
2007-11-10 22:00:00 +01:00
|
|
|
|
search_t *FS_Search(const char *pattern, int caseinsensitive );
|
|
|
|
|
search_t *FS_SearchDirs(const char *pattern, int caseinsensitive );
|
|
|
|
|
|
|
|
|
|
// files managment (like fopen, fread etc)
|
2008-07-23 22:00:00 +02:00
|
|
|
|
file_t *FS_Open( const char* filepath, const char* mode );
|
|
|
|
|
file_t* _FS_Open( const char* filepath, const char* mode, bool quiet );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
fs_offset_t FS_Write (file_t* file, const void* data, size_t datasize);
|
|
|
|
|
fs_offset_t FS_Read (file_t* file, void* buffer, size_t buffersize);
|
|
|
|
|
int FS_VPrintf(file_t* file, const char* format, va_list ap);
|
|
|
|
|
int FS_Seek (file_t* file, fs_offset_t offset, int whence);
|
|
|
|
|
int FS_Gets (file_t* file, byte *string, size_t bufsize );
|
|
|
|
|
int FS_Printf(file_t* file, const char* format, ...);
|
|
|
|
|
fs_offset_t FS_FileSize (const char *filename);
|
2008-06-07 22:00:00 +02:00
|
|
|
|
fs_offset_t FS_FileTime (const char *filename);
|
2007-11-10 22:00:00 +01:00
|
|
|
|
int FS_Print(file_t* file, const char *msg);
|
|
|
|
|
bool FS_FileExists (const char *filename);
|
2008-09-10 22:00:00 +02:00
|
|
|
|
bool FS_Remove( const char *path );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
int FS_UnGetc (file_t* file, byte c);
|
|
|
|
|
void FS_StripExtension (char *path);
|
2009-07-12 22:00:00 +02:00
|
|
|
|
fs_offset_t FS_Tell( file_t* file );
|
|
|
|
|
bool FS_Eof( file_t* file );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
void FS_Purge (file_t* file);
|
|
|
|
|
int FS_Close (file_t* file);
|
|
|
|
|
int FS_Getc (file_t* file);
|
|
|
|
|
bool FS_Eof( file_t* file);
|
|
|
|
|
|
2007-11-25 22:00:00 +01:00
|
|
|
|
//
|
|
|
|
|
// cvar.c
|
|
|
|
|
//
|
|
|
|
|
cvar_t *Cvar_FindVar (const char *var_name);
|
|
|
|
|
cvar_t *Cvar_Get (const char *var_name, const char *value, int flags, const char *description);
|
|
|
|
|
void Cvar_Set( const char *var_name, const char *value);
|
2008-06-05 22:00:00 +02:00
|
|
|
|
cvar_t *Cvar_Set2( const char *var_name, const char *value, bool force );
|
2008-08-15 22:00:00 +02:00
|
|
|
|
void Cvar_LookupVars( int checkbit, void *buffer, void *ptr, setpair_t callback );
|
2007-11-25 22:00:00 +01:00
|
|
|
|
void Cvar_FullSet (char *var_name, char *value, int flags);
|
|
|
|
|
void Cvar_SetLatched( const char *var_name, const char *value);
|
|
|
|
|
void Cvar_SetValue( const char *var_name, float value);
|
|
|
|
|
float Cvar_VariableValue (const char *var_name);
|
|
|
|
|
char *Cvar_VariableString (const char *var_name);
|
|
|
|
|
bool Cvar_Command (void);
|
|
|
|
|
void Cvar_WriteVariables( file_t *f );
|
|
|
|
|
void Cvar_Init (void);
|
|
|
|
|
char *Cvar_Userinfo (void);
|
|
|
|
|
char *Cvar_Serverinfo (void);
|
|
|
|
|
extern bool userinfo_modified;
|
|
|
|
|
char *Info_ValueForKey( char *s, char *key );
|
|
|
|
|
void Info_RemoveKey( char *s, char *key );
|
|
|
|
|
void Info_SetValueForKey( char *s, char *key, char *value );
|
|
|
|
|
bool Info_Validate( char *s );
|
|
|
|
|
void Info_Print( char *s );
|
|
|
|
|
extern cvar_t *cvar_vars;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// cmd.c
|
|
|
|
|
//
|
|
|
|
|
void Cbuf_Init( void );
|
|
|
|
|
void Cbuf_AddText (const char *text);
|
|
|
|
|
void Cbuf_InsertText (const char *text);
|
|
|
|
|
void Cbuf_ExecuteText (int exec_when, const char *text);
|
|
|
|
|
void Cbuf_Execute (void);
|
|
|
|
|
uint Cmd_Argc( void );
|
|
|
|
|
char *Cmd_Args( void );
|
|
|
|
|
char *Cmd_Argv( uint arg );
|
|
|
|
|
void Cmd_Init( void );
|
|
|
|
|
void Cmd_AddCommand(const char *cmd_name, xcommand_t function, const char *cmd_desc);
|
|
|
|
|
void Cmd_RemoveCommand(const char *cmd_name);
|
|
|
|
|
bool Cmd_Exists (const char *cmd_name);
|
2008-08-15 22:00:00 +02:00
|
|
|
|
void Cmd_LookupCmds( char *buffer, void *ptr, setpair_t callback );
|
2007-11-25 22:00:00 +01:00
|
|
|
|
bool Cmd_GetMapList( const char *s, char *completedname, int length );
|
|
|
|
|
bool Cmd_GetDemoList( const char *s, char *completedname, int length );
|
|
|
|
|
bool Cmd_GetMovieList (const char *s, char *completedname, int length );
|
|
|
|
|
void Cmd_TokenizeString (const char *text);
|
|
|
|
|
void Cmd_ExecuteString (const char *text);
|
|
|
|
|
void Cmd_ForwardToServer (void);
|
|
|
|
|
|
2007-11-10 22:00:00 +01:00
|
|
|
|
// virtual files managment
|
2008-08-06 22:00:00 +02:00
|
|
|
|
vfile_t *VFS_Create( const byte *buffer, size_t buffsize );
|
2007-11-18 22:00:00 +01:00
|
|
|
|
vfile_t *VFS_Open(file_t *handle, const char* mode);
|
2007-11-10 22:00:00 +01:00
|
|
|
|
fs_offset_t VFS_Write( vfile_t *file, const void *buf, size_t size );
|
2008-08-06 22:00:00 +02:00
|
|
|
|
fs_offset_t VFS_Read( vfile_t* file, void* buffer, size_t buffersize);
|
2007-11-18 22:00:00 +01:00
|
|
|
|
int VFS_Print(vfile_t* file, const char *msg);
|
|
|
|
|
int VFS_Printf(vfile_t* file, const char* format, ...);
|
2007-11-10 22:00:00 +01:00
|
|
|
|
int VFS_Seek( vfile_t *file, fs_offset_t offset, int whence );
|
2007-11-21 22:00:00 +01:00
|
|
|
|
int VFS_Gets(vfile_t* file, byte *string, size_t bufsize );
|
2007-11-11 22:00:00 +01:00
|
|
|
|
bool VFS_Unpack( void* compbuf, size_t compsize, void **buf, size_t size );
|
2008-08-15 22:00:00 +02:00
|
|
|
|
byte *VFS_GetBuffer( vfile_t *file );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
fs_offset_t VFS_Tell (vfile_t* file);
|
2007-11-18 22:00:00 +01:00
|
|
|
|
file_t *VFS_Close( vfile_t *file );
|
2008-01-05 22:00:00 +01:00
|
|
|
|
bool VFS_Eof( vfile_t* file);
|
2007-11-10 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// crclib.c
|
|
|
|
|
//
|
|
|
|
|
void CRC_Init(word *crcvalue);
|
|
|
|
|
word CRC_Block (byte *start, int count);
|
|
|
|
|
void CRC_ProcessByte(word *crcvalue, byte data);
|
|
|
|
|
byte CRC_BlockSequence(byte *base, int length, int sequence);
|
2007-11-24 22:00:00 +01:00
|
|
|
|
uint Com_BlockChecksum (void *buffer, int length);
|
|
|
|
|
uint Com_BlockChecksumKey(void *buffer, int length, int key);
|
2007-11-10 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// parselib.c
|
|
|
|
|
//
|
2008-11-18 22:00:00 +01:00
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
uint type;
|
|
|
|
|
} punctuation_t;
|
|
|
|
|
|
|
|
|
|
typedef struct script_s
|
|
|
|
|
{
|
|
|
|
|
// shared part of script
|
|
|
|
|
char *buffer;
|
|
|
|
|
char *text;
|
|
|
|
|
size_t size;
|
|
|
|
|
char TXcommand; // (quark .map comment)
|
|
|
|
|
|
|
|
|
|
// private part of script
|
|
|
|
|
string name;
|
|
|
|
|
int line;
|
|
|
|
|
bool allocated;
|
|
|
|
|
punctuation_t *punctuations;
|
|
|
|
|
bool tokenAvailable;
|
|
|
|
|
token_t token;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool PS_ReadToken( script_t *script, scFlags_t flags, token_t *token );
|
|
|
|
|
void PS_SaveToken( script_t *script, token_t *token );
|
|
|
|
|
bool PS_GetString( script_t *script, int flags, char *value, size_t size );
|
|
|
|
|
bool PS_GetDouble( script_t *script, int flags, double *value );
|
|
|
|
|
bool PS_GetFloat( script_t *script, int flags, float *value );
|
|
|
|
|
bool PS_GetUnsigned( script_t *script, int flags, uint *value );
|
|
|
|
|
bool PS_GetInteger( script_t *script, int flags, int *value );
|
|
|
|
|
|
|
|
|
|
void PS_SkipWhiteSpace( script_t *script );
|
|
|
|
|
void PS_SkipRestOfLine( script_t *script );
|
|
|
|
|
void PS_SkipBracedSection( script_t *script, int depth );
|
|
|
|
|
|
|
|
|
|
void PS_ScriptError( script_t *script, scFlags_t flags, const char *fmt, ... );
|
|
|
|
|
void PS_ScriptWarning( script_t *script, scFlags_t flags, const char *fmt, ... );
|
|
|
|
|
|
|
|
|
|
bool PS_MatchToken( token_t *token, const char *keyword );
|
|
|
|
|
void PS_SetPunctuationsTable( script_t *script, punctuation_t *punctuationsTable );
|
|
|
|
|
void PS_ResetScript( script_t *script );
|
|
|
|
|
bool PS_EndOfScript( script_t *script );
|
|
|
|
|
|
|
|
|
|
script_t *PS_LoadScript( const char *filename, const char *buf, size_t size );
|
|
|
|
|
void PS_FreeScript( script_t *script );
|
2007-11-10 22:00:00 +01:00
|
|
|
|
|
2009-07-12 22:00:00 +02:00
|
|
|
|
//
|
|
|
|
|
// parselib.c
|
|
|
|
|
//
|
|
|
|
|
void Patch_Evaluate( const float *p, int *numcp, const int *tess, float *dest, int comp );
|
|
|
|
|
void Patch_GetFlatness( float maxflat, const float *points, int comp, const int *patch_cp, int *flat );
|
|
|
|
|
|
2007-12-17 22:00:00 +01:00
|
|
|
|
//
|
|
|
|
|
// imglib.c
|
|
|
|
|
//
|
|
|
|
|
void Image_Init( void );
|
2008-10-19 22:00:00 +02:00
|
|
|
|
void Image_Setup( const char *formats, const uint flags );
|
2007-12-17 22:00:00 +01:00
|
|
|
|
void Image_Shutdown( void );
|
|
|
|
|
|
2008-08-15 22:00:00 +02:00
|
|
|
|
//
|
|
|
|
|
// stringtable.c
|
|
|
|
|
//
|
|
|
|
|
int StringTable_CreateNewSystem( const char *name, size_t max_strings );
|
|
|
|
|
string_t StringTable_SetString( int handle, const char *string );
|
|
|
|
|
const char *StringTable_GetString( int handle, string_t index );
|
|
|
|
|
int StringTable_LoadSystem( wfile_t *wad, const char *name );
|
|
|
|
|
bool StringTable_SaveSystem( int h, wfile_t *wad );
|
2009-01-04 22:00:00 +01:00
|
|
|
|
const char *StringTable_GetName( int handle );
|
2008-08-15 22:00:00 +02:00
|
|
|
|
void StringTable_DeleteSystem( int handle );
|
2009-01-02 22:00:00 +01:00
|
|
|
|
void StringTable_ClearSystem( int handle );
|
|
|
|
|
void StringTable_Info_f( void );
|
2008-08-15 22:00:00 +02:00
|
|
|
|
|
2007-11-10 22:00:00 +01:00
|
|
|
|
#endif//LAUNCHER_H
|