2008-12-25 22:00:00 +01:00
|
|
|
|
//=======================================================================
|
|
|
|
|
// Copyright XashXT Group 2008 <20>
|
|
|
|
|
// clgame_api.h - entity interface between engine and clgame
|
|
|
|
|
//=======================================================================
|
|
|
|
|
#ifndef CLGAME_API_H
|
|
|
|
|
#define CLGAME_API_H
|
|
|
|
|
|
2010-02-23 22:00:00 +01:00
|
|
|
|
#include "trace_def.h"
|
|
|
|
|
#include "pm_shared.h"
|
|
|
|
|
|
2009-01-11 22:00:00 +01:00
|
|
|
|
typedef int HSPRITE; // handle to a graphic
|
2009-10-18 22:00:00 +02:00
|
|
|
|
typedef struct tempent_s TEMPENTITY;
|
2010-06-28 22:00:00 +02:00
|
|
|
|
typedef struct dlight_s dlight_t;
|
2009-09-13 22:00:00 +02:00
|
|
|
|
typedef struct usercmd_s usercmd_t;
|
2010-03-15 22:00:00 +01:00
|
|
|
|
typedef struct particle_s particle_t;
|
2009-09-17 22:00:00 +02:00
|
|
|
|
typedef struct skyportal_s skyportal_t;
|
2009-01-11 22:00:00 +01:00
|
|
|
|
typedef struct ref_params_s ref_params_t;
|
|
|
|
|
typedef struct dstudioevent_s dstudioevent_t;
|
2010-02-23 22:00:00 +01:00
|
|
|
|
typedef void (*ENTCALLBACK)( TEMPENTITY *ent );
|
|
|
|
|
typedef void (*HITCALLBACK)( TEMPENTITY *ent, TraceResult *ptr );
|
2008-12-25 22:00:00 +01:00
|
|
|
|
typedef int (*pfnUserMsgHook)( const char *pszName, int iSize, void *pbuf ); // user message handle
|
2010-03-15 22:00:00 +01:00
|
|
|
|
typedef enum { pt_static, pt_grav, pt_slowgrav, pt_fire, pt_explode, pt_explode2, pt_blob, pt_blob2 } ptype_t;
|
2008-12-25 22:00:00 +01:00
|
|
|
|
|
2009-10-18 22:00:00 +02:00
|
|
|
|
#define SCRINFO_VIRTUALSPACE 1
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
int iFlags;
|
|
|
|
|
int iRealWidth;
|
|
|
|
|
int iRealHeight;
|
|
|
|
|
int iWidth;
|
|
|
|
|
int iHeight;
|
|
|
|
|
int iCharHeight;
|
|
|
|
|
byte charWidths[256];
|
|
|
|
|
} SCREENINFO;
|
|
|
|
|
|
2009-11-02 22:00:00 +01:00
|
|
|
|
typedef struct wrect_s
|
|
|
|
|
{
|
|
|
|
|
int left;
|
|
|
|
|
int right;
|
|
|
|
|
int top;
|
|
|
|
|
int bottom;
|
|
|
|
|
} wrect_t;
|
|
|
|
|
|
2008-12-25 22:00:00 +01:00
|
|
|
|
typedef struct
|
|
|
|
|
{
|
2009-01-11 22:00:00 +01:00
|
|
|
|
char *name;
|
|
|
|
|
short ping;
|
|
|
|
|
byte thisplayer; // TRUE if this is the calling player
|
2009-12-03 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
byte spectator;
|
|
|
|
|
byte packetloss;
|
2009-11-02 22:00:00 +01:00
|
|
|
|
const char *model;
|
|
|
|
|
short topcolor;
|
|
|
|
|
short bottomcolor;
|
2008-12-25 22:00:00 +01:00
|
|
|
|
} hud_player_info_t;
|
|
|
|
|
|
|
|
|
|
typedef struct client_textmessage_s
|
|
|
|
|
{
|
2009-01-11 22:00:00 +01:00
|
|
|
|
int effect;
|
|
|
|
|
byte r1, g1, b1, a1; // 2 colors for effects
|
|
|
|
|
byte r2, g2, b2, a2;
|
|
|
|
|
float x;
|
|
|
|
|
float y;
|
|
|
|
|
float fadein;
|
|
|
|
|
float fadeout;
|
|
|
|
|
float holdtime;
|
|
|
|
|
float fxtime;
|
|
|
|
|
const char *pName;
|
|
|
|
|
const char *pMessage;
|
2008-12-25 22:00:00 +01:00
|
|
|
|
} client_textmessage_t;
|
|
|
|
|
|
2009-11-02 22:00:00 +01:00
|
|
|
|
typedef struct client_sprite_s
|
|
|
|
|
{
|
|
|
|
|
char szName[64];
|
|
|
|
|
char szSprite[64];
|
|
|
|
|
HSPRITE hSprite;
|
|
|
|
|
int iRes;
|
|
|
|
|
wrect_t rc;
|
|
|
|
|
} client_sprite_t;
|
|
|
|
|
|
2009-09-28 22:00:00 +02:00
|
|
|
|
typedef struct cl_globalvars_s
|
|
|
|
|
{
|
|
|
|
|
float time; // time from server
|
|
|
|
|
float frametime;
|
|
|
|
|
string_t mapname;
|
|
|
|
|
|
2010-03-07 22:00:00 +01:00
|
|
|
|
ref_params_t *pViewParms; // just for easy acess on client
|
|
|
|
|
|
2009-12-03 22:00:00 +01:00
|
|
|
|
int serverflags; // shared serverflags
|
2009-09-28 22:00:00 +02:00
|
|
|
|
int maxClients;
|
2010-02-09 22:00:00 +01:00
|
|
|
|
int windowState; // 0 - inactive (minimize, notfocus), 1 - active
|
2009-09-28 22:00:00 +02:00
|
|
|
|
int maxEntities;
|
|
|
|
|
int numEntities; // actual ents count
|
2010-03-30 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
const char *pStringBase; // actual only when sys_sharedstrings is 1
|
|
|
|
|
|
|
|
|
|
void *pSaveData; // (SAVERESTOREDATA *) pointer
|
2010-06-28 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
// Xash3D specific
|
|
|
|
|
float viewheight[PM_MAXHULLS]; // values from gameinfo.txt
|
|
|
|
|
vec3_t hullmins[PM_MAXHULLS];
|
|
|
|
|
vec3_t hullmaxs[PM_MAXHULLS];
|
2009-09-28 22:00:00 +02:00
|
|
|
|
} cl_globalvars_t;
|
|
|
|
|
|
2008-12-25 22:00:00 +01:00
|
|
|
|
typedef struct cl_enginefuncs_s
|
|
|
|
|
{
|
2009-12-03 22:00:00 +01:00
|
|
|
|
// sprite handlers
|
|
|
|
|
HSPRITE (*pfnSPR_Load)( const char *szPicName );
|
|
|
|
|
int (*pfnSPR_Frames)( HSPRITE hPic );
|
|
|
|
|
int (*pfnSPR_Height)( HSPRITE hPic, int frame );
|
|
|
|
|
int (*pfnSPR_Width)( HSPRITE hPic, int frame );
|
|
|
|
|
void (*pfnSPR_Set)( HSPRITE hPic, int r, int g, int b, int a );
|
|
|
|
|
void (*pfnSPR_Draw)( int frame, int x, int y, int width, int height, const wrect_t *prc );
|
|
|
|
|
void (*pfnSPR_DrawHoles)( int frame, int x, int y, int width, int height, const wrect_t *prc );
|
2010-06-28 22:00:00 +02:00
|
|
|
|
void (*pfnSPR_DrawTrans)( int frame, int x, int y, int width, int height, const wrect_t *prc ); // kRenderTransColor
|
2009-12-03 22:00:00 +01:00
|
|
|
|
void (*pfnSPR_DrawAdditive)( int frame, int x, int y, int width, int height, const wrect_t *prc );
|
|
|
|
|
void (*pfnSPR_EnableScissor)( int x, int y, int width, int height );
|
|
|
|
|
void (*pfnSPR_DisableScissor)( void );
|
|
|
|
|
client_sprite_t *(*pfnSPR_GetList)( char *psz, int *piCount );
|
|
|
|
|
|
|
|
|
|
// screen handlers
|
|
|
|
|
void (*pfnFillRGBA)( int x, int y, int width, int height, int r, int g, int b, int a );
|
|
|
|
|
int (*pfnGetScreenInfo)( SCREENINFO *pscrinfo );
|
|
|
|
|
void (*pfnSetCrosshair)( HSPRITE hspr, wrect_t rc, int r, int g, int b );
|
|
|
|
|
|
2008-12-25 22:00:00 +01:00
|
|
|
|
// cvar handlers
|
2009-01-22 22:00:00 +01:00
|
|
|
|
cvar_t* (*pfnRegisterVariable)( const char *szName, const char *szValue, int flags, const char *szDesc );
|
2008-12-25 22:00:00 +01:00
|
|
|
|
float (*pfnGetCvarFloat)( const char *szName );
|
|
|
|
|
char* (*pfnGetCvarString)( const char *szName );
|
|
|
|
|
|
|
|
|
|
// command handlers
|
|
|
|
|
void (*pfnAddCommand)( const char *cmd_name, void (*function)(void), const char *cmd_desc );
|
2008-12-26 22:00:00 +01:00
|
|
|
|
void (*pfnHookUserMsg)( const char *szMsgName, pfnUserMsgHook pfn );
|
2008-12-25 22:00:00 +01:00
|
|
|
|
void (*pfnServerCmd)( const char *szCmdString );
|
|
|
|
|
void (*pfnClientCmd)( const char *szCmdString );
|
2009-01-09 22:00:00 +01:00
|
|
|
|
|
2008-12-25 22:00:00 +01:00
|
|
|
|
void (*pfnGetPlayerInfo)( int player_num, hud_player_info_t *pinfo );
|
|
|
|
|
|
|
|
|
|
// sound handlers (NULL origin == play at current client origin)
|
2009-01-05 22:00:00 +01:00
|
|
|
|
void (*pfnPlaySoundByName)( const char *szSound, float volume, int pitch, const float *org );
|
|
|
|
|
void (*pfnPlaySoundByIndex)( int iSound, float volume, int pitch, const float *org );
|
2008-12-25 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
// vector helpers
|
|
|
|
|
void (*pfnAngleVectors)( const float *rgflVector, float *forward, float *right, float *up );
|
|
|
|
|
|
2009-12-04 22:00:00 +01:00
|
|
|
|
// text message system
|
|
|
|
|
client_textmessage_t *(*pfnTextMessageGet)( const char *pName );
|
|
|
|
|
int (*pfnDrawCharacter)( int x, int y, int number, int r, int g, int b );
|
|
|
|
|
int (*pfnDrawConsoleString)( int x, int y, char *string );
|
|
|
|
|
void (*pfnDrawSetTextColor)( float r, float g, float b );
|
|
|
|
|
void (*pfnDrawConsoleStringLen)( const char *string, int *length, int *height );
|
|
|
|
|
|
|
|
|
|
void (*pfnConsolePrint)( const char *string );
|
|
|
|
|
void (*pfnCenterPrint)( const char *string );
|
|
|
|
|
|
|
|
|
|
// engine memory manager
|
2009-12-05 22:00:00 +01:00
|
|
|
|
void* (*pfnMemAlloc)( size_t cb, const char *filename, const int fileline );// was GetWindowCenterX
|
|
|
|
|
void (*pfnMemFree)( void *mem, const char *filename, const int fileline ); // was GetWindowCenterY
|
2009-12-04 22:00:00 +01:00
|
|
|
|
|
2009-12-05 22:00:00 +01:00
|
|
|
|
// added for user input processing
|
|
|
|
|
void (*pfnGetViewAngles)( float *rgflAngles );
|
|
|
|
|
void (*pfnSetViewAngles)( float *rgflAngles );
|
|
|
|
|
void (*pfnCvarSetString)( const char *szName, const char *szValue ); // was GetMaxClients (see gpGlobals->maxClients)
|
2009-12-04 22:00:00 +01:00
|
|
|
|
void (*pfnCvarSetValue)( const char *szName, float flValue );
|
|
|
|
|
|
|
|
|
|
int (*pfnCmdArgc)( void );
|
2009-12-05 22:00:00 +01:00
|
|
|
|
const char* (*pfnCmdArgv)( int argc );
|
|
|
|
|
const char *(*pfnCmd_Args)( void ); // was Con_Printf
|
|
|
|
|
float (*pfnGetLerpFrac)( void ); // was Con_DPrintf
|
|
|
|
|
void (*pfnDelCommand)( const char *cmd_name ); // was Con_NPrintf
|
|
|
|
|
void (*pfnAlertMessage)( ALERT_TYPE, char *szFmt, ... ); // was Con_NXPrintf
|
|
|
|
|
|
|
|
|
|
const char* (*pfnPhysInfo_ValueForKey)( const char *key );
|
|
|
|
|
const char* (*pfnServerInfo_ValueForKey)( const char *key );
|
|
|
|
|
float (*pfnGetClientMaxspeed)( void );
|
|
|
|
|
void* (*pfnGetModelPtr)( edict_t* pEdict ); // was CheckParm
|
|
|
|
|
void (*pfnGetBonePosition)( const edict_t* pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); // was Key_Event
|
|
|
|
|
string_t (*pfnAllocString)( const char *szValue ); // was GetMousePosition
|
|
|
|
|
const char *(*pfnGetString)( string_t iString ); // was IsNoClipping
|
|
|
|
|
|
|
|
|
|
// edict handlers
|
2008-12-25 22:00:00 +01:00
|
|
|
|
edict_t* (*pfnGetLocalPlayer)( void );
|
|
|
|
|
edict_t* (*pfnGetViewModel)( void );
|
2009-12-05 22:00:00 +01:00
|
|
|
|
edict_t* (*pfnGetEntityByIndex)( int idx ); // matched with entity serialnumber
|
2008-12-25 22:00:00 +01:00
|
|
|
|
|
2009-12-05 22:00:00 +01:00
|
|
|
|
float (*pfnGetClientTime)( void ); // can use gpGlobals->time instead
|
2010-06-28 22:00:00 +02:00
|
|
|
|
void (*pfnFadeClientVolume)( float fadePercent, float fadeOutSeconds, float holdTime, float fadeInSeconds ); // was V_CalcShake
|
|
|
|
|
int (*pfnGetAttachment)( const edict_t *pEdict, int iAttachment, float *rgflOrg, float *rgflAng ); // was V_ApplyShake
|
2009-10-15 22:00:00 +02:00
|
|
|
|
|
2010-06-28 22:00:00 +02:00
|
|
|
|
int (*pfnPointContents)( const float *rgflPos, int *truecontents );
|
2009-12-05 22:00:00 +01:00
|
|
|
|
edict_t* (*pfnWaterEntity)( const float *rgflPos );
|
2008-12-25 22:00:00 +01:00
|
|
|
|
void (*pfnTraceLine)( const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr );
|
2009-12-05 22:00:00 +01:00
|
|
|
|
void (*pfnTraceToss)( edict_t* pent, edict_t* pentToIgnore, TraceResult *ptr ); // was CL_LoadModel
|
2009-11-26 22:00:00 +01:00
|
|
|
|
void (*pfnTraceHull)( const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr );
|
2009-12-05 22:00:00 +01:00
|
|
|
|
void (*pfnTraceModel)( const float *v1, const float *v2, edict_t *pent, TraceResult *ptr ); // was GetSpritePointer
|
|
|
|
|
const char *(*pfnTraceTexture)( edict_t *pTextureEntity, const float *v1, const float *v2 ); // was pfnPlaySoundByNameAtLocation
|
|
|
|
|
|
2010-06-23 22:00:00 +02:00
|
|
|
|
word (*pfnPrecacheEvent)( int type, const char* psz );
|
|
|
|
|
void (*pfnPlaybackEvent)( int flags, const edict_t *pInvoker, word eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
|
|
|
|
|
void (*pfnWeaponAnim)( int iAnim, int body, float framerate );
|
|
|
|
|
float (*pfnRandomFloat)( float flLow, float flHigh );
|
|
|
|
|
long (*pfnRandomLong)( long lLow, long lHigh );
|
|
|
|
|
void (*pfnHookEvent)( const char *name, void ( *pfnEvent )( struct event_args_s *args ));
|
|
|
|
|
int (*Con_IsVisible)( void );
|
2009-12-05 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
// dlls managemenet
|
|
|
|
|
void* (*pfnLoadLibrary)( const char *name ); // was pfnGetGameDirectory
|
|
|
|
|
void* (*pfnGetProcAddress)( void *hInstance, const char *name ); // was pfnGetCvarPointer
|
|
|
|
|
void (*pfnFreeLibrary)( void *hInstance ); // was Key_LookupBinding
|
2010-06-28 22:00:00 +02:00
|
|
|
|
void (*pfnHostError)( const char *szFmt, ... ); // was pfnGetLevelName (see gpGlobals->mapname)
|
2009-12-05 22:00:00 +01:00
|
|
|
|
int (*pfnFileExists)( const char *filename ); // was pfnGetScreenFade
|
2010-04-09 22:00:00 +02:00
|
|
|
|
void (*pfnGetGameDir)( char *szGetGameDir ); // was pfnSetScreenFade
|
2009-12-05 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
// vgui handlers
|
|
|
|
|
void* (*VGui_GetPanel)( void ); // UNDONE: wait for version 0.75
|
|
|
|
|
void (*VGui_ViewportPaintBackground)( int extents[4] );
|
|
|
|
|
|
|
|
|
|
// parse txt files
|
|
|
|
|
byte* (*pfnLoadFile)( const char *filename, int *pLength ); // was COM_LoadFile, like it
|
|
|
|
|
char *(*pfnParseToken)( const char **data_p ); // was COM_ParseFile, like it
|
|
|
|
|
void (*pfnFreeFile)( void *buffer ); // was COM_FreeFile, like it
|
|
|
|
|
|
|
|
|
|
struct triapi_s *pTriAPI;
|
|
|
|
|
struct efxapi_s *pEfxAPI;
|
|
|
|
|
struct event_api_s *pEventAPI;
|
2008-12-25 22:00:00 +01:00
|
|
|
|
|
2010-06-28 22:00:00 +02:00
|
|
|
|
int (*pfnIsSpectateOnly)( void );
|
|
|
|
|
int (*pfnIsInGame)( void ); // was LoadMapSprite, return false for menu, console, etc
|
2010-03-17 22:00:00 +01:00
|
|
|
|
|
2008-12-25 22:00:00 +01:00
|
|
|
|
} cl_enginefuncs_t;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
int (*pfnVidInit)( void );
|
|
|
|
|
void (*pfnInit)( void );
|
2008-12-26 22:00:00 +01:00
|
|
|
|
int (*pfnRedraw)( float flTime, int state );
|
2010-03-14 22:00:00 +01:00
|
|
|
|
void (*pfnUpdateEntityVars)( edict_t *out, const struct entity_state_s *in1, const struct entity_state_s *in2 );
|
2010-06-28 22:00:00 +02:00
|
|
|
|
void (*pfnUpdateClientVars)( struct entity_state_s *state, const struct clientdata_s *client );
|
2010-03-10 22:00:00 +01:00
|
|
|
|
void (*pfnOnFreeEntPrivateData)( edict_t *pEnt ); // this is called on entity removed
|
2008-12-25 22:00:00 +01:00
|
|
|
|
void (*pfnReset)( void );
|
2010-03-09 22:00:00 +01:00
|
|
|
|
void (*pfnStartFrame)( void );
|
2008-12-25 22:00:00 +01:00
|
|
|
|
void (*pfnFrame)( double time );
|
|
|
|
|
void (*pfnShutdown)( void );
|
2009-12-05 22:00:00 +01:00
|
|
|
|
void (*pfnDrawTriangles)( int fTrans );
|
2008-12-25 22:00:00 +01:00
|
|
|
|
void (*pfnCreateEntities)( void );
|
2010-03-14 22:00:00 +01:00
|
|
|
|
int (*pfnAddVisibleEntity)( edict_t *pEnt, int ed_type );
|
2008-12-25 22:00:00 +01:00
|
|
|
|
void (*pfnStudioEvent)( const dstudioevent_t *event, edict_t *entity );
|
2009-09-17 22:00:00 +02:00
|
|
|
|
void (*pfnStudioFxTransform)( edict_t *pEdict, float transform[4][4] );
|
2009-09-13 22:00:00 +02:00
|
|
|
|
void (*pfnCalcRefdef)( ref_params_t *parms );
|
2009-12-05 22:00:00 +01:00
|
|
|
|
void (*pfnPM_Move)( playermove_t *ppmove, int server );
|
|
|
|
|
void (*pfnPM_Init)( playermove_t *ppmove );
|
|
|
|
|
char (*pfnPM_FindTextureType)( const char *name );
|
|
|
|
|
void (*pfnCmdStart)( const edict_t *player, int runfuncs );
|
|
|
|
|
void (*pfnCmdEnd)( const edict_t *player, const usercmd_t *cmd, unsigned int random_seed );
|
2010-06-18 22:00:00 +02:00
|
|
|
|
void (*pfnCreateMove)( usercmd_t *cmd, int active );
|
2009-12-05 22:00:00 +01:00
|
|
|
|
void (*pfnMouseEvent)( int mx, int my );
|
|
|
|
|
int (*pfnKeyEvent)( int down, int keynum, const char *pszBind );
|
|
|
|
|
void (*VGui_ConsolePrint)( const char *text );
|
2008-12-25 22:00:00 +01:00
|
|
|
|
} HUD_FUNCTIONS;
|
|
|
|
|
|
2009-09-28 22:00:00 +02:00
|
|
|
|
typedef int (*CLIENTAPI)( HUD_FUNCTIONS *pFunctionTable, cl_enginefuncs_t* engfuncs, cl_globalvars_t *pGlobals );
|
2008-12-25 22:00:00 +01:00
|
|
|
|
|
|
|
|
|
#endif//CLGAME_API_H
|