This repository has been archived on 2022-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
Xash3DArchive/engine/common/common.h

793 lines
27 KiB
C
Raw Normal View History

2011-05-09 22:00:00 +02:00
/*
common.h - definitions common between client and server
Copyright (C) 2007 Uncle Mike
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
2008-06-09 22:00:00 +02:00
#ifndef COMMON_H
#define COMMON_H
2011-03-12 22:00:00 +01:00
#ifdef __cplusplus
extern "C" {
#endif
// disable some warnings
#pragma warning(disable : 4244) // MIPS
#pragma warning(disable : 4018) // signed/unsigned mismatch
#pragma warning(disable : 4305) // truncation from const double to float
#define MAX_STRING 256 // generic string
#define MAX_INFO_STRING 256 // infostrings are transmitted across network
#define MAX_SYSPATH 1024 // system filepath
#define MAX_MODS 512 // environment games that engine can keep visible
#define EXPORT __declspec( dllexport )
#define BIT( n ) (1<<( n ))
#ifndef __cplusplus
#define NULL ((void *)0)
#endif
// color strings
#define IsColorString( p ) ( p && *( p ) == '^' && *(( p ) + 1) && *(( p ) + 1) >= '0' && *(( p ) + 1 ) <= '9' )
2011-03-21 22:00:00 +01:00
#define ColorIndex( c ) ((( c ) - '0' ) & 7 )
2011-03-12 22:00:00 +01:00
typedef unsigned long dword;
typedef unsigned int uint;
typedef char string[MAX_STRING];
typedef long fs_offset_t;
typedef struct file_s file_t; // normal file
typedef struct wfile_s wfile_t; // wad file
typedef struct stream_s stream_t; // sound stream for background music playing
typedef struct
{
int numfilenames;
char **filenames;
char *filenamesbuffer;
} search_t;
enum
{
D_INFO = 1, // "-dev 1", shows various system messages
D_WARN, // "-dev 2", shows not critical system warnings
D_ERROR, // "-dev 3", shows critical warnings
D_AICONSOLE, // "-dev 4", special case for game aiconsole
D_NOTE // "-dev 5", show system notifications for engine developers
};
typedef enum
{
HOST_NORMAL, // listen server, singleplayer
HOST_DEDICATED,
HOST_CREDITS // easter egg
} instance_t;
2011-03-10 22:00:00 +01:00
#include "system.h"
2010-12-09 22:00:00 +01:00
#include "ref_params.h"
2010-08-07 22:00:00 +02:00
#include "com_model.h"
2011-03-09 22:00:00 +01:00
#include "crtlib.h"
2008-06-09 22:00:00 +02:00
2011-09-19 22:00:00 +02:00
#define XASH_VERSION 0.9f // engine current version
2011-03-10 22:00:00 +01:00
2010-06-20 22:00:00 +02:00
// PERFORMANCE INFO
2011-07-07 22:00:00 +02:00
#define MIN_FPS 15.0 // host minimum fps value for maxfps.
#define MAX_FPS 500.0 // upper limit for maxfps.
2010-06-20 22:00:00 +02:00
#define MAX_FRAMETIME 0.1
#define MIN_FRAMETIME 0.001
2011-03-09 22:00:00 +01:00
#define MAX_CMD_TOKENS 80 // cmd tokens
2008-07-04 22:00:00 +02:00
#define MAX_ENTNUMBER 99999 // for server and client parsing
#define MAX_HEARTBEAT -99999 // connection time
2011-02-28 22:00:00 +01:00
#define QCHAR_WIDTH 16 // font width
2008-06-09 22:00:00 +02:00
2010-09-30 22:00:00 +02:00
#define CIN_MAIN 0
#define CIN_LOGO 1
2011-03-12 22:00:00 +01:00
#define MAX_NUM_ARGVS 128
2010-10-07 22:00:00 +02:00
// config strings are a general means of communication from
// the server to all connected clients.
// each config string can be at most CS_SIZE characters.
2010-12-16 22:00:00 +01:00
#define CS_SIZE 64 // size of one config string
#define CS_TIME 16 // size of time string
2010-10-07 22:00:00 +02:00
2010-12-16 22:00:00 +01:00
#define MAX_DECALS 512 // touching TE_DECAL messages, etc
2010-10-07 22:00:00 +02:00
2011-03-09 22:00:00 +01:00
// filesystem flags
#define FS_STATIC_PATH 1 // FS_ClearSearchPath will be ignore this path
#define FS_NOWRITE_PATH 2 // default behavior - last added gamedir set as writedir. This flag disables it
#define FS_GAMEDIR_PATH 4 // just a marker for gamedir path
2011-03-01 22:00:00 +01:00
2011-03-12 22:00:00 +01:00
#define GI SI.GameInfo
#define FS_Gamedir() SI.GameInfo->gamedir
#define FS_Title() SI.GameInfo->title
2010-08-05 22:00:00 +02:00
#ifdef _DEBUG
2010-10-26 22:00:00 +02:00
void DBG_AssertFunction( qboolean fExpr, const char* szExpr, const char* szFile, int szLine, const char* szMessage );
2010-08-05 22:00:00 +02:00
#define Assert( f ) DBG_AssertFunction( f, #f, __FILE__, __LINE__, NULL )
#else
#define Assert( f )
#endif
2010-10-22 22:00:00 +02:00
extern convar_t *scr_width;
extern convar_t *scr_height;
2010-12-09 22:00:00 +01:00
extern convar_t *scr_loading;
2010-10-22 22:00:00 +02:00
extern convar_t *scr_download;
2010-12-09 22:00:00 +01:00
extern convar_t *cl_allow_levelshots;
2011-09-03 22:00:00 +02:00
extern convar_t *host_allow_materials;
2010-10-22 22:00:00 +02:00
extern convar_t *host_limitlocal;
extern convar_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
*/
2011-03-12 22:00:00 +01:00
/*
========================================================================
GAMEINFO stuff
internal shared gameinfo structure (readonly for engine parts)
========================================================================
*/
typedef struct gameinfo_s
{
// filesystem info
char gamefolder[64]; // used for change game '-game x'
char basedir[64]; // main game directory (like 'id1' for Quake or 'valve' for Half-Life)
char gamedir[64]; // game directory (can be match with basedir, used as primary dir and as write path
2011-04-05 22:00:00 +02:00
char falldir[64]; // used as second basedir
2011-03-12 22:00:00 +01:00
char startmap[64]; // map to start singleplayer game
char trainmap[64]; // map to start hazard course (if specified)
char title[64]; // Game Main Title
float version; // game version (optional)
// .dll pathes
char dll_path[64]; // e.g. "bin" or "cl_dlls"
char game_dll[64]; // custom path for game.dll
2011-10-01 22:00:00 +02:00
// .ico path
char iconpath[64]; // "game.ico" by default
2011-03-12 22:00:00 +01:00
// about mod info
string game_url; // link to a developer's site
string update_url; // link to updates page
char type[64]; // single, toolkit, multiplayer etc
char date[64];
size_t size;
int gamemode;
2011-09-19 22:00:00 +02:00
qboolean secure; // prevent to console acess
2011-03-12 22:00:00 +01:00
char sp_entity[32]; // e.g. info_player_start
char mp_entity[32]; // e.g. info_player_deathmatch
float client_mins[4][3]; // 4 hulls allowed
float client_maxs[4][3]; // 4 hulls allowed
2011-09-03 22:00:00 +02:00
char ambientsound[NUM_AMBIENTS][64];// quake ambient sounds
2011-03-12 22:00:00 +01:00
int max_edicts; // min edicts is 600, max edicts is 4096
int max_tents; // min temp ents is 300, max is 2048
int max_beams; // min beams is 64, max beams is 512
2011-04-13 22:00:00 +02:00
int max_particles; // min particles is 4096, max particles is 32768
2011-03-12 22:00:00 +01:00
} gameinfo_t;
typedef struct sysinfo_s
{
string ModuleName; // exe.filename
gameinfo_t *GameInfo; // current GameInfo
gameinfo_t *games[MAX_MODS]; // environment games (founded at each engine start)
int numgames;
} sysinfo_t;
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
2011-03-12 22:00:00 +01:00
HOST_ERR_FATAL, // sys error
2008-06-09 22:00:00 +02:00
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;
2011-09-19 22:00:00 +02:00
typedef enum
{
key_console = 0,
key_game,
key_menu,
key_message
} keydest_t;
2011-04-06 22:00:00 +02:00
// MD5 Hash
typedef struct
{
uint buf[4];
uint bits[2];
byte in[64];
} MD5Context_t;
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;
2011-03-01 22:00:00 +01:00
typedef enum
{
NS_CLIENT,
NS_SERVER
} netsrc_t;
#include "netadr.h"
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;
2011-04-06 22:00:00 +02:00
typedef struct
{
vec3_t position;
char name[64];
short entityIndex;
byte depth;
byte flags;
// this is the surface plane that we hit so that
// we can move certain decals across
// transitions if they hit similar geometry
vec3_t impactPlaneNormal;
} decallist_t;
typedef struct
{
string name;
int entnum;
vec3_t origin;
float volume;
float attenuation;
qboolean looping;
int pitch;
} soundlist_t;
2008-06-09 22:00:00 +02:00
typedef struct host_parm_s
{
2011-03-12 22:00:00 +01:00
HINSTANCE hInst;
HANDLE hMutex;
LPTOP_LEVEL_EXCEPTION_FILTER oldFilter;
2008-06-09 22:00:00 +02:00
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
2011-03-09 22:00:00 +01:00
// command line parms
int argc;
2011-03-12 22:00:00 +01:00
const char *argv[MAX_NUM_ARGVS];
2011-03-09 22:00:00 +01:00
2010-10-09 22:00:00 +02:00
double realtime; // host.curtime
double frametime; // time between engine frames
double realframetime; // for some system events, e.g. console animations
2009-09-20 22:00:00 +02:00
uint framecount; // global framecount
2010-10-28 22:00:00 +02:00
// list of unique decal indexes
char draw_decals[MAX_DECALS][CS_SIZE];
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-10-26 22:00:00 +02:00
qboolean key_overstrike; // key overstrike mode
2011-03-09 22:00:00 +01:00
qboolean stuffcmdsrun; // execute stuff commands
2011-03-12 22:00:00 +01:00
qboolean con_showalways; // show console always (developer and dedicated)
qboolean change_game; // initialize when game is changed
2011-03-19 22:00:00 +01:00
qboolean mouse_visible; // vgui override cursor control
qboolean input_enabled; // vgui override mouse & keyboard input
2011-03-12 22:00:00 +01:00
qboolean shutdown_issued; // engine is shutting down
2011-03-20 22:00:00 +01:00
qboolean decal_loading; // nasty hack to tell imagelib about decal
2011-08-21 22:00:00 +02:00
qboolean overview_loading; // another nasty hackk to tell imagelib about ovierview
2011-09-03 22:00:00 +02:00
qboolean force_draw_version; // used when fraps is loaded
2011-03-13 22:00:00 +01:00
2011-04-05 22:00:00 +02:00
char rootdir[256]; // member root directory
2011-03-13 22:00:00 +01:00
char gamefolder[64]; // it's a default gamefolder
2011-02-28 22:00:00 +01:00
byte *imagepool; // imagelib mempool
byte *soundpool; // soundlib mempool
2010-10-09 22:00:00 +02:00
// for IN_MouseMove() easy access
2010-08-20 22:00:00 +02:00
int window_center_x;
int window_center_y;
2010-07-01 22:00:00 +02:00
decallist_t *decalList; // used for keep decals, when renderer is restarted or changed
int numdecals;
2010-10-16 22:00:00 +02:00
soundlist_t *soundList; // used for keep ambient sounds, when renderer or sound is restarted
int numsounds;
2008-06-09 22:00:00 +02:00
} host_parm_t;
2009-11-02 22:00:00 +01:00
extern host_parm_t host;
2011-03-12 22:00:00 +01:00
extern sysinfo_t SI;
2011-01-31 22:00:00 +01:00
2011-03-08 22:00:00 +01:00
//
// filesystem.c
//
void FS_Init( void );
void FS_Path( void );
void FS_Shutdown( void );
void FS_ClearSearchPath( void );
void FS_AllowDirectPaths( qboolean enable );
void FS_AddGameDirectory( const char *dir, int flags );
void FS_AddGameHierarchy( const char *dir, int flags );
void FS_LoadGameInfo( const char *rootfolder );
void FS_FileBase( const char *in, char *out );
const char *FS_FileExtension( const char *in );
void FS_DefaultExtension( char *path, const char *extension );
void FS_ExtractFilePath( const char* const path, char* dest );
const char *FS_GetDiskPath( const char *name, qboolean gamedironly );
const char *FS_FileWithoutPath( const char *in );
wfile_t *W_Open( const char *filename, const char *mode );
byte *W_LoadLump( wfile_t *wad, const char *lumpname, size_t *lumpsizeptr, const char type );
void W_Close( wfile_t *wad );
file_t *FS_OpenFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly );
byte *FS_LoadFile( const char *path, fs_offset_t *filesizeptr, qboolean gamedironly );
qboolean FS_WriteFile( const char *filename, const void *data, fs_offset_t len );
2011-04-05 22:00:00 +02:00
int COM_FileSize( const char *filename );
void COM_FixSlashes( char *pname );
void COM_FreeFile( void *buffer );
2011-03-08 22:00:00 +01:00
search_t *FS_Search( const char *pattern, int caseinsensitive, int gamedironly );
file_t *FS_Open( const char *filepath, const char *mode, qboolean gamedironly );
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, qboolean gamedironly );
fs_offset_t FS_FileTime( const char *filename, qboolean gamedironly );
int FS_Print( file_t *file, const char *msg );
qboolean FS_Rename( const char *oldname, const char *newname );
qboolean FS_FileExists( const char *filename, qboolean gamedironly );
qboolean FS_Delete( const char *path );
int FS_UnGetc( file_t *file, byte c );
void FS_StripExtension( char *path );
fs_offset_t FS_Tell( file_t *file );
qboolean FS_Eof( file_t *file );
void FS_Purge( file_t *file );
int FS_Close( file_t *file );
int FS_Getc( file_t *file );
qboolean FS_Eof( file_t *file );
fs_offset_t FS_FileLength( file_t *f );
2011-03-01 22:00:00 +01:00
//
// network.c
//
void NET_Init( void );
void NET_Shutdown( void );
void NET_Sleep( int msec );
void NET_Config( qboolean net_enable );
qboolean NET_IsLocalAddress( netadr_t adr );
char *NET_AdrToString( const netadr_t a );
char *NET_BaseAdrToString( const netadr_t a );
qboolean NET_StringToAdr( const char *string, netadr_t *adr );
qboolean NET_CompareAdr( const netadr_t a, const netadr_t b );
qboolean NET_CompareBaseAdr( const netadr_t a, const netadr_t b );
qboolean NET_GetPacket( netsrc_t sock, netadr_t *from, byte *data, size_t *length );
void NET_SendPacket( netsrc_t sock, size_t length, const void *data, netadr_t to );
2011-02-28 22:00:00 +01:00
/*
========================================================================
internal image format
typically expanded to rgba buffer
NOTE: number at end of pixelformat name it's a total bitscount e.g. PF_RGB_24 == PF_RGB_888
========================================================================
*/
typedef enum
{
PF_UNKNOWN = 0,
PF_INDEXED_24, // inflated palette (768 bytes)
PF_INDEXED_32, // deflated palette (1024 bytes)
PF_RGBA_32, // normal rgba buffer
PF_BGRA_32, // big endian RGBA (MacOS)
PF_RGB_24, // uncompressed dds or another 24-bit image
PF_BGR_24, // big-endian RGB (MacOS)
PF_TOTALCOUNT, // must be last
} pixformat_t;
typedef struct bpc_desc_s
{
int format; // pixelformat
char name[16]; // used for debug
uint glFormat; // RGBA format
int bpp; // channels (e.g. rgb = 3, rgba = 4)
} bpc_desc_t;
// imagelib global settings
typedef enum
{
IL_USE_LERPING = BIT(0), // lerping images during resample
IL_KEEP_8BIT = BIT(1), // don't expand paletted images
IL_ALLOW_OVERWRITE = BIT(2), // allow to overwrite stored images
2011-10-09 22:00:00 +02:00
IL_DONTFLIP_TGA = BIT(3), // Steam background completely ignore tga attribute 0x20 (stupid lammers!)
2011-02-28 22:00:00 +01:00
} ilFlags_t;
// rgbdata output flags
typedef enum
{
// rgbdata->flags
IMAGE_CUBEMAP = BIT(0), // it's 6-sides cubemap buffer
IMAGE_HAS_ALPHA = BIT(1), // image contain alpha-channel
IMAGE_HAS_COLOR = BIT(2), // image contain RGB-channel
IMAGE_COLORINDEX = BIT(3), // all colors in palette is gradients of last color (decals)
IMAGE_HAS_LUMA = BIT(4), // image has luma pixels (q1-style maps)
IMAGE_SKYBOX = BIT(5), // only used by FS_SaveImage - for write right suffixes
IMAGE_QUAKESKY = BIT(6), // it's a quake sky double layered clouds (so keep it as 8 bit)
IMAGE_STATIC = BIT(7), // never trying to free this image (static memory)
// Image_Process manipulation flags
IMAGE_FLIP_X = BIT(16), // flip the image by width
IMAGE_FLIP_Y = BIT(17), // flip the image by height
IMAGE_ROT_90 = BIT(18), // flip from upper left corner to down right corner
IMAGE_ROT180 = IMAGE_FLIP_X|IMAGE_FLIP_Y,
IMAGE_ROT270 = IMAGE_FLIP_X|IMAGE_FLIP_Y|IMAGE_ROT_90,
IMAGE_ROUND = BIT(19), // round image to nearest Pow2
IMAGE_RESAMPLE = BIT(20), // resample image to specified dims
IMAGE_PALTO24 = BIT(21), // turn 32-bit palette into 24-bit mode (only for indexed images)
IMAGE_ROUNDFILLER = BIT(22), // round image to Pow2 and fill unused entries with single color
IMAGE_FORCE_RGBA = BIT(23), // force image to RGBA buffer
IMAGE_MAKE_LUMA = BIT(24), // create luma texture from indexed
2011-08-21 22:00:00 +02:00
IMAGE_QUANTIZE = BIT(25), // make indexed image from 24 or 32- bit image
2011-10-06 22:00:00 +02:00
IMAGE_LIGHTGAMMA = BIT(26), // apply gamma for image
2011-02-28 22:00:00 +01:00
} imgFlags_t;
typedef struct rgbdata_s
{
word width; // image width
word height; // image height
uint type; // compression type
uint flags; // misc image flags
byte *palette; // palette if present
byte *buffer; // image buffer
rgba_t fogParams; // some water textures in hl1 has info about fog color and alpha
size_t size; // for bounds checking
} rgbdata_t;
//
// imagelib
//
void Image_Init( void );
void Image_Shutdown( void );
rgbdata_t *FS_LoadImage( const char *filename, const byte *buffer, size_t size );
qboolean FS_SaveImage( const char *filename, rgbdata_t *pix );
2011-10-09 22:00:00 +02:00
rgbdata_t *FS_CopyImage( rgbdata_t *in );
2011-02-28 22:00:00 +01:00
void FS_FreeImage( rgbdata_t *pack );
extern const bpc_desc_t PFDesc[]; // image get pixelformat
2011-10-06 22:00:00 +02:00
qboolean Image_Process( rgbdata_t **pix, int width, int height, float gamma, uint flags );
2011-10-09 22:00:00 +02:00
void Image_SetForceFlags( uint flags ); // set image force flags on loading
2011-02-28 22:00:00 +01:00
/*
========================================================================
internal sound format
typically expanded to wav buffer
========================================================================
*/
typedef enum
{
WF_UNKNOWN = 0,
WF_PCMDATA,
WF_MPGDATA,
WF_TOTALCOUNT, // must be last
} sndformat_t;
// imagelib global settings
typedef enum
{
SL_USE_LERPING = BIT(0), // lerping sounds during resample
SL_KEEP_8BIT = BIT(1), // don't expand 8bit sounds automatically up to 16 bit
SL_ALLOW_OVERWRITE = BIT(2), // allow to overwrite stored sounds
} slFlags_t;
// wavdata output flags
typedef enum
{
// wavdata->flags
SOUND_LOOPED = BIT( 0 ), // this is looped sound (contain cue markers)
SOUND_STREAM = BIT( 1 ), // this is a streaminfo, not a real sound
// Sound_Process manipulation flags
SOUND_RESAMPLE = BIT(12), // resample sound to specified rate
SOUND_CONVERT16BIT = BIT(13), // change sound resolution from 8 bit to 16
} sndFlags_t;
typedef struct
{
word rate; // num samples per second (e.g. 11025 - 11 khz)
byte width; // resolution - bum bits divided by 8 (8 bit is 1, 16 bit is 2)
byte channels; // num channels (1 - mono, 2 - stereo)
int loopStart; // offset at this point sound will be looping while playing more than only once
int samples; // total samplecount in wav
uint type; // compression type
uint flags; // misc sound flags
byte *buffer; // sound buffer
size_t size; // for bounds checking
} wavdata_t;
//
// soundlib
//
void Sound_Init( void );
void Sound_Shutdown( void );
wavdata_t *FS_LoadSound( const char *filename, const byte *buffer, size_t size );
void FS_FreeSound( wavdata_t *pack );
stream_t *FS_OpenStream( const char *filename );
wavdata_t *FS_StreamInfo( stream_t *stream );
long FS_ReadStream( stream_t *stream, int bytes, void *buffer );
void FS_FreeStream( stream_t *stream );
qboolean Sound_Process( wavdata_t **wav, int rate, int width, uint flags );
2011-09-03 22:00:00 +02:00
uint Sound_GetApproxWavePlayLen( const char *filepath );
2011-02-28 22:00:00 +01:00
2010-03-07 22:00:00 +01:00
//
// build.c
//
2011-04-06 22:00:00 +02:00
int Q_buildnum( void );
2010-03-07 22:00:00 +01:00
2008-08-04 22:00:00 +02:00
//
// host.c
//
2011-03-12 22:00:00 +01:00
void EXPORT Host_Shutdown( 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 );
2011-03-12 22:00:00 +01:00
void Host_NewInstance( const char *name, const char *finalmsg );
2010-10-26 22:00:00 +02:00
qboolean Host_NewGame( const char *mapName, qboolean 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 );
2011-03-15 22:00:00 +01:00
qboolean CL_ChangeGame( const char *gamefolder, qboolean bReset );
2010-07-30 22:00:00 +02:00
void Host_WriteServerConfig( const char *name );
void Host_WriteOpenGLConfig( void );
2010-12-27 22:00:00 +01:00
void Host_WriteVideoConfig( void );
2009-09-10 22:00:00 +02:00
void Host_WriteConfig( void );
2010-10-26 22:00:00 +02:00
qboolean Host_IsLocalGame( void );
2009-10-13 22:00:00 +02:00
void Host_ShutdownServer( 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, ... );
2011-03-13 22:00:00 +01:00
void Host_InitDecals( void );
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-10-09 22:00:00 +02:00
void Host_ClientFrame( void );
2010-10-26 22:00:00 +02:00
qboolean CL_Active( void );
2008-06-09 22:00:00 +02:00
void SV_Init( void );
2010-10-26 22:00:00 +02:00
void SV_Shutdown( qboolean reconnect );
2010-10-09 22:00:00 +02:00
void Host_ServerFrame( void );
2010-10-26 22:00:00 +02:00
qboolean SV_Active( void );
2008-12-15 22:00:00 +01:00
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
==============================================================
*/
2010-10-22 22:00:00 +02:00
cvar_t *pfnCvar_RegisterVariable( const char *szName, const char *szValue, int flags );
2011-04-06 22:00:00 +02:00
char *COM_MemFgets( byte *pMemFile, int fileSize, int *filePos, char *pBuffer, int bufferSize );
byte* COM_LoadFileForMe( const char *filename, int *pLength );
2010-08-15 22:00:00 +02:00
cvar_t *pfnCVarGetPointer( const char *szVarName );
2011-03-15 22:00:00 +01:00
int pfnAddClientCommand( const char *cmd_name, xcommand_t func );
2010-09-10 22:00:00 +02:00
void *Cache_Check( byte *mempool, struct cache_user_s *c );
2010-10-16 22:00:00 +02:00
edict_t* pfnPEntityOfEntIndex( int iEntIndex );
2011-04-05 22:00:00 +02:00
void pfnGetModelBounds( model_t *mod, float *mins, float *maxs );
2010-04-09 22:00:00 +02:00
void pfnGetGameDir( char *szGetGameDir );
2011-04-05 22:00:00 +02:00
int pfnGetModelType( model_t *mod );
2011-04-01 22:00:00 +02:00
int pfnIsMapValid( char *filename );
2010-08-20 22:00:00 +02:00
void Con_DPrintf( char *fmt, ... );
void Con_Printf( char *szFmt, ... );
2010-04-21 22:00:00 +02:00
int pfnIsInGame( 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
==============================================================
*/
2010-10-28 22:00:00 +02:00
#define Z_Malloc( size ) Mem_Alloc( host.mempool, size )
2009-11-03 22:00:00 +01:00
#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
2011-02-28 22:00:00 +01:00
//
// crclib.c
//
void CRC32_Init( dword *pulCRC );
byte CRC32_BlockSequence( byte *base, int length, int sequence );
void CRC32_ProcessBuffer( dword *pulCRC, const void *pBuffer, int nBuffer );
void CRC32_ProcessByte( dword *pulCRC, byte ch );
void CRC32_Final( dword *pulCRC );
qboolean CRC32_File( dword *crcvalue, const char *filename );
qboolean CRC32_MapFile( dword *crcvalue, const char *filename );
void MD5Init( MD5Context_t *ctx );
void MD5Update( MD5Context_t *ctx, const byte *buf, uint len );
void MD5Final( byte digest[16], MD5Context_t *ctx );
uint Com_HashKey( const char *string, uint hashSize );
//
// hpak.c
//
void HPAK_Init( void );
qboolean HPAK_GetDataPointer( const char *filename, struct resource_s *pRes, byte **buffer, int *size );
qboolean HPAK_ResourceForHash( const char *filename, char *hash, struct resource_s *pRes );
void HPAK_AddLump( qboolean queue, const char *filename, struct resource_s *pRes, byte *data, file_t *f );
void HPAK_CheckIntegrity( const char *filename );
void HPAK_CheckSize( const char *filename );
void HPAK_FlushHostQueue( void );
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
//
2010-10-26 22:00:00 +02:00
qboolean Key_IsDown( int keynum );
2010-01-08 22:00:00 +01:00
const char *Key_IsBind( int keynum );
2010-10-26 22:00:00 +02:00
void Key_Event( int key, qboolean down );
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
//
2010-10-02 22:00:00 +02:00
// avikit.c
2010-09-30 22:00:00 +02:00
//
typedef struct movie_state_s movie_state_t;
long AVI_GetVideoFrameNumber( movie_state_t *Avi, float time );
2010-10-01 22:00:00 +02:00
byte *AVI_GetVideoFrame( movie_state_t *Avi, long frame );
2010-10-26 22:00:00 +02:00
qboolean AVI_GetVideoInfo( movie_state_t *Avi, long *xres, long *yres, float *duration );
qboolean AVI_GetAudioInfo( movie_state_t *Avi, wavdata_t *snd_info );
2010-09-30 22:00:00 +02:00
fs_offset_t AVI_GetAudioChunk( movie_state_t *Avi, char *audiodata, long offset, long length );
2011-02-28 22:00:00 +01:00
void AVI_OpenVideo( movie_state_t *Avi, const char *filename, qboolean load_audio, qboolean ignore_hwgamma, int quiet );
2010-09-30 22:00:00 +02:00
void AVI_CloseVideo( movie_state_t *Avi );
2010-10-26 22:00:00 +02:00
qboolean AVI_IsActive( movie_state_t *Avi );
2010-09-30 22:00:00 +02:00
movie_state_t *AVI_GetState( int num );
2011-03-09 22:00:00 +01:00
qboolean AVI_Initailize( void );
void AVI_Shutdown( void );
2010-09-30 22:00:00 +02:00
2009-12-20 22:00:00 +01:00
// shared calls
2010-10-26 22:00:00 +02:00
qboolean CL_IsInGame( void );
qboolean CL_IsInMenu( void );
2011-02-22 22:00:00 +01:00
qboolean CL_IsInConsole( void );
2010-11-15 22:00:00 +01:00
qboolean CL_IsThirdPerson( void );
2010-06-24 22:00:00 +02:00
float CL_GetServerTime( void );
2010-11-15 22:00:00 +01:00
float CL_GetLerpFrac( void );
2009-11-03 22:00:00 +01:00
void CL_CharEvent( int key );
int CL_PointContents( const vec3_t point );
2010-08-20 22:00:00 +02:00
char *COM_ParseFile( char *data, char *token );
2010-10-31 22:00:00 +01:00
byte *COM_LoadFile( const char *filename, int usehunk, int *pLength );
2010-08-20 22:00:00 +02:00
void CL_StudioEvent( struct mstudioevent_s *event, struct cl_entity_s *ent );
2010-10-26 22:00:00 +02:00
qboolean CL_GetComment( const char *demoname, char *comment );
2010-11-03 22:00:00 +01:00
void COM_AddAppDirectoryToSearchPath( const char *pszBaseDir, const char *appName );
int COM_ExpandFilename( const char *fileName, char *nameOutBuffer, int nameOutBufferSize );
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-10-16 22:00:00 +02:00
void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float attn, int flags, int pitch );
2010-12-02 22:00:00 +01:00
int R_CreateDecalList( decallist_t *pList, qboolean changelevel );
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 );
2011-04-01 22:00:00 +02:00
qboolean UI_CreditsActive( void );
2010-10-09 22:00:00 +02:00
void CL_ExtraUpdate( void );
2009-11-03 22:00:00 +01:00
int CL_GetMaxClients( void );
2010-10-26 22:00:00 +02:00
qboolean CL_IsPlaybackDemo( void );
2010-11-15 22:00:00 +01:00
qboolean CL_LoadProgs( const char *name );
2010-10-26 22:00:00 +02:00
qboolean SV_GetComment( const char *savename, char *comment );
qboolean SV_NewGame( const char *mapName, qboolean 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 );
2011-03-13 22:00:00 +01:00
void SV_FreeGameProgs( void );
2010-03-27 22:00:00 +01:00
void SV_ForceError( void );
void CL_WriteMessageHistory( void );
2010-06-20 22:00:00 +02:00
void CL_SendCmd( void );
2009-11-03 22:00:00 +01:00
void CL_Disconnect( void );
2011-03-09 22:00:00 +01:00
void CL_Crashed( void );
2010-10-26 22:00:00 +02:00
qboolean CL_NextDemo( void );
2008-06-09 22:00:00 +02:00
void CL_Drop( void );
2009-11-03 22:00:00 +01:00
void SCR_Init( void );
void SCR_UpdateScreen( void );
2011-04-05 22:00:00 +02:00
void SCR_BeginLoadingPlaque( qboolean is_background );
2010-10-09 22:00:00 +02:00
void SCR_CheckStartupVids( void );
2010-09-30 22:00:00 +02:00
long SCR_GetAudioChunk( char *rawdata, long length );
wavdata_t *SCR_GetMovieInfo( void );
2009-11-03 22:00:00 +01:00
void SCR_Shutdown( void );
void Con_Print( const char *txt );
2010-08-20 22:00:00 +02:00
void Con_NPrintf( int idx, char *fmt, ... );
void Con_NXPrintf( struct con_nprint_s *info, char *fmt, ... );
2011-04-08 22:00:00 +02:00
void UI_NPrintf( int idx, char *fmt, ... );
void UI_NXPrintf( struct con_nprint_s *info, char *fmt, ... );
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 );
2010-10-26 22:00:00 +02:00
qboolean Info_RemoveKey( char *s, const char *key );
qboolean Info_SetValueForKey( char *s, const char *key, const char *value );
2011-10-09 22:00:00 +02:00
qboolean Info_SetValueForStarKey( char *s, const char *key, const char *value, int maxsize );
2010-10-26 22:00:00 +02:00
qboolean Info_Validate( const char *s );
2009-11-23 22:00:00 +01:00
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-10-26 22:00:00 +02:00
qboolean Cmd_CheckMapsList( qboolean fRefresh );
2010-02-18 22:00:00 +01:00
void Cmd_AutoComplete( char *complete_string );
2011-02-28 22:00:00 +01:00
long Com_RandomLong( long lMin, long lMax );
float Com_RandomFloat( float fMin, float fMax );
2011-03-30 22:00:00 +02:00
void TrimSpace( const char *source, char *dest );
2011-04-06 22:00:00 +02:00
void GL_FreeImage( const char *name );
void VID_RestoreGamma( void );
2011-09-19 22:00:00 +02:00
void UI_SetActiveMenu( qboolean fActive );
2008-06-09 22:00:00 +02:00
2008-08-03 22:00:00 +02:00
typedef struct autocomplete_list_s
{
const char *name;
2010-10-26 22:00:00 +02:00
qboolean (*func)( const char *s, char *name, int length );
2008-08-03 22:00:00 +02:00
} 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
2010-11-20 22:00:00 +01:00
// soundlib shared exports
2010-12-21 22:00:00 +01:00
qboolean S_Init( void );
2010-11-20 22:00:00 +01:00
void S_Shutdown( void );
void S_Activate( qboolean active, void *hInst );
void S_StopSound( int entnum, int channel, const char *soundname );
2010-12-25 22:00:00 +01:00
int S_GetCurrentStaticSounds( soundlist_t *pout, int size );
2010-11-20 22:00:00 +01:00
void S_StopAllSounds( void );
2011-10-06 22:00:00 +02:00
// gamma routines
void BuildGammaTable( float gamma, float texGamma );
byte TextureToTexGamma( byte b );
byte TextureToGamma( byte b );
2011-03-12 22:00:00 +01:00
#ifdef __cplusplus
}
#endif
2007-06-21 22:00:00 +02:00
#endif//COMMON_H