diff --git a/dep/metamod/dllapi.h b/dep/metamod/dllapi.h index 02431d6..1563be0 100644 --- a/dep/metamod/dllapi.h +++ b/dep/metamod/dllapi.h @@ -1,189 +1,189 @@ -// dllapi.h - prototypes and typedefs for Half-Life DLL API routines - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef DLLAPI_H -#define DLLAPI_H - -#include "sdk_util.h" // BOOL -#include "osdep.h" // DLLEXPORT, etc - -// Typedefs for these are provided in SDK engine/eiface.h, but I didn't -// like the names (APIFUNCTION, APIFUNCTION2, NEW_DLL_FUNCTIONS_FN). -typedef int (*GETENTITYAPI_FN) (DLL_FUNCTIONS *pFunctionTable, int interfaceVersion); -typedef int (*GETENTITYAPI2_FN) (DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion); -typedef int (*GETNEWDLLFUNCTIONS_FN) (NEW_DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion); - -// From SDK dlls/cbase.h: -C_DLLEXPORT int GetEntityAPI( DLL_FUNCTIONS *pFunctionTable, int interfaceVersion ); -C_DLLEXPORT int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ); - -// No example in SDK.. -// From Adminmod dll.cpp: -C_DLLEXPORT int GetNewDLLFunctions( NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion ); - - -// From SDK dlls/game.h: -extern void mm_GameDLLInit( void ); - -// From SDK dlls/cbase.h: -extern int mm_DispatchSpawn( edict_t *pent ); -extern void mm_DispatchThink( edict_t *pent ); -extern void mm_DispatchUse( edict_t *pentUsed, edict_t *pentOther ); -extern void mm_DispatchTouch( edict_t *pentTouched, edict_t *pentOther ); -extern void mm_DispatchBlocked( edict_t *pentBlocked, edict_t *pentOther ); -extern void mm_DispatchKeyValue( edict_t *pentKeyvalue, KeyValueData *pkvd ); -extern void mm_DispatchSave( edict_t *pent, SAVERESTOREDATA *pSaveData ); -extern int mm_DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ); -extern void mm_DispatchObjectCollisionBox( edict_t *pent ); -extern void mm_SaveWriteFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); -extern void mm_SaveReadFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); -extern void mm_SaveGlobalState( SAVERESTOREDATA *pSaveData ); -extern void mm_RestoreGlobalState( SAVERESTOREDATA *pSaveData ); -extern void mm_ResetGlobalState( void ); - -// From SDK dlls/client.h: -extern BOOL mm_ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); -extern void mm_ClientDisconnect( edict_t *pEntity ); -extern void mm_ClientKill( edict_t *pEntity ); -extern void mm_ClientPutInServer( edict_t *pEntity ); -extern void mm_ClientCommand( edict_t *pEntity ); -extern void mm_ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ); -extern void mm_ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ); -extern void mm_ServerDeactivate( void ); -extern void mm_PlayerPreThink( edict_t *pEntity ); -extern void mm_PlayerPostThink( edict_t *pEntity ); -extern void mm_StartFrame( void ); -extern void mm_ParmsNewLevel( void ); -extern void mm_ParmsChangeLevel( void ); -extern const char *mm_GetGameDescription( void ); -extern void mm_PlayerCustomization( edict_t *pEntity, customization_t *pCust ); -extern void mm_SpectatorConnect ( edict_t *pEntity ); -extern void mm_SpectatorDisconnect ( edict_t *pEntity ); -extern void mm_SpectatorThink ( edict_t *pEntity ); -extern void mm_Sys_Error( const char *error_string ); - -// From SDK pm_shared/pm_shared.h: -extern void mm_PM_Move ( struct playermove_s *ppmove, int server ); -extern void mm_PM_Init ( struct playermove_s *ppmove ); -extern char mm_PM_FindTextureType ( char *name ); - -// From SDK dlls/client.h: -extern void mm_SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas ); -extern void mm_UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); -extern int mm_AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); -extern void mm_CreateBaseline( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ); -extern void mm_RegisterEncoders( void ); -extern int mm_GetWeaponData( struct edict_s *player, struct weapon_data_s *info ); -extern void mm_CmdStart( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ); -extern void mm_CmdEnd ( const edict_t *player ); -extern int mm_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); -extern int mm_GetHullBounds( int hullnumber, float *mins, float *maxs ); -extern void mm_CreateInstancedBaselines ( void ); -extern int mm_InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message ); -extern int mm_AllowLagCompensation( void ); - -// No example from SDK... -extern void mm_OnFreeEntPrivateData(edict_t pEnt); -extern void mm_GameShutdown(void); -extern int mm_ShouldCollide(edict_t *pentTouched, edict_t *pentOther); -//Added 2005-08-11 (no SDK update) -extern void mm_CvarValue(const edict_t *pEnt, const char *value); //! Obsolete! Use mm_CvarValue2 instead -//Added 2005-11-22 (no SDK update) -extern void mm_CvarValue2(const edict_t *pEnt, int requestID, const char *cvarName, const char *value); - - -// Typedefs for the above functions: - -typedef void (*FN_GAMEINIT) ( void ); -typedef int (*FN_DISPATCHSPAWN) ( edict_t *pent ); -typedef void (*FN_DISPATCHTHINK) ( edict_t *pent ); -typedef void (*FN_DISPATCHUSE) ( edict_t *pentUsed, edict_t *pentOther ); -typedef void (*FN_DISPATCHTOUCH) ( edict_t *pentTouched, edict_t *pentOther ); -typedef void (*FN_DISPATCHBLOCKED) ( edict_t *pentBlocked, edict_t *pentOther ); -typedef void (*FN_DISPATCHKEYVALUE) ( edict_t *pentKeyvalue, KeyValueData *pkvd ); -typedef void (*FN_DISPATCHSAVE) ( edict_t *pent, SAVERESTOREDATA *pSaveData ); -typedef int (*FN_DISPATCHRESTORE) ( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ); -typedef void (*FN_DISPATCHOBJECTCOLLISIONBOX) ( edict_t *pent ); -typedef void (*FN_SAVEWRITEFIELDS) ( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); -typedef void (*FN_SAVEREADFIELDS) ( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); -typedef void (*FN_SAVEGLOBALSTATE) ( SAVERESTOREDATA *pSaveData ); -typedef void (*FN_RESTOREGLOBALSTATE) ( SAVERESTOREDATA *pSaveData ); -typedef void (*FN_RESETGLOBALSTATE) ( void ); - -typedef BOOL (*FN_CLIENTCONNECT) ( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); -typedef void (*FN_CLIENTDISCONNECT) ( edict_t *pEntity ); -typedef void (*FN_CLIENTKILL) ( edict_t *pEntity ); -typedef void (*FN_CLIENTPUTINSERVER) ( edict_t *pEntity ); -typedef void (*FN_CLIENTCOMMAND) ( edict_t *pEntity ); -typedef void (*FN_CLIENTUSERINFOCHANGED) ( edict_t *pEntity, char *infobuffer ); -typedef void (*FN_SERVERACTIVATE) ( edict_t *pEdictList, int edictCount, int clientMax ); -typedef void (*FN_SERVERDEACTIVATE) ( void ); -typedef void (*FN_PLAYERPRETHINK) ( edict_t *pEntity ); -typedef void (*FN_PLAYERPOSTTHINK) ( edict_t *pEntity ); -typedef void (*FN_STARTFRAME) ( void ); -typedef void (*FN_PARMSNEWLEVEL) ( void ); -typedef void (*FN_PARMSCHANGELEVEL) ( void ); -typedef const char *(*FN_GETGAMEDESCRIPTION) ( void ); -typedef void (*FN_PLAYERCUSTOMIZATION) ( edict_t *pEntity, customization_t *pCust ); -typedef void (*FN_SPECTATORCONNECT) ( edict_t *pEntity ); -typedef void (*FN_SPECTATORDISCONNECT) ( edict_t *pEntity ); -typedef void (*FN_SPECTATORTHINK) ( edict_t *pEntity ); -typedef void (*FN_SYS_ERROR) ( const char *error_string ); - -typedef void (*FN_PM_MOVE) ( struct playermove_s *ppmove, int server ); -typedef void (*FN_PM_INIT) ( struct playermove_s *ppmove ); -typedef char (*FN_PM_FINDTEXTURETYPE) ( char *name ); - -typedef void (*FN_SETUPVISIBILITY) ( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas ); -typedef void (*FN_UPDATECLIENTDATA) ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); -typedef int (*FN_ADDTOFULLPACK) ( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); -typedef void (*FN_CREATEBASELINE) ( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ); -typedef void (*FN_REGISTERENCODERS) ( void ); -typedef int (*FN_GETWEAPONDATA) ( struct edict_s *player, struct weapon_data_s *info ); -typedef void (*FN_CMDSTART) ( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ); -typedef void (*FN_CMDEND) ( const edict_t *player ); -typedef int (*FN_CONNECTIONLESSPACKET) ( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); -typedef int (*FN_GETHULLBOUNDS) ( int hullnumber, float *mins, float *maxs ); -typedef void (*FN_CREATEINSTANCEDBASELINES) ( void ); -typedef int (*FN_INCONSISTENTFILE) ( const edict_t *player, const char *filename, char *disconnect_message ); -typedef int (*FN_ALLOWLAGCOMPENSATION) ( void ); - -typedef void (*FN_ONFREEENTPRIVATEDATA) (edict_t *pEnt); -typedef void (*FN_GAMESHUTDOWN) (void); -typedef int (*FN_SHOULDCOLLIDE) (edict_t *pentTouched, edict_t *pentOther); -//Added 2005-08-11 (no SDK update) -typedef void (*FN_CVARVALUE)(const edict_t *pEnt, const char *value); //! Obsolete! Use FN_CVARVALUE2 instead -//Added 2005-11-22 (no SDK update) -typedef void (*FN_CVARVALUE2)(const edict_t *pEnt, int requestID, const char *cvarName, const char *value); - -#endif /* DLLAPI_H */ +// dllapi.h - prototypes and typedefs for Half-Life DLL API routines + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef DLLAPI_H +#define DLLAPI_H + +#include "sdk_util.h" // BOOL +#include "osdep.h" // DLLEXPORT, etc + +// Typedefs for these are provided in SDK engine/eiface.h, but I didn't +// like the names (APIFUNCTION, APIFUNCTION2, NEW_DLL_FUNCTIONS_FN). +typedef int (*GETENTITYAPI_FN) (DLL_FUNCTIONS *pFunctionTable, int interfaceVersion); +typedef int (*GETENTITYAPI2_FN) (DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion); +typedef int (*GETNEWDLLFUNCTIONS_FN) (NEW_DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion); + +// From SDK dlls/cbase.h: +C_DLLEXPORT int GetEntityAPI( DLL_FUNCTIONS *pFunctionTable, int interfaceVersion ); +C_DLLEXPORT int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ); + +// No example in SDK.. +// From Adminmod dll.cpp: +C_DLLEXPORT int GetNewDLLFunctions( NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion ); + + +// From SDK dlls/game.h: +extern void mm_GameDLLInit( void ); + +// From SDK dlls/cbase.h: +extern int mm_DispatchSpawn( edict_t *pent ); +extern void mm_DispatchThink( edict_t *pent ); +extern void mm_DispatchUse( edict_t *pentUsed, edict_t *pentOther ); +extern void mm_DispatchTouch( edict_t *pentTouched, edict_t *pentOther ); +extern void mm_DispatchBlocked( edict_t *pentBlocked, edict_t *pentOther ); +extern void mm_DispatchKeyValue( edict_t *pentKeyvalue, KeyValueData *pkvd ); +extern void mm_DispatchSave( edict_t *pent, SAVERESTOREDATA *pSaveData ); +extern int mm_DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ); +extern void mm_DispatchObjectCollisionBox( edict_t *pent ); +extern void mm_SaveWriteFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); +extern void mm_SaveReadFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); +extern void mm_SaveGlobalState( SAVERESTOREDATA *pSaveData ); +extern void mm_RestoreGlobalState( SAVERESTOREDATA *pSaveData ); +extern void mm_ResetGlobalState( void ); + +// From SDK dlls/client.h: +extern BOOL mm_ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); +extern void mm_ClientDisconnect( edict_t *pEntity ); +extern void mm_ClientKill( edict_t *pEntity ); +extern void mm_ClientPutInServer( edict_t *pEntity ); +extern void mm_ClientCommand( edict_t *pEntity ); +extern void mm_ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ); +extern void mm_ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ); +extern void mm_ServerDeactivate( void ); +extern void mm_PlayerPreThink( edict_t *pEntity ); +extern void mm_PlayerPostThink( edict_t *pEntity ); +extern void mm_StartFrame( void ); +extern void mm_ParmsNewLevel( void ); +extern void mm_ParmsChangeLevel( void ); +extern const char *mm_GetGameDescription( void ); +extern void mm_PlayerCustomization( edict_t *pEntity, customization_t *pCust ); +extern void mm_SpectatorConnect ( edict_t *pEntity ); +extern void mm_SpectatorDisconnect ( edict_t *pEntity ); +extern void mm_SpectatorThink ( edict_t *pEntity ); +extern void mm_Sys_Error( const char *error_string ); + +// From SDK pm_shared/pm_shared.h: +extern void mm_PM_Move ( struct playermove_s *ppmove, int server ); +extern void mm_PM_Init ( struct playermove_s *ppmove ); +extern char mm_PM_FindTextureType ( char *name ); + +// From SDK dlls/client.h: +extern void mm_SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas ); +extern void mm_UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); +extern int mm_AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); +extern void mm_CreateBaseline( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ); +extern void mm_RegisterEncoders( void ); +extern int mm_GetWeaponData( struct edict_s *player, struct weapon_data_s *info ); +extern void mm_CmdStart( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ); +extern void mm_CmdEnd ( const edict_t *player ); +extern int mm_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); +extern int mm_GetHullBounds( int hullnumber, float *mins, float *maxs ); +extern void mm_CreateInstancedBaselines ( void ); +extern int mm_InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message ); +extern int mm_AllowLagCompensation( void ); + +// No example from SDK... +extern void mm_OnFreeEntPrivateData(edict_t pEnt); +extern void mm_GameShutdown(void); +extern int mm_ShouldCollide(edict_t *pentTouched, edict_t *pentOther); +//Added 2005-08-11 (no SDK update) +extern void mm_CvarValue(const edict_t *pEnt, const char *value); //! Obsolete! Use mm_CvarValue2 instead +//Added 2005-11-22 (no SDK update) +extern void mm_CvarValue2(const edict_t *pEnt, int requestID, const char *cvarName, const char *value); + + +// Typedefs for the above functions: + +typedef void (*FN_GAMEINIT) ( void ); +typedef int (*FN_DISPATCHSPAWN) ( edict_t *pent ); +typedef void (*FN_DISPATCHTHINK) ( edict_t *pent ); +typedef void (*FN_DISPATCHUSE) ( edict_t *pentUsed, edict_t *pentOther ); +typedef void (*FN_DISPATCHTOUCH) ( edict_t *pentTouched, edict_t *pentOther ); +typedef void (*FN_DISPATCHBLOCKED) ( edict_t *pentBlocked, edict_t *pentOther ); +typedef void (*FN_DISPATCHKEYVALUE) ( edict_t *pentKeyvalue, KeyValueData *pkvd ); +typedef void (*FN_DISPATCHSAVE) ( edict_t *pent, SAVERESTOREDATA *pSaveData ); +typedef int (*FN_DISPATCHRESTORE) ( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ); +typedef void (*FN_DISPATCHOBJECTCOLLISIONBOX) ( edict_t *pent ); +typedef void (*FN_SAVEWRITEFIELDS) ( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); +typedef void (*FN_SAVEREADFIELDS) ( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); +typedef void (*FN_SAVEGLOBALSTATE) ( SAVERESTOREDATA *pSaveData ); +typedef void (*FN_RESTOREGLOBALSTATE) ( SAVERESTOREDATA *pSaveData ); +typedef void (*FN_RESETGLOBALSTATE) ( void ); + +typedef BOOL (*FN_CLIENTCONNECT) ( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); +typedef void (*FN_CLIENTDISCONNECT) ( edict_t *pEntity ); +typedef void (*FN_CLIENTKILL) ( edict_t *pEntity ); +typedef void (*FN_CLIENTPUTINSERVER) ( edict_t *pEntity ); +typedef void (*FN_CLIENTCOMMAND) ( edict_t *pEntity ); +typedef void (*FN_CLIENTUSERINFOCHANGED) ( edict_t *pEntity, char *infobuffer ); +typedef void (*FN_SERVERACTIVATE) ( edict_t *pEdictList, int edictCount, int clientMax ); +typedef void (*FN_SERVERDEACTIVATE) ( void ); +typedef void (*FN_PLAYERPRETHINK) ( edict_t *pEntity ); +typedef void (*FN_PLAYERPOSTTHINK) ( edict_t *pEntity ); +typedef void (*FN_STARTFRAME) ( void ); +typedef void (*FN_PARMSNEWLEVEL) ( void ); +typedef void (*FN_PARMSCHANGELEVEL) ( void ); +typedef const char *(*FN_GETGAMEDESCRIPTION) ( void ); +typedef void (*FN_PLAYERCUSTOMIZATION) ( edict_t *pEntity, customization_t *pCust ); +typedef void (*FN_SPECTATORCONNECT) ( edict_t *pEntity ); +typedef void (*FN_SPECTATORDISCONNECT) ( edict_t *pEntity ); +typedef void (*FN_SPECTATORTHINK) ( edict_t *pEntity ); +typedef void (*FN_SYS_ERROR) ( const char *error_string ); + +typedef void (*FN_PM_MOVE) ( struct playermove_s *ppmove, int server ); +typedef void (*FN_PM_INIT) ( struct playermove_s *ppmove ); +typedef char (*FN_PM_FINDTEXTURETYPE) ( char *name ); + +typedef void (*FN_SETUPVISIBILITY) ( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas ); +typedef void (*FN_UPDATECLIENTDATA) ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); +typedef int (*FN_ADDTOFULLPACK) ( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); +typedef void (*FN_CREATEBASELINE) ( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ); +typedef void (*FN_REGISTERENCODERS) ( void ); +typedef int (*FN_GETWEAPONDATA) ( struct edict_s *player, struct weapon_data_s *info ); +typedef void (*FN_CMDSTART) ( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ); +typedef void (*FN_CMDEND) ( const edict_t *player ); +typedef int (*FN_CONNECTIONLESSPACKET) ( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); +typedef int (*FN_GETHULLBOUNDS) ( int hullnumber, float *mins, float *maxs ); +typedef void (*FN_CREATEINSTANCEDBASELINES) ( void ); +typedef int (*FN_INCONSISTENTFILE) ( const edict_t *player, const char *filename, char *disconnect_message ); +typedef int (*FN_ALLOWLAGCOMPENSATION) ( void ); + +typedef void (*FN_ONFREEENTPRIVATEDATA) (edict_t *pEnt); +typedef void (*FN_GAMESHUTDOWN) (void); +typedef int (*FN_SHOULDCOLLIDE) (edict_t *pentTouched, edict_t *pentOther); +//Added 2005-08-11 (no SDK update) +typedef void (*FN_CVARVALUE)(const edict_t *pEnt, const char *value); //! Obsolete! Use FN_CVARVALUE2 instead +//Added 2005-11-22 (no SDK update) +typedef void (*FN_CVARVALUE2)(const edict_t *pEnt, int requestID, const char *cvarName, const char *value); + +#endif /* DLLAPI_H */ diff --git a/dep/metamod/engine_api.h b/dep/metamod/engine_api.h index 9076bc3..3e46d28 100644 --- a/dep/metamod/engine_api.h +++ b/dep/metamod/engine_api.h @@ -1,461 +1,461 @@ -// engine_api.h - prototypes and typedefs for Half-Life engine functions - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef ENGINE_API_H -#define ENGINE_API_H - -#include - -// Plugin's GetEngineFunctions, called by metamod. -typedef int (*GET_ENGINE_FUNCTIONS_FN) (enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion); - -// According to SDK engine/eiface.h: -//! enginefuncs_t -//! ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 138 -#define ENGINE_INTERFACE_VERSION 138 - -// Protect against other projects which use this include file but use the -// normal enginefuncs_t type for their meta_engfuncs. -#ifdef METAMOD_CORE -# include "meta_eiface.h" // meta_enginefuncs_t -extern meta_enginefuncs_t meta_engfuncs; -#else -extern enginefuncs_t meta_engfuncs; -#endif - -// From SDK engine/eiface.h: -extern int mm_PrecacheModel(char *s); -extern int mm_PrecacheSound(char *s); -extern void mm_SetModel(edict_t *e, const char *m); -extern int mm_ModelIndex(const char *m); -extern int mm_ModelFrames(int modelIndex); - -extern void mm_SetSize(edict_t *e, const float *rgflMin, const float *rgflMax); -extern void mm_ChangeLevel(char *s1, char *s2); -extern void mm_GetSpawnParms(edict_t *ent); -extern void mm_SaveSpawnParms(edict_t *ent); - -extern float mm_VecToYaw(const float *rgflVector); -extern void mm_VecToAngles(const float *rgflVectorIn, float *rgflVectorOut); -extern void mm_MoveToOrigin(edict_t *ent, const float *pflGoal, float dist, int iMoveType); -extern void mm_ChangeYaw(edict_t *ent); -extern void mm_ChangePitch(edict_t *ent); - -extern edict_t *mm_FindEntityByString(edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue); -extern int mm_GetEntityIllum(edict_t *pEnt); -extern edict_t *mm_FindEntityInSphere(edict_t *pEdictStartSearchAfter, const float *org, float rad); -extern edict_t *mm_FindClientInPVS(edict_t *pEdict); -extern edict_t *mm_EntitiesInPVS(edict_t *pplayer); - -extern void mm_MakeVectors(const float *rgflVector); -extern void mm_AngleVectors(const float *rgflVector, float *forward, float *right, float *up); - -extern edict_t *mm_CreateEntity(void); -extern void mm_RemoveEntity(edict_t *e); -extern edict_t *mm_CreateNamedEntity(int className); - -extern void mm_MakeStatic(edict_t *ent); -extern int mm_EntIsOnFloor(edict_t *e); -extern int mm_DropToFloor(edict_t *e); - -extern int mm_WalkMove(edict_t *ent, float yaw, float dist, int iMode); -extern void mm_SetOrigin(edict_t *e, const float *rgflOrigin); - -extern void mm_EmitSound(edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch); -extern void mm_EmitAmbientSound(edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch); - -extern void mm_TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); -extern void mm_TraceToss(edict_t *pent, edict_t *pentToIgnore, TraceResult *ptr); -extern int mm_TraceMonsterHull(edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); -extern void mm_TraceHull(const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr); -extern void mm_TraceModel(const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr); -extern const char *mm_TraceTexture(edict_t *pTextureEntity, const float *v1, const float *v2 ); -extern void mm_TraceSphere(const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr); -extern void mm_GetAimVector(edict_t *ent, float speed, float *rgflReturn); - -extern void mm_ServerCommand(char *str); -extern void mm_ServerExecute(void); -extern void ClientCommand(edict_t *pEdict, char *szFmt, ...); - -extern void mm_ParticleEffect(const float *org, const float *dir, float color, float count); -extern void mm_LightStyle(int style, char *val); -extern int mm_DecalIndex(const char *name); -extern int mm_PointContents(const float *rgflVector); - -extern void mm_MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); -extern void mm_MessageEnd(void); - -extern void mm_WriteByte(int iValue); -extern void mm_WriteChar(int iValue); -extern void mm_WriteShort(int iValue); -extern void mm_WriteLong(int iValue); -extern void mm_WriteAngle(float flValue); -extern void mm_WriteCoord(float flValue); -extern void mm_WriteString(const char *sz); -extern void mm_WriteEntity(int iValue); - -extern void mm_CVarRegister(cvar_t *pCvar); -extern float mm_CVarGetFloat(const char *szVarName); -extern const char* mm_CVarGetString(const char *szVarName); -extern void mm_CVarSetFloat(const char *szVarName, float flValue); -extern void mm_CVarSetString(const char *szVarName, const char *szValue); - -extern void mm_AlertMessage(ALERT_TYPE atype, char *szFmt, ...); -#ifdef HLSDK_3_2_OLD_EIFACE -extern void mm_EngineFprintf(FILE *pfile, char *szFmt, ...); -#else -extern void mm_EngineFprintf(void *pfile, char *szFmt, ...); -#endif - -#ifdef HLSDK_3_2_OLD_EIFACE -extern void *mm_PvAllocEntPrivateData(edict_t *pEdict, long cb); -#else -extern void *mm_PvAllocEntPrivateData(edict_t *pEdict, int32 cb); -#endif -extern void *mm_PvEntPrivateData(edict_t *pEdict); -extern void mm_FreeEntPrivateData(edict_t *pEdict); - -extern const char *mm_SzFromIndex(int iString); -extern int mm_AllocString(const char *szValue); - -extern struct entvars_s *mm_GetVarsOfEnt(edict_t *pEdict); -extern edict_t *mm_PEntityOfEntOffset(int iEntOffset); -extern int mm_EntOffsetOfPEntity(const edict_t *pEdict); -extern int mm_IndexOfEdict(const edict_t *pEdict); -extern edict_t *mm_PEntityOfEntIndex(int iEntIndex); -extern edict_t *mm_FindEntityByVars(struct entvars_s *pvars); -extern void *mm_GetModelPtr(edict_t *pEdict); - -extern int mm_RegUserMsg(const char *pszName, int iSize); - -extern void mm_AnimationAutomove(const edict_t *pEdict, float flTime); -extern void mm_GetBonePosition(const edict_t *pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); - -#ifdef HLSDK_3_2_OLD_EIFACE -extern unsigned long mm_FunctionFromName( const char *pName ); -extern const char *mm_NameForFunction( unsigned long function ); -#else -extern uint32 mm_FunctionFromName( const char *pName ); -extern const char *mm_NameForFunction( uint32 function ); -#endif - -extern void mm_ClientPrintf( edict_t *pEdict, PRINT_TYPE ptype, const char *szMsg ); //! JOHN: engine callbacks so game DLL can print messages to individual clients -extern void mm_ServerPrint( const char *szMsg ); - -extern const char *mm_Cmd_Args( void ); //! these 3 added -extern const char *mm_Cmd_Argv( int argc ); //! so game DLL can easily -extern int mm_Cmd_Argc( void ); //! access client 'cmd' strings - -extern void mm_GetAttachment(const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles ); - -extern void mm_CRC32_Init(CRC32_t *pulCRC); -extern void mm_CRC32_ProcessBuffer(CRC32_t *pulCRC, void *p, int len); -extern void mm_CRC32_ProcessByte(CRC32_t *pulCRC, unsigned char ch); -extern CRC32_t mm_CRC32_Final(CRC32_t pulCRC); - -#ifdef HLSDK_3_2_OLD_EIFACE -extern long mm_RandomLong(long lLow, long lHigh); -#else -extern int32 mm_RandomLong(int32 lLow, int32 lHigh); -#endif -extern float mm_RandomFloat(float flLow, float flHigh); - -extern void mm_SetView(const edict_t *pClient, const edict_t *pViewent ); -extern float mm_Time( void ); -extern void mm_CrosshairAngle(const edict_t *pClient, float pitch, float yaw); - -extern byte * mm_LoadFileForMe(char *filename, int *pLength); -extern void mm_FreeFile(void *buffer); - -extern void mm_EndSection(const char *pszSectionName); //! trigger_endsection -extern int mm_CompareFileTime(char *filename1, char *filename2, int *iCompare); -extern void mm_GetGameDir(char *szGetGameDir); -extern void mm_Cvar_RegisterVariable(cvar_t *variable); -extern void mm_FadeClientVolume(const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds); -extern void mm_SetClientMaxspeed(const edict_t *pEdict, float fNewMaxspeed); -extern edict_t * mm_CreateFakeClient(const char *netname); //! returns NULL if fake client can't be created -extern void mm_RunPlayerMove(edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); -extern int mm_NumberOfEntities(void); - -extern char *mm_GetInfoKeyBuffer(edict_t *e); //! passing in NULL gets the serverinfo -extern char *mm_InfoKeyValue(char *infobuffer, char *key); -extern void mm_SetKeyValue(char *infobuffer, char *key, char *value); -extern void mm_SetClientKeyValue(int clientIndex, char *infobuffer, char *key, char *value); - -extern int mm_IsMapValid(char *filename); -extern void mm_StaticDecal( const float *origin, int decalIndex, int entityIndex, int modelIndex ); -extern int mm_PrecacheGeneric(char *s); -extern int mm_GetPlayerUserId(edict_t *e ); //! returns the server assigned userid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients -extern void mm_BuildSoundMsg(edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); -extern int mm_IsDedicatedServer(void);//! is this a dedicated server? -extern cvar_t *mm_CVarGetPointer(const char *szVarName); -extern unsigned int mm_GetPlayerWONId(edict_t *e); //! returns the server assigned WONid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients - -//! YWB 8/1/99 TFF Physics additions -extern void mm_Info_RemoveKey( char *s, const char *key ); -extern const char *mm_GetPhysicsKeyValue( const edict_t *pClient, const char *key ); -extern void mm_SetPhysicsKeyValue( const edict_t *pClient, const char *key, const char *value ); -extern const char *mm_GetPhysicsInfoString( const edict_t *pClient ); -extern unsigned short mm_PrecacheEvent( int type, const char *psz ); -extern void mm_PlaybackEvent( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); - -extern unsigned char *mm_SetFatPVS( float *org ); -extern unsigned char *mm_SetFatPAS( float *org ); - -extern int mm_CheckVisibility( const edict_t *entity, unsigned char *pset ); - -extern void mm_DeltaSetField( struct delta_s *pFields, const char *fieldname ); -extern void mm_DeltaUnsetField( struct delta_s *pFields, const char *fieldname ); -extern void mm_DeltaAddEncoder( char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); -extern int mm_GetCurrentPlayer( void ); -extern int mm_CanSkipPlayer( const edict_t *player ); -extern int mm_DeltaFindField( struct delta_s *pFields, const char *fieldname ); -extern void mm_DeltaSetFieldByIndex( struct delta_s *pFields, int fieldNumber ); -extern void mm_DeltaUnsetFieldByIndex( struct delta_s *pFields, int fieldNumber ); - -extern void mm_SetGroupMask( int mask, int op ); - -extern int CreateInstancedBaseline( int classname, struct entity_state_s *baseline ); -extern void mm_Cvar_DirectSet( struct cvar_s *var, char *value ); - -//! Forces the client and server to be running with the same version of the specified file -//!( e.g., a player model ). -//! Calling this has no effect in single player -extern void mm_ForceUnmodified( FORCE_TYPE type, float *mins, float *maxs, const char *filename ); - -extern void mm_GetPlayerStats( const edict_t *pClient, int *ping, int *packet_loss ); - -extern void mm_AddServerCommand( char *cmd_name, void (*function) (void) ); -// Added in SDK 2.2: -extern qboolean mm_Voice_GetClientListening(int iReceiver, int iSender); -extern qboolean mm_Voice_SetClientListening(int iReceiver, int iSender, qboolean bListen); -// Added for HL 1109 (no SDK update): -extern const char *mm_pfnGetPlayerAuthId(edict_t *e); -// Added 2003-11-10 (no SDK update): -extern sequenceEntry_s * mm_SequenceGet(const char* fileName, const char* entryName); -extern sentenceEntry_s * mm_SequencePickSentence(const char* groupName, int pickMethod, int *picked); -extern int mm_GetFileSize(char *filename); -extern unsigned int mm_GetApproxWavePlayLen(const char *filepath); -extern int mm_IsCareerMatch(void); -extern int mm_GetLocalizedStringLength(const char *label); -extern void mm_RegisterTutorMessageShown(int mid); -extern int mm_GetTimesTutorMessageShown(int mid); -extern void mm_ProcessTutorMessageDecayBuffer(int *buffer, int bufferLength); -extern void mm_ConstructTutorMessageDecayBuffer(int *buffer, int bufferLength); -extern void mm_ResetTutorMessageDecayData(void); -//Added 2005-08-11 (no SDK update) -extern void mm_QueryClientCvarValue(const edict_t *pEdict, const char *cvarName); //! Obsolete! Use mm_QueryClientCvarValue2 instead -//Added 2005-11-22 (no SDK update) -extern void mm_QueryClientCvarValue2(const edict_t *pEdict, const char *cvarName, int requestID); - - -// Typedefs for the above functions: - -typedef int (*FN_PRECACHEMODEL) (char* s); -typedef int (*FN_PRECACHESOUND) (char* s); -typedef void (*FN_SETMODEL) (edict_t *e, const char *m); -typedef int (*FN_MODELINDEX) (const char *m); -typedef int (*FN_MODELFRAMES) (int modelIndex); -typedef void (*FN_SETSIZE) (edict_t *e, const float *rgflMin, const float *rgflMax); -typedef void (*FN_CHANGELEVEL) (char *s1, char *s2); -typedef void (*FN_GETSPAWNPARMS) (edict_t *ent); -typedef void (*FN_SAVESPAWNPARMS) (edict_t *ent); -typedef float (*FN_VECTOYAW) (const float *rgflVector); -typedef void (*FN_VECTOANGLES) (const float *rgflVectorIn, float *rgflVectorOut); -typedef void (*FN_MOVETOORIGIN) (edict_t *ent, const float *pflGoal, float dist, int iMoveType); -typedef void (*FN_CHANGEYAW) (edict_t *ent); -typedef void (*FN_CHANGEPITCH) (edict_t *ent); -typedef edict_t * (*FN_FINDENTITYBYSTRING) (edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue); -typedef int (*FN_GETENTITYILLUM) (edict_t *pEnt); -typedef edict_t * (*FN_FINDENTITYINSPHERE) (edict_t *pEdictStartSearchAfter, const float *org, float rad); -typedef edict_t * (*FN_FINDCLIENTINPVS) (edict_t *pEdict); -typedef edict_t * (*FN_ENTITIESINPVS) (edict_t *pplayer); -typedef void (*FN_MAKEVECTORS) (const float *rgflVector); -typedef void (*FN_ANGLEVECTORS) (const float *rgflVector, float *forward, float *right, float *up); -typedef edict_t * (*FN_CREATEENTITY) (void); -typedef void (*FN_REMOVEENTITY) (edict_t *e); -typedef edict_t * (*FN_CREATENAMEDENTITY) (int className); -typedef void (*FN_MAKESTATIC) (edict_t *ent); -typedef int (*FN_ENTISONFLOOR) (edict_t *e); -typedef int (*FN_DROPTOFLOOR) (edict_t *e); -typedef int (*FN_WALKMOVE) (edict_t *ent, float yaw, float dist, int iMode); -typedef void (*FN_SETORIGIN) (edict_t *e, const float *rgflOrigin); -typedef void (*FN_EMITSOUND) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch); -typedef void (*FN_EMITAMBIENTSOUND) (edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch); -typedef void (*FN_TRACELINE) (const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); -typedef void (*FN_TRACETOSS) (edict_t *pent, edict_t *pentToIgnore, TraceResult *ptr); -typedef int (*FN_TRACEMONSTERHULL) (edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); -typedef void (*FN_TRACEHULL) (const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr); -typedef void (*FN_TRACEMODEL) (const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr); -typedef const char * (*FN_TRACETEXTURE) (edict_t *pTextureEntity, const float *v1, const float *v2 ); -typedef void (*FN_TRACESPHERE) (const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr); -typedef void (*FN_GETAIMVECTOR) (edict_t *ent, float speed, float *rgflReturn); -typedef void (*FN_SERVERCOMMAND) (char *str); -typedef void (*FN_SERVEREXECUTE) (void); -typedef void (*FN_CLIENTCOMMAND_ENG) (edict_t *pEdict, char *szFmt, ...); -typedef void (*FN_PARTICLEEFFECT) (const float *org, const float *dir, float color, float count); -typedef void (*FN_LIGHTSTYLE) (int style, char *val); -typedef int (*FN_DECALINDEX) (const char *name); -typedef int (*FN_POINTCONTENTS) (const float *rgflVector); -typedef void (*FN_MESSAGEBEGIN) (int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); -typedef void (*FN_MESSAGEEND) (void); -typedef void (*FN_WRITEBYTE) (int iValue); -typedef void (*FN_WRITECHAR) (int iValue); -typedef void (*FN_WRITESHORT) (int iValue); -typedef void (*FN_WRITELONG) (int iValue); -typedef void (*FN_WRITEANGLE) (float flValue); -typedef void (*FN_WRITECOORD) (float flValue); -typedef void (*FN_WRITESTRING) (const char *sz); -typedef void (*FN_WRITEENTITY) (int iValue); -typedef void (*FN_CVARREGISTER) (cvar_t *pCvar); -typedef float (*FN_CVARGETFLOAT) (const char *szVarName); -typedef const char * (*FN_CVARGETSTRING) (const char *szVarName); -typedef void (*FN_CVARSETFLOAT) (const char *szVarName, float flValue); -typedef void (*FN_CVARSETSTRING) (const char *szVarName, const char *szValue); -typedef void (*FN_ALERTMESSAGE) (ALERT_TYPE atype, char *szFmt, ...); -#ifdef HLSDK_3_2_OLD_EIFACE -typedef void (*FN_ENGINEFPRINTF) (FILE *pfile, char *szFmt, ...); -typedef void * (*FN_PVALLOCENTPRIVATEDATA) (edict_t *pEdict, long cb); -#else -typedef void (*FN_ENGINEFPRINTF) (void *pfile, char *szFmt, ...); -typedef void * (*FN_PVALLOCENTPRIVATEDATA) (edict_t *pEdict, int32 cb); -#endif -typedef void * (*FN_PVENTPRIVATEDATA) (edict_t *pEdict); -typedef void (*FN_FREEENTPRIVATEDATA) (edict_t *pEdict); -typedef const char * (*FN_SZFROMINDEX) (int iString); -typedef int (*FN_ALLOCSTRING) (const char *szValue); -typedef struct entvars_s * (*FN_GETVARSOFENT) (edict_t *pEdict); -typedef edict_t * (*FN_PENTITYOFENTOFFSET) (int iEntOffset); -typedef int (*FN_ENTOFFSETOFPENTITY) (const edict_t *pEdict); -typedef int (*FN_INDEXOFEDICT) (const edict_t *pEdict); -typedef edict_t * (*FN_PENTITYOFENTINDEX) (int iEntIndex); -typedef edict_t * (*FN_FINDENTITYBYVARS) (struct entvars_s *pvars); -typedef void * (*FN_GETMODELPTR) (edict_t *pEdict); -typedef int (*FN_REGUSERMSG) (const char *pszName, int iSize); -typedef void (*FN_ANIMATIONAUTOMOVE) (const edict_t *pEdict, float flTime); -typedef void (*FN_GETBONEPOSITION) (const edict_t *pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); -#ifdef HLSDK_3_2_OLD_EIFACE -typedef unsigned long (*FN_FUNCTIONFROMNAME) ( const char *pName ); -typedef const char * (*FN_NAMEFORFUNCTION) ( unsigned long function ); -#else -typedef uint32 (*FN_FUNCTIONFROMNAME) ( const char *pName ); -typedef const char * (*FN_NAMEFORFUNCTION) ( uint32 function ); -#endif -typedef void (*FN_CLIENTPRINTF) ( edict_t *pEdict, PRINT_TYPE ptype, const char *szMsg ); -typedef void (*FN_SERVERPRINT) ( const char *szMsg ); -typedef const char * (*FN_CMD_ARGS) ( void ); -typedef const char * (*FN_CMD_ARGV) ( int argc ); -typedef int (*FN_CMD_ARGC) ( void ); -typedef void (*FN_GETATTACHMENT) (const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles ); -typedef void (*FN_CRC32_INIT) (CRC32_t *pulCRC); -typedef void (*FN_CRC32_PROCESSBUFFER) (CRC32_t *pulCRC, void *p, int len); -typedef void (*FN_CRC32_PROCESSBYTE) (CRC32_t *pulCRC, unsigned char ch); -typedef CRC32_t (*FN_CRC32_FINAL) (CRC32_t pulCRC); -#ifdef HLSDK_3_2_OLD_EIFACE -typedef long (*FN_RANDOMLONG) (long lLow, long lHigh); -#else -typedef int32 (*FN_RANDOMLONG) (int32 lLow, int32 lHigh); -#endif -typedef float (*FN_RANDOMFLOAT) (float flLow, float flHigh); -typedef void (*FN_SETVIEW) (const edict_t *pClient, const edict_t *pViewent ); -typedef float (*FN_TIME) ( void ); -typedef void (*FN_CROSSHAIRANGLE) (const edict_t *pClient, float pitch, float yaw); -typedef byte * (*FN_LOADFILEFORME) (char *filename, int *pLength); -typedef void (*FN_FREEFILE) (void *buffer); -typedef void (*FN_ENDSECTION) (const char *pszSectionName); -typedef int (*FN_COMPAREFILETIME) (char *filename1, char *filename2, int *iCompare); -typedef void (*FN_GETGAMEDIR) (char *szGetGameDir); -typedef void (*FN_CVAR_REGISTERVARIABLE) (cvar_t *variable); -typedef void (*FN_FADECLIENTVOLUME) (const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds); -typedef void (*FN_SETCLIENTMAXSPEED) (const edict_t *pEdict, float fNewMaxspeed); -typedef edict_t * (*FN_CREATEFAKECLIENT) (const char *netname); -typedef void (*FN_RUNPLAYERMOVE) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); -typedef int (*FN_NUMBEROFENTITIES) (void); -typedef char * (*FN_GETINFOKEYBUFFER) (edict_t *e); -typedef char * (*FN_INFOKEYVALUE) (char *infobuffer, char *key); -typedef void (*FN_SETKEYVALUE) (char *infobuffer, char *key, char *value); -typedef void (*FN_SETCLIENTKEYVALUE) (int clientIndex, char *infobuffer, char *key, char *value); -typedef int (*FN_ISMAPVALID) (char *filename); -typedef void (*FN_STATICDECAL) ( const float *origin, int decalIndex, int entityIndex, int modelIndex ); -typedef int (*FN_PRECACHEGENERIC) (char *s); -typedef int (*FN_GETPLAYERUSERID) (edict_t *e ); -typedef void (*FN_BUILDSOUNDMSG) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); -typedef int (*FN_ISDEDICATEDSERVER) (void); -typedef cvar_t * (*FN_CVARGETPOINTER) (const char *szVarName); -typedef unsigned int (*FN_GETPLAYERWONID) (edict_t *e); -typedef void (*FN_INFO_REMOVEKEY) ( char *s, const char *key ); -typedef const char * (*FN_GETPHYSICSKEYVALUE) ( const edict_t *pClient, const char *key ); -typedef void (*FN_SETPHYSICSKEYVALUE) ( const edict_t *pClient, const char *key, const char *value ); -typedef const char * (*FN_GETPHYSICSINFOSTRING) ( const edict_t *pClient ); -typedef unsigned short (*FN_PRECACHEEVENT) ( int type, const char *psz ); -typedef void (*FN_PLAYBACKEVENT) ( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); -typedef unsigned char * (*FN_SETFATPVS) ( float *org ); -typedef unsigned char * (*FN_SETFATPAS) ( float *org ); -typedef int (*FN_CHECKVISIBILITY) ( const edict_t *entity, unsigned char *pset ); -typedef void (*FN_DELTASETFIELD) ( struct delta_s *pFields, const char *fieldname ); -typedef void (*FN_DELTAUNSETFIELD) ( struct delta_s *pFields, const char *fieldname ); -typedef void (*FN_DELTAADDENCODER) ( char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); -typedef int (*FN_GETCURRENTPLAYER) ( void ); -typedef int (*FN_CANSKIPPLAYER) ( const edict_t *player ); -typedef int (*FN_DELTAFINDFIELD) ( struct delta_s *pFields, const char *fieldname ); -typedef void (*FN_DELTASETFIELDBYINDEX) ( struct delta_s *pFields, int fieldNumber ); -typedef void (*FN_DELTAUNSETFIELDBYINDEX) ( struct delta_s *pFields, int fieldNumber ); -typedef void (*FN_SETGROUPMASK) ( int mask, int op ); -typedef int (*FN_CREATEINSTANCEDBASELINE) ( int classname, struct entity_state_s *baseline ); -typedef void (*FN_CVAR_DIRECTSET) ( struct cvar_s *var, char *value ); -typedef void (*FN_FORCEUNMODIFIED) ( FORCE_TYPE type, float *mins, float *maxs, const char *filename ); -typedef void (*FN_GETPLAYERSTATS) ( const edict_t *pClient, int *ping, int *packet_loss ); -typedef void (*FN_ADDSERVERCOMMAND) ( char *cmd_name, void (*function) (void) ); -// Added in SDK 2.2: -typedef qboolean (*FN_VOICE_GETCLIENTLISTENING) (int iReceiver, int iSender); -typedef qboolean (*FN_VOICE_SETCLIENTLISTENING) (int iReceiver, int iSender, qboolean bListen); -// Added for HL 1109 (no SDK update): -typedef const char * (*FN_GETPLAYERAUTHID) (edict_t *e); -// Added 2003-11-10 (no SDK update): -typedef sequenceEntry_s * (*FN_SEQUENCEGET) (const char* fileName, const char* entryName); -typedef sentenceEntry_s * (*FN_SEQUENCEPICKSENTENCE) (const char* groupName, int pickMethod, int *picked); -typedef int (*FN_GETFILESIZE) (char *filename); -typedef unsigned int (*FN_GETAPPROXWAVEPLAYLEN) (const char *filepath); -typedef int (*FN_ISCAREERMATCH) (void); -typedef int (*FN_GETLOCALIZEDSTRINGLENGTH) (const char *label); -typedef void (*FN_REGISTERTUTORMESSAGESHOWN) (int mid); -typedef int (*FN_GETTIMESTUTORMESSAGESHOWN) (int mid); -typedef void (*FN_PROCESSTUTORMESSAGEDECAYBUFFER) (int *buffer, int bufferLength); -typedef void (*FN_CONSTRUCTTUTORMESSAGEDECAYBUFFER) (int *buffer, int bufferLength); -typedef void (*FN_RESETTUTORMESSAGEDECAYDATA) (void); -//Added 2005-08-11 (no SDK update) -typedef void (*FN_QUERYCLIENTCVARVALUE)(const edict_t *pEdict, const char *cvarName); //! Obsolete! Use FN_QUERYCLIENTCVARVALUE2 instead -//Added 2005-11-22 (no SDK update) -typedef void (*FN_QUERYCLIENTCVARVALUE2)(const edict_t *pEdict, const char *cvarName, int requestID); - +// engine_api.h - prototypes and typedefs for Half-Life engine functions + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef ENGINE_API_H +#define ENGINE_API_H + +#include + +// Plugin's GetEngineFunctions, called by metamod. +typedef int (*GET_ENGINE_FUNCTIONS_FN) (enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion); + +// According to SDK engine/eiface.h: +//! enginefuncs_t +//! ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 138 +#define ENGINE_INTERFACE_VERSION 138 + +// Protect against other projects which use this include file but use the +// normal enginefuncs_t type for their meta_engfuncs. +#ifdef METAMOD_CORE +# include "meta_eiface.h" // meta_enginefuncs_t +extern meta_enginefuncs_t meta_engfuncs; +#else +extern enginefuncs_t meta_engfuncs; +#endif + +// From SDK engine/eiface.h: +extern int mm_PrecacheModel(char *s); +extern int mm_PrecacheSound(char *s); +extern void mm_SetModel(edict_t *e, const char *m); +extern int mm_ModelIndex(const char *m); +extern int mm_ModelFrames(int modelIndex); + +extern void mm_SetSize(edict_t *e, const float *rgflMin, const float *rgflMax); +extern void mm_ChangeLevel(char *s1, char *s2); +extern void mm_GetSpawnParms(edict_t *ent); +extern void mm_SaveSpawnParms(edict_t *ent); + +extern float mm_VecToYaw(const float *rgflVector); +extern void mm_VecToAngles(const float *rgflVectorIn, float *rgflVectorOut); +extern void mm_MoveToOrigin(edict_t *ent, const float *pflGoal, float dist, int iMoveType); +extern void mm_ChangeYaw(edict_t *ent); +extern void mm_ChangePitch(edict_t *ent); + +extern edict_t *mm_FindEntityByString(edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue); +extern int mm_GetEntityIllum(edict_t *pEnt); +extern edict_t *mm_FindEntityInSphere(edict_t *pEdictStartSearchAfter, const float *org, float rad); +extern edict_t *mm_FindClientInPVS(edict_t *pEdict); +extern edict_t *mm_EntitiesInPVS(edict_t *pplayer); + +extern void mm_MakeVectors(const float *rgflVector); +extern void mm_AngleVectors(const float *rgflVector, float *forward, float *right, float *up); + +extern edict_t *mm_CreateEntity(void); +extern void mm_RemoveEntity(edict_t *e); +extern edict_t *mm_CreateNamedEntity(int className); + +extern void mm_MakeStatic(edict_t *ent); +extern int mm_EntIsOnFloor(edict_t *e); +extern int mm_DropToFloor(edict_t *e); + +extern int mm_WalkMove(edict_t *ent, float yaw, float dist, int iMode); +extern void mm_SetOrigin(edict_t *e, const float *rgflOrigin); + +extern void mm_EmitSound(edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch); +extern void mm_EmitAmbientSound(edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch); + +extern void mm_TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); +extern void mm_TraceToss(edict_t *pent, edict_t *pentToIgnore, TraceResult *ptr); +extern int mm_TraceMonsterHull(edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); +extern void mm_TraceHull(const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr); +extern void mm_TraceModel(const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr); +extern const char *mm_TraceTexture(edict_t *pTextureEntity, const float *v1, const float *v2 ); +extern void mm_TraceSphere(const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr); +extern void mm_GetAimVector(edict_t *ent, float speed, float *rgflReturn); + +extern void mm_ServerCommand(char *str); +extern void mm_ServerExecute(void); +extern void ClientCommand(edict_t *pEdict, char *szFmt, ...); + +extern void mm_ParticleEffect(const float *org, const float *dir, float color, float count); +extern void mm_LightStyle(int style, char *val); +extern int mm_DecalIndex(const char *name); +extern int mm_PointContents(const float *rgflVector); + +extern void mm_MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); +extern void mm_MessageEnd(void); + +extern void mm_WriteByte(int iValue); +extern void mm_WriteChar(int iValue); +extern void mm_WriteShort(int iValue); +extern void mm_WriteLong(int iValue); +extern void mm_WriteAngle(float flValue); +extern void mm_WriteCoord(float flValue); +extern void mm_WriteString(const char *sz); +extern void mm_WriteEntity(int iValue); + +extern void mm_CVarRegister(cvar_t *pCvar); +extern float mm_CVarGetFloat(const char *szVarName); +extern const char* mm_CVarGetString(const char *szVarName); +extern void mm_CVarSetFloat(const char *szVarName, float flValue); +extern void mm_CVarSetString(const char *szVarName, const char *szValue); + +extern void mm_AlertMessage(ALERT_TYPE atype, char *szFmt, ...); +#ifdef HLSDK_3_2_OLD_EIFACE +extern void mm_EngineFprintf(FILE *pfile, char *szFmt, ...); +#else +extern void mm_EngineFprintf(void *pfile, char *szFmt, ...); +#endif + +#ifdef HLSDK_3_2_OLD_EIFACE +extern void *mm_PvAllocEntPrivateData(edict_t *pEdict, long cb); +#else +extern void *mm_PvAllocEntPrivateData(edict_t *pEdict, int32 cb); +#endif +extern void *mm_PvEntPrivateData(edict_t *pEdict); +extern void mm_FreeEntPrivateData(edict_t *pEdict); + +extern const char *mm_SzFromIndex(int iString); +extern int mm_AllocString(const char *szValue); + +extern struct entvars_s *mm_GetVarsOfEnt(edict_t *pEdict); +extern edict_t *mm_PEntityOfEntOffset(int iEntOffset); +extern int mm_EntOffsetOfPEntity(const edict_t *pEdict); +extern int mm_IndexOfEdict(const edict_t *pEdict); +extern edict_t *mm_PEntityOfEntIndex(int iEntIndex); +extern edict_t *mm_FindEntityByVars(struct entvars_s *pvars); +extern void *mm_GetModelPtr(edict_t *pEdict); + +extern int mm_RegUserMsg(const char *pszName, int iSize); + +extern void mm_AnimationAutomove(const edict_t *pEdict, float flTime); +extern void mm_GetBonePosition(const edict_t *pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); + +#ifdef HLSDK_3_2_OLD_EIFACE +extern unsigned long mm_FunctionFromName( const char *pName ); +extern const char *mm_NameForFunction( unsigned long function ); +#else +extern uint32 mm_FunctionFromName( const char *pName ); +extern const char *mm_NameForFunction( uint32 function ); +#endif + +extern void mm_ClientPrintf( edict_t *pEdict, PRINT_TYPE ptype, const char *szMsg ); //! JOHN: engine callbacks so game DLL can print messages to individual clients +extern void mm_ServerPrint( const char *szMsg ); + +extern const char *mm_Cmd_Args( void ); //! these 3 added +extern const char *mm_Cmd_Argv( int argc ); //! so game DLL can easily +extern int mm_Cmd_Argc( void ); //! access client 'cmd' strings + +extern void mm_GetAttachment(const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles ); + +extern void mm_CRC32_Init(CRC32_t *pulCRC); +extern void mm_CRC32_ProcessBuffer(CRC32_t *pulCRC, void *p, int len); +extern void mm_CRC32_ProcessByte(CRC32_t *pulCRC, unsigned char ch); +extern CRC32_t mm_CRC32_Final(CRC32_t pulCRC); + +#ifdef HLSDK_3_2_OLD_EIFACE +extern long mm_RandomLong(long lLow, long lHigh); +#else +extern int32 mm_RandomLong(int32 lLow, int32 lHigh); +#endif +extern float mm_RandomFloat(float flLow, float flHigh); + +extern void mm_SetView(const edict_t *pClient, const edict_t *pViewent ); +extern float mm_Time( void ); +extern void mm_CrosshairAngle(const edict_t *pClient, float pitch, float yaw); + +extern byte * mm_LoadFileForMe(char *filename, int *pLength); +extern void mm_FreeFile(void *buffer); + +extern void mm_EndSection(const char *pszSectionName); //! trigger_endsection +extern int mm_CompareFileTime(char *filename1, char *filename2, int *iCompare); +extern void mm_GetGameDir(char *szGetGameDir); +extern void mm_Cvar_RegisterVariable(cvar_t *variable); +extern void mm_FadeClientVolume(const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds); +extern void mm_SetClientMaxspeed(const edict_t *pEdict, float fNewMaxspeed); +extern edict_t * mm_CreateFakeClient(const char *netname); //! returns NULL if fake client can't be created +extern void mm_RunPlayerMove(edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); +extern int mm_NumberOfEntities(void); + +extern char *mm_GetInfoKeyBuffer(edict_t *e); //! passing in NULL gets the serverinfo +extern char *mm_InfoKeyValue(char *infobuffer, char *key); +extern void mm_SetKeyValue(char *infobuffer, char *key, char *value); +extern void mm_SetClientKeyValue(int clientIndex, char *infobuffer, char *key, char *value); + +extern int mm_IsMapValid(char *filename); +extern void mm_StaticDecal( const float *origin, int decalIndex, int entityIndex, int modelIndex ); +extern int mm_PrecacheGeneric(char *s); +extern int mm_GetPlayerUserId(edict_t *e ); //! returns the server assigned userid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients +extern void mm_BuildSoundMsg(edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); +extern int mm_IsDedicatedServer(void);//! is this a dedicated server? +extern cvar_t *mm_CVarGetPointer(const char *szVarName); +extern unsigned int mm_GetPlayerWONId(edict_t *e); //! returns the server assigned WONid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients + +//! YWB 8/1/99 TFF Physics additions +extern void mm_Info_RemoveKey( char *s, const char *key ); +extern const char *mm_GetPhysicsKeyValue( const edict_t *pClient, const char *key ); +extern void mm_SetPhysicsKeyValue( const edict_t *pClient, const char *key, const char *value ); +extern const char *mm_GetPhysicsInfoString( const edict_t *pClient ); +extern unsigned short mm_PrecacheEvent( int type, const char *psz ); +extern void mm_PlaybackEvent( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); + +extern unsigned char *mm_SetFatPVS( float *org ); +extern unsigned char *mm_SetFatPAS( float *org ); + +extern int mm_CheckVisibility( const edict_t *entity, unsigned char *pset ); + +extern void mm_DeltaSetField( struct delta_s *pFields, const char *fieldname ); +extern void mm_DeltaUnsetField( struct delta_s *pFields, const char *fieldname ); +extern void mm_DeltaAddEncoder( char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); +extern int mm_GetCurrentPlayer( void ); +extern int mm_CanSkipPlayer( const edict_t *player ); +extern int mm_DeltaFindField( struct delta_s *pFields, const char *fieldname ); +extern void mm_DeltaSetFieldByIndex( struct delta_s *pFields, int fieldNumber ); +extern void mm_DeltaUnsetFieldByIndex( struct delta_s *pFields, int fieldNumber ); + +extern void mm_SetGroupMask( int mask, int op ); + +extern int CreateInstancedBaseline( int classname, struct entity_state_s *baseline ); +extern void mm_Cvar_DirectSet( struct cvar_s *var, char *value ); + +//! Forces the client and server to be running with the same version of the specified file +//!( e.g., a player model ). +//! Calling this has no effect in single player +extern void mm_ForceUnmodified( FORCE_TYPE type, float *mins, float *maxs, const char *filename ); + +extern void mm_GetPlayerStats( const edict_t *pClient, int *ping, int *packet_loss ); + +extern void mm_AddServerCommand( char *cmd_name, void (*function) (void) ); +// Added in SDK 2.2: +extern qboolean mm_Voice_GetClientListening(int iReceiver, int iSender); +extern qboolean mm_Voice_SetClientListening(int iReceiver, int iSender, qboolean bListen); +// Added for HL 1109 (no SDK update): +extern const char *mm_pfnGetPlayerAuthId(edict_t *e); +// Added 2003-11-10 (no SDK update): +extern sequenceEntry_s * mm_SequenceGet(const char* fileName, const char* entryName); +extern sentenceEntry_s * mm_SequencePickSentence(const char* groupName, int pickMethod, int *picked); +extern int mm_GetFileSize(char *filename); +extern unsigned int mm_GetApproxWavePlayLen(const char *filepath); +extern int mm_IsCareerMatch(void); +extern int mm_GetLocalizedStringLength(const char *label); +extern void mm_RegisterTutorMessageShown(int mid); +extern int mm_GetTimesTutorMessageShown(int mid); +extern void mm_ProcessTutorMessageDecayBuffer(int *buffer, int bufferLength); +extern void mm_ConstructTutorMessageDecayBuffer(int *buffer, int bufferLength); +extern void mm_ResetTutorMessageDecayData(void); +//Added 2005-08-11 (no SDK update) +extern void mm_QueryClientCvarValue(const edict_t *pEdict, const char *cvarName); //! Obsolete! Use mm_QueryClientCvarValue2 instead +//Added 2005-11-22 (no SDK update) +extern void mm_QueryClientCvarValue2(const edict_t *pEdict, const char *cvarName, int requestID); + + +// Typedefs for the above functions: + +typedef int (*FN_PRECACHEMODEL) (char* s); +typedef int (*FN_PRECACHESOUND) (char* s); +typedef void (*FN_SETMODEL) (edict_t *e, const char *m); +typedef int (*FN_MODELINDEX) (const char *m); +typedef int (*FN_MODELFRAMES) (int modelIndex); +typedef void (*FN_SETSIZE) (edict_t *e, const float *rgflMin, const float *rgflMax); +typedef void (*FN_CHANGELEVEL) (char *s1, char *s2); +typedef void (*FN_GETSPAWNPARMS) (edict_t *ent); +typedef void (*FN_SAVESPAWNPARMS) (edict_t *ent); +typedef float (*FN_VECTOYAW) (const float *rgflVector); +typedef void (*FN_VECTOANGLES) (const float *rgflVectorIn, float *rgflVectorOut); +typedef void (*FN_MOVETOORIGIN) (edict_t *ent, const float *pflGoal, float dist, int iMoveType); +typedef void (*FN_CHANGEYAW) (edict_t *ent); +typedef void (*FN_CHANGEPITCH) (edict_t *ent); +typedef edict_t * (*FN_FINDENTITYBYSTRING) (edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue); +typedef int (*FN_GETENTITYILLUM) (edict_t *pEnt); +typedef edict_t * (*FN_FINDENTITYINSPHERE) (edict_t *pEdictStartSearchAfter, const float *org, float rad); +typedef edict_t * (*FN_FINDCLIENTINPVS) (edict_t *pEdict); +typedef edict_t * (*FN_ENTITIESINPVS) (edict_t *pplayer); +typedef void (*FN_MAKEVECTORS) (const float *rgflVector); +typedef void (*FN_ANGLEVECTORS) (const float *rgflVector, float *forward, float *right, float *up); +typedef edict_t * (*FN_CREATEENTITY) (void); +typedef void (*FN_REMOVEENTITY) (edict_t *e); +typedef edict_t * (*FN_CREATENAMEDENTITY) (int className); +typedef void (*FN_MAKESTATIC) (edict_t *ent); +typedef int (*FN_ENTISONFLOOR) (edict_t *e); +typedef int (*FN_DROPTOFLOOR) (edict_t *e); +typedef int (*FN_WALKMOVE) (edict_t *ent, float yaw, float dist, int iMode); +typedef void (*FN_SETORIGIN) (edict_t *e, const float *rgflOrigin); +typedef void (*FN_EMITSOUND) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch); +typedef void (*FN_EMITAMBIENTSOUND) (edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch); +typedef void (*FN_TRACELINE) (const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); +typedef void (*FN_TRACETOSS) (edict_t *pent, edict_t *pentToIgnore, TraceResult *ptr); +typedef int (*FN_TRACEMONSTERHULL) (edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); +typedef void (*FN_TRACEHULL) (const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr); +typedef void (*FN_TRACEMODEL) (const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr); +typedef const char * (*FN_TRACETEXTURE) (edict_t *pTextureEntity, const float *v1, const float *v2 ); +typedef void (*FN_TRACESPHERE) (const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr); +typedef void (*FN_GETAIMVECTOR) (edict_t *ent, float speed, float *rgflReturn); +typedef void (*FN_SERVERCOMMAND) (char *str); +typedef void (*FN_SERVEREXECUTE) (void); +typedef void (*FN_CLIENTCOMMAND_ENG) (edict_t *pEdict, char *szFmt, ...); +typedef void (*FN_PARTICLEEFFECT) (const float *org, const float *dir, float color, float count); +typedef void (*FN_LIGHTSTYLE) (int style, char *val); +typedef int (*FN_DECALINDEX) (const char *name); +typedef int (*FN_POINTCONTENTS) (const float *rgflVector); +typedef void (*FN_MESSAGEBEGIN) (int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); +typedef void (*FN_MESSAGEEND) (void); +typedef void (*FN_WRITEBYTE) (int iValue); +typedef void (*FN_WRITECHAR) (int iValue); +typedef void (*FN_WRITESHORT) (int iValue); +typedef void (*FN_WRITELONG) (int iValue); +typedef void (*FN_WRITEANGLE) (float flValue); +typedef void (*FN_WRITECOORD) (float flValue); +typedef void (*FN_WRITESTRING) (const char *sz); +typedef void (*FN_WRITEENTITY) (int iValue); +typedef void (*FN_CVARREGISTER) (cvar_t *pCvar); +typedef float (*FN_CVARGETFLOAT) (const char *szVarName); +typedef const char * (*FN_CVARGETSTRING) (const char *szVarName); +typedef void (*FN_CVARSETFLOAT) (const char *szVarName, float flValue); +typedef void (*FN_CVARSETSTRING) (const char *szVarName, const char *szValue); +typedef void (*FN_ALERTMESSAGE) (ALERT_TYPE atype, char *szFmt, ...); +#ifdef HLSDK_3_2_OLD_EIFACE +typedef void (*FN_ENGINEFPRINTF) (FILE *pfile, char *szFmt, ...); +typedef void * (*FN_PVALLOCENTPRIVATEDATA) (edict_t *pEdict, long cb); +#else +typedef void (*FN_ENGINEFPRINTF) (void *pfile, char *szFmt, ...); +typedef void * (*FN_PVALLOCENTPRIVATEDATA) (edict_t *pEdict, int32 cb); +#endif +typedef void * (*FN_PVENTPRIVATEDATA) (edict_t *pEdict); +typedef void (*FN_FREEENTPRIVATEDATA) (edict_t *pEdict); +typedef const char * (*FN_SZFROMINDEX) (int iString); +typedef int (*FN_ALLOCSTRING) (const char *szValue); +typedef struct entvars_s * (*FN_GETVARSOFENT) (edict_t *pEdict); +typedef edict_t * (*FN_PENTITYOFENTOFFSET) (int iEntOffset); +typedef int (*FN_ENTOFFSETOFPENTITY) (const edict_t *pEdict); +typedef int (*FN_INDEXOFEDICT) (const edict_t *pEdict); +typedef edict_t * (*FN_PENTITYOFENTINDEX) (int iEntIndex); +typedef edict_t * (*FN_FINDENTITYBYVARS) (struct entvars_s *pvars); +typedef void * (*FN_GETMODELPTR) (edict_t *pEdict); +typedef int (*FN_REGUSERMSG) (const char *pszName, int iSize); +typedef void (*FN_ANIMATIONAUTOMOVE) (const edict_t *pEdict, float flTime); +typedef void (*FN_GETBONEPOSITION) (const edict_t *pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); +#ifdef HLSDK_3_2_OLD_EIFACE +typedef unsigned long (*FN_FUNCTIONFROMNAME) ( const char *pName ); +typedef const char * (*FN_NAMEFORFUNCTION) ( unsigned long function ); +#else +typedef uint32 (*FN_FUNCTIONFROMNAME) ( const char *pName ); +typedef const char * (*FN_NAMEFORFUNCTION) ( uint32 function ); +#endif +typedef void (*FN_CLIENTPRINTF) ( edict_t *pEdict, PRINT_TYPE ptype, const char *szMsg ); +typedef void (*FN_SERVERPRINT) ( const char *szMsg ); +typedef const char * (*FN_CMD_ARGS) ( void ); +typedef const char * (*FN_CMD_ARGV) ( int argc ); +typedef int (*FN_CMD_ARGC) ( void ); +typedef void (*FN_GETATTACHMENT) (const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles ); +typedef void (*FN_CRC32_INIT) (CRC32_t *pulCRC); +typedef void (*FN_CRC32_PROCESSBUFFER) (CRC32_t *pulCRC, void *p, int len); +typedef void (*FN_CRC32_PROCESSBYTE) (CRC32_t *pulCRC, unsigned char ch); +typedef CRC32_t (*FN_CRC32_FINAL) (CRC32_t pulCRC); +#ifdef HLSDK_3_2_OLD_EIFACE +typedef long (*FN_RANDOMLONG) (long lLow, long lHigh); +#else +typedef int32 (*FN_RANDOMLONG) (int32 lLow, int32 lHigh); +#endif +typedef float (*FN_RANDOMFLOAT) (float flLow, float flHigh); +typedef void (*FN_SETVIEW) (const edict_t *pClient, const edict_t *pViewent ); +typedef float (*FN_TIME) ( void ); +typedef void (*FN_CROSSHAIRANGLE) (const edict_t *pClient, float pitch, float yaw); +typedef byte * (*FN_LOADFILEFORME) (char *filename, int *pLength); +typedef void (*FN_FREEFILE) (void *buffer); +typedef void (*FN_ENDSECTION) (const char *pszSectionName); +typedef int (*FN_COMPAREFILETIME) (char *filename1, char *filename2, int *iCompare); +typedef void (*FN_GETGAMEDIR) (char *szGetGameDir); +typedef void (*FN_CVAR_REGISTERVARIABLE) (cvar_t *variable); +typedef void (*FN_FADECLIENTVOLUME) (const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds); +typedef void (*FN_SETCLIENTMAXSPEED) (const edict_t *pEdict, float fNewMaxspeed); +typedef edict_t * (*FN_CREATEFAKECLIENT) (const char *netname); +typedef void (*FN_RUNPLAYERMOVE) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); +typedef int (*FN_NUMBEROFENTITIES) (void); +typedef char * (*FN_GETINFOKEYBUFFER) (edict_t *e); +typedef char * (*FN_INFOKEYVALUE) (char *infobuffer, char *key); +typedef void (*FN_SETKEYVALUE) (char *infobuffer, char *key, char *value); +typedef void (*FN_SETCLIENTKEYVALUE) (int clientIndex, char *infobuffer, char *key, char *value); +typedef int (*FN_ISMAPVALID) (char *filename); +typedef void (*FN_STATICDECAL) ( const float *origin, int decalIndex, int entityIndex, int modelIndex ); +typedef int (*FN_PRECACHEGENERIC) (char *s); +typedef int (*FN_GETPLAYERUSERID) (edict_t *e ); +typedef void (*FN_BUILDSOUNDMSG) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); +typedef int (*FN_ISDEDICATEDSERVER) (void); +typedef cvar_t * (*FN_CVARGETPOINTER) (const char *szVarName); +typedef unsigned int (*FN_GETPLAYERWONID) (edict_t *e); +typedef void (*FN_INFO_REMOVEKEY) ( char *s, const char *key ); +typedef const char * (*FN_GETPHYSICSKEYVALUE) ( const edict_t *pClient, const char *key ); +typedef void (*FN_SETPHYSICSKEYVALUE) ( const edict_t *pClient, const char *key, const char *value ); +typedef const char * (*FN_GETPHYSICSINFOSTRING) ( const edict_t *pClient ); +typedef unsigned short (*FN_PRECACHEEVENT) ( int type, const char *psz ); +typedef void (*FN_PLAYBACKEVENT) ( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); +typedef unsigned char * (*FN_SETFATPVS) ( float *org ); +typedef unsigned char * (*FN_SETFATPAS) ( float *org ); +typedef int (*FN_CHECKVISIBILITY) ( const edict_t *entity, unsigned char *pset ); +typedef void (*FN_DELTASETFIELD) ( struct delta_s *pFields, const char *fieldname ); +typedef void (*FN_DELTAUNSETFIELD) ( struct delta_s *pFields, const char *fieldname ); +typedef void (*FN_DELTAADDENCODER) ( char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); +typedef int (*FN_GETCURRENTPLAYER) ( void ); +typedef int (*FN_CANSKIPPLAYER) ( const edict_t *player ); +typedef int (*FN_DELTAFINDFIELD) ( struct delta_s *pFields, const char *fieldname ); +typedef void (*FN_DELTASETFIELDBYINDEX) ( struct delta_s *pFields, int fieldNumber ); +typedef void (*FN_DELTAUNSETFIELDBYINDEX) ( struct delta_s *pFields, int fieldNumber ); +typedef void (*FN_SETGROUPMASK) ( int mask, int op ); +typedef int (*FN_CREATEINSTANCEDBASELINE) ( int classname, struct entity_state_s *baseline ); +typedef void (*FN_CVAR_DIRECTSET) ( struct cvar_s *var, char *value ); +typedef void (*FN_FORCEUNMODIFIED) ( FORCE_TYPE type, float *mins, float *maxs, const char *filename ); +typedef void (*FN_GETPLAYERSTATS) ( const edict_t *pClient, int *ping, int *packet_loss ); +typedef void (*FN_ADDSERVERCOMMAND) ( char *cmd_name, void (*function) (void) ); +// Added in SDK 2.2: +typedef qboolean (*FN_VOICE_GETCLIENTLISTENING) (int iReceiver, int iSender); +typedef qboolean (*FN_VOICE_SETCLIENTLISTENING) (int iReceiver, int iSender, qboolean bListen); +// Added for HL 1109 (no SDK update): +typedef const char * (*FN_GETPLAYERAUTHID) (edict_t *e); +// Added 2003-11-10 (no SDK update): +typedef sequenceEntry_s * (*FN_SEQUENCEGET) (const char* fileName, const char* entryName); +typedef sentenceEntry_s * (*FN_SEQUENCEPICKSENTENCE) (const char* groupName, int pickMethod, int *picked); +typedef int (*FN_GETFILESIZE) (char *filename); +typedef unsigned int (*FN_GETAPPROXWAVEPLAYLEN) (const char *filepath); +typedef int (*FN_ISCAREERMATCH) (void); +typedef int (*FN_GETLOCALIZEDSTRINGLENGTH) (const char *label); +typedef void (*FN_REGISTERTUTORMESSAGESHOWN) (int mid); +typedef int (*FN_GETTIMESTUTORMESSAGESHOWN) (int mid); +typedef void (*FN_PROCESSTUTORMESSAGEDECAYBUFFER) (int *buffer, int bufferLength); +typedef void (*FN_CONSTRUCTTUTORMESSAGEDECAYBUFFER) (int *buffer, int bufferLength); +typedef void (*FN_RESETTUTORMESSAGEDECAYDATA) (void); +//Added 2005-08-11 (no SDK update) +typedef void (*FN_QUERYCLIENTCVARVALUE)(const edict_t *pEdict, const char *cvarName); //! Obsolete! Use FN_QUERYCLIENTCVARVALUE2 instead +//Added 2005-11-22 (no SDK update) +typedef void (*FN_QUERYCLIENTCVARVALUE2)(const edict_t *pEdict, const char *cvarName, int requestID); + #endif /* ENGINE_API_H */ \ No newline at end of file diff --git a/dep/metamod/enginecallbacks.h b/dep/metamod/enginecallbacks.h index 876d086..7045fbb 100644 --- a/dep/metamod/enginecallbacks.h +++ b/dep/metamod/enginecallbacks.h @@ -1,74 +1,74 @@ -// enginecallbacks.h - wrapper for - -/* - * Copyright (c) 2001-2006 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef MM_ENGINECALLBACKS_H -#define MM_ENGINECALLBACKS_H - -// This file is a wrapper around the SDK's enginecallback.h file. We need -// this because we use a different type for the global object g_engfuncs, -// which is still compatible with the enginefuncs_t that the SDK -// uses. -// This is only done for files that belong to Metamod, not other projects -// like plugins that use this file, or others that include it, too. -// Since we don't have a clean seperation of include files right now we -// "hack" our way around that by using a flag METAMOD_CORE which is set -// when compiling Metamod proper. - -#ifdef METAMOD_CORE -# include "meta_eiface.h" // HL_enginefuncs_t - -// Use a #define to bend the enginefuncs_t type to our HL_enginefuncs_t -// type instead as we now use that for the global object g_engfuncs. -# define enginefuncs_t HL_enginefuncs_t -#endif /* METAMOD_CORE */ - -#include // ALERT, etc - -#ifdef METAMOD_CORE -# undef enginefuncs_t -#endif /* METAMOD_CORE */ - -// Also, create some additional macros for engine callback functions, which -// weren't in SDK dlls/enginecallbacks.h but probably should have been. - -#define GET_INFOKEYBUFFER (*g_engfuncs.pfnGetInfoKeyBuffer) -#define INFOKEY_VALUE (*g_engfuncs.pfnInfoKeyValue) -#define SET_CLIENT_KEYVALUE (*g_engfuncs.pfnSetClientKeyValue) -#define REG_SVR_COMMAND (*g_engfuncs.pfnAddServerCommand) -#define SERVER_PRINT (*g_engfuncs.pfnServerPrint) -#define SET_SERVER_KEYVALUE (*g_engfuncs.pfnSetKeyValue) -#define QUERY_CLIENT_CVAR_VALUE (*g_engfuncs.pfnQueryClientCvarValue) -#define QUERY_CLIENT_CVAR_VALUE2 (*g_engfuncs.pfnQueryClientCvarValue2) - - -#endif /* MM_ENGINECALLBACKS_H */ +// enginecallbacks.h - wrapper for + +/* + * Copyright (c) 2001-2006 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef MM_ENGINECALLBACKS_H +#define MM_ENGINECALLBACKS_H + +// This file is a wrapper around the SDK's enginecallback.h file. We need +// this because we use a different type for the global object g_engfuncs, +// which is still compatible with the enginefuncs_t that the SDK +// uses. +// This is only done for files that belong to Metamod, not other projects +// like plugins that use this file, or others that include it, too. +// Since we don't have a clean seperation of include files right now we +// "hack" our way around that by using a flag METAMOD_CORE which is set +// when compiling Metamod proper. + +#ifdef METAMOD_CORE +# include "meta_eiface.h" // HL_enginefuncs_t + +// Use a #define to bend the enginefuncs_t type to our HL_enginefuncs_t +// type instead as we now use that for the global object g_engfuncs. +# define enginefuncs_t HL_enginefuncs_t +#endif /* METAMOD_CORE */ + +#include // ALERT, etc + +#ifdef METAMOD_CORE +# undef enginefuncs_t +#endif /* METAMOD_CORE */ + +// Also, create some additional macros for engine callback functions, which +// weren't in SDK dlls/enginecallbacks.h but probably should have been. + +#define GET_INFOKEYBUFFER (*g_engfuncs.pfnGetInfoKeyBuffer) +#define INFOKEY_VALUE (*g_engfuncs.pfnInfoKeyValue) +#define SET_CLIENT_KEYVALUE (*g_engfuncs.pfnSetClientKeyValue) +#define REG_SVR_COMMAND (*g_engfuncs.pfnAddServerCommand) +#define SERVER_PRINT (*g_engfuncs.pfnServerPrint) +#define SET_SERVER_KEYVALUE (*g_engfuncs.pfnSetKeyValue) +#define QUERY_CLIENT_CVAR_VALUE (*g_engfuncs.pfnQueryClientCvarValue) +#define QUERY_CLIENT_CVAR_VALUE2 (*g_engfuncs.pfnQueryClientCvarValue2) + + +#endif /* MM_ENGINECALLBACKS_H */ diff --git a/dep/metamod/h_export.h b/dep/metamod/h_export.h index a5a603d..878acd1 100644 --- a/dep/metamod/h_export.h +++ b/dep/metamod/h_export.h @@ -1,46 +1,46 @@ -// h_export.h - prototypes for h_export.cpp - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef H_EXPORT_H -#define H_EXPORT_H - -#include "osdep.h" // DLLEXPORT, WINAPI, etc - -// Our GiveFnptrsToDll, called by engine. -typedef void (WINAPI *GIVE_ENGINE_FUNCTIONS_FN) (enginefuncs_t - *pengfuncsFromEngine, globalvars_t *pGlobals); - -C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t *pengfuncsFromEngine, - globalvars_t *pGlobals); - -#endif /* H_EXPORT_H */ +// h_export.h - prototypes for h_export.cpp + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef H_EXPORT_H +#define H_EXPORT_H + +#include "osdep.h" // DLLEXPORT, WINAPI, etc + +// Our GiveFnptrsToDll, called by engine. +typedef void (WINAPI *GIVE_ENGINE_FUNCTIONS_FN) (enginefuncs_t + *pengfuncsFromEngine, globalvars_t *pGlobals); + +C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t *pengfuncsFromEngine, + globalvars_t *pGlobals); + +#endif /* H_EXPORT_H */ diff --git a/dep/metamod/log_meta.h b/dep/metamod/log_meta.h index a701041..ec47c6d 100644 --- a/dep/metamod/log_meta.h +++ b/dep/metamod/log_meta.h @@ -1,99 +1,99 @@ -// log_meta.h - functions & macros for logging - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef LOG_META_H -#define LOG_META_H - -#include "enginecallbacks.h" // ALERT, etc -#include "sdk_util.h" // UTIL_VarArgs, etc - -// Debug logging. -// -// This is done as a macro, rather than a function. This way, you can add -// DEBUG statements all over, without worrying about performance -// implications. If the debugging level is set low, all those statements -// will only generate a simple float/int compare each; if we were to use a -// function instead of a macro, it would end up wasting a lot of cpu cycles -// calling/returning from the function every time. With a fair number of -// DEBUG statements, or if they're placed in frequently excuted code, the -// overhead of the wasted function calls could significantly impact server -// performance. -// -// For this reason, we also compare directly to the float value of the -// cvar, rather than calling CVAR_GET_FLOAT() and thus generating a string -// compare for each DEBUG statement. -// -// Called as: -// META_DEBUG(3, ("return code: %d", ret)); -// -// Note the double parens, and the missing parens around "args" in the -// macro itself. Note also the "do..while(0)" loop wrapping the -// statements, so they become a single statement when expanded, necessary -// for times when it might be called as a single-statement result of an -// else (or other flow control). -// -// As suggested by Jussi Kivilinna: Use "if(meta_debug.value < level); else -// DO(something);" style because "meta_debug.value < level" is in most common -// case "false". Check disasm, contitional jumps are predicted not to be -// taken by CPU. -// -// Yes, it's all a bit of a hack. - -#define META_DEBUG(level, args) \ - do { if(meta_debug.value < level) break; else ALERT(at_logged, "[META] (debug:%d) %s\n", level, UTIL_VarArgs args ); } while(0) - -// max buffer size for printed messages -#define MAX_LOGMSG_LEN 1024 - -// max buffer size for client messages -#define MAX_CLIENTMSG_LEN 128 - -extern cvar_t meta_debug; - -// META_DEV provides debug logging via the cvar "developer" (when set to 1) -// and uses a function call rather than a macro as it's really intended to -// be used only during startup, before meta_debug has been set from reading -// server.cfg. -// NOTE: META_DEV has now been mostly obsoleted in the code. - -void META_CONS(char *fmt, ...); -void META_DEV(char *fmt, ...); -void META_INFO(char *fmt, ...); -void META_WARNING(char *fmt, ...); -void META_ERROR(char *fmt, ...); -void META_LOG(char *fmt, ...); -void META_CLIENT(edict_t *pEntity, char *fmt, ...); - -void flush_ALERT_buffer(void); - -#endif /* LOG_META_H */ +// log_meta.h - functions & macros for logging + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef LOG_META_H +#define LOG_META_H + +#include "enginecallbacks.h" // ALERT, etc +#include "sdk_util.h" // UTIL_VarArgs, etc + +// Debug logging. +// +// This is done as a macro, rather than a function. This way, you can add +// DEBUG statements all over, without worrying about performance +// implications. If the debugging level is set low, all those statements +// will only generate a simple float/int compare each; if we were to use a +// function instead of a macro, it would end up wasting a lot of cpu cycles +// calling/returning from the function every time. With a fair number of +// DEBUG statements, or if they're placed in frequently excuted code, the +// overhead of the wasted function calls could significantly impact server +// performance. +// +// For this reason, we also compare directly to the float value of the +// cvar, rather than calling CVAR_GET_FLOAT() and thus generating a string +// compare for each DEBUG statement. +// +// Called as: +// META_DEBUG(3, ("return code: %d", ret)); +// +// Note the double parens, and the missing parens around "args" in the +// macro itself. Note also the "do..while(0)" loop wrapping the +// statements, so they become a single statement when expanded, necessary +// for times when it might be called as a single-statement result of an +// else (or other flow control). +// +// As suggested by Jussi Kivilinna: Use "if(meta_debug.value < level); else +// DO(something);" style because "meta_debug.value < level" is in most common +// case "false". Check disasm, contitional jumps are predicted not to be +// taken by CPU. +// +// Yes, it's all a bit of a hack. + +#define META_DEBUG(level, args) \ + do { if(meta_debug.value < level) break; else ALERT(at_logged, "[META] (debug:%d) %s\n", level, UTIL_VarArgs args ); } while(0) + +// max buffer size for printed messages +#define MAX_LOGMSG_LEN 1024 + +// max buffer size for client messages +#define MAX_CLIENTMSG_LEN 128 + +extern cvar_t meta_debug; + +// META_DEV provides debug logging via the cvar "developer" (when set to 1) +// and uses a function call rather than a macro as it's really intended to +// be used only during startup, before meta_debug has been set from reading +// server.cfg. +// NOTE: META_DEV has now been mostly obsoleted in the code. + +void META_CONS(char *fmt, ...); +void META_DEV(char *fmt, ...); +void META_INFO(char *fmt, ...); +void META_WARNING(char *fmt, ...); +void META_ERROR(char *fmt, ...); +void META_LOG(char *fmt, ...); +void META_CLIENT(edict_t *pEntity, char *fmt, ...); + +void flush_ALERT_buffer(void); + +#endif /* LOG_META_H */ diff --git a/dep/metamod/meta_api.h b/dep/metamod/meta_api.h index 456f45c..3bbccfa 100644 --- a/dep/metamod/meta_api.h +++ b/dep/metamod/meta_api.h @@ -1,232 +1,232 @@ -// meta_api.h - description of metamod's DLL interface - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef META_API_H -#define META_API_H - -#include "dllapi.h" // GETENTITYAPI_FN, etc -#include "engine_api.h" // GET_ENGINE_FUNCTIONS_FN, etc -#include "plinfo.h" // plugin_info_t, etc -#include "mutil.h" // mutil_funcs_t, etc -#include "osdep.h" // DLLEXPORT, etc - -// Version consists of "major:minor", two separate integer numbers. -// Version 1 original -// Version 2 added plugin_info_t **pinfo -// Version 3 init split into query and attach, added detach -// Version 4 added (PLUG_LOADTIME now) to attach -// Version 5 changed mm ifvers int* to string, moved pl ifvers to info -// Version 5:1 added link support for entity "adminmod_timer" (adminmod) -// Version 5:2 added gamedll_funcs to meta_attach() [v1.0-rc2] -// Version 5:3 added mutil_funcs to meta_query() [v1.05] -// Version 5:4 added centersay utility functions [v1.06] -// Version 5:5 added Meta_Init to plugin API [v1.08] -// Version 5:6 added CallGameEntity utility function [v1.09] -// Version 5:7 added GetUserMsgID, GetUserMsgName util funcs [v1.11] -// Version 5:8 added GetPluginPath [v1.11] -// Version 5:9 added GetGameInfo [v1.14] -// Version 5:10 added GINFO_REALDLL_FULLPATH for GetGameInfo [v1.17] -// Version 5:11 added plugin loading and unloading API [v1.18] -// Version 5:12 added util code for checking player query status [v1.18] -// Version 5:13 added cvarquery2 support and api for calling hook tables [v1.19] -#define META_INTERFACE_VERSION "5:13" - -#ifdef UNFINISHED -// Version 5:99 added event hook utility functions [v.???] -#define META_INTERFACE_VERSION "5:99" -#endif /* UNFINISHED */ - -// Flags returned by a plugin's api function. -// NOTE: order is crucial, as greater/less comparisons are made. -typedef enum { - MRES_UNSET = 0, - MRES_IGNORED, // plugin didn't take any action - MRES_HANDLED, // plugin did something, but real function should still be called - MRES_OVERRIDE, // call real function, but use my return value - MRES_SUPERCEDE, // skip real function; use my return value -} META_RES; - -// Variables provided to plugins. -typedef struct meta_globals_s { - META_RES mres; // writable; plugin's return flag - META_RES prev_mres; // readable; return flag of the previous plugin called - META_RES status; // readable; "highest" return flag so far - void *orig_ret; // readable; return value from "real" function - void *override_ret; // readable; return value from overriding/superceding plugin -} meta_globals_t; - -extern meta_globals_t *gpMetaGlobals; -#define SET_META_RESULT(result) gpMetaGlobals->mres=result -#define RETURN_META(result) \ - do { gpMetaGlobals->mres=result; return; } while(0) - -#define RETURN_META_VALUE(result, value) \ - do { gpMetaGlobals->mres=result; return(value); } while(0) - -#define META_RESULT_STATUS gpMetaGlobals->status -#define META_RESULT_PREVIOUS gpMetaGlobals->prev_mres -#define META_RESULT_ORIG_RET(type) *(type *)gpMetaGlobals->orig_ret -#define META_RESULT_OVERRIDE_RET(type) *(type *)gpMetaGlobals->override_ret - -// Table of getapi functions, retrieved from each plugin. -typedef struct { - GETENTITYAPI_FN pfnGetEntityAPI; - GETENTITYAPI_FN pfnGetEntityAPI_Post; - GETENTITYAPI2_FN pfnGetEntityAPI2; - GETENTITYAPI2_FN pfnGetEntityAPI2_Post; - GETNEWDLLFUNCTIONS_FN pfnGetNewDLLFunctions; - GETNEWDLLFUNCTIONS_FN pfnGetNewDLLFunctions_Post; - GET_ENGINE_FUNCTIONS_FN pfnGetEngineFunctions; - GET_ENGINE_FUNCTIONS_FN pfnGetEngineFunctions_Post; -} META_FUNCTIONS; - -// Pair of function tables provided by game DLL. -typedef struct { - DLL_FUNCTIONS *dllapi_table; - NEW_DLL_FUNCTIONS *newapi_table; -} gamedll_funcs_t; - -// Declared in plugin; referenced in macros. -extern gamedll_funcs_t *gpGamedllFuncs; -extern mutil_funcs_t *gpMetaUtilFuncs; - -// Tell the dll that we'll be loading it as a metamod plugin, in case it -// needs to do something special prior to the standard query/attach -// procedure. In particular, this will allow for DLL's that can be used as -// both standalone DLL's and metamod plugins. (optional; not required in -// plugin) -C_DLLEXPORT void Meta_Init(void); -typedef void (*META_INIT_FN) (void); - -// Get info about plugin, compare meta_interface versions, provide meta -// utility callback functions. -C_DLLEXPORT int Meta_Query(char *interfaceVersion, - plugin_info_t **plinfo, - mutil_funcs_t *pMetaUtilFuncs); -typedef int (*META_QUERY_FN) (char *interfaceVersion, - plugin_info_t **plinfo, - mutil_funcs_t *pMetaUtilFuncs); - -// Attach the plugin to the API; get the table of getapi functions; give -// meta_globals and gamedll_funcs. -C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, - META_FUNCTIONS *pFunctionTable, - meta_globals_t *pMGlobals, - gamedll_funcs_t *pGamedllFuncs); -typedef int (*META_ATTACH_FN) (PLUG_LOADTIME now, - META_FUNCTIONS *pFunctionTable, - meta_globals_t *pMGlobals, - gamedll_funcs_t *pGamedllFuncs); - -// Detach the plugin; tell why and when. -C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason); -typedef int (*META_DETACH_FN) (PLUG_LOADTIME now, PL_UNLOAD_REASON reason); - -// Standard HL SDK interface function prototypes. -C_DLLEXPORT int GetEntityAPI_Post(DLL_FUNCTIONS *pFunctionTable, - int interfaceVersion ); -C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, - int *interfaceVersion ); - -// Additional SDK-like interface function prototypes. -C_DLLEXPORT int GetNewDLLFunctions_Post(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion ); -C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion); -C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion); - -// Convenience macros for accessing GameDLL functions. Note: these talk -// _directly_ to the gamedll, and are not multiplexed through Metamod to -// the other plugins. -// DLL API functions: -#define MDLL_FUNC gpGamedllFuncs->dllapi_table - -#define MDLL_GameDLLInit MDLL_FUNC->pfnGameInit -#define MDLL_Spawn MDLL_FUNC->pfnSpawn -#define MDLL_Think MDLL_FUNC->pfnThink -#define MDLL_Use MDLL_FUNC->pfnUse -#define MDLL_Touch MDLL_FUNC->pfnTouch -#define MDLL_Blocked MDLL_FUNC->pfnBlocked -#define MDLL_KeyValue MDLL_FUNC->pfnKeyValue -#define MDLL_Save MDLL_FUNC->pfnSave -#define MDLL_Restore MDLL_FUNC->pfnRestore -#define MDLL_ObjectCollsionBox MDLL_FUNC->pfnAbsBox -#define MDLL_SaveWriteFields MDLL_FUNC->pfnSaveWriteFields -#define MDLL_SaveReadFields MDLL_FUNC->pfnSaveReadFields -#define MDLL_SaveGlobalState MDLL_FUNC->pfnSaveGlobalState -#define MDLL_RestoreGlobalState MDLL_FUNC->pfnRestoreGlobalState -#define MDLL_ResetGlobalState MDLL_FUNC->pfnResetGlobalState -#define MDLL_ClientConnect MDLL_FUNC->pfnClientConnect -#define MDLL_ClientDisconnect MDLL_FUNC->pfnClientDisconnect -#define MDLL_ClientKill MDLL_FUNC->pfnClientKill -#define MDLL_ClientPutInServer MDLL_FUNC->pfnClientPutInServer -#define MDLL_ClientCommand MDLL_FUNC->pfnClientCommand -#define MDLL_ClientUserInfoChanged MDLL_FUNC->pfnClientUserInfoChanged -#define MDLL_ServerActivate MDLL_FUNC->pfnServerActivate -#define MDLL_ServerDeactivate MDLL_FUNC->pfnServerDeactivate -#define MDLL_PlayerPreThink MDLL_FUNC->pfnPlayerPreThink -#define MDLL_PlayerPostThink MDLL_FUNC->pfnPlayerPostThink -#define MDLL_StartFrame MDLL_FUNC->pfnStartFrame -#define MDLL_ParmsNewLevel MDLL_FUNC->pfnParmsNewLevel -#define MDLL_ParmsChangeLevel MDLL_FUNC->pfnParmsChangeLevel -#define MDLL_GetGameDescription MDLL_FUNC->pfnGetGameDescription -#define MDLL_PlayerCustomization MDLL_FUNC->pfnPlayerCustomization -#define MDLL_SpectatorConnect MDLL_FUNC->pfnSpectatorConnect -#define MDLL_SpectatorDisconnect MDLL_FUNC->pfnSpectatorDisconnect -#define MDLL_SpectatorThink MDLL_FUNC->pfnSpectatorThink -#define MDLL_Sys_Error MDLL_FUNC->pfnSys_Error -#define MDLL_PM_Move MDLL_FUNC->pfnPM_Move -#define MDLL_PM_Init MDLL_FUNC->pfnPM_Init -#define MDLL_PM_FindTextureType MDLL_FUNC->pfnPM_FindTextureType -#define MDLL_SetupVisibility MDLL_FUNC->pfnSetupVisibility -#define MDLL_UpdateClientData MDLL_FUNC->pfnUpdateClientData -#define MDLL_AddToFullPack MDLL_FUNC->pfnAddToFullPack -#define MDLL_CreateBaseline MDLL_FUNC->pfnCreateBaseline -#define MDLL_RegisterEncoders MDLL_FUNC->pfnRegisterEncoders -#define MDLL_GetWeaponData MDLL_FUNC->pfnGetWeaponData -#define MDLL_CmdStart MDLL_FUNC->pfnCmdStart -#define MDLL_CmdEnd MDLL_FUNC->pfnCmdEnd -#define MDLL_ConnectionlessPacket MDLL_FUNC->pfnConnectionlessPacket -#define MDLL_GetHullBounds MDLL_FUNC->pfnGetHullBounds -#define MDLL_CreateInstancedBaselines MDLL_FUNC->pfnCreateInstancedBaselines -#define MDLL_InconsistentFile MDLL_FUNC->pfnInconsistentFile -#define MDLL_AllowLagCompensation MDLL_FUNC->pfnAllowLagCompensation - -// NEW API functions: -#define MNEW_FUNC gpGamedllFuncs->newapi_table - -#define MNEW_OnFreeEntPrivateData MNEW_FUNC->pfnOnFreeEntPrivateData -#define MNEW_GameShutdown MNEW_FUNC->pfnGameShutdown -#define MNEW_ShouldCollide MNEW_FUNC->pfnShouldCollide -#define MNEW_CvarValue MNEW_FUNC->pfnCvarValue -#define MNEW_CvarValue2 MNEW_FUNC->pfnCvarValue2 - -#endif /* META_API_H */ +// meta_api.h - description of metamod's DLL interface + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef META_API_H +#define META_API_H + +#include "dllapi.h" // GETENTITYAPI_FN, etc +#include "engine_api.h" // GET_ENGINE_FUNCTIONS_FN, etc +#include "plinfo.h" // plugin_info_t, etc +#include "mutil.h" // mutil_funcs_t, etc +#include "osdep.h" // DLLEXPORT, etc + +// Version consists of "major:minor", two separate integer numbers. +// Version 1 original +// Version 2 added plugin_info_t **pinfo +// Version 3 init split into query and attach, added detach +// Version 4 added (PLUG_LOADTIME now) to attach +// Version 5 changed mm ifvers int* to string, moved pl ifvers to info +// Version 5:1 added link support for entity "adminmod_timer" (adminmod) +// Version 5:2 added gamedll_funcs to meta_attach() [v1.0-rc2] +// Version 5:3 added mutil_funcs to meta_query() [v1.05] +// Version 5:4 added centersay utility functions [v1.06] +// Version 5:5 added Meta_Init to plugin API [v1.08] +// Version 5:6 added CallGameEntity utility function [v1.09] +// Version 5:7 added GetUserMsgID, GetUserMsgName util funcs [v1.11] +// Version 5:8 added GetPluginPath [v1.11] +// Version 5:9 added GetGameInfo [v1.14] +// Version 5:10 added GINFO_REALDLL_FULLPATH for GetGameInfo [v1.17] +// Version 5:11 added plugin loading and unloading API [v1.18] +// Version 5:12 added util code for checking player query status [v1.18] +// Version 5:13 added cvarquery2 support and api for calling hook tables [v1.19] +#define META_INTERFACE_VERSION "5:13" + +#ifdef UNFINISHED +// Version 5:99 added event hook utility functions [v.???] +#define META_INTERFACE_VERSION "5:99" +#endif /* UNFINISHED */ + +// Flags returned by a plugin's api function. +// NOTE: order is crucial, as greater/less comparisons are made. +typedef enum { + MRES_UNSET = 0, + MRES_IGNORED, // plugin didn't take any action + MRES_HANDLED, // plugin did something, but real function should still be called + MRES_OVERRIDE, // call real function, but use my return value + MRES_SUPERCEDE, // skip real function; use my return value +} META_RES; + +// Variables provided to plugins. +typedef struct meta_globals_s { + META_RES mres; // writable; plugin's return flag + META_RES prev_mres; // readable; return flag of the previous plugin called + META_RES status; // readable; "highest" return flag so far + void *orig_ret; // readable; return value from "real" function + void *override_ret; // readable; return value from overriding/superceding plugin +} meta_globals_t; + +extern meta_globals_t *gpMetaGlobals; +#define SET_META_RESULT(result) gpMetaGlobals->mres=result +#define RETURN_META(result) \ + do { gpMetaGlobals->mres=result; return; } while(0) + +#define RETURN_META_VALUE(result, value) \ + do { gpMetaGlobals->mres=result; return(value); } while(0) + +#define META_RESULT_STATUS gpMetaGlobals->status +#define META_RESULT_PREVIOUS gpMetaGlobals->prev_mres +#define META_RESULT_ORIG_RET(type) *(type *)gpMetaGlobals->orig_ret +#define META_RESULT_OVERRIDE_RET(type) *(type *)gpMetaGlobals->override_ret + +// Table of getapi functions, retrieved from each plugin. +typedef struct { + GETENTITYAPI_FN pfnGetEntityAPI; + GETENTITYAPI_FN pfnGetEntityAPI_Post; + GETENTITYAPI2_FN pfnGetEntityAPI2; + GETENTITYAPI2_FN pfnGetEntityAPI2_Post; + GETNEWDLLFUNCTIONS_FN pfnGetNewDLLFunctions; + GETNEWDLLFUNCTIONS_FN pfnGetNewDLLFunctions_Post; + GET_ENGINE_FUNCTIONS_FN pfnGetEngineFunctions; + GET_ENGINE_FUNCTIONS_FN pfnGetEngineFunctions_Post; +} META_FUNCTIONS; + +// Pair of function tables provided by game DLL. +typedef struct { + DLL_FUNCTIONS *dllapi_table; + NEW_DLL_FUNCTIONS *newapi_table; +} gamedll_funcs_t; + +// Declared in plugin; referenced in macros. +extern gamedll_funcs_t *gpGamedllFuncs; +extern mutil_funcs_t *gpMetaUtilFuncs; + +// Tell the dll that we'll be loading it as a metamod plugin, in case it +// needs to do something special prior to the standard query/attach +// procedure. In particular, this will allow for DLL's that can be used as +// both standalone DLL's and metamod plugins. (optional; not required in +// plugin) +C_DLLEXPORT void Meta_Init(void); +typedef void (*META_INIT_FN) (void); + +// Get info about plugin, compare meta_interface versions, provide meta +// utility callback functions. +C_DLLEXPORT int Meta_Query(char *interfaceVersion, + plugin_info_t **plinfo, + mutil_funcs_t *pMetaUtilFuncs); +typedef int (*META_QUERY_FN) (char *interfaceVersion, + plugin_info_t **plinfo, + mutil_funcs_t *pMetaUtilFuncs); + +// Attach the plugin to the API; get the table of getapi functions; give +// meta_globals and gamedll_funcs. +C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, + META_FUNCTIONS *pFunctionTable, + meta_globals_t *pMGlobals, + gamedll_funcs_t *pGamedllFuncs); +typedef int (*META_ATTACH_FN) (PLUG_LOADTIME now, + META_FUNCTIONS *pFunctionTable, + meta_globals_t *pMGlobals, + gamedll_funcs_t *pGamedllFuncs); + +// Detach the plugin; tell why and when. +C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason); +typedef int (*META_DETACH_FN) (PLUG_LOADTIME now, PL_UNLOAD_REASON reason); + +// Standard HL SDK interface function prototypes. +C_DLLEXPORT int GetEntityAPI_Post(DLL_FUNCTIONS *pFunctionTable, + int interfaceVersion ); +C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, + int *interfaceVersion ); + +// Additional SDK-like interface function prototypes. +C_DLLEXPORT int GetNewDLLFunctions_Post(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion ); +C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion); +C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion); + +// Convenience macros for accessing GameDLL functions. Note: these talk +// _directly_ to the gamedll, and are not multiplexed through Metamod to +// the other plugins. +// DLL API functions: +#define MDLL_FUNC gpGamedllFuncs->dllapi_table + +#define MDLL_GameDLLInit MDLL_FUNC->pfnGameInit +#define MDLL_Spawn MDLL_FUNC->pfnSpawn +#define MDLL_Think MDLL_FUNC->pfnThink +#define MDLL_Use MDLL_FUNC->pfnUse +#define MDLL_Touch MDLL_FUNC->pfnTouch +#define MDLL_Blocked MDLL_FUNC->pfnBlocked +#define MDLL_KeyValue MDLL_FUNC->pfnKeyValue +#define MDLL_Save MDLL_FUNC->pfnSave +#define MDLL_Restore MDLL_FUNC->pfnRestore +#define MDLL_ObjectCollsionBox MDLL_FUNC->pfnAbsBox +#define MDLL_SaveWriteFields MDLL_FUNC->pfnSaveWriteFields +#define MDLL_SaveReadFields MDLL_FUNC->pfnSaveReadFields +#define MDLL_SaveGlobalState MDLL_FUNC->pfnSaveGlobalState +#define MDLL_RestoreGlobalState MDLL_FUNC->pfnRestoreGlobalState +#define MDLL_ResetGlobalState MDLL_FUNC->pfnResetGlobalState +#define MDLL_ClientConnect MDLL_FUNC->pfnClientConnect +#define MDLL_ClientDisconnect MDLL_FUNC->pfnClientDisconnect +#define MDLL_ClientKill MDLL_FUNC->pfnClientKill +#define MDLL_ClientPutInServer MDLL_FUNC->pfnClientPutInServer +#define MDLL_ClientCommand MDLL_FUNC->pfnClientCommand +#define MDLL_ClientUserInfoChanged MDLL_FUNC->pfnClientUserInfoChanged +#define MDLL_ServerActivate MDLL_FUNC->pfnServerActivate +#define MDLL_ServerDeactivate MDLL_FUNC->pfnServerDeactivate +#define MDLL_PlayerPreThink MDLL_FUNC->pfnPlayerPreThink +#define MDLL_PlayerPostThink MDLL_FUNC->pfnPlayerPostThink +#define MDLL_StartFrame MDLL_FUNC->pfnStartFrame +#define MDLL_ParmsNewLevel MDLL_FUNC->pfnParmsNewLevel +#define MDLL_ParmsChangeLevel MDLL_FUNC->pfnParmsChangeLevel +#define MDLL_GetGameDescription MDLL_FUNC->pfnGetGameDescription +#define MDLL_PlayerCustomization MDLL_FUNC->pfnPlayerCustomization +#define MDLL_SpectatorConnect MDLL_FUNC->pfnSpectatorConnect +#define MDLL_SpectatorDisconnect MDLL_FUNC->pfnSpectatorDisconnect +#define MDLL_SpectatorThink MDLL_FUNC->pfnSpectatorThink +#define MDLL_Sys_Error MDLL_FUNC->pfnSys_Error +#define MDLL_PM_Move MDLL_FUNC->pfnPM_Move +#define MDLL_PM_Init MDLL_FUNC->pfnPM_Init +#define MDLL_PM_FindTextureType MDLL_FUNC->pfnPM_FindTextureType +#define MDLL_SetupVisibility MDLL_FUNC->pfnSetupVisibility +#define MDLL_UpdateClientData MDLL_FUNC->pfnUpdateClientData +#define MDLL_AddToFullPack MDLL_FUNC->pfnAddToFullPack +#define MDLL_CreateBaseline MDLL_FUNC->pfnCreateBaseline +#define MDLL_RegisterEncoders MDLL_FUNC->pfnRegisterEncoders +#define MDLL_GetWeaponData MDLL_FUNC->pfnGetWeaponData +#define MDLL_CmdStart MDLL_FUNC->pfnCmdStart +#define MDLL_CmdEnd MDLL_FUNC->pfnCmdEnd +#define MDLL_ConnectionlessPacket MDLL_FUNC->pfnConnectionlessPacket +#define MDLL_GetHullBounds MDLL_FUNC->pfnGetHullBounds +#define MDLL_CreateInstancedBaselines MDLL_FUNC->pfnCreateInstancedBaselines +#define MDLL_InconsistentFile MDLL_FUNC->pfnInconsistentFile +#define MDLL_AllowLagCompensation MDLL_FUNC->pfnAllowLagCompensation + +// NEW API functions: +#define MNEW_FUNC gpGamedllFuncs->newapi_table + +#define MNEW_OnFreeEntPrivateData MNEW_FUNC->pfnOnFreeEntPrivateData +#define MNEW_GameShutdown MNEW_FUNC->pfnGameShutdown +#define MNEW_ShouldCollide MNEW_FUNC->pfnShouldCollide +#define MNEW_CvarValue MNEW_FUNC->pfnCvarValue +#define MNEW_CvarValue2 MNEW_FUNC->pfnCvarValue2 + +#endif /* META_API_H */ diff --git a/dep/metamod/mhook.h b/dep/metamod/mhook.h index 64f2e95..b56b0a6 100644 --- a/dep/metamod/mhook.h +++ b/dep/metamod/mhook.h @@ -1,157 +1,157 @@ -#ifdef UNFINISHED - -// mhook.h - class and types to describe hooks and hooklists - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef MHOOK_H -#define MHOOK_H - -#include "plinfo.h" // plid_t, etc -#include "types_meta.h" // mBOOL -#include "osdep.h" // MUTEX_T, etc - -#define MAX_HOOKS 100 - -// Particular game events that we detect, though whatever means we can best -// find. -typedef enum { - EV_NONE = 0, // no event here... - // non-log detected - EV_PLAYER_CONNECT, // ie ClientConnect - EV_PLAYER_ENTER, // ie ClientPutInServer - EV_PLAYER_LEAVE, // ie ClientDisconnect (opposite PutInServer) - EV_PLAYER_SPAWN, // deadflag change to DEAD_NO - EV_PLAYER_DEATH, // deadflag change to DEAD_DEAD - EV_PLAYER_CHANGE_NAME, // netname change in ClientUserInfoChanged - // log detected - EV_PLAYER_JOIN_TEAM, // ie "Joe<15><785><>" joined team "CT" - EV_PLAYER_SUICIDE, // ie "Joe<15><785>" committed suicide ... - EV_PLAYER_CHANGE_ROLE, // TFC: ie "Joe<15><785>" changed role to "Pyro" - EV_TEAM_KILL, // ie "Joe<15><785>" killed "Bob<16><342>" ... - EV_WEAPON_KILL, // ie "Joe<15><785>" killed "Sam<17><197>" with "sg552" - EV_TEAM_SCORE, // ie Team "CT" scored "7" with "2" players -} game_event_t; - -// Info corresponding to a player, in particular the info found in the logline. -typedef struct { - char *name; - int userid; - int wonid; - char *team; -} event_player_t; - -// Info for an event, mostly corresponding to info from a logline. -typedef struct { - game_event_t evtype; // specific event, if identified. - char *buf; // copy of the logmsg, with embedded NULLs - event_player_t *player; - char *action; // "triggered" string, or a generic action string - event_player_t *target; - char *with; -} event_args_t; - -// Types for callback functions to be called for requested event/logline. -typedef void (*event_func_t) (game_event_t event, event_args_t *args, - const char *logline); -typedef void (*logmatch_func_t) (const char *pattern, event_args_t *args, - const char *logline); - -// The 4 types of hook requests we accept. -typedef enum { - H_NONE = 0, - H_EVENT, // Specific event, from a short list. - H_TRIGGER, // A given "triggered" string. - H_STRING, // Any substring of logline. - H_REGEX, // A regular expression matching of logline. -} hook_t; - - -// Class for individual hook function, as registered by a plugin. -class MHook { - friend class MHookList; - friend class MFuncQueue; - private: - // data: - int index; - hook_t type; // EVENT, TRIGGER, etc - plid_t plid; - int pl_index; // index of matching plugin - void *pfnHandle; - game_event_t event; // if type is H_EVENT - const char *match; // if type is TRIGGER, STRING, or REGEX - // Copy/Assignment constructors, to satisfy -Weffc++. - // Note however, we declare them private and don't define them, since - // we don't ever want to copy or assign instances of the class. - // (thanks to O'Reilly "C++: The Core Language", page 113) - MHook(const MHook &src); - void operator=(const MHook &src); - // constructors: - MHook(void); - MHook(int idx, plid_t pid, game_event_t evt, event_func_t pfn); - MHook(int idx, plid_t pid, hook_t tp, const char *cp, logmatch_func_t pfn); - // functions: - mBOOL call(event_args_t *args, const char *logline); - mBOOL enqueue(MFuncQueue *mfq, event_args_t *args, const char *logline); - public: - // no public interfaces; everything done from friend MHookList. -}; - - -// Class for list of registered hook functions. -class MHookList { - private: - // data: - MHook *hlist[MAX_HOOKS]; - int size; // set to MAX_HOOKS in constructor - int endlist; - MUTEX_T mx_hlist; - int MXlock(void) { return(MUTEX_LOCK(&mx_hlist)); }; - int MXunlock(void) { return(MUTEX_UNLOCK(&mx_hlist)); }; - public: - // constructor: - MHookList(void); - // functions: - int add(plid_t plid, game_event_t event, event_func_t pfnHandle); - int add(plid_t plid, hook_t type, const char *match, - logmatch_func_t pfnHandle); - mBOOL remove(plid_t plid, int hindex); - int remove_all(plid_t plid); - mBOOL call(event_args_t *args, const char *logline); - mBOOL enqueue(MFuncQueue *mfq, hook_t htype, event_args_t *evargs, - const char *logline); - char *str_htype(hook_t htype); -}; - -#endif /* MHOOK_H */ - -#endif /* UNFINISHED */ +#ifdef UNFINISHED + +// mhook.h - class and types to describe hooks and hooklists + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef MHOOK_H +#define MHOOK_H + +#include "plinfo.h" // plid_t, etc +#include "types_meta.h" // mBOOL +#include "osdep.h" // MUTEX_T, etc + +#define MAX_HOOKS 100 + +// Particular game events that we detect, though whatever means we can best +// find. +typedef enum { + EV_NONE = 0, // no event here... + // non-log detected + EV_PLAYER_CONNECT, // ie ClientConnect + EV_PLAYER_ENTER, // ie ClientPutInServer + EV_PLAYER_LEAVE, // ie ClientDisconnect (opposite PutInServer) + EV_PLAYER_SPAWN, // deadflag change to DEAD_NO + EV_PLAYER_DEATH, // deadflag change to DEAD_DEAD + EV_PLAYER_CHANGE_NAME, // netname change in ClientUserInfoChanged + // log detected + EV_PLAYER_JOIN_TEAM, // ie "Joe<15><785><>" joined team "CT" + EV_PLAYER_SUICIDE, // ie "Joe<15><785>" committed suicide ... + EV_PLAYER_CHANGE_ROLE, // TFC: ie "Joe<15><785>" changed role to "Pyro" + EV_TEAM_KILL, // ie "Joe<15><785>" killed "Bob<16><342>" ... + EV_WEAPON_KILL, // ie "Joe<15><785>" killed "Sam<17><197>" with "sg552" + EV_TEAM_SCORE, // ie Team "CT" scored "7" with "2" players +} game_event_t; + +// Info corresponding to a player, in particular the info found in the logline. +typedef struct { + char *name; + int userid; + int wonid; + char *team; +} event_player_t; + +// Info for an event, mostly corresponding to info from a logline. +typedef struct { + game_event_t evtype; // specific event, if identified. + char *buf; // copy of the logmsg, with embedded NULLs + event_player_t *player; + char *action; // "triggered" string, or a generic action string + event_player_t *target; + char *with; +} event_args_t; + +// Types for callback functions to be called for requested event/logline. +typedef void (*event_func_t) (game_event_t event, event_args_t *args, + const char *logline); +typedef void (*logmatch_func_t) (const char *pattern, event_args_t *args, + const char *logline); + +// The 4 types of hook requests we accept. +typedef enum { + H_NONE = 0, + H_EVENT, // Specific event, from a short list. + H_TRIGGER, // A given "triggered" string. + H_STRING, // Any substring of logline. + H_REGEX, // A regular expression matching of logline. +} hook_t; + + +// Class for individual hook function, as registered by a plugin. +class MHook { + friend class MHookList; + friend class MFuncQueue; + private: + // data: + int index; + hook_t type; // EVENT, TRIGGER, etc + plid_t plid; + int pl_index; // index of matching plugin + void *pfnHandle; + game_event_t event; // if type is H_EVENT + const char *match; // if type is TRIGGER, STRING, or REGEX + // Copy/Assignment constructors, to satisfy -Weffc++. + // Note however, we declare them private and don't define them, since + // we don't ever want to copy or assign instances of the class. + // (thanks to O'Reilly "C++: The Core Language", page 113) + MHook(const MHook &src); + void operator=(const MHook &src); + // constructors: + MHook(void); + MHook(int idx, plid_t pid, game_event_t evt, event_func_t pfn); + MHook(int idx, plid_t pid, hook_t tp, const char *cp, logmatch_func_t pfn); + // functions: + mBOOL call(event_args_t *args, const char *logline); + mBOOL enqueue(MFuncQueue *mfq, event_args_t *args, const char *logline); + public: + // no public interfaces; everything done from friend MHookList. +}; + + +// Class for list of registered hook functions. +class MHookList { + private: + // data: + MHook *hlist[MAX_HOOKS]; + int size; // set to MAX_HOOKS in constructor + int endlist; + MUTEX_T mx_hlist; + int MXlock(void) { return(MUTEX_LOCK(&mx_hlist)); }; + int MXunlock(void) { return(MUTEX_UNLOCK(&mx_hlist)); }; + public: + // constructor: + MHookList(void); + // functions: + int add(plid_t plid, game_event_t event, event_func_t pfnHandle); + int add(plid_t plid, hook_t type, const char *match, + logmatch_func_t pfnHandle); + mBOOL remove(plid_t plid, int hindex); + int remove_all(plid_t plid); + mBOOL call(event_args_t *args, const char *logline); + mBOOL enqueue(MFuncQueue *mfq, hook_t htype, event_args_t *evargs, + const char *logline); + char *str_htype(hook_t htype); +}; + +#endif /* MHOOK_H */ + +#endif /* UNFINISHED */ diff --git a/dep/metamod/mreg.h b/dep/metamod/mreg.h index b66395e..00fe0c9 100644 --- a/dep/metamod/mreg.h +++ b/dep/metamod/mreg.h @@ -1,183 +1,183 @@ -// mreg.h - description of registered items (classes MRegCmd, MRegCmdList) - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef MREG_H -#define MREG_H - -#include "types_meta.h" // mBOOL - -// Number of entries to add to reglists when they need to grow. Typically -// more cvars than commands, so we grow them at different increments. -#define REG_CMD_GROWSIZE 32 -#define REG_CVAR_GROWSIZE 64 - -// Width required to printf a Reg*List index number, for show() functions. -// This used to correspond to the number of digits in MAX_REG, which was a -// fixed, compile-time limit. However, now that the reg lists are grown -// dynamically, this has less strong correspondance to list sizes. So for -// the moment, it reflects what one might normally expect to be the max -// width needed to print an index number; 4 allows 9999 (which is a damn -// lot, if you ask me). -#define WIDTH_MAX_REG 4 - -// Max number of registered user msgs we can manage. -#define MAX_REG_MSGS 256 - -// Flags to indicate if given cvar or func is part of a loaded plugin. -typedef enum { - RG_INVALID, - RG_VALID, -} REG_STATUS; - -// Pointer to function registered by AddServerCommand. -typedef void (*REG_CMD_FN) (void); - - -// An individual registered function/command. -class MRegCmd { - friend class MRegCmdList; - private: - // data: - int index; // 1-based - public: - char *name; // space is malloc'd - REG_CMD_FN pfnCmd; // pointer to the function - int plugid; // index id of corresponding plugin - REG_STATUS status; // whether corresponding plugin is loaded - // functions: - void init(int idx); // init values, as not using constructors - mBOOL call(void); // try to call the function -}; - - -// A list of registered commands. -class MRegCmdList { - private: - // data: - MRegCmd *mlist; // malloc'd array of registered commands - int size; // current size of list - int endlist; // index of last used entry - // Private; to satisfy -Weffc++ "has pointer data members but does - // not override" copy/assignment constructor. - void operator=(const MRegCmdList &src); - MRegCmdList(const MRegCmdList &src); - - public: - // constructor: - MRegCmdList(void); - - // functions: - MRegCmd *find(const char *findname); // find by MRegCmd->name - MRegCmd *add(const char *addname); - void disable(int plugin_id); // change status to Invalid - void show(void); // list all funcs to console - void show(int plugin_id); // list given plugin's funcs to console -}; - - - -// An individual registered cvar. -class MRegCvar { - friend class MRegCvarList; - private: - // data: - int index; // 1-based - public: - cvar_t *data; // actual cvar structure, malloc'd - int plugid; // index id of corresponding plugin - REG_STATUS status; // whether corresponding plugin is loaded - // functions: - void init(int idx); // init values, as not using constructors - mBOOL set(cvar_t *src); -}; - - -// A list of registered cvars. -class MRegCvarList { - private: - // data: - MRegCvar *vlist; // malloc'd array of registered cvars - int size; // size of list, ie MAX_REG_CVARS - int endlist; // index of last used entry - // Private; to satisfy -Weffc++ "has pointer data members but does - // not override" copy/assignment constructor. - void operator=(const MRegCvarList &src); - MRegCvarList(const MRegCvarList &src); - - public: - // constructor: - MRegCvarList(void); - - // functions: - MRegCvar *add(const char *addname); - MRegCvar *find(const char *findname); // find by MRegCvar->data.name - void disable(int plugin_id); // change status to Invalid - void show(void); // list all cvars to console - void show(int plugin_id); // list given plugin's cvars to console -}; - - - -// An individual registered user msg, from gamedll. -class MRegMsg { - friend class MRegMsgList; - private: - // data: - int index; // 1-based - public: - const char *name; // name, assumed constant string in gamedll - int msgid; // msgid, assigned by engine - int size; // size, if given by gamedll -}; - - -// A list of registered user msgs. -class MRegMsgList { - private: - // data: - MRegMsg mlist[MAX_REG_MSGS]; // array of registered msgs - int size; // size of list, ie MAX_REG_MSGS - int endlist; // index of last used entry - - public: - // constructor: - MRegMsgList(void); - - // functions: - MRegMsg *add(const char *addname, int addmsgid, int addsize); - MRegMsg *find(const char *findname); - MRegMsg *find(int findmsgid); - void show(void); // list all msgs to console -}; - -#endif /* MREG_H */ +// mreg.h - description of registered items (classes MRegCmd, MRegCmdList) + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef MREG_H +#define MREG_H + +#include "types_meta.h" // mBOOL + +// Number of entries to add to reglists when they need to grow. Typically +// more cvars than commands, so we grow them at different increments. +#define REG_CMD_GROWSIZE 32 +#define REG_CVAR_GROWSIZE 64 + +// Width required to printf a Reg*List index number, for show() functions. +// This used to correspond to the number of digits in MAX_REG, which was a +// fixed, compile-time limit. However, now that the reg lists are grown +// dynamically, this has less strong correspondance to list sizes. So for +// the moment, it reflects what one might normally expect to be the max +// width needed to print an index number; 4 allows 9999 (which is a damn +// lot, if you ask me). +#define WIDTH_MAX_REG 4 + +// Max number of registered user msgs we can manage. +#define MAX_REG_MSGS 256 + +// Flags to indicate if given cvar or func is part of a loaded plugin. +typedef enum { + RG_INVALID, + RG_VALID, +} REG_STATUS; + +// Pointer to function registered by AddServerCommand. +typedef void (*REG_CMD_FN) (void); + + +// An individual registered function/command. +class MRegCmd { + friend class MRegCmdList; + private: + // data: + int index; // 1-based + public: + char *name; // space is malloc'd + REG_CMD_FN pfnCmd; // pointer to the function + int plugid; // index id of corresponding plugin + REG_STATUS status; // whether corresponding plugin is loaded + // functions: + void init(int idx); // init values, as not using constructors + mBOOL call(void); // try to call the function +}; + + +// A list of registered commands. +class MRegCmdList { + private: + // data: + MRegCmd *mlist; // malloc'd array of registered commands + int size; // current size of list + int endlist; // index of last used entry + // Private; to satisfy -Weffc++ "has pointer data members but does + // not override" copy/assignment constructor. + void operator=(const MRegCmdList &src); + MRegCmdList(const MRegCmdList &src); + + public: + // constructor: + MRegCmdList(void); + + // functions: + MRegCmd *find(const char *findname); // find by MRegCmd->name + MRegCmd *add(const char *addname); + void disable(int plugin_id); // change status to Invalid + void show(void); // list all funcs to console + void show(int plugin_id); // list given plugin's funcs to console +}; + + + +// An individual registered cvar. +class MRegCvar { + friend class MRegCvarList; + private: + // data: + int index; // 1-based + public: + cvar_t *data; // actual cvar structure, malloc'd + int plugid; // index id of corresponding plugin + REG_STATUS status; // whether corresponding plugin is loaded + // functions: + void init(int idx); // init values, as not using constructors + mBOOL set(cvar_t *src); +}; + + +// A list of registered cvars. +class MRegCvarList { + private: + // data: + MRegCvar *vlist; // malloc'd array of registered cvars + int size; // size of list, ie MAX_REG_CVARS + int endlist; // index of last used entry + // Private; to satisfy -Weffc++ "has pointer data members but does + // not override" copy/assignment constructor. + void operator=(const MRegCvarList &src); + MRegCvarList(const MRegCvarList &src); + + public: + // constructor: + MRegCvarList(void); + + // functions: + MRegCvar *add(const char *addname); + MRegCvar *find(const char *findname); // find by MRegCvar->data.name + void disable(int plugin_id); // change status to Invalid + void show(void); // list all cvars to console + void show(int plugin_id); // list given plugin's cvars to console +}; + + + +// An individual registered user msg, from gamedll. +class MRegMsg { + friend class MRegMsgList; + private: + // data: + int index; // 1-based + public: + const char *name; // name, assumed constant string in gamedll + int msgid; // msgid, assigned by engine + int size; // size, if given by gamedll +}; + + +// A list of registered user msgs. +class MRegMsgList { + private: + // data: + MRegMsg mlist[MAX_REG_MSGS]; // array of registered msgs + int size; // size of list, ie MAX_REG_MSGS + int endlist; // index of last used entry + + public: + // constructor: + MRegMsgList(void); + + // functions: + MRegMsg *add(const char *addname, int addmsgid, int addsize); + MRegMsg *find(const char *findname); + MRegMsg *find(int findmsgid); + void show(void); // list all msgs to console +}; + +#endif /* MREG_H */ diff --git a/dep/metamod/mutil.h b/dep/metamod/mutil.h index 2d6c9f7..eb7edc4 100644 --- a/dep/metamod/mutil.h +++ b/dep/metamod/mutil.h @@ -1,157 +1,157 @@ -// mutil.h - prototypes for utility functions to provide to plugins - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef MUTIL_H -#define MUTIL_H - -#include "plinfo.h" // plugin_info_t, etc -#include "mhook.h" // game_event_t, etc -#include "sdk_util.h" // hudtextparms_t, etc - -// max buffer size for printed messages -#define MAX_LOGMSG_LEN 1024 - -// For GetGameInfo: -typedef enum { - GINFO_NAME = 0, - GINFO_DESC, - GINFO_GAMEDIR, - GINFO_DLL_FULLPATH, - GINFO_DLL_FILENAME, - GINFO_REALDLL_FULLPATH, -} ginfo_t; - -// Meta Utility Function table type. -typedef struct meta_util_funcs_s { - void (*pfnLogConsole) (plid_t plid, const char *fmt, ...); - void (*pfnLogMessage) (plid_t plid, const char *fmt, ...); - void (*pfnLogError) (plid_t plid, const char *fmt, ...); - void (*pfnLogDeveloper) (plid_t plid, const char *fmt, ...); - void (*pfnCenterSay) (plid_t plid, const char *fmt, ...); - void (*pfnCenterSayParms) (plid_t plid, hudtextparms_t tparms, - const char *fmt, ...); - void (*pfnCenterSayVarargs) (plid_t plid, hudtextparms_t tparms, - const char *fmt, va_list ap); - qboolean (*pfnCallGameEntity) (plid_t plid, const char *entStr, - entvars_t *pev); - int (*pfnGetUserMsgID) (plid_t plid, const char *msgname, int *size); - const char *(*pfnGetUserMsgName) (plid_t plid, int msgid, int *size); - const char *(*pfnGetPluginPath) (plid_t plid); - const char *(*pfnGetGameInfo) (plid_t plid, ginfo_t tag); - int (*pfnLoadPlugin) (plid_t plid, const char *cmdline, PLUG_LOADTIME now, void **plugin_handle); - int (*pfnUnloadPlugin) (plid_t plid, const char *cmdline, PLUG_LOADTIME now, PL_UNLOAD_REASON reason); - int (*pfnUnloadPluginByHandle) (plid_t plid, void *plugin_handle, PLUG_LOADTIME now, PL_UNLOAD_REASON reason); - const char *(*pfnIsQueryingClientCvar) (plid_t plid, const edict_t *pEdict); - int (*pfnMakeRequestId) (plid_t plid); - void (*pfnGetHookTables) (plid_t plid, enginefuncs_t **peng, DLL_FUNCTIONS **pdll, NEW_DLL_FUNCTIONS **pnewdll); -#ifdef UNFINISHED - int (*pfnHookGameEvent) (plid_t plid, game_event_t event, - event_func_t pfnHandle); - int (*pfnHookLogTrigger) (plid_t plid, const char *trigger, - logmatch_func_t pfnHandle); - int (*pfnHookLogString) (plid_t plid, const char *string, - logmatch_func_t pfnHandle); - int (*pfnHookLogRegex) (plid_t plid, const char *pattern, - logmatch_func_t pfnHandle); - qboolean (*pfnRemoveHookID) (plid_t plid, int hookid); - int (*pfnRemoveHookAll) (plid_t plid); -#endif /* UNFINISHED */ -} mutil_funcs_t; -extern mutil_funcs_t MetaUtilFunctions; - -// Meta Utility Functions -void mutil_LogConsole(plid_t plid, const char *fmt, ...); -void mutil_LogMessage(plid_t plid, const char *fmt, ...); -void mutil_LogError(plid_t plid, const char *fmt, ...); -void mutil_LogDeveloper(plid_t plid, const char *fmt, ...); - -void mutil_CenterSay(plid_t plid, const char *fmt, ...); -void mutil_CenterSayParms(plid_t plid, hudtextparms_t tparms, - const char *fmt, ...); -void mutil_CenterSayVarargs(plid_t plid, hudtextparms_t tparms, - const char *fmt, va_list ap); - -qboolean mutil_CallGameEntity(plid_t plid, const char *entStr, entvars_t *pev); - -int mutil_GetUserMsgID(plid_t plid, const char *name, int *size); -const char *mutil_GetUserMsgName(plid_t plid, int msgid, int *size); -const char *mutil_GetPluginPath(plid_t plid); -const char *mutil_GetGameInfo(plid_t plid, ginfo_t tag); -const char *mutil_IsQueryingClientCvar(plid_t plid, const edict_t *pEdict); -int mutil_MakeRequestId(plid_t plid); -void mutil_GetHookTables(plid_t plid, enginefuncs_t **peng, DLL_FUNCTIONS **pdll, NEW_DLL_FUNCTIONS **pnewdll); - -#ifdef UNFINISHED -int mutil_HookGameEvent(plid_t plid, game_event_t event, - event_func_t pfnHandle); -int mutil_HookLogTrigger(plid_t plid, const char *trigger, - logmatch_func_t pfnHandle); -int mutil_HookLogString(plid_t plid, const char *string, - logmatch_func_t pfnHandle); -int mutil_HookLogRegex(plid_t plid, const char *pattern, - logmatch_func_t pfnHandle); - -qboolean mutil_RemoveHookID(plid_t plid, int hookid); -int mutil_RemoveHookAll(plid_t plid); -#endif /* UNFINISHED */ - -// Convenience macros for MetaUtil functions -#define LOG_CONSOLE (*gpMetaUtilFuncs->pfnLogConsole) -#define LOG_MESSAGE (*gpMetaUtilFuncs->pfnLogMessage) -#define LOG_ERROR (*gpMetaUtilFuncs->pfnLogError) -#define LOG_DEVELOPER (*gpMetaUtilFuncs->pfnLogDeveloper) -#define CENTER_SAY (*gpMetaUtilFuncs->pfnCenterSay) -#define CENTER_SAY_PARMS (*gpMetaUtilFuncs->pfnCenterSayParms) -#define CENTER_SAY_VARARGS (*gpMetaUtilFuncs->pfnCenterSayVarargs) -#define CALL_GAME_ENTITY (*gpMetaUtilFuncs->pfnCallGameEntity) -#define GET_USER_MSG_ID (*gpMetaUtilFuncs->pfnGetUserMsgID) -#define GET_USER_MSG_NAME (*gpMetaUtilFuncs->pfnGetUserMsgName) -#define GET_PLUGIN_PATH (*gpMetaUtilFuncs->pfnGetPluginPath) -#define GET_GAME_INFO (*gpMetaUtilFuncs->pfnGetGameInfo) -#define LOAD_PLUGIN (*gpMetaUtilFuncs->pfnLoadPlugin) -#define UNLOAD_PLUGIN (*gpMetaUtilFuncs->pfnUnloadPlugin) -#define UNLOAD_PLUGIN_BY_HANDLE (*gpMetaUtilFuncs->pfnUnloadPluginByHandle) -#define IS_QUERYING_CLIENT_CVAR (*gpMetaUtilFuncs->pfnIsQueryingClientCvar) -#define MAKE_REQUESTID (*gpMetaUtilFuncs->pfnMakeRequestId) -#define GET_HOOK_TABLES (*gpMetaUtilFuncs->pfnGetHookTables) - -#ifdef UNFINISHED -#define HOOK_GAME_EVENT (*gpMetaUtilFuncs->pfnHookGameEvent) -#define HOOK_LOG_TRIGGER (*gpMetaUtilFuncs->pfnHookLogTrigger) -#define HOOK_LOG_STRING (*gpMetaUtilFuncs->pfnHookLogString) -#define HOOK_LOG_REGEX (*gpMetaUtilFuncs->pfnHookLogRegex) -#define REMOVE_HOOK_ID (*gpMetaUtilFuncs->pfnRemoveHookID) -#define REMOVE_HOOK_ALL (*gpMetaUtilFuncs->pfnRemoveHookAll) -#endif /* UNFINISHED */ - -#endif /* MUTIL_H */ +// mutil.h - prototypes for utility functions to provide to plugins + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef MUTIL_H +#define MUTIL_H + +#include "plinfo.h" // plugin_info_t, etc +#include "mhook.h" // game_event_t, etc +#include "sdk_util.h" // hudtextparms_t, etc + +// max buffer size for printed messages +#define MAX_LOGMSG_LEN 1024 + +// For GetGameInfo: +typedef enum { + GINFO_NAME = 0, + GINFO_DESC, + GINFO_GAMEDIR, + GINFO_DLL_FULLPATH, + GINFO_DLL_FILENAME, + GINFO_REALDLL_FULLPATH, +} ginfo_t; + +// Meta Utility Function table type. +typedef struct meta_util_funcs_s { + void (*pfnLogConsole) (plid_t plid, const char *fmt, ...); + void (*pfnLogMessage) (plid_t plid, const char *fmt, ...); + void (*pfnLogError) (plid_t plid, const char *fmt, ...); + void (*pfnLogDeveloper) (plid_t plid, const char *fmt, ...); + void (*pfnCenterSay) (plid_t plid, const char *fmt, ...); + void (*pfnCenterSayParms) (plid_t plid, hudtextparms_t tparms, + const char *fmt, ...); + void (*pfnCenterSayVarargs) (plid_t plid, hudtextparms_t tparms, + const char *fmt, va_list ap); + qboolean (*pfnCallGameEntity) (plid_t plid, const char *entStr, + entvars_t *pev); + int (*pfnGetUserMsgID) (plid_t plid, const char *msgname, int *size); + const char *(*pfnGetUserMsgName) (plid_t plid, int msgid, int *size); + const char *(*pfnGetPluginPath) (plid_t plid); + const char *(*pfnGetGameInfo) (plid_t plid, ginfo_t tag); + int (*pfnLoadPlugin) (plid_t plid, const char *cmdline, PLUG_LOADTIME now, void **plugin_handle); + int (*pfnUnloadPlugin) (plid_t plid, const char *cmdline, PLUG_LOADTIME now, PL_UNLOAD_REASON reason); + int (*pfnUnloadPluginByHandle) (plid_t plid, void *plugin_handle, PLUG_LOADTIME now, PL_UNLOAD_REASON reason); + const char *(*pfnIsQueryingClientCvar) (plid_t plid, const edict_t *pEdict); + int (*pfnMakeRequestId) (plid_t plid); + void (*pfnGetHookTables) (plid_t plid, enginefuncs_t **peng, DLL_FUNCTIONS **pdll, NEW_DLL_FUNCTIONS **pnewdll); +#ifdef UNFINISHED + int (*pfnHookGameEvent) (plid_t plid, game_event_t event, + event_func_t pfnHandle); + int (*pfnHookLogTrigger) (plid_t plid, const char *trigger, + logmatch_func_t pfnHandle); + int (*pfnHookLogString) (plid_t plid, const char *string, + logmatch_func_t pfnHandle); + int (*pfnHookLogRegex) (plid_t plid, const char *pattern, + logmatch_func_t pfnHandle); + qboolean (*pfnRemoveHookID) (plid_t plid, int hookid); + int (*pfnRemoveHookAll) (plid_t plid); +#endif /* UNFINISHED */ +} mutil_funcs_t; +extern mutil_funcs_t MetaUtilFunctions; + +// Meta Utility Functions +void mutil_LogConsole(plid_t plid, const char *fmt, ...); +void mutil_LogMessage(plid_t plid, const char *fmt, ...); +void mutil_LogError(plid_t plid, const char *fmt, ...); +void mutil_LogDeveloper(plid_t plid, const char *fmt, ...); + +void mutil_CenterSay(plid_t plid, const char *fmt, ...); +void mutil_CenterSayParms(plid_t plid, hudtextparms_t tparms, + const char *fmt, ...); +void mutil_CenterSayVarargs(plid_t plid, hudtextparms_t tparms, + const char *fmt, va_list ap); + +qboolean mutil_CallGameEntity(plid_t plid, const char *entStr, entvars_t *pev); + +int mutil_GetUserMsgID(plid_t plid, const char *name, int *size); +const char *mutil_GetUserMsgName(plid_t plid, int msgid, int *size); +const char *mutil_GetPluginPath(plid_t plid); +const char *mutil_GetGameInfo(plid_t plid, ginfo_t tag); +const char *mutil_IsQueryingClientCvar(plid_t plid, const edict_t *pEdict); +int mutil_MakeRequestId(plid_t plid); +void mutil_GetHookTables(plid_t plid, enginefuncs_t **peng, DLL_FUNCTIONS **pdll, NEW_DLL_FUNCTIONS **pnewdll); + +#ifdef UNFINISHED +int mutil_HookGameEvent(plid_t plid, game_event_t event, + event_func_t pfnHandle); +int mutil_HookLogTrigger(plid_t plid, const char *trigger, + logmatch_func_t pfnHandle); +int mutil_HookLogString(plid_t plid, const char *string, + logmatch_func_t pfnHandle); +int mutil_HookLogRegex(plid_t plid, const char *pattern, + logmatch_func_t pfnHandle); + +qboolean mutil_RemoveHookID(plid_t plid, int hookid); +int mutil_RemoveHookAll(plid_t plid); +#endif /* UNFINISHED */ + +// Convenience macros for MetaUtil functions +#define LOG_CONSOLE (*gpMetaUtilFuncs->pfnLogConsole) +#define LOG_MESSAGE (*gpMetaUtilFuncs->pfnLogMessage) +#define LOG_ERROR (*gpMetaUtilFuncs->pfnLogError) +#define LOG_DEVELOPER (*gpMetaUtilFuncs->pfnLogDeveloper) +#define CENTER_SAY (*gpMetaUtilFuncs->pfnCenterSay) +#define CENTER_SAY_PARMS (*gpMetaUtilFuncs->pfnCenterSayParms) +#define CENTER_SAY_VARARGS (*gpMetaUtilFuncs->pfnCenterSayVarargs) +#define CALL_GAME_ENTITY (*gpMetaUtilFuncs->pfnCallGameEntity) +#define GET_USER_MSG_ID (*gpMetaUtilFuncs->pfnGetUserMsgID) +#define GET_USER_MSG_NAME (*gpMetaUtilFuncs->pfnGetUserMsgName) +#define GET_PLUGIN_PATH (*gpMetaUtilFuncs->pfnGetPluginPath) +#define GET_GAME_INFO (*gpMetaUtilFuncs->pfnGetGameInfo) +#define LOAD_PLUGIN (*gpMetaUtilFuncs->pfnLoadPlugin) +#define UNLOAD_PLUGIN (*gpMetaUtilFuncs->pfnUnloadPlugin) +#define UNLOAD_PLUGIN_BY_HANDLE (*gpMetaUtilFuncs->pfnUnloadPluginByHandle) +#define IS_QUERYING_CLIENT_CVAR (*gpMetaUtilFuncs->pfnIsQueryingClientCvar) +#define MAKE_REQUESTID (*gpMetaUtilFuncs->pfnMakeRequestId) +#define GET_HOOK_TABLES (*gpMetaUtilFuncs->pfnGetHookTables) + +#ifdef UNFINISHED +#define HOOK_GAME_EVENT (*gpMetaUtilFuncs->pfnHookGameEvent) +#define HOOK_LOG_TRIGGER (*gpMetaUtilFuncs->pfnHookLogTrigger) +#define HOOK_LOG_STRING (*gpMetaUtilFuncs->pfnHookLogString) +#define HOOK_LOG_REGEX (*gpMetaUtilFuncs->pfnHookLogRegex) +#define REMOVE_HOOK_ID (*gpMetaUtilFuncs->pfnRemoveHookID) +#define REMOVE_HOOK_ALL (*gpMetaUtilFuncs->pfnRemoveHookAll) +#endif /* UNFINISHED */ + +#endif /* MUTIL_H */ diff --git a/dep/metamod/osdep.h b/dep/metamod/osdep.h index 9dfe734..3666cb2 100644 --- a/dep/metamod/osdep.h +++ b/dep/metamod/osdep.h @@ -1,519 +1,519 @@ -// osdep.h - operating system dependencies - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef OSDEP_H -#define OSDEP_H - -#include // strerror() -#include // isupper, tolower -#include // errno - -// Various differences between WIN32 and Linux. - -#include "types_meta.h" // mBOOL -#include "mreg.h" // REG_CMD_FN, etc -#include "log_meta.h" // LOG_ERROR, etc - -extern mBOOL dlclose_handle_invalid; - -// String describing platform/DLL-type, for matching lines in plugins.ini. -#ifdef __linux__ - #define PLATFORM "linux" -# ifdef __amd64__ - #define PLATFORM_SPC "lin64" -# else - #define PLATFORM_SPC "lin32" -# endif -#elif defined(_WIN32) - #define PLATFORM "mswin" - #define PLATFORM_SPC "win32" -#else /* unknown */ - #error "OS unrecognized" -#endif /* unknown */ - - -// Macro for function-exporting from DLL.. -// from SDK dlls/cbase.h: -//! C functions for external declarations that call the appropriate C++ methods - -// Windows uses "__declspec(dllexport)" to mark functions in the DLL that -// should be visible/callable externally. -// -// It also apparently requires WINAPI for GiveFnptrsToDll(). -// -// See doc/notes_windows_coding for more information.. - -// Attributes to specify an "exported" function, visible from outside the -// DLL. -#undef DLLEXPORT -#ifdef _WIN32 - #define DLLEXPORT __declspec(dllexport) - // WINAPI should be provided in the windows compiler headers. - // It's usually defined to something like "__stdcall". -#elif defined(__linux__) - #define DLLEXPORT __attribute__((visibility("default"))) - #define WINAPI /* */ -#endif /* linux */ - -#ifdef __GNUC__ -# define DECLSPEC(kw) -# define ATTRIBUTE(kw) __attribute__((kw)) -# define MM_CDECL -#elif defined(_MSC_VER) -# define DECLSPEC(kw) __declspec(kw) -# define ATTRIBUTE(kw) -# define MM_CDECL __cdecl -#endif /* _MSC_VER */ - - -// Simplified macro for declaring/defining exported DLL functions. They -// need to be 'extern "C"' so that the C++ compiler enforces parameter -// type-matching, rather than considering routines with mis-matched -// arguments/types to be overloaded functions... -// -// AFAIK, this is os-independent, but it's included here in osdep.h where -// DLLEXPORT is defined, for convenience. -#define C_DLLEXPORT extern "C" DLLEXPORT - - -#ifdef _MSC_VER - // Disable MSVC warning: - // 4390 : empty controlled statement found; is this what was intended? - // generated by the RETURN macros. - #pragma warning(disable: 4390) -#endif /* _MSC_VER */ - - -// Functions & types for DLL open/close/etc operations. -#ifdef __linux__ - #include - typedef void* DLHANDLE; - typedef void* DLFUNC; - inline DLHANDLE DLOPEN(const char *filename) { - return(dlopen(filename, RTLD_NOW)); - } - inline DLFUNC DLSYM(DLHANDLE handle, const char *string) { - return(dlsym(handle, string)); - } - inline int DLCLOSE(DLHANDLE handle) { - if (!handle) { - dlclose_handle_invalid = mTRUE; - return(1); - } - dlclose_handle_invalid = mFALSE; - return(dlclose(handle)); - } - inline char* DLERROR(void) { - if (dlclose_handle_invalid) - return("Invalid handle."); - return(dlerror()); - } -#elif defined(_WIN32) - typedef HINSTANCE DLHANDLE; - typedef FARPROC DLFUNC; - inline DLHANDLE DLOPEN(const char *filename) { - return(LoadLibrary(filename)); - } - inline DLFUNC DLSYM(DLHANDLE handle, const char *string) { - return(GetProcAddress(handle, string)); - } - inline int DLCLOSE(DLHANDLE handle) { - if (!handle) { - dlclose_handle_invalid = mTRUE; - return(1); - } - dlclose_handle_invalid = mFALSE; - // NOTE: Windows FreeLibrary returns success=nonzero, fail=zero, - // which is the opposite of the unix convention, thus the '!'. - return(!FreeLibrary(handle)); - } - // Windows doesn't provide a function corresponding to dlerror(), so - // we make our own. - char *str_GetLastError(void); - inline char* DLERROR(void) { - if (dlclose_handle_invalid) - return("Invalid handle."); - return(str_GetLastError()); - } -#endif /* _WIN32 */ -const char *DLFNAME(void *memptr); -mBOOL IS_VALID_PTR(void *memptr); - - -// Attempt to call the given function pointer, without segfaulting. -mBOOL os_safe_call(REG_CMD_FN pfn); - - -// Windows doesn't have an strtok_r() routine, so we write our own. -#ifdef _WIN32 - #define strtok_r(s, delim, ptrptr) my_strtok_r(s, delim, ptrptr) - char *my_strtok_r(char *s, const char *delim, char **ptrptr); -#endif /* _WIN32 */ - - -// Set filename and pathname maximum lengths. Note some windows compilers -// provide a which is incomplete and/or causes problems; see -// doc/windows_notes.txt for more information. -// -// Note that both OS's include room for null-termination: -// linux: "# chars in a path name including nul" -// win32: "note that the sizes include space for 0-terminator" -#ifdef __linux__ - #include -#elif defined(_WIN32) - #include - #define NAME_MAX _MAX_FNAME - #define PATH_MAX _MAX_PATH -#endif /* _WIN32 */ - - -// Various other windows routine differences. -#ifdef __linux__ - #include // sleep - #ifndef O_BINARY - #define O_BINARY 0 - #endif -#elif defined(_WIN32) - #define snprintf _snprintf - #define vsnprintf _vsnprintf - #define sleep(x) Sleep(x*1000) - #define strcasecmp _stricmp - #define strncasecmp _strnicmp - #include - #define open _open - #define read _read - #define write _write - #define close _close -#endif /* _WIN32 */ - -#ifdef __GNUC__ - #include // getcwd -#elif defined(_MSC_VER) - #include // getcwd -#endif /* _MSC_VER */ - -#include -#ifndef S_ISREG - // Linux gcc defines this; earlier mingw didn't, later mingw does; - // MSVC doesn't seem to. - #define S_ISREG(m) ((m) & S_IFREG) -#endif /* not S_ISREG */ -#ifdef _WIN32 - // The following two are defined in mingw but not in MSVC - #ifndef S_IRUSR - #define S_IRUSR _S_IREAD - #endif - #ifndef S_IWUSR - #define S_IWUSR _S_IWRITE - #endif - - // The following two are defined neither in mingw nor in MSVC - #ifndef S_IRGRP - #define S_IRGRP S_IRUSR - #endif - #ifndef S_IWGRP - #define S_IWGRP S_IWUSR - #endif -#endif /* _WIN32 */ - - -// Our handler for new(). -// -// Thanks to notes from: -// http://dragon.klte.hu/~kollarl/C++/node45.html -// -// At one point it appeared MSVC++ was no longer different from gcc, according -// to: -// http://msdn.microsoft.com/library/en-us/vclang98/stdlib/info/NEW.asp -// -// However, this page is apparently no longer available from MSDN. The -// only thing now is: -// http://msdn.microsoft.com/library/en-us/vccore98/HTML/_crt_malloc.asp -// -// According to Fritz Elfert : -// set_new_handler() is just a stub which (according to comments in the -// MSVCRT debugging sources) should never be used. It is just an ugly -// hack to make STL compile. It does _not_ set the new handler but -// always calls _set_new_handler(0) instead. _set_new_handler is the -// "real" function and uses the "old" semantic; handler-type is: -// int newhandler(size_t) -// -#if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 1300)) - void MM_CDECL meta_new_handler(void); -#elif defined(_MSC_VER) - int meta_new_handler(size_t size); -#endif /* _MSC_VER */ - - -// To keep the rest of the sources clean and keep not only OS but also -// compiler dependant differences in this file, we define a local function -// to set the new handler. -void mm_set_new_handler( void ); - - - -// Thread handling... -#ifdef __linux__ - #include - typedef pthread_t THREAD_T; - // returns 0==success, non-zero==failure - inline int THREAD_CREATE(THREAD_T *tid, void (*func)(void)) { - int ret; - ret=pthread_create(tid, NULL, (void *(*)(void*)) func, NULL); - if(ret != 0) { - META_ERROR("Failure starting thread: %s", strerror(ret)); - return(ret); - } - ret=pthread_detach(*tid); - if(ret != 0) - META_ERROR("Failure detaching thread: %s", strerror(ret)); - return(ret); - } -#elif defined(_WIN32) - // See: - // http://msdn.microsoft.com/library/en-us/dllproc/prothred_4084.asp - typedef DWORD THREAD_T; - // returns 0==success, non-zero==failure - inline int THREAD_CREATE(THREAD_T *tid, void (*func)(void)) { - HANDLE ret; - // win32 returns NULL==failure, non-NULL==success - ret=CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) func, NULL, 0, tid); - if(ret==NULL) - META_ERROR("Failure starting thread: %s", str_GetLastError()); - return(ret==NULL); - } -#endif /* _WIN32 */ -#define THREAD_OK 0 - - -// Mutex handling... -#ifdef __linux__ - typedef pthread_mutex_t MUTEX_T; - inline int MUTEX_INIT(MUTEX_T *mutex) { - int ret; - ret=pthread_mutex_init(mutex, NULL); - if(ret!=THREAD_OK) - META_ERROR("mutex_init failed: %s", strerror(ret)); - return(ret); - } - inline int MUTEX_LOCK(MUTEX_T *mutex) { - int ret; - ret=pthread_mutex_lock(mutex); - if(ret!=THREAD_OK) - META_ERROR("mutex_lock failed: %s", strerror(ret)); - return(ret); - } - inline int MUTEX_UNLOCK(MUTEX_T *mutex) { - int ret; - ret=pthread_mutex_unlock(mutex); - if(ret!=THREAD_OK) - META_ERROR("mutex_unlock failed: %s", strerror(ret)); - return(ret); - } -#elif defined(_WIN32) - // Win32 has "mutexes" as well, but CS's are simpler. - // See: - // http://msdn.microsoft.com/library/en-us/dllproc/synchro_2a2b.asp - typedef CRITICAL_SECTION MUTEX_T; - // Note win32 routines don't return any error (return void). - inline int MUTEX_INIT(MUTEX_T *mutex) { - InitializeCriticalSection(mutex); - return(THREAD_OK); - } - inline int MUTEX_LOCK(MUTEX_T *mutex) { - EnterCriticalSection(mutex); - return(THREAD_OK); - } - inline int MUTEX_UNLOCK(MUTEX_T *mutex) { - LeaveCriticalSection(mutex); - return(THREAD_OK); - } -#endif /* _WIN32 (mutex) */ - - -// Condition variables... -#ifdef __linux__ - typedef pthread_cond_t COND_T; - inline int COND_INIT(COND_T *cond) { - int ret; - ret=pthread_cond_init(cond, NULL); - if(ret!=THREAD_OK) - META_ERROR("cond_init failed: %s", strerror(ret)); - return(ret); - } - inline int COND_WAIT(COND_T *cond, MUTEX_T *mutex) { - int ret; - ret=pthread_cond_wait(cond, mutex); - if(ret!=THREAD_OK) - META_ERROR("cond_wait failed: %s", strerror(ret)); - return(ret); - } - inline int COND_SIGNAL(COND_T *cond) { - int ret; - ret=pthread_cond_signal(cond); - if(ret!=THREAD_OK) - META_ERROR("cond_signal failed: %s", strerror(ret)); - return(ret); - } -#elif defined(_WIN32) - // Since win32 doesn't provide condition-variables, we have to model - // them with mutex/critical-sections and win32 events. This uses the - // second (SetEvent) solution from: - // - // http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - // - // but without the waiters_count overhead, since we don't need - // broadcast functionality anyway. Or actually, I guess it's more like - // the first (PulseEvent) solution, but with SetEven rather than - // PulseEvent. :) - // - // See also: - // http://msdn.microsoft.com/library/en-us/dllproc/synchro_8ann.asp - typedef HANDLE COND_T; - inline int COND_INIT(COND_T *cond) { - *cond = CreateEvent(NULL, // security attributes (none) - FALSE, // manual-reset type (false==auto-reset) - FALSE, // initial state (unsignaled) - NULL); // object name (unnamed) - // returns NULL on error - if(*cond==NULL) { - META_ERROR("cond_init failed: %s", str_GetLastError()); - return(-1); - } - else - return(0); - } - inline int COND_WAIT(COND_T *cond, MUTEX_T *mutex) { - DWORD ret; - LeaveCriticalSection(mutex); - ret=WaitForSingleObject(*cond, INFINITE); - EnterCriticalSection(mutex); - // returns WAIT_OBJECT_0 if object was signaled; other return - // values indicate errors. - if(ret == WAIT_OBJECT_0) - return(0); - else { - META_ERROR("cond_wait failed: %s", str_GetLastError()); - return(-1); - } - } - inline int COND_SIGNAL(COND_T *cond) { - BOOL ret; - ret=SetEvent(*cond); - // returns zero on failure - if(ret==0) { - META_ERROR("cond_signal failed: %s", str_GetLastError()); - return(-1); - } - else - return(0); - } -#endif /* _WIN32 (condition variable) */ - -// Normalize/standardize a pathname. -// - For win32, this involves: -// - Turning backslashes (\) into slashes (/), so that config files and -// Metamod internal code can be simpler and just use slashes (/). -// - Turning upper/mixed case into lowercase, since windows is -// non-case-sensitive. -// - For linux, this requires no work, as paths uses slashes (/) natively, -// and pathnames are case-sensitive. -#ifdef __linux__ -#define normalize_pathname(a) -#elif defined(_WIN32) -inline void normalize_pathname(char *path) { - char *cp; - - META_DEBUG(8, ("normalize: %s", path)); - for(cp=path; *cp; cp++) { - if(isupper(*cp)) *cp=tolower(*cp); - if(*cp=='\\') *cp='/'; - } - META_DEBUG(8, ("normalized: %s", path)); -} -#endif /* _WIN32 */ - -// Indicate if pathname appears to be an absolute-path. Under linux this -// is a leading slash (/). Under win32, this can be: -// - a drive-letter path (ie "D:blah" or "C:\blah") -// - a toplevel path (ie "\blah") -// - a UNC network address (ie "\\srv1\blah"). -// Also, handle both native and normalized pathnames. -inline int is_absolute_path(const char *path) { - if(path[0]=='/') return(TRUE); -#ifdef _WIN32 - if(path[1]==':') return(TRUE); - if(path[0]=='\\') return(TRUE); -#endif /* _WIN32 */ - return(FALSE); -} - -#ifdef _WIN32 -// Buffer pointed to by resolved_name is assumed to be able to store a -// string of PATH_MAX length. -inline char *realpath(const char *file_name, char *resolved_name) { - int ret; - ret=GetFullPathName(file_name, PATH_MAX, resolved_name, NULL); - if(ret > PATH_MAX) { - errno=ENAMETOOLONG; - return(NULL); - } - else if(ret > 0) { - HANDLE handle; - WIN32_FIND_DATA find_data; - handle=FindFirstFile(resolved_name, &find_data); - if(INVALID_HANDLE_VALUE == handle) { - errno=ENOENT; - return NULL; - } - FindClose(handle); - normalize_pathname(resolved_name); - return(resolved_name); - } - else - return(NULL); -} -#endif /* _WIN32 */ - -// Generic "error string" from a recent OS call. For linux, this is based -// on errno. For win32, it's based on GetLastError. -inline const char *str_os_error(void) { -#ifdef __linux__ - return(strerror(errno)); -#elif defined(_WIN32) - return(str_GetLastError()); -#endif /* _WIN32 */ -} - - -#endif /* OSDEP_H */ +// osdep.h - operating system dependencies + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef OSDEP_H +#define OSDEP_H + +#include // strerror() +#include // isupper, tolower +#include // errno + +// Various differences between WIN32 and Linux. + +#include "types_meta.h" // mBOOL +#include "mreg.h" // REG_CMD_FN, etc +#include "log_meta.h" // LOG_ERROR, etc + +extern mBOOL dlclose_handle_invalid; + +// String describing platform/DLL-type, for matching lines in plugins.ini. +#ifdef __linux__ + #define PLATFORM "linux" +# ifdef __amd64__ + #define PLATFORM_SPC "lin64" +# else + #define PLATFORM_SPC "lin32" +# endif +#elif defined(_WIN32) + #define PLATFORM "mswin" + #define PLATFORM_SPC "win32" +#else /* unknown */ + #error "OS unrecognized" +#endif /* unknown */ + + +// Macro for function-exporting from DLL.. +// from SDK dlls/cbase.h: +//! C functions for external declarations that call the appropriate C++ methods + +// Windows uses "__declspec(dllexport)" to mark functions in the DLL that +// should be visible/callable externally. +// +// It also apparently requires WINAPI for GiveFnptrsToDll(). +// +// See doc/notes_windows_coding for more information.. + +// Attributes to specify an "exported" function, visible from outside the +// DLL. +#undef DLLEXPORT +#ifdef _WIN32 + #define DLLEXPORT __declspec(dllexport) + // WINAPI should be provided in the windows compiler headers. + // It's usually defined to something like "__stdcall". +#elif defined(__linux__) + #define DLLEXPORT __attribute__((visibility("default"))) + #define WINAPI /* */ +#endif /* linux */ + +#ifdef __GNUC__ +# define DECLSPEC(kw) +# define ATTRIBUTE(kw) __attribute__((kw)) +# define MM_CDECL +#elif defined(_MSC_VER) +# define DECLSPEC(kw) __declspec(kw) +# define ATTRIBUTE(kw) +# define MM_CDECL __cdecl +#endif /* _MSC_VER */ + + +// Simplified macro for declaring/defining exported DLL functions. They +// need to be 'extern "C"' so that the C++ compiler enforces parameter +// type-matching, rather than considering routines with mis-matched +// arguments/types to be overloaded functions... +// +// AFAIK, this is os-independent, but it's included here in osdep.h where +// DLLEXPORT is defined, for convenience. +#define C_DLLEXPORT extern "C" DLLEXPORT + + +#ifdef _MSC_VER + // Disable MSVC warning: + // 4390 : empty controlled statement found; is this what was intended? + // generated by the RETURN macros. + #pragma warning(disable: 4390) +#endif /* _MSC_VER */ + + +// Functions & types for DLL open/close/etc operations. +#ifdef __linux__ + #include + typedef void* DLHANDLE; + typedef void* DLFUNC; + inline DLHANDLE DLOPEN(const char *filename) { + return(dlopen(filename, RTLD_NOW)); + } + inline DLFUNC DLSYM(DLHANDLE handle, const char *string) { + return(dlsym(handle, string)); + } + inline int DLCLOSE(DLHANDLE handle) { + if (!handle) { + dlclose_handle_invalid = mTRUE; + return(1); + } + dlclose_handle_invalid = mFALSE; + return(dlclose(handle)); + } + inline char* DLERROR(void) { + if (dlclose_handle_invalid) + return("Invalid handle."); + return(dlerror()); + } +#elif defined(_WIN32) + typedef HINSTANCE DLHANDLE; + typedef FARPROC DLFUNC; + inline DLHANDLE DLOPEN(const char *filename) { + return(LoadLibrary(filename)); + } + inline DLFUNC DLSYM(DLHANDLE handle, const char *string) { + return(GetProcAddress(handle, string)); + } + inline int DLCLOSE(DLHANDLE handle) { + if (!handle) { + dlclose_handle_invalid = mTRUE; + return(1); + } + dlclose_handle_invalid = mFALSE; + // NOTE: Windows FreeLibrary returns success=nonzero, fail=zero, + // which is the opposite of the unix convention, thus the '!'. + return(!FreeLibrary(handle)); + } + // Windows doesn't provide a function corresponding to dlerror(), so + // we make our own. + char *str_GetLastError(void); + inline char* DLERROR(void) { + if (dlclose_handle_invalid) + return("Invalid handle."); + return(str_GetLastError()); + } +#endif /* _WIN32 */ +const char *DLFNAME(void *memptr); +mBOOL IS_VALID_PTR(void *memptr); + + +// Attempt to call the given function pointer, without segfaulting. +mBOOL os_safe_call(REG_CMD_FN pfn); + + +// Windows doesn't have an strtok_r() routine, so we write our own. +#ifdef _WIN32 + #define strtok_r(s, delim, ptrptr) my_strtok_r(s, delim, ptrptr) + char *my_strtok_r(char *s, const char *delim, char **ptrptr); +#endif /* _WIN32 */ + + +// Set filename and pathname maximum lengths. Note some windows compilers +// provide a which is incomplete and/or causes problems; see +// doc/windows_notes.txt for more information. +// +// Note that both OS's include room for null-termination: +// linux: "# chars in a path name including nul" +// win32: "note that the sizes include space for 0-terminator" +#ifdef __linux__ + #include +#elif defined(_WIN32) + #include + #define NAME_MAX _MAX_FNAME + #define PATH_MAX _MAX_PATH +#endif /* _WIN32 */ + + +// Various other windows routine differences. +#ifdef __linux__ + #include // sleep + #ifndef O_BINARY + #define O_BINARY 0 + #endif +#elif defined(_WIN32) + #define snprintf _snprintf + #define vsnprintf _vsnprintf + #define sleep(x) Sleep(x*1000) + #define strcasecmp _stricmp + #define strncasecmp _strnicmp + #include + #define open _open + #define read _read + #define write _write + #define close _close +#endif /* _WIN32 */ + +#ifdef __GNUC__ + #include // getcwd +#elif defined(_MSC_VER) + #include // getcwd +#endif /* _MSC_VER */ + +#include +#ifndef S_ISREG + // Linux gcc defines this; earlier mingw didn't, later mingw does; + // MSVC doesn't seem to. + #define S_ISREG(m) ((m) & S_IFREG) +#endif /* not S_ISREG */ +#ifdef _WIN32 + // The following two are defined in mingw but not in MSVC + #ifndef S_IRUSR + #define S_IRUSR _S_IREAD + #endif + #ifndef S_IWUSR + #define S_IWUSR _S_IWRITE + #endif + + // The following two are defined neither in mingw nor in MSVC + #ifndef S_IRGRP + #define S_IRGRP S_IRUSR + #endif + #ifndef S_IWGRP + #define S_IWGRP S_IWUSR + #endif +#endif /* _WIN32 */ + + +// Our handler for new(). +// +// Thanks to notes from: +// http://dragon.klte.hu/~kollarl/C++/node45.html +// +// At one point it appeared MSVC++ was no longer different from gcc, according +// to: +// http://msdn.microsoft.com/library/en-us/vclang98/stdlib/info/NEW.asp +// +// However, this page is apparently no longer available from MSDN. The +// only thing now is: +// http://msdn.microsoft.com/library/en-us/vccore98/HTML/_crt_malloc.asp +// +// According to Fritz Elfert : +// set_new_handler() is just a stub which (according to comments in the +// MSVCRT debugging sources) should never be used. It is just an ugly +// hack to make STL compile. It does _not_ set the new handler but +// always calls _set_new_handler(0) instead. _set_new_handler is the +// "real" function and uses the "old" semantic; handler-type is: +// int newhandler(size_t) +// +#if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 1300)) + void MM_CDECL meta_new_handler(void); +#elif defined(_MSC_VER) + int meta_new_handler(size_t size); +#endif /* _MSC_VER */ + + +// To keep the rest of the sources clean and keep not only OS but also +// compiler dependant differences in this file, we define a local function +// to set the new handler. +void mm_set_new_handler( void ); + + + +// Thread handling... +#ifdef __linux__ + #include + typedef pthread_t THREAD_T; + // returns 0==success, non-zero==failure + inline int THREAD_CREATE(THREAD_T *tid, void (*func)(void)) { + int ret; + ret=pthread_create(tid, NULL, (void *(*)(void*)) func, NULL); + if(ret != 0) { + META_ERROR("Failure starting thread: %s", strerror(ret)); + return(ret); + } + ret=pthread_detach(*tid); + if(ret != 0) + META_ERROR("Failure detaching thread: %s", strerror(ret)); + return(ret); + } +#elif defined(_WIN32) + // See: + // http://msdn.microsoft.com/library/en-us/dllproc/prothred_4084.asp + typedef DWORD THREAD_T; + // returns 0==success, non-zero==failure + inline int THREAD_CREATE(THREAD_T *tid, void (*func)(void)) { + HANDLE ret; + // win32 returns NULL==failure, non-NULL==success + ret=CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) func, NULL, 0, tid); + if(ret==NULL) + META_ERROR("Failure starting thread: %s", str_GetLastError()); + return(ret==NULL); + } +#endif /* _WIN32 */ +#define THREAD_OK 0 + + +// Mutex handling... +#ifdef __linux__ + typedef pthread_mutex_t MUTEX_T; + inline int MUTEX_INIT(MUTEX_T *mutex) { + int ret; + ret=pthread_mutex_init(mutex, NULL); + if(ret!=THREAD_OK) + META_ERROR("mutex_init failed: %s", strerror(ret)); + return(ret); + } + inline int MUTEX_LOCK(MUTEX_T *mutex) { + int ret; + ret=pthread_mutex_lock(mutex); + if(ret!=THREAD_OK) + META_ERROR("mutex_lock failed: %s", strerror(ret)); + return(ret); + } + inline int MUTEX_UNLOCK(MUTEX_T *mutex) { + int ret; + ret=pthread_mutex_unlock(mutex); + if(ret!=THREAD_OK) + META_ERROR("mutex_unlock failed: %s", strerror(ret)); + return(ret); + } +#elif defined(_WIN32) + // Win32 has "mutexes" as well, but CS's are simpler. + // See: + // http://msdn.microsoft.com/library/en-us/dllproc/synchro_2a2b.asp + typedef CRITICAL_SECTION MUTEX_T; + // Note win32 routines don't return any error (return void). + inline int MUTEX_INIT(MUTEX_T *mutex) { + InitializeCriticalSection(mutex); + return(THREAD_OK); + } + inline int MUTEX_LOCK(MUTEX_T *mutex) { + EnterCriticalSection(mutex); + return(THREAD_OK); + } + inline int MUTEX_UNLOCK(MUTEX_T *mutex) { + LeaveCriticalSection(mutex); + return(THREAD_OK); + } +#endif /* _WIN32 (mutex) */ + + +// Condition variables... +#ifdef __linux__ + typedef pthread_cond_t COND_T; + inline int COND_INIT(COND_T *cond) { + int ret; + ret=pthread_cond_init(cond, NULL); + if(ret!=THREAD_OK) + META_ERROR("cond_init failed: %s", strerror(ret)); + return(ret); + } + inline int COND_WAIT(COND_T *cond, MUTEX_T *mutex) { + int ret; + ret=pthread_cond_wait(cond, mutex); + if(ret!=THREAD_OK) + META_ERROR("cond_wait failed: %s", strerror(ret)); + return(ret); + } + inline int COND_SIGNAL(COND_T *cond) { + int ret; + ret=pthread_cond_signal(cond); + if(ret!=THREAD_OK) + META_ERROR("cond_signal failed: %s", strerror(ret)); + return(ret); + } +#elif defined(_WIN32) + // Since win32 doesn't provide condition-variables, we have to model + // them with mutex/critical-sections and win32 events. This uses the + // second (SetEvent) solution from: + // + // http://www.cs.wustl.edu/~schmidt/win32-cv-1.html + // + // but without the waiters_count overhead, since we don't need + // broadcast functionality anyway. Or actually, I guess it's more like + // the first (PulseEvent) solution, but with SetEven rather than + // PulseEvent. :) + // + // See also: + // http://msdn.microsoft.com/library/en-us/dllproc/synchro_8ann.asp + typedef HANDLE COND_T; + inline int COND_INIT(COND_T *cond) { + *cond = CreateEvent(NULL, // security attributes (none) + FALSE, // manual-reset type (false==auto-reset) + FALSE, // initial state (unsignaled) + NULL); // object name (unnamed) + // returns NULL on error + if(*cond==NULL) { + META_ERROR("cond_init failed: %s", str_GetLastError()); + return(-1); + } + else + return(0); + } + inline int COND_WAIT(COND_T *cond, MUTEX_T *mutex) { + DWORD ret; + LeaveCriticalSection(mutex); + ret=WaitForSingleObject(*cond, INFINITE); + EnterCriticalSection(mutex); + // returns WAIT_OBJECT_0 if object was signaled; other return + // values indicate errors. + if(ret == WAIT_OBJECT_0) + return(0); + else { + META_ERROR("cond_wait failed: %s", str_GetLastError()); + return(-1); + } + } + inline int COND_SIGNAL(COND_T *cond) { + BOOL ret; + ret=SetEvent(*cond); + // returns zero on failure + if(ret==0) { + META_ERROR("cond_signal failed: %s", str_GetLastError()); + return(-1); + } + else + return(0); + } +#endif /* _WIN32 (condition variable) */ + +// Normalize/standardize a pathname. +// - For win32, this involves: +// - Turning backslashes (\) into slashes (/), so that config files and +// Metamod internal code can be simpler and just use slashes (/). +// - Turning upper/mixed case into lowercase, since windows is +// non-case-sensitive. +// - For linux, this requires no work, as paths uses slashes (/) natively, +// and pathnames are case-sensitive. +#ifdef __linux__ +#define normalize_pathname(a) +#elif defined(_WIN32) +inline void normalize_pathname(char *path) { + char *cp; + + META_DEBUG(8, ("normalize: %s", path)); + for(cp=path; *cp; cp++) { + if(isupper(*cp)) *cp=tolower(*cp); + if(*cp=='\\') *cp='/'; + } + META_DEBUG(8, ("normalized: %s", path)); +} +#endif /* _WIN32 */ + +// Indicate if pathname appears to be an absolute-path. Under linux this +// is a leading slash (/). Under win32, this can be: +// - a drive-letter path (ie "D:blah" or "C:\blah") +// - a toplevel path (ie "\blah") +// - a UNC network address (ie "\\srv1\blah"). +// Also, handle both native and normalized pathnames. +inline int is_absolute_path(const char *path) { + if(path[0]=='/') return(TRUE); +#ifdef _WIN32 + if(path[1]==':') return(TRUE); + if(path[0]=='\\') return(TRUE); +#endif /* _WIN32 */ + return(FALSE); +} + +#ifdef _WIN32 +// Buffer pointed to by resolved_name is assumed to be able to store a +// string of PATH_MAX length. +inline char *realpath(const char *file_name, char *resolved_name) { + int ret; + ret=GetFullPathName(file_name, PATH_MAX, resolved_name, NULL); + if(ret > PATH_MAX) { + errno=ENAMETOOLONG; + return(NULL); + } + else if(ret > 0) { + HANDLE handle; + WIN32_FIND_DATA find_data; + handle=FindFirstFile(resolved_name, &find_data); + if(INVALID_HANDLE_VALUE == handle) { + errno=ENOENT; + return NULL; + } + FindClose(handle); + normalize_pathname(resolved_name); + return(resolved_name); + } + else + return(NULL); +} +#endif /* _WIN32 */ + +// Generic "error string" from a recent OS call. For linux, this is based +// on errno. For win32, it's based on GetLastError. +inline const char *str_os_error(void) { +#ifdef __linux__ + return(strerror(errno)); +#elif defined(_WIN32) + return(str_GetLastError()); +#endif /* _WIN32 */ +} + + +#endif /* OSDEP_H */ diff --git a/dep/metamod/plinfo.h b/dep/metamod/plinfo.h index f781864..9e5b744 100644 --- a/dep/metamod/plinfo.h +++ b/dep/metamod/plinfo.h @@ -1,79 +1,79 @@ -// plinfo.h - typedefs for plugin info structure - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef PLINFO_H -#define PLINFO_H - -// Flags for plugin to indicate when it can be be loaded/unloaded. -// NOTE: order is crucial, as greater/less comparisons are made. -typedef enum { - PT_NEVER = 0, - PT_STARTUP, // should only be loaded/unloaded at initial hlds execution - PT_CHANGELEVEL, // can be loaded/unloaded between maps - PT_ANYTIME, // can be loaded/unloaded at any time - PT_ANYPAUSE, // can be loaded/unloaded at any time, and can be "paused" during a map -} PLUG_LOADTIME; - -// Flags to indicate why the plugin is being unloaded. -typedef enum { - PNL_NULL = 0, - PNL_INI_DELETED, // was deleted from plugins.ini - PNL_FILE_NEWER, // file on disk is newer than last load - PNL_COMMAND, // requested by server/console command - PNL_CMD_FORCED, // forced by server/console command - PNL_DELAYED, // delayed from previous request; can't tell origin -//only used for 'real_reason' on MPlugin::unload() - PNL_PLUGIN, // requested by plugin function call - PNL_PLG_FORCED, // forced by plugin function call - PNL_RELOAD, // forced unload by reload() -} PL_UNLOAD_REASON; - -// Information plugin provides about itself. -typedef struct { - char *ifvers; // meta_interface version - char *name; // full name of plugin - char *version; // version - char *date; // date - char *author; // author name/email - char *url; // URL - char *logtag; // log message prefix (unused right now) - PLUG_LOADTIME loadable; // when loadable - PLUG_LOADTIME unloadable; // when unloadable -} plugin_info_t; -extern plugin_info_t Plugin_info; - -// Plugin identifier, passed to all Meta Utility Functions. -typedef plugin_info_t* plid_t; -#define PLID &Plugin_info - -#endif /* PLINFO_H */ +// plinfo.h - typedefs for plugin info structure + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef PLINFO_H +#define PLINFO_H + +// Flags for plugin to indicate when it can be be loaded/unloaded. +// NOTE: order is crucial, as greater/less comparisons are made. +typedef enum { + PT_NEVER = 0, + PT_STARTUP, // should only be loaded/unloaded at initial hlds execution + PT_CHANGELEVEL, // can be loaded/unloaded between maps + PT_ANYTIME, // can be loaded/unloaded at any time + PT_ANYPAUSE, // can be loaded/unloaded at any time, and can be "paused" during a map +} PLUG_LOADTIME; + +// Flags to indicate why the plugin is being unloaded. +typedef enum { + PNL_NULL = 0, + PNL_INI_DELETED, // was deleted from plugins.ini + PNL_FILE_NEWER, // file on disk is newer than last load + PNL_COMMAND, // requested by server/console command + PNL_CMD_FORCED, // forced by server/console command + PNL_DELAYED, // delayed from previous request; can't tell origin +//only used for 'real_reason' on MPlugin::unload() + PNL_PLUGIN, // requested by plugin function call + PNL_PLG_FORCED, // forced by plugin function call + PNL_RELOAD, // forced unload by reload() +} PL_UNLOAD_REASON; + +// Information plugin provides about itself. +typedef struct { + char *ifvers; // meta_interface version + char *name; // full name of plugin + char *version; // version + char *date; // date + char *author; // author name/email + char *url; // URL + char *logtag; // log message prefix (unused right now) + PLUG_LOADTIME loadable; // when loadable + PLUG_LOADTIME unloadable; // when unloadable +} plugin_info_t; +extern plugin_info_t Plugin_info; + +// Plugin identifier, passed to all Meta Utility Functions. +typedef plugin_info_t* plid_t; +#define PLID &Plugin_info + +#endif /* PLINFO_H */ diff --git a/dep/metamod/sdk_util.h b/dep/metamod/sdk_util.h index 9a997f6..5b70010 100644 --- a/dep/metamod/sdk_util.h +++ b/dep/metamod/sdk_util.h @@ -1,112 +1,112 @@ -// sdk_util.h - wrapper & extension of util.h from HL SDK - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -// Wrap util.h from SDK with ifndef/endif, to avoid problems from multiple -// inclusions. Dunno why Valve didn't do that in util.h themselves.. - -#ifndef SDK_UTIL_H -#define SDK_UTIL_H - -// We're not including the DBG_EntOfVars and DBG_AssertFunction routines -// mentioned in the SDK util.h, so we're going to unset DEBUG here so that -// we don't get "unresolved symbol" errors. -#ifdef DEBUG -#undef DEBUG -#endif /* DEBUG */ - -// Inlcude local enginecallbacks wrapper *first* so that the g_engfuncs -// type is correct and the header protection is already -// defined. -#include "enginecallbacks.h" - -#include - - - -// Add overloaded ENTINDEX() version for const edict_t pointer. -// The pfnIndexOfEdict() function takes a const edict_t pointer -// as parameter anyway, so there is no reason why ENTINDEX() -// shouldn't. -inline int ENTINDEX(const edict_t *pEdict) { - return (*g_engfuncs.pfnIndexOfEdict)(pEdict); -} - - -// Also, create some nice inlines for engine callback combos. - -// Get a setinfo value from a player entity. -inline char *ENTITY_KEYVALUE(edict_t *entity, char *key) { - char *ifbuf=GET_INFOKEYBUFFER(entity); - return(INFOKEY_VALUE(ifbuf, key)); -} - -// Set a setinfo value for a player entity. -inline void ENTITY_SET_KEYVALUE(edict_t *entity, char *key, char *value) { - char *ifbuf=GET_INFOKEYBUFFER(entity); - SET_CLIENT_KEYVALUE(ENTINDEX(entity), ifbuf, key, value); -} - -// Get a "serverinfo" value. -inline char *SERVERINFO(char *key) { - edict_t *server=INDEXENT(0); - return(ENTITY_KEYVALUE(server, key)); -} - -// Set a "serverinfo" value. -inline void SET_SERVERINFO(char *key, char *value) { - edict_t *server=INDEXENT(0); - char *ifbuf=GET_INFOKEYBUFFER(server); - SET_SERVER_KEYVALUE(ifbuf, key, value); -} - -// Get a "localinfo" value. -inline char *LOCALINFO(char *key) { - edict_t *server=NULL; - return(ENTITY_KEYVALUE(server, key)); -} - -// Set a "localinfo" value. -inline void SET_LOCALINFO(char *key, char *value) { - edict_t *server=NULL; - char *ifbuf=GET_INFOKEYBUFFER(server); - SET_SERVER_KEYVALUE(ifbuf, key, value); -} - -short FixedSigned16(float value, float scale); -unsigned short FixedUnsigned16(float value, float scale); - -// Our slightly modified version, using an edict_t pointer instead of a -// CBaseEntity pointer. -void META_UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, const char *pMessage); - -#endif /* SDK_UTIL_H */ +// sdk_util.h - wrapper & extension of util.h from HL SDK + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +// Wrap util.h from SDK with ifndef/endif, to avoid problems from multiple +// inclusions. Dunno why Valve didn't do that in util.h themselves.. + +#ifndef SDK_UTIL_H +#define SDK_UTIL_H + +// We're not including the DBG_EntOfVars and DBG_AssertFunction routines +// mentioned in the SDK util.h, so we're going to unset DEBUG here so that +// we don't get "unresolved symbol" errors. +#ifdef DEBUG +#undef DEBUG +#endif /* DEBUG */ + +// Inlcude local enginecallbacks wrapper *first* so that the g_engfuncs +// type is correct and the header protection is already +// defined. +#include "enginecallbacks.h" + +#include + + + +// Add overloaded ENTINDEX() version for const edict_t pointer. +// The pfnIndexOfEdict() function takes a const edict_t pointer +// as parameter anyway, so there is no reason why ENTINDEX() +// shouldn't. +inline int ENTINDEX(const edict_t *pEdict) { + return (*g_engfuncs.pfnIndexOfEdict)(pEdict); +} + + +// Also, create some nice inlines for engine callback combos. + +// Get a setinfo value from a player entity. +inline char *ENTITY_KEYVALUE(edict_t *entity, char *key) { + char *ifbuf=GET_INFOKEYBUFFER(entity); + return(INFOKEY_VALUE(ifbuf, key)); +} + +// Set a setinfo value for a player entity. +inline void ENTITY_SET_KEYVALUE(edict_t *entity, char *key, char *value) { + char *ifbuf=GET_INFOKEYBUFFER(entity); + SET_CLIENT_KEYVALUE(ENTINDEX(entity), ifbuf, key, value); +} + +// Get a "serverinfo" value. +inline char *SERVERINFO(char *key) { + edict_t *server=INDEXENT(0); + return(ENTITY_KEYVALUE(server, key)); +} + +// Set a "serverinfo" value. +inline void SET_SERVERINFO(char *key, char *value) { + edict_t *server=INDEXENT(0); + char *ifbuf=GET_INFOKEYBUFFER(server); + SET_SERVER_KEYVALUE(ifbuf, key, value); +} + +// Get a "localinfo" value. +inline char *LOCALINFO(char *key) { + edict_t *server=NULL; + return(ENTITY_KEYVALUE(server, key)); +} + +// Set a "localinfo" value. +inline void SET_LOCALINFO(char *key, char *value) { + edict_t *server=NULL; + char *ifbuf=GET_INFOKEYBUFFER(server); + SET_SERVER_KEYVALUE(ifbuf, key, value); +} + +short FixedSigned16(float value, float scale); +unsigned short FixedUnsigned16(float value, float scale); + +// Our slightly modified version, using an edict_t pointer instead of a +// CBaseEntity pointer. +void META_UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, const char *pMessage); + +#endif /* SDK_UTIL_H */ diff --git a/dep/metamod/types_meta.h b/dep/metamod/types_meta.h index db4a226..6f5bb5d 100644 --- a/dep/metamod/types_meta.h +++ b/dep/metamod/types_meta.h @@ -1,79 +1,79 @@ -// types_meta.h - common internal type, etc definitions - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef TYPES_META_H -#define TYPES_META_H - -// Our own boolean type, for stricter type matching. -typedef enum mBOOL { - mFALSE = 0, - mTRUE, -} mBOOL; - -// Like C's errno, for our various functions; describes causes of failure -// or mFALSE returns. -typedef enum { - ME_NOERROR = 0, - ME_FORMAT, // invalid format - ME_COMMENT, // ignored comment - ME_BLANK, // ignored blank (empty) line - ME_ALREADY, // request had already been done - ME_DELAYED, // request is delayed - ME_NOTALLOWED, // request not allowed - ME_SKIPPED, // request is being skipped for whatever reason - ME_BADREQ, // invalid request for this - ME_ARGUMENT, // invalid arguments - ME_NULLRESULT, // resulting data was empty or null - ME_MAXREACHED, // reached max/limit - ME_NOTUNIQ, // not unique (ambigious match) - ME_NOTFOUND, // in find operation, match not found - ME_NOFILE, // file empty or missing - ME_NOMEM, // malloc failed - ME_BADMEMPTR, // invalid memory address - ME_OSNOTSUP, // OS doesn't support this operation - ME_DLOPEN, // failed to open shared lib/dll - ME_DLMISSING, // symbol missing in lib/dll - ME_DLERROR, // some other error encountered calling functions from dll - ME_IFVERSION, // incompatible interface version - ME_UNLOAD_UNLOADER, // tried to unload unloader - ME_UNLOAD_SELF, // tried to unload self -} META_ERRNO; -extern META_ERRNO meta_errno; - -#define RETURN_ERRNO(retval, errval) \ - do { meta_errno=errval; return(retval); } while(0) - -#define RETURN_LOGERR_ERRNO(errargs, retval, errval) \ - do { META_ERROR errargs ; meta_errno=errval; return(retval); } while(0) - -#endif /* TYPES_META_H */ +// types_meta.h - common internal type, etc definitions + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef TYPES_META_H +#define TYPES_META_H + +// Our own boolean type, for stricter type matching. +typedef enum mBOOL { + mFALSE = 0, + mTRUE, +} mBOOL; + +// Like C's errno, for our various functions; describes causes of failure +// or mFALSE returns. +typedef enum { + ME_NOERROR = 0, + ME_FORMAT, // invalid format + ME_COMMENT, // ignored comment + ME_BLANK, // ignored blank (empty) line + ME_ALREADY, // request had already been done + ME_DELAYED, // request is delayed + ME_NOTALLOWED, // request not allowed + ME_SKIPPED, // request is being skipped for whatever reason + ME_BADREQ, // invalid request for this + ME_ARGUMENT, // invalid arguments + ME_NULLRESULT, // resulting data was empty or null + ME_MAXREACHED, // reached max/limit + ME_NOTUNIQ, // not unique (ambigious match) + ME_NOTFOUND, // in find operation, match not found + ME_NOFILE, // file empty or missing + ME_NOMEM, // malloc failed + ME_BADMEMPTR, // invalid memory address + ME_OSNOTSUP, // OS doesn't support this operation + ME_DLOPEN, // failed to open shared lib/dll + ME_DLMISSING, // symbol missing in lib/dll + ME_DLERROR, // some other error encountered calling functions from dll + ME_IFVERSION, // incompatible interface version + ME_UNLOAD_UNLOADER, // tried to unload unloader + ME_UNLOAD_SELF, // tried to unload self +} META_ERRNO; +extern META_ERRNO meta_errno; + +#define RETURN_ERRNO(retval, errval) \ + do { meta_errno=errval; return(retval); } while(0) + +#define RETURN_LOGERR_ERRNO(errargs, retval, errval) \ + do { META_ERROR errargs ; meta_errno=errval; return(retval); } while(0) + +#endif /* TYPES_META_H */ diff --git a/dep/rehlsdk/common/IGameServerData.h b/dep/rehlsdk/common/IGameServerData.h index fe7b035..d431f00 100644 --- a/dep/rehlsdk/common/IGameServerData.h +++ b/dep/rehlsdk/common/IGameServerData.h @@ -1,15 +1,15 @@ -#pragma once - -#include "maintypes.h" -#include "interface.h" - -class IGameServerData : public IBaseInterface { -public: - virtual ~IGameServerData() { }; - - virtual void WriteDataRequest(const void *buffer, int bufferSize) = 0; - - virtual int ReadDataResponse(void *data, int len) = 0; -}; - -#define GAMESERVERDATA_INTERFACE_VERSION "GameServerData001" +#pragma once + +#include "maintypes.h" +#include "interface.h" + +class IGameServerData : public IBaseInterface { +public: + virtual ~IGameServerData() { }; + + virtual void WriteDataRequest(const void *buffer, int bufferSize) = 0; + + virtual int ReadDataResponse(void *data, int len) = 0; +}; + +#define GAMESERVERDATA_INTERFACE_VERSION "GameServerData001" diff --git a/dep/rehlsdk/common/Sequence.h b/dep/rehlsdk/common/Sequence.h index dff3ef5..8df553d 100644 --- a/dep/rehlsdk/common/Sequence.h +++ b/dep/rehlsdk/common/Sequence.h @@ -1,201 +1,201 @@ -//--------------------------------------------------------------------------- -// -// S c r i p t e d S e q u e n c e s -// -//--------------------------------------------------------------------------- -#ifndef _INCLUDE_SEQUENCE_H_ -#define _INCLUDE_SEQUENCE_H_ - - -#ifndef _DEF_BYTE_ -typedef unsigned char byte; -#endif - -//--------------------------------------------------------------------------- -// client_textmessage_t -//--------------------------------------------------------------------------- -typedef struct client_textmessage_s -{ - 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; -} client_textmessage_t; - - -//-------------------------------------------------------------------------- -// sequenceDefaultBits_e -// -// Enumerated list of possible modifiers for a command. This enumeration -// is used in a bitarray controlling what modifiers are specified for a command. -//--------------------------------------------------------------------------- -enum sequenceModifierBits -{ - SEQUENCE_MODIFIER_EFFECT_BIT = (1 << 1), - SEQUENCE_MODIFIER_POSITION_BIT = (1 << 2), - SEQUENCE_MODIFIER_COLOR_BIT = (1 << 3), - SEQUENCE_MODIFIER_COLOR2_BIT = (1 << 4), - SEQUENCE_MODIFIER_FADEIN_BIT = (1 << 5), - SEQUENCE_MODIFIER_FADEOUT_BIT = (1 << 6), - SEQUENCE_MODIFIER_HOLDTIME_BIT = (1 << 7), - SEQUENCE_MODIFIER_FXTIME_BIT = (1 << 8), - SEQUENCE_MODIFIER_SPEAKER_BIT = (1 << 9), - SEQUENCE_MODIFIER_LISTENER_BIT = (1 << 10), - SEQUENCE_MODIFIER_TEXTCHANNEL_BIT = (1 << 11), -}; -typedef enum sequenceModifierBits sequenceModifierBits_e ; - - -//--------------------------------------------------------------------------- -// sequenceCommandEnum_e -// -// Enumerated sequence command types. -//--------------------------------------------------------------------------- -enum sequenceCommandEnum_ -{ - SEQUENCE_COMMAND_ERROR = -1, - SEQUENCE_COMMAND_PAUSE = 0, - SEQUENCE_COMMAND_FIRETARGETS, - SEQUENCE_COMMAND_KILLTARGETS, - SEQUENCE_COMMAND_TEXT, - SEQUENCE_COMMAND_SOUND, - SEQUENCE_COMMAND_GOSUB, - SEQUENCE_COMMAND_SENTENCE, - SEQUENCE_COMMAND_REPEAT, - SEQUENCE_COMMAND_SETDEFAULTS, - SEQUENCE_COMMAND_MODIFIER, - SEQUENCE_COMMAND_POSTMODIFIER, - SEQUENCE_COMMAND_NOOP, - - SEQUENCE_MODIFIER_EFFECT, - SEQUENCE_MODIFIER_POSITION, - SEQUENCE_MODIFIER_COLOR, - SEQUENCE_MODIFIER_COLOR2, - SEQUENCE_MODIFIER_FADEIN, - SEQUENCE_MODIFIER_FADEOUT, - SEQUENCE_MODIFIER_HOLDTIME, - SEQUENCE_MODIFIER_FXTIME, - SEQUENCE_MODIFIER_SPEAKER, - SEQUENCE_MODIFIER_LISTENER, - SEQUENCE_MODIFIER_TEXTCHANNEL, -}; -typedef enum sequenceCommandEnum_ sequenceCommandEnum_e; - - -//--------------------------------------------------------------------------- -// sequenceCommandType_e -// -// Typeerated sequence command types. -//--------------------------------------------------------------------------- -enum sequenceCommandType_ -{ - SEQUENCE_TYPE_COMMAND, - SEQUENCE_TYPE_MODIFIER, -}; -typedef enum sequenceCommandType_ sequenceCommandType_e; - - -//--------------------------------------------------------------------------- -// sequenceCommandMapping_s -// -// A mapping of a command enumerated-value to its name. -//--------------------------------------------------------------------------- -typedef struct sequenceCommandMapping_ sequenceCommandMapping_s; -struct sequenceCommandMapping_ -{ - sequenceCommandEnum_e commandEnum; - const char* commandName; - sequenceCommandType_e commandType; -}; - - -//--------------------------------------------------------------------------- -// sequenceCommandLine_s -// -// Structure representing a single command (usually 1 line) from a -// .SEQ file entry. -//--------------------------------------------------------------------------- -typedef struct sequenceCommandLine_ sequenceCommandLine_s; -struct sequenceCommandLine_ -{ - int commandType; // Specifies the type of command - client_textmessage_t clientMessage; // Text HUD message struct - char* speakerName; // Targetname of speaking entity - char* listenerName; // Targetname of entity being spoken to - char* soundFileName; // Name of sound file to play - char* sentenceName; // Name of sentences.txt to play - char* fireTargetNames; // List of targetnames to fire - char* killTargetNames; // List of targetnames to remove - float delay; // Seconds 'till next command - int repeatCount; // If nonzero, reset execution pointer to top of block (N times, -1 = infinite) - int textChannel; // Display channel on which text message is sent - int modifierBitField; // Bit field to specify what clientmessage fields are valid - sequenceCommandLine_s* nextCommandLine; // Next command (linked list) -}; - - -//--------------------------------------------------------------------------- -// sequenceEntry_s -// -// Structure representing a single command (usually 1 line) from a -// .SEQ file entry. -//--------------------------------------------------------------------------- -typedef struct sequenceEntry_ sequenceEntry_s; -struct sequenceEntry_ -{ - char* fileName; // Name of sequence file without .SEQ extension - char* entryName; // Name of entry label in file - sequenceCommandLine_s* firstCommand; // Linked list of commands in entry - sequenceEntry_s* nextEntry; // Next loaded entry - qboolean isGlobal; // Is entry retained over level transitions? -}; - - - -//--------------------------------------------------------------------------- -// sentenceEntry_s -// Structure representing a single sentence of a group from a .SEQ -// file entry. Sentences are identical to entries in sentences.txt, but -// can be unique per level and are loaded/unloaded with the level. -//--------------------------------------------------------------------------- -typedef struct sentenceEntry_ sentenceEntry_s; -struct sentenceEntry_ -{ - char* data; // sentence data (ie "We have hostiles" ) - sentenceEntry_s* nextEntry; // Next loaded entry - qboolean isGlobal; // Is entry retained over level transitions? - unsigned int index; // this entry's position in the file. -}; - -//-------------------------------------------------------------------------- -// sentenceGroupEntry_s -// Structure representing a group of sentences found in a .SEQ file. -// A sentence group is defined by all sentences with the same name, ignoring -// the number at the end of the sentence name. Groups enable a sentence -// to be picked at random across a group. -//-------------------------------------------------------------------------- -typedef struct sentenceGroupEntry_ sentenceGroupEntry_s; -struct sentenceGroupEntry_ -{ - char* groupName; // name of the group (ie CT_ALERT ) - unsigned int numSentences; // number of sentences in group - sentenceEntry_s* firstSentence; // head of linked list of sentences in group - sentenceGroupEntry_s* nextEntry; // next loaded group -}; - -//--------------------------------------------------------------------------- -// Function declarations -//--------------------------------------------------------------------------- -sequenceEntry_s* SequenceGet( const char* fileName, const char* entryName ); -void Sequence_ParseFile( const char* fileName, qboolean isGlobal ); -void Sequence_OnLevelLoad( const char* mapName ); -sentenceEntry_s* SequencePickSentence( const char *groupName, int pickMethod, int *picked ); - -#endif // _INCLUDE_SEQUENCE_H_ +//--------------------------------------------------------------------------- +// +// S c r i p t e d S e q u e n c e s +// +//--------------------------------------------------------------------------- +#ifndef _INCLUDE_SEQUENCE_H_ +#define _INCLUDE_SEQUENCE_H_ + + +#ifndef _DEF_BYTE_ +typedef unsigned char byte; +#endif + +//--------------------------------------------------------------------------- +// client_textmessage_t +//--------------------------------------------------------------------------- +typedef struct client_textmessage_s +{ + 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; +} client_textmessage_t; + + +//-------------------------------------------------------------------------- +// sequenceDefaultBits_e +// +// Enumerated list of possible modifiers for a command. This enumeration +// is used in a bitarray controlling what modifiers are specified for a command. +//--------------------------------------------------------------------------- +enum sequenceModifierBits +{ + SEQUENCE_MODIFIER_EFFECT_BIT = (1 << 1), + SEQUENCE_MODIFIER_POSITION_BIT = (1 << 2), + SEQUENCE_MODIFIER_COLOR_BIT = (1 << 3), + SEQUENCE_MODIFIER_COLOR2_BIT = (1 << 4), + SEQUENCE_MODIFIER_FADEIN_BIT = (1 << 5), + SEQUENCE_MODIFIER_FADEOUT_BIT = (1 << 6), + SEQUENCE_MODIFIER_HOLDTIME_BIT = (1 << 7), + SEQUENCE_MODIFIER_FXTIME_BIT = (1 << 8), + SEQUENCE_MODIFIER_SPEAKER_BIT = (1 << 9), + SEQUENCE_MODIFIER_LISTENER_BIT = (1 << 10), + SEQUENCE_MODIFIER_TEXTCHANNEL_BIT = (1 << 11), +}; +typedef enum sequenceModifierBits sequenceModifierBits_e ; + + +//--------------------------------------------------------------------------- +// sequenceCommandEnum_e +// +// Enumerated sequence command types. +//--------------------------------------------------------------------------- +enum sequenceCommandEnum_ +{ + SEQUENCE_COMMAND_ERROR = -1, + SEQUENCE_COMMAND_PAUSE = 0, + SEQUENCE_COMMAND_FIRETARGETS, + SEQUENCE_COMMAND_KILLTARGETS, + SEQUENCE_COMMAND_TEXT, + SEQUENCE_COMMAND_SOUND, + SEQUENCE_COMMAND_GOSUB, + SEQUENCE_COMMAND_SENTENCE, + SEQUENCE_COMMAND_REPEAT, + SEQUENCE_COMMAND_SETDEFAULTS, + SEQUENCE_COMMAND_MODIFIER, + SEQUENCE_COMMAND_POSTMODIFIER, + SEQUENCE_COMMAND_NOOP, + + SEQUENCE_MODIFIER_EFFECT, + SEQUENCE_MODIFIER_POSITION, + SEQUENCE_MODIFIER_COLOR, + SEQUENCE_MODIFIER_COLOR2, + SEQUENCE_MODIFIER_FADEIN, + SEQUENCE_MODIFIER_FADEOUT, + SEQUENCE_MODIFIER_HOLDTIME, + SEQUENCE_MODIFIER_FXTIME, + SEQUENCE_MODIFIER_SPEAKER, + SEQUENCE_MODIFIER_LISTENER, + SEQUENCE_MODIFIER_TEXTCHANNEL, +}; +typedef enum sequenceCommandEnum_ sequenceCommandEnum_e; + + +//--------------------------------------------------------------------------- +// sequenceCommandType_e +// +// Typeerated sequence command types. +//--------------------------------------------------------------------------- +enum sequenceCommandType_ +{ + SEQUENCE_TYPE_COMMAND, + SEQUENCE_TYPE_MODIFIER, +}; +typedef enum sequenceCommandType_ sequenceCommandType_e; + + +//--------------------------------------------------------------------------- +// sequenceCommandMapping_s +// +// A mapping of a command enumerated-value to its name. +//--------------------------------------------------------------------------- +typedef struct sequenceCommandMapping_ sequenceCommandMapping_s; +struct sequenceCommandMapping_ +{ + sequenceCommandEnum_e commandEnum; + const char* commandName; + sequenceCommandType_e commandType; +}; + + +//--------------------------------------------------------------------------- +// sequenceCommandLine_s +// +// Structure representing a single command (usually 1 line) from a +// .SEQ file entry. +//--------------------------------------------------------------------------- +typedef struct sequenceCommandLine_ sequenceCommandLine_s; +struct sequenceCommandLine_ +{ + int commandType; // Specifies the type of command + client_textmessage_t clientMessage; // Text HUD message struct + char* speakerName; // Targetname of speaking entity + char* listenerName; // Targetname of entity being spoken to + char* soundFileName; // Name of sound file to play + char* sentenceName; // Name of sentences.txt to play + char* fireTargetNames; // List of targetnames to fire + char* killTargetNames; // List of targetnames to remove + float delay; // Seconds 'till next command + int repeatCount; // If nonzero, reset execution pointer to top of block (N times, -1 = infinite) + int textChannel; // Display channel on which text message is sent + int modifierBitField; // Bit field to specify what clientmessage fields are valid + sequenceCommandLine_s* nextCommandLine; // Next command (linked list) +}; + + +//--------------------------------------------------------------------------- +// sequenceEntry_s +// +// Structure representing a single command (usually 1 line) from a +// .SEQ file entry. +//--------------------------------------------------------------------------- +typedef struct sequenceEntry_ sequenceEntry_s; +struct sequenceEntry_ +{ + char* fileName; // Name of sequence file without .SEQ extension + char* entryName; // Name of entry label in file + sequenceCommandLine_s* firstCommand; // Linked list of commands in entry + sequenceEntry_s* nextEntry; // Next loaded entry + qboolean isGlobal; // Is entry retained over level transitions? +}; + + + +//--------------------------------------------------------------------------- +// sentenceEntry_s +// Structure representing a single sentence of a group from a .SEQ +// file entry. Sentences are identical to entries in sentences.txt, but +// can be unique per level and are loaded/unloaded with the level. +//--------------------------------------------------------------------------- +typedef struct sentenceEntry_ sentenceEntry_s; +struct sentenceEntry_ +{ + char* data; // sentence data (ie "We have hostiles" ) + sentenceEntry_s* nextEntry; // Next loaded entry + qboolean isGlobal; // Is entry retained over level transitions? + unsigned int index; // this entry's position in the file. +}; + +//-------------------------------------------------------------------------- +// sentenceGroupEntry_s +// Structure representing a group of sentences found in a .SEQ file. +// A sentence group is defined by all sentences with the same name, ignoring +// the number at the end of the sentence name. Groups enable a sentence +// to be picked at random across a group. +//-------------------------------------------------------------------------- +typedef struct sentenceGroupEntry_ sentenceGroupEntry_s; +struct sentenceGroupEntry_ +{ + char* groupName; // name of the group (ie CT_ALERT ) + unsigned int numSentences; // number of sentences in group + sentenceEntry_s* firstSentence; // head of linked list of sentences in group + sentenceGroupEntry_s* nextEntry; // next loaded group +}; + +//--------------------------------------------------------------------------- +// Function declarations +//--------------------------------------------------------------------------- +sequenceEntry_s* SequenceGet( const char* fileName, const char* entryName ); +void Sequence_ParseFile( const char* fileName, qboolean isGlobal ); +void Sequence_OnLevelLoad( const char* mapName ); +sentenceEntry_s* SequencePickSentence( const char *groupName, int pickMethod, int *picked ); + +#endif // _INCLUDE_SEQUENCE_H_ diff --git a/dep/rehlsdk/common/SteamCommon.h b/dep/rehlsdk/common/SteamCommon.h index 6645099..c3fb1b0 100644 --- a/dep/rehlsdk/common/SteamCommon.h +++ b/dep/rehlsdk/common/SteamCommon.h @@ -1,707 +1,707 @@ - -//========= Copyright Valve Corporation, All rights reserved. ============// -/* -** The copyright to the contents herein is the property of Valve Corporation. -** The contents may be used and/or copied only with the written permission of -** Valve, or in accordance with the terms and conditions stipulated in -** the agreement/contract under which the contents have been supplied. -** -******************************************************************************* -** -** Contents: -** -** Common types used in the Steam DLL interface. -** -** This file is distributed to Steam application developers. -** -** -** -*******************************************************************************/ - -#ifndef INCLUDED_STEAM_COMMON_STEAMCOMMON_H -#define INCLUDED_STEAM_COMMON_STEAMCOMMON_H - -#if defined(_MSC_VER) && (_MSC_VER > 1000) -#pragma once -#endif - - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Applications should not define STEAM_EXPORTS. */ - -#if defined ( _WIN32 ) - -#ifdef STEAM_EXPORTS -#define STEAM_API __declspec(dllexport) EXT_FUNC -#else -#define STEAM_API __declspec(dllimport) -#endif - -#define STEAM_CALL __cdecl - -#else - -#ifdef STEAM_EXPORTS -#define STEAM_API EXT_FUNC -#else -#define STEAM_API /* */ -#endif -#define STEAM_CALL /* */ - -#endif - -typedef void (STEAM_CALL *KeyValueIteratorCallback_t )(const char *Key, const char *Val, void *pvParam); - - -/****************************************************************************** -** -** Exported macros and constants -** -******************************************************************************/ - -/* DEPRECATED -- these are ignored now, all API access is granted on SteamStartup */ -#define STEAM_USING_FILESYSTEM (0x00000001) -#define STEAM_USING_LOGGING (0x00000002) -#define STEAM_USING_USERID (0x00000004) -#define STEAM_USING_ACCOUNT (0x00000008) -#define STEAM_USING_ALL (0x0000000f) -/* END DEPRECATED */ - -#define STEAM_MAX_PATH (255) -#define STEAM_QUESTION_MAXLEN (255) -#define STEAM_SALT_SIZE (8) -#define STEAM_PROGRESS_PERCENT_SCALE (0x00001000) - -/* These are maximum significant string lengths, excluding nul-terminator. */ -#define STEAM_CARD_NUMBER_SIZE (17) -#define STEAM_CARD_HOLDERNAME_SIZE (100) -#define STEAM_CARD_EXPYEAR_SIZE (4) -#define STEAM_CARD_EXPMONTH_SIZE (2) -#define STEAM_CARD_CVV2_SIZE (5) -#define STEAM_BILLING_ADDRESS1_SIZE (128) -#define STEAM_BILLING_ADDRESS2_SIZE (128) -#define STEAM_BILLING_CITY_SIZE (50) -#define STEAM_BILLING_ZIP_SIZE (16) -#define STEAM_BILLING_STATE_SIZE (32) -#define STEAM_BILLING_COUNTRY_SIZE (32) -#define STEAM_BILLING_PHONE_SIZE (20) -#define STEAM_BILLING_EMAIL_ADDRESS_SIZE (100) -#define STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE (20) -#define STEAM_PROOF_OF_PURCHASE_TOKEN_SIZE (200) -#define STEAM_EXTERNAL_ACCOUNTNAME_SIZE (100) -#define STEAM_EXTERNAL_ACCOUNTPASSWORD_SIZE (80) -#define STEAM_BILLING_CONFIRMATION_CODE_SIZE (22) -#define STEAM_BILLING_CARD_APPROVAL_CODE_SIZE (100) -#define STEAM_BILLING_TRANS_DATE_SIZE (9) // mm/dd/yy -#define STEAM_BILLING_TRANS_TIME_SIZE (9) // hh:mm:ss - -/****************************************************************************** -** -** Scalar type and enumerated type definitions. -** -******************************************************************************/ - - -typedef unsigned int SteamHandle_t; - -typedef void * SteamUserIDTicketValidationHandle_t; - -typedef unsigned int SteamCallHandle_t; - -#if defined(_MSC_VER) -typedef unsigned __int64 SteamUnsigned64_t; -#else -typedef unsigned long long SteamUnsigned64_t; -#endif - -typedef enum -{ - eSteamSeekMethodSet = 0, - eSteamSeekMethodCur = 1, - eSteamSeekMethodEnd = 2 -} ESteamSeekMethod; - -typedef enum -{ - eSteamBufferMethodFBF = 0, - eSteamBufferMethodNBF = 1 -} ESteamBufferMethod; - -typedef enum -{ - eSteamErrorNone = 0, - eSteamErrorUnknown = 1, - eSteamErrorLibraryNotInitialized = 2, - eSteamErrorLibraryAlreadyInitialized = 3, - eSteamErrorConfig = 4, - eSteamErrorContentServerConnect = 5, - eSteamErrorBadHandle = 6, - eSteamErrorHandlesExhausted = 7, - eSteamErrorBadArg = 8, - eSteamErrorNotFound = 9, - eSteamErrorRead = 10, - eSteamErrorEOF = 11, - eSteamErrorSeek = 12, - eSteamErrorCannotWriteNonUserConfigFile = 13, - eSteamErrorCacheOpen = 14, - eSteamErrorCacheRead = 15, - eSteamErrorCacheCorrupted = 16, - eSteamErrorCacheWrite = 17, - eSteamErrorCacheSession = 18, - eSteamErrorCacheInternal = 19, - eSteamErrorCacheBadApp = 20, - eSteamErrorCacheVersion = 21, - eSteamErrorCacheBadFingerPrint = 22, - - eSteamErrorNotFinishedProcessing = 23, - eSteamErrorNothingToDo = 24, - eSteamErrorCorruptEncryptedUserIDTicket = 25, - eSteamErrorSocketLibraryNotInitialized = 26, - eSteamErrorFailedToConnectToUserIDTicketValidationServer = 27, - eSteamErrorBadProtocolVersion = 28, - eSteamErrorReplayedUserIDTicketFromClient = 29, - eSteamErrorReceiveResultBufferTooSmall = 30, - eSteamErrorSendFailed = 31, - eSteamErrorReceiveFailed = 32, - eSteamErrorReplayedReplyFromUserIDTicketValidationServer = 33, - eSteamErrorBadSignatureFromUserIDTicketValidationServer = 34, - eSteamErrorValidationStalledSoAborted = 35, - eSteamErrorInvalidUserIDTicket = 36, - eSteamErrorClientLoginRateTooHigh = 37, - eSteamErrorClientWasNeverValidated = 38, - eSteamErrorInternalSendBufferTooSmall = 39, - eSteamErrorInternalReceiveBufferTooSmall = 40, - eSteamErrorUserTicketExpired = 41, - eSteamErrorCDKeyAlreadyInUseOnAnotherClient = 42, - - eSteamErrorNotLoggedIn = 101, - eSteamErrorAlreadyExists = 102, - eSteamErrorAlreadySubscribed = 103, - eSteamErrorNotSubscribed = 104, - eSteamErrorAccessDenied = 105, - eSteamErrorFailedToCreateCacheFile = 106, - eSteamErrorCallStalledSoAborted = 107, - eSteamErrorEngineNotRunning = 108, - eSteamErrorEngineConnectionLost = 109, - eSteamErrorLoginFailed = 110, - eSteamErrorAccountPending = 111, - eSteamErrorCacheWasMissingRetry = 112, - eSteamErrorLocalTimeIncorrect = 113, - eSteamErrorCacheNeedsDecryption = 114, - eSteamErrorAccountDisabled = 115, - eSteamErrorCacheNeedsRepair = 116, - eSteamErrorRebootRequired = 117, - - eSteamErrorNetwork = 200, - eSteamErrorOffline = 201 - - -} ESteamError; - - -typedef enum -{ - eNoDetailedErrorAvailable, - eStandardCerrno, - eWin32LastError, - eWinSockLastError, - eDetailedPlatformErrorCount -} EDetailedPlatformErrorType; - -typedef enum /* Filter elements returned by SteamFind{First,Next} */ -{ - eSteamFindLocalOnly, /* limit search to local filesystem */ - eSteamFindRemoteOnly, /* limit search to remote repository */ - eSteamFindAll /* do not limit search (duplicates allowed) */ -} ESteamFindFilter; - - -/****************************************************************************** -** -** Exported structure and complex type definitions. -** -******************************************************************************/ - - -typedef struct -{ - ESteamError eSteamError; - EDetailedPlatformErrorType eDetailedErrorType; - int nDetailedErrorCode; - char szDesc[STEAM_MAX_PATH]; -} TSteamError; - - - -typedef struct -{ - int bIsDir; /* If non-zero, element is a directory; if zero, element is a file */ - unsigned int uSizeOrCount; /* If element is a file, this contains size of file in bytes */ - int bIsLocal; /* If non-zero, reported item is a standalone element on local filesystem */ - char cszName[STEAM_MAX_PATH]; /* Base element name (no path) */ - long lLastAccessTime; /* Seconds since 1/1/1970 (like time_t) when element was last accessed */ - long lLastModificationTime; /* Seconds since 1/1/1970 (like time_t) when element was last modified */ - long lCreationTime; /* Seconds since 1/1/1970 (like time_t) when element was created */ -} TSteamElemInfo; - - -typedef struct -{ - unsigned int uNumSubscriptions; - unsigned int uMaxNameChars; - unsigned int uMaxApps; - -} TSteamSubscriptionStats; - - -typedef struct -{ - unsigned int uNumApps; - unsigned int uMaxNameChars; - unsigned int uMaxInstallDirNameChars; - unsigned int uMaxVersionLabelChars; - unsigned int uMaxLaunchOptions; - unsigned int uMaxLaunchOptionDescChars; - unsigned int uMaxLaunchOptionCmdLineChars; - unsigned int uMaxNumIcons; - unsigned int uMaxIconSize; - unsigned int uMaxDependencies; - -} TSteamAppStats; - -typedef struct -{ - char *szLabel; - unsigned int uMaxLabelChars; - unsigned int uVersionId; - int bIsNotAvailable; -} TSteamAppVersion; - -typedef struct -{ - char *szDesc; - unsigned int uMaxDescChars; - char *szCmdLine; - unsigned int uMaxCmdLineChars; - unsigned int uIndex; - unsigned int uIconIndex; - int bNoDesktopShortcut; - int bNoStartMenuShortcut; - int bIsLongRunningUnattended; - -} TSteamAppLaunchOption; - - -typedef struct -{ - char *szName; - unsigned int uMaxNameChars; - char *szLatestVersionLabel; - unsigned int uMaxLatestVersionLabelChars; - char *szCurrentVersionLabel; - unsigned int uMaxCurrentVersionLabelChars; - char *szInstallDirName; - unsigned int uMaxInstallDirNameChars; - unsigned int uId; - unsigned int uLatestVersionId; - unsigned int uCurrentVersionId; - unsigned int uMinCacheFileSizeMB; - unsigned int uMaxCacheFileSizeMB; - unsigned int uNumLaunchOptions; - unsigned int uNumIcons; - unsigned int uNumVersions; - unsigned int uNumDependencies; - -} TSteamApp; - -typedef enum -{ - eNoCost = 0, - eBillOnceOnly = 1, - eBillMonthly = 2, - eProofOfPrepurchaseOnly = 3, - eGuestPass = 4, - eHardwarePromo = 5, - eNumBillingTypes, -} EBillingType; - -typedef struct -{ - char *szName; - unsigned int uMaxNameChars; - unsigned int *puAppIds; - unsigned int uMaxAppIds; - unsigned int uId; - unsigned int uNumApps; - EBillingType eBillingType; - unsigned int uCostInCents; - unsigned int uNumDiscounts; - int bIsPreorder; - int bRequiresShippingAddress; - unsigned int uDomesticShippingCostInCents; - unsigned int uInternationalShippingCostInCents; - bool bIsCyberCafeSubscription; - unsigned int uGameCode; - char szGameCodeDesc[STEAM_MAX_PATH]; - bool bIsDisabled; - bool bRequiresCD; - unsigned int uTerritoryCode; - bool bIsSteam3Subscription; - -} TSteamSubscription; - -typedef struct -{ - char szName[STEAM_MAX_PATH]; - unsigned int uDiscountInCents; - unsigned int uNumQualifiers; - -} TSteamSubscriptionDiscount; - -typedef struct -{ - char szName[STEAM_MAX_PATH]; - unsigned int uRequiredSubscription; - int bIsDisqualifier; - -} TSteamDiscountQualifier; - -typedef struct TSteamProgress -{ - int bValid; /* non-zero if call provides progress info */ - unsigned int uPercentDone; /* 0 to 100 * STEAM_PROGRESS_PERCENT_SCALE if bValid */ - char szProgress[STEAM_MAX_PATH]; /* additional progress info */ -} TSteamProgress; - -typedef enum -{ - eSteamNotifyTicketsWillExpire, - eSteamNotifyAccountInfoChanged, - eSteamNotifyContentDescriptionChanged, - eSteamNotifyPleaseShutdown, - eSteamNotifyNewContentServer, - eSteamNotifySubscriptionStatusChanged, - eSteamNotifyContentServerConnectionLost, - eSteamNotifyCacheLoadingCompleted, - eSteamNotifyCacheNeedsDecryption, - eSteamNotifyCacheNeedsRepair -} ESteamNotificationCallbackEvent; - - -typedef void(*SteamNotificationCallback_t)(ESteamNotificationCallbackEvent eEvent, unsigned int nData); - - -typedef char SteamPersonalQuestion_t[ STEAM_QUESTION_MAXLEN + 1 ]; - -typedef struct -{ - unsigned char uchSalt[STEAM_SALT_SIZE]; -} SteamSalt_t; - -typedef enum -{ - eVisa = 1, - eMaster = 2, - eAmericanExpress = 3, - eDiscover = 4, - eDinnersClub = 5, - eJCB = 6 -} ESteamPaymentCardType; - -typedef struct -{ - ESteamPaymentCardType eCardType; - char szCardNumber[ STEAM_CARD_NUMBER_SIZE +1 ]; - char szCardHolderName[ STEAM_CARD_HOLDERNAME_SIZE + 1]; - char szCardExpYear[ STEAM_CARD_EXPYEAR_SIZE + 1 ]; - char szCardExpMonth[ STEAM_CARD_EXPMONTH_SIZE+ 1 ]; - char szCardCVV2[ STEAM_CARD_CVV2_SIZE + 1 ]; - char szBillingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ]; - char szBillingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ]; - char szBillingCity[ STEAM_BILLING_CITY_SIZE + 1 ]; - char szBillingZip[ STEAM_BILLING_ZIP_SIZE + 1 ]; - char szBillingState[ STEAM_BILLING_STATE_SIZE + 1 ]; - char szBillingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ]; - char szBillingPhone[ STEAM_BILLING_PHONE_SIZE + 1 ]; - char szBillingEmailAddress[ STEAM_BILLING_EMAIL_ADDRESS_SIZE + 1 ]; - unsigned int uExpectedCostInCents; - unsigned int uExpectedTaxInCents; - /* If the TSteamSubscription says that shipping info is required, */ - /* then the following fields must be filled out. */ - /* If szShippingName is empty, then assumes so are the rest. */ - char szShippingName[ STEAM_CARD_HOLDERNAME_SIZE + 1]; - char szShippingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ]; - char szShippingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ]; - char szShippingCity[ STEAM_BILLING_CITY_SIZE + 1 ]; - char szShippingZip[ STEAM_BILLING_ZIP_SIZE + 1 ]; - char szShippingState[ STEAM_BILLING_STATE_SIZE + 1 ]; - char szShippingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ]; - char szShippingPhone[ STEAM_BILLING_PHONE_SIZE + 1 ]; - unsigned int uExpectedShippingCostInCents; - -} TSteamPaymentCardInfo; - -typedef struct -{ - char szTypeOfProofOfPurchase[ STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE + 1 ]; - - /* A ProofOfPurchase token is not necessarily a nul-terminated string; it may be binary data - (perhaps encrypted). Hence we need a length and an array of bytes. */ - unsigned int uLengthOfBinaryProofOfPurchaseToken; - char cBinaryProofOfPurchaseToken[ STEAM_PROOF_OF_PURCHASE_TOKEN_SIZE + 1 ]; -} TSteamPrepurchaseInfo; - -typedef struct -{ - char szAccountName[ STEAM_EXTERNAL_ACCOUNTNAME_SIZE + 1 ]; - char szPassword[ STEAM_EXTERNAL_ACCOUNTPASSWORD_SIZE + 1 ]; -} TSteamExternalBillingInfo; - -typedef enum -{ - ePaymentCardInfo = 1, - ePrepurchasedInfo = 2, - eAccountBillingInfo = 3, - eExternalBillingInfo = 4, /* indirect billing via ISP etc (not supported yet) */ - ePaymentCardReceipt = 5, - ePrepurchaseReceipt = 6, - eEmptyReceipt = 7 -} ESteamSubscriptionBillingInfoType; - -typedef struct -{ - ESteamSubscriptionBillingInfoType eBillingInfoType; - union { - TSteamPaymentCardInfo PaymentCardInfo; - TSteamPrepurchaseInfo PrepurchaseInfo; - TSteamExternalBillingInfo ExternalBillingInfo; - char bUseAccountBillingInfo; - }; - -} TSteamSubscriptionBillingInfo; - -typedef enum -{ - /* Subscribed */ - eSteamSubscriptionOK = 0, /* Subscribed */ - eSteamSubscriptionPending = 1, /* Awaiting transaction completion */ - eSteamSubscriptionPreorder = 2, /* Is currently a pre-order */ - eSteamSubscriptionPrepurchaseTransferred = 3, /* hop to this account */ - /* Unusbscribed */ - eSteamSubscriptionPrepurchaseInvalid = 4, /* Invalid cd-key */ - eSteamSubscriptionPrepurchaseRejected = 5, /* hopped out / banned / etc */ - eSteamSubscriptionPrepurchaseRevoked = 6, /* hop away from this account */ - eSteamSubscriptionPaymentCardDeclined = 7, /* CC txn declined */ - eSteamSubscriptionCancelledByUser = 8, /* Cancelled by client */ - eSteamSubscriptionCancelledByVendor = 9, /* Cancelled by us */ - eSteamSubscriptionPaymentCardUseLimit = 10, /* Card used too many times, potential fraud */ - eSteamSubscriptionPaymentCardAlert = 11, /* Got a "pick up card" or the like from bank */ - eSteamSubscriptionFailed = 12, /* Other Error in subscription data or transaction failed/lost */ - eSteamSubscriptionPaymentCardAVSFailure = 13, /* Card failed Address Verification check */ - eSteamSubscriptionPaymentCardInsufficientFunds = 14, /* Card failed due to insufficient funds */ - eSteamSubscriptionRestrictedCountry = 15 /* The subscription is not available in the user's country */ - -} ESteamSubscriptionStatus; - -typedef struct -{ - ESteamPaymentCardType eCardType; - char szCardLastFourDigits[ 4 + 1 ]; - char szCardHolderName[ STEAM_CARD_HOLDERNAME_SIZE + 1]; - char szBillingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ]; - char szBillingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ]; - char szBillingCity[ STEAM_BILLING_CITY_SIZE + 1 ]; - char szBillingZip[ STEAM_BILLING_ZIP_SIZE + 1 ]; - char szBillingState[ STEAM_BILLING_STATE_SIZE + 1 ]; - char szBillingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ]; - - // The following are only available after the subscription leaves "pending" status - char szCardApprovalCode[ STEAM_BILLING_CARD_APPROVAL_CODE_SIZE + 1]; - char szTransDate[ STEAM_BILLING_TRANS_DATE_SIZE + 1]; /* mm/dd/yy */ - char szTransTime[ STEAM_BILLING_TRANS_TIME_SIZE + 1]; /* hh:mm:ss */ - unsigned int uPriceWithoutTax; - unsigned int uTaxAmount; - unsigned int uShippingCost; - -} TSteamPaymentCardReceiptInfo; - -typedef struct -{ - char szTypeOfProofOfPurchase[ STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE + 1 ]; -} TSteamPrepurchaseReceiptInfo; - -typedef struct -{ - ESteamSubscriptionStatus eStatus; - ESteamSubscriptionStatus ePreviousStatus; - ESteamSubscriptionBillingInfoType eReceiptInfoType; - char szConfirmationCode[ STEAM_BILLING_CONFIRMATION_CODE_SIZE + 1]; - union { - TSteamPaymentCardReceiptInfo PaymentCardReceiptInfo; - TSteamPrepurchaseReceiptInfo PrepurchaseReceiptInfo; - }; - -} TSteamSubscriptionReceipt; - -typedef enum -{ - ePhysicalBytesReceivedThisSession = 1, - eAppReadyToLaunchStatus = 2, - eAppPreloadStatus = 3, - eAppEntireDepot = 4, - eCacheBytesPresent = 5 -} ESteamAppUpdateStatsQueryType; - -typedef struct -{ - SteamUnsigned64_t uBytesTotal; - SteamUnsigned64_t uBytesPresent; -} TSteamUpdateStats; - -typedef enum -{ - eSteamUserAdministrator = 0x00000001, /* May subscribe, unsubscribe, etc */ - eSteamUserDeveloper = 0x00000002, /* Steam or App developer */ - eSteamUserCyberCafe = 0x00000004 /* CyberCafe, school, etc -- UI should ask for password */ - /* before allowing logout, unsubscribe, etc */ -} ESteamUserTypeFlags; - -typedef enum -{ - eSteamAccountStatusDefault = 0x00000000, - eSteamAccountStatusEmailVerified = 0x00000001, - /* Note: Mask value 0x2 is reserved for future use. (Some, but not all, public accounts already have this set.) */ - eSteamAccountDisabled = 0x00000004 -} ESteamAccountStatusBitFields ; - - -typedef enum -{ - eSteamBootstrapperError = -1, - eSteamBootstrapperDontCheckForUpdate = 0, - eSteamBootstrapperCheckForUpdateAndRerun = 7 - -} ESteamBootStrapperClientAppResult; - -typedef enum -{ - eSteamOnline = 0, - eSteamOffline = 1, - eSteamNoAuthMode = 2, - eSteamBillingOffline = 3 -} eSteamOfflineStatus; - -typedef struct -{ - int eOfflineNow; - int eOfflineNextSession; -} TSteamOfflineStatus; - -typedef struct -{ - unsigned int uAppId; - int bIsSystemDefined; - char szMountPath[STEAM_MAX_PATH]; -} TSteamAppDependencyInfo; - -typedef enum -{ - eSteamOpenFileRegular = 0x0, - eSteamOpenFileIgnoreLocal = 0x1, - eSteamOpenFileChecksumReads = 0x2 -} ESteamOpenFileFlags; - -typedef enum -{ - eSteamValveCDKeyValidationServer = 0, - eSteamHalfLifeMasterServer = 1, - eSteamFriendsServer = 2, - eSteamCSERServer = 3, - eSteamHalfLife2MasterServer = 4, - eSteamRDKFMasterServer = 5, - eMaxServerTypes = 6 -} ESteamServerType; - -/****************************************************************************** -** -** More exported constants -** -******************************************************************************/ - - -#ifdef __cplusplus - -const SteamHandle_t STEAM_INVALID_HANDLE = 0; -const SteamCallHandle_t STEAM_INVALID_CALL_HANDLE = 0; -const SteamUserIDTicketValidationHandle_t STEAM_INACTIVE_USERIDTICKET_VALIDATION_HANDLE = 0; -const unsigned int STEAM_USE_LATEST_VERSION = 0xFFFFFFFF; - -#else - -#define STEAM_INVALID_HANDLE ((SteamHandle_t)(0)) -#define STEAM_INVALID_CALL_HANDLE ((SteamCallHandle_t)(0)) -#define STEAM_INACTIVE_USERIDTICKET_VALIDATION_HANDLE ((SteamUserIDTicketValidationHandle_t)(0)) -#define STEAM_USE_LATEST_VERSION (0xFFFFFFFFu); - -#endif - - -/****************************************************************************** -** Each Steam instance (licensed Steam Service Provider) has a unique SteamInstanceID_t. -** -** Each Steam instance as its own DB of users. -** Each user in the DB has a unique SteamLocalUserID_t (a serial number, with possible -** rare gaps in the sequence). -** -******************************************************************************/ - -typedef unsigned short SteamInstanceID_t; // MUST be 16 bits - - -#if defined ( _WIN32 ) -typedef unsigned __int64 SteamLocalUserID_t; // MUST be 64 bits -#else -typedef unsigned long long SteamLocalUserID_t; // MUST be 64 bits -#endif - -/****************************************************************************** -** -** Applications need to be able to authenticate Steam users from ANY instance. -** So a SteamIDTicket contains SteamGlobalUserID, which is a unique combination of -** instance and user id. -** -** SteamLocalUserID is an unsigned 64-bit integer. -** For platforms without 64-bit int support, we provide access via a union that splits it into -** high and low unsigned 32-bit ints. Such platforms will only need to compare LocalUserIDs -** for equivalence anyway - not perform arithmetic with them. -** -********************************************************************************/ -typedef struct -{ - unsigned int Low32bits; - unsigned int High32bits; -} TSteamSplitLocalUserID; - -typedef struct -{ - SteamInstanceID_t m_SteamInstanceID; - - union - { - SteamLocalUserID_t As64bits; - TSteamSplitLocalUserID Split; - } m_SteamLocalUserID; - -} TSteamGlobalUserID; - - -#ifdef __cplusplus -} -#endif - - -#endif + +//========= Copyright Valve Corporation, All rights reserved. ============// +/* +** The copyright to the contents herein is the property of Valve Corporation. +** The contents may be used and/or copied only with the written permission of +** Valve, or in accordance with the terms and conditions stipulated in +** the agreement/contract under which the contents have been supplied. +** +******************************************************************************* +** +** Contents: +** +** Common types used in the Steam DLL interface. +** +** This file is distributed to Steam application developers. +** +** +** +*******************************************************************************/ + +#ifndef INCLUDED_STEAM_COMMON_STEAMCOMMON_H +#define INCLUDED_STEAM_COMMON_STEAMCOMMON_H + +#if defined(_MSC_VER) && (_MSC_VER > 1000) +#pragma once +#endif + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* Applications should not define STEAM_EXPORTS. */ + +#if defined ( _WIN32 ) + +#ifdef STEAM_EXPORTS +#define STEAM_API __declspec(dllexport) EXT_FUNC +#else +#define STEAM_API __declspec(dllimport) +#endif + +#define STEAM_CALL __cdecl + +#else + +#ifdef STEAM_EXPORTS +#define STEAM_API EXT_FUNC +#else +#define STEAM_API /* */ +#endif +#define STEAM_CALL /* */ + +#endif + +typedef void (STEAM_CALL *KeyValueIteratorCallback_t )(const char *Key, const char *Val, void *pvParam); + + +/****************************************************************************** +** +** Exported macros and constants +** +******************************************************************************/ + +/* DEPRECATED -- these are ignored now, all API access is granted on SteamStartup */ +#define STEAM_USING_FILESYSTEM (0x00000001) +#define STEAM_USING_LOGGING (0x00000002) +#define STEAM_USING_USERID (0x00000004) +#define STEAM_USING_ACCOUNT (0x00000008) +#define STEAM_USING_ALL (0x0000000f) +/* END DEPRECATED */ + +#define STEAM_MAX_PATH (255) +#define STEAM_QUESTION_MAXLEN (255) +#define STEAM_SALT_SIZE (8) +#define STEAM_PROGRESS_PERCENT_SCALE (0x00001000) + +/* These are maximum significant string lengths, excluding nul-terminator. */ +#define STEAM_CARD_NUMBER_SIZE (17) +#define STEAM_CARD_HOLDERNAME_SIZE (100) +#define STEAM_CARD_EXPYEAR_SIZE (4) +#define STEAM_CARD_EXPMONTH_SIZE (2) +#define STEAM_CARD_CVV2_SIZE (5) +#define STEAM_BILLING_ADDRESS1_SIZE (128) +#define STEAM_BILLING_ADDRESS2_SIZE (128) +#define STEAM_BILLING_CITY_SIZE (50) +#define STEAM_BILLING_ZIP_SIZE (16) +#define STEAM_BILLING_STATE_SIZE (32) +#define STEAM_BILLING_COUNTRY_SIZE (32) +#define STEAM_BILLING_PHONE_SIZE (20) +#define STEAM_BILLING_EMAIL_ADDRESS_SIZE (100) +#define STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE (20) +#define STEAM_PROOF_OF_PURCHASE_TOKEN_SIZE (200) +#define STEAM_EXTERNAL_ACCOUNTNAME_SIZE (100) +#define STEAM_EXTERNAL_ACCOUNTPASSWORD_SIZE (80) +#define STEAM_BILLING_CONFIRMATION_CODE_SIZE (22) +#define STEAM_BILLING_CARD_APPROVAL_CODE_SIZE (100) +#define STEAM_BILLING_TRANS_DATE_SIZE (9) // mm/dd/yy +#define STEAM_BILLING_TRANS_TIME_SIZE (9) // hh:mm:ss + +/****************************************************************************** +** +** Scalar type and enumerated type definitions. +** +******************************************************************************/ + + +typedef unsigned int SteamHandle_t; + +typedef void * SteamUserIDTicketValidationHandle_t; + +typedef unsigned int SteamCallHandle_t; + +#if defined(_MSC_VER) +typedef unsigned __int64 SteamUnsigned64_t; +#else +typedef unsigned long long SteamUnsigned64_t; +#endif + +typedef enum +{ + eSteamSeekMethodSet = 0, + eSteamSeekMethodCur = 1, + eSteamSeekMethodEnd = 2 +} ESteamSeekMethod; + +typedef enum +{ + eSteamBufferMethodFBF = 0, + eSteamBufferMethodNBF = 1 +} ESteamBufferMethod; + +typedef enum +{ + eSteamErrorNone = 0, + eSteamErrorUnknown = 1, + eSteamErrorLibraryNotInitialized = 2, + eSteamErrorLibraryAlreadyInitialized = 3, + eSteamErrorConfig = 4, + eSteamErrorContentServerConnect = 5, + eSteamErrorBadHandle = 6, + eSteamErrorHandlesExhausted = 7, + eSteamErrorBadArg = 8, + eSteamErrorNotFound = 9, + eSteamErrorRead = 10, + eSteamErrorEOF = 11, + eSteamErrorSeek = 12, + eSteamErrorCannotWriteNonUserConfigFile = 13, + eSteamErrorCacheOpen = 14, + eSteamErrorCacheRead = 15, + eSteamErrorCacheCorrupted = 16, + eSteamErrorCacheWrite = 17, + eSteamErrorCacheSession = 18, + eSteamErrorCacheInternal = 19, + eSteamErrorCacheBadApp = 20, + eSteamErrorCacheVersion = 21, + eSteamErrorCacheBadFingerPrint = 22, + + eSteamErrorNotFinishedProcessing = 23, + eSteamErrorNothingToDo = 24, + eSteamErrorCorruptEncryptedUserIDTicket = 25, + eSteamErrorSocketLibraryNotInitialized = 26, + eSteamErrorFailedToConnectToUserIDTicketValidationServer = 27, + eSteamErrorBadProtocolVersion = 28, + eSteamErrorReplayedUserIDTicketFromClient = 29, + eSteamErrorReceiveResultBufferTooSmall = 30, + eSteamErrorSendFailed = 31, + eSteamErrorReceiveFailed = 32, + eSteamErrorReplayedReplyFromUserIDTicketValidationServer = 33, + eSteamErrorBadSignatureFromUserIDTicketValidationServer = 34, + eSteamErrorValidationStalledSoAborted = 35, + eSteamErrorInvalidUserIDTicket = 36, + eSteamErrorClientLoginRateTooHigh = 37, + eSteamErrorClientWasNeverValidated = 38, + eSteamErrorInternalSendBufferTooSmall = 39, + eSteamErrorInternalReceiveBufferTooSmall = 40, + eSteamErrorUserTicketExpired = 41, + eSteamErrorCDKeyAlreadyInUseOnAnotherClient = 42, + + eSteamErrorNotLoggedIn = 101, + eSteamErrorAlreadyExists = 102, + eSteamErrorAlreadySubscribed = 103, + eSteamErrorNotSubscribed = 104, + eSteamErrorAccessDenied = 105, + eSteamErrorFailedToCreateCacheFile = 106, + eSteamErrorCallStalledSoAborted = 107, + eSteamErrorEngineNotRunning = 108, + eSteamErrorEngineConnectionLost = 109, + eSteamErrorLoginFailed = 110, + eSteamErrorAccountPending = 111, + eSteamErrorCacheWasMissingRetry = 112, + eSteamErrorLocalTimeIncorrect = 113, + eSteamErrorCacheNeedsDecryption = 114, + eSteamErrorAccountDisabled = 115, + eSteamErrorCacheNeedsRepair = 116, + eSteamErrorRebootRequired = 117, + + eSteamErrorNetwork = 200, + eSteamErrorOffline = 201 + + +} ESteamError; + + +typedef enum +{ + eNoDetailedErrorAvailable, + eStandardCerrno, + eWin32LastError, + eWinSockLastError, + eDetailedPlatformErrorCount +} EDetailedPlatformErrorType; + +typedef enum /* Filter elements returned by SteamFind{First,Next} */ +{ + eSteamFindLocalOnly, /* limit search to local filesystem */ + eSteamFindRemoteOnly, /* limit search to remote repository */ + eSteamFindAll /* do not limit search (duplicates allowed) */ +} ESteamFindFilter; + + +/****************************************************************************** +** +** Exported structure and complex type definitions. +** +******************************************************************************/ + + +typedef struct +{ + ESteamError eSteamError; + EDetailedPlatformErrorType eDetailedErrorType; + int nDetailedErrorCode; + char szDesc[STEAM_MAX_PATH]; +} TSteamError; + + + +typedef struct +{ + int bIsDir; /* If non-zero, element is a directory; if zero, element is a file */ + unsigned int uSizeOrCount; /* If element is a file, this contains size of file in bytes */ + int bIsLocal; /* If non-zero, reported item is a standalone element on local filesystem */ + char cszName[STEAM_MAX_PATH]; /* Base element name (no path) */ + long lLastAccessTime; /* Seconds since 1/1/1970 (like time_t) when element was last accessed */ + long lLastModificationTime; /* Seconds since 1/1/1970 (like time_t) when element was last modified */ + long lCreationTime; /* Seconds since 1/1/1970 (like time_t) when element was created */ +} TSteamElemInfo; + + +typedef struct +{ + unsigned int uNumSubscriptions; + unsigned int uMaxNameChars; + unsigned int uMaxApps; + +} TSteamSubscriptionStats; + + +typedef struct +{ + unsigned int uNumApps; + unsigned int uMaxNameChars; + unsigned int uMaxInstallDirNameChars; + unsigned int uMaxVersionLabelChars; + unsigned int uMaxLaunchOptions; + unsigned int uMaxLaunchOptionDescChars; + unsigned int uMaxLaunchOptionCmdLineChars; + unsigned int uMaxNumIcons; + unsigned int uMaxIconSize; + unsigned int uMaxDependencies; + +} TSteamAppStats; + +typedef struct +{ + char *szLabel; + unsigned int uMaxLabelChars; + unsigned int uVersionId; + int bIsNotAvailable; +} TSteamAppVersion; + +typedef struct +{ + char *szDesc; + unsigned int uMaxDescChars; + char *szCmdLine; + unsigned int uMaxCmdLineChars; + unsigned int uIndex; + unsigned int uIconIndex; + int bNoDesktopShortcut; + int bNoStartMenuShortcut; + int bIsLongRunningUnattended; + +} TSteamAppLaunchOption; + + +typedef struct +{ + char *szName; + unsigned int uMaxNameChars; + char *szLatestVersionLabel; + unsigned int uMaxLatestVersionLabelChars; + char *szCurrentVersionLabel; + unsigned int uMaxCurrentVersionLabelChars; + char *szInstallDirName; + unsigned int uMaxInstallDirNameChars; + unsigned int uId; + unsigned int uLatestVersionId; + unsigned int uCurrentVersionId; + unsigned int uMinCacheFileSizeMB; + unsigned int uMaxCacheFileSizeMB; + unsigned int uNumLaunchOptions; + unsigned int uNumIcons; + unsigned int uNumVersions; + unsigned int uNumDependencies; + +} TSteamApp; + +typedef enum +{ + eNoCost = 0, + eBillOnceOnly = 1, + eBillMonthly = 2, + eProofOfPrepurchaseOnly = 3, + eGuestPass = 4, + eHardwarePromo = 5, + eNumBillingTypes, +} EBillingType; + +typedef struct +{ + char *szName; + unsigned int uMaxNameChars; + unsigned int *puAppIds; + unsigned int uMaxAppIds; + unsigned int uId; + unsigned int uNumApps; + EBillingType eBillingType; + unsigned int uCostInCents; + unsigned int uNumDiscounts; + int bIsPreorder; + int bRequiresShippingAddress; + unsigned int uDomesticShippingCostInCents; + unsigned int uInternationalShippingCostInCents; + bool bIsCyberCafeSubscription; + unsigned int uGameCode; + char szGameCodeDesc[STEAM_MAX_PATH]; + bool bIsDisabled; + bool bRequiresCD; + unsigned int uTerritoryCode; + bool bIsSteam3Subscription; + +} TSteamSubscription; + +typedef struct +{ + char szName[STEAM_MAX_PATH]; + unsigned int uDiscountInCents; + unsigned int uNumQualifiers; + +} TSteamSubscriptionDiscount; + +typedef struct +{ + char szName[STEAM_MAX_PATH]; + unsigned int uRequiredSubscription; + int bIsDisqualifier; + +} TSteamDiscountQualifier; + +typedef struct TSteamProgress +{ + int bValid; /* non-zero if call provides progress info */ + unsigned int uPercentDone; /* 0 to 100 * STEAM_PROGRESS_PERCENT_SCALE if bValid */ + char szProgress[STEAM_MAX_PATH]; /* additional progress info */ +} TSteamProgress; + +typedef enum +{ + eSteamNotifyTicketsWillExpire, + eSteamNotifyAccountInfoChanged, + eSteamNotifyContentDescriptionChanged, + eSteamNotifyPleaseShutdown, + eSteamNotifyNewContentServer, + eSteamNotifySubscriptionStatusChanged, + eSteamNotifyContentServerConnectionLost, + eSteamNotifyCacheLoadingCompleted, + eSteamNotifyCacheNeedsDecryption, + eSteamNotifyCacheNeedsRepair +} ESteamNotificationCallbackEvent; + + +typedef void(*SteamNotificationCallback_t)(ESteamNotificationCallbackEvent eEvent, unsigned int nData); + + +typedef char SteamPersonalQuestion_t[ STEAM_QUESTION_MAXLEN + 1 ]; + +typedef struct +{ + unsigned char uchSalt[STEAM_SALT_SIZE]; +} SteamSalt_t; + +typedef enum +{ + eVisa = 1, + eMaster = 2, + eAmericanExpress = 3, + eDiscover = 4, + eDinnersClub = 5, + eJCB = 6 +} ESteamPaymentCardType; + +typedef struct +{ + ESteamPaymentCardType eCardType; + char szCardNumber[ STEAM_CARD_NUMBER_SIZE +1 ]; + char szCardHolderName[ STEAM_CARD_HOLDERNAME_SIZE + 1]; + char szCardExpYear[ STEAM_CARD_EXPYEAR_SIZE + 1 ]; + char szCardExpMonth[ STEAM_CARD_EXPMONTH_SIZE+ 1 ]; + char szCardCVV2[ STEAM_CARD_CVV2_SIZE + 1 ]; + char szBillingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ]; + char szBillingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ]; + char szBillingCity[ STEAM_BILLING_CITY_SIZE + 1 ]; + char szBillingZip[ STEAM_BILLING_ZIP_SIZE + 1 ]; + char szBillingState[ STEAM_BILLING_STATE_SIZE + 1 ]; + char szBillingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ]; + char szBillingPhone[ STEAM_BILLING_PHONE_SIZE + 1 ]; + char szBillingEmailAddress[ STEAM_BILLING_EMAIL_ADDRESS_SIZE + 1 ]; + unsigned int uExpectedCostInCents; + unsigned int uExpectedTaxInCents; + /* If the TSteamSubscription says that shipping info is required, */ + /* then the following fields must be filled out. */ + /* If szShippingName is empty, then assumes so are the rest. */ + char szShippingName[ STEAM_CARD_HOLDERNAME_SIZE + 1]; + char szShippingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ]; + char szShippingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ]; + char szShippingCity[ STEAM_BILLING_CITY_SIZE + 1 ]; + char szShippingZip[ STEAM_BILLING_ZIP_SIZE + 1 ]; + char szShippingState[ STEAM_BILLING_STATE_SIZE + 1 ]; + char szShippingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ]; + char szShippingPhone[ STEAM_BILLING_PHONE_SIZE + 1 ]; + unsigned int uExpectedShippingCostInCents; + +} TSteamPaymentCardInfo; + +typedef struct +{ + char szTypeOfProofOfPurchase[ STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE + 1 ]; + + /* A ProofOfPurchase token is not necessarily a nul-terminated string; it may be binary data + (perhaps encrypted). Hence we need a length and an array of bytes. */ + unsigned int uLengthOfBinaryProofOfPurchaseToken; + char cBinaryProofOfPurchaseToken[ STEAM_PROOF_OF_PURCHASE_TOKEN_SIZE + 1 ]; +} TSteamPrepurchaseInfo; + +typedef struct +{ + char szAccountName[ STEAM_EXTERNAL_ACCOUNTNAME_SIZE + 1 ]; + char szPassword[ STEAM_EXTERNAL_ACCOUNTPASSWORD_SIZE + 1 ]; +} TSteamExternalBillingInfo; + +typedef enum +{ + ePaymentCardInfo = 1, + ePrepurchasedInfo = 2, + eAccountBillingInfo = 3, + eExternalBillingInfo = 4, /* indirect billing via ISP etc (not supported yet) */ + ePaymentCardReceipt = 5, + ePrepurchaseReceipt = 6, + eEmptyReceipt = 7 +} ESteamSubscriptionBillingInfoType; + +typedef struct +{ + ESteamSubscriptionBillingInfoType eBillingInfoType; + union { + TSteamPaymentCardInfo PaymentCardInfo; + TSteamPrepurchaseInfo PrepurchaseInfo; + TSteamExternalBillingInfo ExternalBillingInfo; + char bUseAccountBillingInfo; + }; + +} TSteamSubscriptionBillingInfo; + +typedef enum +{ + /* Subscribed */ + eSteamSubscriptionOK = 0, /* Subscribed */ + eSteamSubscriptionPending = 1, /* Awaiting transaction completion */ + eSteamSubscriptionPreorder = 2, /* Is currently a pre-order */ + eSteamSubscriptionPrepurchaseTransferred = 3, /* hop to this account */ + /* Unusbscribed */ + eSteamSubscriptionPrepurchaseInvalid = 4, /* Invalid cd-key */ + eSteamSubscriptionPrepurchaseRejected = 5, /* hopped out / banned / etc */ + eSteamSubscriptionPrepurchaseRevoked = 6, /* hop away from this account */ + eSteamSubscriptionPaymentCardDeclined = 7, /* CC txn declined */ + eSteamSubscriptionCancelledByUser = 8, /* Cancelled by client */ + eSteamSubscriptionCancelledByVendor = 9, /* Cancelled by us */ + eSteamSubscriptionPaymentCardUseLimit = 10, /* Card used too many times, potential fraud */ + eSteamSubscriptionPaymentCardAlert = 11, /* Got a "pick up card" or the like from bank */ + eSteamSubscriptionFailed = 12, /* Other Error in subscription data or transaction failed/lost */ + eSteamSubscriptionPaymentCardAVSFailure = 13, /* Card failed Address Verification check */ + eSteamSubscriptionPaymentCardInsufficientFunds = 14, /* Card failed due to insufficient funds */ + eSteamSubscriptionRestrictedCountry = 15 /* The subscription is not available in the user's country */ + +} ESteamSubscriptionStatus; + +typedef struct +{ + ESteamPaymentCardType eCardType; + char szCardLastFourDigits[ 4 + 1 ]; + char szCardHolderName[ STEAM_CARD_HOLDERNAME_SIZE + 1]; + char szBillingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ]; + char szBillingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ]; + char szBillingCity[ STEAM_BILLING_CITY_SIZE + 1 ]; + char szBillingZip[ STEAM_BILLING_ZIP_SIZE + 1 ]; + char szBillingState[ STEAM_BILLING_STATE_SIZE + 1 ]; + char szBillingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ]; + + // The following are only available after the subscription leaves "pending" status + char szCardApprovalCode[ STEAM_BILLING_CARD_APPROVAL_CODE_SIZE + 1]; + char szTransDate[ STEAM_BILLING_TRANS_DATE_SIZE + 1]; /* mm/dd/yy */ + char szTransTime[ STEAM_BILLING_TRANS_TIME_SIZE + 1]; /* hh:mm:ss */ + unsigned int uPriceWithoutTax; + unsigned int uTaxAmount; + unsigned int uShippingCost; + +} TSteamPaymentCardReceiptInfo; + +typedef struct +{ + char szTypeOfProofOfPurchase[ STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE + 1 ]; +} TSteamPrepurchaseReceiptInfo; + +typedef struct +{ + ESteamSubscriptionStatus eStatus; + ESteamSubscriptionStatus ePreviousStatus; + ESteamSubscriptionBillingInfoType eReceiptInfoType; + char szConfirmationCode[ STEAM_BILLING_CONFIRMATION_CODE_SIZE + 1]; + union { + TSteamPaymentCardReceiptInfo PaymentCardReceiptInfo; + TSteamPrepurchaseReceiptInfo PrepurchaseReceiptInfo; + }; + +} TSteamSubscriptionReceipt; + +typedef enum +{ + ePhysicalBytesReceivedThisSession = 1, + eAppReadyToLaunchStatus = 2, + eAppPreloadStatus = 3, + eAppEntireDepot = 4, + eCacheBytesPresent = 5 +} ESteamAppUpdateStatsQueryType; + +typedef struct +{ + SteamUnsigned64_t uBytesTotal; + SteamUnsigned64_t uBytesPresent; +} TSteamUpdateStats; + +typedef enum +{ + eSteamUserAdministrator = 0x00000001, /* May subscribe, unsubscribe, etc */ + eSteamUserDeveloper = 0x00000002, /* Steam or App developer */ + eSteamUserCyberCafe = 0x00000004 /* CyberCafe, school, etc -- UI should ask for password */ + /* before allowing logout, unsubscribe, etc */ +} ESteamUserTypeFlags; + +typedef enum +{ + eSteamAccountStatusDefault = 0x00000000, + eSteamAccountStatusEmailVerified = 0x00000001, + /* Note: Mask value 0x2 is reserved for future use. (Some, but not all, public accounts already have this set.) */ + eSteamAccountDisabled = 0x00000004 +} ESteamAccountStatusBitFields ; + + +typedef enum +{ + eSteamBootstrapperError = -1, + eSteamBootstrapperDontCheckForUpdate = 0, + eSteamBootstrapperCheckForUpdateAndRerun = 7 + +} ESteamBootStrapperClientAppResult; + +typedef enum +{ + eSteamOnline = 0, + eSteamOffline = 1, + eSteamNoAuthMode = 2, + eSteamBillingOffline = 3 +} eSteamOfflineStatus; + +typedef struct +{ + int eOfflineNow; + int eOfflineNextSession; +} TSteamOfflineStatus; + +typedef struct +{ + unsigned int uAppId; + int bIsSystemDefined; + char szMountPath[STEAM_MAX_PATH]; +} TSteamAppDependencyInfo; + +typedef enum +{ + eSteamOpenFileRegular = 0x0, + eSteamOpenFileIgnoreLocal = 0x1, + eSteamOpenFileChecksumReads = 0x2 +} ESteamOpenFileFlags; + +typedef enum +{ + eSteamValveCDKeyValidationServer = 0, + eSteamHalfLifeMasterServer = 1, + eSteamFriendsServer = 2, + eSteamCSERServer = 3, + eSteamHalfLife2MasterServer = 4, + eSteamRDKFMasterServer = 5, + eMaxServerTypes = 6 +} ESteamServerType; + +/****************************************************************************** +** +** More exported constants +** +******************************************************************************/ + + +#ifdef __cplusplus + +const SteamHandle_t STEAM_INVALID_HANDLE = 0; +const SteamCallHandle_t STEAM_INVALID_CALL_HANDLE = 0; +const SteamUserIDTicketValidationHandle_t STEAM_INACTIVE_USERIDTICKET_VALIDATION_HANDLE = 0; +const unsigned int STEAM_USE_LATEST_VERSION = 0xFFFFFFFF; + +#else + +#define STEAM_INVALID_HANDLE ((SteamHandle_t)(0)) +#define STEAM_INVALID_CALL_HANDLE ((SteamCallHandle_t)(0)) +#define STEAM_INACTIVE_USERIDTICKET_VALIDATION_HANDLE ((SteamUserIDTicketValidationHandle_t)(0)) +#define STEAM_USE_LATEST_VERSION (0xFFFFFFFFu); + +#endif + + +/****************************************************************************** +** Each Steam instance (licensed Steam Service Provider) has a unique SteamInstanceID_t. +** +** Each Steam instance as its own DB of users. +** Each user in the DB has a unique SteamLocalUserID_t (a serial number, with possible +** rare gaps in the sequence). +** +******************************************************************************/ + +typedef unsigned short SteamInstanceID_t; // MUST be 16 bits + + +#if defined ( _WIN32 ) +typedef unsigned __int64 SteamLocalUserID_t; // MUST be 64 bits +#else +typedef unsigned long long SteamLocalUserID_t; // MUST be 64 bits +#endif + +/****************************************************************************** +** +** Applications need to be able to authenticate Steam users from ANY instance. +** So a SteamIDTicket contains SteamGlobalUserID, which is a unique combination of +** instance and user id. +** +** SteamLocalUserID is an unsigned 64-bit integer. +** For platforms without 64-bit int support, we provide access via a union that splits it into +** high and low unsigned 32-bit ints. Such platforms will only need to compare LocalUserIDs +** for equivalence anyway - not perform arithmetic with them. +** +********************************************************************************/ +typedef struct +{ + unsigned int Low32bits; + unsigned int High32bits; +} TSteamSplitLocalUserID; + +typedef struct +{ + SteamInstanceID_t m_SteamInstanceID; + + union + { + SteamLocalUserID_t As64bits; + TSteamSplitLocalUserID Split; + } m_SteamLocalUserID; + +} TSteamGlobalUserID; + + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/dep/rehlsdk/common/beamdef.h b/dep/rehlsdk/common/beamdef.h index f493391..fd77a76 100644 --- a/dep/rehlsdk/common/beamdef.h +++ b/dep/rehlsdk/common/beamdef.h @@ -1,62 +1,62 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined ( BEAMDEFH ) -#define BEAMDEFH -#ifdef _WIN32 -#pragma once -#endif - -#define FBEAM_STARTENTITY 0x00000001 -#define FBEAM_ENDENTITY 0x00000002 -#define FBEAM_FADEIN 0x00000004 -#define FBEAM_FADEOUT 0x00000008 -#define FBEAM_SINENOISE 0x00000010 -#define FBEAM_SOLID 0x00000020 -#define FBEAM_SHADEIN 0x00000040 -#define FBEAM_SHADEOUT 0x00000080 -#define FBEAM_STARTVISIBLE 0x10000000 // Has this client actually seen this beam's start entity yet? -#define FBEAM_ENDVISIBLE 0x20000000 // Has this client actually seen this beam's end entity yet? -#define FBEAM_ISACTIVE 0x40000000 -#define FBEAM_FOREVER 0x80000000 - -typedef struct beam_s BEAM; -struct beam_s -{ - BEAM *next; - int type; - int flags; - vec3_t source; - vec3_t target; - vec3_t delta; - float t; // 0 .. 1 over lifetime of beam - float freq; - float die; - float width; - float amplitude; - float r, g, b; - float brightness; - float speed; - float frameRate; - float frame; - int segments; - int startEntity; - int endEntity; - int modelIndex; - int frameCount; - struct model_s *pFollowModel; - struct particle_s *particles; -}; - -#endif +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#if !defined ( BEAMDEFH ) +#define BEAMDEFH +#ifdef _WIN32 +#pragma once +#endif + +#define FBEAM_STARTENTITY 0x00000001 +#define FBEAM_ENDENTITY 0x00000002 +#define FBEAM_FADEIN 0x00000004 +#define FBEAM_FADEOUT 0x00000008 +#define FBEAM_SINENOISE 0x00000010 +#define FBEAM_SOLID 0x00000020 +#define FBEAM_SHADEIN 0x00000040 +#define FBEAM_SHADEOUT 0x00000080 +#define FBEAM_STARTVISIBLE 0x10000000 // Has this client actually seen this beam's start entity yet? +#define FBEAM_ENDVISIBLE 0x20000000 // Has this client actually seen this beam's end entity yet? +#define FBEAM_ISACTIVE 0x40000000 +#define FBEAM_FOREVER 0x80000000 + +typedef struct beam_s BEAM; +struct beam_s +{ + BEAM *next; + int type; + int flags; + vec3_t source; + vec3_t target; + vec3_t delta; + float t; // 0 .. 1 over lifetime of beam + float freq; + float die; + float width; + float amplitude; + float r, g, b; + float brightness; + float speed; + float frameRate; + float frame; + int segments; + int startEntity; + int endEntity; + int modelIndex; + int frameCount; + struct model_s *pFollowModel; + struct particle_s *particles; +}; + +#endif diff --git a/dep/rehlsdk/common/cl_entity.h b/dep/rehlsdk/common/cl_entity.h index b8fd373..a7cd472 100644 --- a/dep/rehlsdk/common/cl_entity.h +++ b/dep/rehlsdk/common/cl_entity.h @@ -1,115 +1,115 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// cl_entity.h -#if !defined( CL_ENTITYH ) -#define CL_ENTITYH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct efrag_s -{ - struct mleaf_s *leaf; - struct efrag_s *leafnext; - struct cl_entity_s *entity; - struct efrag_s *entnext; -} efrag_t; - -typedef struct -{ - byte mouthopen; // 0 = mouth closed, 255 = mouth agape - byte sndcount; // counter for running average - int sndavg; // running average -} mouth_t; - -typedef struct -{ - float prevanimtime; - float sequencetime; - byte prevseqblending[2]; - vec3_t prevorigin; - vec3_t prevangles; - - int prevsequence; - float prevframe; - - byte prevcontroller[4]; - byte prevblending[2]; -} latchedvars_t; - -typedef struct -{ - // Time stamp for this movement - float animtime; - - vec3_t origin; - vec3_t angles; -} position_history_t; - -typedef struct cl_entity_s cl_entity_t; - -#define HISTORY_MAX 64 // Must be power of 2 -#define HISTORY_MASK ( HISTORY_MAX - 1 ) - - -#if !defined( ENTITY_STATEH ) -#include "entity_state.h" -#endif - -#if !defined( PROGS_H ) -#include "progs.h" -#endif - -struct cl_entity_s -{ - int index; // Index into cl_entities ( should match actual slot, but not necessarily ) - - qboolean player; // True if this entity is a "player" - - entity_state_t baseline; // The original state from which to delta during an uncompressed message - entity_state_t prevstate; // The state information from the penultimate message received from the server - entity_state_t curstate; // The state information from the last message received from server - - int current_position; // Last received history update index - position_history_t ph[ HISTORY_MAX ]; // History of position and angle updates for this player - - mouth_t mouth; // For synchronizing mouth movements. - - latchedvars_t latched; // Variables used by studio model rendering routines - - // Information based on interplocation, extrapolation, prediction, or just copied from last msg received. - // - float lastmove; - - // Actual render position and angles - vec3_t origin; - vec3_t angles; - - // Attachment points - vec3_t attachment[4]; - - // Other entity local information - int trivial_accept; - - struct model_s *model; // cl.model_precache[ curstate.modelindes ]; all visible entities have a model - struct efrag_s *efrag; // linked list of efrags - struct mnode_s *topnode; // for bmodels, first world node that splits bmodel, or NULL if not split - - float syncbase; // for client-side animations -- used by obsolete alias animation system, remove? - int visframe; // last frame this entity was found in an active leaf - colorVec cvFloorColor; -}; - -#endif // !CL_ENTITYH +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +// cl_entity.h +#if !defined( CL_ENTITYH ) +#define CL_ENTITYH +#ifdef _WIN32 +#pragma once +#endif + +typedef struct efrag_s +{ + struct mleaf_s *leaf; + struct efrag_s *leafnext; + struct cl_entity_s *entity; + struct efrag_s *entnext; +} efrag_t; + +typedef struct +{ + byte mouthopen; // 0 = mouth closed, 255 = mouth agape + byte sndcount; // counter for running average + int sndavg; // running average +} mouth_t; + +typedef struct +{ + float prevanimtime; + float sequencetime; + byte prevseqblending[2]; + vec3_t prevorigin; + vec3_t prevangles; + + int prevsequence; + float prevframe; + + byte prevcontroller[4]; + byte prevblending[2]; +} latchedvars_t; + +typedef struct +{ + // Time stamp for this movement + float animtime; + + vec3_t origin; + vec3_t angles; +} position_history_t; + +typedef struct cl_entity_s cl_entity_t; + +#define HISTORY_MAX 64 // Must be power of 2 +#define HISTORY_MASK ( HISTORY_MAX - 1 ) + + +#if !defined( ENTITY_STATEH ) +#include "entity_state.h" +#endif + +#if !defined( PROGS_H ) +#include "progs.h" +#endif + +struct cl_entity_s +{ + int index; // Index into cl_entities ( should match actual slot, but not necessarily ) + + qboolean player; // True if this entity is a "player" + + entity_state_t baseline; // The original state from which to delta during an uncompressed message + entity_state_t prevstate; // The state information from the penultimate message received from the server + entity_state_t curstate; // The state information from the last message received from server + + int current_position; // Last received history update index + position_history_t ph[ HISTORY_MAX ]; // History of position and angle updates for this player + + mouth_t mouth; // For synchronizing mouth movements. + + latchedvars_t latched; // Variables used by studio model rendering routines + + // Information based on interplocation, extrapolation, prediction, or just copied from last msg received. + // + float lastmove; + + // Actual render position and angles + vec3_t origin; + vec3_t angles; + + // Attachment points + vec3_t attachment[4]; + + // Other entity local information + int trivial_accept; + + struct model_s *model; // cl.model_precache[ curstate.modelindes ]; all visible entities have a model + struct efrag_s *efrag; // linked list of efrags + struct mnode_s *topnode; // for bmodels, first world node that splits bmodel, or NULL if not split + + float syncbase; // for client-side animations -- used by obsolete alias animation system, remove? + int visframe; // last frame this entity was found in an active leaf + colorVec cvFloorColor; +}; + +#endif // !CL_ENTITYH diff --git a/dep/rehlsdk/common/com_model.h b/dep/rehlsdk/common/com_model.h index 6ccee32..d6e3d42 100644 --- a/dep/rehlsdk/common/com_model.h +++ b/dep/rehlsdk/common/com_model.h @@ -1,340 +1,340 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// com_model.h -#pragma once - -#define STUDIO_RENDER 1 -#define STUDIO_EVENTS 2 - -//#define MAX_MODEL_NAME 64 -//#define MAX_MAP_HULLS 4 -//#define MIPLEVELS 4 -//#define NUM_AMBIENTS 4 // automatic ambient sounds -//#define MAXLIGHTMAPS 4 -#define PLANE_ANYZ 5 - -#define ALIAS_Z_CLIP_PLANE 5 - -// flags in finalvert_t.flags -#define ALIAS_LEFT_CLIP 0x0001 -#define ALIAS_TOP_CLIP 0x0002 -#define ALIAS_RIGHT_CLIP 0x0004 -#define ALIAS_BOTTOM_CLIP 0x0008 -#define ALIAS_Z_CLIP 0x0010 -#define ALIAS_ONSEAM 0x0020 -#define ALIAS_XY_CLIP_MASK 0x000F - -#define ZISCALE ((float)0x8000) - -#define CACHE_SIZE 32 // used to align key data structures - -//typedef enum -//{ -// mod_brush, -// mod_sprite, -// mod_alias, -// mod_studio -//} modtype_t; - -// must match definition in modelgen.h -//#ifndef SYNCTYPE_T -//#define SYNCTYPE_T -// -//typedef enum -//{ -// ST_SYNC=0, -// ST_RAND -//} synctype_t; -// -//#endif - -//typedef struct -//{ -// float mins[3], maxs[3]; -// float origin[3]; -// int headnode[MAX_MAP_HULLS]; -// int visleafs; // not including the solid leaf 0 -// int firstface, numfaces; -//} dmodel_t; - -// plane_t structure -//typedef struct mplane_s -//{ -// vec3_t normal; // surface normal -// float dist; // closest appoach to origin -// byte type; // for texture axis selection and fast side tests -// byte signbits; // signx + signy<<1 + signz<<1 -// byte pad[2]; -//} mplane_t; - -//typedef struct -//{ -// vec3_t position; -//} mvertex_t; - -//typedef struct -//{ -// unsigned short v[2]; -// unsigned int cachededgeoffset; -//} medge_t; - -//typedef struct texture_s -//{ -// char name[16]; -// unsigned width, height; -// int anim_total; // total tenths in sequence ( 0 = no) -// int anim_min, anim_max; // time for this frame min <=time< max -// struct texture_s *anim_next; // in the animation sequence -// struct texture_s *alternate_anims; // bmodels in frame 1 use these -// unsigned offsets[MIPLEVELS]; // four mip maps stored -// unsigned paloffset; -//} texture_t; - -//typedef struct -//{ -// float vecs[2][4]; // [s/t] unit vectors in world space. -// // [i][3] is the s/t offset relative to the origin. -// // s or t = dot(3Dpoint,vecs[i])+vecs[i][3] -// float mipadjust; // ?? mipmap limits for very small surfaces -// texture_t *texture; -// int flags; // sky or slime, no lightmap or 256 subdivision -//} mtexinfo_t; - -//typedef struct mnode_s -//{ -// // common with leaf -// int contents; // 0, to differentiate from leafs -// int visframe; // node needs to be traversed if current -// -// short minmaxs[6]; // for bounding box culling -// -// struct mnode_s *parent; -// -// // node specific -// mplane_t *plane; -// struct mnode_s *children[2]; -// -// unsigned short firstsurface; -// unsigned short numsurfaces; -//} mnode_t; - -//typedef struct msurface_s msurface_t; -//typedef struct decal_s decal_t; - -// JAY: Compress this as much as possible -//struct decal_s -//{ -// decal_t *pnext; // linked list for each surface -// msurface_t *psurface; // Surface id for persistence / unlinking -// short dx; // Offsets into surface texture (in texture coordinates, so we don't need floats) -// short dy; -// short texture; // Decal texture -// byte scale; // Pixel scale -// byte flags; // Decal flags -// -// short entityIndex; // Entity this is attached to -//}; - -//typedef struct mleaf_s -//{ -// // common with node -// int contents; // wil be a negative contents number -// int visframe; // node needs to be traversed if current -// -// short minmaxs[6]; // for bounding box culling -// -// struct mnode_s *parent; -// -// // leaf specific -// byte *compressed_vis; -// struct efrag_s *efrags; -// -// msurface_t **firstmarksurface; -// int nummarksurfaces; -// int key; // BSP sequence number for leaf's contents -// byte ambient_sound_level[NUM_AMBIENTS]; -//} mleaf_t; - -//struct msurface_s -//{ -// int visframe; // should be drawn when node is crossed -// -// int dlightframe; // last frame the surface was checked by an animated light -// int dlightbits; // dynamically generated. Indicates if the surface illumination -// // is modified by an animated light. -// -// mplane_t *plane; // pointer to shared plane -// int flags; // see SURF_ #defines -// -// int firstedge; // look up in model->surfedges[], negative numbers -// int numedges; // are backwards edges -// -// // surface generation data -// struct surfcache_s *cachespots[MIPLEVELS]; -// -// short texturemins[2]; // smallest s/t position on the surface. -// short extents[2]; // ?? s/t texture size, 1..256 for all non-sky surfaces -// -// mtexinfo_t *texinfo; -// -// // lighting info -// byte styles[MAXLIGHTMAPS]; // index into d_lightstylevalue[] for animated lights -// // no one surface can be effected by more than 4 -// // animated lights. -// color24 *samples; -// -// decal_t *pdecals; -//}; - -//typedef struct -//{ -// int planenum; -// short children[2]; // negative numbers are contents -//} dclipnode_t; - -//typedef struct hull_s -//{ -// dclipnode_t *clipnodes; -// mplane_t *planes; -// int firstclipnode; -// int lastclipnode; -// vec3_t clip_mins; -// vec3_t clip_maxs; -//} hull_t; - -typedef struct cache_user_s -{ - void *data; -} cache_user_t; - -//typedef struct model_s -//{ -// char name[ MAX_MODEL_NAME ]; -// qboolean needload; // bmodels and sprites don't cache normally -// -// modtype_t type; -// int numframes; -// synctype_t synctype; -// -// int flags; -// -// // -// // volume occupied by the model -// // -// vec3_t mins, maxs; -// float radius; -// -// // -// // brush model -// // -// int firstmodelsurface, nummodelsurfaces; -// -// int numsubmodels; -// dmodel_t *submodels; -// -// int numplanes; -// mplane_t *planes; -// -// int numleafs; // number of visible leafs, not counting 0 -// struct mleaf_s *leafs; -// -// int numvertexes; -// mvertex_t *vertexes; -// -// int numedges; -// medge_t *edges; -// -// int numnodes; -// mnode_t *nodes; -// -// int numtexinfo; -// mtexinfo_t *texinfo; -// -// int numsurfaces; -// msurface_t *surfaces; -// -// int numsurfedges; -// int *surfedges; -// -// int numclipnodes; -// dclipnode_t *clipnodes; -// -// int nummarksurfaces; -// msurface_t **marksurfaces; -// -// hull_t hulls[MAX_MAP_HULLS]; -// -// int numtextures; -// texture_t **textures; -// -// byte *visdata; -// -// color24 *lightdata; -// -// char *entities; -// -// // -// // additional model data -// // -// cache_user_t cache; // only access through Mod_Extradata -// -//} model_t; - -//typedef vec_t vec4_t[4]; - -typedef struct alight_s -{ - int ambientlight; // clip at 128 - int shadelight; // clip at 192 - ambientlight - vec3_t color; - float *plightvec; -} alight_t; - -typedef struct auxvert_s -{ - float fv[3]; // viewspace x, y -} auxvert_t; - -#include "custom.h" - -//#define MAX_SCOREBOARDNAME 32 - -// Defined in client.h differently -//typedef struct player_info_s -//{ -// // User id on server -// int userid; -// -// // User info string -// char userinfo[ MAX_INFO_STRING ]; -// -// // Name -// char name[ MAX_SCOREBOARDNAME ]; -// -// // Spectator or not, unused -// int spectator; -// -// int ping; -// int packet_loss; -// -// // skin information -// char model[MAX_QPATH]; -// int topcolor; -// int bottomcolor; -// -// // last frame rendered -// int renderframe; -// -// // Gait frame estimation -// int gaitsequence; -// float gaitframe; -// float gaityaw; -// vec3_t prevgaitorigin; -// -// customization_t customdata; -//} player_info_t; +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +// com_model.h +#pragma once + +#define STUDIO_RENDER 1 +#define STUDIO_EVENTS 2 + +//#define MAX_MODEL_NAME 64 +//#define MAX_MAP_HULLS 4 +//#define MIPLEVELS 4 +//#define NUM_AMBIENTS 4 // automatic ambient sounds +//#define MAXLIGHTMAPS 4 +#define PLANE_ANYZ 5 + +#define ALIAS_Z_CLIP_PLANE 5 + +// flags in finalvert_t.flags +#define ALIAS_LEFT_CLIP 0x0001 +#define ALIAS_TOP_CLIP 0x0002 +#define ALIAS_RIGHT_CLIP 0x0004 +#define ALIAS_BOTTOM_CLIP 0x0008 +#define ALIAS_Z_CLIP 0x0010 +#define ALIAS_ONSEAM 0x0020 +#define ALIAS_XY_CLIP_MASK 0x000F + +#define ZISCALE ((float)0x8000) + +#define CACHE_SIZE 32 // used to align key data structures + +//typedef enum +//{ +// mod_brush, +// mod_sprite, +// mod_alias, +// mod_studio +//} modtype_t; + +// must match definition in modelgen.h +//#ifndef SYNCTYPE_T +//#define SYNCTYPE_T +// +//typedef enum +//{ +// ST_SYNC=0, +// ST_RAND +//} synctype_t; +// +//#endif + +//typedef struct +//{ +// float mins[3], maxs[3]; +// float origin[3]; +// int headnode[MAX_MAP_HULLS]; +// int visleafs; // not including the solid leaf 0 +// int firstface, numfaces; +//} dmodel_t; + +// plane_t structure +//typedef struct mplane_s +//{ +// vec3_t normal; // surface normal +// float dist; // closest appoach to origin +// byte type; // for texture axis selection and fast side tests +// byte signbits; // signx + signy<<1 + signz<<1 +// byte pad[2]; +//} mplane_t; + +//typedef struct +//{ +// vec3_t position; +//} mvertex_t; + +//typedef struct +//{ +// unsigned short v[2]; +// unsigned int cachededgeoffset; +//} medge_t; + +//typedef struct texture_s +//{ +// char name[16]; +// unsigned width, height; +// int anim_total; // total tenths in sequence ( 0 = no) +// int anim_min, anim_max; // time for this frame min <=time< max +// struct texture_s *anim_next; // in the animation sequence +// struct texture_s *alternate_anims; // bmodels in frame 1 use these +// unsigned offsets[MIPLEVELS]; // four mip maps stored +// unsigned paloffset; +//} texture_t; + +//typedef struct +//{ +// float vecs[2][4]; // [s/t] unit vectors in world space. +// // [i][3] is the s/t offset relative to the origin. +// // s or t = dot(3Dpoint,vecs[i])+vecs[i][3] +// float mipadjust; // ?? mipmap limits for very small surfaces +// texture_t *texture; +// int flags; // sky or slime, no lightmap or 256 subdivision +//} mtexinfo_t; + +//typedef struct mnode_s +//{ +// // common with leaf +// int contents; // 0, to differentiate from leafs +// int visframe; // node needs to be traversed if current +// +// short minmaxs[6]; // for bounding box culling +// +// struct mnode_s *parent; +// +// // node specific +// mplane_t *plane; +// struct mnode_s *children[2]; +// +// unsigned short firstsurface; +// unsigned short numsurfaces; +//} mnode_t; + +//typedef struct msurface_s msurface_t; +//typedef struct decal_s decal_t; + +// JAY: Compress this as much as possible +//struct decal_s +//{ +// decal_t *pnext; // linked list for each surface +// msurface_t *psurface; // Surface id for persistence / unlinking +// short dx; // Offsets into surface texture (in texture coordinates, so we don't need floats) +// short dy; +// short texture; // Decal texture +// byte scale; // Pixel scale +// byte flags; // Decal flags +// +// short entityIndex; // Entity this is attached to +//}; + +//typedef struct mleaf_s +//{ +// // common with node +// int contents; // wil be a negative contents number +// int visframe; // node needs to be traversed if current +// +// short minmaxs[6]; // for bounding box culling +// +// struct mnode_s *parent; +// +// // leaf specific +// byte *compressed_vis; +// struct efrag_s *efrags; +// +// msurface_t **firstmarksurface; +// int nummarksurfaces; +// int key; // BSP sequence number for leaf's contents +// byte ambient_sound_level[NUM_AMBIENTS]; +//} mleaf_t; + +//struct msurface_s +//{ +// int visframe; // should be drawn when node is crossed +// +// int dlightframe; // last frame the surface was checked by an animated light +// int dlightbits; // dynamically generated. Indicates if the surface illumination +// // is modified by an animated light. +// +// mplane_t *plane; // pointer to shared plane +// int flags; // see SURF_ #defines +// +// int firstedge; // look up in model->surfedges[], negative numbers +// int numedges; // are backwards edges +// +// // surface generation data +// struct surfcache_s *cachespots[MIPLEVELS]; +// +// short texturemins[2]; // smallest s/t position on the surface. +// short extents[2]; // ?? s/t texture size, 1..256 for all non-sky surfaces +// +// mtexinfo_t *texinfo; +// +// // lighting info +// byte styles[MAXLIGHTMAPS]; // index into d_lightstylevalue[] for animated lights +// // no one surface can be effected by more than 4 +// // animated lights. +// color24 *samples; +// +// decal_t *pdecals; +//}; + +//typedef struct +//{ +// int planenum; +// short children[2]; // negative numbers are contents +//} dclipnode_t; + +//typedef struct hull_s +//{ +// dclipnode_t *clipnodes; +// mplane_t *planes; +// int firstclipnode; +// int lastclipnode; +// vec3_t clip_mins; +// vec3_t clip_maxs; +//} hull_t; + +typedef struct cache_user_s +{ + void *data; +} cache_user_t; + +//typedef struct model_s +//{ +// char name[ MAX_MODEL_NAME ]; +// qboolean needload; // bmodels and sprites don't cache normally +// +// modtype_t type; +// int numframes; +// synctype_t synctype; +// +// int flags; +// +// // +// // volume occupied by the model +// // +// vec3_t mins, maxs; +// float radius; +// +// // +// // brush model +// // +// int firstmodelsurface, nummodelsurfaces; +// +// int numsubmodels; +// dmodel_t *submodels; +// +// int numplanes; +// mplane_t *planes; +// +// int numleafs; // number of visible leafs, not counting 0 +// struct mleaf_s *leafs; +// +// int numvertexes; +// mvertex_t *vertexes; +// +// int numedges; +// medge_t *edges; +// +// int numnodes; +// mnode_t *nodes; +// +// int numtexinfo; +// mtexinfo_t *texinfo; +// +// int numsurfaces; +// msurface_t *surfaces; +// +// int numsurfedges; +// int *surfedges; +// +// int numclipnodes; +// dclipnode_t *clipnodes; +// +// int nummarksurfaces; +// msurface_t **marksurfaces; +// +// hull_t hulls[MAX_MAP_HULLS]; +// +// int numtextures; +// texture_t **textures; +// +// byte *visdata; +// +// color24 *lightdata; +// +// char *entities; +// +// // +// // additional model data +// // +// cache_user_t cache; // only access through Mod_Extradata +// +//} model_t; + +//typedef vec_t vec4_t[4]; + +typedef struct alight_s +{ + int ambientlight; // clip at 128 + int shadelight; // clip at 192 - ambientlight + vec3_t color; + float *plightvec; +} alight_t; + +typedef struct auxvert_s +{ + float fv[3]; // viewspace x, y +} auxvert_t; + +#include "custom.h" + +//#define MAX_SCOREBOARDNAME 32 + +// Defined in client.h differently +//typedef struct player_info_s +//{ +// // User id on server +// int userid; +// +// // User info string +// char userinfo[ MAX_INFO_STRING ]; +// +// // Name +// char name[ MAX_SCOREBOARDNAME ]; +// +// // Spectator or not, unused +// int spectator; +// +// int ping; +// int packet_loss; +// +// // skin information +// char model[MAX_QPATH]; +// int topcolor; +// int bottomcolor; +// +// // last frame rendered +// int renderframe; +// +// // Gait frame estimation +// int gaitsequence; +// float gaitframe; +// float gaityaw; +// vec3_t prevgaitorigin; +// +// customization_t customdata; +//} player_info_t; diff --git a/dep/rehlsdk/common/con_nprint.h b/dep/rehlsdk/common/con_nprint.h index 849d1d4..b2a1888 100644 --- a/dep/rehlsdk/common/con_nprint.h +++ b/dep/rehlsdk/common/con_nprint.h @@ -1,38 +1,38 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( CON_NPRINTH ) -#define CON_NPRINTH -#ifdef _WIN32 -#pragma once -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct con_nprint_s -{ - int index; // Row # - float time_to_live; // # of seconds before it dissappears - float color[ 3 ]; // RGB colors ( 0.0 -> 1.0 scale ) -} con_nprint_t; - -void Con_NPrintf( int idx, const char *fmt, ... ); -void Con_NXPrintf( struct con_nprint_s *info, const char *fmt, ... ); -#ifdef __cplusplus -} -#endif - -#endif +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#if !defined( CON_NPRINTH ) +#define CON_NPRINTH +#ifdef _WIN32 +#pragma once +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct con_nprint_s +{ + int index; // Row # + float time_to_live; // # of seconds before it dissappears + float color[ 3 ]; // RGB colors ( 0.0 -> 1.0 scale ) +} con_nprint_t; + +void Con_NPrintf( int idx, const char *fmt, ... ); +void Con_NXPrintf( struct con_nprint_s *info, const char *fmt, ... ); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/dep/rehlsdk/common/const.h b/dep/rehlsdk/common/const.h index 721a8da..aa081dc 100644 --- a/dep/rehlsdk/common/const.h +++ b/dep/rehlsdk/common/const.h @@ -1,806 +1,806 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#ifndef CONST_H -#define CONST_H -#ifdef _WIN32 -#pragma once -#endif - -// Max # of clients allowed in a server. -#define MAX_CLIENTS 32 - -// How many bits to use to encode an edict. -#define MAX_EDICT_BITS 11 // # of bits needed to represent max edicts -// Max # of edicts in a level (2048) -#define MAX_EDICTS (1<flags -#define FL_FLY (1<<0) // Changes the SV_Movestep() behavior to not need to be on ground -#define FL_SWIM (1<<1) // Changes the SV_Movestep() behavior to not need to be on ground (but stay in water) -#define FL_CONVEYOR (1<<2) -#define FL_CLIENT (1<<3) -#define FL_INWATER (1<<4) -#define FL_MONSTER (1<<5) -#define FL_GODMODE (1<<6) -#define FL_NOTARGET (1<<7) -#define FL_SKIPLOCALHOST (1<<8) // Don't send entity to local host, it's predicting this entity itself -#define FL_ONGROUND (1<<9) // At rest / on the ground -#define FL_PARTIALGROUND (1<<10) // not all corners are valid -#define FL_WATERJUMP (1<<11) // player jumping out of water -#define FL_FROZEN (1<<12) // Player is frozen for 3rd person camera -#define FL_FAKECLIENT (1<<13) // JAC: fake client, simulated server side; don't send network messages to them -#define FL_DUCKING (1<<14) // Player flag -- Player is fully crouched -#define FL_FLOAT (1<<15) // Apply floating force to this entity when in water -#define FL_GRAPHED (1<<16) // worldgraph has this ent listed as something that blocks a connection - -// UNDONE: Do we need these? -#define FL_IMMUNE_WATER (1<<17) -#define FL_IMMUNE_SLIME (1<<18) -#define FL_IMMUNE_LAVA (1<<19) - -#define FL_PROXY (1<<20) // This is a spectator proxy -#define FL_ALWAYSTHINK (1<<21) // Brush model flag -- call think every frame regardless of nextthink - ltime (for constantly changing velocity/path) -#define FL_BASEVELOCITY (1<<22) // Base velocity has been applied this frame (used to convert base velocity into momentum) -#define FL_MONSTERCLIP (1<<23) // Only collide in with monsters who have FL_MONSTERCLIP set -#define FL_ONTRAIN (1<<24) // Player is _controlling_ a train, so movement commands should be ignored on client during prediction. -#define FL_WORLDBRUSH (1<<25) // Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something) -#define FL_SPECTATOR (1<<26) // This client is a spectator, don't run touch functions, etc. -#define FL_CUSTOMENTITY (1<<29) // This is a custom entity -#define FL_KILLME (1<<30) // This entity is marked for death -- This allows the engine to kill ents at the appropriate time -#define FL_DORMANT (1<<31) // Entity is dormant, no updates to client - -// SV_EmitSound2 flags -#define SND_EMIT2_NOPAS (1<<0) // never to do check PAS -#define SND_EMIT2_INVOKER (1<<1) // do not send to the client invoker - -// Engine edict->spawnflags -#define SF_NOTINDEATHMATCH 0x0800 // Do not spawn when deathmatch and loading entities from a file - - -// Goes into globalvars_t.trace_flags -#define FTRACE_SIMPLEBOX (1<<0) // Traceline with a simple box - - -// walkmove modes -#define WALKMOVE_NORMAL 0 // normal walkmove -#define WALKMOVE_WORLDONLY 1 // doesn't hit ANY entities, no matter what the solid type -#define WALKMOVE_CHECKONLY 2 // move, but don't touch triggers - -// edict->movetype values -#define MOVETYPE_NONE 0 // never moves -//#define MOVETYPE_ANGLENOCLIP 1 -//#define MOVETYPE_ANGLECLIP 2 -#define MOVETYPE_WALK 3 // Player only - moving on the ground -#define MOVETYPE_STEP 4 // gravity, special edge handling -- monsters use this -#define MOVETYPE_FLY 5 // No gravity, but still collides with stuff -#define MOVETYPE_TOSS 6 // gravity/collisions -#define MOVETYPE_PUSH 7 // no clip to world, push and crush -#define MOVETYPE_NOCLIP 8 // No gravity, no collisions, still do velocity/avelocity -#define MOVETYPE_FLYMISSILE 9 // extra size to monsters -#define MOVETYPE_BOUNCE 10 // Just like Toss, but reflect velocity when contacting surfaces -#define MOVETYPE_BOUNCEMISSILE 11 // bounce w/o gravity -#define MOVETYPE_FOLLOW 12 // track movement of aiment -#define MOVETYPE_PUSHSTEP 13 // BSP model that needs physics/world collisions (uses nearest hull for world collision) - -// edict->solid values -// NOTE: Some movetypes will cause collisions independent of SOLID_NOT/SOLID_TRIGGER when the entity moves -// SOLID only effects OTHER entities colliding with this one when they move - UGH! -#define SOLID_NOT 0 // no interaction with other objects -#define SOLID_TRIGGER 1 // touch on edge, but not blocking -#define SOLID_BBOX 2 // touch on edge, block -#define SOLID_SLIDEBOX 3 // touch on edge, but not an onground -#define SOLID_BSP 4 // bsp clip, touch on edge, block - -// edict->deadflag values -#define DEAD_NO 0 // alive -#define DEAD_DYING 1 // playing death animation or still falling off of a ledge waiting to hit ground -#define DEAD_DEAD 2 // dead. lying still. -#define DEAD_RESPAWNABLE 3 -#define DEAD_DISCARDBODY 4 - -#define DAMAGE_NO 0 -#define DAMAGE_YES 1 -#define DAMAGE_AIM 2 - -// entity effects -#define EF_BRIGHTFIELD 1 // swirling cloud of particles -#define EF_MUZZLEFLASH 2 // single frame ELIGHT on entity attachment 0 -#define EF_BRIGHTLIGHT 4 // DLIGHT centered at entity origin -#define EF_DIMLIGHT 8 // player flashlight -#define EF_INVLIGHT 16 // get lighting from ceiling -#define EF_NOINTERP 32 // don't interpolate the next frame -#define EF_LIGHT 64 // rocket flare glow sprite -#define EF_NODRAW 128 // don't draw entity -#define EF_NIGHTVISION 256 // player nightvision -#define EF_SNIPERLASER 512 // sniper laser effect -#define EF_FIBERCAMERA 1024// fiber camera - - -// entity flags -#define EFLAG_SLERP 1 // do studio interpolation of this entity - -// -// temp entity events -// -#define TE_BEAMPOINTS 0 // beam effect between two points -// coord coord coord (start position) -// coord coord coord (end position) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_BEAMENTPOINT 1 // beam effect between point and entity -// short (start entity) -// coord coord coord (end position) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_GUNSHOT 2 // particle effect plus ricochet sound -// coord coord coord (position) - -#define TE_EXPLOSION 3 // additive sprite, 2 dynamic lights, flickering particles, explosion sound, move vertically 8 pps -// coord coord coord (position) -// short (sprite index) -// byte (scale in 0.1's) -// byte (framerate) -// byte (flags) -// -// The Explosion effect has some flags to control performance/aesthetic features: -#define TE_EXPLFLAG_NONE 0 // all flags clear makes default Half-Life explosion -#define TE_EXPLFLAG_NOADDITIVE 1 // sprite will be drawn opaque (ensure that the sprite you send is a non-additive sprite) -#define TE_EXPLFLAG_NODLIGHTS 2 // do not render dynamic lights -#define TE_EXPLFLAG_NOSOUND 4 // do not play client explosion sound -#define TE_EXPLFLAG_NOPARTICLES 8 // do not draw particles - - -#define TE_TAREXPLOSION 4 // Quake1 "tarbaby" explosion with sound -// coord coord coord (position) - -#define TE_SMOKE 5 // alphablend sprite, move vertically 30 pps -// coord coord coord (position) -// short (sprite index) -// byte (scale in 0.1's) -// byte (framerate) - -#define TE_TRACER 6 // tracer effect from point to point -// coord, coord, coord (start) -// coord, coord, coord (end) - -#define TE_LIGHTNING 7 // TE_BEAMPOINTS with simplified parameters -// coord, coord, coord (start) -// coord, coord, coord (end) -// byte (life in 0.1's) -// byte (width in 0.1's) -// byte (amplitude in 0.01's) -// short (sprite model index) - -#define TE_BEAMENTS 8 -// short (start entity) -// short (end entity) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_SPARKS 9 // 8 random tracers with gravity, ricochet sprite -// coord coord coord (position) - -#define TE_LAVASPLASH 10 // Quake1 lava splash -// coord coord coord (position) - -#define TE_TELEPORT 11 // Quake1 teleport splash -// coord coord coord (position) - -#define TE_EXPLOSION2 12 // Quake1 colormaped (base palette) particle explosion with sound -// coord coord coord (position) -// byte (starting color) -// byte (num colors) - -#define TE_BSPDECAL 13 // Decal from the .BSP file -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// short (texture index of precached decal texture name) -// short (entity index) -// [optional - only included if previous short is non-zero (not the world)] short (index of model of above entity) - -#define TE_IMPLOSION 14 // tracers moving toward a point -// coord, coord, coord (position) -// byte (radius) -// byte (count) -// byte (life in 0.1's) - -#define TE_SPRITETRAIL 15 // line of moving glow sprites with gravity, fadeout, and collisions -// coord, coord, coord (start) -// coord, coord, coord (end) -// short (sprite index) -// byte (count) -// byte (life in 0.1's) -// byte (scale in 0.1's) -// byte (velocity along vector in 10's) -// byte (randomness of velocity in 10's) - -#define TE_BEAM 16 // obsolete - -#define TE_SPRITE 17 // additive sprite, plays 1 cycle -// coord, coord, coord (position) -// short (sprite index) -// byte (scale in 0.1's) -// byte (brightness) - -#define TE_BEAMSPRITE 18 // A beam with a sprite at the end -// coord, coord, coord (start position) -// coord, coord, coord (end position) -// short (beam sprite index) -// short (end sprite index) - -#define TE_BEAMTORUS 19 // screen aligned beam ring, expands to max radius over lifetime -// coord coord coord (center position) -// coord coord coord (axis and radius) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_BEAMDISK 20 // disk that expands to max radius over lifetime -// coord coord coord (center position) -// coord coord coord (axis and radius) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_BEAMCYLINDER 21 // cylinder that expands to max radius over lifetime -// coord coord coord (center position) -// coord coord coord (axis and radius) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_BEAMFOLLOW 22 // create a line of decaying beam segments until entity stops moving -// short (entity:attachment to follow) -// short (sprite index) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte,byte,byte (color) -// byte (brightness) - -#define TE_GLOWSPRITE 23 -// coord, coord, coord (pos) short (model index) byte (scale / 10) - -#define TE_BEAMRING 24 // connect a beam ring to two entities -// short (start entity) -// short (end entity) -// short (sprite index) -// byte (starting frame) -// byte (frame rate in 0.1's) -// byte (life in 0.1's) -// byte (line width in 0.1's) -// byte (noise amplitude in 0.01's) -// byte,byte,byte (color) -// byte (brightness) -// byte (scroll speed in 0.1's) - -#define TE_STREAK_SPLASH 25 // oriented shower of tracers -// coord coord coord (start position) -// coord coord coord (direction vector) -// byte (color) -// short (count) -// short (base speed) -// short (ramdon velocity) - -#define TE_BEAMHOSE 26 // obsolete - -#define TE_DLIGHT 27 // dynamic light, effect world, minor entity effect -// coord, coord, coord (pos) -// byte (radius in 10's) -// byte byte byte (color) -// byte (brightness) -// byte (life in 10's) -// byte (decay rate in 10's) - -#define TE_ELIGHT 28 // point entity light, no world effect -// short (entity:attachment to follow) -// coord coord coord (initial position) -// coord (radius) -// byte byte byte (color) -// byte (life in 0.1's) -// coord (decay rate) - -#define TE_TEXTMESSAGE 29 -// short 1.2.13 x (-1 = center) -// short 1.2.13 y (-1 = center) -// byte Effect 0 = fade in/fade out - // 1 is flickery credits - // 2 is write out (training room) - -// 4 bytes r,g,b,a color1 (text color) -// 4 bytes r,g,b,a color2 (effect color) -// ushort 8.8 fadein time -// ushort 8.8 fadeout time -// ushort 8.8 hold time -// optional ushort 8.8 fxtime (time the highlight lags behing the leading text in effect 2) -// string text message (512 chars max sz string) -#define TE_LINE 30 -// coord, coord, coord startpos -// coord, coord, coord endpos -// short life in 0.1 s -// 3 bytes r, g, b - -#define TE_BOX 31 -// coord, coord, coord boxmins -// coord, coord, coord boxmaxs -// short life in 0.1 s -// 3 bytes r, g, b - -#define TE_KILLBEAM 99 // kill all beams attached to entity -// short (entity) - -#define TE_LARGEFUNNEL 100 -// coord coord coord (funnel position) -// short (sprite index) -// short (flags) - -#define TE_BLOODSTREAM 101 // particle spray -// coord coord coord (start position) -// coord coord coord (spray vector) -// byte (color) -// byte (speed) - -#define TE_SHOWLINE 102 // line of particles every 5 units, dies in 30 seconds -// coord coord coord (start position) -// coord coord coord (end position) - -#define TE_BLOOD 103 // particle spray -// coord coord coord (start position) -// coord coord coord (spray vector) -// byte (color) -// byte (speed) - -#define TE_DECAL 104 // Decal applied to a brush entity (not the world) -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// byte (texture index of precached decal texture name) -// short (entity index) - -#define TE_FIZZ 105 // create alpha sprites inside of entity, float upwards -// short (entity) -// short (sprite index) -// byte (density) - -#define TE_MODEL 106 // create a moving model that bounces and makes a sound when it hits -// coord, coord, coord (position) -// coord, coord, coord (velocity) -// angle (initial yaw) -// short (model index) -// byte (bounce sound type) -// byte (life in 0.1's) - -#define TE_EXPLODEMODEL 107 // spherical shower of models, picks from set -// coord, coord, coord (origin) -// coord (velocity) -// short (model index) -// short (count) -// byte (life in 0.1's) - -#define TE_BREAKMODEL 108 // box of models or sprites -// coord, coord, coord (position) -// coord, coord, coord (size) -// coord, coord, coord (velocity) -// byte (random velocity in 10's) -// short (sprite or model index) -// byte (count) -// byte (life in 0.1 secs) -// byte (flags) - -#define TE_GUNSHOTDECAL 109 // decal and ricochet sound -// coord, coord, coord (position) -// short (entity index???) -// byte (decal???) - -#define TE_SPRITE_SPRAY 110 // spay of alpha sprites -// coord, coord, coord (position) -// coord, coord, coord (velocity) -// short (sprite index) -// byte (count) -// byte (speed) -// byte (noise) - -#define TE_ARMOR_RICOCHET 111 // quick spark sprite, client ricochet sound. -// coord, coord, coord (position) -// byte (scale in 0.1's) - -#define TE_PLAYERDECAL 112 // ??? -// byte (playerindex) -// coord, coord, coord (position) -// short (entity???) -// byte (decal number???) -// [optional] short (model index???) - -#define TE_BUBBLES 113 // create alpha sprites inside of box, float upwards -// coord, coord, coord (min start position) -// coord, coord, coord (max start position) -// coord (float height) -// short (model index) -// byte (count) -// coord (speed) - -#define TE_BUBBLETRAIL 114 // create alpha sprites along a line, float upwards -// coord, coord, coord (min start position) -// coord, coord, coord (max start position) -// coord (float height) -// short (model index) -// byte (count) -// coord (speed) - -#define TE_BLOODSPRITE 115 // spray of opaque sprite1's that fall, single sprite2 for 1..2 secs (this is a high-priority tent) -// coord, coord, coord (position) -// short (sprite1 index) -// short (sprite2 index) -// byte (color) -// byte (scale) - -#define TE_WORLDDECAL 116 // Decal applied to the world brush -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// byte (texture index of precached decal texture name) - -#define TE_WORLDDECALHIGH 117 // Decal (with texture index > 256) applied to world brush -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// byte (texture index of precached decal texture name - 256) - -#define TE_DECALHIGH 118 // Same as TE_DECAL, but the texture index was greater than 256 -// coord, coord, coord (x,y,z), decal position (center of texture in world) -// byte (texture index of precached decal texture name - 256) -// short (entity index) - -#define TE_PROJECTILE 119 // Makes a projectile (like a nail) (this is a high-priority tent) -// coord, coord, coord (position) -// coord, coord, coord (velocity) -// short (modelindex) -// byte (life) -// byte (owner) projectile won't collide with owner (if owner == 0, projectile will hit any client). - -#define TE_SPRAY 120 // Throws a shower of sprites or models -// coord, coord, coord (position) -// coord, coord, coord (direction) -// short (modelindex) -// byte (count) -// byte (speed) -// byte (noise) -// byte (rendermode) - -#define TE_PLAYERSPRITES 121 // sprites emit from a player's bounding box (ONLY use for players!) -// byte (playernum) -// short (sprite modelindex) -// byte (count) -// byte (variance) (0 = no variance in size) (10 = 10% variance in size) - -#define TE_PARTICLEBURST 122 // very similar to lavasplash. -// coord (origin) -// short (radius) -// byte (particle color) -// byte (duration * 10) (will be randomized a bit) - -#define TE_FIREFIELD 123 // makes a field of fire. -// coord (origin) -// short (radius) (fire is made in a square around origin. -radius, -radius to radius, radius) -// short (modelindex) -// byte (count) -// byte (flags) -// byte (duration (in seconds) * 10) (will be randomized a bit) -// -// to keep network traffic low, this message has associated flags that fit into a byte: -#define TEFIRE_FLAG_ALLFLOAT 1 // all sprites will drift upwards as they animate -#define TEFIRE_FLAG_SOMEFLOAT 2 // some of the sprites will drift upwards. (50% chance) -#define TEFIRE_FLAG_LOOP 4 // if set, sprite plays at 15 fps, otherwise plays at whatever rate stretches the animation over the sprite's duration. -#define TEFIRE_FLAG_ALPHA 8 // if set, sprite is rendered alpha blended at 50% else, opaque -#define TEFIRE_FLAG_PLANAR 16 // if set, all fire sprites have same initial Z instead of randomly filling a cube. -#define TEFIRE_FLAG_ADDITIVE 32 // if set, sprite is rendered non-opaque with additive - -#define TE_PLAYERATTACHMENT 124 // attaches a TENT to a player (this is a high-priority tent) -// byte (entity index of player) -// coord (vertical offset) ( attachment origin.z = player origin.z + vertical offset ) -// short (model index) -// short (life * 10 ); - -#define TE_KILLPLAYERATTACHMENTS 125 // will expire all TENTS attached to a player. -// byte (entity index of player) - -#define TE_MULTIGUNSHOT 126 // much more compact shotgun message -// This message is used to make a client approximate a 'spray' of gunfire. -// Any weapon that fires more than one bullet per frame and fires in a bit of a spread is -// a good candidate for MULTIGUNSHOT use. (shotguns) -// -// NOTE: This effect makes the client do traces for each bullet, these client traces ignore -// entities that have studio models.Traces are 4096 long. -// -// coord (origin) -// coord (origin) -// coord (origin) -// coord (direction) -// coord (direction) -// coord (direction) -// coord (x noise * 100) -// coord (y noise * 100) -// byte (count) -// byte (bullethole decal texture index) - -#define TE_USERTRACER 127 // larger message than the standard tracer, but allows some customization. -// coord (origin) -// coord (origin) -// coord (origin) -// coord (velocity) -// coord (velocity) -// coord (velocity) -// byte ( life * 10 ) -// byte ( color ) this is an index into an array of color vectors in the engine. (0 - ) -// byte ( length * 10 ) - - - -#define MSG_BROADCAST 0 // unreliable to all -#define MSG_ONE 1 // reliable to one (msg_entity) -#define MSG_ALL 2 // reliable to all -#define MSG_INIT 3 // write to the init string -#define MSG_PVS 4 // Ents in PVS of org -#define MSG_PAS 5 // Ents in PAS of org -#define MSG_PVS_R 6 // Reliable to PVS -#define MSG_PAS_R 7 // Reliable to PAS -#define MSG_ONE_UNRELIABLE 8 // Send to one client, but don't put in reliable stream, put in unreliable datagram ( could be dropped ) -#define MSG_SPEC 9 // Sends to all spectator proxies - -// contents of a spot in the world -#define CONTENTS_EMPTY -1 -#define CONTENTS_SOLID -2 -#define CONTENTS_WATER -3 -#define CONTENTS_SLIME -4 -#define CONTENTS_LAVA -5 -#define CONTENTS_SKY -6 -/* These additional contents constants are defined in bspfile.h -#define CONTENTS_ORIGIN -7 // removed at csg time -#define CONTENTS_CLIP -8 // changed to contents_solid -#define CONTENTS_CURRENT_0 -9 -#define CONTENTS_CURRENT_90 -10 -#define CONTENTS_CURRENT_180 -11 -#define CONTENTS_CURRENT_270 -12 -#define CONTENTS_CURRENT_UP -13 -#define CONTENTS_CURRENT_DOWN -14 - -#define CONTENTS_TRANSLUCENT -15 -*/ -#define CONTENTS_LADDER -16 - -#define CONTENT_FLYFIELD -17 -#define CONTENT_GRAVITY_FLYFIELD -18 -#define CONTENT_FOG -19 - -#define CONTENT_EMPTY -1 -#define CONTENT_SOLID -2 -#define CONTENT_WATER -3 -#define CONTENT_SLIME -4 -#define CONTENT_LAVA -5 -#define CONTENT_SKY -6 - -// channels -#define CHAN_AUTO 0 -#define CHAN_WEAPON 1 -#define CHAN_VOICE 2 -#define CHAN_ITEM 3 -#define CHAN_BODY 4 -#define CHAN_STREAM 5 // allocate stream channel from the static or dynamic area -#define CHAN_STATIC 6 // allocate channel from the static area -#define CHAN_NETWORKVOICE_BASE 7 // voice data coming across the network -#define CHAN_NETWORKVOICE_END 500 // network voice data reserves slots (CHAN_NETWORKVOICE_BASE through CHAN_NETWORKVOICE_END). -#define CHAN_BOT 501 // channel used for bot chatter. - -// attenuation values -#define ATTN_NONE 0 -#define ATTN_NORM (float)0.8 -#define ATTN_IDLE (float)2 -#define ATTN_STATIC (float)1.25 - -// pitch values -#define PITCH_NORM 100 // non-pitch shifted -#define PITCH_LOW 95 // other values are possible - 0-255, where 255 is very high -#define PITCH_HIGH 120 - -// volume values -#define VOL_NORM 1.0 - -// plats -#define PLAT_LOW_TRIGGER 1 - -// Trains -#define SF_TRAIN_WAIT_RETRIGGER 1 -#define SF_TRAIN_START_ON 4 // Train is initially moving -#define SF_TRAIN_PASSABLE 8 // Train is not solid -- used to make water trains - -// buttons -#ifndef IN_BUTTONS_H -#include "in_buttons.h" -#endif - -// Break Model Defines - -#define BREAK_TYPEMASK 0x4F -#define BREAK_GLASS 0x01 -#define BREAK_METAL 0x02 -#define BREAK_FLESH 0x04 -#define BREAK_WOOD 0x08 - -#define BREAK_SMOKE 0x10 -#define BREAK_TRANS 0x20 -#define BREAK_CONCRETE 0x40 -#define BREAK_2 0x80 - -// Colliding temp entity sounds - -#define BOUNCE_GLASS BREAK_GLASS -#define BOUNCE_METAL BREAK_METAL -#define BOUNCE_FLESH BREAK_FLESH -#define BOUNCE_WOOD BREAK_WOOD -#define BOUNCE_SHRAP 0x10 -#define BOUNCE_SHELL 0x20 -#define BOUNCE_CONCRETE BREAK_CONCRETE -#define BOUNCE_SHOTSHELL 0x80 - -// Temp entity bounce sound types -#define TE_BOUNCE_NULL 0 -#define TE_BOUNCE_SHELL 1 -#define TE_BOUNCE_SHOTSHELL 2 - -// Rendering constants -enum -{ - kRenderNormal, // src - kRenderTransColor, // c*a+dest*(1-a) - kRenderTransTexture, // src*a+dest*(1-a) - kRenderGlow, // src*a+dest -- No Z buffer checks - kRenderTransAlpha, // src*srca+dest*(1-srca) - kRenderTransAdd, // src*a+dest -}; - -enum -{ - kRenderFxNone = 0, - kRenderFxPulseSlow, - kRenderFxPulseFast, - kRenderFxPulseSlowWide, - kRenderFxPulseFastWide, - kRenderFxFadeSlow, - kRenderFxFadeFast, - kRenderFxSolidSlow, - kRenderFxSolidFast, - kRenderFxStrobeSlow, - kRenderFxStrobeFast, - kRenderFxStrobeFaster, - kRenderFxFlickerSlow, - kRenderFxFlickerFast, - kRenderFxNoDissipation, - kRenderFxDistort, // Distort/scale/translate flicker - kRenderFxHologram, // kRenderFxDistort + distance fade - kRenderFxDeadPlayer, // kRenderAmt is the player index - kRenderFxExplode, // Scale up really big! - kRenderFxGlowShell, // Glowing Shell - kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!) - kRenderFxLightMultiplier, //CTM !!!CZERO added to tell the studiorender that the value in iuser2 is a lightmultiplier -}; - - -typedef unsigned int func_t; -typedef unsigned int string_t; - -typedef unsigned char byte; -typedef unsigned short word; -#define _DEF_BYTE_ - -#undef true -#undef false - -#ifndef __cplusplus -typedef enum {false, true} qboolean; -#else -typedef int qboolean; -#endif - -typedef struct -{ - byte r, g, b; -} color24; - -typedef struct -{ - unsigned r, g, b, a; -} colorVec; - -#ifdef _WIN32 -#pragma pack(push,2) -#endif - -typedef struct -{ - unsigned short r, g, b, a; -} PackedColorVec; - -#ifdef _WIN32 -#pragma pack(pop) -#endif -typedef struct link_s -{ - struct link_s *prev, *next; -} link_t; - -typedef struct edict_s edict_t; - -typedef struct -{ - vec3_t normal; - float dist; -} plane_t; - -typedef struct -{ - qboolean allsolid; // if true, plane is not valid - qboolean startsolid; // if true, the initial point was in a solid area - qboolean inopen, inwater; - float fraction; // time completed, 1.0 = didn't hit anything - vec3_t endpos; // final position - plane_t plane; // surface normal at impact - edict_t * ent; // entity the surface is on - int hitgroup; // 0 == generic, non zero is specific body part -} trace_t; - -#endif // CONST_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +#ifndef CONST_H +#define CONST_H +#ifdef _WIN32 +#pragma once +#endif + +// Max # of clients allowed in a server. +#define MAX_CLIENTS 32 + +// How many bits to use to encode an edict. +#define MAX_EDICT_BITS 11 // # of bits needed to represent max edicts +// Max # of edicts in a level (2048) +#define MAX_EDICTS (1<flags +#define FL_FLY (1<<0) // Changes the SV_Movestep() behavior to not need to be on ground +#define FL_SWIM (1<<1) // Changes the SV_Movestep() behavior to not need to be on ground (but stay in water) +#define FL_CONVEYOR (1<<2) +#define FL_CLIENT (1<<3) +#define FL_INWATER (1<<4) +#define FL_MONSTER (1<<5) +#define FL_GODMODE (1<<6) +#define FL_NOTARGET (1<<7) +#define FL_SKIPLOCALHOST (1<<8) // Don't send entity to local host, it's predicting this entity itself +#define FL_ONGROUND (1<<9) // At rest / on the ground +#define FL_PARTIALGROUND (1<<10) // not all corners are valid +#define FL_WATERJUMP (1<<11) // player jumping out of water +#define FL_FROZEN (1<<12) // Player is frozen for 3rd person camera +#define FL_FAKECLIENT (1<<13) // JAC: fake client, simulated server side; don't send network messages to them +#define FL_DUCKING (1<<14) // Player flag -- Player is fully crouched +#define FL_FLOAT (1<<15) // Apply floating force to this entity when in water +#define FL_GRAPHED (1<<16) // worldgraph has this ent listed as something that blocks a connection + +// UNDONE: Do we need these? +#define FL_IMMUNE_WATER (1<<17) +#define FL_IMMUNE_SLIME (1<<18) +#define FL_IMMUNE_LAVA (1<<19) + +#define FL_PROXY (1<<20) // This is a spectator proxy +#define FL_ALWAYSTHINK (1<<21) // Brush model flag -- call think every frame regardless of nextthink - ltime (for constantly changing velocity/path) +#define FL_BASEVELOCITY (1<<22) // Base velocity has been applied this frame (used to convert base velocity into momentum) +#define FL_MONSTERCLIP (1<<23) // Only collide in with monsters who have FL_MONSTERCLIP set +#define FL_ONTRAIN (1<<24) // Player is _controlling_ a train, so movement commands should be ignored on client during prediction. +#define FL_WORLDBRUSH (1<<25) // Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something) +#define FL_SPECTATOR (1<<26) // This client is a spectator, don't run touch functions, etc. +#define FL_CUSTOMENTITY (1<<29) // This is a custom entity +#define FL_KILLME (1<<30) // This entity is marked for death -- This allows the engine to kill ents at the appropriate time +#define FL_DORMANT (1<<31) // Entity is dormant, no updates to client + +// SV_EmitSound2 flags +#define SND_EMIT2_NOPAS (1<<0) // never to do check PAS +#define SND_EMIT2_INVOKER (1<<1) // do not send to the client invoker + +// Engine edict->spawnflags +#define SF_NOTINDEATHMATCH 0x0800 // Do not spawn when deathmatch and loading entities from a file + + +// Goes into globalvars_t.trace_flags +#define FTRACE_SIMPLEBOX (1<<0) // Traceline with a simple box + + +// walkmove modes +#define WALKMOVE_NORMAL 0 // normal walkmove +#define WALKMOVE_WORLDONLY 1 // doesn't hit ANY entities, no matter what the solid type +#define WALKMOVE_CHECKONLY 2 // move, but don't touch triggers + +// edict->movetype values +#define MOVETYPE_NONE 0 // never moves +//#define MOVETYPE_ANGLENOCLIP 1 +//#define MOVETYPE_ANGLECLIP 2 +#define MOVETYPE_WALK 3 // Player only - moving on the ground +#define MOVETYPE_STEP 4 // gravity, special edge handling -- monsters use this +#define MOVETYPE_FLY 5 // No gravity, but still collides with stuff +#define MOVETYPE_TOSS 6 // gravity/collisions +#define MOVETYPE_PUSH 7 // no clip to world, push and crush +#define MOVETYPE_NOCLIP 8 // No gravity, no collisions, still do velocity/avelocity +#define MOVETYPE_FLYMISSILE 9 // extra size to monsters +#define MOVETYPE_BOUNCE 10 // Just like Toss, but reflect velocity when contacting surfaces +#define MOVETYPE_BOUNCEMISSILE 11 // bounce w/o gravity +#define MOVETYPE_FOLLOW 12 // track movement of aiment +#define MOVETYPE_PUSHSTEP 13 // BSP model that needs physics/world collisions (uses nearest hull for world collision) + +// edict->solid values +// NOTE: Some movetypes will cause collisions independent of SOLID_NOT/SOLID_TRIGGER when the entity moves +// SOLID only effects OTHER entities colliding with this one when they move - UGH! +#define SOLID_NOT 0 // no interaction with other objects +#define SOLID_TRIGGER 1 // touch on edge, but not blocking +#define SOLID_BBOX 2 // touch on edge, block +#define SOLID_SLIDEBOX 3 // touch on edge, but not an onground +#define SOLID_BSP 4 // bsp clip, touch on edge, block + +// edict->deadflag values +#define DEAD_NO 0 // alive +#define DEAD_DYING 1 // playing death animation or still falling off of a ledge waiting to hit ground +#define DEAD_DEAD 2 // dead. lying still. +#define DEAD_RESPAWNABLE 3 +#define DEAD_DISCARDBODY 4 + +#define DAMAGE_NO 0 +#define DAMAGE_YES 1 +#define DAMAGE_AIM 2 + +// entity effects +#define EF_BRIGHTFIELD 1 // swirling cloud of particles +#define EF_MUZZLEFLASH 2 // single frame ELIGHT on entity attachment 0 +#define EF_BRIGHTLIGHT 4 // DLIGHT centered at entity origin +#define EF_DIMLIGHT 8 // player flashlight +#define EF_INVLIGHT 16 // get lighting from ceiling +#define EF_NOINTERP 32 // don't interpolate the next frame +#define EF_LIGHT 64 // rocket flare glow sprite +#define EF_NODRAW 128 // don't draw entity +#define EF_NIGHTVISION 256 // player nightvision +#define EF_SNIPERLASER 512 // sniper laser effect +#define EF_FIBERCAMERA 1024// fiber camera + + +// entity flags +#define EFLAG_SLERP 1 // do studio interpolation of this entity + +// +// temp entity events +// +#define TE_BEAMPOINTS 0 // beam effect between two points +// coord coord coord (start position) +// coord coord coord (end position) +// short (sprite index) +// byte (starting frame) +// byte (frame rate in 0.1's) +// byte (life in 0.1's) +// byte (line width in 0.1's) +// byte (noise amplitude in 0.01's) +// byte,byte,byte (color) +// byte (brightness) +// byte (scroll speed in 0.1's) + +#define TE_BEAMENTPOINT 1 // beam effect between point and entity +// short (start entity) +// coord coord coord (end position) +// short (sprite index) +// byte (starting frame) +// byte (frame rate in 0.1's) +// byte (life in 0.1's) +// byte (line width in 0.1's) +// byte (noise amplitude in 0.01's) +// byte,byte,byte (color) +// byte (brightness) +// byte (scroll speed in 0.1's) + +#define TE_GUNSHOT 2 // particle effect plus ricochet sound +// coord coord coord (position) + +#define TE_EXPLOSION 3 // additive sprite, 2 dynamic lights, flickering particles, explosion sound, move vertically 8 pps +// coord coord coord (position) +// short (sprite index) +// byte (scale in 0.1's) +// byte (framerate) +// byte (flags) +// +// The Explosion effect has some flags to control performance/aesthetic features: +#define TE_EXPLFLAG_NONE 0 // all flags clear makes default Half-Life explosion +#define TE_EXPLFLAG_NOADDITIVE 1 // sprite will be drawn opaque (ensure that the sprite you send is a non-additive sprite) +#define TE_EXPLFLAG_NODLIGHTS 2 // do not render dynamic lights +#define TE_EXPLFLAG_NOSOUND 4 // do not play client explosion sound +#define TE_EXPLFLAG_NOPARTICLES 8 // do not draw particles + + +#define TE_TAREXPLOSION 4 // Quake1 "tarbaby" explosion with sound +// coord coord coord (position) + +#define TE_SMOKE 5 // alphablend sprite, move vertically 30 pps +// coord coord coord (position) +// short (sprite index) +// byte (scale in 0.1's) +// byte (framerate) + +#define TE_TRACER 6 // tracer effect from point to point +// coord, coord, coord (start) +// coord, coord, coord (end) + +#define TE_LIGHTNING 7 // TE_BEAMPOINTS with simplified parameters +// coord, coord, coord (start) +// coord, coord, coord (end) +// byte (life in 0.1's) +// byte (width in 0.1's) +// byte (amplitude in 0.01's) +// short (sprite model index) + +#define TE_BEAMENTS 8 +// short (start entity) +// short (end entity) +// short (sprite index) +// byte (starting frame) +// byte (frame rate in 0.1's) +// byte (life in 0.1's) +// byte (line width in 0.1's) +// byte (noise amplitude in 0.01's) +// byte,byte,byte (color) +// byte (brightness) +// byte (scroll speed in 0.1's) + +#define TE_SPARKS 9 // 8 random tracers with gravity, ricochet sprite +// coord coord coord (position) + +#define TE_LAVASPLASH 10 // Quake1 lava splash +// coord coord coord (position) + +#define TE_TELEPORT 11 // Quake1 teleport splash +// coord coord coord (position) + +#define TE_EXPLOSION2 12 // Quake1 colormaped (base palette) particle explosion with sound +// coord coord coord (position) +// byte (starting color) +// byte (num colors) + +#define TE_BSPDECAL 13 // Decal from the .BSP file +// coord, coord, coord (x,y,z), decal position (center of texture in world) +// short (texture index of precached decal texture name) +// short (entity index) +// [optional - only included if previous short is non-zero (not the world)] short (index of model of above entity) + +#define TE_IMPLOSION 14 // tracers moving toward a point +// coord, coord, coord (position) +// byte (radius) +// byte (count) +// byte (life in 0.1's) + +#define TE_SPRITETRAIL 15 // line of moving glow sprites with gravity, fadeout, and collisions +// coord, coord, coord (start) +// coord, coord, coord (end) +// short (sprite index) +// byte (count) +// byte (life in 0.1's) +// byte (scale in 0.1's) +// byte (velocity along vector in 10's) +// byte (randomness of velocity in 10's) + +#define TE_BEAM 16 // obsolete + +#define TE_SPRITE 17 // additive sprite, plays 1 cycle +// coord, coord, coord (position) +// short (sprite index) +// byte (scale in 0.1's) +// byte (brightness) + +#define TE_BEAMSPRITE 18 // A beam with a sprite at the end +// coord, coord, coord (start position) +// coord, coord, coord (end position) +// short (beam sprite index) +// short (end sprite index) + +#define TE_BEAMTORUS 19 // screen aligned beam ring, expands to max radius over lifetime +// coord coord coord (center position) +// coord coord coord (axis and radius) +// short (sprite index) +// byte (starting frame) +// byte (frame rate in 0.1's) +// byte (life in 0.1's) +// byte (line width in 0.1's) +// byte (noise amplitude in 0.01's) +// byte,byte,byte (color) +// byte (brightness) +// byte (scroll speed in 0.1's) + +#define TE_BEAMDISK 20 // disk that expands to max radius over lifetime +// coord coord coord (center position) +// coord coord coord (axis and radius) +// short (sprite index) +// byte (starting frame) +// byte (frame rate in 0.1's) +// byte (life in 0.1's) +// byte (line width in 0.1's) +// byte (noise amplitude in 0.01's) +// byte,byte,byte (color) +// byte (brightness) +// byte (scroll speed in 0.1's) + +#define TE_BEAMCYLINDER 21 // cylinder that expands to max radius over lifetime +// coord coord coord (center position) +// coord coord coord (axis and radius) +// short (sprite index) +// byte (starting frame) +// byte (frame rate in 0.1's) +// byte (life in 0.1's) +// byte (line width in 0.1's) +// byte (noise amplitude in 0.01's) +// byte,byte,byte (color) +// byte (brightness) +// byte (scroll speed in 0.1's) + +#define TE_BEAMFOLLOW 22 // create a line of decaying beam segments until entity stops moving +// short (entity:attachment to follow) +// short (sprite index) +// byte (life in 0.1's) +// byte (line width in 0.1's) +// byte,byte,byte (color) +// byte (brightness) + +#define TE_GLOWSPRITE 23 +// coord, coord, coord (pos) short (model index) byte (scale / 10) + +#define TE_BEAMRING 24 // connect a beam ring to two entities +// short (start entity) +// short (end entity) +// short (sprite index) +// byte (starting frame) +// byte (frame rate in 0.1's) +// byte (life in 0.1's) +// byte (line width in 0.1's) +// byte (noise amplitude in 0.01's) +// byte,byte,byte (color) +// byte (brightness) +// byte (scroll speed in 0.1's) + +#define TE_STREAK_SPLASH 25 // oriented shower of tracers +// coord coord coord (start position) +// coord coord coord (direction vector) +// byte (color) +// short (count) +// short (base speed) +// short (ramdon velocity) + +#define TE_BEAMHOSE 26 // obsolete + +#define TE_DLIGHT 27 // dynamic light, effect world, minor entity effect +// coord, coord, coord (pos) +// byte (radius in 10's) +// byte byte byte (color) +// byte (brightness) +// byte (life in 10's) +// byte (decay rate in 10's) + +#define TE_ELIGHT 28 // point entity light, no world effect +// short (entity:attachment to follow) +// coord coord coord (initial position) +// coord (radius) +// byte byte byte (color) +// byte (life in 0.1's) +// coord (decay rate) + +#define TE_TEXTMESSAGE 29 +// short 1.2.13 x (-1 = center) +// short 1.2.13 y (-1 = center) +// byte Effect 0 = fade in/fade out + // 1 is flickery credits + // 2 is write out (training room) + +// 4 bytes r,g,b,a color1 (text color) +// 4 bytes r,g,b,a color2 (effect color) +// ushort 8.8 fadein time +// ushort 8.8 fadeout time +// ushort 8.8 hold time +// optional ushort 8.8 fxtime (time the highlight lags behing the leading text in effect 2) +// string text message (512 chars max sz string) +#define TE_LINE 30 +// coord, coord, coord startpos +// coord, coord, coord endpos +// short life in 0.1 s +// 3 bytes r, g, b + +#define TE_BOX 31 +// coord, coord, coord boxmins +// coord, coord, coord boxmaxs +// short life in 0.1 s +// 3 bytes r, g, b + +#define TE_KILLBEAM 99 // kill all beams attached to entity +// short (entity) + +#define TE_LARGEFUNNEL 100 +// coord coord coord (funnel position) +// short (sprite index) +// short (flags) + +#define TE_BLOODSTREAM 101 // particle spray +// coord coord coord (start position) +// coord coord coord (spray vector) +// byte (color) +// byte (speed) + +#define TE_SHOWLINE 102 // line of particles every 5 units, dies in 30 seconds +// coord coord coord (start position) +// coord coord coord (end position) + +#define TE_BLOOD 103 // particle spray +// coord coord coord (start position) +// coord coord coord (spray vector) +// byte (color) +// byte (speed) + +#define TE_DECAL 104 // Decal applied to a brush entity (not the world) +// coord, coord, coord (x,y,z), decal position (center of texture in world) +// byte (texture index of precached decal texture name) +// short (entity index) + +#define TE_FIZZ 105 // create alpha sprites inside of entity, float upwards +// short (entity) +// short (sprite index) +// byte (density) + +#define TE_MODEL 106 // create a moving model that bounces and makes a sound when it hits +// coord, coord, coord (position) +// coord, coord, coord (velocity) +// angle (initial yaw) +// short (model index) +// byte (bounce sound type) +// byte (life in 0.1's) + +#define TE_EXPLODEMODEL 107 // spherical shower of models, picks from set +// coord, coord, coord (origin) +// coord (velocity) +// short (model index) +// short (count) +// byte (life in 0.1's) + +#define TE_BREAKMODEL 108 // box of models or sprites +// coord, coord, coord (position) +// coord, coord, coord (size) +// coord, coord, coord (velocity) +// byte (random velocity in 10's) +// short (sprite or model index) +// byte (count) +// byte (life in 0.1 secs) +// byte (flags) + +#define TE_GUNSHOTDECAL 109 // decal and ricochet sound +// coord, coord, coord (position) +// short (entity index???) +// byte (decal???) + +#define TE_SPRITE_SPRAY 110 // spay of alpha sprites +// coord, coord, coord (position) +// coord, coord, coord (velocity) +// short (sprite index) +// byte (count) +// byte (speed) +// byte (noise) + +#define TE_ARMOR_RICOCHET 111 // quick spark sprite, client ricochet sound. +// coord, coord, coord (position) +// byte (scale in 0.1's) + +#define TE_PLAYERDECAL 112 // ??? +// byte (playerindex) +// coord, coord, coord (position) +// short (entity???) +// byte (decal number???) +// [optional] short (model index???) + +#define TE_BUBBLES 113 // create alpha sprites inside of box, float upwards +// coord, coord, coord (min start position) +// coord, coord, coord (max start position) +// coord (float height) +// short (model index) +// byte (count) +// coord (speed) + +#define TE_BUBBLETRAIL 114 // create alpha sprites along a line, float upwards +// coord, coord, coord (min start position) +// coord, coord, coord (max start position) +// coord (float height) +// short (model index) +// byte (count) +// coord (speed) + +#define TE_BLOODSPRITE 115 // spray of opaque sprite1's that fall, single sprite2 for 1..2 secs (this is a high-priority tent) +// coord, coord, coord (position) +// short (sprite1 index) +// short (sprite2 index) +// byte (color) +// byte (scale) + +#define TE_WORLDDECAL 116 // Decal applied to the world brush +// coord, coord, coord (x,y,z), decal position (center of texture in world) +// byte (texture index of precached decal texture name) + +#define TE_WORLDDECALHIGH 117 // Decal (with texture index > 256) applied to world brush +// coord, coord, coord (x,y,z), decal position (center of texture in world) +// byte (texture index of precached decal texture name - 256) + +#define TE_DECALHIGH 118 // Same as TE_DECAL, but the texture index was greater than 256 +// coord, coord, coord (x,y,z), decal position (center of texture in world) +// byte (texture index of precached decal texture name - 256) +// short (entity index) + +#define TE_PROJECTILE 119 // Makes a projectile (like a nail) (this is a high-priority tent) +// coord, coord, coord (position) +// coord, coord, coord (velocity) +// short (modelindex) +// byte (life) +// byte (owner) projectile won't collide with owner (if owner == 0, projectile will hit any client). + +#define TE_SPRAY 120 // Throws a shower of sprites or models +// coord, coord, coord (position) +// coord, coord, coord (direction) +// short (modelindex) +// byte (count) +// byte (speed) +// byte (noise) +// byte (rendermode) + +#define TE_PLAYERSPRITES 121 // sprites emit from a player's bounding box (ONLY use for players!) +// byte (playernum) +// short (sprite modelindex) +// byte (count) +// byte (variance) (0 = no variance in size) (10 = 10% variance in size) + +#define TE_PARTICLEBURST 122 // very similar to lavasplash. +// coord (origin) +// short (radius) +// byte (particle color) +// byte (duration * 10) (will be randomized a bit) + +#define TE_FIREFIELD 123 // makes a field of fire. +// coord (origin) +// short (radius) (fire is made in a square around origin. -radius, -radius to radius, radius) +// short (modelindex) +// byte (count) +// byte (flags) +// byte (duration (in seconds) * 10) (will be randomized a bit) +// +// to keep network traffic low, this message has associated flags that fit into a byte: +#define TEFIRE_FLAG_ALLFLOAT 1 // all sprites will drift upwards as they animate +#define TEFIRE_FLAG_SOMEFLOAT 2 // some of the sprites will drift upwards. (50% chance) +#define TEFIRE_FLAG_LOOP 4 // if set, sprite plays at 15 fps, otherwise plays at whatever rate stretches the animation over the sprite's duration. +#define TEFIRE_FLAG_ALPHA 8 // if set, sprite is rendered alpha blended at 50% else, opaque +#define TEFIRE_FLAG_PLANAR 16 // if set, all fire sprites have same initial Z instead of randomly filling a cube. +#define TEFIRE_FLAG_ADDITIVE 32 // if set, sprite is rendered non-opaque with additive + +#define TE_PLAYERATTACHMENT 124 // attaches a TENT to a player (this is a high-priority tent) +// byte (entity index of player) +// coord (vertical offset) ( attachment origin.z = player origin.z + vertical offset ) +// short (model index) +// short (life * 10 ); + +#define TE_KILLPLAYERATTACHMENTS 125 // will expire all TENTS attached to a player. +// byte (entity index of player) + +#define TE_MULTIGUNSHOT 126 // much more compact shotgun message +// This message is used to make a client approximate a 'spray' of gunfire. +// Any weapon that fires more than one bullet per frame and fires in a bit of a spread is +// a good candidate for MULTIGUNSHOT use. (shotguns) +// +// NOTE: This effect makes the client do traces for each bullet, these client traces ignore +// entities that have studio models.Traces are 4096 long. +// +// coord (origin) +// coord (origin) +// coord (origin) +// coord (direction) +// coord (direction) +// coord (direction) +// coord (x noise * 100) +// coord (y noise * 100) +// byte (count) +// byte (bullethole decal texture index) + +#define TE_USERTRACER 127 // larger message than the standard tracer, but allows some customization. +// coord (origin) +// coord (origin) +// coord (origin) +// coord (velocity) +// coord (velocity) +// coord (velocity) +// byte ( life * 10 ) +// byte ( color ) this is an index into an array of color vectors in the engine. (0 - ) +// byte ( length * 10 ) + + + +#define MSG_BROADCAST 0 // unreliable to all +#define MSG_ONE 1 // reliable to one (msg_entity) +#define MSG_ALL 2 // reliable to all +#define MSG_INIT 3 // write to the init string +#define MSG_PVS 4 // Ents in PVS of org +#define MSG_PAS 5 // Ents in PAS of org +#define MSG_PVS_R 6 // Reliable to PVS +#define MSG_PAS_R 7 // Reliable to PAS +#define MSG_ONE_UNRELIABLE 8 // Send to one client, but don't put in reliable stream, put in unreliable datagram ( could be dropped ) +#define MSG_SPEC 9 // Sends to all spectator proxies + +// contents of a spot in the world +#define CONTENTS_EMPTY -1 +#define CONTENTS_SOLID -2 +#define CONTENTS_WATER -3 +#define CONTENTS_SLIME -4 +#define CONTENTS_LAVA -5 +#define CONTENTS_SKY -6 +/* These additional contents constants are defined in bspfile.h +#define CONTENTS_ORIGIN -7 // removed at csg time +#define CONTENTS_CLIP -8 // changed to contents_solid +#define CONTENTS_CURRENT_0 -9 +#define CONTENTS_CURRENT_90 -10 +#define CONTENTS_CURRENT_180 -11 +#define CONTENTS_CURRENT_270 -12 +#define CONTENTS_CURRENT_UP -13 +#define CONTENTS_CURRENT_DOWN -14 + +#define CONTENTS_TRANSLUCENT -15 +*/ +#define CONTENTS_LADDER -16 + +#define CONTENT_FLYFIELD -17 +#define CONTENT_GRAVITY_FLYFIELD -18 +#define CONTENT_FOG -19 + +#define CONTENT_EMPTY -1 +#define CONTENT_SOLID -2 +#define CONTENT_WATER -3 +#define CONTENT_SLIME -4 +#define CONTENT_LAVA -5 +#define CONTENT_SKY -6 + +// channels +#define CHAN_AUTO 0 +#define CHAN_WEAPON 1 +#define CHAN_VOICE 2 +#define CHAN_ITEM 3 +#define CHAN_BODY 4 +#define CHAN_STREAM 5 // allocate stream channel from the static or dynamic area +#define CHAN_STATIC 6 // allocate channel from the static area +#define CHAN_NETWORKVOICE_BASE 7 // voice data coming across the network +#define CHAN_NETWORKVOICE_END 500 // network voice data reserves slots (CHAN_NETWORKVOICE_BASE through CHAN_NETWORKVOICE_END). +#define CHAN_BOT 501 // channel used for bot chatter. + +// attenuation values +#define ATTN_NONE 0 +#define ATTN_NORM (float)0.8 +#define ATTN_IDLE (float)2 +#define ATTN_STATIC (float)1.25 + +// pitch values +#define PITCH_NORM 100 // non-pitch shifted +#define PITCH_LOW 95 // other values are possible - 0-255, where 255 is very high +#define PITCH_HIGH 120 + +// volume values +#define VOL_NORM 1.0 + +// plats +#define PLAT_LOW_TRIGGER 1 + +// Trains +#define SF_TRAIN_WAIT_RETRIGGER 1 +#define SF_TRAIN_START_ON 4 // Train is initially moving +#define SF_TRAIN_PASSABLE 8 // Train is not solid -- used to make water trains + +// buttons +#ifndef IN_BUTTONS_H +#include "in_buttons.h" +#endif + +// Break Model Defines + +#define BREAK_TYPEMASK 0x4F +#define BREAK_GLASS 0x01 +#define BREAK_METAL 0x02 +#define BREAK_FLESH 0x04 +#define BREAK_WOOD 0x08 + +#define BREAK_SMOKE 0x10 +#define BREAK_TRANS 0x20 +#define BREAK_CONCRETE 0x40 +#define BREAK_2 0x80 + +// Colliding temp entity sounds + +#define BOUNCE_GLASS BREAK_GLASS +#define BOUNCE_METAL BREAK_METAL +#define BOUNCE_FLESH BREAK_FLESH +#define BOUNCE_WOOD BREAK_WOOD +#define BOUNCE_SHRAP 0x10 +#define BOUNCE_SHELL 0x20 +#define BOUNCE_CONCRETE BREAK_CONCRETE +#define BOUNCE_SHOTSHELL 0x80 + +// Temp entity bounce sound types +#define TE_BOUNCE_NULL 0 +#define TE_BOUNCE_SHELL 1 +#define TE_BOUNCE_SHOTSHELL 2 + +// Rendering constants +enum +{ + kRenderNormal, // src + kRenderTransColor, // c*a+dest*(1-a) + kRenderTransTexture, // src*a+dest*(1-a) + kRenderGlow, // src*a+dest -- No Z buffer checks + kRenderTransAlpha, // src*srca+dest*(1-srca) + kRenderTransAdd, // src*a+dest +}; + +enum +{ + kRenderFxNone = 0, + kRenderFxPulseSlow, + kRenderFxPulseFast, + kRenderFxPulseSlowWide, + kRenderFxPulseFastWide, + kRenderFxFadeSlow, + kRenderFxFadeFast, + kRenderFxSolidSlow, + kRenderFxSolidFast, + kRenderFxStrobeSlow, + kRenderFxStrobeFast, + kRenderFxStrobeFaster, + kRenderFxFlickerSlow, + kRenderFxFlickerFast, + kRenderFxNoDissipation, + kRenderFxDistort, // Distort/scale/translate flicker + kRenderFxHologram, // kRenderFxDistort + distance fade + kRenderFxDeadPlayer, // kRenderAmt is the player index + kRenderFxExplode, // Scale up really big! + kRenderFxGlowShell, // Glowing Shell + kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!) + kRenderFxLightMultiplier, //CTM !!!CZERO added to tell the studiorender that the value in iuser2 is a lightmultiplier +}; + + +typedef unsigned int func_t; +typedef unsigned int string_t; + +typedef unsigned char byte; +typedef unsigned short word; +#define _DEF_BYTE_ + +#undef true +#undef false + +#ifndef __cplusplus +typedef enum {false, true} qboolean; +#else +typedef int qboolean; +#endif + +typedef struct +{ + byte r, g, b; +} color24; + +typedef struct +{ + unsigned r, g, b, a; +} colorVec; + +#ifdef _WIN32 +#pragma pack(push,2) +#endif + +typedef struct +{ + unsigned short r, g, b, a; +} PackedColorVec; + +#ifdef _WIN32 +#pragma pack(pop) +#endif +typedef struct link_s +{ + struct link_s *prev, *next; +} link_t; + +typedef struct edict_s edict_t; + +typedef struct +{ + vec3_t normal; + float dist; +} plane_t; + +typedef struct +{ + qboolean allsolid; // if true, plane is not valid + qboolean startsolid; // if true, the initial point was in a solid area + qboolean inopen, inwater; + float fraction; // time completed, 1.0 = didn't hit anything + vec3_t endpos; // final position + plane_t plane; // surface normal at impact + edict_t * ent; // entity the surface is on + int hitgroup; // 0 == generic, non zero is specific body part +} trace_t; + +#endif // CONST_H diff --git a/dep/rehlsdk/common/crc.h b/dep/rehlsdk/common/crc.h index 4e0cfb6..f7c6bb2 100644 --- a/dep/rehlsdk/common/crc.h +++ b/dep/rehlsdk/common/crc.h @@ -1,38 +1,38 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -/* crc.h */ -#pragma once - -#include "quakedef.h" - -typedef unsigned int CRC32_t; - -#ifdef __cplusplus -extern "C" -{ -#endif - -void CRC32_Init(CRC32_t *pulCRC); -CRC32_t CRC32_Final(CRC32_t pulCRC); -void CRC32_ProcessByte(CRC32_t *pulCRC, unsigned char ch); -void CRC32_ProcessBuffer(CRC32_t *pulCRC, void *pBuffer, int nBuffer); -BOOL CRC_File(CRC32_t *crcvalue, char *pszFileName); - -#ifdef __cplusplus -} -#endif - -byte COM_BlockSequenceCRCByte(byte *base, int length, int sequence); -int CRC_MapFile(CRC32_t *crcvalue, char *pszFileName); +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +/* crc.h */ +#pragma once + +#include "quakedef.h" + +typedef unsigned int CRC32_t; + +#ifdef __cplusplus +extern "C" +{ +#endif + +void CRC32_Init(CRC32_t *pulCRC); +CRC32_t CRC32_Final(CRC32_t pulCRC); +void CRC32_ProcessByte(CRC32_t *pulCRC, unsigned char ch); +void CRC32_ProcessBuffer(CRC32_t *pulCRC, void *pBuffer, int nBuffer); +BOOL CRC_File(CRC32_t *crcvalue, char *pszFileName); + +#ifdef __cplusplus +} +#endif + +byte COM_BlockSequenceCRCByte(byte *base, int length, int sequence); +int CRC_MapFile(CRC32_t *crcvalue, char *pszFileName); diff --git a/dep/rehlsdk/common/cvardef.h b/dep/rehlsdk/common/cvardef.h index aea0f9e..7bba22b 100644 --- a/dep/rehlsdk/common/cvardef.h +++ b/dep/rehlsdk/common/cvardef.h @@ -1,50 +1,50 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#ifndef CVARDEF_H -#define CVARDEF_H - -#define FCVAR_ARCHIVE (1<<0) // set to cause it to be saved to vars.rc -#define FCVAR_USERINFO (1<<1) // changes the client's info string -#define FCVAR_SERVER (1<<2) // notifies players when changed -#define FCVAR_EXTDLL (1<<3) // defined by external DLL -#define FCVAR_CLIENTDLL (1<<4) // defined by the client dll -#define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value -#define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server. -#define FCVAR_PRINTABLEONLY (1<<7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). -#define FCVAR_UNLOGGED (1<<8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log -#define FCVAR_NOEXTRAWHITEPACE (1<<9) // strip trailing/leading white space from this cvar - -typedef struct cvar_s -{ - const char *name; - char *string; - int flags; - float value; - struct cvar_s *next; -} cvar_t; - -using cvar_callback_t = void (*)(const char *pszNewValue); - -struct cvar_listener_t -{ - cvar_listener_t(const char *var_name, cvar_callback_t handler) : - func(handler), name(var_name) {} - - cvar_callback_t func; - const char *name; -}; - -#endif // CVARDEF_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +#ifndef CVARDEF_H +#define CVARDEF_H + +#define FCVAR_ARCHIVE (1<<0) // set to cause it to be saved to vars.rc +#define FCVAR_USERINFO (1<<1) // changes the client's info string +#define FCVAR_SERVER (1<<2) // notifies players when changed +#define FCVAR_EXTDLL (1<<3) // defined by external DLL +#define FCVAR_CLIENTDLL (1<<4) // defined by the client dll +#define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value +#define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server. +#define FCVAR_PRINTABLEONLY (1<<7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). +#define FCVAR_UNLOGGED (1<<8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log +#define FCVAR_NOEXTRAWHITEPACE (1<<9) // strip trailing/leading white space from this cvar + +typedef struct cvar_s +{ + const char *name; + char *string; + int flags; + float value; + struct cvar_s *next; +} cvar_t; + +using cvar_callback_t = void (*)(const char *pszNewValue); + +struct cvar_listener_t +{ + cvar_listener_t(const char *var_name, cvar_callback_t handler) : + func(handler), name(var_name) {} + + cvar_callback_t func; + const char *name; +}; + +#endif // CVARDEF_H diff --git a/dep/rehlsdk/common/demo_api.h b/dep/rehlsdk/common/demo_api.h index be20cc1..8284a81 100644 --- a/dep/rehlsdk/common/demo_api.h +++ b/dep/rehlsdk/common/demo_api.h @@ -1,31 +1,31 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined ( DEMO_APIH ) -#define DEMO_APIH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct demo_api_s -{ - int ( *IsRecording ) ( void ); - int ( *IsPlayingback ) ( void ); - int ( *IsTimeDemo ) ( void ); - void ( *WriteBuffer ) ( int size, unsigned char *buffer ); -} demo_api_t; - -extern demo_api_t demoapi; - -#endif +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#if !defined ( DEMO_APIH ) +#define DEMO_APIH +#ifdef _WIN32 +#pragma once +#endif + +typedef struct demo_api_s +{ + int ( *IsRecording ) ( void ); + int ( *IsPlayingback ) ( void ); + int ( *IsTimeDemo ) ( void ); + void ( *WriteBuffer ) ( int size, unsigned char *buffer ); +} demo_api_t; + +extern demo_api_t demoapi; + +#endif diff --git a/dep/rehlsdk/common/director_cmds.h b/dep/rehlsdk/common/director_cmds.h index da99929..4c8fdd5 100644 --- a/dep/rehlsdk/common/director_cmds.h +++ b/dep/rehlsdk/common/director_cmds.h @@ -1,38 +1,38 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// director_cmds.h -// sub commands for svc_director - -#define DRC_ACTIVE 0 // tells client that he's an spectator and will get director command -#define DRC_STATUS 1 // send status infos about proxy -#define DRC_CAMERA 2 // set the actual director camera position -#define DRC_EVENT 3 // informs the dircetor about ann important game event - - -#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important) -#define DRC_FLAG_SIDE (1<<4) -#define DRC_FLAG_DRAMATIC (1<<5) - - - -// commands of the director API function CallDirectorProc(...) - -#define DRCAPI_NOP 0 // no operation -#define DRCAPI_ACTIVE 1 // de/acivates director mode in engine -#define DRCAPI_STATUS 2 // request proxy information -#define DRCAPI_SETCAM 3 // set camera n to given position and angle -#define DRCAPI_GETCAM 4 // request camera n position and angle -#define DRCAPI_DIRPLAY 5 // set director time and play with normal speed -#define DRCAPI_DIRFREEZE 6 // freeze directo at this time -#define DRCAPI_SETVIEWMODE 7 // overview or 4 cameras -#define DRCAPI_SETOVERVIEWPARAMS 8 // sets parameter for overview mode -#define DRCAPI_SETFOCUS 9 // set the camera which has the input focus -#define DRCAPI_GETTARGETS 10 // queries engine for player list -#define DRCAPI_SETVIEWPOINTS 11 // gives engine all waypoints - - +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +// director_cmds.h +// sub commands for svc_director + +#define DRC_ACTIVE 0 // tells client that he's an spectator and will get director command +#define DRC_STATUS 1 // send status infos about proxy +#define DRC_CAMERA 2 // set the actual director camera position +#define DRC_EVENT 3 // informs the dircetor about ann important game event + + +#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important) +#define DRC_FLAG_SIDE (1<<4) +#define DRC_FLAG_DRAMATIC (1<<5) + + + +// commands of the director API function CallDirectorProc(...) + +#define DRCAPI_NOP 0 // no operation +#define DRCAPI_ACTIVE 1 // de/acivates director mode in engine +#define DRCAPI_STATUS 2 // request proxy information +#define DRCAPI_SETCAM 3 // set camera n to given position and angle +#define DRCAPI_GETCAM 4 // request camera n position and angle +#define DRCAPI_DIRPLAY 5 // set director time and play with normal speed +#define DRCAPI_DIRFREEZE 6 // freeze directo at this time +#define DRCAPI_SETVIEWMODE 7 // overview or 4 cameras +#define DRCAPI_SETOVERVIEWPARAMS 8 // sets parameter for overview mode +#define DRCAPI_SETFOCUS 9 // set the camera which has the input focus +#define DRCAPI_GETTARGETS 10 // queries engine for player list +#define DRCAPI_SETVIEWPOINTS 11 // gives engine all waypoints + + diff --git a/dep/rehlsdk/common/dlight.h b/dep/rehlsdk/common/dlight.h index 0abc857..f869c98 100644 --- a/dep/rehlsdk/common/dlight.h +++ b/dep/rehlsdk/common/dlight.h @@ -1,33 +1,33 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined ( DLIGHTH ) -#define DLIGHTH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct dlight_s -{ - vec3_t origin; - float radius; - color24 color; - float die; // stop lighting after this time - float decay; // drop this each second - float minlight; // don't add when contributing less - int key; - qboolean dark; // subtracts light instead of adding -} dlight_t; - -#endif +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#if !defined ( DLIGHTH ) +#define DLIGHTH +#ifdef _WIN32 +#pragma once +#endif + +typedef struct dlight_s +{ + vec3_t origin; + float radius; + color24 color; + float die; // stop lighting after this time + float decay; // drop this each second + float minlight; // don't add when contributing less + int key; + qboolean dark; // subtracts light instead of adding +} dlight_t; + +#endif diff --git a/dep/rehlsdk/common/dll_state.h b/dep/rehlsdk/common/dll_state.h index c297132..ad16296 100644 --- a/dep/rehlsdk/common/dll_state.h +++ b/dep/rehlsdk/common/dll_state.h @@ -1,23 +1,23 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -//DLL State Flags - -#define DLL_INACTIVE 0 // no dll -#define DLL_ACTIVE 1 // dll is running -#define DLL_PAUSED 2 // dll is paused -#define DLL_CLOSE 3 // closing down dll -#define DLL_TRANS 4 // Level Transition - -// DLL Pause reasons - -#define DLL_NORMAL 0 // User hit Esc or something. -#define DLL_QUIT 4 // Quit now -#define DLL_RESTART 5 // Switch to launcher for linux, does a quit but returns 1 - -// DLL Substate info ( not relevant ) -#define ENG_NORMAL (1<<0) +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +//DLL State Flags + +#define DLL_INACTIVE 0 // no dll +#define DLL_ACTIVE 1 // dll is running +#define DLL_PAUSED 2 // dll is paused +#define DLL_CLOSE 3 // closing down dll +#define DLL_TRANS 4 // Level Transition + +// DLL Pause reasons + +#define DLL_NORMAL 0 // User hit Esc or something. +#define DLL_QUIT 4 // Quit now +#define DLL_RESTART 5 // Switch to launcher for linux, does a quit but returns 1 + +// DLL Substate info ( not relevant ) +#define ENG_NORMAL (1<<0) diff --git a/dep/rehlsdk/common/entity_state.h b/dep/rehlsdk/common/entity_state.h index 91fe2ed..2fe67c9 100644 --- a/dep/rehlsdk/common/entity_state.h +++ b/dep/rehlsdk/common/entity_state.h @@ -1,198 +1,198 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#ifndef ENTITY_STATE_H -#define ENTITY_STATE_H -#ifdef _WIN32 -#pragma once -#endif - -#include "const.h" - - -// For entityType below -#define ENTITY_NORMAL (1<<0) -#define ENTITY_BEAM (1<<1) -#define ENTITY_UNINITIALIZED (1<<30) - -// Entity state is used for the baseline and for delta compression of a packet of -// entities that is sent to a client. -typedef struct entity_state_s entity_state_t; - -struct entity_state_s -{ -// Fields which are filled in by routines outside of delta compression - int entityType; - // Index into cl_entities array for this entity. - int number; - float msg_time; - - // Message number last time the player/entity state was updated. - int messagenum; - - // Fields which can be transitted and reconstructed over the network stream - vec3_t origin; - vec3_t angles; - - int modelindex; - int sequence; - float frame; - int colormap; - short skin; - short solid; - int effects; - float scale; - - byte eflags; - - // Render information - int rendermode; - int renderamt; - color24 rendercolor; - int renderfx; - - int movetype; - float animtime; - float framerate; - int body; - byte controller[4]; - byte blending[4]; - vec3_t velocity; - - // Send bbox down to client for use during prediction. - vec3_t mins; - vec3_t maxs; - - int aiment; - // If owned by a player, the index of that player ( for projectiles ). - int owner; - - // Friction, for prediction. - float friction; - // Gravity multiplier - float gravity; - -// PLAYER SPECIFIC - int team; - int playerclass; - int health; - qboolean spectator; - int weaponmodel; - int gaitsequence; - // If standing on conveyor, e.g. - vec3_t basevelocity; - // Use the crouched hull, or the regular player hull. - int usehull; - // Latched buttons last time state updated. - int oldbuttons; - // -1 = in air, else pmove entity number - int onground; - int iStepLeft; - // How fast we are falling - float flFallVelocity; - - float fov; - int weaponanim; - - // Parametric movement overrides - vec3_t startpos; - vec3_t endpos; - float impacttime; - float starttime; - - // For mods - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; - vec3_t vuser1; - vec3_t vuser2; - vec3_t vuser3; - vec3_t vuser4; -}; - -#include "pm_info.h" - -typedef struct clientdata_s -{ - vec3_t origin; - vec3_t velocity; - - int viewmodel; - vec3_t punchangle; - int flags; - int waterlevel; - int watertype; - vec3_t view_ofs; - float health; - - int bInDuck; - - int weapons; // remove? - - int flTimeStepSound; - int flDuckTime; - int flSwimTime; - int waterjumptime; - - float maxspeed; - - float fov; - int weaponanim; - - int m_iId; - int ammo_shells; - int ammo_nails; - int ammo_cells; - int ammo_rockets; - float m_flNextAttack; - - int tfstate; - - int pushmsec; - - int deadflag; - - char physinfo[ MAX_PHYSINFO_STRING ]; - - // For mods - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; - vec3_t vuser1; - vec3_t vuser2; - vec3_t vuser3; - vec3_t vuser4; -} clientdata_t; - -#include "weaponinfo.h" - -typedef struct local_state_s -{ - entity_state_t playerstate; - clientdata_t client; - weapon_data_t weapondata[ 64 ]; -} local_state_t; - -#endif // ENTITY_STATE_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +#ifndef ENTITY_STATE_H +#define ENTITY_STATE_H +#ifdef _WIN32 +#pragma once +#endif + +#include "const.h" + + +// For entityType below +#define ENTITY_NORMAL (1<<0) +#define ENTITY_BEAM (1<<1) +#define ENTITY_UNINITIALIZED (1<<30) + +// Entity state is used for the baseline and for delta compression of a packet of +// entities that is sent to a client. +typedef struct entity_state_s entity_state_t; + +struct entity_state_s +{ +// Fields which are filled in by routines outside of delta compression + int entityType; + // Index into cl_entities array for this entity. + int number; + float msg_time; + + // Message number last time the player/entity state was updated. + int messagenum; + + // Fields which can be transitted and reconstructed over the network stream + vec3_t origin; + vec3_t angles; + + int modelindex; + int sequence; + float frame; + int colormap; + short skin; + short solid; + int effects; + float scale; + + byte eflags; + + // Render information + int rendermode; + int renderamt; + color24 rendercolor; + int renderfx; + + int movetype; + float animtime; + float framerate; + int body; + byte controller[4]; + byte blending[4]; + vec3_t velocity; + + // Send bbox down to client for use during prediction. + vec3_t mins; + vec3_t maxs; + + int aiment; + // If owned by a player, the index of that player ( for projectiles ). + int owner; + + // Friction, for prediction. + float friction; + // Gravity multiplier + float gravity; + +// PLAYER SPECIFIC + int team; + int playerclass; + int health; + qboolean spectator; + int weaponmodel; + int gaitsequence; + // If standing on conveyor, e.g. + vec3_t basevelocity; + // Use the crouched hull, or the regular player hull. + int usehull; + // Latched buttons last time state updated. + int oldbuttons; + // -1 = in air, else pmove entity number + int onground; + int iStepLeft; + // How fast we are falling + float flFallVelocity; + + float fov; + int weaponanim; + + // Parametric movement overrides + vec3_t startpos; + vec3_t endpos; + float impacttime; + float starttime; + + // For mods + int iuser1; + int iuser2; + int iuser3; + int iuser4; + float fuser1; + float fuser2; + float fuser3; + float fuser4; + vec3_t vuser1; + vec3_t vuser2; + vec3_t vuser3; + vec3_t vuser4; +}; + +#include "pm_info.h" + +typedef struct clientdata_s +{ + vec3_t origin; + vec3_t velocity; + + int viewmodel; + vec3_t punchangle; + int flags; + int waterlevel; + int watertype; + vec3_t view_ofs; + float health; + + int bInDuck; + + int weapons; // remove? + + int flTimeStepSound; + int flDuckTime; + int flSwimTime; + int waterjumptime; + + float maxspeed; + + float fov; + int weaponanim; + + int m_iId; + int ammo_shells; + int ammo_nails; + int ammo_cells; + int ammo_rockets; + float m_flNextAttack; + + int tfstate; + + int pushmsec; + + int deadflag; + + char physinfo[ MAX_PHYSINFO_STRING ]; + + // For mods + int iuser1; + int iuser2; + int iuser3; + int iuser4; + float fuser1; + float fuser2; + float fuser3; + float fuser4; + vec3_t vuser1; + vec3_t vuser2; + vec3_t vuser3; + vec3_t vuser4; +} clientdata_t; + +#include "weaponinfo.h" + +typedef struct local_state_s +{ + entity_state_t playerstate; + clientdata_t client; + weapon_data_t weapondata[ 64 ]; +} local_state_t; + +#endif // ENTITY_STATE_H diff --git a/dep/rehlsdk/common/entity_types.h b/dep/rehlsdk/common/entity_types.h index 2ab96e3..ff783df 100644 --- a/dep/rehlsdk/common/entity_types.h +++ b/dep/rehlsdk/common/entity_types.h @@ -1,26 +1,26 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// entity_types.h -#if !defined( ENTITY_TYPESH ) -#define ENTITY_TYPESH - -#define ET_NORMAL 0 -#define ET_PLAYER 1 -#define ET_TEMPENTITY 2 -#define ET_BEAM 3 -// BMODEL or SPRITE that was split across BSP nodes -#define ET_FRAGMENTED 4 - -#endif // !ENTITY_TYPESH +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +// entity_types.h +#if !defined( ENTITY_TYPESH ) +#define ENTITY_TYPESH + +#define ET_NORMAL 0 +#define ET_PLAYER 1 +#define ET_TEMPENTITY 2 +#define ET_BEAM 3 +// BMODEL or SPRITE that was split across BSP nodes +#define ET_FRAGMENTED 4 + +#endif // !ENTITY_TYPESH diff --git a/dep/rehlsdk/common/enums.h b/dep/rehlsdk/common/enums.h index 72f525c..ad8bfe0 100644 --- a/dep/rehlsdk/common/enums.h +++ b/dep/rehlsdk/common/enums.h @@ -1,28 +1,28 @@ -/*** - * - * Copyright (c) 2009, Valve LLC. All rights reserved. - * - * This product contains software technology licensed from Id - * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. - * All Rights Reserved. - * - * Use, distribution, and modification of this source code and/or resulting - * object code is restricted to non-commercial enhancements to products from - * Valve LLC. All other use, distribution, or modification is prohibited - * without written permission from Valve LLC. - * - ****/ - -#ifndef ENUMS_H -#define ENUMS_H - -// Used as array indexer -typedef enum netsrc_s -{ - NS_CLIENT = 0, - NS_SERVER, - NS_MULTICAST, // xxxMO - NS_MAX -} netsrc_t; - -#endif +/*** + * + * Copyright (c) 2009, Valve LLC. All rights reserved. + * + * This product contains software technology licensed from Id + * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. + * All Rights Reserved. + * + * Use, distribution, and modification of this source code and/or resulting + * object code is restricted to non-commercial enhancements to products from + * Valve LLC. All other use, distribution, or modification is prohibited + * without written permission from Valve LLC. + * + ****/ + +#ifndef ENUMS_H +#define ENUMS_H + +// Used as array indexer +typedef enum netsrc_s +{ + NS_CLIENT = 0, + NS_SERVER, + NS_MULTICAST, // xxxMO + NS_MAX +} netsrc_t; + +#endif diff --git a/dep/rehlsdk/common/event_api.h b/dep/rehlsdk/common/event_api.h index 9e4a1fe..722dfe2 100644 --- a/dep/rehlsdk/common/event_api.h +++ b/dep/rehlsdk/common/event_api.h @@ -1,51 +1,51 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined ( EVENT_APIH ) -#define EVENT_APIH -#ifdef _WIN32 -#pragma once -#endif - -#define EVENT_API_VERSION 1 - -typedef struct event_api_s -{ - int version; - void ( *EV_PlaySound ) ( int ent, float *origin, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch ); - void ( *EV_StopSound ) ( int ent, int channel, const char *sample ); - int ( *EV_FindModelIndex )( const char *pmodel ); - int ( *EV_IsLocal ) ( int playernum ); - int ( *EV_LocalPlayerDucking ) ( void ); - void ( *EV_LocalPlayerViewheight ) ( float * ); - void ( *EV_LocalPlayerBounds ) ( int hull, float *mins, float *maxs ); - int ( *EV_IndexFromTrace) ( struct pmtrace_s *pTrace ); - struct physent_s *( *EV_GetPhysent ) ( int idx ); - void ( *EV_SetUpPlayerPrediction ) ( int dopred, int bIncludeLocalClient ); - void ( *EV_PushPMStates ) ( void ); - void ( *EV_PopPMStates ) ( void ); - void ( *EV_SetSolidPlayers ) (int playernum); - void ( *EV_SetTraceHull ) ( int hull ); - void ( *EV_PlayerTrace ) ( float *start, float *end, int traceFlags, int ignore_pe, struct pmtrace_s *tr ); - void ( *EV_WeaponAnimation ) ( int sequence, int body ); - unsigned short ( *EV_PrecacheEvent ) ( int type, const char* psz ); - void ( *EV_PlaybackEvent ) ( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); - const char *( *EV_TraceTexture ) ( int ground, float *vstart, float *vend ); - void ( *EV_StopAllSounds ) ( int entnum, int entchannel ); - void ( *EV_KillEvents ) ( int entnum, const char *eventname ); -} event_api_t; - -extern event_api_t eventapi; - -#endif +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#if !defined ( EVENT_APIH ) +#define EVENT_APIH +#ifdef _WIN32 +#pragma once +#endif + +#define EVENT_API_VERSION 1 + +typedef struct event_api_s +{ + int version; + void ( *EV_PlaySound ) ( int ent, float *origin, int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch ); + void ( *EV_StopSound ) ( int ent, int channel, const char *sample ); + int ( *EV_FindModelIndex )( const char *pmodel ); + int ( *EV_IsLocal ) ( int playernum ); + int ( *EV_LocalPlayerDucking ) ( void ); + void ( *EV_LocalPlayerViewheight ) ( float * ); + void ( *EV_LocalPlayerBounds ) ( int hull, float *mins, float *maxs ); + int ( *EV_IndexFromTrace) ( struct pmtrace_s *pTrace ); + struct physent_s *( *EV_GetPhysent ) ( int idx ); + void ( *EV_SetUpPlayerPrediction ) ( int dopred, int bIncludeLocalClient ); + void ( *EV_PushPMStates ) ( void ); + void ( *EV_PopPMStates ) ( void ); + void ( *EV_SetSolidPlayers ) (int playernum); + void ( *EV_SetTraceHull ) ( int hull ); + void ( *EV_PlayerTrace ) ( float *start, float *end, int traceFlags, int ignore_pe, struct pmtrace_s *tr ); + void ( *EV_WeaponAnimation ) ( int sequence, int body ); + unsigned short ( *EV_PrecacheEvent ) ( int type, const char* psz ); + void ( *EV_PlaybackEvent ) ( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); + const char *( *EV_TraceTexture ) ( int ground, float *vstart, float *vend ); + void ( *EV_StopAllSounds ) ( int entnum, int entchannel ); + void ( *EV_KillEvents ) ( int entnum, const char *eventname ); +} event_api_t; + +extern event_api_t eventapi; + +#endif diff --git a/dep/rehlsdk/common/event_args.h b/dep/rehlsdk/common/event_args.h index 8c41076..99dd49a 100644 --- a/dep/rehlsdk/common/event_args.h +++ b/dep/rehlsdk/common/event_args.h @@ -1,50 +1,50 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( EVENT_ARGSH ) -#define EVENT_ARGSH -#ifdef _WIN32 -#pragma once -#endif - -// Event was invoked with stated origin -#define FEVENT_ORIGIN ( 1<<0 ) - -// Event was invoked with stated angles -#define FEVENT_ANGLES ( 1<<1 ) - -typedef struct event_args_s -{ - int flags; - - // Transmitted - int entindex; - - float origin[3]; - float angles[3]; - float velocity[3]; - - int ducking; - - float fparam1; - float fparam2; - - int iparam1; - int iparam2; - - int bparam1; - int bparam2; -} event_args_t; - -#endif +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#if !defined( EVENT_ARGSH ) +#define EVENT_ARGSH +#ifdef _WIN32 +#pragma once +#endif + +// Event was invoked with stated origin +#define FEVENT_ORIGIN ( 1<<0 ) + +// Event was invoked with stated angles +#define FEVENT_ANGLES ( 1<<1 ) + +typedef struct event_args_s +{ + int flags; + + // Transmitted + int entindex; + + float origin[3]; + float angles[3]; + float velocity[3]; + + int ducking; + + float fparam1; + float fparam2; + + int iparam1; + int iparam2; + + int bparam1; + int bparam2; +} event_args_t; + +#endif diff --git a/dep/rehlsdk/common/event_flags.h b/dep/rehlsdk/common/event_flags.h index d601e43..43f804f 100644 --- a/dep/rehlsdk/common/event_flags.h +++ b/dep/rehlsdk/common/event_flags.h @@ -1,47 +1,47 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( EVENT_FLAGSH ) -#define EVENT_FLAGSH -#ifdef _WIN32 -#pragma once -#endif - -// Skip local host for event send. -#define FEV_NOTHOST (1<<0) - -// Send the event reliably. You must specify the origin and angles and use -// PLAYBACK_EVENT_FULL for this to work correctly on the server for anything -// that depends on the event origin/angles. I.e., the origin/angles are not -// taken from the invoking edict for reliable events. -#define FEV_RELIABLE (1<<1) - -// Don't restrict to PAS/PVS, send this event to _everybody_ on the server ( useful for stopping CHAN_STATIC -// sounds started by client event when client is not in PVS anymore ( hwguy in TFC e.g. ). -#define FEV_GLOBAL (1<<2) - -// If this client already has one of these events in its queue, just update the event instead of sending it as a duplicate -// -#define FEV_UPDATE (1<<3) - -// Only send to entity specified as the invoker -#define FEV_HOSTONLY (1<<4) - -// Only send if the event was created on the server. -#define FEV_SERVER (1<<5) - -// Only issue event client side ( from shared code ) -#define FEV_CLIENT (1<<6) - -#endif +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#if !defined( EVENT_FLAGSH ) +#define EVENT_FLAGSH +#ifdef _WIN32 +#pragma once +#endif + +// Skip local host for event send. +#define FEV_NOTHOST (1<<0) + +// Send the event reliably. You must specify the origin and angles and use +// PLAYBACK_EVENT_FULL for this to work correctly on the server for anything +// that depends on the event origin/angles. I.e., the origin/angles are not +// taken from the invoking edict for reliable events. +#define FEV_RELIABLE (1<<1) + +// Don't restrict to PAS/PVS, send this event to _everybody_ on the server ( useful for stopping CHAN_STATIC +// sounds started by client event when client is not in PVS anymore ( hwguy in TFC e.g. ). +#define FEV_GLOBAL (1<<2) + +// If this client already has one of these events in its queue, just update the event instead of sending it as a duplicate +// +#define FEV_UPDATE (1<<3) + +// Only send to entity specified as the invoker +#define FEV_HOSTONLY (1<<4) + +// Only send if the event was created on the server. +#define FEV_SERVER (1<<5) + +// Only issue event client side ( from shared code ) +#define FEV_CLIENT (1<<6) + +#endif diff --git a/dep/rehlsdk/common/hltv.h b/dep/rehlsdk/common/hltv.h index 635c8c3..ea420a3 100644 --- a/dep/rehlsdk/common/hltv.h +++ b/dep/rehlsdk/common/hltv.h @@ -1,60 +1,60 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// hltv.h -// all shared consts between server, clients and proxy - -#ifndef HLTV_H -#define HLTV_H - -#define TYPE_CLIENT 0 // client is a normal HL client (default) -#define TYPE_PROXY 1 // client is another proxy -#define TYPE_DIRECTOR 2 -#define TYPE_COMMENTATOR 3 // client is a commentator -#define TYPE_DEMO 4 // client is a demo file - -// sub commands of svc_hltv: -#define HLTV_ACTIVE 0 // tells client that he's an spectator and will get director commands -#define HLTV_STATUS 1 // send status infos about proxy -#define HLTV_LISTEN 2 // tell client to listen to a multicast stream - -// director command types: -#define DRC_CMD_NONE 0 // NULL director command -#define DRC_CMD_START 1 // start director mode -#define DRC_CMD_EVENT 2 // informs about director command -#define DRC_CMD_MODE 3 // switches camera modes -#define DRC_CMD_CAMERA 4 // set fixed camera -#define DRC_CMD_TIMESCALE 5 // sets time scale -#define DRC_CMD_MESSAGE 6 // send HUD centerprint -#define DRC_CMD_SOUND 7 // plays a particular sound -#define DRC_CMD_STATUS 8 // HLTV broadcast status -#define DRC_CMD_BANNER 9 // set GUI banner -#define DRC_CMD_STUFFTEXT 10 // like the normal svc_stufftext but as director command -#define DRC_CMD_CHASE 11 // chase a certain player -#define DRC_CMD_INEYE 12 // view player through own eyes -#define DRC_CMD_MAP 13 // show overview map -#define DRC_CMD_CAMPATH 14 // define camera waypoint -#define DRC_CMD_WAYPOINTS 15 // start moving camera, inetranl message - -#define DRC_CMD_LAST 15 - -// DRC_CMD_EVENT event flags -#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important) -#define DRC_FLAG_SIDE (1<<4) // -#define DRC_FLAG_DRAMATIC (1<<5) // is a dramatic scene -#define DRC_FLAG_SLOWMOTION (1<<6) // would look good in SloMo -#define DRC_FLAG_FACEPLAYER (1<<7) // player is doning something (reload/defuse bomb etc) -#define DRC_FLAG_INTRO (1<<8) // is a introduction scene -#define DRC_FLAG_FINAL (1<<9) // is a final scene -#define DRC_FLAG_NO_RANDOM (1<<10) // don't randomize event data - -// DRC_CMD_WAYPOINT flags -#define DRC_FLAG_STARTPATH 1 // end with speed 0.0 -#define DRC_FLAG_SLOWSTART 2 // start with speed 0.0 -#define DRC_FLAG_SLOWEND 4 // end with speed 0.0 - -#endif // HLTV_H +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +// hltv.h +// all shared consts between server, clients and proxy + +#ifndef HLTV_H +#define HLTV_H + +#define TYPE_CLIENT 0 // client is a normal HL client (default) +#define TYPE_PROXY 1 // client is another proxy +#define TYPE_DIRECTOR 2 +#define TYPE_COMMENTATOR 3 // client is a commentator +#define TYPE_DEMO 4 // client is a demo file + +// sub commands of svc_hltv: +#define HLTV_ACTIVE 0 // tells client that he's an spectator and will get director commands +#define HLTV_STATUS 1 // send status infos about proxy +#define HLTV_LISTEN 2 // tell client to listen to a multicast stream + +// director command types: +#define DRC_CMD_NONE 0 // NULL director command +#define DRC_CMD_START 1 // start director mode +#define DRC_CMD_EVENT 2 // informs about director command +#define DRC_CMD_MODE 3 // switches camera modes +#define DRC_CMD_CAMERA 4 // set fixed camera +#define DRC_CMD_TIMESCALE 5 // sets time scale +#define DRC_CMD_MESSAGE 6 // send HUD centerprint +#define DRC_CMD_SOUND 7 // plays a particular sound +#define DRC_CMD_STATUS 8 // HLTV broadcast status +#define DRC_CMD_BANNER 9 // set GUI banner +#define DRC_CMD_STUFFTEXT 10 // like the normal svc_stufftext but as director command +#define DRC_CMD_CHASE 11 // chase a certain player +#define DRC_CMD_INEYE 12 // view player through own eyes +#define DRC_CMD_MAP 13 // show overview map +#define DRC_CMD_CAMPATH 14 // define camera waypoint +#define DRC_CMD_WAYPOINTS 15 // start moving camera, inetranl message + +#define DRC_CMD_LAST 15 + +// DRC_CMD_EVENT event flags +#define DRC_FLAG_PRIO_MASK 0x0F // priorities between 0 and 15 (15 most important) +#define DRC_FLAG_SIDE (1<<4) // +#define DRC_FLAG_DRAMATIC (1<<5) // is a dramatic scene +#define DRC_FLAG_SLOWMOTION (1<<6) // would look good in SloMo +#define DRC_FLAG_FACEPLAYER (1<<7) // player is doning something (reload/defuse bomb etc) +#define DRC_FLAG_INTRO (1<<8) // is a introduction scene +#define DRC_FLAG_FINAL (1<<9) // is a final scene +#define DRC_FLAG_NO_RANDOM (1<<10) // don't randomize event data + +// DRC_CMD_WAYPOINT flags +#define DRC_FLAG_STARTPATH 1 // end with speed 0.0 +#define DRC_FLAG_SLOWSTART 2 // start with speed 0.0 +#define DRC_FLAG_SLOWEND 4 // end with speed 0.0 + +#endif // HLTV_H diff --git a/dep/rehlsdk/common/in_buttons.h b/dep/rehlsdk/common/in_buttons.h index 7ed5650..4196a2d 100644 --- a/dep/rehlsdk/common/in_buttons.h +++ b/dep/rehlsdk/common/in_buttons.h @@ -1,38 +1,38 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef IN_BUTTONS_H -#define IN_BUTTONS_H -#ifdef _WIN32 -#pragma once -#endif - -#define IN_ATTACK (1 << 0) -#define IN_JUMP (1 << 1) -#define IN_DUCK (1 << 2) -#define IN_FORWARD (1 << 3) -#define IN_BACK (1 << 4) -#define IN_USE (1 << 5) -#define IN_CANCEL (1 << 6) -#define IN_LEFT (1 << 7) -#define IN_RIGHT (1 << 8) -#define IN_MOVELEFT (1 << 9) -#define IN_MOVERIGHT (1 << 10) -#define IN_ATTACK2 (1 << 11) -#define IN_RUN (1 << 12) -#define IN_RELOAD (1 << 13) -#define IN_ALT1 (1 << 14) -#define IN_SCORE (1 << 15) // Used by client.dll for when scoreboard is held down - -#endif // IN_BUTTONS_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef IN_BUTTONS_H +#define IN_BUTTONS_H +#ifdef _WIN32 +#pragma once +#endif + +#define IN_ATTACK (1 << 0) +#define IN_JUMP (1 << 1) +#define IN_DUCK (1 << 2) +#define IN_FORWARD (1 << 3) +#define IN_BACK (1 << 4) +#define IN_USE (1 << 5) +#define IN_CANCEL (1 << 6) +#define IN_LEFT (1 << 7) +#define IN_RIGHT (1 << 8) +#define IN_MOVELEFT (1 << 9) +#define IN_MOVERIGHT (1 << 10) +#define IN_ATTACK2 (1 << 11) +#define IN_RUN (1 << 12) +#define IN_RELOAD (1 << 13) +#define IN_ALT1 (1 << 14) +#define IN_SCORE (1 << 15) // Used by client.dll for when scoreboard is held down + +#endif // IN_BUTTONS_H diff --git a/dep/rehlsdk/common/ivoicetweak.h b/dep/rehlsdk/common/ivoicetweak.h index c15ef5f..da568c5 100644 --- a/dep/rehlsdk/common/ivoicetweak.h +++ b/dep/rehlsdk/common/ivoicetweak.h @@ -1,38 +1,38 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef IVOICETWEAK_H -#define IVOICETWEAK_H -#ifdef _WIN32 -#pragma once -#endif - -// These provide access to the voice controls. -typedef enum -{ - MicrophoneVolume=0, // values 0-1. - OtherSpeakerScale, // values 0-1. Scales how loud other players are. - MicBoost, // 20 db gain to voice input -} VoiceTweakControl; - - -typedef struct IVoiceTweak_s -{ - // These turn voice tweak mode on and off. While in voice tweak mode, the user's voice is echoed back - // without sending to the server. - int (*StartVoiceTweakMode)(); // Returns 0 on error. - void (*EndVoiceTweakMode)(); - - // Get/set control values. - void (*SetControlFloat)(VoiceTweakControl iControl, float value); - float (*GetControlFloat)(VoiceTweakControl iControl); - - int (*GetSpeakingVolume)(); -} IVoiceTweak; - - -#endif // IVOICETWEAK_H +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef IVOICETWEAK_H +#define IVOICETWEAK_H +#ifdef _WIN32 +#pragma once +#endif + +// These provide access to the voice controls. +typedef enum +{ + MicrophoneVolume=0, // values 0-1. + OtherSpeakerScale, // values 0-1. Scales how loud other players are. + MicBoost, // 20 db gain to voice input +} VoiceTweakControl; + + +typedef struct IVoiceTweak_s +{ + // These turn voice tweak mode on and off. While in voice tweak mode, the user's voice is echoed back + // without sending to the server. + int (*StartVoiceTweakMode)(); // Returns 0 on error. + void (*EndVoiceTweakMode)(); + + // Get/set control values. + void (*SetControlFloat)(VoiceTweakControl iControl, float value); + float (*GetControlFloat)(VoiceTweakControl iControl); + + int (*GetSpeakingVolume)(); +} IVoiceTweak; + + +#endif // IVOICETWEAK_H diff --git a/dep/rehlsdk/common/kbutton.h b/dep/rehlsdk/common/kbutton.h index 55a75dc..5607568 100644 --- a/dep/rehlsdk/common/kbutton.h +++ b/dep/rehlsdk/common/kbutton.h @@ -1,41 +1,41 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#ifndef KBUTTON_H -#define KBUTTON_H -#ifdef _WIN32 -#pragma once -#endif - -typedef struct kbutton_s -{ - int down[2]; - int state; -} kbutton_t; - -#endif // KBUTTON_H +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + +#ifndef KBUTTON_H +#define KBUTTON_H +#ifdef _WIN32 +#pragma once +#endif + +typedef struct kbutton_s +{ + int down[2]; + int state; +} kbutton_t; + +#endif // KBUTTON_H diff --git a/dep/rehlsdk/common/mathlib.h b/dep/rehlsdk/common/mathlib.h index 83affe8..af30ae7 100644 --- a/dep/rehlsdk/common/mathlib.h +++ b/dep/rehlsdk/common/mathlib.h @@ -1,108 +1,108 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#ifndef MATHLIB_H -#define MATHLIB_H -#ifdef _WIN32 -#pragma once -#endif - -typedef float vec_t; - -#if !defined DID_VEC3_T_DEFINE && !defined vec3_t -#define DID_VEC3_T_DEFINE -typedef vec_t vec3_t[3]; -#endif - -typedef vec_t vec4_t[4]; -typedef int fixed16_t; - -typedef union DLONG_u -{ - int i[2]; - double d; - float f; -} DLONG; - -#define M_PI 3.14159265358979323846 - -#ifdef __cplusplus -#ifdef min -#undef min -#endif - -#ifdef max -#undef max -#endif - -#ifdef clamp -#undef clamp -#endif - -template -inline T min(T a, T b) -{ - return (a < b) ? a : b; -} - -template -inline T max(T a, T b) -{ - return (a < b) ? b : a; -} - -template -inline T clamp(T a, T min, T max) -{ - return (a > max) ? max : (a < min) ? min : a; -} - -template -inline T bswap(T s) -{ - switch (sizeof(T)) - { - case 2: {auto res = __builtin_bswap16(*(uint16 *)&s); return *(T *)&res; } - case 4: {auto res = __builtin_bswap32(*(uint32 *)&s); return *(T *)&res; } - case 8: {auto res = __builtin_bswap64(*(uint64 *)&s); return *(T *)&res; } - default: return s; - } -} -#else // __cplusplus -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif - -#define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val))) -#endif // __cplusplus - -#endif // MATHLIB_H +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + +#ifndef MATHLIB_H +#define MATHLIB_H +#ifdef _WIN32 +#pragma once +#endif + +typedef float vec_t; + +#if !defined DID_VEC3_T_DEFINE && !defined vec3_t +#define DID_VEC3_T_DEFINE +typedef vec_t vec3_t[3]; +#endif + +typedef vec_t vec4_t[4]; +typedef int fixed16_t; + +typedef union DLONG_u +{ + int i[2]; + double d; + float f; +} DLONG; + +#define M_PI 3.14159265358979323846 + +#ifdef __cplusplus +#ifdef min +#undef min +#endif + +#ifdef max +#undef max +#endif + +#ifdef clamp +#undef clamp +#endif + +template +inline T min(T a, T b) +{ + return (a < b) ? a : b; +} + +template +inline T max(T a, T b) +{ + return (a < b) ? b : a; +} + +template +inline T clamp(T a, T min, T max) +{ + return (a > max) ? max : (a < min) ? min : a; +} + +template +inline T bswap(T s) +{ + switch (sizeof(T)) + { + case 2: {auto res = __builtin_bswap16(*(uint16 *)&s); return *(T *)&res; } + case 4: {auto res = __builtin_bswap32(*(uint32 *)&s); return *(T *)&res; } + case 8: {auto res = __builtin_bswap64(*(uint64 *)&s); return *(T *)&res; } + default: return s; + } +} +#else // __cplusplus +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +#define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val))) +#endif // __cplusplus + +#endif // MATHLIB_H diff --git a/dep/rehlsdk/common/net_api.h b/dep/rehlsdk/common/net_api.h index c8e3439..9551d18 100644 --- a/dep/rehlsdk/common/net_api.h +++ b/dep/rehlsdk/common/net_api.h @@ -1,99 +1,99 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#if !defined( NET_APIH ) -#define NET_APIH -#ifdef _WIN32 -#pragma once -#endif - -#if !defined ( NETADRH ) -#include "netadr.h" -#endif - -#define NETAPI_REQUEST_SERVERLIST ( 0 ) // Doesn't need a remote address -#define NETAPI_REQUEST_PING ( 1 ) -#define NETAPI_REQUEST_RULES ( 2 ) -#define NETAPI_REQUEST_PLAYERS ( 3 ) -#define NETAPI_REQUEST_DETAILS ( 4 ) - -// Set this flag for things like broadcast requests, etc. where the engine should not -// kill the request hook after receiving the first response -#define FNETAPI_MULTIPLE_RESPONSE ( 1<<0 ) - -typedef void ( *net_api_response_func_t ) ( struct net_response_s *response ); - -#define NET_SUCCESS ( 0 ) -#define NET_ERROR_TIMEOUT ( 1<<0 ) -#define NET_ERROR_PROTO_UNSUPPORTED ( 1<<1 ) -#define NET_ERROR_UNDEFINED ( 1<<2 ) - -typedef struct net_adrlist_s -{ - struct net_adrlist_s *next; - netadr_t remote_address; -} net_adrlist_t; - -typedef struct net_response_s -{ - // NET_SUCCESS or an error code - int error; - - // Context ID - int context; - // Type - int type; - - // Server that is responding to the request - netadr_t remote_address; - - // Response RTT ping time - double ping; - // Key/Value pair string ( separated by backlash \ characters ) - // WARNING: You must copy this buffer in the callback function, because it is freed - // by the engine right after the call!!!! - // ALSO: For NETAPI_REQUEST_SERVERLIST requests, this will be a pointer to a linked list of net_adrlist_t's - void *response; -} net_response_t; - -typedef struct net_status_s -{ - // Connected to remote server? 1 == yes, 0 otherwise - int connected; - // Client's IP address - netadr_t local_address; - // Address of remote server - netadr_t remote_address; - // Packet Loss ( as a percentage ) - int packet_loss; - // Latency, in seconds ( multiply by 1000.0 to get milliseconds ) - double latency; - // Connection time, in seconds - double connection_time; - // Rate setting ( for incoming data ) - double rate; -} net_status_t; - -typedef struct net_api_s -{ - // APIs - void ( *InitNetworking )( void ); - void ( *Status ) ( struct net_status_s *status ); - void ( *SendRequest) ( int context, int request, int flags, double timeout, struct netadr_s *remote_address, net_api_response_func_t response ); - void ( *CancelRequest ) ( int context ); - void ( *CancelAllRequests ) ( void ); - char *( *AdrToString ) ( struct netadr_s *a ); - int ( *CompareAdr ) ( struct netadr_s *a, struct netadr_s *b ); - int ( *StringToAdr ) ( char *s, struct netadr_s *a ); - const char *( *ValueForKey ) ( const char *s, const char *key ); - void ( *RemoveKey ) ( char *s, const char *key ); - void ( *SetValueForKey ) (char *s, const char *key, const char *value, int maxsize ); -} net_api_t; - -extern net_api_t netapi; - -#endif // NET_APIH +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#if !defined( NET_APIH ) +#define NET_APIH +#ifdef _WIN32 +#pragma once +#endif + +#if !defined ( NETADRH ) +#include "netadr.h" +#endif + +#define NETAPI_REQUEST_SERVERLIST ( 0 ) // Doesn't need a remote address +#define NETAPI_REQUEST_PING ( 1 ) +#define NETAPI_REQUEST_RULES ( 2 ) +#define NETAPI_REQUEST_PLAYERS ( 3 ) +#define NETAPI_REQUEST_DETAILS ( 4 ) + +// Set this flag for things like broadcast requests, etc. where the engine should not +// kill the request hook after receiving the first response +#define FNETAPI_MULTIPLE_RESPONSE ( 1<<0 ) + +typedef void ( *net_api_response_func_t ) ( struct net_response_s *response ); + +#define NET_SUCCESS ( 0 ) +#define NET_ERROR_TIMEOUT ( 1<<0 ) +#define NET_ERROR_PROTO_UNSUPPORTED ( 1<<1 ) +#define NET_ERROR_UNDEFINED ( 1<<2 ) + +typedef struct net_adrlist_s +{ + struct net_adrlist_s *next; + netadr_t remote_address; +} net_adrlist_t; + +typedef struct net_response_s +{ + // NET_SUCCESS or an error code + int error; + + // Context ID + int context; + // Type + int type; + + // Server that is responding to the request + netadr_t remote_address; + + // Response RTT ping time + double ping; + // Key/Value pair string ( separated by backlash \ characters ) + // WARNING: You must copy this buffer in the callback function, because it is freed + // by the engine right after the call!!!! + // ALSO: For NETAPI_REQUEST_SERVERLIST requests, this will be a pointer to a linked list of net_adrlist_t's + void *response; +} net_response_t; + +typedef struct net_status_s +{ + // Connected to remote server? 1 == yes, 0 otherwise + int connected; + // Client's IP address + netadr_t local_address; + // Address of remote server + netadr_t remote_address; + // Packet Loss ( as a percentage ) + int packet_loss; + // Latency, in seconds ( multiply by 1000.0 to get milliseconds ) + double latency; + // Connection time, in seconds + double connection_time; + // Rate setting ( for incoming data ) + double rate; +} net_status_t; + +typedef struct net_api_s +{ + // APIs + void ( *InitNetworking )( void ); + void ( *Status ) ( struct net_status_s *status ); + void ( *SendRequest) ( int context, int request, int flags, double timeout, struct netadr_s *remote_address, net_api_response_func_t response ); + void ( *CancelRequest ) ( int context ); + void ( *CancelAllRequests ) ( void ); + char *( *AdrToString ) ( struct netadr_s *a ); + int ( *CompareAdr ) ( struct netadr_s *a, struct netadr_s *b ); + int ( *StringToAdr ) ( char *s, struct netadr_s *a ); + const char *( *ValueForKey ) ( const char *s, const char *key ); + void ( *RemoveKey ) ( char *s, const char *key ); + void ( *SetValueForKey ) (char *s, const char *key, const char *value, int maxsize ); +} net_api_t; + +extern net_api_t netapi; + +#endif // NET_APIH diff --git a/dep/rehlsdk/common/netadr.h b/dep/rehlsdk/common/netadr.h index 05f8f27..0a468d2 100644 --- a/dep/rehlsdk/common/netadr.h +++ b/dep/rehlsdk/common/netadr.h @@ -1,40 +1,40 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#ifndef NETADR_H -#define NETADR_H -#ifdef _WIN32 -#pragma once -#endif - -typedef enum -{ - NA_UNUSED, - NA_LOOPBACK, - NA_BROADCAST, - NA_IP, - NA_IPX, - NA_BROADCAST_IPX, -} netadrtype_t; - -typedef struct netadr_s -{ - netadrtype_t type; - unsigned char ip[4]; - unsigned char ipx[10]; - unsigned short port; -} netadr_t; - -#endif // NETADR_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +#ifndef NETADR_H +#define NETADR_H +#ifdef _WIN32 +#pragma once +#endif + +typedef enum +{ + NA_UNUSED, + NA_LOOPBACK, + NA_BROADCAST, + NA_IP, + NA_IPX, + NA_BROADCAST_IPX, +} netadrtype_t; + +typedef struct netadr_s +{ + netadrtype_t type; + unsigned char ip[4]; + unsigned char ipx[10]; + unsigned short port; +} netadr_t; + +#endif // NETADR_H diff --git a/dep/rehlsdk/common/nowin.h b/dep/rehlsdk/common/nowin.h index d4fc615..0b1f577 100644 --- a/dep/rehlsdk/common/nowin.h +++ b/dep/rehlsdk/common/nowin.h @@ -1,16 +1,16 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef INC_NOWIN_H -#define INC_NOWIN_H -#ifndef _WIN32 - -#include -#include - -#endif //!_WIN32 -#endif //INC_NOWIN_H +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef INC_NOWIN_H +#define INC_NOWIN_H +#ifndef _WIN32 + +#include +#include + +#endif //!_WIN32 +#endif //INC_NOWIN_H diff --git a/dep/rehlsdk/common/parsemsg.cpp b/dep/rehlsdk/common/parsemsg.cpp index fa96324..6742db2 100644 --- a/dep/rehlsdk/common/parsemsg.cpp +++ b/dep/rehlsdk/common/parsemsg.cpp @@ -1,259 +1,259 @@ -/*** -* -* Copyright (c) 1999, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// -// parsemsg.cpp -// -//-------------------------------------------------------------------------------------------------------------- -#include "parsemsg.h" -#include - -typedef unsigned char byte; -#define true 1 - -static byte *gpBuf; -static int giSize; -static int giRead; -static int giBadRead; - -int READ_OK( void ) -{ - return !giBadRead; -} - -void BEGIN_READ( void *buf, int size ) -{ - giRead = 0; - giBadRead = 0; - giSize = size; - gpBuf = (byte*)buf; -} - - -int READ_CHAR( void ) -{ - int c; - - if (giRead + 1 > giSize) - { - giBadRead = true; - return -1; - } - - c = (signed char)gpBuf[giRead]; - giRead++; - - return c; -} - -int READ_BYTE( void ) -{ - int c; - - if (giRead+1 > giSize) - { - giBadRead = true; - return -1; - } - - c = (unsigned char)gpBuf[giRead]; - giRead++; - - return c; -} - -int READ_SHORT( void ) -{ - int c; - - if (giRead+2 > giSize) - { - giBadRead = true; - return -1; - } - - c = (short)( gpBuf[giRead] + ( gpBuf[giRead+1] << 8 ) ); - - giRead += 2; - - return c; -} - -int READ_WORD( void ) -{ - return READ_SHORT(); -} - - -int READ_LONG( void ) -{ - int c; - - if (giRead+4 > giSize) - { - giBadRead = true; - return -1; - } - - c = gpBuf[giRead] + (gpBuf[giRead + 1] << 8) + (gpBuf[giRead + 2] << 16) + (gpBuf[giRead + 3] << 24); - - giRead += 4; - - return c; -} - -float READ_FLOAT( void ) -{ - union - { - byte b[4]; - float f; - int l; - } dat; - - dat.b[0] = gpBuf[giRead]; - dat.b[1] = gpBuf[giRead+1]; - dat.b[2] = gpBuf[giRead+2]; - dat.b[3] = gpBuf[giRead+3]; - giRead += 4; - -// dat.l = LittleLong (dat.l); - - return dat.f; -} - -char* READ_STRING( void ) -{ - static char string[2048]; - int l,c; - - string[0] = 0; - - l = 0; - do - { - if ( giRead+1 > giSize ) - break; // no more characters - - c = READ_CHAR(); - if (c == -1 || c == 0) - break; - string[l] = c; - l++; - } while (l < sizeof(string)-1); - - string[l] = 0; - - return string; -} - -float READ_COORD( void ) -{ - return (float)(READ_SHORT() * (1.0/8)); -} - -float READ_ANGLE( void ) -{ - return (float)(READ_CHAR() * (360.0/256)); -} - -float READ_HIRESANGLE( void ) -{ - return (float)(READ_SHORT() * (360.0/65536)); -} - -//-------------------------------------------------------------------------------------------------------------- -BufferWriter::BufferWriter() -{ - Init( NULL, 0 ); -} - -//-------------------------------------------------------------------------------------------------------------- -BufferWriter::BufferWriter( unsigned char *buffer, int bufferLen ) -{ - Init( buffer, bufferLen ); -} - -//-------------------------------------------------------------------------------------------------------------- -void BufferWriter::Init( unsigned char *buffer, int bufferLen ) -{ - m_overflow = false; - m_buffer = buffer; - m_remaining = bufferLen; - m_overallLength = bufferLen; -} - -//-------------------------------------------------------------------------------------------------------------- -void BufferWriter::WriteByte( unsigned char data ) -{ - if (!m_buffer || !m_remaining) - { - m_overflow = true; - return; - } - - *m_buffer = data; - ++m_buffer; - --m_remaining; -} - -//-------------------------------------------------------------------------------------------------------------- -void BufferWriter::WriteLong( int data ) -{ - if (!m_buffer || m_remaining < 4) - { - m_overflow = true; - return; - } - - m_buffer[0] = data&0xff; - m_buffer[1] = (data>>8)&0xff; - m_buffer[2] = (data>>16)&0xff; - m_buffer[3] = data>>24; - m_buffer += 4; - m_remaining -= 4; -} - -//-------------------------------------------------------------------------------------------------------------- -void BufferWriter::WriteString( const char *str ) -{ - if (!m_buffer || !m_remaining) - { - m_overflow = true; - return; - } - - if (!str) - str = ""; - - int len = strlen(str)+1; - if ( len > m_remaining ) - { - m_overflow = true; - str = ""; - len = 1; - } - - strcpy((char *)m_buffer, str); - m_remaining -= len; - m_buffer += len; -} - -//-------------------------------------------------------------------------------------------------------------- -int BufferWriter::GetSpaceUsed() -{ - return m_overallLength - m_remaining; -} - -//-------------------------------------------------------------------------------------------------------------- +/*** +* +* Copyright (c) 1999, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +// +// parsemsg.cpp +// +//-------------------------------------------------------------------------------------------------------------- +#include "parsemsg.h" +#include + +typedef unsigned char byte; +#define true 1 + +static byte *gpBuf; +static int giSize; +static int giRead; +static int giBadRead; + +int READ_OK( void ) +{ + return !giBadRead; +} + +void BEGIN_READ( void *buf, int size ) +{ + giRead = 0; + giBadRead = 0; + giSize = size; + gpBuf = (byte*)buf; +} + + +int READ_CHAR( void ) +{ + int c; + + if (giRead + 1 > giSize) + { + giBadRead = true; + return -1; + } + + c = (signed char)gpBuf[giRead]; + giRead++; + + return c; +} + +int READ_BYTE( void ) +{ + int c; + + if (giRead+1 > giSize) + { + giBadRead = true; + return -1; + } + + c = (unsigned char)gpBuf[giRead]; + giRead++; + + return c; +} + +int READ_SHORT( void ) +{ + int c; + + if (giRead+2 > giSize) + { + giBadRead = true; + return -1; + } + + c = (short)( gpBuf[giRead] + ( gpBuf[giRead+1] << 8 ) ); + + giRead += 2; + + return c; +} + +int READ_WORD( void ) +{ + return READ_SHORT(); +} + + +int READ_LONG( void ) +{ + int c; + + if (giRead+4 > giSize) + { + giBadRead = true; + return -1; + } + + c = gpBuf[giRead] + (gpBuf[giRead + 1] << 8) + (gpBuf[giRead + 2] << 16) + (gpBuf[giRead + 3] << 24); + + giRead += 4; + + return c; +} + +float READ_FLOAT( void ) +{ + union + { + byte b[4]; + float f; + int l; + } dat; + + dat.b[0] = gpBuf[giRead]; + dat.b[1] = gpBuf[giRead+1]; + dat.b[2] = gpBuf[giRead+2]; + dat.b[3] = gpBuf[giRead+3]; + giRead += 4; + +// dat.l = LittleLong (dat.l); + + return dat.f; +} + +char* READ_STRING( void ) +{ + static char string[2048]; + int l,c; + + string[0] = 0; + + l = 0; + do + { + if ( giRead+1 > giSize ) + break; // no more characters + + c = READ_CHAR(); + if (c == -1 || c == 0) + break; + string[l] = c; + l++; + } while (l < sizeof(string)-1); + + string[l] = 0; + + return string; +} + +float READ_COORD( void ) +{ + return (float)(READ_SHORT() * (1.0/8)); +} + +float READ_ANGLE( void ) +{ + return (float)(READ_CHAR() * (360.0/256)); +} + +float READ_HIRESANGLE( void ) +{ + return (float)(READ_SHORT() * (360.0/65536)); +} + +//-------------------------------------------------------------------------------------------------------------- +BufferWriter::BufferWriter() +{ + Init( NULL, 0 ); +} + +//-------------------------------------------------------------------------------------------------------------- +BufferWriter::BufferWriter( unsigned char *buffer, int bufferLen ) +{ + Init( buffer, bufferLen ); +} + +//-------------------------------------------------------------------------------------------------------------- +void BufferWriter::Init( unsigned char *buffer, int bufferLen ) +{ + m_overflow = false; + m_buffer = buffer; + m_remaining = bufferLen; + m_overallLength = bufferLen; +} + +//-------------------------------------------------------------------------------------------------------------- +void BufferWriter::WriteByte( unsigned char data ) +{ + if (!m_buffer || !m_remaining) + { + m_overflow = true; + return; + } + + *m_buffer = data; + ++m_buffer; + --m_remaining; +} + +//-------------------------------------------------------------------------------------------------------------- +void BufferWriter::WriteLong( int data ) +{ + if (!m_buffer || m_remaining < 4) + { + m_overflow = true; + return; + } + + m_buffer[0] = data&0xff; + m_buffer[1] = (data>>8)&0xff; + m_buffer[2] = (data>>16)&0xff; + m_buffer[3] = data>>24; + m_buffer += 4; + m_remaining -= 4; +} + +//-------------------------------------------------------------------------------------------------------------- +void BufferWriter::WriteString( const char *str ) +{ + if (!m_buffer || !m_remaining) + { + m_overflow = true; + return; + } + + if (!str) + str = ""; + + int len = strlen(str)+1; + if ( len > m_remaining ) + { + m_overflow = true; + str = ""; + len = 1; + } + + strcpy((char *)m_buffer, str); + m_remaining -= len; + m_buffer += len; +} + +//-------------------------------------------------------------------------------------------------------------- +int BufferWriter::GetSpaceUsed() +{ + return m_overallLength - m_remaining; +} + +//-------------------------------------------------------------------------------------------------------------- diff --git a/dep/rehlsdk/common/parsemsg.h b/dep/rehlsdk/common/parsemsg.h index 194f844..be7affc 100644 --- a/dep/rehlsdk/common/parsemsg.h +++ b/dep/rehlsdk/common/parsemsg.h @@ -1,66 +1,66 @@ -/*** -* -* Copyright (c) 1999, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// -// parsemsg.h -// MDC - copying from cstrike\cl_dll so career-mode stuff can catch messages -// in this dll. (and C++ifying it) -// - -#ifndef PARSEMSG_H -#define PARSEMSG_H - -#define ASSERT( x ) -//-------------------------------------------------------------------------------------------------------------- -void BEGIN_READ( void *buf, int size ); -int READ_CHAR( void ); -int READ_BYTE( void ); -int READ_SHORT( void ); -int READ_WORD( void ); -int READ_LONG( void ); -float READ_FLOAT( void ); -char* READ_STRING( void ); -float READ_COORD( void ); -float READ_ANGLE( void ); -float READ_HIRESANGLE( void ); -int READ_OK( void ); - -//-------------------------------------------------------------------------------------------------------------- -class BufferWriter -{ -public: - BufferWriter(); - BufferWriter( unsigned char *buffer, int bufferLen ); - void Init( unsigned char *buffer, int bufferLen ); - - void WriteByte( unsigned char data ); - void WriteLong( int data ); - void WriteString( const char *str ); - - bool HasOverflowed(); - int GetSpaceUsed(); - -protected: - unsigned char *m_buffer; - int m_remaining; - bool m_overflow; - int m_overallLength; -}; - -//-------------------------------------------------------------------------------------------------------------- - -#endif // PARSEMSG_H - - - +/*** +* +* Copyright (c) 1999, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +// +// parsemsg.h +// MDC - copying from cstrike\cl_dll so career-mode stuff can catch messages +// in this dll. (and C++ifying it) +// + +#ifndef PARSEMSG_H +#define PARSEMSG_H + +#define ASSERT( x ) +//-------------------------------------------------------------------------------------------------------------- +void BEGIN_READ( void *buf, int size ); +int READ_CHAR( void ); +int READ_BYTE( void ); +int READ_SHORT( void ); +int READ_WORD( void ); +int READ_LONG( void ); +float READ_FLOAT( void ); +char* READ_STRING( void ); +float READ_COORD( void ); +float READ_ANGLE( void ); +float READ_HIRESANGLE( void ); +int READ_OK( void ); + +//-------------------------------------------------------------------------------------------------------------- +class BufferWriter +{ +public: + BufferWriter(); + BufferWriter( unsigned char *buffer, int bufferLen ); + void Init( unsigned char *buffer, int bufferLen ); + + void WriteByte( unsigned char data ); + void WriteLong( int data ); + void WriteString( const char *str ); + + bool HasOverflowed(); + int GetSpaceUsed(); + +protected: + unsigned char *m_buffer; + int m_remaining; + bool m_overflow; + int m_overallLength; +}; + +//-------------------------------------------------------------------------------------------------------------- + +#endif // PARSEMSG_H + + + diff --git a/dep/rehlsdk/common/particledef.h b/dep/rehlsdk/common/particledef.h index b1356d2..7e4043a 100644 --- a/dep/rehlsdk/common/particledef.h +++ b/dep/rehlsdk/common/particledef.h @@ -1,57 +1,57 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( PARTICLEDEFH ) -#define PARTICLEDEFH -#ifdef _WIN32 -#pragma once -#endif - -typedef enum { - pt_static, - pt_grav, - pt_slowgrav, - pt_fire, - pt_explode, - pt_explode2, - pt_blob, - pt_blob2, - pt_vox_slowgrav, - pt_vox_grav, - pt_clientcustom // Must have callback function specified -} ptype_t; - -// !!! if this is changed, it must be changed in d_ifacea.h too !!! -typedef struct particle_s -{ -// driver-usable fields - vec3_t org; - short color; - short packedColor; -// drivers never touch the following fields - struct particle_s *next; - vec3_t vel; - float ramp; - float die; - ptype_t type; - void (*deathfunc)( struct particle_s *particle ); - - // for pt_clientcusttom, we'll call this function each frame - void (*callback)( struct particle_s *particle, float frametime ); - - // For deathfunc, etc. - unsigned char context; -} particle_t; - -#endif +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#if !defined( PARTICLEDEFH ) +#define PARTICLEDEFH +#ifdef _WIN32 +#pragma once +#endif + +typedef enum { + pt_static, + pt_grav, + pt_slowgrav, + pt_fire, + pt_explode, + pt_explode2, + pt_blob, + pt_blob2, + pt_vox_slowgrav, + pt_vox_grav, + pt_clientcustom // Must have callback function specified +} ptype_t; + +// !!! if this is changed, it must be changed in d_ifacea.h too !!! +typedef struct particle_s +{ +// driver-usable fields + vec3_t org; + short color; + short packedColor; +// drivers never touch the following fields + struct particle_s *next; + vec3_t vel; + float ramp; + float die; + ptype_t type; + void (*deathfunc)( struct particle_s *particle ); + + // for pt_clientcusttom, we'll call this function each frame + void (*callback)( struct particle_s *particle, float frametime ); + + // For deathfunc, etc. + unsigned char context; +} particle_t; + +#endif diff --git a/dep/rehlsdk/common/pmtrace.h b/dep/rehlsdk/common/pmtrace.h index 8d33780..1784e9c 100644 --- a/dep/rehlsdk/common/pmtrace.h +++ b/dep/rehlsdk/common/pmtrace.h @@ -1,43 +1,43 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( PMTRACEH ) -#define PMTRACEH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct -{ - vec3_t normal; - float dist; -} pmplane_t; - -typedef struct pmtrace_s pmtrace_t; - -struct pmtrace_s -{ - qboolean allsolid; // if true, plane is not valid - qboolean startsolid; // if true, the initial point was in a solid area - qboolean inopen, inwater; // End point is in empty space or in water - float fraction; // time completed, 1.0 = didn't hit anything - vec3_t endpos; // final position - pmplane_t plane; // surface normal at impact - int ent; // entity at impact - vec3_t deltavelocity; // Change in player's velocity caused by impact. - // Only run on server. - int hitgroup; -}; - -#endif +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#if !defined( PMTRACEH ) +#define PMTRACEH +#ifdef _WIN32 +#pragma once +#endif + +typedef struct +{ + vec3_t normal; + float dist; +} pmplane_t; + +typedef struct pmtrace_s pmtrace_t; + +struct pmtrace_s +{ + qboolean allsolid; // if true, plane is not valid + qboolean startsolid; // if true, the initial point was in a solid area + qboolean inopen, inwater; // End point is in empty space or in water + float fraction; // time completed, 1.0 = didn't hit anything + vec3_t endpos; // final position + pmplane_t plane; // surface normal at impact + int ent; // entity at impact + vec3_t deltavelocity; // Change in player's velocity caused by impact. + // Only run on server. + int hitgroup; +}; + +#endif diff --git a/dep/rehlsdk/common/port.h b/dep/rehlsdk/common/port.h index fc12e70..a0838a7 100644 --- a/dep/rehlsdk/common/port.h +++ b/dep/rehlsdk/common/port.h @@ -1,119 +1,119 @@ -// port.h: portability helper -// -////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "archtypes.h" // DAL - -#ifdef _WIN32 - - // Insert your headers here - #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - #define WIN32_EXTRA_LEAN - - #include "winsani_in.h" - #include - #include "winsani_out.h" - - #include - #include - #include - -#else // _WIN32 - - #include - #include - #include // exit() - #include // strncpy() - #include // tolower() - #include - #include - #include - #include - - typedef unsigned char BYTE; - - typedef int32 LONG; - //typedef uint32 ULONG; - - #ifndef ARCHTYPES_H - typedef uint32 ULONG; - #endif - - typedef void *HANDLE; - - #ifndef HMODULE - typedef void *HMODULE; - #endif - - typedef char * LPSTR; - - #define __cdecl - - - #ifdef __linux__ - typedef struct POINT_s - { - int x; - int y; - } POINT; - typedef void *HINSTANCE; - typedef void *HWND; - typedef void *HDC; - typedef void *HGLRC; - - typedef struct RECT_s - { - int left; - int right; - int top; - int bottom; - } RECT; - #endif - - - #ifdef __cplusplus - - //#undef FALSE - //#undef TRUE - - #ifdef OSX - //#else - //const bool FALSE = false; - //const bool TRUE = true; - #endif - #endif - - #ifndef NULL - #ifdef __cplusplus - #define NULL 0 - #else - #define NULL ((void *)0) - #endif - #endif - - #ifdef __cplusplus - inline int ioctlsocket( int d, int cmd, uint32 *argp ) { return ioctl( d, cmd, argp ); } - inline int closesocket( int fd ) { return close( fd ); } - inline char * GetCurrentDirectory( size_t size, char * buf ) { return getcwd( buf, size ); } - inline int WSAGetLastError() { return errno; } - - inline void DebugBreak( void ) { exit( 1 ); } - #endif - - extern char g_szEXEName[ 4096 ]; - - #define _snprintf snprintf - - #if defined(OSX) - #define SO_ARCH_SUFFIX ".dylib" - #else - #if defined ( __x86_64__ ) - #define SO_ARCH_SUFFIX "_amd64.so" - #else - #define SO_ARCH_SUFFIX ".so" - #endif - #endif -#endif - +// port.h: portability helper +// +////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "archtypes.h" // DAL + +#ifdef _WIN32 + + // Insert your headers here + #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + #define WIN32_EXTRA_LEAN + + #include "winsani_in.h" + #include + #include "winsani_out.h" + + #include + #include + #include + +#else // _WIN32 + + #include + #include + #include // exit() + #include // strncpy() + #include // tolower() + #include + #include + #include + #include + + typedef unsigned char BYTE; + + typedef int32 LONG; + //typedef uint32 ULONG; + + #ifndef ARCHTYPES_H + typedef uint32 ULONG; + #endif + + typedef void *HANDLE; + + #ifndef HMODULE + typedef void *HMODULE; + #endif + + typedef char * LPSTR; + + #define __cdecl + + + #ifdef __linux__ + typedef struct POINT_s + { + int x; + int y; + } POINT; + typedef void *HINSTANCE; + typedef void *HWND; + typedef void *HDC; + typedef void *HGLRC; + + typedef struct RECT_s + { + int left; + int right; + int top; + int bottom; + } RECT; + #endif + + + #ifdef __cplusplus + + //#undef FALSE + //#undef TRUE + + #ifdef OSX + //#else + //const bool FALSE = false; + //const bool TRUE = true; + #endif + #endif + + #ifndef NULL + #ifdef __cplusplus + #define NULL 0 + #else + #define NULL ((void *)0) + #endif + #endif + + #ifdef __cplusplus + inline int ioctlsocket( int d, int cmd, uint32 *argp ) { return ioctl( d, cmd, argp ); } + inline int closesocket( int fd ) { return close( fd ); } + inline char * GetCurrentDirectory( size_t size, char * buf ) { return getcwd( buf, size ); } + inline int WSAGetLastError() { return errno; } + + inline void DebugBreak( void ) { exit( 1 ); } + #endif + + extern char g_szEXEName[ 4096 ]; + + #define _snprintf snprintf + + #if defined(OSX) + #define SO_ARCH_SUFFIX ".dylib" + #else + #if defined ( __x86_64__ ) + #define SO_ARCH_SUFFIX "_amd64.so" + #else + #define SO_ARCH_SUFFIX ".so" + #endif + #endif +#endif + diff --git a/dep/rehlsdk/common/qfont.h b/dep/rehlsdk/common/qfont.h index 010b5be..2fc8129 100644 --- a/dep/rehlsdk/common/qfont.h +++ b/dep/rehlsdk/common/qfont.h @@ -1,41 +1,41 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( QFONTH ) -#define QFONTH -#ifdef _WIN32 -#pragma once -#endif - -// Font stuff - -#define NUM_GLYPHS 256 -// does not exist: // #include "basetypes.h" - -typedef struct -{ - short startoffset; - short charwidth; -} charinfo; - -typedef struct qfont_s -{ - int width, height; - int rowcount; - int rowheight; - charinfo fontinfo[ NUM_GLYPHS ]; - unsigned char data[4]; -} qfont_t; - -#endif // qfont.h +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#if !defined( QFONTH ) +#define QFONTH +#ifdef _WIN32 +#pragma once +#endif + +// Font stuff + +#define NUM_GLYPHS 256 +// does not exist: // #include "basetypes.h" + +typedef struct +{ + short startoffset; + short charwidth; +} charinfo; + +typedef struct qfont_s +{ + int width, height; + int rowcount; + int rowheight; + charinfo fontinfo[ NUM_GLYPHS ]; + unsigned char data[4]; +} qfont_t; + +#endif // qfont.h diff --git a/dep/rehlsdk/common/quakedef.h b/dep/rehlsdk/common/quakedef.h index 21f88e2..da0590e 100644 --- a/dep/rehlsdk/common/quakedef.h +++ b/dep/rehlsdk/common/quakedef.h @@ -1,41 +1,41 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -typedef int BOOL; - -// user message -#define MAX_USER_MSG_DATA 192 - -//moved to com_model.h -//typedef struct cache_user_s -//{ -// void *data; -//} cache_user_t; - -typedef int (*pfnUserMsgHook)(const char *, int, void *); +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ +#pragma once + +typedef int BOOL; + +// user message +#define MAX_USER_MSG_DATA 192 + +//moved to com_model.h +//typedef struct cache_user_s +//{ +// void *data; +//} cache_user_t; + +typedef int (*pfnUserMsgHook)(const char *, int, void *); diff --git a/dep/rehlsdk/common/r_efx.h b/dep/rehlsdk/common/r_efx.h index 1348175..4f7b806 100644 --- a/dep/rehlsdk/common/r_efx.h +++ b/dep/rehlsdk/common/r_efx.h @@ -1,197 +1,197 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined ( R_EFXH ) -#define R_EFXH -#ifdef _WIN32 -#pragma once -#endif - -// particle_t -#if !defined( PARTICLEDEFH ) -#include "particledef.h" -#endif - -// BEAM -#if !defined( BEAMDEFH ) -#include "beamdef.h" -#endif - -// dlight_t -#if !defined ( DLIGHTH ) -#include "dlight.h" -#endif - -// cl_entity_t -#if !defined( CL_ENTITYH ) -#include "cl_entity.h" -#endif - -/* -// FOR REFERENCE, These are the built-in tracer colors. Note, color 4 is the one -// that uses the tracerred/tracergreen/tracerblue and traceralpha cvar settings -color24 gTracerColors[] = -{ - { 255, 255, 255 }, // White - { 255, 0, 0 }, // Red - { 0, 255, 0 }, // Green - { 0, 0, 255 }, // Blue - { 0, 0, 0 }, // Tracer default, filled in from cvars, etc. - { 255, 167, 17 }, // Yellow-orange sparks - { 255, 130, 90 }, // Yellowish streaks (garg) - { 55, 60, 144 }, // Blue egon streak - { 255, 130, 90 }, // More Yellowish streaks (garg) - { 255, 140, 90 }, // More Yellowish streaks (garg) - { 200, 130, 90 }, // More red streaks (garg) - { 255, 120, 70 }, // Darker red streaks (garg) -}; -*/ - -// Temporary entity array -#define TENTPRIORITY_LOW 0 -#define TENTPRIORITY_HIGH 1 - -// TEMPENTITY flags -#define FTENT_NONE 0x00000000 -#define FTENT_SINEWAVE 0x00000001 -#define FTENT_GRAVITY 0x00000002 -#define FTENT_ROTATE 0x00000004 -#define FTENT_SLOWGRAVITY 0x00000008 -#define FTENT_SMOKETRAIL 0x00000010 -#define FTENT_COLLIDEWORLD 0x00000020 -#define FTENT_FLICKER 0x00000040 -#define FTENT_FADEOUT 0x00000080 -#define FTENT_SPRANIMATE 0x00000100 -#define FTENT_HITSOUND 0x00000200 -#define FTENT_SPIRAL 0x00000400 -#define FTENT_SPRCYCLE 0x00000800 -#define FTENT_COLLIDEALL 0x00001000 // will collide with world and slideboxes -#define FTENT_PERSIST 0x00002000 // tent is not removed when unable to draw -#define FTENT_COLLIDEKILL 0x00004000 // tent is removed upon collision with anything -#define FTENT_PLYRATTACHMENT 0x00008000 // tent is attached to a player (owner) -#define FTENT_SPRANIMATELOOP 0x00010000 // animating sprite doesn't die when last frame is displayed -#define FTENT_SPARKSHOWER 0x00020000 -#define FTENT_NOMODEL 0x00040000 // Doesn't have a model, never try to draw ( it just triggers other things ) -#define FTENT_CLIENTCUSTOM 0x00080000 // Must specify callback. Callback function is responsible for killing tempent and updating fields ( unless other flags specify how to do things ) - -typedef struct tempent_s -{ - int flags; - float die; - float frameMax; - float x; - float y; - float z; - float fadeSpeed; - float bounceFactor; - int hitSound; - void ( *hitcallback ) ( struct tempent_s *ent, struct pmtrace_s *ptr ); - void ( *callback ) ( struct tempent_s *ent, float frametime, float currenttime ); - struct tempent_s *next; - int priority; - short clientIndex; // if attached, this is the index of the client to stick to - // if COLLIDEALL, this is the index of the client to ignore - // TENTS with FTENT_PLYRATTACHMENT MUST set the clientindex! - - vec3_t tentOffset; // if attached, client origin + tentOffset = tent origin. - cl_entity_t entity; - - // baseline.origin - velocity - // baseline.renderamt - starting fadeout intensity - // baseline.angles - angle velocity -} TEMPENTITY; - -typedef struct efx_api_s efx_api_t; - -struct efx_api_s -{ - particle_t *( *R_AllocParticle ) ( void ( *callback ) ( struct particle_s *particle, float frametime ) ); - void ( *R_BlobExplosion ) ( float * org ); - void ( *R_Blood ) ( float * org, float * dir, int pcolor, int speed ); - void ( *R_BloodSprite ) ( float * org, int colorindex, int modelIndex, int modelIndex2, float size ); - void ( *R_BloodStream ) ( float * org, float * dir, int pcolor, int speed ); - void ( *R_BreakModel ) ( float *pos, float *size, float *dir, float random, float life, int count, int modelIndex, char flags ); - void ( *R_Bubbles ) ( float * mins, float * maxs, float height, int modelIndex, int count, float speed ); - void ( *R_BubbleTrail ) ( float * start, float * end, float height, int modelIndex, int count, float speed ); - void ( *R_BulletImpactParticles ) ( float * pos ); - void ( *R_EntityParticles ) ( struct cl_entity_s *ent ); - void ( *R_Explosion ) ( float *pos, int model, float scale, float framerate, int flags ); - void ( *R_FizzEffect ) ( struct cl_entity_s *pent, int modelIndex, int density ); - void ( *R_FireField ) ( float * org, int radius, int modelIndex, int count, int flags, float life ); - void ( *R_FlickerParticles ) ( float * org ); - void ( *R_FunnelSprite ) ( float *org, int modelIndex, int reverse ); - void ( *R_Implosion ) ( float * end, float radius, int count, float life ); - void ( *R_LargeFunnel ) ( float * org, int reverse ); - void ( *R_LavaSplash ) ( float * org ); - void ( *R_MultiGunshot ) ( float * org, float * dir, float * noise, int count, int decalCount, int *decalIndices ); - void ( *R_MuzzleFlash ) ( float *pos1, int type ); - void ( *R_ParticleBox ) ( float *mins, float *maxs, unsigned char r, unsigned char g, unsigned char b, float life ); - void ( *R_ParticleBurst ) ( float * pos, int size, int color, float life ); - void ( *R_ParticleExplosion ) ( float * org ); - void ( *R_ParticleExplosion2 ) ( float * org, int colorStart, int colorLength ); - void ( *R_ParticleLine ) ( float * start, float *end, unsigned char r, unsigned char g, unsigned char b, float life ); - void ( *R_PlayerSprites ) ( int client, int modelIndex, int count, int size ); - void ( *R_Projectile ) ( float * origin, float * velocity, int modelIndex, int life, int owner, void (*hitcallback)( struct tempent_s *ent, struct pmtrace_s *ptr ) ); - void ( *R_RicochetSound ) ( float * pos ); - void ( *R_RicochetSprite ) ( float *pos, struct model_s *pmodel, float duration, float scale ); - void ( *R_RocketFlare ) ( float *pos ); - void ( *R_RocketTrail ) ( float * start, float * end, int type ); - void ( *R_RunParticleEffect ) ( float * org, float * dir, int color, int count ); - void ( *R_ShowLine ) ( float * start, float * end ); - void ( *R_SparkEffect ) ( float *pos, int count, int velocityMin, int velocityMax ); - void ( *R_SparkShower ) ( float *pos ); - void ( *R_SparkStreaks ) ( float * pos, int count, int velocityMin, int velocityMax ); - void ( *R_Spray ) ( float * pos, float * dir, int modelIndex, int count, int speed, int spread, int rendermode ); - void ( *R_Sprite_Explode ) ( TEMPENTITY *pTemp, float scale, int flags ); - void ( *R_Sprite_Smoke ) ( TEMPENTITY *pTemp, float scale ); - void ( *R_Sprite_Spray ) ( float * pos, float * dir, int modelIndex, int count, int speed, int iRand ); - void ( *R_Sprite_Trail ) ( int type, float * start, float * end, int modelIndex, int count, float life, float size, float amplitude, int renderamt, float speed ); - void ( *R_Sprite_WallPuff ) ( TEMPENTITY *pTemp, float scale ); - void ( *R_StreakSplash ) ( float * pos, float * dir, int color, int count, float speed, int velocityMin, int velocityMax ); - void ( *R_TracerEffect ) ( float * start, float * end ); - void ( *R_UserTracerParticle ) ( float * org, float * vel, float life, int colorIndex, float length, unsigned char deathcontext, void ( *deathfunc)( struct particle_s *particle ) ); - particle_t *( *R_TracerParticles ) ( float * org, float * vel, float life ); - void ( *R_TeleportSplash ) ( float * org ); - void ( *R_TempSphereModel ) ( float *pos, float speed, float life, int count, int modelIndex ); - TEMPENTITY *( *R_TempModel ) ( float *pos, float *dir, float *angles, float life, int modelIndex, int soundtype ); - TEMPENTITY *( *R_DefaultSprite ) ( float *pos, int spriteIndex, float framerate ); - TEMPENTITY *( *R_TempSprite ) ( float *pos, float *dir, float scale, int modelIndex, int rendermode, int renderfx, float a, float life, int flags ); - int ( *Draw_DecalIndex ) ( int id ); - int ( *Draw_DecalIndexFromName ) ( char *name ); - void ( *R_DecalShoot ) ( int textureIndex, int entity, int modelIndex, float * position, int flags ); - void ( *R_AttachTentToPlayer ) ( int client, int modelIndex, float zoffset, float life ); - void ( *R_KillAttachedTents ) ( int client ); - BEAM *( *R_BeamCirclePoints ) ( int type, float * start, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); - BEAM *( *R_BeamEntPoint ) ( int startEnt, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); - BEAM *( *R_BeamEnts ) ( int startEnt, int endEnt, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); - BEAM *( *R_BeamFollow ) ( int startEnt, int modelIndex, float life, float width, float r, float g, float b, float brightness ); - void ( *R_BeamKill ) ( int deadEntity ); - BEAM *( *R_BeamLightning ) ( float * start, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed ); - BEAM *( *R_BeamPoints ) ( float * start, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); - BEAM *( *R_BeamRing ) ( int startEnt, int endEnt, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); - dlight_t *( *CL_AllocDlight ) ( int key ); - dlight_t *( *CL_AllocElight ) ( int key ); - TEMPENTITY *( *CL_TempEntAlloc ) ( float * org, struct model_s *model ); - TEMPENTITY *( *CL_TempEntAllocNoModel ) ( float * org ); - TEMPENTITY *( *CL_TempEntAllocHigh ) ( float * org, struct model_s *model ); - TEMPENTITY *( *CL_TentEntAllocCustom ) ( float *origin, struct model_s *model, int high, void ( *callback ) ( struct tempent_s *ent, float frametime, float currenttime ) ); - void ( *R_GetPackedColor ) ( short *packed, short color ); - short ( *R_LookupColor ) ( unsigned char r, unsigned char g, unsigned char b ); - void ( *R_DecalRemoveAll ) ( int textureIndex ); //textureIndex points to the decal index in the array, not the actual texture index. - void ( *R_FireCustomDecal ) ( int textureIndex, int entity, int modelIndex, float * position, int flags, float scale ); -}; - -extern efx_api_t efx; - -#endif +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#if !defined ( R_EFXH ) +#define R_EFXH +#ifdef _WIN32 +#pragma once +#endif + +// particle_t +#if !defined( PARTICLEDEFH ) +#include "particledef.h" +#endif + +// BEAM +#if !defined( BEAMDEFH ) +#include "beamdef.h" +#endif + +// dlight_t +#if !defined ( DLIGHTH ) +#include "dlight.h" +#endif + +// cl_entity_t +#if !defined( CL_ENTITYH ) +#include "cl_entity.h" +#endif + +/* +// FOR REFERENCE, These are the built-in tracer colors. Note, color 4 is the one +// that uses the tracerred/tracergreen/tracerblue and traceralpha cvar settings +color24 gTracerColors[] = +{ + { 255, 255, 255 }, // White + { 255, 0, 0 }, // Red + { 0, 255, 0 }, // Green + { 0, 0, 255 }, // Blue + { 0, 0, 0 }, // Tracer default, filled in from cvars, etc. + { 255, 167, 17 }, // Yellow-orange sparks + { 255, 130, 90 }, // Yellowish streaks (garg) + { 55, 60, 144 }, // Blue egon streak + { 255, 130, 90 }, // More Yellowish streaks (garg) + { 255, 140, 90 }, // More Yellowish streaks (garg) + { 200, 130, 90 }, // More red streaks (garg) + { 255, 120, 70 }, // Darker red streaks (garg) +}; +*/ + +// Temporary entity array +#define TENTPRIORITY_LOW 0 +#define TENTPRIORITY_HIGH 1 + +// TEMPENTITY flags +#define FTENT_NONE 0x00000000 +#define FTENT_SINEWAVE 0x00000001 +#define FTENT_GRAVITY 0x00000002 +#define FTENT_ROTATE 0x00000004 +#define FTENT_SLOWGRAVITY 0x00000008 +#define FTENT_SMOKETRAIL 0x00000010 +#define FTENT_COLLIDEWORLD 0x00000020 +#define FTENT_FLICKER 0x00000040 +#define FTENT_FADEOUT 0x00000080 +#define FTENT_SPRANIMATE 0x00000100 +#define FTENT_HITSOUND 0x00000200 +#define FTENT_SPIRAL 0x00000400 +#define FTENT_SPRCYCLE 0x00000800 +#define FTENT_COLLIDEALL 0x00001000 // will collide with world and slideboxes +#define FTENT_PERSIST 0x00002000 // tent is not removed when unable to draw +#define FTENT_COLLIDEKILL 0x00004000 // tent is removed upon collision with anything +#define FTENT_PLYRATTACHMENT 0x00008000 // tent is attached to a player (owner) +#define FTENT_SPRANIMATELOOP 0x00010000 // animating sprite doesn't die when last frame is displayed +#define FTENT_SPARKSHOWER 0x00020000 +#define FTENT_NOMODEL 0x00040000 // Doesn't have a model, never try to draw ( it just triggers other things ) +#define FTENT_CLIENTCUSTOM 0x00080000 // Must specify callback. Callback function is responsible for killing tempent and updating fields ( unless other flags specify how to do things ) + +typedef struct tempent_s +{ + int flags; + float die; + float frameMax; + float x; + float y; + float z; + float fadeSpeed; + float bounceFactor; + int hitSound; + void ( *hitcallback ) ( struct tempent_s *ent, struct pmtrace_s *ptr ); + void ( *callback ) ( struct tempent_s *ent, float frametime, float currenttime ); + struct tempent_s *next; + int priority; + short clientIndex; // if attached, this is the index of the client to stick to + // if COLLIDEALL, this is the index of the client to ignore + // TENTS with FTENT_PLYRATTACHMENT MUST set the clientindex! + + vec3_t tentOffset; // if attached, client origin + tentOffset = tent origin. + cl_entity_t entity; + + // baseline.origin - velocity + // baseline.renderamt - starting fadeout intensity + // baseline.angles - angle velocity +} TEMPENTITY; + +typedef struct efx_api_s efx_api_t; + +struct efx_api_s +{ + particle_t *( *R_AllocParticle ) ( void ( *callback ) ( struct particle_s *particle, float frametime ) ); + void ( *R_BlobExplosion ) ( float * org ); + void ( *R_Blood ) ( float * org, float * dir, int pcolor, int speed ); + void ( *R_BloodSprite ) ( float * org, int colorindex, int modelIndex, int modelIndex2, float size ); + void ( *R_BloodStream ) ( float * org, float * dir, int pcolor, int speed ); + void ( *R_BreakModel ) ( float *pos, float *size, float *dir, float random, float life, int count, int modelIndex, char flags ); + void ( *R_Bubbles ) ( float * mins, float * maxs, float height, int modelIndex, int count, float speed ); + void ( *R_BubbleTrail ) ( float * start, float * end, float height, int modelIndex, int count, float speed ); + void ( *R_BulletImpactParticles ) ( float * pos ); + void ( *R_EntityParticles ) ( struct cl_entity_s *ent ); + void ( *R_Explosion ) ( float *pos, int model, float scale, float framerate, int flags ); + void ( *R_FizzEffect ) ( struct cl_entity_s *pent, int modelIndex, int density ); + void ( *R_FireField ) ( float * org, int radius, int modelIndex, int count, int flags, float life ); + void ( *R_FlickerParticles ) ( float * org ); + void ( *R_FunnelSprite ) ( float *org, int modelIndex, int reverse ); + void ( *R_Implosion ) ( float * end, float radius, int count, float life ); + void ( *R_LargeFunnel ) ( float * org, int reverse ); + void ( *R_LavaSplash ) ( float * org ); + void ( *R_MultiGunshot ) ( float * org, float * dir, float * noise, int count, int decalCount, int *decalIndices ); + void ( *R_MuzzleFlash ) ( float *pos1, int type ); + void ( *R_ParticleBox ) ( float *mins, float *maxs, unsigned char r, unsigned char g, unsigned char b, float life ); + void ( *R_ParticleBurst ) ( float * pos, int size, int color, float life ); + void ( *R_ParticleExplosion ) ( float * org ); + void ( *R_ParticleExplosion2 ) ( float * org, int colorStart, int colorLength ); + void ( *R_ParticleLine ) ( float * start, float *end, unsigned char r, unsigned char g, unsigned char b, float life ); + void ( *R_PlayerSprites ) ( int client, int modelIndex, int count, int size ); + void ( *R_Projectile ) ( float * origin, float * velocity, int modelIndex, int life, int owner, void (*hitcallback)( struct tempent_s *ent, struct pmtrace_s *ptr ) ); + void ( *R_RicochetSound ) ( float * pos ); + void ( *R_RicochetSprite ) ( float *pos, struct model_s *pmodel, float duration, float scale ); + void ( *R_RocketFlare ) ( float *pos ); + void ( *R_RocketTrail ) ( float * start, float * end, int type ); + void ( *R_RunParticleEffect ) ( float * org, float * dir, int color, int count ); + void ( *R_ShowLine ) ( float * start, float * end ); + void ( *R_SparkEffect ) ( float *pos, int count, int velocityMin, int velocityMax ); + void ( *R_SparkShower ) ( float *pos ); + void ( *R_SparkStreaks ) ( float * pos, int count, int velocityMin, int velocityMax ); + void ( *R_Spray ) ( float * pos, float * dir, int modelIndex, int count, int speed, int spread, int rendermode ); + void ( *R_Sprite_Explode ) ( TEMPENTITY *pTemp, float scale, int flags ); + void ( *R_Sprite_Smoke ) ( TEMPENTITY *pTemp, float scale ); + void ( *R_Sprite_Spray ) ( float * pos, float * dir, int modelIndex, int count, int speed, int iRand ); + void ( *R_Sprite_Trail ) ( int type, float * start, float * end, int modelIndex, int count, float life, float size, float amplitude, int renderamt, float speed ); + void ( *R_Sprite_WallPuff ) ( TEMPENTITY *pTemp, float scale ); + void ( *R_StreakSplash ) ( float * pos, float * dir, int color, int count, float speed, int velocityMin, int velocityMax ); + void ( *R_TracerEffect ) ( float * start, float * end ); + void ( *R_UserTracerParticle ) ( float * org, float * vel, float life, int colorIndex, float length, unsigned char deathcontext, void ( *deathfunc)( struct particle_s *particle ) ); + particle_t *( *R_TracerParticles ) ( float * org, float * vel, float life ); + void ( *R_TeleportSplash ) ( float * org ); + void ( *R_TempSphereModel ) ( float *pos, float speed, float life, int count, int modelIndex ); + TEMPENTITY *( *R_TempModel ) ( float *pos, float *dir, float *angles, float life, int modelIndex, int soundtype ); + TEMPENTITY *( *R_DefaultSprite ) ( float *pos, int spriteIndex, float framerate ); + TEMPENTITY *( *R_TempSprite ) ( float *pos, float *dir, float scale, int modelIndex, int rendermode, int renderfx, float a, float life, int flags ); + int ( *Draw_DecalIndex ) ( int id ); + int ( *Draw_DecalIndexFromName ) ( char *name ); + void ( *R_DecalShoot ) ( int textureIndex, int entity, int modelIndex, float * position, int flags ); + void ( *R_AttachTentToPlayer ) ( int client, int modelIndex, float zoffset, float life ); + void ( *R_KillAttachedTents ) ( int client ); + BEAM *( *R_BeamCirclePoints ) ( int type, float * start, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); + BEAM *( *R_BeamEntPoint ) ( int startEnt, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); + BEAM *( *R_BeamEnts ) ( int startEnt, int endEnt, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); + BEAM *( *R_BeamFollow ) ( int startEnt, int modelIndex, float life, float width, float r, float g, float b, float brightness ); + void ( *R_BeamKill ) ( int deadEntity ); + BEAM *( *R_BeamLightning ) ( float * start, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed ); + BEAM *( *R_BeamPoints ) ( float * start, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); + BEAM *( *R_BeamRing ) ( int startEnt, int endEnt, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b ); + dlight_t *( *CL_AllocDlight ) ( int key ); + dlight_t *( *CL_AllocElight ) ( int key ); + TEMPENTITY *( *CL_TempEntAlloc ) ( float * org, struct model_s *model ); + TEMPENTITY *( *CL_TempEntAllocNoModel ) ( float * org ); + TEMPENTITY *( *CL_TempEntAllocHigh ) ( float * org, struct model_s *model ); + TEMPENTITY *( *CL_TentEntAllocCustom ) ( float *origin, struct model_s *model, int high, void ( *callback ) ( struct tempent_s *ent, float frametime, float currenttime ) ); + void ( *R_GetPackedColor ) ( short *packed, short color ); + short ( *R_LookupColor ) ( unsigned char r, unsigned char g, unsigned char b ); + void ( *R_DecalRemoveAll ) ( int textureIndex ); //textureIndex points to the decal index in the array, not the actual texture index. + void ( *R_FireCustomDecal ) ( int textureIndex, int entity, int modelIndex, float * position, int flags, float scale ); +}; + +extern efx_api_t efx; + +#endif diff --git a/dep/rehlsdk/common/r_studioint.h b/dep/rehlsdk/common/r_studioint.h index bbe105b..2ddf012 100644 --- a/dep/rehlsdk/common/r_studioint.h +++ b/dep/rehlsdk/common/r_studioint.h @@ -1,151 +1,151 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#if !defined( R_STUDIOINT_H ) -#define R_STUDIOINT_H -#if defined( _WIN32 ) -#pragma once -#endif - -#define STUDIO_INTERFACE_VERSION 1 - -typedef struct engine_studio_api_s -{ - // Allocate number*size bytes and zero it - void *( *Mem_Calloc ) ( int number, size_t size ); - // Check to see if pointer is in the cache - void *( *Cache_Check ) ( struct cache_user_s *c ); - // Load file into cache ( can be swapped out on demand ) - void ( *LoadCacheFile ) ( char *path, struct cache_user_s *cu ); - // Retrieve model pointer for the named model - struct model_s *( *Mod_ForName ) ( const char *name, int crash_if_missing ); - // Retrieve pointer to studio model data block from a model - void *( *Mod_Extradata ) ( struct model_s *mod ); - // Retrieve indexed model from client side model precache list - struct model_s *( *GetModelByIndex ) ( int index ); - // Get entity that is set for rendering - struct cl_entity_s * ( *GetCurrentEntity ) ( void ); - // Get referenced player_info_t - struct player_info_s *( *PlayerInfo ) ( int index ); - // Get most recently received player state data from network system - struct entity_state_s *( *GetPlayerState ) ( int index ); - // Get viewentity - struct cl_entity_s * ( *GetViewEntity ) ( void ); - // Get current frame count, and last two timestampes on client - void ( *GetTimes ) ( int *framecount, double *current, double *old ); - // Get a pointer to a cvar by name - struct cvar_s *( *GetCvar ) ( const char *name ); - // Get current render origin and view vectors ( up, right and vpn ) - void ( *GetViewInfo ) ( float *origin, float *upv, float *rightv, float *vpnv ); - // Get sprite model used for applying chrome effect - struct model_s *( *GetChromeSprite ) ( void ); - // Get model counters so we can incement instrumentation - void ( *GetModelCounters ) ( int **s, int **a ); - // Get software scaling coefficients - void ( *GetAliasScale ) ( float *x, float *y ); - - // Get bone, light, alias, and rotation matrices - float ****( *StudioGetBoneTransform ) ( void ); - float ****( *StudioGetLightTransform )( void ); - float ***( *StudioGetAliasTransform ) ( void ); - float ***( *StudioGetRotationMatrix ) ( void ); - - // Set up body part, and get submodel pointers - void ( *StudioSetupModel ) ( int bodypart, void **ppbodypart, void **ppsubmodel ); - // Check if entity's bbox is in the view frustum - int ( *StudioCheckBBox ) ( void ); - // Apply lighting effects to model - void ( *StudioDynamicLight ) ( struct cl_entity_s *ent, struct alight_s *plight ); - void ( *StudioEntityLight ) ( struct alight_s *plight ); - void ( *StudioSetupLighting ) ( struct alight_s *plighting ); - - // Draw mesh vertices - void ( *StudioDrawPoints ) ( void ); - - // Draw hulls around bones - void ( *StudioDrawHulls ) ( void ); - // Draw bbox around studio models - void ( *StudioDrawAbsBBox ) ( void ); - // Draws bones - void ( *StudioDrawBones ) ( void ); - // Loads in appropriate texture for model - void ( *StudioSetupSkin ) ( void *ptexturehdr, int index ); - // Sets up for remapped colors - void ( *StudioSetRemapColors ) ( int top, int bottom ); - // Set's player model and returns model pointer - struct model_s *( *SetupPlayerModel ) ( int index ); - // Fires any events embedded in animation - void ( *StudioClientEvents ) ( void ); - // Retrieve/set forced render effects flags - int ( *GetForceFaceFlags ) ( void ); - void ( *SetForceFaceFlags ) ( int flags ); - // Tell engine the value of the studio model header - void ( *StudioSetHeader ) ( void *header ); - // Tell engine which model_t * is being renderered - void ( *SetRenderModel ) ( struct model_s *model ); - - // Final state setup and restore for rendering - void ( *SetupRenderer ) ( int rendermode ); - void ( *RestoreRenderer ) ( void ); - - // Set render origin for applying chrome effect - void ( *SetChromeOrigin ) ( void ); - - // True if using D3D/OpenGL - int ( *IsHardware ) ( void ); - - // Only called by hardware interface - void ( *GL_StudioDrawShadow ) ( void ); - void ( *GL_SetRenderMode ) ( int mode ); - - void ( *StudioSetRenderamt ) (int iRenderamt); //!!!CZERO added for rendering glass on viewmodels - void ( *StudioSetCullState ) ( int iCull ); - void ( *StudioRenderShadow ) ( int iSprite, float *p1, float *p2, float *p3, float *p4 ); -} engine_studio_api_t; - -typedef struct server_studio_api_s -{ - // Allocate number*size bytes and zero it - void *( *Mem_Calloc ) ( int number, size_t size ); - // Check to see if pointer is in the cache - void *( *Cache_Check ) ( struct cache_user_s *c ); - // Load file into cache ( can be swapped out on demand ) - void ( *LoadCacheFile ) ( char *path, struct cache_user_s *cu ); - // Retrieve pointer to studio model data block from a model - void *( *Mod_Extradata ) ( struct model_s *mod ); -} server_studio_api_t; - - -// client blending -typedef struct r_studio_interface_s -{ - int version; - int ( *StudioDrawModel ) ( int flags ); - int ( *StudioDrawPlayer ) ( int flags, struct entity_state_s *pplayer ); -} r_studio_interface_t; - -extern r_studio_interface_t *pStudioAPI; - -// server blending -#define SV_BLENDING_INTERFACE_VERSION 1 - -typedef struct sv_blending_interface_s -{ - int version; - - void ( *SV_StudioSetupBones )( struct model_s *pModel, - float frame, - int sequence, - const vec3_t angles, - const vec3_t origin, - const byte *pcontroller, - const byte *pblending, - int iBone, - const edict_t *pEdict ); -} sv_blending_interface_t; - -#endif // R_STUDIOINT_H +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#if !defined( R_STUDIOINT_H ) +#define R_STUDIOINT_H +#if defined( _WIN32 ) +#pragma once +#endif + +#define STUDIO_INTERFACE_VERSION 1 + +typedef struct engine_studio_api_s +{ + // Allocate number*size bytes and zero it + void *( *Mem_Calloc ) ( int number, size_t size ); + // Check to see if pointer is in the cache + void *( *Cache_Check ) ( struct cache_user_s *c ); + // Load file into cache ( can be swapped out on demand ) + void ( *LoadCacheFile ) ( char *path, struct cache_user_s *cu ); + // Retrieve model pointer for the named model + struct model_s *( *Mod_ForName ) ( const char *name, int crash_if_missing ); + // Retrieve pointer to studio model data block from a model + void *( *Mod_Extradata ) ( struct model_s *mod ); + // Retrieve indexed model from client side model precache list + struct model_s *( *GetModelByIndex ) ( int index ); + // Get entity that is set for rendering + struct cl_entity_s * ( *GetCurrentEntity ) ( void ); + // Get referenced player_info_t + struct player_info_s *( *PlayerInfo ) ( int index ); + // Get most recently received player state data from network system + struct entity_state_s *( *GetPlayerState ) ( int index ); + // Get viewentity + struct cl_entity_s * ( *GetViewEntity ) ( void ); + // Get current frame count, and last two timestampes on client + void ( *GetTimes ) ( int *framecount, double *current, double *old ); + // Get a pointer to a cvar by name + struct cvar_s *( *GetCvar ) ( const char *name ); + // Get current render origin and view vectors ( up, right and vpn ) + void ( *GetViewInfo ) ( float *origin, float *upv, float *rightv, float *vpnv ); + // Get sprite model used for applying chrome effect + struct model_s *( *GetChromeSprite ) ( void ); + // Get model counters so we can incement instrumentation + void ( *GetModelCounters ) ( int **s, int **a ); + // Get software scaling coefficients + void ( *GetAliasScale ) ( float *x, float *y ); + + // Get bone, light, alias, and rotation matrices + float ****( *StudioGetBoneTransform ) ( void ); + float ****( *StudioGetLightTransform )( void ); + float ***( *StudioGetAliasTransform ) ( void ); + float ***( *StudioGetRotationMatrix ) ( void ); + + // Set up body part, and get submodel pointers + void ( *StudioSetupModel ) ( int bodypart, void **ppbodypart, void **ppsubmodel ); + // Check if entity's bbox is in the view frustum + int ( *StudioCheckBBox ) ( void ); + // Apply lighting effects to model + void ( *StudioDynamicLight ) ( struct cl_entity_s *ent, struct alight_s *plight ); + void ( *StudioEntityLight ) ( struct alight_s *plight ); + void ( *StudioSetupLighting ) ( struct alight_s *plighting ); + + // Draw mesh vertices + void ( *StudioDrawPoints ) ( void ); + + // Draw hulls around bones + void ( *StudioDrawHulls ) ( void ); + // Draw bbox around studio models + void ( *StudioDrawAbsBBox ) ( void ); + // Draws bones + void ( *StudioDrawBones ) ( void ); + // Loads in appropriate texture for model + void ( *StudioSetupSkin ) ( void *ptexturehdr, int index ); + // Sets up for remapped colors + void ( *StudioSetRemapColors ) ( int top, int bottom ); + // Set's player model and returns model pointer + struct model_s *( *SetupPlayerModel ) ( int index ); + // Fires any events embedded in animation + void ( *StudioClientEvents ) ( void ); + // Retrieve/set forced render effects flags + int ( *GetForceFaceFlags ) ( void ); + void ( *SetForceFaceFlags ) ( int flags ); + // Tell engine the value of the studio model header + void ( *StudioSetHeader ) ( void *header ); + // Tell engine which model_t * is being renderered + void ( *SetRenderModel ) ( struct model_s *model ); + + // Final state setup and restore for rendering + void ( *SetupRenderer ) ( int rendermode ); + void ( *RestoreRenderer ) ( void ); + + // Set render origin for applying chrome effect + void ( *SetChromeOrigin ) ( void ); + + // True if using D3D/OpenGL + int ( *IsHardware ) ( void ); + + // Only called by hardware interface + void ( *GL_StudioDrawShadow ) ( void ); + void ( *GL_SetRenderMode ) ( int mode ); + + void ( *StudioSetRenderamt ) (int iRenderamt); //!!!CZERO added for rendering glass on viewmodels + void ( *StudioSetCullState ) ( int iCull ); + void ( *StudioRenderShadow ) ( int iSprite, float *p1, float *p2, float *p3, float *p4 ); +} engine_studio_api_t; + +typedef struct server_studio_api_s +{ + // Allocate number*size bytes and zero it + void *( *Mem_Calloc ) ( int number, size_t size ); + // Check to see if pointer is in the cache + void *( *Cache_Check ) ( struct cache_user_s *c ); + // Load file into cache ( can be swapped out on demand ) + void ( *LoadCacheFile ) ( char *path, struct cache_user_s *cu ); + // Retrieve pointer to studio model data block from a model + void *( *Mod_Extradata ) ( struct model_s *mod ); +} server_studio_api_t; + + +// client blending +typedef struct r_studio_interface_s +{ + int version; + int ( *StudioDrawModel ) ( int flags ); + int ( *StudioDrawPlayer ) ( int flags, struct entity_state_s *pplayer ); +} r_studio_interface_t; + +extern r_studio_interface_t *pStudioAPI; + +// server blending +#define SV_BLENDING_INTERFACE_VERSION 1 + +typedef struct sv_blending_interface_s +{ + int version; + + void ( *SV_StudioSetupBones )( struct model_s *pModel, + float frame, + int sequence, + const vec3_t angles, + const vec3_t origin, + const byte *pcontroller, + const byte *pblending, + int iBone, + const edict_t *pEdict ); +} sv_blending_interface_t; + +#endif // R_STUDIOINT_H diff --git a/dep/rehlsdk/common/ref_params.h b/dep/rehlsdk/common/ref_params.h index 10e8837..90eb03f 100644 --- a/dep/rehlsdk/common/ref_params.h +++ b/dep/rehlsdk/common/ref_params.h @@ -1,75 +1,75 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( REF_PARAMSH ) -#define REF_PARAMSH - -typedef struct ref_params_s -{ - // Output - float vieworg[3]; - float viewangles[3]; - - float forward[3]; - float right[3]; - float up[3]; - - // Client frametime; - float frametime; - // Client time - float time; - - // Misc - int intermission; - int paused; - int spectator; - int onground; - int waterlevel; - - float simvel[3]; - float simorg[3]; - - float viewheight[3]; - float idealpitch; - - float cl_viewangles[3]; - - int health; - float crosshairangle[3]; - float viewsize; - - float punchangle[3]; - int maxclients; - int viewentity; - int playernum; - int max_entities; - int demoplayback; - int hardware; - - int smoothing; - - // Last issued usercmd - struct usercmd_s *cmd; - - // Movevars - struct movevars_s *movevars; - - int viewport[4]; // the viewport coordinates x ,y , width, height - - int nextView; // the renderer calls ClientDLL_CalcRefdef() and Renderview - // so long in cycles until this value is 0 (multiple views) - int onlyClientDraw; // if !=0 nothing is drawn by the engine except clientDraw functions -} ref_params_t; - -#endif // !REF_PARAMSH +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#if !defined( REF_PARAMSH ) +#define REF_PARAMSH + +typedef struct ref_params_s +{ + // Output + float vieworg[3]; + float viewangles[3]; + + float forward[3]; + float right[3]; + float up[3]; + + // Client frametime; + float frametime; + // Client time + float time; + + // Misc + int intermission; + int paused; + int spectator; + int onground; + int waterlevel; + + float simvel[3]; + float simorg[3]; + + float viewheight[3]; + float idealpitch; + + float cl_viewangles[3]; + + int health; + float crosshairangle[3]; + float viewsize; + + float punchangle[3]; + int maxclients; + int viewentity; + int playernum; + int max_entities; + int demoplayback; + int hardware; + + int smoothing; + + // Last issued usercmd + struct usercmd_s *cmd; + + // Movevars + struct movevars_s *movevars; + + int viewport[4]; // the viewport coordinates x ,y , width, height + + int nextView; // the renderer calls ClientDLL_CalcRefdef() and Renderview + // so long in cycles until this value is 0 (multiple views) + int onlyClientDraw; // if !=0 nothing is drawn by the engine except clientDraw functions +} ref_params_t; + +#endif // !REF_PARAMSH diff --git a/dep/rehlsdk/common/screenfade.h b/dep/rehlsdk/common/screenfade.h index d1d7126..62c0d25 100644 --- a/dep/rehlsdk/common/screenfade.h +++ b/dep/rehlsdk/common/screenfade.h @@ -1,24 +1,24 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#if !defined( SCREENFADEH ) -#define SCREENFADEH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct screenfade_s -{ - float fadeSpeed; // How fast to fade (tics / second) (+ fade in, - fade out) - float fadeEnd; // When the fading hits maximum - float fadeTotalEnd; // Total End Time of the fade (used for FFADE_OUT) - float fadeReset; // When to reset to not fading (for fadeout and hold) - byte fader, fadeg, fadeb, fadealpha; // Fade color - int fadeFlags; // Fading flags -} screenfade_t; - -#endif // !SCREENFADEH +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#if !defined( SCREENFADEH ) +#define SCREENFADEH +#ifdef _WIN32 +#pragma once +#endif + +typedef struct screenfade_s +{ + float fadeSpeed; // How fast to fade (tics / second) (+ fade in, - fade out) + float fadeEnd; // When the fading hits maximum + float fadeTotalEnd; // Total End Time of the fade (used for FFADE_OUT) + float fadeReset; // When to reset to not fading (for fadeout and hold) + byte fader, fadeg, fadeb, fadealpha; // Fade color + int fadeFlags; // Fading flags +} screenfade_t; + +#endif // !SCREENFADEH diff --git a/dep/rehlsdk/common/studio_event.h b/dep/rehlsdk/common/studio_event.h index 5ecf24f..c79c210 100644 --- a/dep/rehlsdk/common/studio_event.h +++ b/dep/rehlsdk/common/studio_event.h @@ -1,29 +1,29 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( STUDIO_EVENTH ) -#define STUDIO_EVENTH -#ifdef _WIN32 -#pragma once -#endif - -typedef struct mstudioevent_s -{ - int frame; - int event; - int type; - char options[64]; -} mstudioevent_t; - -#endif // STUDIO_EVENTH +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#if !defined( STUDIO_EVENTH ) +#define STUDIO_EVENTH +#ifdef _WIN32 +#pragma once +#endif + +typedef struct mstudioevent_s +{ + int frame; + int event; + int type; + char options[64]; +} mstudioevent_t; + +#endif // STUDIO_EVENTH diff --git a/dep/rehlsdk/common/triangleapi.h b/dep/rehlsdk/common/triangleapi.h index db2d849..069a4d6 100644 --- a/dep/rehlsdk/common/triangleapi.h +++ b/dep/rehlsdk/common/triangleapi.h @@ -1,64 +1,64 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( TRIANGLEAPIH ) -#define TRIANGLEAPIH -#ifdef _WIN32 -#pragma once -#endif - -typedef enum -{ - TRI_FRONT = 0, - TRI_NONE = 1, -} TRICULLSTYLE; - -#define TRI_API_VERSION 1 - -#define TRI_TRIANGLES 0 -#define TRI_TRIANGLE_FAN 1 -#define TRI_QUADS 2 -#define TRI_POLYGON 3 -#define TRI_LINES 4 -#define TRI_TRIANGLE_STRIP 5 -#define TRI_QUAD_STRIP 6 - -typedef struct triangleapi_s -{ - int version; - - void ( *RenderMode )( int mode ); - void ( *Begin )( int primitiveCode ); - void ( *End ) ( void ); - - void ( *Color4f ) ( float r, float g, float b, float a ); - void ( *Color4ub ) ( unsigned char r, unsigned char g, unsigned char b, unsigned char a ); - void ( *TexCoord2f ) ( float u, float v ); - void ( *Vertex3fv ) ( float *worldPnt ); - void ( *Vertex3f ) ( float x, float y, float z ); - void ( *Brightness ) ( float brightness ); - void ( *CullFace ) ( TRICULLSTYLE style ); - int ( *SpriteTexture ) ( struct model_s *pSpriteModel, int frame ); - int ( *WorldToScreen ) ( float *world, float *screen ); // Returns 1 if it's z clipped - void ( *Fog ) ( float flFogColor[3], float flStart, float flEnd, int bOn ); // Works just like GL_FOG, flFogColor is r/g/b. - void ( *ScreenToWorld ) ( float *screen, float *world ); - void ( *GetMatrix ) ( const int pname, float *matrix ); - int ( *BoxInPVS ) ( float *mins, float *maxs ); - void ( *LightAtPoint ) ( float *pos, float *value ); - void ( *Color4fRendermode ) ( float r, float g, float b, float a, int rendermode ); - void ( *FogParams ) ( float flDensity, int iFogSkybox ); // Used with Fog()...sets fog density and whether the fog should be applied to the skybox - -} triangleapi_t; - -#endif // !TRIANGLEAPIH +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#if !defined( TRIANGLEAPIH ) +#define TRIANGLEAPIH +#ifdef _WIN32 +#pragma once +#endif + +typedef enum +{ + TRI_FRONT = 0, + TRI_NONE = 1, +} TRICULLSTYLE; + +#define TRI_API_VERSION 1 + +#define TRI_TRIANGLES 0 +#define TRI_TRIANGLE_FAN 1 +#define TRI_QUADS 2 +#define TRI_POLYGON 3 +#define TRI_LINES 4 +#define TRI_TRIANGLE_STRIP 5 +#define TRI_QUAD_STRIP 6 + +typedef struct triangleapi_s +{ + int version; + + void ( *RenderMode )( int mode ); + void ( *Begin )( int primitiveCode ); + void ( *End ) ( void ); + + void ( *Color4f ) ( float r, float g, float b, float a ); + void ( *Color4ub ) ( unsigned char r, unsigned char g, unsigned char b, unsigned char a ); + void ( *TexCoord2f ) ( float u, float v ); + void ( *Vertex3fv ) ( float *worldPnt ); + void ( *Vertex3f ) ( float x, float y, float z ); + void ( *Brightness ) ( float brightness ); + void ( *CullFace ) ( TRICULLSTYLE style ); + int ( *SpriteTexture ) ( struct model_s *pSpriteModel, int frame ); + int ( *WorldToScreen ) ( float *world, float *screen ); // Returns 1 if it's z clipped + void ( *Fog ) ( float flFogColor[3], float flStart, float flEnd, int bOn ); // Works just like GL_FOG, flFogColor is r/g/b. + void ( *ScreenToWorld ) ( float *screen, float *world ); + void ( *GetMatrix ) ( const int pname, float *matrix ); + int ( *BoxInPVS ) ( float *mins, float *maxs ); + void ( *LightAtPoint ) ( float *pos, float *value ); + void ( *Color4fRendermode ) ( float r, float g, float b, float a, int rendermode ); + void ( *FogParams ) ( float flDensity, int iFogSkybox ); // Used with Fog()...sets fog density and whether the fog should be applied to the skybox + +} triangleapi_t; + +#endif // !TRIANGLEAPIH diff --git a/dep/rehlsdk/common/usercmd.h b/dep/rehlsdk/common/usercmd.h index ab88ddb..7cdcfe2 100644 --- a/dep/rehlsdk/common/usercmd.h +++ b/dep/rehlsdk/common/usercmd.h @@ -1,41 +1,41 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef USERCMD_H -#define USERCMD_H -#ifdef _WIN32 -#pragma once -#endif - -typedef struct usercmd_s -{ - short lerp_msec; // Interpolation time on client - byte msec; // Duration in ms of command - vec3_t viewangles; // Command view angles. - -// intended velocities - float forwardmove; // Forward velocity. - float sidemove; // Sideways velocity. - float upmove; // Upward velocity. - byte lightlevel; // Light level at spot where we are standing. - unsigned short buttons; // Attack buttons - byte impulse; // Impulse command issued. - byte weaponselect; // Current weapon id - -// Experimental player impact stuff. - int impact_index; - vec3_t impact_position; -} usercmd_t; - -#endif // USERCMD_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef USERCMD_H +#define USERCMD_H +#ifdef _WIN32 +#pragma once +#endif + +typedef struct usercmd_s +{ + short lerp_msec; // Interpolation time on client + byte msec; // Duration in ms of command + vec3_t viewangles; // Command view angles. + +// intended velocities + float forwardmove; // Forward velocity. + float sidemove; // Sideways velocity. + float upmove; // Upward velocity. + byte lightlevel; // Light level at spot where we are standing. + unsigned short buttons; // Attack buttons + byte impulse; // Impulse command issued. + byte weaponselect; // Current weapon id + +// Experimental player impact stuff. + int impact_index; + vec3_t impact_position; +} usercmd_t; + +#endif // USERCMD_H diff --git a/dep/rehlsdk/common/vmodes.h b/dep/rehlsdk/common/vmodes.h index 7714765..9765bca 100644 --- a/dep/rehlsdk/common/vmodes.h +++ b/dep/rehlsdk/common/vmodes.h @@ -1,33 +1,33 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -typedef struct rect_s -{ - int left, right, top, bottom; -} wrect_t; +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ +#pragma once + +typedef struct rect_s +{ + int left, right, top, bottom; +} wrect_t; diff --git a/dep/rehlsdk/common/weaponinfo.h b/dep/rehlsdk/common/weaponinfo.h index 5a601ba..251a096 100644 --- a/dep/rehlsdk/common/weaponinfo.h +++ b/dep/rehlsdk/common/weaponinfo.h @@ -1,53 +1,53 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#ifndef WEAPONINFO_H -#define WEAPONINFO_H -#ifdef _WIN32 -#pragma once -#endif - -// Info about weapons player might have in his/her possession -typedef struct weapon_data_s -{ - int m_iId; - int m_iClip; - - float m_flNextPrimaryAttack; - float m_flNextSecondaryAttack; - float m_flTimeWeaponIdle; - - int m_fInReload; - int m_fInSpecialReload; - float m_flNextReload; - float m_flPumpTime; - float m_fReloadTime; - - float m_fAimedDamage; - float m_fNextAimBonus; - int m_fInZoom; - int m_iWeaponState; - - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; -} weapon_data_t; - -#endif // WEAPONINFO_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +#ifndef WEAPONINFO_H +#define WEAPONINFO_H +#ifdef _WIN32 +#pragma once +#endif + +// Info about weapons player might have in his/her possession +typedef struct weapon_data_s +{ + int m_iId; + int m_iClip; + + float m_flNextPrimaryAttack; + float m_flNextSecondaryAttack; + float m_flTimeWeaponIdle; + + int m_fInReload; + int m_fInSpecialReload; + float m_flNextReload; + float m_flPumpTime; + float m_fReloadTime; + + float m_fAimedDamage; + float m_fNextAimBonus; + int m_fInZoom; + int m_iWeaponState; + + int iuser1; + int iuser2; + int iuser3; + int iuser4; + float fuser1; + float fuser2; + float fuser3; + float fuser4; +} weapon_data_t; + +#endif // WEAPONINFO_H diff --git a/dep/rehlsdk/common/winsani_in.h b/dep/rehlsdk/common/winsani_in.h index e2bb599..d8c8527 100644 --- a/dep/rehlsdk/common/winsani_in.h +++ b/dep/rehlsdk/common/winsani_in.h @@ -1,7 +1,7 @@ -#if _MSC_VER >= 1500 // MSVC++ 9.0 (Visual Studio 2008) -#pragma push_macro("ARRAYSIZE") -#ifdef ARRAYSIZE -#undef ARRAYSIZE -#endif -#define HSPRITE WINDOWS_HSPRITE -#endif +#if _MSC_VER >= 1500 // MSVC++ 9.0 (Visual Studio 2008) +#pragma push_macro("ARRAYSIZE") +#ifdef ARRAYSIZE +#undef ARRAYSIZE +#endif +#define HSPRITE WINDOWS_HSPRITE +#endif diff --git a/dep/rehlsdk/common/winsani_out.h b/dep/rehlsdk/common/winsani_out.h index 3d9cef0..2726950 100644 --- a/dep/rehlsdk/common/winsani_out.h +++ b/dep/rehlsdk/common/winsani_out.h @@ -1,4 +1,4 @@ -#if _MSC_VER >= 1500 // MSVC++ 9.0 (Visual Studio 2008) -#undef HSPRITE -#pragma pop_macro("ARRAYSIZE") -#endif +#if _MSC_VER >= 1500 // MSVC++ 9.0 (Visual Studio 2008) +#undef HSPRITE +#pragma pop_macro("ARRAYSIZE") +#endif diff --git a/dep/rehlsdk/dlls/activity.h b/dep/rehlsdk/dlls/activity.h index 37c82b6..6fd3a18 100644 --- a/dep/rehlsdk/dlls/activity.h +++ b/dep/rehlsdk/dlls/activity.h @@ -1,109 +1,109 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#ifndef ACTIVITY_H -#define ACTIVITY_H - - -typedef enum { - ACT_RESET = 0, // Set m_Activity to this invalid value to force a reset to m_IdealActivity - ACT_IDLE = 1, - ACT_GUARD, - ACT_WALK, - ACT_RUN, - ACT_FLY, // Fly (and flap if appropriate) - ACT_SWIM, - ACT_HOP, // vertical jump - ACT_LEAP, // long forward jump - ACT_FALL, - ACT_LAND, - ACT_STRAFE_LEFT, - ACT_STRAFE_RIGHT, - ACT_ROLL_LEFT, // tuck and roll, left - ACT_ROLL_RIGHT, // tuck and roll, right - ACT_TURN_LEFT, // turn quickly left (stationary) - ACT_TURN_RIGHT, // turn quickly right (stationary) - ACT_CROUCH, // the act of crouching down from a standing position - ACT_CROUCHIDLE, // holding body in crouched position (loops) - ACT_STAND, // the act of standing from a crouched position - ACT_USE, - ACT_SIGNAL1, - ACT_SIGNAL2, - ACT_SIGNAL3, - ACT_TWITCH, - ACT_COWER, - ACT_SMALL_FLINCH, - ACT_BIG_FLINCH, - ACT_RANGE_ATTACK1, - ACT_RANGE_ATTACK2, - ACT_MELEE_ATTACK1, - ACT_MELEE_ATTACK2, - ACT_RELOAD, - ACT_ARM, // pull out gun, for instance - ACT_DISARM, // reholster gun - ACT_EAT, // monster chowing on a large food item (loop) - ACT_DIESIMPLE, - ACT_DIEBACKWARD, - ACT_DIEFORWARD, - ACT_DIEVIOLENT, - ACT_BARNACLE_HIT, // barnacle tongue hits a monster - ACT_BARNACLE_PULL, // barnacle is lifting the monster ( loop ) - ACT_BARNACLE_CHOMP, // barnacle latches on to the monster - ACT_BARNACLE_CHEW, // barnacle is holding the monster in its mouth ( loop ) - ACT_SLEEP, - ACT_INSPECT_FLOOR, // for active idles, look at something on or near the floor - ACT_INSPECT_WALL, // for active idles, look at something directly ahead of you ( doesn't HAVE to be a wall or on a wall ) - ACT_IDLE_ANGRY, // alternate idle animation in which the monster is clearly agitated. (loop) - ACT_WALK_HURT, // limp (loop) - ACT_RUN_HURT, // limp (loop) - ACT_HOVER, // Idle while in flight - ACT_GLIDE, // Fly (don't flap) - ACT_FLY_LEFT, // Turn left in flight - ACT_FLY_RIGHT, // Turn right in flight - ACT_DETECT_SCENT, // this means the monster smells a scent carried by the air - ACT_SNIFF, // this is the act of actually sniffing an item in front of the monster - ACT_BITE, // some large monsters can eat small things in one bite. This plays one time, EAT loops. - ACT_THREAT_DISPLAY, // without attacking, monster demonstrates that it is angry. (Yell, stick out chest, etc ) - ACT_FEAR_DISPLAY, // monster just saw something that it is afraid of - ACT_EXCITED, // for some reason, monster is excited. Sees something he really likes to eat, or whatever. - ACT_SPECIAL_ATTACK1, // very monster specific special attacks. - ACT_SPECIAL_ATTACK2, - ACT_COMBAT_IDLE, // agitated idle. - ACT_WALK_SCARED, - ACT_RUN_SCARED, - ACT_VICTORY_DANCE, // killed a player, do a victory dance. - ACT_DIE_HEADSHOT, // die, hit in head. - ACT_DIE_CHESTSHOT, // die, hit in chest - ACT_DIE_GUTSHOT, // die, hit in gut - ACT_DIE_BACKSHOT, // die, hit in back - ACT_FLINCH_HEAD, - ACT_FLINCH_CHEST, - ACT_FLINCH_STOMACH, - ACT_FLINCH_LEFTARM, - ACT_FLINCH_RIGHTARM, - ACT_FLINCH_LEFTLEG, - ACT_FLINCH_RIGHTLEG, -} Activity; - - -typedef struct { - int type; - char *name; -} activity_map_t; - -extern activity_map_t activity_map[]; - - -#endif //ACTIVITY_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +#ifndef ACTIVITY_H +#define ACTIVITY_H + + +typedef enum { + ACT_RESET = 0, // Set m_Activity to this invalid value to force a reset to m_IdealActivity + ACT_IDLE = 1, + ACT_GUARD, + ACT_WALK, + ACT_RUN, + ACT_FLY, // Fly (and flap if appropriate) + ACT_SWIM, + ACT_HOP, // vertical jump + ACT_LEAP, // long forward jump + ACT_FALL, + ACT_LAND, + ACT_STRAFE_LEFT, + ACT_STRAFE_RIGHT, + ACT_ROLL_LEFT, // tuck and roll, left + ACT_ROLL_RIGHT, // tuck and roll, right + ACT_TURN_LEFT, // turn quickly left (stationary) + ACT_TURN_RIGHT, // turn quickly right (stationary) + ACT_CROUCH, // the act of crouching down from a standing position + ACT_CROUCHIDLE, // holding body in crouched position (loops) + ACT_STAND, // the act of standing from a crouched position + ACT_USE, + ACT_SIGNAL1, + ACT_SIGNAL2, + ACT_SIGNAL3, + ACT_TWITCH, + ACT_COWER, + ACT_SMALL_FLINCH, + ACT_BIG_FLINCH, + ACT_RANGE_ATTACK1, + ACT_RANGE_ATTACK2, + ACT_MELEE_ATTACK1, + ACT_MELEE_ATTACK2, + ACT_RELOAD, + ACT_ARM, // pull out gun, for instance + ACT_DISARM, // reholster gun + ACT_EAT, // monster chowing on a large food item (loop) + ACT_DIESIMPLE, + ACT_DIEBACKWARD, + ACT_DIEFORWARD, + ACT_DIEVIOLENT, + ACT_BARNACLE_HIT, // barnacle tongue hits a monster + ACT_BARNACLE_PULL, // barnacle is lifting the monster ( loop ) + ACT_BARNACLE_CHOMP, // barnacle latches on to the monster + ACT_BARNACLE_CHEW, // barnacle is holding the monster in its mouth ( loop ) + ACT_SLEEP, + ACT_INSPECT_FLOOR, // for active idles, look at something on or near the floor + ACT_INSPECT_WALL, // for active idles, look at something directly ahead of you ( doesn't HAVE to be a wall or on a wall ) + ACT_IDLE_ANGRY, // alternate idle animation in which the monster is clearly agitated. (loop) + ACT_WALK_HURT, // limp (loop) + ACT_RUN_HURT, // limp (loop) + ACT_HOVER, // Idle while in flight + ACT_GLIDE, // Fly (don't flap) + ACT_FLY_LEFT, // Turn left in flight + ACT_FLY_RIGHT, // Turn right in flight + ACT_DETECT_SCENT, // this means the monster smells a scent carried by the air + ACT_SNIFF, // this is the act of actually sniffing an item in front of the monster + ACT_BITE, // some large monsters can eat small things in one bite. This plays one time, EAT loops. + ACT_THREAT_DISPLAY, // without attacking, monster demonstrates that it is angry. (Yell, stick out chest, etc ) + ACT_FEAR_DISPLAY, // monster just saw something that it is afraid of + ACT_EXCITED, // for some reason, monster is excited. Sees something he really likes to eat, or whatever. + ACT_SPECIAL_ATTACK1, // very monster specific special attacks. + ACT_SPECIAL_ATTACK2, + ACT_COMBAT_IDLE, // agitated idle. + ACT_WALK_SCARED, + ACT_RUN_SCARED, + ACT_VICTORY_DANCE, // killed a player, do a victory dance. + ACT_DIE_HEADSHOT, // die, hit in head. + ACT_DIE_CHESTSHOT, // die, hit in chest + ACT_DIE_GUTSHOT, // die, hit in gut + ACT_DIE_BACKSHOT, // die, hit in back + ACT_FLINCH_HEAD, + ACT_FLINCH_CHEST, + ACT_FLINCH_STOMACH, + ACT_FLINCH_LEFTARM, + ACT_FLINCH_RIGHTARM, + ACT_FLINCH_LEFTLEG, + ACT_FLINCH_RIGHTLEG, +} Activity; + + +typedef struct { + int type; + char *name; +} activity_map_t; + +extern activity_map_t activity_map[]; + + +#endif //ACTIVITY_H diff --git a/dep/rehlsdk/dlls/activitymap.h b/dep/rehlsdk/dlls/activitymap.h index b72c4e4..92cadae 100644 --- a/dep/rehlsdk/dlls/activitymap.h +++ b/dep/rehlsdk/dlls/activitymap.h @@ -1,97 +1,97 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#define _A( a ) { a, #a } - -activity_map_t activity_map[] = -{ -_A( ACT_IDLE ), -_A( ACT_GUARD ), -_A( ACT_WALK ), -_A( ACT_RUN ), -_A( ACT_FLY ), -_A( ACT_SWIM ), -_A( ACT_HOP ), -_A( ACT_LEAP ), -_A( ACT_FALL ), -_A( ACT_LAND ), -_A( ACT_STRAFE_LEFT ), -_A( ACT_STRAFE_RIGHT ), -_A( ACT_ROLL_LEFT ), -_A( ACT_ROLL_RIGHT ), -_A( ACT_TURN_LEFT ), -_A( ACT_TURN_RIGHT ), -_A( ACT_CROUCH ), -_A( ACT_CROUCHIDLE ), -_A( ACT_STAND ), -_A( ACT_USE ), -_A( ACT_SIGNAL1 ), -_A( ACT_SIGNAL2 ), -_A( ACT_SIGNAL3 ), -_A( ACT_TWITCH ), -_A( ACT_COWER ), -_A( ACT_SMALL_FLINCH ), -_A( ACT_BIG_FLINCH ), -_A( ACT_RANGE_ATTACK1 ), -_A( ACT_RANGE_ATTACK2 ), -_A( ACT_MELEE_ATTACK1 ), -_A( ACT_MELEE_ATTACK2 ), -_A( ACT_RELOAD ), -_A( ACT_ARM ), -_A( ACT_DISARM ), -_A( ACT_EAT ), -_A( ACT_DIESIMPLE ), -_A( ACT_DIEBACKWARD ), -_A( ACT_DIEFORWARD ), -_A( ACT_DIEVIOLENT ), -_A( ACT_BARNACLE_HIT ), -_A( ACT_BARNACLE_PULL ), -_A( ACT_BARNACLE_CHOMP ), -_A( ACT_BARNACLE_CHEW ), -_A( ACT_SLEEP ), -_A( ACT_INSPECT_FLOOR ), -_A( ACT_INSPECT_WALL ), -_A( ACT_IDLE_ANGRY ), -_A( ACT_WALK_HURT ), -_A( ACT_RUN_HURT ), -_A( ACT_HOVER ), -_A( ACT_GLIDE ), -_A( ACT_FLY_LEFT ), -_A( ACT_FLY_RIGHT ), -_A( ACT_DETECT_SCENT ), -_A( ACT_SNIFF ), -_A( ACT_BITE ), -_A( ACT_THREAT_DISPLAY ), -_A( ACT_FEAR_DISPLAY ), -_A( ACT_EXCITED ), -_A( ACT_SPECIAL_ATTACK1 ), -_A( ACT_SPECIAL_ATTACK2 ), -_A( ACT_COMBAT_IDLE ), -_A( ACT_WALK_SCARED ), -_A( ACT_RUN_SCARED ), -_A( ACT_VICTORY_DANCE ), -_A( ACT_DIE_HEADSHOT ), -_A( ACT_DIE_CHESTSHOT ), -_A( ACT_DIE_GUTSHOT ), -_A( ACT_DIE_BACKSHOT ), -_A( ACT_FLINCH_HEAD ), -_A( ACT_FLINCH_CHEST ), -_A( ACT_FLINCH_STOMACH ), -_A( ACT_FLINCH_LEFTARM ), -_A( ACT_FLINCH_RIGHTARM ), -_A( ACT_FLINCH_LEFTLEG ), -_A( ACT_FLINCH_RIGHTLEG ), -0, NULL -}; +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +#define _A( a ) { a, #a } + +activity_map_t activity_map[] = +{ +_A( ACT_IDLE ), +_A( ACT_GUARD ), +_A( ACT_WALK ), +_A( ACT_RUN ), +_A( ACT_FLY ), +_A( ACT_SWIM ), +_A( ACT_HOP ), +_A( ACT_LEAP ), +_A( ACT_FALL ), +_A( ACT_LAND ), +_A( ACT_STRAFE_LEFT ), +_A( ACT_STRAFE_RIGHT ), +_A( ACT_ROLL_LEFT ), +_A( ACT_ROLL_RIGHT ), +_A( ACT_TURN_LEFT ), +_A( ACT_TURN_RIGHT ), +_A( ACT_CROUCH ), +_A( ACT_CROUCHIDLE ), +_A( ACT_STAND ), +_A( ACT_USE ), +_A( ACT_SIGNAL1 ), +_A( ACT_SIGNAL2 ), +_A( ACT_SIGNAL3 ), +_A( ACT_TWITCH ), +_A( ACT_COWER ), +_A( ACT_SMALL_FLINCH ), +_A( ACT_BIG_FLINCH ), +_A( ACT_RANGE_ATTACK1 ), +_A( ACT_RANGE_ATTACK2 ), +_A( ACT_MELEE_ATTACK1 ), +_A( ACT_MELEE_ATTACK2 ), +_A( ACT_RELOAD ), +_A( ACT_ARM ), +_A( ACT_DISARM ), +_A( ACT_EAT ), +_A( ACT_DIESIMPLE ), +_A( ACT_DIEBACKWARD ), +_A( ACT_DIEFORWARD ), +_A( ACT_DIEVIOLENT ), +_A( ACT_BARNACLE_HIT ), +_A( ACT_BARNACLE_PULL ), +_A( ACT_BARNACLE_CHOMP ), +_A( ACT_BARNACLE_CHEW ), +_A( ACT_SLEEP ), +_A( ACT_INSPECT_FLOOR ), +_A( ACT_INSPECT_WALL ), +_A( ACT_IDLE_ANGRY ), +_A( ACT_WALK_HURT ), +_A( ACT_RUN_HURT ), +_A( ACT_HOVER ), +_A( ACT_GLIDE ), +_A( ACT_FLY_LEFT ), +_A( ACT_FLY_RIGHT ), +_A( ACT_DETECT_SCENT ), +_A( ACT_SNIFF ), +_A( ACT_BITE ), +_A( ACT_THREAT_DISPLAY ), +_A( ACT_FEAR_DISPLAY ), +_A( ACT_EXCITED ), +_A( ACT_SPECIAL_ATTACK1 ), +_A( ACT_SPECIAL_ATTACK2 ), +_A( ACT_COMBAT_IDLE ), +_A( ACT_WALK_SCARED ), +_A( ACT_RUN_SCARED ), +_A( ACT_VICTORY_DANCE ), +_A( ACT_DIE_HEADSHOT ), +_A( ACT_DIE_CHESTSHOT ), +_A( ACT_DIE_GUTSHOT ), +_A( ACT_DIE_BACKSHOT ), +_A( ACT_FLINCH_HEAD ), +_A( ACT_FLINCH_CHEST ), +_A( ACT_FLINCH_STOMACH ), +_A( ACT_FLINCH_LEFTARM ), +_A( ACT_FLINCH_RIGHTARM ), +_A( ACT_FLINCH_LEFTLEG ), +_A( ACT_FLINCH_RIGHTLEG ), +0, NULL +}; diff --git a/dep/rehlsdk/dlls/animation.h b/dep/rehlsdk/dlls/animation.h index 7728167..174bd71 100644 --- a/dep/rehlsdk/dlls/animation.h +++ b/dep/rehlsdk/dlls/animation.h @@ -1,47 +1,47 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef ANIMATION_H -#define ANIMATION_H - -#define ACTIVITY_NOT_AVAILABLE -1 - -#ifndef MONSTEREVENT_H -#include "monsterevent.h" -#endif - -extern int IsSoundEvent( int eventNumber ); - -int LookupActivity( void *pmodel, entvars_t *pev, int activity ); -int LookupActivityHeaviest( void *pmodel, entvars_t *pev, int activity ); -int LookupSequence( void *pmodel, const char *label ); -void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float *pflGroundSpeed ); -int GetSequenceFlags( void *pmodel, entvars_t *pev ); -int LookupAnimationEvents( void *pmodel, entvars_t *pev, float flStart, float flEnd ); -float SetController( void *pmodel, entvars_t *pev, int iController, float flValue ); -float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue ); -void GetEyePosition( void *pmodel, float *vecEyePosition ); -void SequencePrecache( void *pmodel, const char *pSequenceName ); -int FindTransition( void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir ); -void SetBodygroup( void *pmodel, entvars_t *pev, int iGroup, int iValue ); -int GetBodygroup( void *pmodel, entvars_t *pev, int iGroup ); - -int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEvent, float flStart, float flEnd, int index ); -int ExtractBbox( void *pmodel, int sequence, float *mins, float *maxs ); - -// From /engine/studio.h -#define STUDIO_LOOPING 0x0001 - - -#endif //ANIMATION_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef ANIMATION_H +#define ANIMATION_H + +#define ACTIVITY_NOT_AVAILABLE -1 + +#ifndef MONSTEREVENT_H +#include "monsterevent.h" +#endif + +extern int IsSoundEvent( int eventNumber ); + +int LookupActivity( void *pmodel, entvars_t *pev, int activity ); +int LookupActivityHeaviest( void *pmodel, entvars_t *pev, int activity ); +int LookupSequence( void *pmodel, const char *label ); +void GetSequenceInfo( void *pmodel, entvars_t *pev, float *pflFrameRate, float *pflGroundSpeed ); +int GetSequenceFlags( void *pmodel, entvars_t *pev ); +int LookupAnimationEvents( void *pmodel, entvars_t *pev, float flStart, float flEnd ); +float SetController( void *pmodel, entvars_t *pev, int iController, float flValue ); +float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue ); +void GetEyePosition( void *pmodel, float *vecEyePosition ); +void SequencePrecache( void *pmodel, const char *pSequenceName ); +int FindTransition( void *pmodel, int iEndingAnim, int iGoalAnim, int *piDir ); +void SetBodygroup( void *pmodel, entvars_t *pev, int iGroup, int iValue ); +int GetBodygroup( void *pmodel, entvars_t *pev, int iGroup ); + +int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEvent, float flStart, float flEnd, int index ); +int ExtractBbox( void *pmodel, int sequence, float *mins, float *maxs ); + +// From /engine/studio.h +#define STUDIO_LOOPING 0x0001 + + +#endif //ANIMATION_H diff --git a/dep/rehlsdk/dlls/basemonster.h b/dep/rehlsdk/dlls/basemonster.h index 280e467..43a2ed7 100644 --- a/dep/rehlsdk/dlls/basemonster.h +++ b/dep/rehlsdk/dlls/basemonster.h @@ -1,94 +1,94 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef BASEMONSTER_H -#define BASEMONSTER_H - -class CBaseMonster : public CBaseToggle -{ -public: - Activity m_Activity;// what the monster is doing (animation) - Activity m_IdealActivity;// monster should switch to this activity - int m_LastHitGroup; // the last body region that took damage - int m_bitsDamageType; // what types of damage has monster (player) taken - BYTE m_rgbTimeBasedDamage[CDMG_TIMEBASED]; - MONSTERSTATE m_MonsterState;// monster's current state - MONSTERSTATE m_IdealMonsterState;// monster should change to this state - int m_afConditions; - int m_afMemory; - float m_flNextAttack; // cannot attack again until this time - EHANDLE m_hEnemy; // the entity that the monster is fighting. - EHANDLE m_hTargetEnt; // the entity that the monster is trying to reach - float m_flFieldOfView;// width of monster's field of view ( dot product ) - int m_bloodColor; // color of blood particless - Vector m_HackedGunPos; // HACK until we can query end of gun - Vector m_vecEnemyLKP;// last known position of enemy. (enemy's origin) - - - void KeyValue( KeyValueData *pkvd ); - - void MakeIdealYaw( Vector vecTarget ); - virtual float ChangeYaw ( int speed ); - virtual BOOL HasHumanGibs( void ); - virtual BOOL HasAlienGibs( void ); - virtual void FadeMonster( void ); // Called instead of GibMonster() when gibs are disabled - virtual void GibMonster( void ); - virtual Activity GetDeathActivity ( void ); - Activity GetSmallFlinchActivity( void ); - virtual void BecomeDead( void ); - BOOL ShouldGibMonster( int iGib ); - void CallGibMonster( void ); - virtual BOOL ShouldFadeOnDeath( void ); - BOOL FCheckAITrigger( void );// checks and, if necessary, fires the monster's trigger target. - virtual int IRelationship ( CBaseEntity *pTarget ); - virtual int TakeHealth( float flHealth, int bitsDamageType ); - virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType); - int DeadTakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); - float DamageForce( float damage ); - virtual void Killed( entvars_t *pevAttacker, int iGib ); - virtual void PainSound ( void ) { return; }; - - void RadiusDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ); - void RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ); - - inline void SetConditions( int iConditions ) { m_afConditions |= iConditions; } - inline void ClearConditions( int iConditions ) { m_afConditions &= ~iConditions; } - inline BOOL HasConditions( int iConditions ) { if ( m_afConditions & iConditions ) return TRUE; return FALSE; } - inline BOOL HasAllConditions( int iConditions ) { if ( (m_afConditions & iConditions) == iConditions ) return TRUE; return FALSE; } - - inline void Remember( int iMemory ) { m_afMemory |= iMemory; } - inline void Forget( int iMemory ) { m_afMemory &= ~iMemory; } - inline BOOL HasMemory( int iMemory ) { if ( m_afMemory & iMemory ) return TRUE; return FALSE; } - inline BOOL HasAllMemories( int iMemory ) { if ( (m_afMemory & iMemory) == iMemory ) return TRUE; return FALSE; } - - // This will stop animation until you call ResetSequenceInfo() at some point in the future - inline void StopAnimation( void ) { pev->framerate = 0; } - - virtual void ReportAIState( void ); - virtual void MonsterInitDead( void ); // Call after animation/pose is set up - void EXPORT CorpseFallThink( void ); - - virtual void Look ( int iDistance );// basic sight function for monsters - virtual CBaseEntity* BestVisibleEnemy ( void );// finds best visible enemy for attack - CBaseEntity *CheckTraceHullAttack( float flDist, int iDamage, int iDmgType ); - virtual BOOL FInViewCone ( CBaseEntity *pEntity );// see if pEntity is in monster's view cone - virtual BOOL FInViewCone ( Vector *pOrigin );// see if given location is in monster's view cone - void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); - void MakeDamageBloodDecal ( int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir ); - virtual BOOL IsAlive( void ) { return (pev->deadflag != DEAD_DEAD); } - -}; - - -#endif +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef BASEMONSTER_H +#define BASEMONSTER_H + +class CBaseMonster : public CBaseToggle +{ +public: + Activity m_Activity;// what the monster is doing (animation) + Activity m_IdealActivity;// monster should switch to this activity + int m_LastHitGroup; // the last body region that took damage + int m_bitsDamageType; // what types of damage has monster (player) taken + BYTE m_rgbTimeBasedDamage[CDMG_TIMEBASED]; + MONSTERSTATE m_MonsterState;// monster's current state + MONSTERSTATE m_IdealMonsterState;// monster should change to this state + int m_afConditions; + int m_afMemory; + float m_flNextAttack; // cannot attack again until this time + EHANDLE m_hEnemy; // the entity that the monster is fighting. + EHANDLE m_hTargetEnt; // the entity that the monster is trying to reach + float m_flFieldOfView;// width of monster's field of view ( dot product ) + int m_bloodColor; // color of blood particless + Vector m_HackedGunPos; // HACK until we can query end of gun + Vector m_vecEnemyLKP;// last known position of enemy. (enemy's origin) + + + void KeyValue( KeyValueData *pkvd ); + + void MakeIdealYaw( Vector vecTarget ); + virtual float ChangeYaw ( int speed ); + virtual BOOL HasHumanGibs( void ); + virtual BOOL HasAlienGibs( void ); + virtual void FadeMonster( void ); // Called instead of GibMonster() when gibs are disabled + virtual void GibMonster( void ); + virtual Activity GetDeathActivity ( void ); + Activity GetSmallFlinchActivity( void ); + virtual void BecomeDead( void ); + BOOL ShouldGibMonster( int iGib ); + void CallGibMonster( void ); + virtual BOOL ShouldFadeOnDeath( void ); + BOOL FCheckAITrigger( void );// checks and, if necessary, fires the monster's trigger target. + virtual int IRelationship ( CBaseEntity *pTarget ); + virtual int TakeHealth( float flHealth, int bitsDamageType ); + virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType); + int DeadTakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); + float DamageForce( float damage ); + virtual void Killed( entvars_t *pevAttacker, int iGib ); + virtual void PainSound ( void ) { return; }; + + void RadiusDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ); + void RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ); + + inline void SetConditions( int iConditions ) { m_afConditions |= iConditions; } + inline void ClearConditions( int iConditions ) { m_afConditions &= ~iConditions; } + inline BOOL HasConditions( int iConditions ) { if ( m_afConditions & iConditions ) return TRUE; return FALSE; } + inline BOOL HasAllConditions( int iConditions ) { if ( (m_afConditions & iConditions) == iConditions ) return TRUE; return FALSE; } + + inline void Remember( int iMemory ) { m_afMemory |= iMemory; } + inline void Forget( int iMemory ) { m_afMemory &= ~iMemory; } + inline BOOL HasMemory( int iMemory ) { if ( m_afMemory & iMemory ) return TRUE; return FALSE; } + inline BOOL HasAllMemories( int iMemory ) { if ( (m_afMemory & iMemory) == iMemory ) return TRUE; return FALSE; } + + // This will stop animation until you call ResetSequenceInfo() at some point in the future + inline void StopAnimation( void ) { pev->framerate = 0; } + + virtual void ReportAIState( void ); + virtual void MonsterInitDead( void ); // Call after animation/pose is set up + void EXPORT CorpseFallThink( void ); + + virtual void Look ( int iDistance );// basic sight function for monsters + virtual CBaseEntity* BestVisibleEnemy ( void );// finds best visible enemy for attack + CBaseEntity *CheckTraceHullAttack( float flDist, int iDamage, int iDmgType ); + virtual BOOL FInViewCone ( CBaseEntity *pEntity );// see if pEntity is in monster's view cone + virtual BOOL FInViewCone ( Vector *pOrigin );// see if given location is in monster's view cone + void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); + void MakeDamageBloodDecal ( int cCount, float flNoise, TraceResult *ptr, const Vector &vecDir ); + virtual BOOL IsAlive( void ) { return (pev->deadflag != DEAD_DEAD); } + +}; + + +#endif diff --git a/dep/rehlsdk/dlls/cbase.h b/dep/rehlsdk/dlls/cbase.h index df3b8ee..87cb8fd 100644 --- a/dep/rehlsdk/dlls/cbase.h +++ b/dep/rehlsdk/dlls/cbase.h @@ -1,802 +1,802 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -/* - -Class Hierachy - -CBaseEntity - CBaseDelay - CBaseToggle - CBaseItem - CBaseMonster - CBaseCycler - CBasePlayer - CBaseGroup -*/ - -#define MAX_PATH_SIZE 10 // max number of nodes available for a path. - -// These are caps bits to indicate what an object's capabilities (currently used for save/restore and level transitions) -#define FCAP_CUSTOMSAVE 0x00000001 -#define FCAP_ACROSS_TRANSITION 0x00000002 // should transfer between transitions -#define FCAP_MUST_SPAWN 0x00000004 // Spawn after restore -#define FCAP_DONT_SAVE 0x80000000 // Don't save this -#define FCAP_IMPULSE_USE 0x00000008 // can be used by the player -#define FCAP_CONTINUOUS_USE 0x00000010 // can be used by the player -#define FCAP_ONOFF_USE 0x00000020 // can be used by the player -#define FCAP_DIRECTIONAL_USE 0x00000040 // Player sends +/- 1 when using (currently only tracktrains) -#define FCAP_MASTER 0x00000080 // Can be used to "master" other entities (like multisource) - -// UNDONE: This will ignore transition volumes (trigger_transition), but not the PVS!!! -#define FCAP_FORCE_TRANSITION 0x00000080 // ALWAYS goes across transitions - -#include "archtypes.h" // DAL -#include "saverestore.h" -#include "schedule.h" - -#ifndef MONSTEREVENT_H -#include "monsterevent.h" -#endif - -// C functions for external declarations that call the appropriate C++ methods - -#ifndef CBASE_DLLEXPORT -#ifdef _WIN32 -#define CBASE_DLLEXPORT _declspec( dllexport ) EXT_FUNC -#else -#define CBASE_DLLEXPORT __attribute__ ((visibility("default"))) EXT_FUNC -#endif -#endif - -#define EXPORT CBASE_DLLEXPORT - -extern "C" CBASE_DLLEXPORT int GetEntityAPI( DLL_FUNCTIONS *pFunctionTable, int interfaceVersion ); -extern "C" CBASE_DLLEXPORT int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ); - -extern int DispatchSpawn( edict_t *pent ); -extern void DispatchKeyValue( edict_t *pentKeyvalue, KeyValueData *pkvd ); -extern void DispatchTouch( edict_t *pentTouched, edict_t *pentOther ); -extern void DispatchUse( edict_t *pentUsed, edict_t *pentOther ); -extern void DispatchThink( edict_t *pent ); -extern void DispatchBlocked( edict_t *pentBlocked, edict_t *pentOther ); -extern void DispatchSave( edict_t *pent, SAVERESTOREDATA *pSaveData ); -extern int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ); -extern void DispatchObjectCollsionBox( edict_t *pent ); -extern void SaveWriteFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); -extern void SaveReadFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); -extern void SaveGlobalState( SAVERESTOREDATA *pSaveData ); -extern void RestoreGlobalState( SAVERESTOREDATA *pSaveData ); -extern void ResetGlobalState( void ); - -typedef enum { USE_OFF = 0, USE_ON = 1, USE_SET = 2, USE_TOGGLE = 3 } USE_TYPE; - -extern void FireTargets( const char *targetName, CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - -typedef void (CBaseEntity::*BASEPTR)(void); -typedef void (CBaseEntity::*ENTITYFUNCPTR)(CBaseEntity *pOther ); -typedef void (CBaseEntity::*USEPTR)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - -// For CLASSIFY -#define CLASS_NONE 0 -#define CLASS_MACHINE 1 -#define CLASS_PLAYER 2 -#define CLASS_HUMAN_PASSIVE 3 -#define CLASS_HUMAN_MILITARY 4 -#define CLASS_ALIEN_MILITARY 5 -#define CLASS_ALIEN_PASSIVE 6 -#define CLASS_ALIEN_MONSTER 7 -#define CLASS_ALIEN_PREY 8 -#define CLASS_ALIEN_PREDATOR 9 -#define CLASS_INSECT 10 -#define CLASS_PLAYER_ALLY 11 -#define CLASS_PLAYER_BIOWEAPON 12 // hornets and snarks.launched by players -#define CLASS_ALIEN_BIOWEAPON 13 // hornets and snarks.launched by the alien menace -#define CLASS_BARNACLE 99 // special because no one pays attention to it, and it eats a wide cross-section of creatures. - -class CBaseEntity; -class CBaseMonster; -class CBasePlayerItem; -class CSquadMonster; - - -#define SF_NORESPAWN ( 1 << 30 )// !!!set this bit on guns and stuff that should never respawn. - -// -// EHANDLE. Safe way to point to CBaseEntities who may die between frames -// -class EHANDLE -{ -private: - edict_t *m_pent; - int m_serialnumber; -public: - edict_t *Get( void ); - edict_t *Set( edict_t *pent ); - - operator int (); - - operator CBaseEntity *(); - - CBaseEntity * operator = (CBaseEntity *pEntity); - CBaseEntity * operator ->(); -}; - - -// -// Base Entity. All entity types derive from this -// -class CBaseEntity -{ -public: - // Constructor. Set engine to use C/C++ callback functions - // pointers to engine data - entvars_t *pev; // Don't need to save/restore this pointer, the engine resets it - - // path corners - CBaseEntity *m_pGoalEnt;// path corner we are heading towards - CBaseEntity *m_pLink;// used for temporary link-list operations. - - // initialization functions - virtual void Spawn( void ) { return; } - virtual void Precache( void ) { return; } - virtual void KeyValue( KeyValueData* pkvd) { pkvd->fHandled = FALSE; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - virtual int ObjectCaps( void ) { return FCAP_ACROSS_TRANSITION; } - virtual void Activate( void ) {} - - // Setup the object->object collision box (pev->mins / pev->maxs is the object->world collision box) - virtual void SetObjectCollisionBox( void ); - -// Classify - returns the type of group (i.e, "houndeye", or "human military" so that monsters with different classnames -// still realize that they are teammates. (overridden for monsters that form groups) - virtual int Classify ( void ) { return CLASS_NONE; }; - virtual void DeathNotice ( entvars_t *pevChild ) {}// monster maker children use this to tell the monster maker that they have died. - - - static TYPEDESCRIPTION m_SaveData[]; - - virtual void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); - virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); - virtual int TakeHealth( float flHealth, int bitsDamageType ); - virtual void Killed( entvars_t *pevAttacker, int iGib ); - virtual int BloodColor( void ) { return DONT_BLEED; } - virtual void TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); - virtual BOOL IsTriggered( CBaseEntity *pActivator ) {return TRUE;} - virtual CBaseMonster *MyMonsterPointer( void ) { return NULL;} - virtual CSquadMonster *MySquadMonsterPointer( void ) { return NULL;} - virtual int GetToggleState( void ) { return TS_AT_TOP; } - virtual void AddPoints( int score, BOOL bAllowNegativeScore ) {} - virtual void AddPointsToTeam( int score, BOOL bAllowNegativeScore ) {} - virtual BOOL AddPlayerItem( CBasePlayerItem *pItem ) { return 0; } - virtual BOOL RemovePlayerItem( CBasePlayerItem *pItem ) { return 0; } - virtual int GiveAmmo( int iAmount, char *szName, int iMax ) { return -1; }; - virtual float GetDelay( void ) { return 0; } - virtual int IsMoving( void ) { return pev->velocity != g_vecZero; } - virtual void OverrideReset( void ) {} - virtual int DamageDecal( int bitsDamageType ); - // This is ONLY used by the node graph to test movement through a door - virtual void SetToggleState( int state ) {} - virtual void StartSneaking( void ) {} - virtual void StopSneaking( void ) {} - virtual BOOL OnControls( entvars_t *pev ) { return FALSE; } - virtual BOOL IsSneaking( void ) { return FALSE; } - virtual BOOL IsAlive( void ) { return (pev->deadflag == DEAD_NO) && pev->health > 0; } - virtual BOOL IsBSPModel( void ) { return pev->solid == SOLID_BSP || pev->movetype == MOVETYPE_PUSHSTEP; } - virtual BOOL ReflectGauss( void ) { return ( IsBSPModel() && !pev->takedamage ); } - virtual BOOL HasTarget( string_t targetname ) { return FStrEq(STRING(targetname), STRING(pev->targetname) ); } - virtual BOOL IsInWorld( void ); - virtual BOOL IsPlayer( void ) { return FALSE; } - virtual BOOL IsNetClient( void ) { return FALSE; } - virtual const char *TeamID( void ) { return ""; } - - -// virtual void SetActivator( CBaseEntity *pActivator ) {} - virtual CBaseEntity *GetNextTarget( void ); - - // fundamental callbacks - void (CBaseEntity ::*m_pfnThink)(void); - void (CBaseEntity ::*m_pfnTouch)( CBaseEntity *pOther ); - void (CBaseEntity ::*m_pfnUse)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void (CBaseEntity ::*m_pfnBlocked)( CBaseEntity *pOther ); - - virtual void Think( void ) { if (m_pfnThink) (this->*m_pfnThink)(); }; - virtual void Touch( CBaseEntity *pOther ) { if (m_pfnTouch) (this->*m_pfnTouch)( pOther ); }; - virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) - { - if (m_pfnUse) - (this->*m_pfnUse)( pActivator, pCaller, useType, value ); - } - virtual void Blocked( CBaseEntity *pOther ) { if (m_pfnBlocked) (this->*m_pfnBlocked)( pOther ); }; - - // allow engine to allocate instance data - void *operator new( size_t stAllocateBlock, entvars_t *pev ) - { - return (void *)ALLOC_PRIVATE(ENT(pev), stAllocateBlock); - }; - - // don't use this. -#if _MSC_VER >= 1200 // only build this code if MSVC++ 6.0 or higher - void operator delete(void *pMem, entvars_t *pev) - { - pev->flags |= FL_KILLME; - }; -#endif - - void UpdateOnRemove( void ); - - // common member functions - void EXPORT SUB_Remove( void ); - void EXPORT SUB_DoNothing( void ); - void EXPORT SUB_StartFadeOut ( void ); - void EXPORT SUB_FadeOut ( void ); - void EXPORT SUB_CallUseToggle( void ) { this->Use( this, this, USE_TOGGLE, 0 ); } - int ShouldToggle( USE_TYPE useType, BOOL currentState ); - void FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq = 4, int iDamage = 0, entvars_t *pevAttacker = NULL ); - Vector FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq = 4, int iDamage = 0, entvars_t *pevAttacker = NULL, int shared_rand = 0 ); - - virtual CBaseEntity *Respawn( void ) { return NULL; } - - void SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value ); - // Do the bounding boxes of these two intersect? - int Intersects( CBaseEntity *pOther ); - void MakeDormant( void ); - int IsDormant( void ); - BOOL IsLockedByMaster( void ) { return FALSE; } - - static CBaseEntity *Instance( edict_t *pent ) - { - if ( !pent ) - pent = ENT(0); - CBaseEntity *pEnt = (CBaseEntity *)GET_PRIVATE(pent); - return pEnt; - } - - static CBaseEntity *Instance( entvars_t *pev ) { return Instance( ENT( pev ) ); } - static CBaseEntity *Instance( int eoffset) { return Instance( ENT( eoffset) ); } - - CBaseMonster *GetMonsterPointer( entvars_t *pevMonster ) - { - CBaseEntity *pEntity = Instance( pevMonster ); - if ( pEntity ) - return pEntity->MyMonsterPointer(); - return NULL; - } - CBaseMonster *GetMonsterPointer( edict_t *pentMonster ) - { - CBaseEntity *pEntity = Instance( pentMonster ); - if ( pEntity ) - return pEntity->MyMonsterPointer(); - return NULL; - } - - - // Ugly code to lookup all functions to make sure they are exported when set. -#ifdef _DEBUG - void FunctionCheck( void *pFunction, char *name ) - { - if (pFunction && !NAME_FOR_FUNCTION((uint32)pFunction) ) - ALERT( at_error, "No EXPORT: %s:%s (%08lx)\n", STRING(pev->classname), name, (uint32)pFunction ); - } - - BASEPTR ThinkSet( BASEPTR func, char *name ) - { - m_pfnThink = func; - FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnThink)))), name ); - return func; - } - ENTITYFUNCPTR TouchSet( ENTITYFUNCPTR func, char *name ) - { - m_pfnTouch = func; - FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnTouch)))), name ); - return func; - } - USEPTR UseSet( USEPTR func, char *name ) - { - m_pfnUse = func; - FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnUse)))), name ); - return func; - } - ENTITYFUNCPTR BlockedSet( ENTITYFUNCPTR func, char *name ) - { - m_pfnBlocked = func; - FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnBlocked)))), name ); - return func; - } - -#endif - - - // virtual functions used by a few classes - - // used by monsters that are created by the MonsterMaker - virtual void UpdateOwner( void ) { return; }; - - - // - static CBaseEntity *Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner = NULL ); - - virtual BOOL FBecomeProne( void ) {return FALSE;}; - edict_t *edict() { return ENT( pev ); }; - EOFFSET eoffset( ) { return OFFSET( pev ); }; - int entindex( ) { return ENTINDEX( edict() ); }; - - virtual Vector Center( ) { return (pev->absmax + pev->absmin) * 0.5; }; // center point of entity - virtual Vector EyePosition( ) { return pev->origin + pev->view_ofs; }; // position of eyes - virtual Vector EarPosition( ) { return pev->origin + pev->view_ofs; }; // position of ears - virtual Vector BodyTarget( const Vector &posSrc ) { return Center( ); }; // position to shoot at - - virtual int Illumination( ) { return GETENTITYILLUM( ENT( pev ) ); }; - - virtual BOOL FVisible ( CBaseEntity *pEntity ); - virtual BOOL FVisible ( const Vector &vecOrigin ); - - //We use this variables to store each ammo count. - int ammo_9mm; - int ammo_357; - int ammo_bolts; - int ammo_buckshot; - int ammo_rockets; - int ammo_uranium; - int ammo_hornets; - int ammo_argrens; - //Special stuff for grenades and satchels. - float m_flStartThrow; - float m_flReleaseThrow; - int m_chargeReady; - int m_fInAttack; - - enum EGON_FIRESTATE { FIRE_OFF, FIRE_CHARGE }; - int m_fireState; -}; - - - -// Ugly technique to override base member functions -// Normally it's illegal to cast a pointer to a member function of a derived class to a pointer to a -// member function of a base class. static_cast is a sleezy way around that problem. - -#ifdef _DEBUG - -#define SetThink( a ) ThinkSet( static_cast (a), #a ) -#define SetTouch( a ) TouchSet( static_cast (a), #a ) -#define SetUse( a ) UseSet( static_cast (a), #a ) -#define SetBlocked( a ) BlockedSet( static_cast (a), #a ) - -#else - -#define SetThink( a ) m_pfnThink = static_cast (a) -#define SetTouch( a ) m_pfnTouch = static_cast (a) -#define SetUse( a ) m_pfnUse = static_cast (a) -#define SetBlocked( a ) m_pfnBlocked = static_cast (a) - -#endif - - -class CPointEntity : public CBaseEntity -{ -public: - void Spawn( void ); - virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } -private: -}; - - -typedef struct locksounds // sounds that doors and buttons make when locked/unlocked -{ - string_t sLockedSound; // sound a door makes when it's locked - string_t sLockedSentence; // sentence group played when door is locked - string_t sUnlockedSound; // sound a door makes when it's unlocked - string_t sUnlockedSentence; // sentence group played when door is unlocked - - int iLockedSentence; // which sentence in sentence group to play next - int iUnlockedSentence; // which sentence in sentence group to play next - - float flwaitSound; // time delay between playing consecutive 'locked/unlocked' sounds - float flwaitSentence; // time delay between playing consecutive sentences - BYTE bEOFLocked; // true if hit end of list of locked sentences - BYTE bEOFUnlocked; // true if hit end of list of unlocked sentences -} locksound_t; - -void PlayLockSounds(entvars_t *pev, locksound_t *pls, int flocked, int fbutton); - -// -// MultiSouce -// - -#define MAX_MULTI_TARGETS 16 // maximum number of targets a single multi_manager entity may be assigned. -#define MS_MAX_TARGETS 32 - -class CMultiSource : public CPointEntity -{ -public: - void Spawn( ); - void KeyValue( KeyValueData *pkvd ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - int ObjectCaps( void ) { return (CPointEntity::ObjectCaps() | FCAP_MASTER); } - BOOL IsTriggered( CBaseEntity *pActivator ); - void EXPORT Register( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - static TYPEDESCRIPTION m_SaveData[]; - - EHANDLE m_rgEntities[MS_MAX_TARGETS]; - int m_rgTriggered[MS_MAX_TARGETS]; - - int m_iTotal; - string_t m_globalstate; -}; - - -// -// generic Delay entity. -// -class CBaseDelay : public CBaseEntity -{ -public: - float m_flDelay; - int m_iszKillTarget; - - virtual void KeyValue( KeyValueData* pkvd); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - static TYPEDESCRIPTION m_SaveData[]; - // common member functions - void SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value ); - void EXPORT DelayThink( void ); -}; - - -class CBaseAnimating : public CBaseDelay -{ -public: - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - static TYPEDESCRIPTION m_SaveData[]; - - // Basic Monster Animation functions - float StudioFrameAdvance( float flInterval = 0.0 ); // accumulate animation frame time from last time called until now - int GetSequenceFlags( void ); - int LookupActivity ( int activity ); - int LookupActivityHeaviest ( int activity ); - int LookupSequence ( const char *label ); - void ResetSequenceInfo ( ); - void DispatchAnimEvents ( float flFutureInterval = 0.1 ); // Handle events that have happend since last time called up until X seconds into the future - virtual void HandleAnimEvent( MonsterEvent_t *pEvent ) { return; }; - float SetBoneController ( int iController, float flValue ); - void InitBoneControllers ( void ); - float SetBlending ( int iBlender, float flValue ); - void GetBonePosition ( int iBone, Vector &origin, Vector &angles ); - void GetAutomovement( Vector &origin, Vector &angles, float flInterval = 0.1 ); - int FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ); - void GetAttachment ( int iAttachment, Vector &origin, Vector &angles ); - void SetBodygroup( int iGroup, int iValue ); - int GetBodygroup( int iGroup ); - int ExtractBbox( int sequence, float *mins, float *maxs ); - void SetSequenceBox( void ); - - // animation needs - float m_flFrameRate; // computed FPS for current sequence - float m_flGroundSpeed; // computed linear movement rate for current sequence - float m_flLastEventCheck; // last time the event list was checked - BOOL m_fSequenceFinished;// flag set when StudioAdvanceFrame moves across a frame boundry - BOOL m_fSequenceLoops; // true if the sequence loops -}; - - -// -// generic Toggle entity. -// -#define SF_ITEM_USE_ONLY 256 // ITEM_USE_ONLY = BUTTON_USE_ONLY = DOOR_USE_ONLY!!! - -class CBaseToggle : public CBaseAnimating -{ -public: - void KeyValue( KeyValueData *pkvd ); - - TOGGLE_STATE m_toggle_state; - float m_flActivateFinished;//like attack_finished, but for doors - float m_flMoveDistance;// how far a door should slide or rotate - float m_flWait; - float m_flLip; - float m_flTWidth;// for plats - float m_flTLength;// for plats - - Vector m_vecPosition1; - Vector m_vecPosition2; - Vector m_vecAngle1; - Vector m_vecAngle2; - - int m_cTriggersLeft; // trigger_counter only, # of activations remaining - float m_flHeight; - EHANDLE m_hActivator; - void (CBaseToggle::*m_pfnCallWhenMoveDone)(void); - Vector m_vecFinalDest; - Vector m_vecFinalAngle; - - int m_bitsDamageInflict; // DMG_ damage type that the door or tigger does - - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - static TYPEDESCRIPTION m_SaveData[]; - - virtual int GetToggleState( void ) { return m_toggle_state; } - virtual float GetDelay( void ) { return m_flWait; } - - // common member functions - void LinearMove( Vector vecDest, float flSpeed ); - void EXPORT LinearMoveDone( void ); - void AngularMove( Vector vecDestAngle, float flSpeed ); - void EXPORT AngularMoveDone( void ); - BOOL IsLockedByMaster( void ); - - static float AxisValue( int flags, const Vector &angles ); - static void AxisDir( entvars_t *pev ); - static float AxisDelta( int flags, const Vector &angle1, const Vector &angle2 ); - - string_t m_sMaster; // If this button has a master switch, this is the targetname. - // A master switch must be of the multisource type. If all - // of the switches in the multisource have been triggered, then - // the button will be allowed to operate. Otherwise, it will be - // deactivated. -}; -#define SetMoveDone( a ) m_pfnCallWhenMoveDone = static_cast (a) - - -// people gib if their health is <= this at the time of death -#define GIB_HEALTH_VALUE -30 - -#define ROUTE_SIZE 8 // how many waypoints a monster can store at one time -#define MAX_OLD_ENEMIES 4 // how many old enemies to remember - -#define bits_CAP_DUCK ( 1 << 0 )// crouch -#define bits_CAP_JUMP ( 1 << 1 )// jump/leap -#define bits_CAP_STRAFE ( 1 << 2 )// strafe ( walk/run sideways) -#define bits_CAP_SQUAD ( 1 << 3 )// can form squads -#define bits_CAP_SWIM ( 1 << 4 )// proficiently navigate in water -#define bits_CAP_CLIMB ( 1 << 5 )// climb ladders/ropes -#define bits_CAP_USE ( 1 << 6 )// open doors/push buttons/pull levers -#define bits_CAP_HEAR ( 1 << 7 )// can hear forced sounds -#define bits_CAP_AUTO_DOORS ( 1 << 8 )// can trigger auto doors -#define bits_CAP_OPEN_DOORS ( 1 << 9 )// can open manual doors -#define bits_CAP_TURN_HEAD ( 1 << 10)// can turn head, always bone controller 0 - -#define bits_CAP_RANGE_ATTACK1 ( 1 << 11)// can do a range attack 1 -#define bits_CAP_RANGE_ATTACK2 ( 1 << 12)// can do a range attack 2 -#define bits_CAP_MELEE_ATTACK1 ( 1 << 13)// can do a melee attack 1 -#define bits_CAP_MELEE_ATTACK2 ( 1 << 14)// can do a melee attack 2 - -#define bits_CAP_FLY ( 1 << 15)// can fly, move all around - -#define bits_CAP_DOORS_GROUP (bits_CAP_USE | bits_CAP_AUTO_DOORS | bits_CAP_OPEN_DOORS) - -// used by suit voice to indicate damage sustained and repaired type to player - -// instant damage - -#define DMG_GENERIC 0 // generic damage was done -#define DMG_CRUSH (1 << 0) // crushed by falling or moving object -#define DMG_BULLET (1 << 1) // shot -#define DMG_SLASH (1 << 2) // cut, clawed, stabbed -#define DMG_BURN (1 << 3) // heat burned -#define DMG_FREEZE (1 << 4) // frozen -#define DMG_FALL (1 << 5) // fell too far -#define DMG_BLAST (1 << 6) // explosive blast damage -#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt -#define DMG_SHOCK (1 << 8) // electric shock -#define DMG_SONIC (1 << 9) // sound pulse shockwave -#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam -#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death -#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death. -#define DMG_DROWN (1 << 14) // Drowning -// time-based damage -#define DMG_TIMEBASED (~(0x3fff)) // mask for time-based damage - -#define DMG_PARALYZE (1 << 15) // slows affected creature down -#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad -#define DMG_POISON (1 << 17) // blood poisioning -#define DMG_RADIATION (1 << 18) // radiation exposure -#define DMG_DROWNRECOVER (1 << 19) // drowning recovery -#define DMG_ACID (1 << 20) // toxic chemicals or acid burns -#define DMG_SLOWBURN (1 << 21) // in an oven -#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer -#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar) - -// these are the damage types that are allowed to gib corpses -#define DMG_GIB_CORPSE ( DMG_CRUSH | DMG_FALL | DMG_BLAST | DMG_SONIC | DMG_CLUB ) - -// these are the damage types that have client hud art -#define DMG_SHOWNHUD (DMG_POISON | DMG_ACID | DMG_FREEZE | DMG_SLOWFREEZE | DMG_DROWN | DMG_BURN | DMG_SLOWBURN | DMG_NERVEGAS | DMG_RADIATION | DMG_SHOCK) - -// NOTE: tweak these values based on gameplay feedback: - -#define PARALYZE_DURATION 2 // number of 2 second intervals to take damage -#define PARALYZE_DAMAGE 1.0 // damage to take each 2 second interval - -#define NERVEGAS_DURATION 2 -#define NERVEGAS_DAMAGE 5.0 - -#define POISON_DURATION 5 -#define POISON_DAMAGE 2.0 - -#define RADIATION_DURATION 2 -#define RADIATION_DAMAGE 1.0 - -#define ACID_DURATION 2 -#define ACID_DAMAGE 5.0 - -#define SLOWBURN_DURATION 2 -#define SLOWBURN_DAMAGE 1.0 - -#define SLOWFREEZE_DURATION 2 -#define SLOWFREEZE_DAMAGE 1.0 - - -#define itbd_Paralyze 0 -#define itbd_NerveGas 1 -#define itbd_Poison 2 -#define itbd_Radiation 3 -#define itbd_DrownRecover 4 -#define itbd_Acid 5 -#define itbd_SlowBurn 6 -#define itbd_SlowFreeze 7 -#define CDMG_TIMEBASED 8 - -// when calling KILLED(), a value that governs gib behavior is expected to be -// one of these three values -#define GIB_NORMAL 0// gib if entity was overkilled -#define GIB_NEVER 1// never gib, no matter how much death damage is done ( freezing, etc ) -#define GIB_ALWAYS 2// always gib ( Houndeye Shock, Barnacle Bite ) - -class CBaseMonster; -class CCineMonster; -class CSound; - -#include "basemonster.h" - - -char *ButtonSound( int sound ); // get string of button sound number - - -// -// Generic Button -// -class CBaseButton : public CBaseToggle -{ -public: - void Spawn( void ); - virtual void Precache( void ); - void RotSpawn( void ); - virtual void KeyValue( KeyValueData* pkvd); - - void ButtonActivate( ); - void SparkSoundCache( void ); - - void EXPORT ButtonShot( void ); - void EXPORT ButtonTouch( CBaseEntity *pOther ); - void EXPORT ButtonSpark ( void ); - void EXPORT TriggerAndWait( void ); - void EXPORT ButtonReturn( void ); - void EXPORT ButtonBackHome( void ); - void EXPORT ButtonUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - enum BUTTON_CODE { BUTTON_NOTHING, BUTTON_ACTIVATE, BUTTON_RETURN }; - BUTTON_CODE ButtonResponseToTouch( void ); - - static TYPEDESCRIPTION m_SaveData[]; - // Buttons that don't take damage can be IMPULSE used - virtual int ObjectCaps( void ) { return (CBaseToggle:: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | (pev->takedamage?0:FCAP_IMPULSE_USE); } - - BOOL m_fStayPushed; // button stays pushed in until touched again? - BOOL m_fRotating; // a rotating button? default is a sliding button. - - string_t m_strChangeTarget; // if this field is not null, this is an index into the engine string array. - // when this button is touched, it's target entity's TARGET field will be set - // to the button's ChangeTarget. This allows you to make a func_train switch paths, etc. - - locksound_t m_ls; // door lock sounds - - BYTE m_bLockedSound; // ordinals from entity selection - BYTE m_bLockedSentence; - BYTE m_bUnlockedSound; - BYTE m_bUnlockedSentence; - int m_sounds; -}; - -// -// Weapons -// - -#define BAD_WEAPON 0x00007FFF - -// -// Converts a entvars_t * to a class pointer -// It will allocate the class and entity if necessary -// -template T * GetClassPtr( T *a ) -{ - entvars_t *pev = (entvars_t *)a; - - // allocate entity if necessary - if (pev == NULL) - pev = VARS(CREATE_ENTITY()); - - // get the private data - a = (T *)GET_PRIVATE(ENT(pev)); - - if (a == NULL) - { - // allocate private data - a = new(pev) T; - a->pev = pev; - } - return a; -} - - -/* -bit_PUSHBRUSH_DATA | bit_TOGGLE_DATA -bit_MONSTER_DATA -bit_DELAY_DATA -bit_TOGGLE_DATA | bit_DELAY_DATA | bit_MONSTER_DATA -bit_PLAYER_DATA | bit_MONSTER_DATA -bit_MONSTER_DATA | CYCLER_DATA -bit_LIGHT_DATA -path_corner_data -bit_MONSTER_DATA | wildcard_data -bit_MONSTER_DATA | bit_GROUP_DATA -boid_flock_data -boid_data -CYCLER_DATA -bit_ITEM_DATA -bit_ITEM_DATA | func_hud_data -bit_TOGGLE_DATA | bit_ITEM_DATA -EOFFSET -env_sound_data -env_sound_data -push_trigger_data -*/ - -#define TRACER_FREQ 4 // Tracers fire every 4 bullets - -typedef struct _SelAmmo -{ - BYTE Ammo1Type; - BYTE Ammo1; - BYTE Ammo2Type; - BYTE Ammo2; -} SelAmmo; - - -// this moved here from world.cpp, to allow classes to be derived from it -//======================= -// CWorld -// -// This spawns first when each level begins. -//======================= -class CWorld : public CBaseEntity -{ -public: - void Spawn( void ); - void Precache( void ); - void KeyValue( KeyValueData *pkvd ); -}; +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +/* + +Class Hierachy + +CBaseEntity + CBaseDelay + CBaseToggle + CBaseItem + CBaseMonster + CBaseCycler + CBasePlayer + CBaseGroup +*/ + +#define MAX_PATH_SIZE 10 // max number of nodes available for a path. + +// These are caps bits to indicate what an object's capabilities (currently used for save/restore and level transitions) +#define FCAP_CUSTOMSAVE 0x00000001 +#define FCAP_ACROSS_TRANSITION 0x00000002 // should transfer between transitions +#define FCAP_MUST_SPAWN 0x00000004 // Spawn after restore +#define FCAP_DONT_SAVE 0x80000000 // Don't save this +#define FCAP_IMPULSE_USE 0x00000008 // can be used by the player +#define FCAP_CONTINUOUS_USE 0x00000010 // can be used by the player +#define FCAP_ONOFF_USE 0x00000020 // can be used by the player +#define FCAP_DIRECTIONAL_USE 0x00000040 // Player sends +/- 1 when using (currently only tracktrains) +#define FCAP_MASTER 0x00000080 // Can be used to "master" other entities (like multisource) + +// UNDONE: This will ignore transition volumes (trigger_transition), but not the PVS!!! +#define FCAP_FORCE_TRANSITION 0x00000080 // ALWAYS goes across transitions + +#include "archtypes.h" // DAL +#include "saverestore.h" +#include "schedule.h" + +#ifndef MONSTEREVENT_H +#include "monsterevent.h" +#endif + +// C functions for external declarations that call the appropriate C++ methods + +#ifndef CBASE_DLLEXPORT +#ifdef _WIN32 +#define CBASE_DLLEXPORT _declspec( dllexport ) EXT_FUNC +#else +#define CBASE_DLLEXPORT __attribute__ ((visibility("default"))) EXT_FUNC +#endif +#endif + +#define EXPORT CBASE_DLLEXPORT + +extern "C" CBASE_DLLEXPORT int GetEntityAPI( DLL_FUNCTIONS *pFunctionTable, int interfaceVersion ); +extern "C" CBASE_DLLEXPORT int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ); + +extern int DispatchSpawn( edict_t *pent ); +extern void DispatchKeyValue( edict_t *pentKeyvalue, KeyValueData *pkvd ); +extern void DispatchTouch( edict_t *pentTouched, edict_t *pentOther ); +extern void DispatchUse( edict_t *pentUsed, edict_t *pentOther ); +extern void DispatchThink( edict_t *pent ); +extern void DispatchBlocked( edict_t *pentBlocked, edict_t *pentOther ); +extern void DispatchSave( edict_t *pent, SAVERESTOREDATA *pSaveData ); +extern int DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ); +extern void DispatchObjectCollsionBox( edict_t *pent ); +extern void SaveWriteFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); +extern void SaveReadFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); +extern void SaveGlobalState( SAVERESTOREDATA *pSaveData ); +extern void RestoreGlobalState( SAVERESTOREDATA *pSaveData ); +extern void ResetGlobalState( void ); + +typedef enum { USE_OFF = 0, USE_ON = 1, USE_SET = 2, USE_TOGGLE = 3 } USE_TYPE; + +extern void FireTargets( const char *targetName, CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + +typedef void (CBaseEntity::*BASEPTR)(void); +typedef void (CBaseEntity::*ENTITYFUNCPTR)(CBaseEntity *pOther ); +typedef void (CBaseEntity::*USEPTR)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + +// For CLASSIFY +#define CLASS_NONE 0 +#define CLASS_MACHINE 1 +#define CLASS_PLAYER 2 +#define CLASS_HUMAN_PASSIVE 3 +#define CLASS_HUMAN_MILITARY 4 +#define CLASS_ALIEN_MILITARY 5 +#define CLASS_ALIEN_PASSIVE 6 +#define CLASS_ALIEN_MONSTER 7 +#define CLASS_ALIEN_PREY 8 +#define CLASS_ALIEN_PREDATOR 9 +#define CLASS_INSECT 10 +#define CLASS_PLAYER_ALLY 11 +#define CLASS_PLAYER_BIOWEAPON 12 // hornets and snarks.launched by players +#define CLASS_ALIEN_BIOWEAPON 13 // hornets and snarks.launched by the alien menace +#define CLASS_BARNACLE 99 // special because no one pays attention to it, and it eats a wide cross-section of creatures. + +class CBaseEntity; +class CBaseMonster; +class CBasePlayerItem; +class CSquadMonster; + + +#define SF_NORESPAWN ( 1 << 30 )// !!!set this bit on guns and stuff that should never respawn. + +// +// EHANDLE. Safe way to point to CBaseEntities who may die between frames +// +class EHANDLE +{ +private: + edict_t *m_pent; + int m_serialnumber; +public: + edict_t *Get( void ); + edict_t *Set( edict_t *pent ); + + operator int (); + + operator CBaseEntity *(); + + CBaseEntity * operator = (CBaseEntity *pEntity); + CBaseEntity * operator ->(); +}; + + +// +// Base Entity. All entity types derive from this +// +class CBaseEntity +{ +public: + // Constructor. Set engine to use C/C++ callback functions + // pointers to engine data + entvars_t *pev; // Don't need to save/restore this pointer, the engine resets it + + // path corners + CBaseEntity *m_pGoalEnt;// path corner we are heading towards + CBaseEntity *m_pLink;// used for temporary link-list operations. + + // initialization functions + virtual void Spawn( void ) { return; } + virtual void Precache( void ) { return; } + virtual void KeyValue( KeyValueData* pkvd) { pkvd->fHandled = FALSE; } + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + virtual int ObjectCaps( void ) { return FCAP_ACROSS_TRANSITION; } + virtual void Activate( void ) {} + + // Setup the object->object collision box (pev->mins / pev->maxs is the object->world collision box) + virtual void SetObjectCollisionBox( void ); + +// Classify - returns the type of group (i.e, "houndeye", or "human military" so that monsters with different classnames +// still realize that they are teammates. (overridden for monsters that form groups) + virtual int Classify ( void ) { return CLASS_NONE; }; + virtual void DeathNotice ( entvars_t *pevChild ) {}// monster maker children use this to tell the monster maker that they have died. + + + static TYPEDESCRIPTION m_SaveData[]; + + virtual void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); + virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); + virtual int TakeHealth( float flHealth, int bitsDamageType ); + virtual void Killed( entvars_t *pevAttacker, int iGib ); + virtual int BloodColor( void ) { return DONT_BLEED; } + virtual void TraceBleed( float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); + virtual BOOL IsTriggered( CBaseEntity *pActivator ) {return TRUE;} + virtual CBaseMonster *MyMonsterPointer( void ) { return NULL;} + virtual CSquadMonster *MySquadMonsterPointer( void ) { return NULL;} + virtual int GetToggleState( void ) { return TS_AT_TOP; } + virtual void AddPoints( int score, BOOL bAllowNegativeScore ) {} + virtual void AddPointsToTeam( int score, BOOL bAllowNegativeScore ) {} + virtual BOOL AddPlayerItem( CBasePlayerItem *pItem ) { return 0; } + virtual BOOL RemovePlayerItem( CBasePlayerItem *pItem ) { return 0; } + virtual int GiveAmmo( int iAmount, char *szName, int iMax ) { return -1; }; + virtual float GetDelay( void ) { return 0; } + virtual int IsMoving( void ) { return pev->velocity != g_vecZero; } + virtual void OverrideReset( void ) {} + virtual int DamageDecal( int bitsDamageType ); + // This is ONLY used by the node graph to test movement through a door + virtual void SetToggleState( int state ) {} + virtual void StartSneaking( void ) {} + virtual void StopSneaking( void ) {} + virtual BOOL OnControls( entvars_t *pev ) { return FALSE; } + virtual BOOL IsSneaking( void ) { return FALSE; } + virtual BOOL IsAlive( void ) { return (pev->deadflag == DEAD_NO) && pev->health > 0; } + virtual BOOL IsBSPModel( void ) { return pev->solid == SOLID_BSP || pev->movetype == MOVETYPE_PUSHSTEP; } + virtual BOOL ReflectGauss( void ) { return ( IsBSPModel() && !pev->takedamage ); } + virtual BOOL HasTarget( string_t targetname ) { return FStrEq(STRING(targetname), STRING(pev->targetname) ); } + virtual BOOL IsInWorld( void ); + virtual BOOL IsPlayer( void ) { return FALSE; } + virtual BOOL IsNetClient( void ) { return FALSE; } + virtual const char *TeamID( void ) { return ""; } + + +// virtual void SetActivator( CBaseEntity *pActivator ) {} + virtual CBaseEntity *GetNextTarget( void ); + + // fundamental callbacks + void (CBaseEntity ::*m_pfnThink)(void); + void (CBaseEntity ::*m_pfnTouch)( CBaseEntity *pOther ); + void (CBaseEntity ::*m_pfnUse)( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void (CBaseEntity ::*m_pfnBlocked)( CBaseEntity *pOther ); + + virtual void Think( void ) { if (m_pfnThink) (this->*m_pfnThink)(); }; + virtual void Touch( CBaseEntity *pOther ) { if (m_pfnTouch) (this->*m_pfnTouch)( pOther ); }; + virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) + { + if (m_pfnUse) + (this->*m_pfnUse)( pActivator, pCaller, useType, value ); + } + virtual void Blocked( CBaseEntity *pOther ) { if (m_pfnBlocked) (this->*m_pfnBlocked)( pOther ); }; + + // allow engine to allocate instance data + void *operator new( size_t stAllocateBlock, entvars_t *pev ) + { + return (void *)ALLOC_PRIVATE(ENT(pev), stAllocateBlock); + }; + + // don't use this. +#if _MSC_VER >= 1200 // only build this code if MSVC++ 6.0 or higher + void operator delete(void *pMem, entvars_t *pev) + { + pev->flags |= FL_KILLME; + }; +#endif + + void UpdateOnRemove( void ); + + // common member functions + void EXPORT SUB_Remove( void ); + void EXPORT SUB_DoNothing( void ); + void EXPORT SUB_StartFadeOut ( void ); + void EXPORT SUB_FadeOut ( void ); + void EXPORT SUB_CallUseToggle( void ) { this->Use( this, this, USE_TOGGLE, 0 ); } + int ShouldToggle( USE_TYPE useType, BOOL currentState ); + void FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq = 4, int iDamage = 0, entvars_t *pevAttacker = NULL ); + Vector FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq = 4, int iDamage = 0, entvars_t *pevAttacker = NULL, int shared_rand = 0 ); + + virtual CBaseEntity *Respawn( void ) { return NULL; } + + void SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value ); + // Do the bounding boxes of these two intersect? + int Intersects( CBaseEntity *pOther ); + void MakeDormant( void ); + int IsDormant( void ); + BOOL IsLockedByMaster( void ) { return FALSE; } + + static CBaseEntity *Instance( edict_t *pent ) + { + if ( !pent ) + pent = ENT(0); + CBaseEntity *pEnt = (CBaseEntity *)GET_PRIVATE(pent); + return pEnt; + } + + static CBaseEntity *Instance( entvars_t *pev ) { return Instance( ENT( pev ) ); } + static CBaseEntity *Instance( int eoffset) { return Instance( ENT( eoffset) ); } + + CBaseMonster *GetMonsterPointer( entvars_t *pevMonster ) + { + CBaseEntity *pEntity = Instance( pevMonster ); + if ( pEntity ) + return pEntity->MyMonsterPointer(); + return NULL; + } + CBaseMonster *GetMonsterPointer( edict_t *pentMonster ) + { + CBaseEntity *pEntity = Instance( pentMonster ); + if ( pEntity ) + return pEntity->MyMonsterPointer(); + return NULL; + } + + + // Ugly code to lookup all functions to make sure they are exported when set. +#ifdef _DEBUG + void FunctionCheck( void *pFunction, char *name ) + { + if (pFunction && !NAME_FOR_FUNCTION((uint32)pFunction) ) + ALERT( at_error, "No EXPORT: %s:%s (%08lx)\n", STRING(pev->classname), name, (uint32)pFunction ); + } + + BASEPTR ThinkSet( BASEPTR func, char *name ) + { + m_pfnThink = func; + FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnThink)))), name ); + return func; + } + ENTITYFUNCPTR TouchSet( ENTITYFUNCPTR func, char *name ) + { + m_pfnTouch = func; + FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnTouch)))), name ); + return func; + } + USEPTR UseSet( USEPTR func, char *name ) + { + m_pfnUse = func; + FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnUse)))), name ); + return func; + } + ENTITYFUNCPTR BlockedSet( ENTITYFUNCPTR func, char *name ) + { + m_pfnBlocked = func; + FunctionCheck( (void *)*((int *)((char *)this + ( offsetof(CBaseEntity,m_pfnBlocked)))), name ); + return func; + } + +#endif + + + // virtual functions used by a few classes + + // used by monsters that are created by the MonsterMaker + virtual void UpdateOwner( void ) { return; }; + + + // + static CBaseEntity *Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner = NULL ); + + virtual BOOL FBecomeProne( void ) {return FALSE;}; + edict_t *edict() { return ENT( pev ); }; + EOFFSET eoffset( ) { return OFFSET( pev ); }; + int entindex( ) { return ENTINDEX( edict() ); }; + + virtual Vector Center( ) { return (pev->absmax + pev->absmin) * 0.5; }; // center point of entity + virtual Vector EyePosition( ) { return pev->origin + pev->view_ofs; }; // position of eyes + virtual Vector EarPosition( ) { return pev->origin + pev->view_ofs; }; // position of ears + virtual Vector BodyTarget( const Vector &posSrc ) { return Center( ); }; // position to shoot at + + virtual int Illumination( ) { return GETENTITYILLUM( ENT( pev ) ); }; + + virtual BOOL FVisible ( CBaseEntity *pEntity ); + virtual BOOL FVisible ( const Vector &vecOrigin ); + + //We use this variables to store each ammo count. + int ammo_9mm; + int ammo_357; + int ammo_bolts; + int ammo_buckshot; + int ammo_rockets; + int ammo_uranium; + int ammo_hornets; + int ammo_argrens; + //Special stuff for grenades and satchels. + float m_flStartThrow; + float m_flReleaseThrow; + int m_chargeReady; + int m_fInAttack; + + enum EGON_FIRESTATE { FIRE_OFF, FIRE_CHARGE }; + int m_fireState; +}; + + + +// Ugly technique to override base member functions +// Normally it's illegal to cast a pointer to a member function of a derived class to a pointer to a +// member function of a base class. static_cast is a sleezy way around that problem. + +#ifdef _DEBUG + +#define SetThink( a ) ThinkSet( static_cast (a), #a ) +#define SetTouch( a ) TouchSet( static_cast (a), #a ) +#define SetUse( a ) UseSet( static_cast (a), #a ) +#define SetBlocked( a ) BlockedSet( static_cast (a), #a ) + +#else + +#define SetThink( a ) m_pfnThink = static_cast (a) +#define SetTouch( a ) m_pfnTouch = static_cast (a) +#define SetUse( a ) m_pfnUse = static_cast (a) +#define SetBlocked( a ) m_pfnBlocked = static_cast (a) + +#endif + + +class CPointEntity : public CBaseEntity +{ +public: + void Spawn( void ); + virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } +private: +}; + + +typedef struct locksounds // sounds that doors and buttons make when locked/unlocked +{ + string_t sLockedSound; // sound a door makes when it's locked + string_t sLockedSentence; // sentence group played when door is locked + string_t sUnlockedSound; // sound a door makes when it's unlocked + string_t sUnlockedSentence; // sentence group played when door is unlocked + + int iLockedSentence; // which sentence in sentence group to play next + int iUnlockedSentence; // which sentence in sentence group to play next + + float flwaitSound; // time delay between playing consecutive 'locked/unlocked' sounds + float flwaitSentence; // time delay between playing consecutive sentences + BYTE bEOFLocked; // true if hit end of list of locked sentences + BYTE bEOFUnlocked; // true if hit end of list of unlocked sentences +} locksound_t; + +void PlayLockSounds(entvars_t *pev, locksound_t *pls, int flocked, int fbutton); + +// +// MultiSouce +// + +#define MAX_MULTI_TARGETS 16 // maximum number of targets a single multi_manager entity may be assigned. +#define MS_MAX_TARGETS 32 + +class CMultiSource : public CPointEntity +{ +public: + void Spawn( ); + void KeyValue( KeyValueData *pkvd ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + int ObjectCaps( void ) { return (CPointEntity::ObjectCaps() | FCAP_MASTER); } + BOOL IsTriggered( CBaseEntity *pActivator ); + void EXPORT Register( void ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + + static TYPEDESCRIPTION m_SaveData[]; + + EHANDLE m_rgEntities[MS_MAX_TARGETS]; + int m_rgTriggered[MS_MAX_TARGETS]; + + int m_iTotal; + string_t m_globalstate; +}; + + +// +// generic Delay entity. +// +class CBaseDelay : public CBaseEntity +{ +public: + float m_flDelay; + int m_iszKillTarget; + + virtual void KeyValue( KeyValueData* pkvd); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + + static TYPEDESCRIPTION m_SaveData[]; + // common member functions + void SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value ); + void EXPORT DelayThink( void ); +}; + + +class CBaseAnimating : public CBaseDelay +{ +public: + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + + static TYPEDESCRIPTION m_SaveData[]; + + // Basic Monster Animation functions + float StudioFrameAdvance( float flInterval = 0.0 ); // accumulate animation frame time from last time called until now + int GetSequenceFlags( void ); + int LookupActivity ( int activity ); + int LookupActivityHeaviest ( int activity ); + int LookupSequence ( const char *label ); + void ResetSequenceInfo ( ); + void DispatchAnimEvents ( float flFutureInterval = 0.1 ); // Handle events that have happend since last time called up until X seconds into the future + virtual void HandleAnimEvent( MonsterEvent_t *pEvent ) { return; }; + float SetBoneController ( int iController, float flValue ); + void InitBoneControllers ( void ); + float SetBlending ( int iBlender, float flValue ); + void GetBonePosition ( int iBone, Vector &origin, Vector &angles ); + void GetAutomovement( Vector &origin, Vector &angles, float flInterval = 0.1 ); + int FindTransition( int iEndingSequence, int iGoalSequence, int *piDir ); + void GetAttachment ( int iAttachment, Vector &origin, Vector &angles ); + void SetBodygroup( int iGroup, int iValue ); + int GetBodygroup( int iGroup ); + int ExtractBbox( int sequence, float *mins, float *maxs ); + void SetSequenceBox( void ); + + // animation needs + float m_flFrameRate; // computed FPS for current sequence + float m_flGroundSpeed; // computed linear movement rate for current sequence + float m_flLastEventCheck; // last time the event list was checked + BOOL m_fSequenceFinished;// flag set when StudioAdvanceFrame moves across a frame boundry + BOOL m_fSequenceLoops; // true if the sequence loops +}; + + +// +// generic Toggle entity. +// +#define SF_ITEM_USE_ONLY 256 // ITEM_USE_ONLY = BUTTON_USE_ONLY = DOOR_USE_ONLY!!! + +class CBaseToggle : public CBaseAnimating +{ +public: + void KeyValue( KeyValueData *pkvd ); + + TOGGLE_STATE m_toggle_state; + float m_flActivateFinished;//like attack_finished, but for doors + float m_flMoveDistance;// how far a door should slide or rotate + float m_flWait; + float m_flLip; + float m_flTWidth;// for plats + float m_flTLength;// for plats + + Vector m_vecPosition1; + Vector m_vecPosition2; + Vector m_vecAngle1; + Vector m_vecAngle2; + + int m_cTriggersLeft; // trigger_counter only, # of activations remaining + float m_flHeight; + EHANDLE m_hActivator; + void (CBaseToggle::*m_pfnCallWhenMoveDone)(void); + Vector m_vecFinalDest; + Vector m_vecFinalAngle; + + int m_bitsDamageInflict; // DMG_ damage type that the door or tigger does + + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + + static TYPEDESCRIPTION m_SaveData[]; + + virtual int GetToggleState( void ) { return m_toggle_state; } + virtual float GetDelay( void ) { return m_flWait; } + + // common member functions + void LinearMove( Vector vecDest, float flSpeed ); + void EXPORT LinearMoveDone( void ); + void AngularMove( Vector vecDestAngle, float flSpeed ); + void EXPORT AngularMoveDone( void ); + BOOL IsLockedByMaster( void ); + + static float AxisValue( int flags, const Vector &angles ); + static void AxisDir( entvars_t *pev ); + static float AxisDelta( int flags, const Vector &angle1, const Vector &angle2 ); + + string_t m_sMaster; // If this button has a master switch, this is the targetname. + // A master switch must be of the multisource type. If all + // of the switches in the multisource have been triggered, then + // the button will be allowed to operate. Otherwise, it will be + // deactivated. +}; +#define SetMoveDone( a ) m_pfnCallWhenMoveDone = static_cast (a) + + +// people gib if their health is <= this at the time of death +#define GIB_HEALTH_VALUE -30 + +#define ROUTE_SIZE 8 // how many waypoints a monster can store at one time +#define MAX_OLD_ENEMIES 4 // how many old enemies to remember + +#define bits_CAP_DUCK ( 1 << 0 )// crouch +#define bits_CAP_JUMP ( 1 << 1 )// jump/leap +#define bits_CAP_STRAFE ( 1 << 2 )// strafe ( walk/run sideways) +#define bits_CAP_SQUAD ( 1 << 3 )// can form squads +#define bits_CAP_SWIM ( 1 << 4 )// proficiently navigate in water +#define bits_CAP_CLIMB ( 1 << 5 )// climb ladders/ropes +#define bits_CAP_USE ( 1 << 6 )// open doors/push buttons/pull levers +#define bits_CAP_HEAR ( 1 << 7 )// can hear forced sounds +#define bits_CAP_AUTO_DOORS ( 1 << 8 )// can trigger auto doors +#define bits_CAP_OPEN_DOORS ( 1 << 9 )// can open manual doors +#define bits_CAP_TURN_HEAD ( 1 << 10)// can turn head, always bone controller 0 + +#define bits_CAP_RANGE_ATTACK1 ( 1 << 11)// can do a range attack 1 +#define bits_CAP_RANGE_ATTACK2 ( 1 << 12)// can do a range attack 2 +#define bits_CAP_MELEE_ATTACK1 ( 1 << 13)// can do a melee attack 1 +#define bits_CAP_MELEE_ATTACK2 ( 1 << 14)// can do a melee attack 2 + +#define bits_CAP_FLY ( 1 << 15)// can fly, move all around + +#define bits_CAP_DOORS_GROUP (bits_CAP_USE | bits_CAP_AUTO_DOORS | bits_CAP_OPEN_DOORS) + +// used by suit voice to indicate damage sustained and repaired type to player + +// instant damage + +#define DMG_GENERIC 0 // generic damage was done +#define DMG_CRUSH (1 << 0) // crushed by falling or moving object +#define DMG_BULLET (1 << 1) // shot +#define DMG_SLASH (1 << 2) // cut, clawed, stabbed +#define DMG_BURN (1 << 3) // heat burned +#define DMG_FREEZE (1 << 4) // frozen +#define DMG_FALL (1 << 5) // fell too far +#define DMG_BLAST (1 << 6) // explosive blast damage +#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt +#define DMG_SHOCK (1 << 8) // electric shock +#define DMG_SONIC (1 << 9) // sound pulse shockwave +#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam +#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death +#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death. +#define DMG_DROWN (1 << 14) // Drowning +// time-based damage +#define DMG_TIMEBASED (~(0x3fff)) // mask for time-based damage + +#define DMG_PARALYZE (1 << 15) // slows affected creature down +#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad +#define DMG_POISON (1 << 17) // blood poisioning +#define DMG_RADIATION (1 << 18) // radiation exposure +#define DMG_DROWNRECOVER (1 << 19) // drowning recovery +#define DMG_ACID (1 << 20) // toxic chemicals or acid burns +#define DMG_SLOWBURN (1 << 21) // in an oven +#define DMG_SLOWFREEZE (1 << 22) // in a subzero freezer +#define DMG_MORTAR (1 << 23) // Hit by air raid (done to distinguish grenade from mortar) + +// these are the damage types that are allowed to gib corpses +#define DMG_GIB_CORPSE ( DMG_CRUSH | DMG_FALL | DMG_BLAST | DMG_SONIC | DMG_CLUB ) + +// these are the damage types that have client hud art +#define DMG_SHOWNHUD (DMG_POISON | DMG_ACID | DMG_FREEZE | DMG_SLOWFREEZE | DMG_DROWN | DMG_BURN | DMG_SLOWBURN | DMG_NERVEGAS | DMG_RADIATION | DMG_SHOCK) + +// NOTE: tweak these values based on gameplay feedback: + +#define PARALYZE_DURATION 2 // number of 2 second intervals to take damage +#define PARALYZE_DAMAGE 1.0 // damage to take each 2 second interval + +#define NERVEGAS_DURATION 2 +#define NERVEGAS_DAMAGE 5.0 + +#define POISON_DURATION 5 +#define POISON_DAMAGE 2.0 + +#define RADIATION_DURATION 2 +#define RADIATION_DAMAGE 1.0 + +#define ACID_DURATION 2 +#define ACID_DAMAGE 5.0 + +#define SLOWBURN_DURATION 2 +#define SLOWBURN_DAMAGE 1.0 + +#define SLOWFREEZE_DURATION 2 +#define SLOWFREEZE_DAMAGE 1.0 + + +#define itbd_Paralyze 0 +#define itbd_NerveGas 1 +#define itbd_Poison 2 +#define itbd_Radiation 3 +#define itbd_DrownRecover 4 +#define itbd_Acid 5 +#define itbd_SlowBurn 6 +#define itbd_SlowFreeze 7 +#define CDMG_TIMEBASED 8 + +// when calling KILLED(), a value that governs gib behavior is expected to be +// one of these three values +#define GIB_NORMAL 0// gib if entity was overkilled +#define GIB_NEVER 1// never gib, no matter how much death damage is done ( freezing, etc ) +#define GIB_ALWAYS 2// always gib ( Houndeye Shock, Barnacle Bite ) + +class CBaseMonster; +class CCineMonster; +class CSound; + +#include "basemonster.h" + + +char *ButtonSound( int sound ); // get string of button sound number + + +// +// Generic Button +// +class CBaseButton : public CBaseToggle +{ +public: + void Spawn( void ); + virtual void Precache( void ); + void RotSpawn( void ); + virtual void KeyValue( KeyValueData* pkvd); + + void ButtonActivate( ); + void SparkSoundCache( void ); + + void EXPORT ButtonShot( void ); + void EXPORT ButtonTouch( CBaseEntity *pOther ); + void EXPORT ButtonSpark ( void ); + void EXPORT TriggerAndWait( void ); + void EXPORT ButtonReturn( void ); + void EXPORT ButtonBackHome( void ); + void EXPORT ButtonUse ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + + enum BUTTON_CODE { BUTTON_NOTHING, BUTTON_ACTIVATE, BUTTON_RETURN }; + BUTTON_CODE ButtonResponseToTouch( void ); + + static TYPEDESCRIPTION m_SaveData[]; + // Buttons that don't take damage can be IMPULSE used + virtual int ObjectCaps( void ) { return (CBaseToggle:: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | (pev->takedamage?0:FCAP_IMPULSE_USE); } + + BOOL m_fStayPushed; // button stays pushed in until touched again? + BOOL m_fRotating; // a rotating button? default is a sliding button. + + string_t m_strChangeTarget; // if this field is not null, this is an index into the engine string array. + // when this button is touched, it's target entity's TARGET field will be set + // to the button's ChangeTarget. This allows you to make a func_train switch paths, etc. + + locksound_t m_ls; // door lock sounds + + BYTE m_bLockedSound; // ordinals from entity selection + BYTE m_bLockedSentence; + BYTE m_bUnlockedSound; + BYTE m_bUnlockedSentence; + int m_sounds; +}; + +// +// Weapons +// + +#define BAD_WEAPON 0x00007FFF + +// +// Converts a entvars_t * to a class pointer +// It will allocate the class and entity if necessary +// +template T * GetClassPtr( T *a ) +{ + entvars_t *pev = (entvars_t *)a; + + // allocate entity if necessary + if (pev == NULL) + pev = VARS(CREATE_ENTITY()); + + // get the private data + a = (T *)GET_PRIVATE(ENT(pev)); + + if (a == NULL) + { + // allocate private data + a = new(pev) T; + a->pev = pev; + } + return a; +} + + +/* +bit_PUSHBRUSH_DATA | bit_TOGGLE_DATA +bit_MONSTER_DATA +bit_DELAY_DATA +bit_TOGGLE_DATA | bit_DELAY_DATA | bit_MONSTER_DATA +bit_PLAYER_DATA | bit_MONSTER_DATA +bit_MONSTER_DATA | CYCLER_DATA +bit_LIGHT_DATA +path_corner_data +bit_MONSTER_DATA | wildcard_data +bit_MONSTER_DATA | bit_GROUP_DATA +boid_flock_data +boid_data +CYCLER_DATA +bit_ITEM_DATA +bit_ITEM_DATA | func_hud_data +bit_TOGGLE_DATA | bit_ITEM_DATA +EOFFSET +env_sound_data +env_sound_data +push_trigger_data +*/ + +#define TRACER_FREQ 4 // Tracers fire every 4 bullets + +typedef struct _SelAmmo +{ + BYTE Ammo1Type; + BYTE Ammo1; + BYTE Ammo2Type; + BYTE Ammo2; +} SelAmmo; + + +// this moved here from world.cpp, to allow classes to be derived from it +//======================= +// CWorld +// +// This spawns first when each level begins. +//======================= +class CWorld : public CBaseEntity +{ +public: + void Spawn( void ); + void Precache( void ); + void KeyValue( KeyValueData *pkvd ); +}; diff --git a/dep/rehlsdk/dlls/cdll_dll.h b/dep/rehlsdk/dlls/cdll_dll.h index 6fb5e98..920fa29 100644 --- a/dep/rehlsdk/dlls/cdll_dll.h +++ b/dep/rehlsdk/dlls/cdll_dll.h @@ -1,46 +1,46 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// -// cdll_dll.h - -// this file is included by both the game-dll and the client-dll, - -#ifndef CDLL_DLL_H -#define CDLL_DLL_H - -#define MAX_WEAPONS 32 // ??? - -#define MAX_WEAPON_SLOTS 5 // hud item selection slots -#define MAX_ITEM_TYPES 6 // hud item selection slots - -#define MAX_ITEMS 5 // hard coded item types - -#define HIDEHUD_WEAPONS ( 1<<0 ) -#define HIDEHUD_FLASHLIGHT ( 1<<1 ) -#define HIDEHUD_ALL ( 1<<2 ) -#define HIDEHUD_HEALTH ( 1<<3 ) - -#define MAX_AMMO_TYPES 32 // ??? -#define MAX_AMMO_SLOTS 32 // not really slots - -#define HUD_PRINTNOTIFY 1 -#define HUD_PRINTCONSOLE 2 -#define HUD_PRINTTALK 3 -#define HUD_PRINTCENTER 4 - - -#define WEAPON_SUIT 31 - -#endif +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +// +// cdll_dll.h + +// this file is included by both the game-dll and the client-dll, + +#ifndef CDLL_DLL_H +#define CDLL_DLL_H + +#define MAX_WEAPONS 32 // ??? + +#define MAX_WEAPON_SLOTS 5 // hud item selection slots +#define MAX_ITEM_TYPES 6 // hud item selection slots + +#define MAX_ITEMS 5 // hard coded item types + +#define HIDEHUD_WEAPONS ( 1<<0 ) +#define HIDEHUD_FLASHLIGHT ( 1<<1 ) +#define HIDEHUD_ALL ( 1<<2 ) +#define HIDEHUD_HEALTH ( 1<<3 ) + +#define MAX_AMMO_TYPES 32 // ??? +#define MAX_AMMO_SLOTS 32 // not really slots + +#define HUD_PRINTNOTIFY 1 +#define HUD_PRINTCONSOLE 2 +#define HUD_PRINTTALK 3 +#define HUD_PRINTCENTER 4 + + +#define WEAPON_SUIT 31 + +#endif diff --git a/dep/rehlsdk/dlls/client.h b/dep/rehlsdk/dlls/client.h index 2e0b38e..1e66cc8 100644 --- a/dep/rehlsdk/dlls/client.h +++ b/dep/rehlsdk/dlls/client.h @@ -1,65 +1,65 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef CLIENT_H -#define CLIENT_H - -extern void respawn( entvars_t* pev, BOOL fCopyCorpse ); -extern BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); -extern void ClientDisconnect( edict_t *pEntity ); -extern void ClientKill( edict_t *pEntity ); -extern void ClientPutInServer( edict_t *pEntity ); -extern void ClientCommand( edict_t *pEntity ); -extern void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ); -extern void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ); -extern void ServerDeactivate( void ); -extern void StartFrame( void ); -extern void PlayerPostThink( edict_t *pEntity ); -extern void PlayerPreThink( edict_t *pEntity ); -extern void ParmsNewLevel( void ); -extern void ParmsChangeLevel( void ); - -extern void ClientPrecache( void ); - -extern const char *GetGameDescription( void ); -extern void PlayerCustomization( edict_t *pEntity, customization_t *pCust ); - -extern void SpectatorConnect ( edict_t *pEntity ); -extern void SpectatorDisconnect ( edict_t *pEntity ); -extern void SpectatorThink ( edict_t *pEntity ); - -extern void Sys_Error( const char *error_string ); - -extern void SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas ); -extern void UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); -extern int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); -extern void CreateBaseline( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ); -extern void RegisterEncoders( void ); - -extern int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ); - -extern void CmdStart( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ); -extern void CmdEnd ( const edict_t *player ); - -extern int ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); - -extern int GetHullBounds( int hullnumber, float *mins, float *maxs ); - -extern void CreateInstancedBaselines ( void ); - -extern int InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message ); - -extern int AllowLagCompensation( void ); - -#endif // CLIENT_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef CLIENT_H +#define CLIENT_H + +extern void respawn( entvars_t* pev, BOOL fCopyCorpse ); +extern BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); +extern void ClientDisconnect( edict_t *pEntity ); +extern void ClientKill( edict_t *pEntity ); +extern void ClientPutInServer( edict_t *pEntity ); +extern void ClientCommand( edict_t *pEntity ); +extern void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ); +extern void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ); +extern void ServerDeactivate( void ); +extern void StartFrame( void ); +extern void PlayerPostThink( edict_t *pEntity ); +extern void PlayerPreThink( edict_t *pEntity ); +extern void ParmsNewLevel( void ); +extern void ParmsChangeLevel( void ); + +extern void ClientPrecache( void ); + +extern const char *GetGameDescription( void ); +extern void PlayerCustomization( edict_t *pEntity, customization_t *pCust ); + +extern void SpectatorConnect ( edict_t *pEntity ); +extern void SpectatorDisconnect ( edict_t *pEntity ); +extern void SpectatorThink ( edict_t *pEntity ); + +extern void Sys_Error( const char *error_string ); + +extern void SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas ); +extern void UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); +extern int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); +extern void CreateBaseline( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ); +extern void RegisterEncoders( void ); + +extern int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ); + +extern void CmdStart( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ); +extern void CmdEnd ( const edict_t *player ); + +extern int ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); + +extern int GetHullBounds( int hullnumber, float *mins, float *maxs ); + +extern void CreateInstancedBaselines ( void ); + +extern int InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message ); + +extern int AllowLagCompensation( void ); + +#endif // CLIENT_H diff --git a/dep/rehlsdk/dlls/decals.h b/dep/rehlsdk/dlls/decals.h index 3185649..f66da95 100644 --- a/dep/rehlsdk/dlls/decals.h +++ b/dep/rehlsdk/dlls/decals.h @@ -1,84 +1,84 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef DECALS_H -#define DECALS_H - -// -// Dynamic Decals -// -enum decal_e -{ - DECAL_GUNSHOT1 = 0, - DECAL_GUNSHOT2, - DECAL_GUNSHOT3, - DECAL_GUNSHOT4, - DECAL_GUNSHOT5, - DECAL_LAMBDA1, - DECAL_LAMBDA2, - DECAL_LAMBDA3, - DECAL_LAMBDA4, - DECAL_LAMBDA5, - DECAL_LAMBDA6, - DECAL_SCORCH1, - DECAL_SCORCH2, - DECAL_BLOOD1, - DECAL_BLOOD2, - DECAL_BLOOD3, - DECAL_BLOOD4, - DECAL_BLOOD5, - DECAL_BLOOD6, - DECAL_YBLOOD1, - DECAL_YBLOOD2, - DECAL_YBLOOD3, - DECAL_YBLOOD4, - DECAL_YBLOOD5, - DECAL_YBLOOD6, - DECAL_GLASSBREAK1, - DECAL_GLASSBREAK2, - DECAL_GLASSBREAK3, - DECAL_BIGSHOT1, - DECAL_BIGSHOT2, - DECAL_BIGSHOT3, - DECAL_BIGSHOT4, - DECAL_BIGSHOT5, - DECAL_SPIT1, - DECAL_SPIT2, - DECAL_BPROOF1, // Bulletproof glass decal - DECAL_GARGSTOMP1, // Gargantua stomp crack - DECAL_SMALLSCORCH1, // Small scorch mark - DECAL_SMALLSCORCH2, // Small scorch mark - DECAL_SMALLSCORCH3, // Small scorch mark - DECAL_MOMMABIRTH, // Big momma birth splatter - DECAL_MOMMASPLAT, -}; - -typedef struct -{ - char *name; - short entityIndex; - byte depth; - byte flags; - vec3_t position; -} DECALLIST; - -typedef struct -{ - char *name; - int index; -} DLL_DECALLIST; - -extern DLL_DECALLIST gDecals[]; - -#endif // DECALS_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef DECALS_H +#define DECALS_H + +// +// Dynamic Decals +// +enum decal_e +{ + DECAL_GUNSHOT1 = 0, + DECAL_GUNSHOT2, + DECAL_GUNSHOT3, + DECAL_GUNSHOT4, + DECAL_GUNSHOT5, + DECAL_LAMBDA1, + DECAL_LAMBDA2, + DECAL_LAMBDA3, + DECAL_LAMBDA4, + DECAL_LAMBDA5, + DECAL_LAMBDA6, + DECAL_SCORCH1, + DECAL_SCORCH2, + DECAL_BLOOD1, + DECAL_BLOOD2, + DECAL_BLOOD3, + DECAL_BLOOD4, + DECAL_BLOOD5, + DECAL_BLOOD6, + DECAL_YBLOOD1, + DECAL_YBLOOD2, + DECAL_YBLOOD3, + DECAL_YBLOOD4, + DECAL_YBLOOD5, + DECAL_YBLOOD6, + DECAL_GLASSBREAK1, + DECAL_GLASSBREAK2, + DECAL_GLASSBREAK3, + DECAL_BIGSHOT1, + DECAL_BIGSHOT2, + DECAL_BIGSHOT3, + DECAL_BIGSHOT4, + DECAL_BIGSHOT5, + DECAL_SPIT1, + DECAL_SPIT2, + DECAL_BPROOF1, // Bulletproof glass decal + DECAL_GARGSTOMP1, // Gargantua stomp crack + DECAL_SMALLSCORCH1, // Small scorch mark + DECAL_SMALLSCORCH2, // Small scorch mark + DECAL_SMALLSCORCH3, // Small scorch mark + DECAL_MOMMABIRTH, // Big momma birth splatter + DECAL_MOMMASPLAT, +}; + +typedef struct +{ + char *name; + short entityIndex; + byte depth; + byte flags; + vec3_t position; +} DECALLIST; + +typedef struct +{ + char *name; + int index; +} DLL_DECALLIST; + +extern DLL_DECALLIST gDecals[]; + +#endif // DECALS_H diff --git a/dep/rehlsdk/dlls/doors.h b/dep/rehlsdk/dlls/doors.h index 55a853f..8008861 100644 --- a/dep/rehlsdk/dlls/doors.h +++ b/dep/rehlsdk/dlls/doors.h @@ -1,33 +1,33 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef DOORS_H -#define DOORS_H - -// doors -#define SF_DOOR_ROTATE_Y 0 -#define SF_DOOR_START_OPEN 1 -#define SF_DOOR_ROTATE_BACKWARDS 2 -#define SF_DOOR_PASSABLE 8 -#define SF_DOOR_ONEWAY 16 -#define SF_DOOR_NO_AUTO_RETURN 32 -#define SF_DOOR_ROTATE_Z 64 -#define SF_DOOR_ROTATE_X 128 -#define SF_DOOR_USE_ONLY 256 // door must be opened by player's use button. -#define SF_DOOR_NOMONSTERS 512 // Monster can't open -#define SF_DOOR_SILENT 0x80000000 - - - -#endif //DOORS_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef DOORS_H +#define DOORS_H + +// doors +#define SF_DOOR_ROTATE_Y 0 +#define SF_DOOR_START_OPEN 1 +#define SF_DOOR_ROTATE_BACKWARDS 2 +#define SF_DOOR_PASSABLE 8 +#define SF_DOOR_ONEWAY 16 +#define SF_DOOR_NO_AUTO_RETURN 32 +#define SF_DOOR_ROTATE_Z 64 +#define SF_DOOR_ROTATE_X 128 +#define SF_DOOR_USE_ONLY 256 // door must be opened by player's use button. +#define SF_DOOR_NOMONSTERS 512 // Monster can't open +#define SF_DOOR_SILENT 0x80000000 + + + +#endif //DOORS_H diff --git a/dep/rehlsdk/dlls/effects.h b/dep/rehlsdk/dlls/effects.h index ac1516d..f93a9d8 100644 --- a/dep/rehlsdk/dlls/effects.h +++ b/dep/rehlsdk/dlls/effects.h @@ -1,209 +1,209 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef EFFECTS_H -#define EFFECTS_H - -#define SF_BEAM_STARTON 0x0001 -#define SF_BEAM_TOGGLE 0x0002 -#define SF_BEAM_RANDOM 0x0004 -#define SF_BEAM_RING 0x0008 -#define SF_BEAM_SPARKSTART 0x0010 -#define SF_BEAM_SPARKEND 0x0020 -#define SF_BEAM_DECALS 0x0040 -#define SF_BEAM_SHADEIN 0x0080 -#define SF_BEAM_SHADEOUT 0x0100 -#define SF_BEAM_TEMPORARY 0x8000 - -#define SF_SPRITE_STARTON 0x0001 -#define SF_SPRITE_ONCE 0x0002 -#define SF_SPRITE_TEMPORARY 0x8000 - -class CSprite : public CPointEntity -{ -public: - void Spawn( void ); - void Precache( void ); - - int ObjectCaps( void ) - { - int flags = 0; - if ( pev->spawnflags & SF_SPRITE_TEMPORARY ) - flags = FCAP_DONT_SAVE; - return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags; - } - void EXPORT AnimateThink( void ); - void EXPORT ExpandThink( void ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void Animate( float frames ); - void Expand( float scaleSpeed, float fadeSpeed ); - void SpriteInit( const char *pSpriteName, const Vector &origin ); - - inline void SetAttachment( edict_t *pEntity, int attachment ) - { - if ( pEntity ) - { - pev->skin = ENTINDEX(pEntity); - pev->body = attachment; - pev->aiment = pEntity; - pev->movetype = MOVETYPE_FOLLOW; - } - } - void TurnOff( void ); - void TurnOn( void ); - inline float Frames( void ) { return m_maxFrame; } - inline void SetTransparency( int rendermode, int r, int g, int b, int a, int fx ) - { - pev->rendermode = rendermode; - pev->rendercolor.x = r; - pev->rendercolor.y = g; - pev->rendercolor.z = b; - pev->renderamt = a; - pev->renderfx = fx; - } - inline void SetTexture( int spriteIndex ) { pev->modelindex = spriteIndex; } - inline void SetScale( float scale ) { pev->scale = scale; } - inline void SetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; } - inline void SetBrightness( int brightness ) { pev->renderamt = brightness; } - - inline void AnimateAndDie( float framerate ) - { - SetThink(&CSprite::AnimateUntilDead); - pev->framerate = framerate; - pev->dmgtime = gpGlobals->time + (m_maxFrame / framerate); - pev->nextthink = gpGlobals->time; - } - - void EXPORT AnimateUntilDead( void ); - - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; - static CSprite *SpriteCreate( const char *pSpriteName, const Vector &origin, BOOL animate ); - -private: - - float m_lastTime; - float m_maxFrame; -}; - - -class CBeam : public CBaseEntity -{ -public: - void Spawn( void ); - void Precache( void ); - int ObjectCaps( void ) - { - int flags = 0; - if ( pev->spawnflags & SF_BEAM_TEMPORARY ) - flags = FCAP_DONT_SAVE; - return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags; - } - - void EXPORT TriggerTouch( CBaseEntity *pOther ); - - // These functions are here to show the way beams are encoded as entities. - // Encoding beams as entities simplifies their management in the client/server architecture - inline void SetType( int type ) { pev->rendermode = (pev->rendermode & 0xF0) | (type&0x0F); } - inline void SetFlags( int flags ) { pev->rendermode = (pev->rendermode & 0x0F) | (flags&0xF0); } - inline void SetStartPos( const Vector& pos ) { pev->origin = pos; } - inline void SetEndPos( const Vector& pos ) { pev->angles = pos; } - void SetStartEntity( int entityIndex ); - void SetEndEntity( int entityIndex ); - - inline void SetStartAttachment( int attachment ) { pev->sequence = (pev->sequence & 0x0FFF) | ((attachment&0xF)<<12); } - inline void SetEndAttachment( int attachment ) { pev->skin = (pev->skin & 0x0FFF) | ((attachment&0xF)<<12); } - - inline void SetTexture( int spriteIndex ) { pev->modelindex = spriteIndex; } - inline void SetWidth( int width ) { pev->scale = width; } - inline void SetNoise( int amplitude ) { pev->body = amplitude; } - inline void SetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; } - inline void SetBrightness( int brightness ) { pev->renderamt = brightness; } - inline void SetFrame( float frame ) { pev->frame = frame; } - inline void SetScrollRate( int speed ) { pev->animtime = speed; } - - inline int GetType( void ) { return pev->rendermode & 0x0F; } - inline int GetFlags( void ) { return pev->rendermode & 0xF0; } - inline int GetStartEntity( void ) { return pev->sequence & 0xFFF; } - inline int GetEndEntity( void ) { return pev->skin & 0xFFF; } - - const Vector &GetStartPos( void ); - const Vector &GetEndPos( void ); - - Vector Center( void ) { return (GetStartPos() + GetEndPos()) * 0.5; }; // center point of beam - - inline int GetTexture( void ) { return pev->modelindex; } - inline int GetWidth( void ) { return pev->scale; } - inline int GetNoise( void ) { return pev->body; } - // inline void GetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; } - inline int GetBrightness( void ) { return pev->renderamt; } - inline int GetFrame( void ) { return pev->frame; } - inline int GetScrollRate( void ) { return pev->animtime; } - - // Call after you change start/end positions - void RelinkBeam( void ); -// void SetObjectCollisionBox( void ); - - void DoSparks( const Vector &start, const Vector &end ); - CBaseEntity *RandomTargetname( const char *szName ); - void BeamDamage( TraceResult *ptr ); - // Init after BeamCreate() - void BeamInit( const char *pSpriteName, int width ); - void PointsInit( const Vector &start, const Vector &end ); - void PointEntInit( const Vector &start, int endIndex ); - void EntsInit( int startIndex, int endIndex ); - void HoseInit( const Vector &start, const Vector &direction ); - - static CBeam *BeamCreate( const char *pSpriteName, int width ); - - inline void LiveForTime( float time ) { SetThink(&CBeam::SUB_Remove); pev->nextthink = gpGlobals->time + time; } - inline void BeamDamageInstant( TraceResult *ptr, float damage ) - { - pev->dmg = damage; - pev->dmgtime = gpGlobals->time - 1; - BeamDamage(ptr); - } -}; - - -#define SF_MESSAGE_ONCE 0x0001 // Fade in, not out -#define SF_MESSAGE_ALL 0x0002 // Send to all clients - - -class CLaser : public CBeam -{ -public: - void Spawn( void ); - void Precache( void ); - void KeyValue( KeyValueData *pkvd ); - - void TurnOn( void ); - void TurnOff( void ); - int IsOn( void ); - - void FireAtPoint( TraceResult &point ); - - void EXPORT StrikeThink( void ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; - - CSprite *m_pSprite; - int m_iszSpriteName; - Vector m_firePosition; -}; - -#endif //EFFECTS_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef EFFECTS_H +#define EFFECTS_H + +#define SF_BEAM_STARTON 0x0001 +#define SF_BEAM_TOGGLE 0x0002 +#define SF_BEAM_RANDOM 0x0004 +#define SF_BEAM_RING 0x0008 +#define SF_BEAM_SPARKSTART 0x0010 +#define SF_BEAM_SPARKEND 0x0020 +#define SF_BEAM_DECALS 0x0040 +#define SF_BEAM_SHADEIN 0x0080 +#define SF_BEAM_SHADEOUT 0x0100 +#define SF_BEAM_TEMPORARY 0x8000 + +#define SF_SPRITE_STARTON 0x0001 +#define SF_SPRITE_ONCE 0x0002 +#define SF_SPRITE_TEMPORARY 0x8000 + +class CSprite : public CPointEntity +{ +public: + void Spawn( void ); + void Precache( void ); + + int ObjectCaps( void ) + { + int flags = 0; + if ( pev->spawnflags & SF_SPRITE_TEMPORARY ) + flags = FCAP_DONT_SAVE; + return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags; + } + void EXPORT AnimateThink( void ); + void EXPORT ExpandThink( void ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void Animate( float frames ); + void Expand( float scaleSpeed, float fadeSpeed ); + void SpriteInit( const char *pSpriteName, const Vector &origin ); + + inline void SetAttachment( edict_t *pEntity, int attachment ) + { + if ( pEntity ) + { + pev->skin = ENTINDEX(pEntity); + pev->body = attachment; + pev->aiment = pEntity; + pev->movetype = MOVETYPE_FOLLOW; + } + } + void TurnOff( void ); + void TurnOn( void ); + inline float Frames( void ) { return m_maxFrame; } + inline void SetTransparency( int rendermode, int r, int g, int b, int a, int fx ) + { + pev->rendermode = rendermode; + pev->rendercolor.x = r; + pev->rendercolor.y = g; + pev->rendercolor.z = b; + pev->renderamt = a; + pev->renderfx = fx; + } + inline void SetTexture( int spriteIndex ) { pev->modelindex = spriteIndex; } + inline void SetScale( float scale ) { pev->scale = scale; } + inline void SetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; } + inline void SetBrightness( int brightness ) { pev->renderamt = brightness; } + + inline void AnimateAndDie( float framerate ) + { + SetThink(&CSprite::AnimateUntilDead); + pev->framerate = framerate; + pev->dmgtime = gpGlobals->time + (m_maxFrame / framerate); + pev->nextthink = gpGlobals->time; + } + + void EXPORT AnimateUntilDead( void ); + + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; + static CSprite *SpriteCreate( const char *pSpriteName, const Vector &origin, BOOL animate ); + +private: + + float m_lastTime; + float m_maxFrame; +}; + + +class CBeam : public CBaseEntity +{ +public: + void Spawn( void ); + void Precache( void ); + int ObjectCaps( void ) + { + int flags = 0; + if ( pev->spawnflags & SF_BEAM_TEMPORARY ) + flags = FCAP_DONT_SAVE; + return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags; + } + + void EXPORT TriggerTouch( CBaseEntity *pOther ); + + // These functions are here to show the way beams are encoded as entities. + // Encoding beams as entities simplifies their management in the client/server architecture + inline void SetType( int type ) { pev->rendermode = (pev->rendermode & 0xF0) | (type&0x0F); } + inline void SetFlags( int flags ) { pev->rendermode = (pev->rendermode & 0x0F) | (flags&0xF0); } + inline void SetStartPos( const Vector& pos ) { pev->origin = pos; } + inline void SetEndPos( const Vector& pos ) { pev->angles = pos; } + void SetStartEntity( int entityIndex ); + void SetEndEntity( int entityIndex ); + + inline void SetStartAttachment( int attachment ) { pev->sequence = (pev->sequence & 0x0FFF) | ((attachment&0xF)<<12); } + inline void SetEndAttachment( int attachment ) { pev->skin = (pev->skin & 0x0FFF) | ((attachment&0xF)<<12); } + + inline void SetTexture( int spriteIndex ) { pev->modelindex = spriteIndex; } + inline void SetWidth( int width ) { pev->scale = width; } + inline void SetNoise( int amplitude ) { pev->body = amplitude; } + inline void SetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; } + inline void SetBrightness( int brightness ) { pev->renderamt = brightness; } + inline void SetFrame( float frame ) { pev->frame = frame; } + inline void SetScrollRate( int speed ) { pev->animtime = speed; } + + inline int GetType( void ) { return pev->rendermode & 0x0F; } + inline int GetFlags( void ) { return pev->rendermode & 0xF0; } + inline int GetStartEntity( void ) { return pev->sequence & 0xFFF; } + inline int GetEndEntity( void ) { return pev->skin & 0xFFF; } + + const Vector &GetStartPos( void ); + const Vector &GetEndPos( void ); + + Vector Center( void ) { return (GetStartPos() + GetEndPos()) * 0.5; }; // center point of beam + + inline int GetTexture( void ) { return pev->modelindex; } + inline int GetWidth( void ) { return pev->scale; } + inline int GetNoise( void ) { return pev->body; } + // inline void GetColor( int r, int g, int b ) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; } + inline int GetBrightness( void ) { return pev->renderamt; } + inline int GetFrame( void ) { return pev->frame; } + inline int GetScrollRate( void ) { return pev->animtime; } + + // Call after you change start/end positions + void RelinkBeam( void ); +// void SetObjectCollisionBox( void ); + + void DoSparks( const Vector &start, const Vector &end ); + CBaseEntity *RandomTargetname( const char *szName ); + void BeamDamage( TraceResult *ptr ); + // Init after BeamCreate() + void BeamInit( const char *pSpriteName, int width ); + void PointsInit( const Vector &start, const Vector &end ); + void PointEntInit( const Vector &start, int endIndex ); + void EntsInit( int startIndex, int endIndex ); + void HoseInit( const Vector &start, const Vector &direction ); + + static CBeam *BeamCreate( const char *pSpriteName, int width ); + + inline void LiveForTime( float time ) { SetThink(&CBeam::SUB_Remove); pev->nextthink = gpGlobals->time + time; } + inline void BeamDamageInstant( TraceResult *ptr, float damage ) + { + pev->dmg = damage; + pev->dmgtime = gpGlobals->time - 1; + BeamDamage(ptr); + } +}; + + +#define SF_MESSAGE_ONCE 0x0001 // Fade in, not out +#define SF_MESSAGE_ALL 0x0002 // Send to all clients + + +class CLaser : public CBeam +{ +public: + void Spawn( void ); + void Precache( void ); + void KeyValue( KeyValueData *pkvd ); + + void TurnOn( void ); + void TurnOff( void ); + int IsOn( void ); + + void FireAtPoint( TraceResult &point ); + + void EXPORT StrikeThink( void ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; + + CSprite *m_pSprite; + int m_iszSpriteName; + Vector m_firePosition; +}; + +#endif //EFFECTS_H diff --git a/dep/rehlsdk/dlls/enginecallback.h b/dep/rehlsdk/dlls/enginecallback.h index 32925f3..ddca3d3 100644 --- a/dep/rehlsdk/dlls/enginecallback.h +++ b/dep/rehlsdk/dlls/enginecallback.h @@ -1,160 +1,160 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef ENGINECALLBACK_H -#define ENGINECALLBACK_H -#ifdef _WIN32 -#pragma once -#endif - -#include "event_flags.h" - -// Must be provided by user of this code -extern enginefuncs_t g_engfuncs; - -// The actual engine callbacks -#define GETPLAYERUSERID (*g_engfuncs.pfnGetPlayerUserId) -#define PRECACHE_MODEL (*g_engfuncs.pfnPrecacheModel) -#define PRECACHE_SOUND (*g_engfuncs.pfnPrecacheSound) -#define PRECACHE_GENERIC (*g_engfuncs.pfnPrecacheGeneric) -#define SET_MODEL (*g_engfuncs.pfnSetModel) -#define MODEL_INDEX (*g_engfuncs.pfnModelIndex) -#define MODEL_FRAMES (*g_engfuncs.pfnModelFrames) -#define SET_SIZE (*g_engfuncs.pfnSetSize) -#define CHANGE_LEVEL (*g_engfuncs.pfnChangeLevel) -#define GET_SPAWN_PARMS (*g_engfuncs.pfnGetSpawnParms) -#define SAVE_SPAWN_PARMS (*g_engfuncs.pfnSaveSpawnParms) -#define VEC_TO_YAW (*g_engfuncs.pfnVecToYaw) -#define VEC_TO_ANGLES (*g_engfuncs.pfnVecToAngles) -#define MOVE_TO_ORIGIN (*g_engfuncs.pfnMoveToOrigin) -#define oldCHANGE_YAW (*g_engfuncs.pfnChangeYaw) -#define CHANGE_PITCH (*g_engfuncs.pfnChangePitch) -#define MAKE_VECTORS (*g_engfuncs.pfnMakeVectors) -#define CREATE_ENTITY (*g_engfuncs.pfnCreateEntity) -#define REMOVE_ENTITY (*g_engfuncs.pfnRemoveEntity) -#define CREATE_NAMED_ENTITY (*g_engfuncs.pfnCreateNamedEntity) -#define MAKE_STATIC (*g_engfuncs.pfnMakeStatic) -#define ENT_IS_ON_FLOOR (*g_engfuncs.pfnEntIsOnFloor) -#define DROP_TO_FLOOR (*g_engfuncs.pfnDropToFloor) -#define WALK_MOVE (*g_engfuncs.pfnWalkMove) -#define SET_ORIGIN (*g_engfuncs.pfnSetOrigin) -#define EMIT_SOUND_DYN2 (*g_engfuncs.pfnEmitSound) -#define BUILD_SOUND_MSG (*g_engfuncs.pfnBuildSoundMsg) -#define TRACE_LINE (*g_engfuncs.pfnTraceLine) -#define TRACE_TOSS (*g_engfuncs.pfnTraceToss) -#define TRACE_MONSTER_HULL (*g_engfuncs.pfnTraceMonsterHull) -#define TRACE_HULL (*g_engfuncs.pfnTraceHull) -#define GET_AIM_VECTOR (*g_engfuncs.pfnGetAimVector) -#define SERVER_COMMAND (*g_engfuncs.pfnServerCommand) -#define SERVER_EXECUTE (*g_engfuncs.pfnServerExecute) -#define CLIENT_COMMAND (*g_engfuncs.pfnClientCommand) -#define PARTICLE_EFFECT (*g_engfuncs.pfnParticleEffect) -#define LIGHT_STYLE (*g_engfuncs.pfnLightStyle) -#define DECAL_INDEX (*g_engfuncs.pfnDecalIndex) -#define POINT_CONTENTS (*g_engfuncs.pfnPointContents) -#define CRC32_INIT (*g_engfuncs.pfnCRC32_Init) -#define CRC32_PROCESS_BUFFER (*g_engfuncs.pfnCRC32_ProcessBuffer) -#define CRC32_PROCESS_BYTE (*g_engfuncs.pfnCRC32_ProcessByte) -#define CRC32_FINAL (*g_engfuncs.pfnCRC32_Final) -#define RANDOM_LONG (*g_engfuncs.pfnRandomLong) -#define RANDOM_FLOAT (*g_engfuncs.pfnRandomFloat) -#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId) - -inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin = NULL, edict_t *ed = NULL ) { - (*g_engfuncs.pfnMessageBegin)(msg_dest, msg_type, pOrigin, ed); -} -#define MESSAGE_END (*g_engfuncs.pfnMessageEnd) -#define WRITE_BYTE (*g_engfuncs.pfnWriteByte) -#define WRITE_CHAR (*g_engfuncs.pfnWriteChar) -#define WRITE_SHORT (*g_engfuncs.pfnWriteShort) -#define WRITE_LONG (*g_engfuncs.pfnWriteLong) -#define WRITE_ANGLE (*g_engfuncs.pfnWriteAngle) -#define WRITE_COORD (*g_engfuncs.pfnWriteCoord) -#define WRITE_STRING (*g_engfuncs.pfnWriteString) -#define WRITE_ENTITY (*g_engfuncs.pfnWriteEntity) -#define CVAR_REGISTER (*g_engfuncs.pfnCVarRegister) -#define CVAR_GET_FLOAT (*g_engfuncs.pfnCVarGetFloat) -#define CVAR_GET_STRING (*g_engfuncs.pfnCVarGetString) -#define CVAR_SET_FLOAT (*g_engfuncs.pfnCVarSetFloat) -#define CVAR_SET_STRING (*g_engfuncs.pfnCVarSetString) -#define CVAR_GET_POINTER (*g_engfuncs.pfnCVarGetPointer) -#define ALERT (*g_engfuncs.pfnAlertMessage) -#define ENGINE_FPRINTF (*g_engfuncs.pfnEngineFprintf) -#define ALLOC_PRIVATE (*g_engfuncs.pfnPvAllocEntPrivateData) -inline void *GET_PRIVATE( edict_t *pent ) -{ - if ( pent ) - return pent->pvPrivateData; - return NULL; -} - -#define FREE_PRIVATE (*g_engfuncs.pfnFreeEntPrivateData) -//#define STRING (*g_engfuncs.pfnSzFromIndex) -#define ALLOC_STRING (*g_engfuncs.pfnAllocString) -#define FIND_ENTITY_BY_STRING (*g_engfuncs.pfnFindEntityByString) -#define GETENTITYILLUM (*g_engfuncs.pfnGetEntityIllum) -#define FIND_ENTITY_IN_SPHERE (*g_engfuncs.pfnFindEntityInSphere) -#define FIND_CLIENT_IN_PVS (*g_engfuncs.pfnFindClientInPVS) -#define EMIT_AMBIENT_SOUND (*g_engfuncs.pfnEmitAmbientSound) -#define GET_MODEL_PTR (*g_engfuncs.pfnGetModelPtr) -#define REG_USER_MSG (*g_engfuncs.pfnRegUserMsg) -#define GET_BONE_POSITION (*g_engfuncs.pfnGetBonePosition) -#define FUNCTION_FROM_NAME (*g_engfuncs.pfnFunctionFromName) -#define NAME_FOR_FUNCTION (*g_engfuncs.pfnNameForFunction) -#define TRACE_TEXTURE (*g_engfuncs.pfnTraceTexture) -#define CLIENT_PRINTF (*g_engfuncs.pfnClientPrintf) -#define CMD_ARGS (*g_engfuncs.pfnCmd_Args) -#define CMD_ARGC (*g_engfuncs.pfnCmd_Argc) -#define CMD_ARGV (*g_engfuncs.pfnCmd_Argv) -#define GET_ATTACHMENT (*g_engfuncs.pfnGetAttachment) -#define SET_VIEW (*g_engfuncs.pfnSetView) -#define SET_CROSSHAIRANGLE (*g_engfuncs.pfnCrosshairAngle) -#define LOAD_FILE_FOR_ME (*g_engfuncs.pfnLoadFileForMe) -#define FREE_FILE (*g_engfuncs.pfnFreeFile) -#define COMPARE_FILE_TIME (*g_engfuncs.pfnCompareFileTime) -#define GET_GAME_DIR (*g_engfuncs.pfnGetGameDir) -#define IS_MAP_VALID (*g_engfuncs.pfnIsMapValid) -#define NUMBER_OF_ENTITIES (*g_engfuncs.pfnNumberOfEntities) -#define IS_DEDICATED_SERVER (*g_engfuncs.pfnIsDedicatedServer) - -#define PRECACHE_EVENT (*g_engfuncs.pfnPrecacheEvent) -#define PLAYBACK_EVENT_FULL (*g_engfuncs.pfnPlaybackEvent) - -#define ENGINE_SET_PVS (*g_engfuncs.pfnSetFatPVS) -#define ENGINE_SET_PAS (*g_engfuncs.pfnSetFatPAS) - -#define ENGINE_CHECK_VISIBILITY (*g_engfuncs.pfnCheckVisibility) - -#define DELTA_SET ( *g_engfuncs.pfnDeltaSetField ) -#define DELTA_UNSET ( *g_engfuncs.pfnDeltaUnsetField ) -#define DELTA_ADDENCODER ( *g_engfuncs.pfnDeltaAddEncoder ) -#define ENGINE_CURRENT_PLAYER ( *g_engfuncs.pfnGetCurrentPlayer ) - -#define ENGINE_CANSKIP ( *g_engfuncs.pfnCanSkipPlayer ) - -#define DELTA_FINDFIELD ( *g_engfuncs.pfnDeltaFindField ) -#define DELTA_SETBYINDEX ( *g_engfuncs.pfnDeltaSetFieldByIndex ) -#define DELTA_UNSETBYINDEX ( *g_engfuncs.pfnDeltaUnsetFieldByIndex ) - -#define ENGINE_GETPHYSINFO ( *g_engfuncs.pfnGetPhysicsInfoString ) - -#define ENGINE_SETGROUPMASK ( *g_engfuncs.pfnSetGroupMask ) - -#define ENGINE_INSTANCE_BASELINE ( *g_engfuncs.pfnCreateInstancedBaseline ) - -#define ENGINE_FORCE_UNMODIFIED ( *g_engfuncs.pfnForceUnmodified ) - -#define PLAYER_CNX_STATS ( *g_engfuncs.pfnGetPlayerStats ) - -#endif //ENGINECALLBACK_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef ENGINECALLBACK_H +#define ENGINECALLBACK_H +#ifdef _WIN32 +#pragma once +#endif + +#include "event_flags.h" + +// Must be provided by user of this code +extern enginefuncs_t g_engfuncs; + +// The actual engine callbacks +#define GETPLAYERUSERID (*g_engfuncs.pfnGetPlayerUserId) +#define PRECACHE_MODEL (*g_engfuncs.pfnPrecacheModel) +#define PRECACHE_SOUND (*g_engfuncs.pfnPrecacheSound) +#define PRECACHE_GENERIC (*g_engfuncs.pfnPrecacheGeneric) +#define SET_MODEL (*g_engfuncs.pfnSetModel) +#define MODEL_INDEX (*g_engfuncs.pfnModelIndex) +#define MODEL_FRAMES (*g_engfuncs.pfnModelFrames) +#define SET_SIZE (*g_engfuncs.pfnSetSize) +#define CHANGE_LEVEL (*g_engfuncs.pfnChangeLevel) +#define GET_SPAWN_PARMS (*g_engfuncs.pfnGetSpawnParms) +#define SAVE_SPAWN_PARMS (*g_engfuncs.pfnSaveSpawnParms) +#define VEC_TO_YAW (*g_engfuncs.pfnVecToYaw) +#define VEC_TO_ANGLES (*g_engfuncs.pfnVecToAngles) +#define MOVE_TO_ORIGIN (*g_engfuncs.pfnMoveToOrigin) +#define oldCHANGE_YAW (*g_engfuncs.pfnChangeYaw) +#define CHANGE_PITCH (*g_engfuncs.pfnChangePitch) +#define MAKE_VECTORS (*g_engfuncs.pfnMakeVectors) +#define CREATE_ENTITY (*g_engfuncs.pfnCreateEntity) +#define REMOVE_ENTITY (*g_engfuncs.pfnRemoveEntity) +#define CREATE_NAMED_ENTITY (*g_engfuncs.pfnCreateNamedEntity) +#define MAKE_STATIC (*g_engfuncs.pfnMakeStatic) +#define ENT_IS_ON_FLOOR (*g_engfuncs.pfnEntIsOnFloor) +#define DROP_TO_FLOOR (*g_engfuncs.pfnDropToFloor) +#define WALK_MOVE (*g_engfuncs.pfnWalkMove) +#define SET_ORIGIN (*g_engfuncs.pfnSetOrigin) +#define EMIT_SOUND_DYN2 (*g_engfuncs.pfnEmitSound) +#define BUILD_SOUND_MSG (*g_engfuncs.pfnBuildSoundMsg) +#define TRACE_LINE (*g_engfuncs.pfnTraceLine) +#define TRACE_TOSS (*g_engfuncs.pfnTraceToss) +#define TRACE_MONSTER_HULL (*g_engfuncs.pfnTraceMonsterHull) +#define TRACE_HULL (*g_engfuncs.pfnTraceHull) +#define GET_AIM_VECTOR (*g_engfuncs.pfnGetAimVector) +#define SERVER_COMMAND (*g_engfuncs.pfnServerCommand) +#define SERVER_EXECUTE (*g_engfuncs.pfnServerExecute) +#define CLIENT_COMMAND (*g_engfuncs.pfnClientCommand) +#define PARTICLE_EFFECT (*g_engfuncs.pfnParticleEffect) +#define LIGHT_STYLE (*g_engfuncs.pfnLightStyle) +#define DECAL_INDEX (*g_engfuncs.pfnDecalIndex) +#define POINT_CONTENTS (*g_engfuncs.pfnPointContents) +#define CRC32_INIT (*g_engfuncs.pfnCRC32_Init) +#define CRC32_PROCESS_BUFFER (*g_engfuncs.pfnCRC32_ProcessBuffer) +#define CRC32_PROCESS_BYTE (*g_engfuncs.pfnCRC32_ProcessByte) +#define CRC32_FINAL (*g_engfuncs.pfnCRC32_Final) +#define RANDOM_LONG (*g_engfuncs.pfnRandomLong) +#define RANDOM_FLOAT (*g_engfuncs.pfnRandomFloat) +#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId) + +inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin = NULL, edict_t *ed = NULL ) { + (*g_engfuncs.pfnMessageBegin)(msg_dest, msg_type, pOrigin, ed); +} +#define MESSAGE_END (*g_engfuncs.pfnMessageEnd) +#define WRITE_BYTE (*g_engfuncs.pfnWriteByte) +#define WRITE_CHAR (*g_engfuncs.pfnWriteChar) +#define WRITE_SHORT (*g_engfuncs.pfnWriteShort) +#define WRITE_LONG (*g_engfuncs.pfnWriteLong) +#define WRITE_ANGLE (*g_engfuncs.pfnWriteAngle) +#define WRITE_COORD (*g_engfuncs.pfnWriteCoord) +#define WRITE_STRING (*g_engfuncs.pfnWriteString) +#define WRITE_ENTITY (*g_engfuncs.pfnWriteEntity) +#define CVAR_REGISTER (*g_engfuncs.pfnCVarRegister) +#define CVAR_GET_FLOAT (*g_engfuncs.pfnCVarGetFloat) +#define CVAR_GET_STRING (*g_engfuncs.pfnCVarGetString) +#define CVAR_SET_FLOAT (*g_engfuncs.pfnCVarSetFloat) +#define CVAR_SET_STRING (*g_engfuncs.pfnCVarSetString) +#define CVAR_GET_POINTER (*g_engfuncs.pfnCVarGetPointer) +#define ALERT (*g_engfuncs.pfnAlertMessage) +#define ENGINE_FPRINTF (*g_engfuncs.pfnEngineFprintf) +#define ALLOC_PRIVATE (*g_engfuncs.pfnPvAllocEntPrivateData) +inline void *GET_PRIVATE( edict_t *pent ) +{ + if ( pent ) + return pent->pvPrivateData; + return NULL; +} + +#define FREE_PRIVATE (*g_engfuncs.pfnFreeEntPrivateData) +//#define STRING (*g_engfuncs.pfnSzFromIndex) +#define ALLOC_STRING (*g_engfuncs.pfnAllocString) +#define FIND_ENTITY_BY_STRING (*g_engfuncs.pfnFindEntityByString) +#define GETENTITYILLUM (*g_engfuncs.pfnGetEntityIllum) +#define FIND_ENTITY_IN_SPHERE (*g_engfuncs.pfnFindEntityInSphere) +#define FIND_CLIENT_IN_PVS (*g_engfuncs.pfnFindClientInPVS) +#define EMIT_AMBIENT_SOUND (*g_engfuncs.pfnEmitAmbientSound) +#define GET_MODEL_PTR (*g_engfuncs.pfnGetModelPtr) +#define REG_USER_MSG (*g_engfuncs.pfnRegUserMsg) +#define GET_BONE_POSITION (*g_engfuncs.pfnGetBonePosition) +#define FUNCTION_FROM_NAME (*g_engfuncs.pfnFunctionFromName) +#define NAME_FOR_FUNCTION (*g_engfuncs.pfnNameForFunction) +#define TRACE_TEXTURE (*g_engfuncs.pfnTraceTexture) +#define CLIENT_PRINTF (*g_engfuncs.pfnClientPrintf) +#define CMD_ARGS (*g_engfuncs.pfnCmd_Args) +#define CMD_ARGC (*g_engfuncs.pfnCmd_Argc) +#define CMD_ARGV (*g_engfuncs.pfnCmd_Argv) +#define GET_ATTACHMENT (*g_engfuncs.pfnGetAttachment) +#define SET_VIEW (*g_engfuncs.pfnSetView) +#define SET_CROSSHAIRANGLE (*g_engfuncs.pfnCrosshairAngle) +#define LOAD_FILE_FOR_ME (*g_engfuncs.pfnLoadFileForMe) +#define FREE_FILE (*g_engfuncs.pfnFreeFile) +#define COMPARE_FILE_TIME (*g_engfuncs.pfnCompareFileTime) +#define GET_GAME_DIR (*g_engfuncs.pfnGetGameDir) +#define IS_MAP_VALID (*g_engfuncs.pfnIsMapValid) +#define NUMBER_OF_ENTITIES (*g_engfuncs.pfnNumberOfEntities) +#define IS_DEDICATED_SERVER (*g_engfuncs.pfnIsDedicatedServer) + +#define PRECACHE_EVENT (*g_engfuncs.pfnPrecacheEvent) +#define PLAYBACK_EVENT_FULL (*g_engfuncs.pfnPlaybackEvent) + +#define ENGINE_SET_PVS (*g_engfuncs.pfnSetFatPVS) +#define ENGINE_SET_PAS (*g_engfuncs.pfnSetFatPAS) + +#define ENGINE_CHECK_VISIBILITY (*g_engfuncs.pfnCheckVisibility) + +#define DELTA_SET ( *g_engfuncs.pfnDeltaSetField ) +#define DELTA_UNSET ( *g_engfuncs.pfnDeltaUnsetField ) +#define DELTA_ADDENCODER ( *g_engfuncs.pfnDeltaAddEncoder ) +#define ENGINE_CURRENT_PLAYER ( *g_engfuncs.pfnGetCurrentPlayer ) + +#define ENGINE_CANSKIP ( *g_engfuncs.pfnCanSkipPlayer ) + +#define DELTA_FINDFIELD ( *g_engfuncs.pfnDeltaFindField ) +#define DELTA_SETBYINDEX ( *g_engfuncs.pfnDeltaSetFieldByIndex ) +#define DELTA_UNSETBYINDEX ( *g_engfuncs.pfnDeltaUnsetFieldByIndex ) + +#define ENGINE_GETPHYSINFO ( *g_engfuncs.pfnGetPhysicsInfoString ) + +#define ENGINE_SETGROUPMASK ( *g_engfuncs.pfnSetGroupMask ) + +#define ENGINE_INSTANCE_BASELINE ( *g_engfuncs.pfnCreateInstancedBaseline ) + +#define ENGINE_FORCE_UNMODIFIED ( *g_engfuncs.pfnForceUnmodified ) + +#define PLAYER_CNX_STATS ( *g_engfuncs.pfnGetPlayerStats ) + +#endif //ENGINECALLBACK_H diff --git a/dep/rehlsdk/dlls/explode.h b/dep/rehlsdk/dlls/explode.h index 3d8c410..3feb011 100644 --- a/dep/rehlsdk/dlls/explode.h +++ b/dep/rehlsdk/dlls/explode.h @@ -1,32 +1,32 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef EXPLODE_H -#define EXPLODE_H - - -#define SF_ENVEXPLOSION_NODAMAGE ( 1 << 0 ) // when set, ENV_EXPLOSION will not actually inflict damage -#define SF_ENVEXPLOSION_REPEATABLE ( 1 << 1 ) // can this entity be refired? -#define SF_ENVEXPLOSION_NOFIREBALL ( 1 << 2 ) // don't draw the fireball -#define SF_ENVEXPLOSION_NOSMOKE ( 1 << 3 ) // don't draw the smoke -#define SF_ENVEXPLOSION_NODECAL ( 1 << 4 ) // don't make a scorch mark -#define SF_ENVEXPLOSION_NOSPARKS ( 1 << 5 ) // don't make a scorch mark - -extern DLL_GLOBAL short g_sModelIndexFireball; -extern DLL_GLOBAL short g_sModelIndexSmoke; - - -extern void ExplosionCreate( const Vector ¢er, const Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage ); - -#endif //EXPLODE_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef EXPLODE_H +#define EXPLODE_H + + +#define SF_ENVEXPLOSION_NODAMAGE ( 1 << 0 ) // when set, ENV_EXPLOSION will not actually inflict damage +#define SF_ENVEXPLOSION_REPEATABLE ( 1 << 1 ) // can this entity be refired? +#define SF_ENVEXPLOSION_NOFIREBALL ( 1 << 2 ) // don't draw the fireball +#define SF_ENVEXPLOSION_NOSMOKE ( 1 << 3 ) // don't draw the smoke +#define SF_ENVEXPLOSION_NODECAL ( 1 << 4 ) // don't make a scorch mark +#define SF_ENVEXPLOSION_NOSPARKS ( 1 << 5 ) // don't make a scorch mark + +extern DLL_GLOBAL short g_sModelIndexFireball; +extern DLL_GLOBAL short g_sModelIndexSmoke; + + +extern void ExplosionCreate( const Vector ¢er, const Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage ); + +#endif //EXPLODE_H diff --git a/dep/rehlsdk/dlls/extdll.h b/dep/rehlsdk/dlls/extdll.h index e264f87..2f8786c 100644 --- a/dep/rehlsdk/dlls/extdll.h +++ b/dep/rehlsdk/dlls/extdll.h @@ -1,97 +1,97 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef EXTDLL_H -#define EXTDLL_H - - -// -// Global header file for extension DLLs -// - -// Allow "DEBUG" in addition to default "_DEBUG" -#ifdef _DEBUG -#define DEBUG 1 -#endif - -// Silence certain warnings -#pragma warning(disable : 4244) // int or float down-conversion -#pragma warning(disable : 4305) // int or float data truncation -#pragma warning(disable : 4201) // nameless struct/union -#pragma warning(disable : 4514) // unreferenced inline function removed -#pragma warning(disable : 4100) // unreferenced formal parameter - -#include "archtypes.h" // DAL - -// Prevent tons of unused windows definitions -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#define NOWINRES -#define NOSERVICE -#define NOMCX -#define NOIME -#include "winsani_in.h" -#include "windows.h" -#include "winsani_out.h" -#else // _WIN32 -#ifndef TRUE -#define FALSE 0 -#define TRUE (!FALSE) -#endif //TRUE -typedef uint32 ULONG; -typedef unsigned char BYTE; -typedef int BOOL; -#ifndef MAX_PATH -#define MAX_PATH PATH_MAX -#endif // MAX_PATH -#include -#include -#include // memset -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) -#define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d) -#endif -#endif //_WIN32 - -// Misc C-runtime library headers -#include "stdio.h" -#include "stdlib.h" -#include "math.h" - -// Header file containing definition of globalvars_t and entvars_t -typedef unsigned int func_t; // -typedef unsigned int string_t; // from engine's pr_comp.h; -typedef float vec_t; // needed before including progdefs.h - -// Vector class -#include "vector.h" - -// Defining it as a (bogus) struct helps enforce type-checking -#define vec3_t Vector - -// Shared engine/DLL constants -#include "const.h" -#include "progdefs.h" -#include "edict.h" - -// Shared header describing protocol between engine and DLLs -#include "eiface.h" - -// Shared header between the client DLL and the game DLLs -#include "cdll_dll.h" - -#endif //EXTDLL_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef EXTDLL_H +#define EXTDLL_H + + +// +// Global header file for extension DLLs +// + +// Allow "DEBUG" in addition to default "_DEBUG" +#ifdef _DEBUG +#define DEBUG 1 +#endif + +// Silence certain warnings +#pragma warning(disable : 4244) // int or float down-conversion +#pragma warning(disable : 4305) // int or float data truncation +#pragma warning(disable : 4201) // nameless struct/union +#pragma warning(disable : 4514) // unreferenced inline function removed +#pragma warning(disable : 4100) // unreferenced formal parameter + +#include "archtypes.h" // DAL + +// Prevent tons of unused windows definitions +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#define NOWINRES +#define NOSERVICE +#define NOMCX +#define NOIME +#include "winsani_in.h" +#include "windows.h" +#include "winsani_out.h" +#else // _WIN32 +#ifndef TRUE +#define FALSE 0 +#define TRUE (!FALSE) +#endif //TRUE +typedef uint32 ULONG; +typedef unsigned char BYTE; +typedef int BOOL; +#ifndef MAX_PATH +#define MAX_PATH PATH_MAX +#endif // MAX_PATH +#include +#include +#include // memset +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d) +#endif +#endif //_WIN32 + +// Misc C-runtime library headers +#include "stdio.h" +#include "stdlib.h" +#include "math.h" + +// Header file containing definition of globalvars_t and entvars_t +typedef unsigned int func_t; // +typedef unsigned int string_t; // from engine's pr_comp.h; +typedef float vec_t; // needed before including progdefs.h + +// Vector class +#include "vector.h" + +// Defining it as a (bogus) struct helps enforce type-checking +#define vec3_t Vector + +// Shared engine/DLL constants +#include "const.h" +#include "progdefs.h" +#include "edict.h" + +// Shared header describing protocol between engine and DLLs +#include "eiface.h" + +// Shared header between the client DLL and the game DLLs +#include "cdll_dll.h" + +#endif //EXTDLL_H diff --git a/dep/rehlsdk/dlls/func_break.h b/dep/rehlsdk/dlls/func_break.h index 2441f75..9bb281d 100644 --- a/dep/rehlsdk/dlls/func_break.h +++ b/dep/rehlsdk/dlls/func_break.h @@ -1,74 +1,74 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef FUNC_BREAK_H -#define FUNC_BREAK_H - -typedef enum { expRandom, expDirected} Explosions; -typedef enum { matGlass = 0, matWood, matMetal, matFlesh, matCinderBlock, matCeilingTile, matComputer, matUnbreakableGlass, matRocks, matNone, matLastMaterial } Materials; - -#define NUM_SHARDS 6 // this many shards spawned when breakable objects break; - -class CBreakable : public CBaseDelay -{ -public: - // basic functions - void Spawn( void ); - void Precache( void ); - void KeyValue( KeyValueData* pkvd); - void EXPORT BreakTouch( CBaseEntity *pOther ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void DamageSound( void ); - - // breakables use an overridden takedamage - virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); - // To spark when hit - void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); - - BOOL IsBreakable( void ); - BOOL SparkWhenHit( void ); - - int DamageDecal( int bitsDamageType ); - - void EXPORT Die( void ); - virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION); } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - inline BOOL Explodable( void ) { return ExplosionMagnitude() > 0; } - inline int ExplosionMagnitude( void ) { return pev->impulse; } - inline void ExplosionSetMagnitude( int magnitude ) { pev->impulse = magnitude; } - - static void MaterialSoundPrecache( Materials precacheMaterial ); - static void MaterialSoundRandom( edict_t *pEdict, Materials soundMaterial, float volume ); - static const char **MaterialSoundList( Materials precacheMaterial, int &soundCount ); - - static const char *pSoundsWood[]; - static const char *pSoundsFlesh[]; - static const char *pSoundsGlass[]; - static const char *pSoundsMetal[]; - static const char *pSoundsConcrete[]; - static const char *pSpawnObjects[]; - - static TYPEDESCRIPTION m_SaveData[]; - - Materials m_Material; - Explosions m_Explosion; - int m_idShard; - float m_angle; - int m_iszGibModel; - int m_iszSpawnObject; -}; - -#endif // FUNC_BREAK_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef FUNC_BREAK_H +#define FUNC_BREAK_H + +typedef enum { expRandom, expDirected} Explosions; +typedef enum { matGlass = 0, matWood, matMetal, matFlesh, matCinderBlock, matCeilingTile, matComputer, matUnbreakableGlass, matRocks, matNone, matLastMaterial } Materials; + +#define NUM_SHARDS 6 // this many shards spawned when breakable objects break; + +class CBreakable : public CBaseDelay +{ +public: + // basic functions + void Spawn( void ); + void Precache( void ); + void KeyValue( KeyValueData* pkvd); + void EXPORT BreakTouch( CBaseEntity *pOther ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void DamageSound( void ); + + // breakables use an overridden takedamage + virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); + // To spark when hit + void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); + + BOOL IsBreakable( void ); + BOOL SparkWhenHit( void ); + + int DamageDecal( int bitsDamageType ); + + void EXPORT Die( void ); + virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION); } + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + + inline BOOL Explodable( void ) { return ExplosionMagnitude() > 0; } + inline int ExplosionMagnitude( void ) { return pev->impulse; } + inline void ExplosionSetMagnitude( int magnitude ) { pev->impulse = magnitude; } + + static void MaterialSoundPrecache( Materials precacheMaterial ); + static void MaterialSoundRandom( edict_t *pEdict, Materials soundMaterial, float volume ); + static const char **MaterialSoundList( Materials precacheMaterial, int &soundCount ); + + static const char *pSoundsWood[]; + static const char *pSoundsFlesh[]; + static const char *pSoundsGlass[]; + static const char *pSoundsMetal[]; + static const char *pSoundsConcrete[]; + static const char *pSpawnObjects[]; + + static TYPEDESCRIPTION m_SaveData[]; + + Materials m_Material; + Explosions m_Explosion; + int m_idShard; + float m_angle; + int m_iszGibModel; + int m_iszSpawnObject; +}; + +#endif // FUNC_BREAK_H diff --git a/dep/rehlsdk/dlls/game.h b/dep/rehlsdk/dlls/game.h index 7bd9dce..58e7e75 100644 --- a/dep/rehlsdk/dlls/game.h +++ b/dep/rehlsdk/dlls/game.h @@ -1,45 +1,45 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#ifndef GAME_H -#define GAME_H - -extern void GameDLLInit( void ); - - -extern cvar_t displaysoundlist; - -// multiplayer server rules -extern cvar_t teamplay; -extern cvar_t fraglimit; -extern cvar_t timelimit; -extern cvar_t friendlyfire; -extern cvar_t falldamage; -extern cvar_t weaponstay; -extern cvar_t forcerespawn; -extern cvar_t flashlight; -extern cvar_t aimcrosshair; -extern cvar_t decalfrequency; -extern cvar_t teamlist; -extern cvar_t teamoverride; -extern cvar_t defaultteam; -extern cvar_t allowmonsters; - -// Engine Cvars -extern cvar_t *g_psv_gravity; -extern cvar_t *g_psv_aim; -extern cvar_t *g_footsteps; - -#endif // GAME_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +#ifndef GAME_H +#define GAME_H + +extern void GameDLLInit( void ); + + +extern cvar_t displaysoundlist; + +// multiplayer server rules +extern cvar_t teamplay; +extern cvar_t fraglimit; +extern cvar_t timelimit; +extern cvar_t friendlyfire; +extern cvar_t falldamage; +extern cvar_t weaponstay; +extern cvar_t forcerespawn; +extern cvar_t flashlight; +extern cvar_t aimcrosshair; +extern cvar_t decalfrequency; +extern cvar_t teamlist; +extern cvar_t teamoverride; +extern cvar_t defaultteam; +extern cvar_t allowmonsters; + +// Engine Cvars +extern cvar_t *g_psv_gravity; +extern cvar_t *g_psv_aim; +extern cvar_t *g_footsteps; + +#endif // GAME_H diff --git a/dep/rehlsdk/dlls/gamerules.h b/dep/rehlsdk/dlls/gamerules.h index 2e85304..76b3515 100644 --- a/dep/rehlsdk/dlls/gamerules.h +++ b/dep/rehlsdk/dlls/gamerules.h @@ -1,360 +1,360 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -//========================================================= -// GameRules -//========================================================= - -//#include "weapons.h" -//#include "items.h" -class CBasePlayerItem; -class CBasePlayer; -class CItem; -class CBasePlayerAmmo; - -// weapon respawning return codes -enum -{ - GR_NONE = 0, - - GR_WEAPON_RESPAWN_YES, - GR_WEAPON_RESPAWN_NO, - - GR_AMMO_RESPAWN_YES, - GR_AMMO_RESPAWN_NO, - - GR_ITEM_RESPAWN_YES, - GR_ITEM_RESPAWN_NO, - - GR_PLR_DROP_GUN_ALL, - GR_PLR_DROP_GUN_ACTIVE, - GR_PLR_DROP_GUN_NO, - - GR_PLR_DROP_AMMO_ALL, - GR_PLR_DROP_AMMO_ACTIVE, - GR_PLR_DROP_AMMO_NO, -}; - -// Player relationship return codes -enum -{ - GR_NOTTEAMMATE = 0, - GR_TEAMMATE, - GR_ENEMY, - GR_ALLY, - GR_NEUTRAL, -}; - -class CGameRules -{ -public: - virtual void RefreshSkillData( void );// fill skill data struct with proper values - virtual void Think( void ) = 0;// GR_Think - runs every server frame, should handle any timer tasks, periodic events, etc. - virtual BOOL IsAllowedToSpawn( CBaseEntity *pEntity ) = 0; // Can this item spawn (eg monsters don't spawn in deathmatch). - - virtual BOOL FAllowFlashlight( void ) = 0;// Are players allowed to switch on their flashlight? - virtual BOOL FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ) = 0;// should the player switch to this weapon? - virtual BOOL GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ) = 0;// I can't use this weapon anymore, get me the next best one. - -// Functions to verify the single/multiplayer status of a game - virtual BOOL IsMultiplayer( void ) = 0;// is this a multiplayer game? (either coop or deathmatch) - virtual BOOL IsDeathmatch( void ) = 0;//is this a deathmatch game? - virtual BOOL IsTeamplay( void ) { return FALSE; };// is this deathmatch game being played with team rules? - virtual BOOL IsCoOp( void ) = 0;// is this a coop game? - virtual const char *GetGameDescription( void ) { return "Half-Life"; } // this is the game name that gets seen in the server browser - -// Client connection/disconnection - virtual BOOL ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ) = 0;// a client just connected to the server (player hasn't spawned yet) - virtual void InitHUD( CBasePlayer *pl ) = 0; // the client dll is ready for updating - virtual void ClientDisconnected( edict_t *pClient ) = 0;// a client just disconnected from the server - virtual void UpdateGameMode( CBasePlayer *pPlayer ) {} // the client needs to be informed of the current game mode - -// Client damage rules - virtual float FlPlayerFallDamage( CBasePlayer *pPlayer ) = 0;// this client just hit the ground after a fall. How much damage? - virtual BOOL FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ) {return TRUE;};// can this player take damage from this attacker? - virtual BOOL ShouldAutoAim( CBasePlayer *pPlayer, edict_t *target ) { return TRUE; } - -// Client spawn/respawn control - virtual void PlayerSpawn( CBasePlayer *pPlayer ) = 0;// called by CBasePlayer::Spawn just before releasing player into the game - virtual void PlayerThink( CBasePlayer *pPlayer ) = 0; // called by CBasePlayer::PreThink every frame, before physics are run and after keys are accepted - virtual BOOL FPlayerCanRespawn( CBasePlayer *pPlayer ) = 0;// is this player allowed to respawn now? - virtual float FlPlayerSpawnTime( CBasePlayer *pPlayer ) = 0;// When in the future will this player be able to spawn? - virtual edict_t *GetPlayerSpawnSpot( CBasePlayer *pPlayer );// Place this player on their spawnspot and face them the proper direction. - - virtual BOOL AllowAutoTargetCrosshair( void ) { return TRUE; }; - virtual BOOL ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) { return FALSE; }; // handles the user commands; returns TRUE if command handled properly - virtual void ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer ) {} // the player has changed userinfo; can change it now - -// Client kills/scoring - virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ) = 0;// how many points do I award whoever kills this player? - virtual void PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ) = 0;// Called each time a player dies - virtual void DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor )= 0;// Call this from within a GameRules class to report an obituary. -// Weapon retrieval - virtual BOOL CanHavePlayerItem( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon );// The player is touching an CBasePlayerItem, do I give it to him? - virtual void PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ) = 0;// Called each time a player picks up a weapon from the ground - -// Weapon spawn/respawn control - virtual int WeaponShouldRespawn( CBasePlayerItem *pWeapon ) = 0;// should this weapon respawn? - virtual float FlWeaponRespawnTime( CBasePlayerItem *pWeapon ) = 0;// when may this weapon respawn? - virtual float FlWeaponTryRespawn( CBasePlayerItem *pWeapon ) = 0; // can i respawn now, and if not, when should i try again? - virtual Vector VecWeaponRespawnSpot( CBasePlayerItem *pWeapon ) = 0;// where in the world should this weapon respawn? - -// Item retrieval - virtual BOOL CanHaveItem( CBasePlayer *pPlayer, CItem *pItem ) = 0;// is this player allowed to take this item? - virtual void PlayerGotItem( CBasePlayer *pPlayer, CItem *pItem ) = 0;// call each time a player picks up an item (battery, healthkit, longjump) - -// Item spawn/respawn control - virtual int ItemShouldRespawn( CItem *pItem ) = 0;// Should this item respawn? - virtual float FlItemRespawnTime( CItem *pItem ) = 0;// when may this item respawn? - virtual Vector VecItemRespawnSpot( CItem *pItem ) = 0;// where in the world should this item respawn? - -// Ammo retrieval - virtual BOOL CanHaveAmmo( CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry );// can this player take more of this ammo? - virtual void PlayerGotAmmo( CBasePlayer *pPlayer, char *szName, int iCount ) = 0;// called each time a player picks up some ammo in the world - -// Ammo spawn/respawn control - virtual int AmmoShouldRespawn( CBasePlayerAmmo *pAmmo ) = 0;// should this ammo item respawn? - virtual float FlAmmoRespawnTime( CBasePlayerAmmo *pAmmo ) = 0;// when should this ammo item respawn? - virtual Vector VecAmmoRespawnSpot( CBasePlayerAmmo *pAmmo ) = 0;// where in the world should this ammo item respawn? - // by default, everything spawns - -// Healthcharger respawn control - virtual float FlHealthChargerRechargeTime( void ) = 0;// how long until a depleted HealthCharger recharges itself? - virtual float FlHEVChargerRechargeTime( void ) { return 0; }// how long until a depleted HealthCharger recharges itself? - -// What happens to a dead player's weapons - virtual int DeadPlayerWeapons( CBasePlayer *pPlayer ) = 0;// what do I do with a player's weapons when he's killed? - -// What happens to a dead player's ammo - virtual int DeadPlayerAmmo( CBasePlayer *pPlayer ) = 0;// Do I drop ammo when the player dies? How much? - -// Teamplay stuff - virtual const char *GetTeamID( CBaseEntity *pEntity ) = 0;// what team is this entity on? - virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget ) = 0;// What is the player's relationship with this entity? - virtual int GetTeamIndex( const char *pTeamName ) { return -1; } - virtual const char *GetIndexedTeamName( int teamIndex ) { return ""; } - virtual BOOL IsValidTeam( const char *pTeamName ) { return TRUE; } - virtual void ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib ) {} - virtual const char *SetDefaultPlayerTeam( CBasePlayer *pPlayer ) { return ""; } - -// Sounds - virtual BOOL PlayTextureSounds( void ) { return TRUE; } - virtual BOOL PlayFootstepSounds( CBasePlayer *pl, float fvol ) { return TRUE; } - -// Monsters - virtual BOOL FAllowMonsters( void ) = 0;//are monsters allowed - - // Immediately end a multiplayer game - virtual void EndMultiplayerGame( void ) {} -}; - -extern CGameRules *InstallGameRules( void ); - - -//========================================================= -// CHalfLifeRules - rules for the single player Half-Life -// game. -//========================================================= -class CHalfLifeRules : public CGameRules -{ -public: - CHalfLifeRules ( void ); - -// GR_Think - virtual void Think( void ); - virtual BOOL IsAllowedToSpawn( CBaseEntity *pEntity ); - virtual BOOL FAllowFlashlight( void ) { return TRUE; }; - - virtual BOOL FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ); - virtual BOOL GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ); - -// Functions to verify the single/multiplayer status of a game - virtual BOOL IsMultiplayer( void ); - virtual BOOL IsDeathmatch( void ); - virtual BOOL IsCoOp( void ); - -// Client connection/disconnection - virtual BOOL ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); - virtual void InitHUD( CBasePlayer *pl ); // the client dll is ready for updating - virtual void ClientDisconnected( edict_t *pClient ); - -// Client damage rules - virtual float FlPlayerFallDamage( CBasePlayer *pPlayer ); - -// Client spawn/respawn control - virtual void PlayerSpawn( CBasePlayer *pPlayer ); - virtual void PlayerThink( CBasePlayer *pPlayer ); - virtual BOOL FPlayerCanRespawn( CBasePlayer *pPlayer ); - virtual float FlPlayerSpawnTime( CBasePlayer *pPlayer ); - - virtual BOOL AllowAutoTargetCrosshair( void ); - -// Client kills/scoring - virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ); - virtual void PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ); - virtual void DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ); - -// Weapon retrieval - virtual void PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ); - -// Weapon spawn/respawn control - virtual int WeaponShouldRespawn( CBasePlayerItem *pWeapon ); - virtual float FlWeaponRespawnTime( CBasePlayerItem *pWeapon ); - virtual float FlWeaponTryRespawn( CBasePlayerItem *pWeapon ); - virtual Vector VecWeaponRespawnSpot( CBasePlayerItem *pWeapon ); - -// Item retrieval - virtual BOOL CanHaveItem( CBasePlayer *pPlayer, CItem *pItem ); - virtual void PlayerGotItem( CBasePlayer *pPlayer, CItem *pItem ); - -// Item spawn/respawn control - virtual int ItemShouldRespawn( CItem *pItem ); - virtual float FlItemRespawnTime( CItem *pItem ); - virtual Vector VecItemRespawnSpot( CItem *pItem ); - -// Ammo retrieval - virtual void PlayerGotAmmo( CBasePlayer *pPlayer, char *szName, int iCount ); - -// Ammo spawn/respawn control - virtual int AmmoShouldRespawn( CBasePlayerAmmo *pAmmo ); - virtual float FlAmmoRespawnTime( CBasePlayerAmmo *pAmmo ); - virtual Vector VecAmmoRespawnSpot( CBasePlayerAmmo *pAmmo ); - -// Healthcharger respawn control - virtual float FlHealthChargerRechargeTime( void ); - -// What happens to a dead player's weapons - virtual int DeadPlayerWeapons( CBasePlayer *pPlayer ); - -// What happens to a dead player's ammo - virtual int DeadPlayerAmmo( CBasePlayer *pPlayer ); - -// Monsters - virtual BOOL FAllowMonsters( void ); - -// Teamplay stuff - virtual const char *GetTeamID( CBaseEntity *pEntity ) {return "";}; - virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget ); -}; - -//========================================================= -// CHalfLifeMultiplay - rules for the basic half life multiplayer -// competition -//========================================================= -class CHalfLifeMultiplay : public CGameRules -{ -public: - CHalfLifeMultiplay(); - -// GR_Think - virtual void Think( void ); - virtual void RefreshSkillData( void ); - virtual BOOL IsAllowedToSpawn( CBaseEntity *pEntity ); - virtual BOOL FAllowFlashlight( void ); - - virtual BOOL FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ); - virtual BOOL GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ); - -// Functions to verify the single/multiplayer status of a game - virtual BOOL IsMultiplayer( void ); - virtual BOOL IsDeathmatch( void ); - virtual BOOL IsCoOp( void ); - -// Client connection/disconnection - // If ClientConnected returns FALSE, the connection is rejected and the user is provided the reason specified in - // svRejectReason - // Only the client's name and remote address are provided to the dll for verification. - virtual BOOL ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); - virtual void InitHUD( CBasePlayer *pl ); // the client dll is ready for updating - virtual void ClientDisconnected( edict_t *pClient ); - virtual void UpdateGameMode( CBasePlayer *pPlayer ); // the client needs to be informed of the current game mode - -// Client damage rules - virtual float FlPlayerFallDamage( CBasePlayer *pPlayer ); - virtual BOOL FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ); - -// Client spawn/respawn control - virtual void PlayerSpawn( CBasePlayer *pPlayer ); - virtual void PlayerThink( CBasePlayer *pPlayer ); - virtual BOOL FPlayerCanRespawn( CBasePlayer *pPlayer ); - virtual float FlPlayerSpawnTime( CBasePlayer *pPlayer ); - virtual edict_t *GetPlayerSpawnSpot( CBasePlayer *pPlayer ); - - virtual BOOL AllowAutoTargetCrosshair( void ); - virtual BOOL ClientCommand( CBasePlayer *pPlayer, const char *pcmd ); - -// Client kills/scoring - virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ); - virtual void PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ); - virtual void DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ); - -// Weapon retrieval - virtual void PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ); - virtual BOOL CanHavePlayerItem( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon );// The player is touching an CBasePlayerItem, do I give it to him? - -// Weapon spawn/respawn control - virtual int WeaponShouldRespawn( CBasePlayerItem *pWeapon ); - virtual float FlWeaponRespawnTime( CBasePlayerItem *pWeapon ); - virtual float FlWeaponTryRespawn( CBasePlayerItem *pWeapon ); - virtual Vector VecWeaponRespawnSpot( CBasePlayerItem *pWeapon ); - -// Item retrieval - virtual BOOL CanHaveItem( CBasePlayer *pPlayer, CItem *pItem ); - virtual void PlayerGotItem( CBasePlayer *pPlayer, CItem *pItem ); - -// Item spawn/respawn control - virtual int ItemShouldRespawn( CItem *pItem ); - virtual float FlItemRespawnTime( CItem *pItem ); - virtual Vector VecItemRespawnSpot( CItem *pItem ); - -// Ammo retrieval - virtual void PlayerGotAmmo( CBasePlayer *pPlayer, char *szName, int iCount ); - -// Ammo spawn/respawn control - virtual int AmmoShouldRespawn( CBasePlayerAmmo *pAmmo ); - virtual float FlAmmoRespawnTime( CBasePlayerAmmo *pAmmo ); - virtual Vector VecAmmoRespawnSpot( CBasePlayerAmmo *pAmmo ); - -// Healthcharger respawn control - virtual float FlHealthChargerRechargeTime( void ); - virtual float FlHEVChargerRechargeTime( void ); - -// What happens to a dead player's weapons - virtual int DeadPlayerWeapons( CBasePlayer *pPlayer ); - -// What happens to a dead player's ammo - virtual int DeadPlayerAmmo( CBasePlayer *pPlayer ); - -// Teamplay stuff - virtual const char *GetTeamID( CBaseEntity *pEntity ) {return "";} - virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget ); - - virtual BOOL PlayTextureSounds( void ) { return FALSE; } - virtual BOOL PlayFootstepSounds( CBasePlayer *pl, float fvol ); - -// Monsters - virtual BOOL FAllowMonsters( void ); - - // Immediately end a multiplayer game - virtual void EndMultiplayerGame( void ) { GoToIntermission(); } - -protected: - virtual void ChangeLevel( void ); - virtual void GoToIntermission( void ); - float m_flIntermissionEndTime; - BOOL m_iEndIntermissionButtonHit; - void SendMOTDToClient( edict_t *client ); -}; - -extern DLL_GLOBAL CGameRules* g_pGameRules; +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +//========================================================= +// GameRules +//========================================================= + +//#include "weapons.h" +//#include "items.h" +class CBasePlayerItem; +class CBasePlayer; +class CItem; +class CBasePlayerAmmo; + +// weapon respawning return codes +enum +{ + GR_NONE = 0, + + GR_WEAPON_RESPAWN_YES, + GR_WEAPON_RESPAWN_NO, + + GR_AMMO_RESPAWN_YES, + GR_AMMO_RESPAWN_NO, + + GR_ITEM_RESPAWN_YES, + GR_ITEM_RESPAWN_NO, + + GR_PLR_DROP_GUN_ALL, + GR_PLR_DROP_GUN_ACTIVE, + GR_PLR_DROP_GUN_NO, + + GR_PLR_DROP_AMMO_ALL, + GR_PLR_DROP_AMMO_ACTIVE, + GR_PLR_DROP_AMMO_NO, +}; + +// Player relationship return codes +enum +{ + GR_NOTTEAMMATE = 0, + GR_TEAMMATE, + GR_ENEMY, + GR_ALLY, + GR_NEUTRAL, +}; + +class CGameRules +{ +public: + virtual void RefreshSkillData( void );// fill skill data struct with proper values + virtual void Think( void ) = 0;// GR_Think - runs every server frame, should handle any timer tasks, periodic events, etc. + virtual BOOL IsAllowedToSpawn( CBaseEntity *pEntity ) = 0; // Can this item spawn (eg monsters don't spawn in deathmatch). + + virtual BOOL FAllowFlashlight( void ) = 0;// Are players allowed to switch on their flashlight? + virtual BOOL FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ) = 0;// should the player switch to this weapon? + virtual BOOL GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ) = 0;// I can't use this weapon anymore, get me the next best one. + +// Functions to verify the single/multiplayer status of a game + virtual BOOL IsMultiplayer( void ) = 0;// is this a multiplayer game? (either coop or deathmatch) + virtual BOOL IsDeathmatch( void ) = 0;//is this a deathmatch game? + virtual BOOL IsTeamplay( void ) { return FALSE; };// is this deathmatch game being played with team rules? + virtual BOOL IsCoOp( void ) = 0;// is this a coop game? + virtual const char *GetGameDescription( void ) { return "Half-Life"; } // this is the game name that gets seen in the server browser + +// Client connection/disconnection + virtual BOOL ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ) = 0;// a client just connected to the server (player hasn't spawned yet) + virtual void InitHUD( CBasePlayer *pl ) = 0; // the client dll is ready for updating + virtual void ClientDisconnected( edict_t *pClient ) = 0;// a client just disconnected from the server + virtual void UpdateGameMode( CBasePlayer *pPlayer ) {} // the client needs to be informed of the current game mode + +// Client damage rules + virtual float FlPlayerFallDamage( CBasePlayer *pPlayer ) = 0;// this client just hit the ground after a fall. How much damage? + virtual BOOL FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ) {return TRUE;};// can this player take damage from this attacker? + virtual BOOL ShouldAutoAim( CBasePlayer *pPlayer, edict_t *target ) { return TRUE; } + +// Client spawn/respawn control + virtual void PlayerSpawn( CBasePlayer *pPlayer ) = 0;// called by CBasePlayer::Spawn just before releasing player into the game + virtual void PlayerThink( CBasePlayer *pPlayer ) = 0; // called by CBasePlayer::PreThink every frame, before physics are run and after keys are accepted + virtual BOOL FPlayerCanRespawn( CBasePlayer *pPlayer ) = 0;// is this player allowed to respawn now? + virtual float FlPlayerSpawnTime( CBasePlayer *pPlayer ) = 0;// When in the future will this player be able to spawn? + virtual edict_t *GetPlayerSpawnSpot( CBasePlayer *pPlayer );// Place this player on their spawnspot and face them the proper direction. + + virtual BOOL AllowAutoTargetCrosshair( void ) { return TRUE; }; + virtual BOOL ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) { return FALSE; }; // handles the user commands; returns TRUE if command handled properly + virtual void ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer ) {} // the player has changed userinfo; can change it now + +// Client kills/scoring + virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ) = 0;// how many points do I award whoever kills this player? + virtual void PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ) = 0;// Called each time a player dies + virtual void DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor )= 0;// Call this from within a GameRules class to report an obituary. +// Weapon retrieval + virtual BOOL CanHavePlayerItem( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon );// The player is touching an CBasePlayerItem, do I give it to him? + virtual void PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ) = 0;// Called each time a player picks up a weapon from the ground + +// Weapon spawn/respawn control + virtual int WeaponShouldRespawn( CBasePlayerItem *pWeapon ) = 0;// should this weapon respawn? + virtual float FlWeaponRespawnTime( CBasePlayerItem *pWeapon ) = 0;// when may this weapon respawn? + virtual float FlWeaponTryRespawn( CBasePlayerItem *pWeapon ) = 0; // can i respawn now, and if not, when should i try again? + virtual Vector VecWeaponRespawnSpot( CBasePlayerItem *pWeapon ) = 0;// where in the world should this weapon respawn? + +// Item retrieval + virtual BOOL CanHaveItem( CBasePlayer *pPlayer, CItem *pItem ) = 0;// is this player allowed to take this item? + virtual void PlayerGotItem( CBasePlayer *pPlayer, CItem *pItem ) = 0;// call each time a player picks up an item (battery, healthkit, longjump) + +// Item spawn/respawn control + virtual int ItemShouldRespawn( CItem *pItem ) = 0;// Should this item respawn? + virtual float FlItemRespawnTime( CItem *pItem ) = 0;// when may this item respawn? + virtual Vector VecItemRespawnSpot( CItem *pItem ) = 0;// where in the world should this item respawn? + +// Ammo retrieval + virtual BOOL CanHaveAmmo( CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry );// can this player take more of this ammo? + virtual void PlayerGotAmmo( CBasePlayer *pPlayer, char *szName, int iCount ) = 0;// called each time a player picks up some ammo in the world + +// Ammo spawn/respawn control + virtual int AmmoShouldRespawn( CBasePlayerAmmo *pAmmo ) = 0;// should this ammo item respawn? + virtual float FlAmmoRespawnTime( CBasePlayerAmmo *pAmmo ) = 0;// when should this ammo item respawn? + virtual Vector VecAmmoRespawnSpot( CBasePlayerAmmo *pAmmo ) = 0;// where in the world should this ammo item respawn? + // by default, everything spawns + +// Healthcharger respawn control + virtual float FlHealthChargerRechargeTime( void ) = 0;// how long until a depleted HealthCharger recharges itself? + virtual float FlHEVChargerRechargeTime( void ) { return 0; }// how long until a depleted HealthCharger recharges itself? + +// What happens to a dead player's weapons + virtual int DeadPlayerWeapons( CBasePlayer *pPlayer ) = 0;// what do I do with a player's weapons when he's killed? + +// What happens to a dead player's ammo + virtual int DeadPlayerAmmo( CBasePlayer *pPlayer ) = 0;// Do I drop ammo when the player dies? How much? + +// Teamplay stuff + virtual const char *GetTeamID( CBaseEntity *pEntity ) = 0;// what team is this entity on? + virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget ) = 0;// What is the player's relationship with this entity? + virtual int GetTeamIndex( const char *pTeamName ) { return -1; } + virtual const char *GetIndexedTeamName( int teamIndex ) { return ""; } + virtual BOOL IsValidTeam( const char *pTeamName ) { return TRUE; } + virtual void ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib ) {} + virtual const char *SetDefaultPlayerTeam( CBasePlayer *pPlayer ) { return ""; } + +// Sounds + virtual BOOL PlayTextureSounds( void ) { return TRUE; } + virtual BOOL PlayFootstepSounds( CBasePlayer *pl, float fvol ) { return TRUE; } + +// Monsters + virtual BOOL FAllowMonsters( void ) = 0;//are monsters allowed + + // Immediately end a multiplayer game + virtual void EndMultiplayerGame( void ) {} +}; + +extern CGameRules *InstallGameRules( void ); + + +//========================================================= +// CHalfLifeRules - rules for the single player Half-Life +// game. +//========================================================= +class CHalfLifeRules : public CGameRules +{ +public: + CHalfLifeRules ( void ); + +// GR_Think + virtual void Think( void ); + virtual BOOL IsAllowedToSpawn( CBaseEntity *pEntity ); + virtual BOOL FAllowFlashlight( void ) { return TRUE; }; + + virtual BOOL FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ); + virtual BOOL GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ); + +// Functions to verify the single/multiplayer status of a game + virtual BOOL IsMultiplayer( void ); + virtual BOOL IsDeathmatch( void ); + virtual BOOL IsCoOp( void ); + +// Client connection/disconnection + virtual BOOL ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); + virtual void InitHUD( CBasePlayer *pl ); // the client dll is ready for updating + virtual void ClientDisconnected( edict_t *pClient ); + +// Client damage rules + virtual float FlPlayerFallDamage( CBasePlayer *pPlayer ); + +// Client spawn/respawn control + virtual void PlayerSpawn( CBasePlayer *pPlayer ); + virtual void PlayerThink( CBasePlayer *pPlayer ); + virtual BOOL FPlayerCanRespawn( CBasePlayer *pPlayer ); + virtual float FlPlayerSpawnTime( CBasePlayer *pPlayer ); + + virtual BOOL AllowAutoTargetCrosshair( void ); + +// Client kills/scoring + virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ); + virtual void PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ); + virtual void DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ); + +// Weapon retrieval + virtual void PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ); + +// Weapon spawn/respawn control + virtual int WeaponShouldRespawn( CBasePlayerItem *pWeapon ); + virtual float FlWeaponRespawnTime( CBasePlayerItem *pWeapon ); + virtual float FlWeaponTryRespawn( CBasePlayerItem *pWeapon ); + virtual Vector VecWeaponRespawnSpot( CBasePlayerItem *pWeapon ); + +// Item retrieval + virtual BOOL CanHaveItem( CBasePlayer *pPlayer, CItem *pItem ); + virtual void PlayerGotItem( CBasePlayer *pPlayer, CItem *pItem ); + +// Item spawn/respawn control + virtual int ItemShouldRespawn( CItem *pItem ); + virtual float FlItemRespawnTime( CItem *pItem ); + virtual Vector VecItemRespawnSpot( CItem *pItem ); + +// Ammo retrieval + virtual void PlayerGotAmmo( CBasePlayer *pPlayer, char *szName, int iCount ); + +// Ammo spawn/respawn control + virtual int AmmoShouldRespawn( CBasePlayerAmmo *pAmmo ); + virtual float FlAmmoRespawnTime( CBasePlayerAmmo *pAmmo ); + virtual Vector VecAmmoRespawnSpot( CBasePlayerAmmo *pAmmo ); + +// Healthcharger respawn control + virtual float FlHealthChargerRechargeTime( void ); + +// What happens to a dead player's weapons + virtual int DeadPlayerWeapons( CBasePlayer *pPlayer ); + +// What happens to a dead player's ammo + virtual int DeadPlayerAmmo( CBasePlayer *pPlayer ); + +// Monsters + virtual BOOL FAllowMonsters( void ); + +// Teamplay stuff + virtual const char *GetTeamID( CBaseEntity *pEntity ) {return "";}; + virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget ); +}; + +//========================================================= +// CHalfLifeMultiplay - rules for the basic half life multiplayer +// competition +//========================================================= +class CHalfLifeMultiplay : public CGameRules +{ +public: + CHalfLifeMultiplay(); + +// GR_Think + virtual void Think( void ); + virtual void RefreshSkillData( void ); + virtual BOOL IsAllowedToSpawn( CBaseEntity *pEntity ); + virtual BOOL FAllowFlashlight( void ); + + virtual BOOL FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ); + virtual BOOL GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ); + +// Functions to verify the single/multiplayer status of a game + virtual BOOL IsMultiplayer( void ); + virtual BOOL IsDeathmatch( void ); + virtual BOOL IsCoOp( void ); + +// Client connection/disconnection + // If ClientConnected returns FALSE, the connection is rejected and the user is provided the reason specified in + // svRejectReason + // Only the client's name and remote address are provided to the dll for verification. + virtual BOOL ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); + virtual void InitHUD( CBasePlayer *pl ); // the client dll is ready for updating + virtual void ClientDisconnected( edict_t *pClient ); + virtual void UpdateGameMode( CBasePlayer *pPlayer ); // the client needs to be informed of the current game mode + +// Client damage rules + virtual float FlPlayerFallDamage( CBasePlayer *pPlayer ); + virtual BOOL FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ); + +// Client spawn/respawn control + virtual void PlayerSpawn( CBasePlayer *pPlayer ); + virtual void PlayerThink( CBasePlayer *pPlayer ); + virtual BOOL FPlayerCanRespawn( CBasePlayer *pPlayer ); + virtual float FlPlayerSpawnTime( CBasePlayer *pPlayer ); + virtual edict_t *GetPlayerSpawnSpot( CBasePlayer *pPlayer ); + + virtual BOOL AllowAutoTargetCrosshair( void ); + virtual BOOL ClientCommand( CBasePlayer *pPlayer, const char *pcmd ); + +// Client kills/scoring + virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ); + virtual void PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ); + virtual void DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ); + +// Weapon retrieval + virtual void PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon ); + virtual BOOL CanHavePlayerItem( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon );// The player is touching an CBasePlayerItem, do I give it to him? + +// Weapon spawn/respawn control + virtual int WeaponShouldRespawn( CBasePlayerItem *pWeapon ); + virtual float FlWeaponRespawnTime( CBasePlayerItem *pWeapon ); + virtual float FlWeaponTryRespawn( CBasePlayerItem *pWeapon ); + virtual Vector VecWeaponRespawnSpot( CBasePlayerItem *pWeapon ); + +// Item retrieval + virtual BOOL CanHaveItem( CBasePlayer *pPlayer, CItem *pItem ); + virtual void PlayerGotItem( CBasePlayer *pPlayer, CItem *pItem ); + +// Item spawn/respawn control + virtual int ItemShouldRespawn( CItem *pItem ); + virtual float FlItemRespawnTime( CItem *pItem ); + virtual Vector VecItemRespawnSpot( CItem *pItem ); + +// Ammo retrieval + virtual void PlayerGotAmmo( CBasePlayer *pPlayer, char *szName, int iCount ); + +// Ammo spawn/respawn control + virtual int AmmoShouldRespawn( CBasePlayerAmmo *pAmmo ); + virtual float FlAmmoRespawnTime( CBasePlayerAmmo *pAmmo ); + virtual Vector VecAmmoRespawnSpot( CBasePlayerAmmo *pAmmo ); + +// Healthcharger respawn control + virtual float FlHealthChargerRechargeTime( void ); + virtual float FlHEVChargerRechargeTime( void ); + +// What happens to a dead player's weapons + virtual int DeadPlayerWeapons( CBasePlayer *pPlayer ); + +// What happens to a dead player's ammo + virtual int DeadPlayerAmmo( CBasePlayer *pPlayer ); + +// Teamplay stuff + virtual const char *GetTeamID( CBaseEntity *pEntity ) {return "";} + virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget ); + + virtual BOOL PlayTextureSounds( void ) { return FALSE; } + virtual BOOL PlayFootstepSounds( CBasePlayer *pl, float fvol ); + +// Monsters + virtual BOOL FAllowMonsters( void ); + + // Immediately end a multiplayer game + virtual void EndMultiplayerGame( void ) { GoToIntermission(); } + +protected: + virtual void ChangeLevel( void ); + virtual void GoToIntermission( void ); + float m_flIntermissionEndTime; + BOOL m_iEndIntermissionButtonHit; + void SendMOTDToClient( edict_t *client ); +}; + +extern DLL_GLOBAL CGameRules* g_pGameRules; diff --git a/dep/rehlsdk/dlls/hornet.h b/dep/rehlsdk/dlls/hornet.h index f069c3d..98d1710 100644 --- a/dep/rehlsdk/dlls/hornet.h +++ b/dep/rehlsdk/dlls/hornet.h @@ -1,58 +1,58 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -//========================================================= -// Hornets -//========================================================= - -//========================================================= -// Hornet Defines -//========================================================= -#define HORNET_TYPE_RED 0 -#define HORNET_TYPE_ORANGE 1 -#define HORNET_RED_SPEED (float)600 -#define HORNET_ORANGE_SPEED (float)800 -#define HORNET_BUZZ_VOLUME (float)0.8 - -extern int iHornetPuff; - -//========================================================= -// Hornet - this is the projectile that the Alien Grunt fires. -//========================================================= -class CHornet : public CBaseMonster -{ -public: - void Spawn( void ); - void Precache( void ); - int Classify ( void ); - int IRelationship ( CBaseEntity *pTarget ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; - - void IgniteTrail( void ); - void EXPORT StartTrack ( void ); - void EXPORT StartDart ( void ); - void EXPORT TrackTarget ( void ); - void EXPORT TrackTouch ( CBaseEntity *pOther ); - void EXPORT DartTouch( CBaseEntity *pOther ); - void EXPORT DieTouch ( CBaseEntity *pOther ); - - int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); - - float m_flStopAttack; - int m_iHornetType; - float m_flFlySpeed; -}; - +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +//========================================================= +// Hornets +//========================================================= + +//========================================================= +// Hornet Defines +//========================================================= +#define HORNET_TYPE_RED 0 +#define HORNET_TYPE_ORANGE 1 +#define HORNET_RED_SPEED (float)600 +#define HORNET_ORANGE_SPEED (float)800 +#define HORNET_BUZZ_VOLUME (float)0.8 + +extern int iHornetPuff; + +//========================================================= +// Hornet - this is the projectile that the Alien Grunt fires. +//========================================================= +class CHornet : public CBaseMonster +{ +public: + void Spawn( void ); + void Precache( void ); + int Classify ( void ); + int IRelationship ( CBaseEntity *pTarget ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; + + void IgniteTrail( void ); + void EXPORT StartTrack ( void ); + void EXPORT StartDart ( void ); + void EXPORT TrackTarget ( void ); + void EXPORT TrackTouch ( CBaseEntity *pOther ); + void EXPORT DartTouch( CBaseEntity *pOther ); + void EXPORT DieTouch ( CBaseEntity *pOther ); + + int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); + + float m_flStopAttack; + int m_iHornetType; + float m_flFlySpeed; +}; + diff --git a/dep/rehlsdk/dlls/items.h b/dep/rehlsdk/dlls/items.h index 04905fc..e985296 100644 --- a/dep/rehlsdk/dlls/items.h +++ b/dep/rehlsdk/dlls/items.h @@ -1,29 +1,29 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef ITEMS_H -#define ITEMS_H - - -class CItem : public CBaseEntity -{ -public: - void Spawn( void ); - CBaseEntity* Respawn( void ); - void EXPORT ItemTouch( CBaseEntity *pOther ); - void EXPORT Materialize( void ); - virtual BOOL MyTouch( CBasePlayer *pPlayer ) { return FALSE; }; -}; - -#endif // ITEMS_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef ITEMS_H +#define ITEMS_H + + +class CItem : public CBaseEntity +{ +public: + void Spawn( void ); + CBaseEntity* Respawn( void ); + void EXPORT ItemTouch( CBaseEntity *pOther ); + void EXPORT Materialize( void ); + virtual BOOL MyTouch( CBasePlayer *pPlayer ) { return FALSE; }; +}; + +#endif // ITEMS_H diff --git a/dep/rehlsdk/dlls/maprules.h b/dep/rehlsdk/dlls/maprules.h index 975dafa..57f9939 100644 --- a/dep/rehlsdk/dlls/maprules.h +++ b/dep/rehlsdk/dlls/maprules.h @@ -1,22 +1,22 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#ifndef MAPRULES_H -#define MAPRULES_H - - - -#endif // MAPRULES_H - +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +#ifndef MAPRULES_H +#define MAPRULES_H + + + +#endif // MAPRULES_H + diff --git a/dep/rehlsdk/dlls/monsterevent.h b/dep/rehlsdk/dlls/monsterevent.h index 58357e1..46c5624 100644 --- a/dep/rehlsdk/dlls/monsterevent.h +++ b/dep/rehlsdk/dlls/monsterevent.h @@ -1,34 +1,34 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef MONSTEREVENT_H -#define MONSTEREVENT_H - -typedef struct -{ - int event; - char *options; -} MonsterEvent_t; - -#define EVENT_SPECIFIC 0 -#define EVENT_SCRIPTED 1000 -#define EVENT_SHARED 2000 -#define EVENT_CLIENT 5000 - -#define MONSTER_EVENT_BODYDROP_LIGHT 2001 -#define MONSTER_EVENT_BODYDROP_HEAVY 2002 - -#define MONSTER_EVENT_SWISHSOUND 2010 - -#endif // MONSTEREVENT_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef MONSTEREVENT_H +#define MONSTEREVENT_H + +typedef struct +{ + int event; + char *options; +} MonsterEvent_t; + +#define EVENT_SPECIFIC 0 +#define EVENT_SCRIPTED 1000 +#define EVENT_SHARED 2000 +#define EVENT_CLIENT 5000 + +#define MONSTER_EVENT_BODYDROP_LIGHT 2001 +#define MONSTER_EVENT_BODYDROP_HEAVY 2002 + +#define MONSTER_EVENT_SWISHSOUND 2010 + +#endif // MONSTEREVENT_H diff --git a/dep/rehlsdk/dlls/monsters.h b/dep/rehlsdk/dlls/monsters.h index f107510..591ea52 100644 --- a/dep/rehlsdk/dlls/monsters.h +++ b/dep/rehlsdk/dlls/monsters.h @@ -1,183 +1,183 @@ -/*** -* -* Copyright (c) 1996-2001, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* This source code contains proprietary and confidential information of -* Valve LLC and its suppliers. Access to this code is restricted to -* persons who have executed a written SDK license with Valve. Any access, -* use or distribution of this code by or to any unlicensed person is illegal. -* -****/ -#ifndef MONSTERS_H -#include "skill.h" -#define MONSTERS_H - -/* - -===== monsters.h ======================================================== - - Header file for monster-related utility code - -*/ - -// CHECKLOCALMOVE result types -#define LOCALMOVE_INVALID 0 // move is not possible -#define LOCALMOVE_INVALID_DONT_TRIANGULATE 1 // move is not possible, don't try to triangulate -#define LOCALMOVE_VALID 2 // move is possible - -// Hit Group standards -#define HITGROUP_GENERIC 0 -#define HITGROUP_HEAD 1 -#define HITGROUP_CHEST 2 -#define HITGROUP_STOMACH 3 -#define HITGROUP_LEFTARM 4 -#define HITGROUP_RIGHTARM 5 -#define HITGROUP_LEFTLEG 6 -#define HITGROUP_RIGHTLEG 7 - - -// Monster Spawnflags -#define SF_MONSTER_WAIT_TILL_SEEN 1// spawnflag that makes monsters wait until player can see them before attacking. -#define SF_MONSTER_GAG 2 // no idle noises from this monster -#define SF_MONSTER_HITMONSTERCLIP 4 -// 8 -#define SF_MONSTER_PRISONER 16 // monster won't attack anyone, no one will attacke him. -// 32 -// 64 -#define SF_MONSTER_WAIT_FOR_SCRIPT 128 //spawnflag that makes monsters wait to check for attacking until the script is done or they've been attacked -#define SF_MONSTER_PREDISASTER 256 //this is a predisaster scientist or barney. Influences how they speak. -#define SF_MONSTER_FADECORPSE 512 // Fade out corpse after death -#define SF_MONSTER_FALL_TO_GROUND 0x80000000 - -// specialty spawnflags -#define SF_MONSTER_TURRET_AUTOACTIVATE 32 -#define SF_MONSTER_TURRET_STARTINACTIVE 64 -#define SF_MONSTER_WAIT_UNTIL_PROVOKED 64 // don't attack the player unless provoked - - - -// MoveToOrigin stuff -#define MOVE_START_TURN_DIST 64 // when this far away from moveGoal, start turning to face next goal -#define MOVE_STUCK_DIST 32 // if a monster can't step this far, it is stuck. - - -// MoveToOrigin stuff -#define MOVE_NORMAL 0// normal move in the direction monster is facing -#define MOVE_STRAFE 1// moves in direction specified, no matter which way monster is facing - -// spawn flags 256 and above are already taken by the engine -extern void UTIL_MoveToOrigin( edict_t* pent, const Vector &vecGoal, float flDist, int iMoveType ); - -Vector VecCheckToss ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj = 1.0 ); -Vector VecCheckThrow ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj = 1.0 ); -extern DLL_GLOBAL Vector g_vecAttackDir; -extern DLL_GLOBAL CONSTANT float g_flMeleeRange; -extern DLL_GLOBAL CONSTANT float g_flMediumRange; -extern DLL_GLOBAL CONSTANT float g_flLongRange; -extern void EjectBrass (const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ); -extern void ExplodeModel( const Vector &vecOrigin, float speed, int model, int count ); - -BOOL FBoxVisible ( entvars_t *pevLooker, entvars_t *pevTarget ); -BOOL FBoxVisible ( entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize = 0.0 ); - -// monster to monster relationship types -#define R_AL -2 // (ALLY) pals. Good alternative to R_NO when applicable. -#define R_FR -1// (FEAR)will run -#define R_NO 0// (NO RELATIONSHIP) disregard -#define R_DL 1// (DISLIKE) will attack -#define R_HT 2// (HATE)will attack this character instead of any visible DISLIKEd characters -#define R_NM 3// (NEMESIS) A monster Will ALWAYS attack its nemsis, no matter what - - -// these bits represent the monster's memory -#define MEMORY_CLEAR 0 -#define bits_MEMORY_PROVOKED ( 1 << 0 )// right now only used for houndeyes. -#define bits_MEMORY_INCOVER ( 1 << 1 )// monster knows it is in a covered position. -#define bits_MEMORY_SUSPICIOUS ( 1 << 2 )// Ally is suspicious of the player, and will move to provoked more easily -#define bits_MEMORY_PATH_FINISHED ( 1 << 3 )// Finished monster path (just used by big momma for now) -#define bits_MEMORY_ON_PATH ( 1 << 4 )// Moving on a path -#define bits_MEMORY_MOVE_FAILED ( 1 << 5 )// Movement has already failed -#define bits_MEMORY_FLINCHED ( 1 << 6 )// Has already flinched -#define bits_MEMORY_KILLED ( 1 << 7 )// HACKHACK -- remember that I've already called my Killed() -#define bits_MEMORY_CUSTOM4 ( 1 << 28 ) // Monster-specific memory -#define bits_MEMORY_CUSTOM3 ( 1 << 29 ) // Monster-specific memory -#define bits_MEMORY_CUSTOM2 ( 1 << 30 ) // Monster-specific memory -#define bits_MEMORY_CUSTOM1 ( 1 << 31 ) // Monster-specific memory - -// trigger conditions for scripted AI -// these MUST match the CHOICES interface in halflife.fgd for the base monster -enum -{ - AITRIGGER_NONE = 0, - AITRIGGER_SEEPLAYER_ANGRY_AT_PLAYER, - AITRIGGER_TAKEDAMAGE, - AITRIGGER_HALFHEALTH, - AITRIGGER_DEATH, - AITRIGGER_SQUADMEMBERDIE, - AITRIGGER_SQUADLEADERDIE, - AITRIGGER_HEARWORLD, - AITRIGGER_HEARPLAYER, - AITRIGGER_HEARCOMBAT, - AITRIGGER_SEEPLAYER_UNCONDITIONAL, - AITRIGGER_SEEPLAYER_NOT_IN_COMBAT, -}; -/* - 0 : "No Trigger" - 1 : "See Player" - 2 : "Take Damage" - 3 : "50% Health Remaining" - 4 : "Death" - 5 : "Squad Member Dead" - 6 : "Squad Leader Dead" - 7 : "Hear World" - 8 : "Hear Player" - 9 : "Hear Combat" -*/ - -// -// A gib is a chunk of a body, or a piece of wood/metal/rocks/etc. -// -class CGib : public CBaseEntity -{ -public: - void Spawn( const char *szGibModel ); - void EXPORT BounceGibTouch ( CBaseEntity *pOther ); - void EXPORT StickyGibTouch ( CBaseEntity *pOther ); - void EXPORT WaitTillLand( void ); - void LimitVelocity( void ); - - virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE; } - static void SpawnHeadGib( entvars_t *pevVictim ); - static void SpawnRandomGibs( entvars_t *pevVictim, int cGibs, int human ); - static void SpawnStickyGibs( entvars_t *pevVictim, Vector vecOrigin, int cGibs ); - - int m_bloodColor; - int m_cBloodDecals; - int m_material; - float m_lifeTime; -}; - - -#define CUSTOM_SCHEDULES\ - virtual Schedule_t *ScheduleFromName( const char *pName );\ - static Schedule_t *m_scheduleList[]; - -#define DEFINE_CUSTOM_SCHEDULES(derivedClass)\ - Schedule_t *derivedClass::m_scheduleList[] = - -#define IMPLEMENT_CUSTOM_SCHEDULES(derivedClass, baseClass)\ - Schedule_t *derivedClass::ScheduleFromName( const char *pName )\ - {\ - Schedule_t *pSchedule = ScheduleInList( pName, m_scheduleList, ARRAYSIZE(m_scheduleList) );\ - if ( !pSchedule )\ - return baseClass::ScheduleFromName(pName);\ - return pSchedule;\ - } - - - -#endif //MONSTERS_H +/*** +* +* Copyright (c) 1996-2001, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* This source code contains proprietary and confidential information of +* Valve LLC and its suppliers. Access to this code is restricted to +* persons who have executed a written SDK license with Valve. Any access, +* use or distribution of this code by or to any unlicensed person is illegal. +* +****/ +#ifndef MONSTERS_H +#include "skill.h" +#define MONSTERS_H + +/* + +===== monsters.h ======================================================== + + Header file for monster-related utility code + +*/ + +// CHECKLOCALMOVE result types +#define LOCALMOVE_INVALID 0 // move is not possible +#define LOCALMOVE_INVALID_DONT_TRIANGULATE 1 // move is not possible, don't try to triangulate +#define LOCALMOVE_VALID 2 // move is possible + +// Hit Group standards +#define HITGROUP_GENERIC 0 +#define HITGROUP_HEAD 1 +#define HITGROUP_CHEST 2 +#define HITGROUP_STOMACH 3 +#define HITGROUP_LEFTARM 4 +#define HITGROUP_RIGHTARM 5 +#define HITGROUP_LEFTLEG 6 +#define HITGROUP_RIGHTLEG 7 + + +// Monster Spawnflags +#define SF_MONSTER_WAIT_TILL_SEEN 1// spawnflag that makes monsters wait until player can see them before attacking. +#define SF_MONSTER_GAG 2 // no idle noises from this monster +#define SF_MONSTER_HITMONSTERCLIP 4 +// 8 +#define SF_MONSTER_PRISONER 16 // monster won't attack anyone, no one will attacke him. +// 32 +// 64 +#define SF_MONSTER_WAIT_FOR_SCRIPT 128 //spawnflag that makes monsters wait to check for attacking until the script is done or they've been attacked +#define SF_MONSTER_PREDISASTER 256 //this is a predisaster scientist or barney. Influences how they speak. +#define SF_MONSTER_FADECORPSE 512 // Fade out corpse after death +#define SF_MONSTER_FALL_TO_GROUND 0x80000000 + +// specialty spawnflags +#define SF_MONSTER_TURRET_AUTOACTIVATE 32 +#define SF_MONSTER_TURRET_STARTINACTIVE 64 +#define SF_MONSTER_WAIT_UNTIL_PROVOKED 64 // don't attack the player unless provoked + + + +// MoveToOrigin stuff +#define MOVE_START_TURN_DIST 64 // when this far away from moveGoal, start turning to face next goal +#define MOVE_STUCK_DIST 32 // if a monster can't step this far, it is stuck. + + +// MoveToOrigin stuff +#define MOVE_NORMAL 0// normal move in the direction monster is facing +#define MOVE_STRAFE 1// moves in direction specified, no matter which way monster is facing + +// spawn flags 256 and above are already taken by the engine +extern void UTIL_MoveToOrigin( edict_t* pent, const Vector &vecGoal, float flDist, int iMoveType ); + +Vector VecCheckToss ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj = 1.0 ); +Vector VecCheckThrow ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj = 1.0 ); +extern DLL_GLOBAL Vector g_vecAttackDir; +extern DLL_GLOBAL CONSTANT float g_flMeleeRange; +extern DLL_GLOBAL CONSTANT float g_flMediumRange; +extern DLL_GLOBAL CONSTANT float g_flLongRange; +extern void EjectBrass (const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ); +extern void ExplodeModel( const Vector &vecOrigin, float speed, int model, int count ); + +BOOL FBoxVisible ( entvars_t *pevLooker, entvars_t *pevTarget ); +BOOL FBoxVisible ( entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize = 0.0 ); + +// monster to monster relationship types +#define R_AL -2 // (ALLY) pals. Good alternative to R_NO when applicable. +#define R_FR -1// (FEAR)will run +#define R_NO 0// (NO RELATIONSHIP) disregard +#define R_DL 1// (DISLIKE) will attack +#define R_HT 2// (HATE)will attack this character instead of any visible DISLIKEd characters +#define R_NM 3// (NEMESIS) A monster Will ALWAYS attack its nemsis, no matter what + + +// these bits represent the monster's memory +#define MEMORY_CLEAR 0 +#define bits_MEMORY_PROVOKED ( 1 << 0 )// right now only used for houndeyes. +#define bits_MEMORY_INCOVER ( 1 << 1 )// monster knows it is in a covered position. +#define bits_MEMORY_SUSPICIOUS ( 1 << 2 )// Ally is suspicious of the player, and will move to provoked more easily +#define bits_MEMORY_PATH_FINISHED ( 1 << 3 )// Finished monster path (just used by big momma for now) +#define bits_MEMORY_ON_PATH ( 1 << 4 )// Moving on a path +#define bits_MEMORY_MOVE_FAILED ( 1 << 5 )// Movement has already failed +#define bits_MEMORY_FLINCHED ( 1 << 6 )// Has already flinched +#define bits_MEMORY_KILLED ( 1 << 7 )// HACKHACK -- remember that I've already called my Killed() +#define bits_MEMORY_CUSTOM4 ( 1 << 28 ) // Monster-specific memory +#define bits_MEMORY_CUSTOM3 ( 1 << 29 ) // Monster-specific memory +#define bits_MEMORY_CUSTOM2 ( 1 << 30 ) // Monster-specific memory +#define bits_MEMORY_CUSTOM1 ( 1 << 31 ) // Monster-specific memory + +// trigger conditions for scripted AI +// these MUST match the CHOICES interface in halflife.fgd for the base monster +enum +{ + AITRIGGER_NONE = 0, + AITRIGGER_SEEPLAYER_ANGRY_AT_PLAYER, + AITRIGGER_TAKEDAMAGE, + AITRIGGER_HALFHEALTH, + AITRIGGER_DEATH, + AITRIGGER_SQUADMEMBERDIE, + AITRIGGER_SQUADLEADERDIE, + AITRIGGER_HEARWORLD, + AITRIGGER_HEARPLAYER, + AITRIGGER_HEARCOMBAT, + AITRIGGER_SEEPLAYER_UNCONDITIONAL, + AITRIGGER_SEEPLAYER_NOT_IN_COMBAT, +}; +/* + 0 : "No Trigger" + 1 : "See Player" + 2 : "Take Damage" + 3 : "50% Health Remaining" + 4 : "Death" + 5 : "Squad Member Dead" + 6 : "Squad Leader Dead" + 7 : "Hear World" + 8 : "Hear Player" + 9 : "Hear Combat" +*/ + +// +// A gib is a chunk of a body, or a piece of wood/metal/rocks/etc. +// +class CGib : public CBaseEntity +{ +public: + void Spawn( const char *szGibModel ); + void EXPORT BounceGibTouch ( CBaseEntity *pOther ); + void EXPORT StickyGibTouch ( CBaseEntity *pOther ); + void EXPORT WaitTillLand( void ); + void LimitVelocity( void ); + + virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE; } + static void SpawnHeadGib( entvars_t *pevVictim ); + static void SpawnRandomGibs( entvars_t *pevVictim, int cGibs, int human ); + static void SpawnStickyGibs( entvars_t *pevVictim, Vector vecOrigin, int cGibs ); + + int m_bloodColor; + int m_cBloodDecals; + int m_material; + float m_lifeTime; +}; + + +#define CUSTOM_SCHEDULES\ + virtual Schedule_t *ScheduleFromName( const char *pName );\ + static Schedule_t *m_scheduleList[]; + +#define DEFINE_CUSTOM_SCHEDULES(derivedClass)\ + Schedule_t *derivedClass::m_scheduleList[] = + +#define IMPLEMENT_CUSTOM_SCHEDULES(derivedClass, baseClass)\ + Schedule_t *derivedClass::ScheduleFromName( const char *pName )\ + {\ + Schedule_t *pSchedule = ScheduleInList( pName, m_scheduleList, ARRAYSIZE(m_scheduleList) );\ + if ( !pSchedule )\ + return baseClass::ScheduleFromName(pName);\ + return pSchedule;\ + } + + + +#endif //MONSTERS_H diff --git a/dep/rehlsdk/dlls/nodes.h b/dep/rehlsdk/dlls/nodes.h index 8778366..29ffc5c 100644 --- a/dep/rehlsdk/dlls/nodes.h +++ b/dep/rehlsdk/dlls/nodes.h @@ -1,379 +1,379 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -//========================================================= -// nodes.h -//========================================================= - -#ifndef NODES_H -#define NODES_H - -//========================================================= -// DEFINE -//========================================================= -#define MAX_STACK_NODES 100 -#define NO_NODE -1 -#define MAX_NODE_HULLS 4 - -#define bits_NODE_LAND ( 1 << 0 ) // Land node, so nudge if necessary. -#define bits_NODE_AIR ( 1 << 1 ) // Air node, don't nudge. -#define bits_NODE_WATER ( 1 << 2 ) // Water node, don't nudge. -#define bits_NODE_GROUP_REALM (bits_NODE_LAND | bits_NODE_AIR | bits_NODE_WATER) - -//========================================================= -// Instance of a node. -//========================================================= -class CNode -{ -public: - Vector m_vecOrigin;// location of this node in space - Vector m_vecOriginPeek; // location of this node (LAND nodes are NODE_HEIGHT higher). - BYTE m_Region[3]; // Which of 256 regions do each of the coordinate belong? - int m_afNodeInfo;// bits that tell us more about this location - - int m_cNumLinks; // how many links this node has - int m_iFirstLink;// index of this node's first link in the link pool. - - // Where to start looking in the compressed routing table (offset into m_pRouteInfo). - // (4 hull sizes -- smallest to largest + fly/swim), and secondly, door capability. - // - int m_pNextBestNode[MAX_NODE_HULLS][2]; - - // Used in finding the shortest path. m_fClosestSoFar is -1 if not visited. - // Then it is the distance to the source. If another path uses this node - // and has a closer distance, then m_iPreviousNode is also updated. - // - float m_flClosestSoFar; // Used in finding the shortest path. - int m_iPreviousNode; - - short m_sHintType;// there is something interesting in the world at this node's position - short m_sHintActivity;// there is something interesting in the world at this node's position - float m_flHintYaw;// monster on this node should face this yaw to face the hint. -}; - -//========================================================= -// CLink - A link between 2 nodes -//========================================================= -#define bits_LINK_SMALL_HULL ( 1 << 0 )// headcrab box can fit through this connection -#define bits_LINK_HUMAN_HULL ( 1 << 1 )// player box can fit through this connection -#define bits_LINK_LARGE_HULL ( 1 << 2 )// big box can fit through this connection -#define bits_LINK_FLY_HULL ( 1 << 3 )// a flying big box can fit through this connection -#define bits_LINK_DISABLED ( 1 << 4 )// link is not valid when the set - -#define NODE_SMALL_HULL 0 -#define NODE_HUMAN_HULL 1 -#define NODE_LARGE_HULL 2 -#define NODE_FLY_HULL 3 - -class CLink -{ -public: - int m_iSrcNode;// the node that 'owns' this link ( keeps us from having to make reverse lookups ) - int m_iDestNode;// the node on the other end of the link. - - entvars_t *m_pLinkEnt;// the entity that blocks this connection (doors, etc) - - // m_szLinkEntModelname is not necessarily NULL terminated (so we can store it in a more alignment-friendly 4 bytes) - char m_szLinkEntModelname[ 4 ];// the unique name of the brush model that blocks the connection (this is kept for save/restore) - - int m_afLinkInfo;// information about this link - float m_flWeight;// length of the link line segment -}; - - -typedef struct -{ - int m_SortedBy[3]; - int m_CheckedEvent; -} DIST_INFO; - -typedef struct -{ - Vector v; - short n; // Nearest node or -1 if no node found. -} CACHE_ENTRY; - -//========================================================= -// CGraph -//========================================================= -#define GRAPH_VERSION (int)16// !!!increment this whever graph/node/link classes change, to obsolesce older disk files. -class CGraph -{ -public: - -// the graph has two flags, and should not be accessed unless both flags are TRUE! - BOOL m_fGraphPresent;// is the graph in memory? - BOOL m_fGraphPointersSet;// are the entity pointers for the graph all set? - BOOL m_fRoutingComplete; // are the optimal routes computed, yet? - - CNode *m_pNodes;// pointer to the memory block that contains all node info - CLink *m_pLinkPool;// big list of all node connections - char *m_pRouteInfo; // compressed routing information the nodes use. - - int m_cNodes;// total number of nodes - int m_cLinks;// total number of links - int m_nRouteInfo; // size of m_pRouteInfo in bytes. - - // Tables for making nearest node lookup faster. SortedBy provided nodes in a - // order of a particular coordinate. Instead of doing a binary search, RangeStart - // and RangeEnd let you get to the part of SortedBy that you are interested in. - // - // Once you have a point of interest, the only way you'll find a closer point is - // if at least one of the coordinates is closer than the ones you have now. So we - // search each range. After the search is exhausted, we know we have the closest - // node. - // -#define CACHE_SIZE 128 -#define NUM_RANGES 256 - DIST_INFO *m_di; // This is m_cNodes long, but the entries don't correspond to CNode entries. - int m_RangeStart[3][NUM_RANGES]; - int m_RangeEnd[3][NUM_RANGES]; - float m_flShortest; - int m_iNearest; - int m_minX, m_minY, m_minZ, m_maxX, m_maxY, m_maxZ; - int m_minBoxX, m_minBoxY, m_minBoxZ, m_maxBoxX, m_maxBoxY, m_maxBoxZ; - int m_CheckedCounter; - float m_RegionMin[3], m_RegionMax[3]; // The range of nodes. - CACHE_ENTRY m_Cache[CACHE_SIZE]; - - - int m_HashPrimes[16]; - short *m_pHashLinks; - int m_nHashLinks; - - - // kinda sleazy. In order to allow variety in active idles for monster groups in a room with more than one node, - // we keep track of the last node we searched from and store it here. Subsequent searches by other monsters will pick - // up where the last search stopped. - int m_iLastActiveIdleSearch; - - // another such system used to track the search for cover nodes, helps greatly with two monsters trying to get to the same node. - int m_iLastCoverSearch; - - // functions to create the graph - int LinkVisibleNodes ( CLink *pLinkPool, FILE *file, int *piBadNode ); - int RejectInlineLinks ( CLink *pLinkPool, FILE *file ); - int FindShortestPath ( int *piPath, int iStart, int iDest, int iHull, int afCapMask); - int FindNearestNode ( const Vector &vecOrigin, CBaseEntity *pEntity ); - int FindNearestNode ( const Vector &vecOrigin, int afNodeTypes ); - //int FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, BOOL *pfAlongLine ); - float PathLength( int iStart, int iDest, int iHull, int afCapMask ); - int NextNodeInRoute( int iCurrentNode, int iDest, int iHull, int iCap ); - - enum NODEQUERY { NODEGRAPH_DYNAMIC, NODEGRAPH_STATIC }; - // A static query means we're asking about the possiblity of handling this entity at ANY time - // A dynamic query means we're asking about it RIGHT NOW. So we should query the current state - int HandleLinkEnt ( int iNode, entvars_t *pevLinkEnt, int afCapMask, NODEQUERY queryType ); - entvars_t* LinkEntForLink ( CLink *pLink, CNode *pNode ); - void ShowNodeConnections ( int iNode ); - void InitGraph( void ); - int AllocNodes ( void ); - - int CheckNODFile(char *szMapName); - int FLoadGraph(char *szMapName); - int FSaveGraph(char *szMapName); - int FSetGraphPointers(void); - void CheckNode(Vector vecOrigin, int iNode); - - void BuildRegionTables(void); - void ComputeStaticRoutingTables(void); - void TestRoutingTables(void); - - void HashInsert(int iSrcNode, int iDestNode, int iKey); - void HashSearch(int iSrcNode, int iDestNode, int &iKey); - void HashChoosePrimes(int TableSize); - void BuildLinkLookups(void); - - void SortNodes(void); - - int HullIndex( const CBaseEntity *pEntity ); // what hull the monster uses - int NodeType( const CBaseEntity *pEntity ); // what node type the monster uses - inline int CapIndex( int afCapMask ) - { - if (afCapMask & (bits_CAP_OPEN_DOORS | bits_CAP_AUTO_DOORS | bits_CAP_USE)) - return 1; - return 0; - } - - - inline CNode &Node( int i ) - { -#ifdef _DEBUG - if ( !m_pNodes || i < 0 || i > m_cNodes ) - ALERT( at_error, "Bad Node!\n" ); -#endif - return m_pNodes[i]; - } - - inline CLink &Link( int i ) - { -#ifdef _DEBUG - if ( !m_pLinkPool || i < 0 || i > m_cLinks ) - ALERT( at_error, "Bad link!\n" ); -#endif - return m_pLinkPool[i]; - } - - inline CLink &NodeLink( int iNode, int iLink ) - { - return Link( Node( iNode ).m_iFirstLink + iLink ); - } - - inline CLink &NodeLink( const CNode &node, int iLink ) - { - return Link( node.m_iFirstLink + iLink ); - } - - inline int INodeLink ( int iNode, int iLink ) - { - return NodeLink( iNode, iLink ).m_iDestNode; - } - -#if 0 - inline CNode &SourceNode( int iNode, int iLink ) - { - return Node( NodeLink( iNode, iLink ).m_iSrcNode ); - } - - inline CNode &DestNode( int iNode, int iLink ) - { - return Node( NodeLink( iNode, iLink ).m_iDestNode ); - } - - inline CNode *PNodeLink ( int iNode, int iLink ) - { - return &DestNode( iNode, iLink ); - } -#endif -}; - -//========================================================= -// Nodes start out as ents in the level. The node graph -// is built, then these ents are discarded. -//========================================================= -class CNodeEnt : public CBaseEntity -{ - void Spawn( void ); - void KeyValue( KeyValueData *pkvd ); - virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } - - short m_sHintType; - short m_sHintActivity; -}; - - -//========================================================= -// CStack - last in, first out. -//========================================================= -class CStack -{ -public: - CStack( void ); - void Push( int value ); - int Pop( void ); - int Top( void ); - int Empty( void ) { return m_level==0; } - int Size( void ) { return m_level; } - void CopyToArray ( int *piArray ); - -private: - int m_stack[ MAX_STACK_NODES ]; - int m_level; -}; - - -//========================================================= -// CQueue - first in, first out. -//========================================================= -class CQueue -{ -public: - - CQueue( void );// constructor - inline int Full ( void ) { return ( m_cSize == MAX_STACK_NODES ); } - inline int Empty ( void ) { return ( m_cSize == 0 ); } - //inline int Tail ( void ) { return ( m_queue[ m_tail ] ); } - inline int Size ( void ) { return ( m_cSize ); } - void Insert( int, float ); - int Remove( float & ); - -private: - int m_cSize; - struct tag_QUEUE_NODE - { - int Id; - float Priority; - } m_queue[ MAX_STACK_NODES ]; - int m_head; - int m_tail; -}; - -//========================================================= -// CQueuePriority - Priority queue (smallest item out first). -// -//========================================================= -class CQueuePriority -{ -public: - - CQueuePriority( void );// constructor - inline int Full ( void ) { return ( m_cSize == MAX_STACK_NODES ); } - inline int Empty ( void ) { return ( m_cSize == 0 ); } - //inline int Tail ( float & ) { return ( m_queue[ m_tail ].Id ); } - inline int Size ( void ) { return ( m_cSize ); } - void Insert( int, float ); - int Remove( float &); - -private: - int m_cSize; - struct tag_HEAP_NODE - { - int Id; - float Priority; - } m_heap[ MAX_STACK_NODES ]; - void Heap_SiftDown(int); - void Heap_SiftUp(void); - -}; - -//========================================================= -// hints - these MUST coincide with the HINTS listed under -// info_node in the FGD file! -//========================================================= -enum -{ - HINT_NONE = 0, - HINT_WORLD_DOOR, - HINT_WORLD_WINDOW, - HINT_WORLD_BUTTON, - HINT_WORLD_MACHINERY, - HINT_WORLD_LEDGE, - HINT_WORLD_LIGHT_SOURCE, - HINT_WORLD_HEAT_SOURCE, - HINT_WORLD_BLINKING_LIGHT, - HINT_WORLD_BRIGHT_COLORS, - HINT_WORLD_HUMAN_BLOOD, - HINT_WORLD_ALIEN_BLOOD, - - HINT_TACTICAL_EXIT = 100, - HINT_TACTICAL_VANTAGE, - HINT_TACTICAL_AMBUSH, - - HINT_STUKA_PERCH = 300, - HINT_STUKA_LANDING, -}; - -extern CGraph WorldGraph; - -#endif // NODES_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +//========================================================= +// nodes.h +//========================================================= + +#ifndef NODES_H +#define NODES_H + +//========================================================= +// DEFINE +//========================================================= +#define MAX_STACK_NODES 100 +#define NO_NODE -1 +#define MAX_NODE_HULLS 4 + +#define bits_NODE_LAND ( 1 << 0 ) // Land node, so nudge if necessary. +#define bits_NODE_AIR ( 1 << 1 ) // Air node, don't nudge. +#define bits_NODE_WATER ( 1 << 2 ) // Water node, don't nudge. +#define bits_NODE_GROUP_REALM (bits_NODE_LAND | bits_NODE_AIR | bits_NODE_WATER) + +//========================================================= +// Instance of a node. +//========================================================= +class CNode +{ +public: + Vector m_vecOrigin;// location of this node in space + Vector m_vecOriginPeek; // location of this node (LAND nodes are NODE_HEIGHT higher). + BYTE m_Region[3]; // Which of 256 regions do each of the coordinate belong? + int m_afNodeInfo;// bits that tell us more about this location + + int m_cNumLinks; // how many links this node has + int m_iFirstLink;// index of this node's first link in the link pool. + + // Where to start looking in the compressed routing table (offset into m_pRouteInfo). + // (4 hull sizes -- smallest to largest + fly/swim), and secondly, door capability. + // + int m_pNextBestNode[MAX_NODE_HULLS][2]; + + // Used in finding the shortest path. m_fClosestSoFar is -1 if not visited. + // Then it is the distance to the source. If another path uses this node + // and has a closer distance, then m_iPreviousNode is also updated. + // + float m_flClosestSoFar; // Used in finding the shortest path. + int m_iPreviousNode; + + short m_sHintType;// there is something interesting in the world at this node's position + short m_sHintActivity;// there is something interesting in the world at this node's position + float m_flHintYaw;// monster on this node should face this yaw to face the hint. +}; + +//========================================================= +// CLink - A link between 2 nodes +//========================================================= +#define bits_LINK_SMALL_HULL ( 1 << 0 )// headcrab box can fit through this connection +#define bits_LINK_HUMAN_HULL ( 1 << 1 )// player box can fit through this connection +#define bits_LINK_LARGE_HULL ( 1 << 2 )// big box can fit through this connection +#define bits_LINK_FLY_HULL ( 1 << 3 )// a flying big box can fit through this connection +#define bits_LINK_DISABLED ( 1 << 4 )// link is not valid when the set + +#define NODE_SMALL_HULL 0 +#define NODE_HUMAN_HULL 1 +#define NODE_LARGE_HULL 2 +#define NODE_FLY_HULL 3 + +class CLink +{ +public: + int m_iSrcNode;// the node that 'owns' this link ( keeps us from having to make reverse lookups ) + int m_iDestNode;// the node on the other end of the link. + + entvars_t *m_pLinkEnt;// the entity that blocks this connection (doors, etc) + + // m_szLinkEntModelname is not necessarily NULL terminated (so we can store it in a more alignment-friendly 4 bytes) + char m_szLinkEntModelname[ 4 ];// the unique name of the brush model that blocks the connection (this is kept for save/restore) + + int m_afLinkInfo;// information about this link + float m_flWeight;// length of the link line segment +}; + + +typedef struct +{ + int m_SortedBy[3]; + int m_CheckedEvent; +} DIST_INFO; + +typedef struct +{ + Vector v; + short n; // Nearest node or -1 if no node found. +} CACHE_ENTRY; + +//========================================================= +// CGraph +//========================================================= +#define GRAPH_VERSION (int)16// !!!increment this whever graph/node/link classes change, to obsolesce older disk files. +class CGraph +{ +public: + +// the graph has two flags, and should not be accessed unless both flags are TRUE! + BOOL m_fGraphPresent;// is the graph in memory? + BOOL m_fGraphPointersSet;// are the entity pointers for the graph all set? + BOOL m_fRoutingComplete; // are the optimal routes computed, yet? + + CNode *m_pNodes;// pointer to the memory block that contains all node info + CLink *m_pLinkPool;// big list of all node connections + char *m_pRouteInfo; // compressed routing information the nodes use. + + int m_cNodes;// total number of nodes + int m_cLinks;// total number of links + int m_nRouteInfo; // size of m_pRouteInfo in bytes. + + // Tables for making nearest node lookup faster. SortedBy provided nodes in a + // order of a particular coordinate. Instead of doing a binary search, RangeStart + // and RangeEnd let you get to the part of SortedBy that you are interested in. + // + // Once you have a point of interest, the only way you'll find a closer point is + // if at least one of the coordinates is closer than the ones you have now. So we + // search each range. After the search is exhausted, we know we have the closest + // node. + // +#define CACHE_SIZE 128 +#define NUM_RANGES 256 + DIST_INFO *m_di; // This is m_cNodes long, but the entries don't correspond to CNode entries. + int m_RangeStart[3][NUM_RANGES]; + int m_RangeEnd[3][NUM_RANGES]; + float m_flShortest; + int m_iNearest; + int m_minX, m_minY, m_minZ, m_maxX, m_maxY, m_maxZ; + int m_minBoxX, m_minBoxY, m_minBoxZ, m_maxBoxX, m_maxBoxY, m_maxBoxZ; + int m_CheckedCounter; + float m_RegionMin[3], m_RegionMax[3]; // The range of nodes. + CACHE_ENTRY m_Cache[CACHE_SIZE]; + + + int m_HashPrimes[16]; + short *m_pHashLinks; + int m_nHashLinks; + + + // kinda sleazy. In order to allow variety in active idles for monster groups in a room with more than one node, + // we keep track of the last node we searched from and store it here. Subsequent searches by other monsters will pick + // up where the last search stopped. + int m_iLastActiveIdleSearch; + + // another such system used to track the search for cover nodes, helps greatly with two monsters trying to get to the same node. + int m_iLastCoverSearch; + + // functions to create the graph + int LinkVisibleNodes ( CLink *pLinkPool, FILE *file, int *piBadNode ); + int RejectInlineLinks ( CLink *pLinkPool, FILE *file ); + int FindShortestPath ( int *piPath, int iStart, int iDest, int iHull, int afCapMask); + int FindNearestNode ( const Vector &vecOrigin, CBaseEntity *pEntity ); + int FindNearestNode ( const Vector &vecOrigin, int afNodeTypes ); + //int FindNearestLink ( const Vector &vecTestPoint, int *piNearestLink, BOOL *pfAlongLine ); + float PathLength( int iStart, int iDest, int iHull, int afCapMask ); + int NextNodeInRoute( int iCurrentNode, int iDest, int iHull, int iCap ); + + enum NODEQUERY { NODEGRAPH_DYNAMIC, NODEGRAPH_STATIC }; + // A static query means we're asking about the possiblity of handling this entity at ANY time + // A dynamic query means we're asking about it RIGHT NOW. So we should query the current state + int HandleLinkEnt ( int iNode, entvars_t *pevLinkEnt, int afCapMask, NODEQUERY queryType ); + entvars_t* LinkEntForLink ( CLink *pLink, CNode *pNode ); + void ShowNodeConnections ( int iNode ); + void InitGraph( void ); + int AllocNodes ( void ); + + int CheckNODFile(char *szMapName); + int FLoadGraph(char *szMapName); + int FSaveGraph(char *szMapName); + int FSetGraphPointers(void); + void CheckNode(Vector vecOrigin, int iNode); + + void BuildRegionTables(void); + void ComputeStaticRoutingTables(void); + void TestRoutingTables(void); + + void HashInsert(int iSrcNode, int iDestNode, int iKey); + void HashSearch(int iSrcNode, int iDestNode, int &iKey); + void HashChoosePrimes(int TableSize); + void BuildLinkLookups(void); + + void SortNodes(void); + + int HullIndex( const CBaseEntity *pEntity ); // what hull the monster uses + int NodeType( const CBaseEntity *pEntity ); // what node type the monster uses + inline int CapIndex( int afCapMask ) + { + if (afCapMask & (bits_CAP_OPEN_DOORS | bits_CAP_AUTO_DOORS | bits_CAP_USE)) + return 1; + return 0; + } + + + inline CNode &Node( int i ) + { +#ifdef _DEBUG + if ( !m_pNodes || i < 0 || i > m_cNodes ) + ALERT( at_error, "Bad Node!\n" ); +#endif + return m_pNodes[i]; + } + + inline CLink &Link( int i ) + { +#ifdef _DEBUG + if ( !m_pLinkPool || i < 0 || i > m_cLinks ) + ALERT( at_error, "Bad link!\n" ); +#endif + return m_pLinkPool[i]; + } + + inline CLink &NodeLink( int iNode, int iLink ) + { + return Link( Node( iNode ).m_iFirstLink + iLink ); + } + + inline CLink &NodeLink( const CNode &node, int iLink ) + { + return Link( node.m_iFirstLink + iLink ); + } + + inline int INodeLink ( int iNode, int iLink ) + { + return NodeLink( iNode, iLink ).m_iDestNode; + } + +#if 0 + inline CNode &SourceNode( int iNode, int iLink ) + { + return Node( NodeLink( iNode, iLink ).m_iSrcNode ); + } + + inline CNode &DestNode( int iNode, int iLink ) + { + return Node( NodeLink( iNode, iLink ).m_iDestNode ); + } + + inline CNode *PNodeLink ( int iNode, int iLink ) + { + return &DestNode( iNode, iLink ); + } +#endif +}; + +//========================================================= +// Nodes start out as ents in the level. The node graph +// is built, then these ents are discarded. +//========================================================= +class CNodeEnt : public CBaseEntity +{ + void Spawn( void ); + void KeyValue( KeyValueData *pkvd ); + virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + + short m_sHintType; + short m_sHintActivity; +}; + + +//========================================================= +// CStack - last in, first out. +//========================================================= +class CStack +{ +public: + CStack( void ); + void Push( int value ); + int Pop( void ); + int Top( void ); + int Empty( void ) { return m_level==0; } + int Size( void ) { return m_level; } + void CopyToArray ( int *piArray ); + +private: + int m_stack[ MAX_STACK_NODES ]; + int m_level; +}; + + +//========================================================= +// CQueue - first in, first out. +//========================================================= +class CQueue +{ +public: + + CQueue( void );// constructor + inline int Full ( void ) { return ( m_cSize == MAX_STACK_NODES ); } + inline int Empty ( void ) { return ( m_cSize == 0 ); } + //inline int Tail ( void ) { return ( m_queue[ m_tail ] ); } + inline int Size ( void ) { return ( m_cSize ); } + void Insert( int, float ); + int Remove( float & ); + +private: + int m_cSize; + struct tag_QUEUE_NODE + { + int Id; + float Priority; + } m_queue[ MAX_STACK_NODES ]; + int m_head; + int m_tail; +}; + +//========================================================= +// CQueuePriority - Priority queue (smallest item out first). +// +//========================================================= +class CQueuePriority +{ +public: + + CQueuePriority( void );// constructor + inline int Full ( void ) { return ( m_cSize == MAX_STACK_NODES ); } + inline int Empty ( void ) { return ( m_cSize == 0 ); } + //inline int Tail ( float & ) { return ( m_queue[ m_tail ].Id ); } + inline int Size ( void ) { return ( m_cSize ); } + void Insert( int, float ); + int Remove( float &); + +private: + int m_cSize; + struct tag_HEAP_NODE + { + int Id; + float Priority; + } m_heap[ MAX_STACK_NODES ]; + void Heap_SiftDown(int); + void Heap_SiftUp(void); + +}; + +//========================================================= +// hints - these MUST coincide with the HINTS listed under +// info_node in the FGD file! +//========================================================= +enum +{ + HINT_NONE = 0, + HINT_WORLD_DOOR, + HINT_WORLD_WINDOW, + HINT_WORLD_BUTTON, + HINT_WORLD_MACHINERY, + HINT_WORLD_LEDGE, + HINT_WORLD_LIGHT_SOURCE, + HINT_WORLD_HEAT_SOURCE, + HINT_WORLD_BLINKING_LIGHT, + HINT_WORLD_BRIGHT_COLORS, + HINT_WORLD_HUMAN_BLOOD, + HINT_WORLD_ALIEN_BLOOD, + + HINT_TACTICAL_EXIT = 100, + HINT_TACTICAL_VANTAGE, + HINT_TACTICAL_AMBUSH, + + HINT_STUKA_PERCH = 300, + HINT_STUKA_LANDING, +}; + +extern CGraph WorldGraph; + +#endif // NODES_H diff --git a/dep/rehlsdk/dlls/plane.h b/dep/rehlsdk/dlls/plane.h index a54f245..af70f1c 100644 --- a/dep/rehlsdk/dlls/plane.h +++ b/dep/rehlsdk/dlls/plane.h @@ -1,43 +1,43 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef PLANE_H -#define PLANE_H - -//========================================================= -// Plane -//========================================================= -class CPlane -{ -public: - CPlane ( void ); - - //========================================================= - // InitializePlane - Takes a normal for the plane and a - // point on the plane and - //========================================================= - void InitializePlane ( const Vector &vecNormal, const Vector &vecPoint ); - - //========================================================= - // PointInFront - determines whether the given vector is - // in front of the plane. - //========================================================= - BOOL PointInFront ( const Vector &vecPoint ); - - Vector m_vecNormal; - float m_flDist; - BOOL m_fInitialized; -}; - -#endif // PLANE_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef PLANE_H +#define PLANE_H + +//========================================================= +// Plane +//========================================================= +class CPlane +{ +public: + CPlane ( void ); + + //========================================================= + // InitializePlane - Takes a normal for the plane and a + // point on the plane and + //========================================================= + void InitializePlane ( const Vector &vecNormal, const Vector &vecPoint ); + + //========================================================= + // PointInFront - determines whether the given vector is + // in front of the plane. + //========================================================= + BOOL PointInFront ( const Vector &vecPoint ); + + Vector m_vecNormal; + float m_flDist; + BOOL m_fInitialized; +}; + +#endif // PLANE_H diff --git a/dep/rehlsdk/dlls/player.h b/dep/rehlsdk/dlls/player.h index 0f90e73..f760548 100644 --- a/dep/rehlsdk/dlls/player.h +++ b/dep/rehlsdk/dlls/player.h @@ -1,336 +1,336 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef PLAYER_H -#define PLAYER_H - - -#include "pm_materials.h" - - -#define PLAYER_FATAL_FALL_SPEED 1024// approx 60 feet -#define PLAYER_MAX_SAFE_FALL_SPEED 580// approx 20 feet -#define DAMAGE_FOR_FALL_SPEED (float) 100 / ( PLAYER_FATAL_FALL_SPEED - PLAYER_MAX_SAFE_FALL_SPEED )// damage per unit per second. -#define PLAYER_MIN_BOUNCE_SPEED 200 -#define PLAYER_FALL_PUNCH_THRESHHOLD (float)350 // won't punch player's screen/make scrape noise unless player falling at least this fast. - -// -// Player PHYSICS FLAGS bits -// -#define PFLAG_ONLADDER ( 1<<0 ) -#define PFLAG_ONSWING ( 1<<0 ) -#define PFLAG_ONTRAIN ( 1<<1 ) -#define PFLAG_ONBARNACLE ( 1<<2 ) -#define PFLAG_DUCKING ( 1<<3 ) // In the process of ducking, but totally squatted yet -#define PFLAG_USING ( 1<<4 ) // Using a continuous entity -#define PFLAG_OBSERVER ( 1<<5 ) // player is locked in stationary cam mode. Spectators can move, observers can't. - -// -// generic player -// -//----------------------------------------------------- -//This is Half-Life player entity -//----------------------------------------------------- -#define CSUITPLAYLIST 4 // max of 4 suit sentences queued up at any time - -#define SUIT_GROUP TRUE -#define SUIT_SENTENCE FALSE - -#define SUIT_REPEAT_OK 0 -#define SUIT_NEXT_IN_30SEC 30 -#define SUIT_NEXT_IN_1MIN 60 -#define SUIT_NEXT_IN_5MIN 300 -#define SUIT_NEXT_IN_10MIN 600 -#define SUIT_NEXT_IN_30MIN 1800 -#define SUIT_NEXT_IN_1HOUR 3600 - -#define CSUITNOREPEAT 32 - -#define SOUND_FLASHLIGHT_ON "items/flashlight1.wav" -#define SOUND_FLASHLIGHT_OFF "items/flashlight1.wav" - -#define TEAM_NAME_LENGTH 16 - -typedef enum -{ - PLAYER_IDLE, - PLAYER_WALK, - PLAYER_JUMP, - PLAYER_SUPERJUMP, - PLAYER_DIE, - PLAYER_ATTACK1, -} PLAYER_ANIM; - -#define MAX_ID_RANGE 2048 -#define SBAR_STRING_SIZE 128 - -enum sbar_data -{ - SBAR_ID_TARGETNAME = 1, - SBAR_ID_TARGETHEALTH, - SBAR_ID_TARGETARMOR, - SBAR_END, -}; - -#define CHAT_INTERVAL 1.0f - -class CBasePlayer : public CBaseMonster -{ -public: - - // Spectator camera - void Observer_FindNextPlayer( bool bReverse ); - void Observer_HandleButtons(); - void Observer_SetMode( int iMode ); - void Observer_CheckTarget(); - void Observer_CheckProperties(); - EHANDLE m_hObserverTarget; - float m_flNextObserverInput; - int m_iObserverWeapon; // weapon of current tracked target - int m_iObserverLastMode;// last used observer mode - int IsObserver() { return pev->iuser1; }; - int random_seed; // See that is shared between client & server for shared weapons code - - int m_iPlayerSound;// the index of the sound list slot reserved for this player - int m_iTargetVolume;// ideal sound volume. - int m_iWeaponVolume;// how loud the player's weapon is right now. - int m_iExtraSoundTypes;// additional classification for this weapon's sound - int m_iWeaponFlash;// brightness of the weapon flash - float m_flStopExtraSoundTime; - - float m_flFlashLightTime; // Time until next battery draw/Recharge - int m_iFlashBattery; // Flashlight Battery Draw - - int m_afButtonLast; - int m_afButtonPressed; - int m_afButtonReleased; - - edict_t *m_pentSndLast; // last sound entity to modify player room type - float m_flSndRoomtype; // last roomtype set by sound entity - float m_flSndRange; // dist from player to sound entity - - float m_flFallVelocity; - - int m_rgItems[MAX_ITEMS]; - int m_fKnownItem; // True when a new item needs to be added - int m_fNewAmmo; // True when a new item has been added - - unsigned int m_afPhysicsFlags; // physics flags - set when 'normal' physics should be revisited or overriden - float m_fNextSuicideTime; // the time after which the player can next use the suicide command - - -// these are time-sensitive things that we keep track of - float m_flTimeStepSound; // when the last stepping sound was made - float m_flTimeWeaponIdle; // when to play another weapon idle animation. - float m_flSwimTime; // how long player has been underwater - float m_flDuckTime; // how long we've been ducking - float m_flWallJumpTime; // how long until next walljump - - float m_flSuitUpdate; // when to play next suit update - int m_rgSuitPlayList[CSUITPLAYLIST];// next sentencenum to play for suit update - int m_iSuitPlayNext; // next sentence slot for queue storage; - int m_rgiSuitNoRepeat[CSUITNOREPEAT]; // suit sentence no repeat list - float m_rgflSuitNoRepeatTime[CSUITNOREPEAT]; // how long to wait before allowing repeat - int m_lastDamageAmount; // Last damage taken - float m_tbdPrev; // Time-based damage timer - - float m_flgeigerRange; // range to nearest radiation source - float m_flgeigerDelay; // delay per update of range msg to client - int m_igeigerRangePrev; - int m_iStepLeft; // alternate left/right foot stepping sound - char m_szTextureName[CBTEXTURENAMEMAX]; // current texture name we're standing on - char m_chTextureType; // current texture type - - int m_idrowndmg; // track drowning damage taken - int m_idrownrestored; // track drowning damage restored - - int m_bitsHUDDamage; // Damage bits for the current fame. These get sent to - // the hude via the DAMAGE message - BOOL m_fInitHUD; // True when deferred HUD restart msg needs to be sent - BOOL m_fGameHUDInitialized; - int m_iTrain; // Train control position - BOOL m_fWeapon; // Set this to FALSE to force a reset of the current weapon HUD info - - EHANDLE m_pTank; // the tank which the player is currently controlling, NULL if no tank - float m_fDeadTime; // the time at which the player died (used in PlayerDeathThink()) - - BOOL m_fNoPlayerSound; // a debugging feature. Player makes no sound if this is true. - BOOL m_fLongJump; // does this player have the longjump module? - - float m_tSneaking; - int m_iUpdateTime; // stores the number of frame ticks before sending HUD update messages - int m_iClientHealth; // the health currently known by the client. If this changes, send a new - int m_iClientBattery; // the Battery currently known by the client. If this changes, send a new - int m_iHideHUD; // the players hud weapon info is to be hidden - int m_iClientHideHUD; - int m_iFOV; // field of view - int m_iClientFOV; // client's known FOV - // usable player items - CBasePlayerItem *m_rgpPlayerItems[MAX_ITEM_TYPES]; - CBasePlayerItem *m_pActiveItem; - CBasePlayerItem *m_pClientActiveItem; // client version of the active item - CBasePlayerItem *m_pLastItem; - // shared ammo slots - int m_rgAmmo[MAX_AMMO_SLOTS]; - int m_rgAmmoLast[MAX_AMMO_SLOTS]; - - Vector m_vecAutoAim; - BOOL m_fOnTarget; - int m_iDeaths; - float m_iRespawnFrames; // used in PlayerDeathThink() to make sure players can always respawn - - int m_lastx, m_lasty; // These are the previous update's crosshair angles, DON"T SAVE/RESTORE - - int m_nCustomSprayFrames;// Custom clan logo frames for this player - float m_flNextDecalTime;// next time this player can spray a decal - - char m_szTeamName[TEAM_NAME_LENGTH]; - - virtual void Spawn( void ); - void Pain( void ); - -// virtual void Think( void ); - virtual void Jump( void ); - virtual void Duck( void ); - virtual void PreThink( void ); - virtual void PostThink( void ); - virtual Vector GetGunPosition( void ); - virtual int TakeHealth( float flHealth, int bitsDamageType ); - virtual void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); - virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType); - virtual void Killed( entvars_t *pevAttacker, int iGib ); - virtual Vector BodyTarget( const Vector &posSrc ) { return Center( ) + pev->view_ofs * RANDOM_FLOAT( 0.5, 1.1 ); }; // position to shoot at - virtual void StartSneaking( void ) { m_tSneaking = gpGlobals->time - 1; } - virtual void StopSneaking( void ) { m_tSneaking = gpGlobals->time + 30; } - virtual BOOL IsSneaking( void ) { return m_tSneaking <= gpGlobals->time; } - virtual BOOL IsAlive( void ) { return (pev->deadflag == DEAD_NO) && pev->health > 0; } - virtual BOOL ShouldFadeOnDeath( void ) { return FALSE; } - virtual BOOL IsPlayer( void ) { return TRUE; } // Spectators should return FALSE for this, they aren't "players" as far as game logic is concerned - - virtual BOOL IsNetClient( void ) { return TRUE; } // Bots should return FALSE for this, they can't receive NET messages - // Spectators should return TRUE for this - virtual const char *TeamID( void ); - - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - void RenewItems(void); - void PackDeadPlayerItems( void ); - void RemoveAllItems( BOOL removeSuit ); - BOOL SwitchWeapon( CBasePlayerItem *pWeapon ); - - // JOHN: sends custom messages if player HUD data has changed (eg health, ammo) - virtual void UpdateClientData( void ); - - static TYPEDESCRIPTION m_playerSaveData[]; - - // Player is moved across the transition by other means - virtual int ObjectCaps( void ) { return CBaseMonster :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } - virtual void Precache( void ); - BOOL IsOnLadder( void ); - BOOL FlashlightIsOn( void ); - void FlashlightTurnOn( void ); - void FlashlightTurnOff( void ); - - void UpdatePlayerSound ( void ); - void DeathSound ( void ); - - int Classify ( void ); - void SetAnimation( PLAYER_ANIM playerAnim ); - void SetWeaponAnimType( const char *szExtention ); - char m_szAnimExtention[32]; - - // custom player functions - virtual void ImpulseCommands( void ); - void CheatImpulseCommands( int iImpulse ); - - void StartDeathCam( void ); - void StartObserver( Vector vecPosition, Vector vecViewAngle ); - - void AddPoints( int score, BOOL bAllowNegativeScore ); - void AddPointsToTeam( int score, BOOL bAllowNegativeScore ); - BOOL AddPlayerItem( CBasePlayerItem *pItem ); - BOOL RemovePlayerItem( CBasePlayerItem *pItem ); - void DropPlayerItem ( char *pszItemName ); - BOOL HasPlayerItem( CBasePlayerItem *pCheckItem ); - BOOL HasNamedPlayerItem( const char *pszItemName ); - BOOL HasWeapons( void );// do I have ANY weapons? - void SelectPrevItem( int iItem ); - void SelectNextItem( int iItem ); - void SelectLastItem(void); - void SelectItem(const char *pstr); - void ItemPreFrame( void ); - void ItemPostFrame( void ); - void GiveNamedItem( const char *szName ); - void EnableControl(BOOL fControl); - - int GiveAmmo( int iAmount, char *szName, int iMax ); - void SendAmmoUpdate(void); - - void WaterMove( void ); - void EXPORT PlayerDeathThink( void ); - void PlayerUse( void ); - - void CheckSuitUpdate(); - void SetSuitUpdate(char *name, int fgroup, int iNoRepeat); - void UpdateGeigerCounter( void ); - void CheckTimeBasedDamage( void ); - - BOOL FBecomeProne ( void ); - void BarnacleVictimBitten ( entvars_t *pevBarnacle ); - void BarnacleVictimReleased ( void ); - static int GetAmmoIndex(const char *psz); - int AmmoInventory( int iAmmoIndex ); - int Illumination( void ); - - void ResetAutoaim( void ); - Vector GetAutoaimVector( float flDelta ); - Vector AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta ); - - void ForceClientDllUpdate( void ); // Forces all client .dll specific data to be resent to client. - - void DeathMessage( entvars_t *pevKiller ); - - void SetCustomDecalFrames( int nFrames ); - int GetCustomDecalFrames( void ); - - void CBasePlayer::TabulateAmmo( void ); - - float m_flStartCharge; - float m_flAmmoStartCharge; - float m_flPlayAftershock; - float m_flNextAmmoBurn;// while charging, when to absorb another unit of player's ammo? - - //Player ID - void InitStatusBar( void ); - void UpdateStatusBar( void ); - int m_izSBarState[ SBAR_END ]; - float m_flNextSBarUpdateTime; - float m_flStatusBarDisappearDelay; - char m_SbarString0[ SBAR_STRING_SIZE ]; - char m_SbarString1[ SBAR_STRING_SIZE ]; - - float m_flNextChatTime; - -}; - -#define AUTOAIM_2DEGREES 0.0348994967025 -#define AUTOAIM_5DEGREES 0.08715574274766 -#define AUTOAIM_8DEGREES 0.1391731009601 -#define AUTOAIM_10DEGREES 0.1736481776669 - - -extern int gmsgHudText; -extern BOOL gInitHUD; - -#endif // PLAYER_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef PLAYER_H +#define PLAYER_H + + +#include "pm_materials.h" + + +#define PLAYER_FATAL_FALL_SPEED 1024// approx 60 feet +#define PLAYER_MAX_SAFE_FALL_SPEED 580// approx 20 feet +#define DAMAGE_FOR_FALL_SPEED (float) 100 / ( PLAYER_FATAL_FALL_SPEED - PLAYER_MAX_SAFE_FALL_SPEED )// damage per unit per second. +#define PLAYER_MIN_BOUNCE_SPEED 200 +#define PLAYER_FALL_PUNCH_THRESHHOLD (float)350 // won't punch player's screen/make scrape noise unless player falling at least this fast. + +// +// Player PHYSICS FLAGS bits +// +#define PFLAG_ONLADDER ( 1<<0 ) +#define PFLAG_ONSWING ( 1<<0 ) +#define PFLAG_ONTRAIN ( 1<<1 ) +#define PFLAG_ONBARNACLE ( 1<<2 ) +#define PFLAG_DUCKING ( 1<<3 ) // In the process of ducking, but totally squatted yet +#define PFLAG_USING ( 1<<4 ) // Using a continuous entity +#define PFLAG_OBSERVER ( 1<<5 ) // player is locked in stationary cam mode. Spectators can move, observers can't. + +// +// generic player +// +//----------------------------------------------------- +//This is Half-Life player entity +//----------------------------------------------------- +#define CSUITPLAYLIST 4 // max of 4 suit sentences queued up at any time + +#define SUIT_GROUP TRUE +#define SUIT_SENTENCE FALSE + +#define SUIT_REPEAT_OK 0 +#define SUIT_NEXT_IN_30SEC 30 +#define SUIT_NEXT_IN_1MIN 60 +#define SUIT_NEXT_IN_5MIN 300 +#define SUIT_NEXT_IN_10MIN 600 +#define SUIT_NEXT_IN_30MIN 1800 +#define SUIT_NEXT_IN_1HOUR 3600 + +#define CSUITNOREPEAT 32 + +#define SOUND_FLASHLIGHT_ON "items/flashlight1.wav" +#define SOUND_FLASHLIGHT_OFF "items/flashlight1.wav" + +#define TEAM_NAME_LENGTH 16 + +typedef enum +{ + PLAYER_IDLE, + PLAYER_WALK, + PLAYER_JUMP, + PLAYER_SUPERJUMP, + PLAYER_DIE, + PLAYER_ATTACK1, +} PLAYER_ANIM; + +#define MAX_ID_RANGE 2048 +#define SBAR_STRING_SIZE 128 + +enum sbar_data +{ + SBAR_ID_TARGETNAME = 1, + SBAR_ID_TARGETHEALTH, + SBAR_ID_TARGETARMOR, + SBAR_END, +}; + +#define CHAT_INTERVAL 1.0f + +class CBasePlayer : public CBaseMonster +{ +public: + + // Spectator camera + void Observer_FindNextPlayer( bool bReverse ); + void Observer_HandleButtons(); + void Observer_SetMode( int iMode ); + void Observer_CheckTarget(); + void Observer_CheckProperties(); + EHANDLE m_hObserverTarget; + float m_flNextObserverInput; + int m_iObserverWeapon; // weapon of current tracked target + int m_iObserverLastMode;// last used observer mode + int IsObserver() { return pev->iuser1; }; + int random_seed; // See that is shared between client & server for shared weapons code + + int m_iPlayerSound;// the index of the sound list slot reserved for this player + int m_iTargetVolume;// ideal sound volume. + int m_iWeaponVolume;// how loud the player's weapon is right now. + int m_iExtraSoundTypes;// additional classification for this weapon's sound + int m_iWeaponFlash;// brightness of the weapon flash + float m_flStopExtraSoundTime; + + float m_flFlashLightTime; // Time until next battery draw/Recharge + int m_iFlashBattery; // Flashlight Battery Draw + + int m_afButtonLast; + int m_afButtonPressed; + int m_afButtonReleased; + + edict_t *m_pentSndLast; // last sound entity to modify player room type + float m_flSndRoomtype; // last roomtype set by sound entity + float m_flSndRange; // dist from player to sound entity + + float m_flFallVelocity; + + int m_rgItems[MAX_ITEMS]; + int m_fKnownItem; // True when a new item needs to be added + int m_fNewAmmo; // True when a new item has been added + + unsigned int m_afPhysicsFlags; // physics flags - set when 'normal' physics should be revisited or overriden + float m_fNextSuicideTime; // the time after which the player can next use the suicide command + + +// these are time-sensitive things that we keep track of + float m_flTimeStepSound; // when the last stepping sound was made + float m_flTimeWeaponIdle; // when to play another weapon idle animation. + float m_flSwimTime; // how long player has been underwater + float m_flDuckTime; // how long we've been ducking + float m_flWallJumpTime; // how long until next walljump + + float m_flSuitUpdate; // when to play next suit update + int m_rgSuitPlayList[CSUITPLAYLIST];// next sentencenum to play for suit update + int m_iSuitPlayNext; // next sentence slot for queue storage; + int m_rgiSuitNoRepeat[CSUITNOREPEAT]; // suit sentence no repeat list + float m_rgflSuitNoRepeatTime[CSUITNOREPEAT]; // how long to wait before allowing repeat + int m_lastDamageAmount; // Last damage taken + float m_tbdPrev; // Time-based damage timer + + float m_flgeigerRange; // range to nearest radiation source + float m_flgeigerDelay; // delay per update of range msg to client + int m_igeigerRangePrev; + int m_iStepLeft; // alternate left/right foot stepping sound + char m_szTextureName[CBTEXTURENAMEMAX]; // current texture name we're standing on + char m_chTextureType; // current texture type + + int m_idrowndmg; // track drowning damage taken + int m_idrownrestored; // track drowning damage restored + + int m_bitsHUDDamage; // Damage bits for the current fame. These get sent to + // the hude via the DAMAGE message + BOOL m_fInitHUD; // True when deferred HUD restart msg needs to be sent + BOOL m_fGameHUDInitialized; + int m_iTrain; // Train control position + BOOL m_fWeapon; // Set this to FALSE to force a reset of the current weapon HUD info + + EHANDLE m_pTank; // the tank which the player is currently controlling, NULL if no tank + float m_fDeadTime; // the time at which the player died (used in PlayerDeathThink()) + + BOOL m_fNoPlayerSound; // a debugging feature. Player makes no sound if this is true. + BOOL m_fLongJump; // does this player have the longjump module? + + float m_tSneaking; + int m_iUpdateTime; // stores the number of frame ticks before sending HUD update messages + int m_iClientHealth; // the health currently known by the client. If this changes, send a new + int m_iClientBattery; // the Battery currently known by the client. If this changes, send a new + int m_iHideHUD; // the players hud weapon info is to be hidden + int m_iClientHideHUD; + int m_iFOV; // field of view + int m_iClientFOV; // client's known FOV + // usable player items + CBasePlayerItem *m_rgpPlayerItems[MAX_ITEM_TYPES]; + CBasePlayerItem *m_pActiveItem; + CBasePlayerItem *m_pClientActiveItem; // client version of the active item + CBasePlayerItem *m_pLastItem; + // shared ammo slots + int m_rgAmmo[MAX_AMMO_SLOTS]; + int m_rgAmmoLast[MAX_AMMO_SLOTS]; + + Vector m_vecAutoAim; + BOOL m_fOnTarget; + int m_iDeaths; + float m_iRespawnFrames; // used in PlayerDeathThink() to make sure players can always respawn + + int m_lastx, m_lasty; // These are the previous update's crosshair angles, DON"T SAVE/RESTORE + + int m_nCustomSprayFrames;// Custom clan logo frames for this player + float m_flNextDecalTime;// next time this player can spray a decal + + char m_szTeamName[TEAM_NAME_LENGTH]; + + virtual void Spawn( void ); + void Pain( void ); + +// virtual void Think( void ); + virtual void Jump( void ); + virtual void Duck( void ); + virtual void PreThink( void ); + virtual void PostThink( void ); + virtual Vector GetGunPosition( void ); + virtual int TakeHealth( float flHealth, int bitsDamageType ); + virtual void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); + virtual int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType); + virtual void Killed( entvars_t *pevAttacker, int iGib ); + virtual Vector BodyTarget( const Vector &posSrc ) { return Center( ) + pev->view_ofs * RANDOM_FLOAT( 0.5, 1.1 ); }; // position to shoot at + virtual void StartSneaking( void ) { m_tSneaking = gpGlobals->time - 1; } + virtual void StopSneaking( void ) { m_tSneaking = gpGlobals->time + 30; } + virtual BOOL IsSneaking( void ) { return m_tSneaking <= gpGlobals->time; } + virtual BOOL IsAlive( void ) { return (pev->deadflag == DEAD_NO) && pev->health > 0; } + virtual BOOL ShouldFadeOnDeath( void ) { return FALSE; } + virtual BOOL IsPlayer( void ) { return TRUE; } // Spectators should return FALSE for this, they aren't "players" as far as game logic is concerned + + virtual BOOL IsNetClient( void ) { return TRUE; } // Bots should return FALSE for this, they can't receive NET messages + // Spectators should return TRUE for this + virtual const char *TeamID( void ); + + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + void RenewItems(void); + void PackDeadPlayerItems( void ); + void RemoveAllItems( BOOL removeSuit ); + BOOL SwitchWeapon( CBasePlayerItem *pWeapon ); + + // JOHN: sends custom messages if player HUD data has changed (eg health, ammo) + virtual void UpdateClientData( void ); + + static TYPEDESCRIPTION m_playerSaveData[]; + + // Player is moved across the transition by other means + virtual int ObjectCaps( void ) { return CBaseMonster :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + virtual void Precache( void ); + BOOL IsOnLadder( void ); + BOOL FlashlightIsOn( void ); + void FlashlightTurnOn( void ); + void FlashlightTurnOff( void ); + + void UpdatePlayerSound ( void ); + void DeathSound ( void ); + + int Classify ( void ); + void SetAnimation( PLAYER_ANIM playerAnim ); + void SetWeaponAnimType( const char *szExtention ); + char m_szAnimExtention[32]; + + // custom player functions + virtual void ImpulseCommands( void ); + void CheatImpulseCommands( int iImpulse ); + + void StartDeathCam( void ); + void StartObserver( Vector vecPosition, Vector vecViewAngle ); + + void AddPoints( int score, BOOL bAllowNegativeScore ); + void AddPointsToTeam( int score, BOOL bAllowNegativeScore ); + BOOL AddPlayerItem( CBasePlayerItem *pItem ); + BOOL RemovePlayerItem( CBasePlayerItem *pItem ); + void DropPlayerItem ( char *pszItemName ); + BOOL HasPlayerItem( CBasePlayerItem *pCheckItem ); + BOOL HasNamedPlayerItem( const char *pszItemName ); + BOOL HasWeapons( void );// do I have ANY weapons? + void SelectPrevItem( int iItem ); + void SelectNextItem( int iItem ); + void SelectLastItem(void); + void SelectItem(const char *pstr); + void ItemPreFrame( void ); + void ItemPostFrame( void ); + void GiveNamedItem( const char *szName ); + void EnableControl(BOOL fControl); + + int GiveAmmo( int iAmount, char *szName, int iMax ); + void SendAmmoUpdate(void); + + void WaterMove( void ); + void EXPORT PlayerDeathThink( void ); + void PlayerUse( void ); + + void CheckSuitUpdate(); + void SetSuitUpdate(char *name, int fgroup, int iNoRepeat); + void UpdateGeigerCounter( void ); + void CheckTimeBasedDamage( void ); + + BOOL FBecomeProne ( void ); + void BarnacleVictimBitten ( entvars_t *pevBarnacle ); + void BarnacleVictimReleased ( void ); + static int GetAmmoIndex(const char *psz); + int AmmoInventory( int iAmmoIndex ); + int Illumination( void ); + + void ResetAutoaim( void ); + Vector GetAutoaimVector( float flDelta ); + Vector AutoaimDeflection( Vector &vecSrc, float flDist, float flDelta ); + + void ForceClientDllUpdate( void ); // Forces all client .dll specific data to be resent to client. + + void DeathMessage( entvars_t *pevKiller ); + + void SetCustomDecalFrames( int nFrames ); + int GetCustomDecalFrames( void ); + + void CBasePlayer::TabulateAmmo( void ); + + float m_flStartCharge; + float m_flAmmoStartCharge; + float m_flPlayAftershock; + float m_flNextAmmoBurn;// while charging, when to absorb another unit of player's ammo? + + //Player ID + void InitStatusBar( void ); + void UpdateStatusBar( void ); + int m_izSBarState[ SBAR_END ]; + float m_flNextSBarUpdateTime; + float m_flStatusBarDisappearDelay; + char m_SbarString0[ SBAR_STRING_SIZE ]; + char m_SbarString1[ SBAR_STRING_SIZE ]; + + float m_flNextChatTime; + +}; + +#define AUTOAIM_2DEGREES 0.0348994967025 +#define AUTOAIM_5DEGREES 0.08715574274766 +#define AUTOAIM_8DEGREES 0.1391731009601 +#define AUTOAIM_10DEGREES 0.1736481776669 + + +extern int gmsgHudText; +extern BOOL gInitHUD; + +#endif // PLAYER_H diff --git a/dep/rehlsdk/dlls/saverestore.h b/dep/rehlsdk/dlls/saverestore.h index 3814aaa..c3761f3 100644 --- a/dep/rehlsdk/dlls/saverestore.h +++ b/dep/rehlsdk/dlls/saverestore.h @@ -1,169 +1,169 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// Implementation in UTIL.CPP -#ifndef SAVERESTORE_H -#define SAVERESTORE_H - -class CBaseEntity; - -class CSaveRestoreBuffer -{ -public: - CSaveRestoreBuffer( void ); - CSaveRestoreBuffer( SAVERESTOREDATA *pdata ); - ~CSaveRestoreBuffer( void ); - - int EntityIndex( entvars_t *pevLookup ); - int EntityIndex( edict_t *pentLookup ); - int EntityIndex( EOFFSET eoLookup ); - int EntityIndex( CBaseEntity *pEntity ); - - int EntityFlags( int entityIndex, int flags ) { return EntityFlagsSet( entityIndex, 0 ); } - int EntityFlagsSet( int entityIndex, int flags ); - - edict_t *EntityFromIndex( int entityIndex ); - - unsigned short TokenHash( const char *pszToken ); - -protected: - SAVERESTOREDATA *m_pdata; - void BufferRewind( int size ); - unsigned int HashString( const char *pszToken ); -}; - - -class CSave : public CSaveRestoreBuffer -{ -public: - CSave( SAVERESTOREDATA *pdata ) : CSaveRestoreBuffer( pdata ) {}; - - void WriteShort( const char *pname, const short *value, int count ); - void WriteInt( const char *pname, const int *value, int count ); // Save an int - void WriteFloat( const char *pname, const float *value, int count ); // Save a float - void WriteTime( const char *pname, const float *value, int count ); // Save a float (timevalue) - void WriteData( const char *pname, int size, const char *pdata ); // Save a binary data block - void WriteString( const char *pname, const char *pstring ); // Save a null-terminated string - void WriteString( const char *pname, const int *stringId, int count ); // Save a null-terminated string (engine string) - void WriteVector( const char *pname, const Vector &value ); // Save a vector - void WriteVector( const char *pname, const float *value, int count ); // Save a vector - void WritePositionVector( const char *pname, const Vector &value ); // Offset for landmark if necessary - void WritePositionVector( const char *pname, const float *value, int count ); // array of pos vectors - void WriteFunction( const char *pname, void **value, int count ); // Save a function pointer - int WriteEntVars( const char *pname, entvars_t *pev ); // Save entvars_t (entvars_t) - int WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); - -private: - int DataEmpty( const char *pdata, int size ); - void BufferField( const char *pname, int size, const char *pdata ); - void BufferString( char *pdata, int len ); - void BufferData( const char *pdata, int size ); - void BufferHeader( const char *pname, int size ); -}; - -typedef struct -{ - unsigned short size; - unsigned short token; - char *pData; -} HEADER; - -class CRestore : public CSaveRestoreBuffer -{ -public: - CRestore( SAVERESTOREDATA *pdata ) : CSaveRestoreBuffer( pdata ) { m_global = 0; m_precache = TRUE; } - int ReadEntVars( const char *pname, entvars_t *pev ); // entvars_t - int ReadFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); - int ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount, int startField, int size, char *pName, void *pData ); - int ReadInt( void ); - short ReadShort( void ); - int ReadNamedInt( const char *pName ); - char *ReadNamedString( const char *pName ); - int Empty( void ) { return (m_pdata == NULL) || ((m_pdata->pCurrentData-m_pdata->pBaseData)>=m_pdata->bufferSize); } - inline void SetGlobalMode( int global ) { m_global = global; } - void PrecacheMode( BOOL mode ) { m_precache = mode; } - -private: - char *BufferPointer( void ); - void BufferReadBytes( char *pOutput, int size ); - void BufferSkipBytes( int bytes ); - int BufferSkipZString( void ); - int BufferCheckZString( const char *string ); - - void BufferReadHeader( HEADER *pheader ); - - int m_global; // Restoring a global entity? - BOOL m_precache; -}; - -#define MAX_ENTITYARRAY 64 - -//#define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) - -#define IMPLEMENT_SAVERESTORE(derivedClass,baseClass) \ - int derivedClass::Save( CSave &save )\ - {\ - if ( !baseClass::Save(save) )\ - return 0;\ - return save.WriteFields( #derivedClass, this, m_SaveData, ARRAYSIZE(m_SaveData) );\ - }\ - int derivedClass::Restore( CRestore &restore )\ - {\ - if ( !baseClass::Restore(restore) )\ - return 0;\ - return restore.ReadFields( #derivedClass, this, m_SaveData, ARRAYSIZE(m_SaveData) );\ - } - - -typedef enum { GLOBAL_OFF = 0, GLOBAL_ON = 1, GLOBAL_DEAD = 2 } GLOBALESTATE; - -typedef struct globalentity_s globalentity_t; - -struct globalentity_s -{ - char name[64]; - char levelName[32]; - GLOBALESTATE state; - globalentity_t *pNext; -}; - -class CGlobalState -{ -public: - CGlobalState(); - void Reset( void ); - void ClearStates( void ); - void EntityAdd( string_t globalname, string_t mapName, GLOBALESTATE state ); - void EntitySetState( string_t globalname, GLOBALESTATE state ); - void EntityUpdate( string_t globalname, string_t mapname ); - const globalentity_t *EntityFromTable( string_t globalname ); - GLOBALESTATE EntityGetState( string_t globalname ); - int EntityInTable( string_t globalname ) { return (Find( globalname ) != NULL) ? 1 : 0; } - int Save( CSave &save ); - int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; - -//#ifdef _DEBUG - void DumpGlobals( void ); -//#endif - -private: - globalentity_t *Find( string_t globalname ); - globalentity_t *m_pList; - int m_listCount; -}; - -extern CGlobalState gGlobalState; - -#endif //SAVERESTORE_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +// Implementation in UTIL.CPP +#ifndef SAVERESTORE_H +#define SAVERESTORE_H + +class CBaseEntity; + +class CSaveRestoreBuffer +{ +public: + CSaveRestoreBuffer( void ); + CSaveRestoreBuffer( SAVERESTOREDATA *pdata ); + ~CSaveRestoreBuffer( void ); + + int EntityIndex( entvars_t *pevLookup ); + int EntityIndex( edict_t *pentLookup ); + int EntityIndex( EOFFSET eoLookup ); + int EntityIndex( CBaseEntity *pEntity ); + + int EntityFlags( int entityIndex, int flags ) { return EntityFlagsSet( entityIndex, 0 ); } + int EntityFlagsSet( int entityIndex, int flags ); + + edict_t *EntityFromIndex( int entityIndex ); + + unsigned short TokenHash( const char *pszToken ); + +protected: + SAVERESTOREDATA *m_pdata; + void BufferRewind( int size ); + unsigned int HashString( const char *pszToken ); +}; + + +class CSave : public CSaveRestoreBuffer +{ +public: + CSave( SAVERESTOREDATA *pdata ) : CSaveRestoreBuffer( pdata ) {}; + + void WriteShort( const char *pname, const short *value, int count ); + void WriteInt( const char *pname, const int *value, int count ); // Save an int + void WriteFloat( const char *pname, const float *value, int count ); // Save a float + void WriteTime( const char *pname, const float *value, int count ); // Save a float (timevalue) + void WriteData( const char *pname, int size, const char *pdata ); // Save a binary data block + void WriteString( const char *pname, const char *pstring ); // Save a null-terminated string + void WriteString( const char *pname, const int *stringId, int count ); // Save a null-terminated string (engine string) + void WriteVector( const char *pname, const Vector &value ); // Save a vector + void WriteVector( const char *pname, const float *value, int count ); // Save a vector + void WritePositionVector( const char *pname, const Vector &value ); // Offset for landmark if necessary + void WritePositionVector( const char *pname, const float *value, int count ); // array of pos vectors + void WriteFunction( const char *pname, void **value, int count ); // Save a function pointer + int WriteEntVars( const char *pname, entvars_t *pev ); // Save entvars_t (entvars_t) + int WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); + +private: + int DataEmpty( const char *pdata, int size ); + void BufferField( const char *pname, int size, const char *pdata ); + void BufferString( char *pdata, int len ); + void BufferData( const char *pdata, int size ); + void BufferHeader( const char *pname, int size ); +}; + +typedef struct +{ + unsigned short size; + unsigned short token; + char *pData; +} HEADER; + +class CRestore : public CSaveRestoreBuffer +{ +public: + CRestore( SAVERESTOREDATA *pdata ) : CSaveRestoreBuffer( pdata ) { m_global = 0; m_precache = TRUE; } + int ReadEntVars( const char *pname, entvars_t *pev ); // entvars_t + int ReadFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); + int ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount, int startField, int size, char *pName, void *pData ); + int ReadInt( void ); + short ReadShort( void ); + int ReadNamedInt( const char *pName ); + char *ReadNamedString( const char *pName ); + int Empty( void ) { return (m_pdata == NULL) || ((m_pdata->pCurrentData-m_pdata->pBaseData)>=m_pdata->bufferSize); } + inline void SetGlobalMode( int global ) { m_global = global; } + void PrecacheMode( BOOL mode ) { m_precache = mode; } + +private: + char *BufferPointer( void ); + void BufferReadBytes( char *pOutput, int size ); + void BufferSkipBytes( int bytes ); + int BufferSkipZString( void ); + int BufferCheckZString( const char *string ); + + void BufferReadHeader( HEADER *pheader ); + + int m_global; // Restoring a global entity? + BOOL m_precache; +}; + +#define MAX_ENTITYARRAY 64 + +//#define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) + +#define IMPLEMENT_SAVERESTORE(derivedClass,baseClass) \ + int derivedClass::Save( CSave &save )\ + {\ + if ( !baseClass::Save(save) )\ + return 0;\ + return save.WriteFields( #derivedClass, this, m_SaveData, ARRAYSIZE(m_SaveData) );\ + }\ + int derivedClass::Restore( CRestore &restore )\ + {\ + if ( !baseClass::Restore(restore) )\ + return 0;\ + return restore.ReadFields( #derivedClass, this, m_SaveData, ARRAYSIZE(m_SaveData) );\ + } + + +typedef enum { GLOBAL_OFF = 0, GLOBAL_ON = 1, GLOBAL_DEAD = 2 } GLOBALESTATE; + +typedef struct globalentity_s globalentity_t; + +struct globalentity_s +{ + char name[64]; + char levelName[32]; + GLOBALESTATE state; + globalentity_t *pNext; +}; + +class CGlobalState +{ +public: + CGlobalState(); + void Reset( void ); + void ClearStates( void ); + void EntityAdd( string_t globalname, string_t mapName, GLOBALESTATE state ); + void EntitySetState( string_t globalname, GLOBALESTATE state ); + void EntityUpdate( string_t globalname, string_t mapname ); + const globalentity_t *EntityFromTable( string_t globalname ); + GLOBALESTATE EntityGetState( string_t globalname ); + int EntityInTable( string_t globalname ) { return (Find( globalname ) != NULL) ? 1 : 0; } + int Save( CSave &save ); + int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; + +//#ifdef _DEBUG + void DumpGlobals( void ); +//#endif + +private: + globalentity_t *Find( string_t globalname ); + globalentity_t *m_pList; + int m_listCount; +}; + +extern CGlobalState gGlobalState; + +#endif //SAVERESTORE_H diff --git a/dep/rehlsdk/dlls/schedule.h b/dep/rehlsdk/dlls/schedule.h index 7d9ff17..0c09441 100644 --- a/dep/rehlsdk/dlls/schedule.h +++ b/dep/rehlsdk/dlls/schedule.h @@ -1,290 +1,290 @@ -/*** -* -* Copyright (c) 1996-2001, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* This source code contains proprietary and confidential information of -* Valve LLC and its suppliers. Access to this code is restricted to -* persons who have executed a written SDK license with Valve. Any access, -* use or distribution of this code by or to any unlicensed person is illegal. -* -****/ -//========================================================= -// Scheduling -//========================================================= - -#ifndef SCHEDULE_H -#define SCHEDULE_H - -#define TASKSTATUS_NEW 0 // Just started -#define TASKSTATUS_RUNNING 1 // Running task & movement -#define TASKSTATUS_RUNNING_MOVEMENT 2 // Just running movement -#define TASKSTATUS_RUNNING_TASK 3 // Just running task -#define TASKSTATUS_COMPLETE 4 // Completed, get next task - - -//========================================================= -// These are the schedule types -//========================================================= -typedef enum -{ - SCHED_NONE = 0, - SCHED_IDLE_STAND, - SCHED_IDLE_WALK, - SCHED_WAKE_ANGRY, - SCHED_WAKE_CALLED, - SCHED_ALERT_FACE, - SCHED_ALERT_SMALL_FLINCH, - SCHED_ALERT_BIG_FLINCH, - SCHED_ALERT_STAND, - SCHED_INVESTIGATE_SOUND, - SCHED_COMBAT_FACE, - SCHED_COMBAT_STAND, - SCHED_CHASE_ENEMY, - SCHED_CHASE_ENEMY_FAILED, - SCHED_VICTORY_DANCE, - SCHED_TARGET_FACE, - SCHED_TARGET_CHASE, - SCHED_SMALL_FLINCH, - SCHED_TAKE_COVER_FROM_ENEMY, - SCHED_TAKE_COVER_FROM_BEST_SOUND, - SCHED_TAKE_COVER_FROM_ORIGIN, - SCHED_COWER, // usually a last resort! - SCHED_MELEE_ATTACK1, - SCHED_MELEE_ATTACK2, - SCHED_RANGE_ATTACK1, - SCHED_RANGE_ATTACK2, - SCHED_SPECIAL_ATTACK1, - SCHED_SPECIAL_ATTACK2, - SCHED_STANDOFF, - SCHED_ARM_WEAPON, - SCHED_RELOAD, - SCHED_GUARD, - SCHED_AMBUSH, - SCHED_DIE, - SCHED_WAIT_TRIGGER, - SCHED_FOLLOW, - SCHED_SLEEP, - SCHED_WAKE, - SCHED_BARNACLE_VICTIM_GRAB, - SCHED_BARNACLE_VICTIM_CHOMP, - SCHED_AISCRIPT, - SCHED_FAIL, - - LAST_COMMON_SCHEDULE // Leave this at the bottom -} SCHEDULE_TYPE; - -//========================================================= -// These are the shared tasks -//========================================================= -typedef enum -{ - TASK_INVALID = 0, - TASK_WAIT, - TASK_WAIT_FACE_ENEMY, - TASK_WAIT_PVS, - TASK_SUGGEST_STATE, - TASK_WALK_TO_TARGET, - TASK_RUN_TO_TARGET, - TASK_MOVE_TO_TARGET_RANGE, - TASK_GET_PATH_TO_ENEMY, - TASK_GET_PATH_TO_ENEMY_LKP, - TASK_GET_PATH_TO_ENEMY_CORPSE, - TASK_GET_PATH_TO_LEADER, - TASK_GET_PATH_TO_SPOT, - TASK_GET_PATH_TO_TARGET, - TASK_GET_PATH_TO_HINTNODE, - TASK_GET_PATH_TO_LASTPOSITION, - TASK_GET_PATH_TO_BESTSOUND, - TASK_GET_PATH_TO_BESTSCENT, - TASK_RUN_PATH, - TASK_WALK_PATH, - TASK_STRAFE_PATH, - TASK_CLEAR_MOVE_WAIT, - TASK_STORE_LASTPOSITION, - TASK_CLEAR_LASTPOSITION, - TASK_PLAY_ACTIVE_IDLE, - TASK_FIND_HINTNODE, - TASK_CLEAR_HINTNODE, - TASK_SMALL_FLINCH, - TASK_FACE_IDEAL, - TASK_FACE_ROUTE, - TASK_FACE_ENEMY, - TASK_FACE_HINTNODE, - TASK_FACE_TARGET, - TASK_FACE_LASTPOSITION, - TASK_RANGE_ATTACK1, - TASK_RANGE_ATTACK2, - TASK_MELEE_ATTACK1, - TASK_MELEE_ATTACK2, - TASK_RELOAD, - TASK_RANGE_ATTACK1_NOTURN, - TASK_RANGE_ATTACK2_NOTURN, - TASK_MELEE_ATTACK1_NOTURN, - TASK_MELEE_ATTACK2_NOTURN, - TASK_RELOAD_NOTURN, - TASK_SPECIAL_ATTACK1, - TASK_SPECIAL_ATTACK2, - TASK_CROUCH, - TASK_STAND, - TASK_GUARD, - TASK_STEP_LEFT, - TASK_STEP_RIGHT, - TASK_STEP_FORWARD, - TASK_STEP_BACK, - TASK_DODGE_LEFT, - TASK_DODGE_RIGHT, - TASK_SOUND_ANGRY, - TASK_SOUND_DEATH, - TASK_SET_ACTIVITY, - TASK_SET_SCHEDULE, - TASK_SET_FAIL_SCHEDULE, - TASK_CLEAR_FAIL_SCHEDULE, - TASK_PLAY_SEQUENCE, - TASK_PLAY_SEQUENCE_FACE_ENEMY, - TASK_PLAY_SEQUENCE_FACE_TARGET, - TASK_SOUND_IDLE, - TASK_SOUND_WAKE, - TASK_SOUND_PAIN, - TASK_SOUND_DIE, - TASK_FIND_COVER_FROM_BEST_SOUND,// tries lateral cover first, then node cover - TASK_FIND_COVER_FROM_ENEMY,// tries lateral cover first, then node cover - TASK_FIND_LATERAL_COVER_FROM_ENEMY, - TASK_FIND_NODE_COVER_FROM_ENEMY, - TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY,// data for this one is the MAXIMUM acceptable distance to the cover. - TASK_FIND_FAR_NODE_COVER_FROM_ENEMY,// data for this one is there MINIMUM aceptable distance to the cover. - TASK_FIND_COVER_FROM_ORIGIN, - TASK_EAT, - TASK_DIE, - TASK_WAIT_FOR_SCRIPT, - TASK_PLAY_SCRIPT, - TASK_ENABLE_SCRIPT, - TASK_PLANT_ON_SCRIPT, - TASK_FACE_SCRIPT, - TASK_WAIT_RANDOM, - TASK_WAIT_INDEFINITE, - TASK_STOP_MOVING, - TASK_TURN_LEFT, - TASK_TURN_RIGHT, - TASK_REMEMBER, - TASK_FORGET, - TASK_WAIT_FOR_MOVEMENT, // wait until MovementIsComplete() - LAST_COMMON_TASK, // LEAVE THIS AT THE BOTTOM!! (sjb) -} SHARED_TASKS; - - -// These go in the flData member of the TASK_WALK_TO_TARGET, TASK_RUN_TO_TARGET -enum -{ - TARGET_MOVE_NORMAL = 0, - TARGET_MOVE_SCRIPTED = 1, -}; - - -// A goal should be used for a task that requires several schedules to complete. -// The goal index should indicate which schedule (ordinally) the monster is running. -// That way, when tasks fail, the AI can make decisions based on the context of the -// current goal and sequence rather than just the current schedule. -enum -{ - GOAL_ATTACK_ENEMY, - GOAL_MOVE, - GOAL_TAKE_COVER, - GOAL_MOVE_TARGET, - GOAL_EAT, -}; - -// an array of tasks is a task list -// an array of schedules is a schedule list -struct Task_t -{ - - int iTask; - float flData; -}; - -struct Schedule_t -{ - - Task_t *pTasklist; - int cTasks; - int iInterruptMask;// a bit mask of conditions that can interrupt this schedule - - // a more specific mask that indicates which TYPES of sounds will interrupt the schedule in the - // event that the schedule is broken by COND_HEAR_SOUND - int iSoundMask; - const char *pName; -}; - -// an array of waypoints makes up the monster's route. -// !!!LATER- this declaration doesn't belong in this file. -struct WayPoint_t -{ - Vector vecLocation; - int iType; -}; - -// these MoveFlag values are assigned to a WayPoint's TYPE in order to demonstrate the -// type of movement the monster should use to get there. -#define bits_MF_TO_TARGETENT ( 1 << 0 ) // local move to targetent. -#define bits_MF_TO_ENEMY ( 1 << 1 ) // local move to enemy -#define bits_MF_TO_COVER ( 1 << 2 ) // local move to a hiding place -#define bits_MF_TO_DETOUR ( 1 << 3 ) // local move to detour point. -#define bits_MF_TO_PATHCORNER ( 1 << 4 ) // local move to a path corner -#define bits_MF_TO_NODE ( 1 << 5 ) // local move to a node -#define bits_MF_TO_LOCATION ( 1 << 6 ) // local move to an arbitrary point -#define bits_MF_IS_GOAL ( 1 << 7 ) // this waypoint is the goal of the whole move. -#define bits_MF_DONT_SIMPLIFY ( 1 << 8 ) // Don't let the route code simplify this waypoint - -// If you define any flags that aren't _TO_ flags, add them here so we can mask -// them off when doing compares. -#define bits_MF_NOT_TO_MASK (bits_MF_IS_GOAL | bits_MF_DONT_SIMPLIFY) - -#define MOVEGOAL_NONE (0) -#define MOVEGOAL_TARGETENT (bits_MF_TO_TARGETENT) -#define MOVEGOAL_ENEMY (bits_MF_TO_ENEMY) -#define MOVEGOAL_PATHCORNER (bits_MF_TO_PATHCORNER) -#define MOVEGOAL_LOCATION (bits_MF_TO_LOCATION) -#define MOVEGOAL_NODE (bits_MF_TO_NODE) - -// these bits represent conditions that may befall the monster, of which some are allowed -// to interrupt certain schedules. -#define bits_COND_NO_AMMO_LOADED ( 1 << 0 ) // weapon needs to be reloaded! -#define bits_COND_SEE_HATE ( 1 << 1 ) // see something that you hate -#define bits_COND_SEE_FEAR ( 1 << 2 ) // see something that you are afraid of -#define bits_COND_SEE_DISLIKE ( 1 << 3 ) // see something that you dislike -#define bits_COND_SEE_ENEMY ( 1 << 4 ) // target entity is in full view. -#define bits_COND_ENEMY_OCCLUDED ( 1 << 5 ) // target entity occluded by the world -#define bits_COND_SMELL_FOOD ( 1 << 6 ) -#define bits_COND_ENEMY_TOOFAR ( 1 << 7 ) -#define bits_COND_LIGHT_DAMAGE ( 1 << 8 ) // hurt a little -#define bits_COND_HEAVY_DAMAGE ( 1 << 9 ) // hurt a lot -#define bits_COND_CAN_RANGE_ATTACK1 ( 1 << 10) -#define bits_COND_CAN_MELEE_ATTACK1 ( 1 << 11) -#define bits_COND_CAN_RANGE_ATTACK2 ( 1 << 12) -#define bits_COND_CAN_MELEE_ATTACK2 ( 1 << 13) -// #define bits_COND_CAN_RANGE_ATTACK3 ( 1 << 14) -#define bits_COND_PROVOKED ( 1 << 15) -#define bits_COND_NEW_ENEMY ( 1 << 16) -#define bits_COND_HEAR_SOUND ( 1 << 17) // there is an interesting sound -#define bits_COND_SMELL ( 1 << 18) // there is an interesting scent -#define bits_COND_ENEMY_FACING_ME ( 1 << 19) // enemy is facing me -#define bits_COND_ENEMY_DEAD ( 1 << 20) // enemy was killed. If you get this in combat, try to find another enemy. If you get it in alert, victory dance. -#define bits_COND_SEE_CLIENT ( 1 << 21) // see a client -#define bits_COND_SEE_NEMESIS ( 1 << 22) // see my nemesis - -#define bits_COND_SPECIAL1 ( 1 << 28) // Defined by individual monster -#define bits_COND_SPECIAL2 ( 1 << 29) // Defined by individual monster - -#define bits_COND_TASK_FAILED ( 1 << 30) -#define bits_COND_SCHEDULE_DONE ( 1 << 31) - - -#define bits_COND_ALL_SPECIAL (bits_COND_SPECIAL1 | bits_COND_SPECIAL2) - -#define bits_COND_CAN_ATTACK (bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK2 | bits_COND_CAN_MELEE_ATTACK2) - -#endif // SCHEDULE_H +/*** +* +* Copyright (c) 1996-2001, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* This source code contains proprietary and confidential information of +* Valve LLC and its suppliers. Access to this code is restricted to +* persons who have executed a written SDK license with Valve. Any access, +* use or distribution of this code by or to any unlicensed person is illegal. +* +****/ +//========================================================= +// Scheduling +//========================================================= + +#ifndef SCHEDULE_H +#define SCHEDULE_H + +#define TASKSTATUS_NEW 0 // Just started +#define TASKSTATUS_RUNNING 1 // Running task & movement +#define TASKSTATUS_RUNNING_MOVEMENT 2 // Just running movement +#define TASKSTATUS_RUNNING_TASK 3 // Just running task +#define TASKSTATUS_COMPLETE 4 // Completed, get next task + + +//========================================================= +// These are the schedule types +//========================================================= +typedef enum +{ + SCHED_NONE = 0, + SCHED_IDLE_STAND, + SCHED_IDLE_WALK, + SCHED_WAKE_ANGRY, + SCHED_WAKE_CALLED, + SCHED_ALERT_FACE, + SCHED_ALERT_SMALL_FLINCH, + SCHED_ALERT_BIG_FLINCH, + SCHED_ALERT_STAND, + SCHED_INVESTIGATE_SOUND, + SCHED_COMBAT_FACE, + SCHED_COMBAT_STAND, + SCHED_CHASE_ENEMY, + SCHED_CHASE_ENEMY_FAILED, + SCHED_VICTORY_DANCE, + SCHED_TARGET_FACE, + SCHED_TARGET_CHASE, + SCHED_SMALL_FLINCH, + SCHED_TAKE_COVER_FROM_ENEMY, + SCHED_TAKE_COVER_FROM_BEST_SOUND, + SCHED_TAKE_COVER_FROM_ORIGIN, + SCHED_COWER, // usually a last resort! + SCHED_MELEE_ATTACK1, + SCHED_MELEE_ATTACK2, + SCHED_RANGE_ATTACK1, + SCHED_RANGE_ATTACK2, + SCHED_SPECIAL_ATTACK1, + SCHED_SPECIAL_ATTACK2, + SCHED_STANDOFF, + SCHED_ARM_WEAPON, + SCHED_RELOAD, + SCHED_GUARD, + SCHED_AMBUSH, + SCHED_DIE, + SCHED_WAIT_TRIGGER, + SCHED_FOLLOW, + SCHED_SLEEP, + SCHED_WAKE, + SCHED_BARNACLE_VICTIM_GRAB, + SCHED_BARNACLE_VICTIM_CHOMP, + SCHED_AISCRIPT, + SCHED_FAIL, + + LAST_COMMON_SCHEDULE // Leave this at the bottom +} SCHEDULE_TYPE; + +//========================================================= +// These are the shared tasks +//========================================================= +typedef enum +{ + TASK_INVALID = 0, + TASK_WAIT, + TASK_WAIT_FACE_ENEMY, + TASK_WAIT_PVS, + TASK_SUGGEST_STATE, + TASK_WALK_TO_TARGET, + TASK_RUN_TO_TARGET, + TASK_MOVE_TO_TARGET_RANGE, + TASK_GET_PATH_TO_ENEMY, + TASK_GET_PATH_TO_ENEMY_LKP, + TASK_GET_PATH_TO_ENEMY_CORPSE, + TASK_GET_PATH_TO_LEADER, + TASK_GET_PATH_TO_SPOT, + TASK_GET_PATH_TO_TARGET, + TASK_GET_PATH_TO_HINTNODE, + TASK_GET_PATH_TO_LASTPOSITION, + TASK_GET_PATH_TO_BESTSOUND, + TASK_GET_PATH_TO_BESTSCENT, + TASK_RUN_PATH, + TASK_WALK_PATH, + TASK_STRAFE_PATH, + TASK_CLEAR_MOVE_WAIT, + TASK_STORE_LASTPOSITION, + TASK_CLEAR_LASTPOSITION, + TASK_PLAY_ACTIVE_IDLE, + TASK_FIND_HINTNODE, + TASK_CLEAR_HINTNODE, + TASK_SMALL_FLINCH, + TASK_FACE_IDEAL, + TASK_FACE_ROUTE, + TASK_FACE_ENEMY, + TASK_FACE_HINTNODE, + TASK_FACE_TARGET, + TASK_FACE_LASTPOSITION, + TASK_RANGE_ATTACK1, + TASK_RANGE_ATTACK2, + TASK_MELEE_ATTACK1, + TASK_MELEE_ATTACK2, + TASK_RELOAD, + TASK_RANGE_ATTACK1_NOTURN, + TASK_RANGE_ATTACK2_NOTURN, + TASK_MELEE_ATTACK1_NOTURN, + TASK_MELEE_ATTACK2_NOTURN, + TASK_RELOAD_NOTURN, + TASK_SPECIAL_ATTACK1, + TASK_SPECIAL_ATTACK2, + TASK_CROUCH, + TASK_STAND, + TASK_GUARD, + TASK_STEP_LEFT, + TASK_STEP_RIGHT, + TASK_STEP_FORWARD, + TASK_STEP_BACK, + TASK_DODGE_LEFT, + TASK_DODGE_RIGHT, + TASK_SOUND_ANGRY, + TASK_SOUND_DEATH, + TASK_SET_ACTIVITY, + TASK_SET_SCHEDULE, + TASK_SET_FAIL_SCHEDULE, + TASK_CLEAR_FAIL_SCHEDULE, + TASK_PLAY_SEQUENCE, + TASK_PLAY_SEQUENCE_FACE_ENEMY, + TASK_PLAY_SEQUENCE_FACE_TARGET, + TASK_SOUND_IDLE, + TASK_SOUND_WAKE, + TASK_SOUND_PAIN, + TASK_SOUND_DIE, + TASK_FIND_COVER_FROM_BEST_SOUND,// tries lateral cover first, then node cover + TASK_FIND_COVER_FROM_ENEMY,// tries lateral cover first, then node cover + TASK_FIND_LATERAL_COVER_FROM_ENEMY, + TASK_FIND_NODE_COVER_FROM_ENEMY, + TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY,// data for this one is the MAXIMUM acceptable distance to the cover. + TASK_FIND_FAR_NODE_COVER_FROM_ENEMY,// data for this one is there MINIMUM aceptable distance to the cover. + TASK_FIND_COVER_FROM_ORIGIN, + TASK_EAT, + TASK_DIE, + TASK_WAIT_FOR_SCRIPT, + TASK_PLAY_SCRIPT, + TASK_ENABLE_SCRIPT, + TASK_PLANT_ON_SCRIPT, + TASK_FACE_SCRIPT, + TASK_WAIT_RANDOM, + TASK_WAIT_INDEFINITE, + TASK_STOP_MOVING, + TASK_TURN_LEFT, + TASK_TURN_RIGHT, + TASK_REMEMBER, + TASK_FORGET, + TASK_WAIT_FOR_MOVEMENT, // wait until MovementIsComplete() + LAST_COMMON_TASK, // LEAVE THIS AT THE BOTTOM!! (sjb) +} SHARED_TASKS; + + +// These go in the flData member of the TASK_WALK_TO_TARGET, TASK_RUN_TO_TARGET +enum +{ + TARGET_MOVE_NORMAL = 0, + TARGET_MOVE_SCRIPTED = 1, +}; + + +// A goal should be used for a task that requires several schedules to complete. +// The goal index should indicate which schedule (ordinally) the monster is running. +// That way, when tasks fail, the AI can make decisions based on the context of the +// current goal and sequence rather than just the current schedule. +enum +{ + GOAL_ATTACK_ENEMY, + GOAL_MOVE, + GOAL_TAKE_COVER, + GOAL_MOVE_TARGET, + GOAL_EAT, +}; + +// an array of tasks is a task list +// an array of schedules is a schedule list +struct Task_t +{ + + int iTask; + float flData; +}; + +struct Schedule_t +{ + + Task_t *pTasklist; + int cTasks; + int iInterruptMask;// a bit mask of conditions that can interrupt this schedule + + // a more specific mask that indicates which TYPES of sounds will interrupt the schedule in the + // event that the schedule is broken by COND_HEAR_SOUND + int iSoundMask; + const char *pName; +}; + +// an array of waypoints makes up the monster's route. +// !!!LATER- this declaration doesn't belong in this file. +struct WayPoint_t +{ + Vector vecLocation; + int iType; +}; + +// these MoveFlag values are assigned to a WayPoint's TYPE in order to demonstrate the +// type of movement the monster should use to get there. +#define bits_MF_TO_TARGETENT ( 1 << 0 ) // local move to targetent. +#define bits_MF_TO_ENEMY ( 1 << 1 ) // local move to enemy +#define bits_MF_TO_COVER ( 1 << 2 ) // local move to a hiding place +#define bits_MF_TO_DETOUR ( 1 << 3 ) // local move to detour point. +#define bits_MF_TO_PATHCORNER ( 1 << 4 ) // local move to a path corner +#define bits_MF_TO_NODE ( 1 << 5 ) // local move to a node +#define bits_MF_TO_LOCATION ( 1 << 6 ) // local move to an arbitrary point +#define bits_MF_IS_GOAL ( 1 << 7 ) // this waypoint is the goal of the whole move. +#define bits_MF_DONT_SIMPLIFY ( 1 << 8 ) // Don't let the route code simplify this waypoint + +// If you define any flags that aren't _TO_ flags, add them here so we can mask +// them off when doing compares. +#define bits_MF_NOT_TO_MASK (bits_MF_IS_GOAL | bits_MF_DONT_SIMPLIFY) + +#define MOVEGOAL_NONE (0) +#define MOVEGOAL_TARGETENT (bits_MF_TO_TARGETENT) +#define MOVEGOAL_ENEMY (bits_MF_TO_ENEMY) +#define MOVEGOAL_PATHCORNER (bits_MF_TO_PATHCORNER) +#define MOVEGOAL_LOCATION (bits_MF_TO_LOCATION) +#define MOVEGOAL_NODE (bits_MF_TO_NODE) + +// these bits represent conditions that may befall the monster, of which some are allowed +// to interrupt certain schedules. +#define bits_COND_NO_AMMO_LOADED ( 1 << 0 ) // weapon needs to be reloaded! +#define bits_COND_SEE_HATE ( 1 << 1 ) // see something that you hate +#define bits_COND_SEE_FEAR ( 1 << 2 ) // see something that you are afraid of +#define bits_COND_SEE_DISLIKE ( 1 << 3 ) // see something that you dislike +#define bits_COND_SEE_ENEMY ( 1 << 4 ) // target entity is in full view. +#define bits_COND_ENEMY_OCCLUDED ( 1 << 5 ) // target entity occluded by the world +#define bits_COND_SMELL_FOOD ( 1 << 6 ) +#define bits_COND_ENEMY_TOOFAR ( 1 << 7 ) +#define bits_COND_LIGHT_DAMAGE ( 1 << 8 ) // hurt a little +#define bits_COND_HEAVY_DAMAGE ( 1 << 9 ) // hurt a lot +#define bits_COND_CAN_RANGE_ATTACK1 ( 1 << 10) +#define bits_COND_CAN_MELEE_ATTACK1 ( 1 << 11) +#define bits_COND_CAN_RANGE_ATTACK2 ( 1 << 12) +#define bits_COND_CAN_MELEE_ATTACK2 ( 1 << 13) +// #define bits_COND_CAN_RANGE_ATTACK3 ( 1 << 14) +#define bits_COND_PROVOKED ( 1 << 15) +#define bits_COND_NEW_ENEMY ( 1 << 16) +#define bits_COND_HEAR_SOUND ( 1 << 17) // there is an interesting sound +#define bits_COND_SMELL ( 1 << 18) // there is an interesting scent +#define bits_COND_ENEMY_FACING_ME ( 1 << 19) // enemy is facing me +#define bits_COND_ENEMY_DEAD ( 1 << 20) // enemy was killed. If you get this in combat, try to find another enemy. If you get it in alert, victory dance. +#define bits_COND_SEE_CLIENT ( 1 << 21) // see a client +#define bits_COND_SEE_NEMESIS ( 1 << 22) // see my nemesis + +#define bits_COND_SPECIAL1 ( 1 << 28) // Defined by individual monster +#define bits_COND_SPECIAL2 ( 1 << 29) // Defined by individual monster + +#define bits_COND_TASK_FAILED ( 1 << 30) +#define bits_COND_SCHEDULE_DONE ( 1 << 31) + + +#define bits_COND_ALL_SPECIAL (bits_COND_SPECIAL1 | bits_COND_SPECIAL2) + +#define bits_COND_CAN_ATTACK (bits_COND_CAN_RANGE_ATTACK1 | bits_COND_CAN_MELEE_ATTACK1 | bits_COND_CAN_RANGE_ATTACK2 | bits_COND_CAN_MELEE_ATTACK2) + +#endif // SCHEDULE_H diff --git a/dep/rehlsdk/dlls/scriptevent.h b/dep/rehlsdk/dlls/scriptevent.h index 9a02bd6..42377cf 100644 --- a/dep/rehlsdk/dlls/scriptevent.h +++ b/dep/rehlsdk/dlls/scriptevent.h @@ -1,29 +1,29 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef SCRIPTEVENT_H -#define SCRIPTEVENT_H - -#define SCRIPT_EVENT_DEAD 1000 // character is now dead -#define SCRIPT_EVENT_NOINTERRUPT 1001 // does not allow interrupt -#define SCRIPT_EVENT_CANINTERRUPT 1002 // will allow interrupt -#define SCRIPT_EVENT_FIREEVENT 1003 // event now fires -#define SCRIPT_EVENT_SOUND 1004 // Play named wave file (on CHAN_BODY) -#define SCRIPT_EVENT_SENTENCE 1005 // Play named sentence -#define SCRIPT_EVENT_INAIR 1006 // Leave the character in air at the end of the sequence (don't find the floor) -#define SCRIPT_EVENT_ENDANIMATION 1007 // Set the animation by name after the sequence completes -#define SCRIPT_EVENT_SOUND_VOICE 1008 // Play named wave file (on CHAN_VOICE) -#define SCRIPT_EVENT_SENTENCE_RND1 1009 // Play sentence group 25% of the time -#define SCRIPT_EVENT_NOT_DEAD 1010 // Bring back to life (for life/death sequences) -#endif //SCRIPTEVENT_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef SCRIPTEVENT_H +#define SCRIPTEVENT_H + +#define SCRIPT_EVENT_DEAD 1000 // character is now dead +#define SCRIPT_EVENT_NOINTERRUPT 1001 // does not allow interrupt +#define SCRIPT_EVENT_CANINTERRUPT 1002 // will allow interrupt +#define SCRIPT_EVENT_FIREEVENT 1003 // event now fires +#define SCRIPT_EVENT_SOUND 1004 // Play named wave file (on CHAN_BODY) +#define SCRIPT_EVENT_SENTENCE 1005 // Play named sentence +#define SCRIPT_EVENT_INAIR 1006 // Leave the character in air at the end of the sequence (don't find the floor) +#define SCRIPT_EVENT_ENDANIMATION 1007 // Set the animation by name after the sequence completes +#define SCRIPT_EVENT_SOUND_VOICE 1008 // Play named wave file (on CHAN_VOICE) +#define SCRIPT_EVENT_SENTENCE_RND1 1009 // Play sentence group 25% of the time +#define SCRIPT_EVENT_NOT_DEAD 1010 // Bring back to life (for life/death sequences) +#endif //SCRIPTEVENT_H diff --git a/dep/rehlsdk/dlls/skill.h b/dep/rehlsdk/dlls/skill.h index 4434071..5ec320c 100644 --- a/dep/rehlsdk/dlls/skill.h +++ b/dep/rehlsdk/dlls/skill.h @@ -1,147 +1,147 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -//========================================================= -// skill.h - skill level concerns -//========================================================= - -struct skilldata_t -{ - - int iSkillLevel; // game skill level - -// Monster Health & Damage - float agruntHealth; - float agruntDmgPunch; - - float apacheHealth; - - float barneyHealth; - - float bigmommaHealthFactor; // Multiply each node's health by this - float bigmommaDmgSlash; // melee attack damage - float bigmommaDmgBlast; // mortar attack damage - float bigmommaRadiusBlast; // mortar attack radius - - float bullsquidHealth; - float bullsquidDmgBite; - float bullsquidDmgWhip; - float bullsquidDmgSpit; - - float gargantuaHealth; - float gargantuaDmgSlash; - float gargantuaDmgFire; - float gargantuaDmgStomp; - - float hassassinHealth; - - float headcrabHealth; - float headcrabDmgBite; - - float hgruntHealth; - float hgruntDmgKick; - float hgruntShotgunPellets; - float hgruntGrenadeSpeed; - - float houndeyeHealth; - float houndeyeDmgBlast; - - float slaveHealth; - float slaveDmgClaw; - float slaveDmgClawrake; - float slaveDmgZap; - - float ichthyosaurHealth; - float ichthyosaurDmgShake; - - float leechHealth; - float leechDmgBite; - - float controllerHealth; - float controllerDmgZap; - float controllerSpeedBall; - float controllerDmgBall; - - float nihilanthHealth; - float nihilanthZap; - - float scientistHealth; - - float snarkHealth; - float snarkDmgBite; - float snarkDmgPop; - - float zombieHealth; - float zombieDmgOneSlash; - float zombieDmgBothSlash; - - float turretHealth; - float miniturretHealth; - float sentryHealth; - - -// Player Weapons - float plrDmgCrowbar; - float plrDmg9MM; - float plrDmg357; - float plrDmgMP5; - float plrDmgM203Grenade; - float plrDmgBuckshot; - float plrDmgCrossbowClient; - float plrDmgCrossbowMonster; - float plrDmgRPG; - float plrDmgGauss; - float plrDmgEgonNarrow; - float plrDmgEgonWide; - float plrDmgHornet; - float plrDmgHandGrenade; - float plrDmgSatchel; - float plrDmgTripmine; - -// weapons shared by monsters - float monDmg9MM; - float monDmgMP5; - float monDmg12MM; - float monDmgHornet; - -// health/suit charge - float suitchargerCapacity; - float batteryCapacity; - float healthchargerCapacity; - float healthkitCapacity; - float scientistHeal; - -// monster damage adj - float monHead; - float monChest; - float monStomach; - float monLeg; - float monArm; - -// player damage adj - float plrHead; - float plrChest; - float plrStomach; - float plrLeg; - float plrArm; -}; - -extern DLL_GLOBAL skilldata_t gSkillData; -float GetSkillCvar( char *pName ); - -extern DLL_GLOBAL int g_iSkillLevel; - -#define SKILL_EASY 1 -#define SKILL_MEDIUM 2 -#define SKILL_HARD 3 +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +//========================================================= +// skill.h - skill level concerns +//========================================================= + +struct skilldata_t +{ + + int iSkillLevel; // game skill level + +// Monster Health & Damage + float agruntHealth; + float agruntDmgPunch; + + float apacheHealth; + + float barneyHealth; + + float bigmommaHealthFactor; // Multiply each node's health by this + float bigmommaDmgSlash; // melee attack damage + float bigmommaDmgBlast; // mortar attack damage + float bigmommaRadiusBlast; // mortar attack radius + + float bullsquidHealth; + float bullsquidDmgBite; + float bullsquidDmgWhip; + float bullsquidDmgSpit; + + float gargantuaHealth; + float gargantuaDmgSlash; + float gargantuaDmgFire; + float gargantuaDmgStomp; + + float hassassinHealth; + + float headcrabHealth; + float headcrabDmgBite; + + float hgruntHealth; + float hgruntDmgKick; + float hgruntShotgunPellets; + float hgruntGrenadeSpeed; + + float houndeyeHealth; + float houndeyeDmgBlast; + + float slaveHealth; + float slaveDmgClaw; + float slaveDmgClawrake; + float slaveDmgZap; + + float ichthyosaurHealth; + float ichthyosaurDmgShake; + + float leechHealth; + float leechDmgBite; + + float controllerHealth; + float controllerDmgZap; + float controllerSpeedBall; + float controllerDmgBall; + + float nihilanthHealth; + float nihilanthZap; + + float scientistHealth; + + float snarkHealth; + float snarkDmgBite; + float snarkDmgPop; + + float zombieHealth; + float zombieDmgOneSlash; + float zombieDmgBothSlash; + + float turretHealth; + float miniturretHealth; + float sentryHealth; + + +// Player Weapons + float plrDmgCrowbar; + float plrDmg9MM; + float plrDmg357; + float plrDmgMP5; + float plrDmgM203Grenade; + float plrDmgBuckshot; + float plrDmgCrossbowClient; + float plrDmgCrossbowMonster; + float plrDmgRPG; + float plrDmgGauss; + float plrDmgEgonNarrow; + float plrDmgEgonWide; + float plrDmgHornet; + float plrDmgHandGrenade; + float plrDmgSatchel; + float plrDmgTripmine; + +// weapons shared by monsters + float monDmg9MM; + float monDmgMP5; + float monDmg12MM; + float monDmgHornet; + +// health/suit charge + float suitchargerCapacity; + float batteryCapacity; + float healthchargerCapacity; + float healthkitCapacity; + float scientistHeal; + +// monster damage adj + float monHead; + float monChest; + float monStomach; + float monLeg; + float monArm; + +// player damage adj + float plrHead; + float plrChest; + float plrStomach; + float plrLeg; + float plrArm; +}; + +extern DLL_GLOBAL skilldata_t gSkillData; +float GetSkillCvar( char *pName ); + +extern DLL_GLOBAL int g_iSkillLevel; + +#define SKILL_EASY 1 +#define SKILL_MEDIUM 2 +#define SKILL_HARD 3 diff --git a/dep/rehlsdk/dlls/soundent.h b/dep/rehlsdk/dlls/soundent.h index 2393cb4..150daac 100644 --- a/dep/rehlsdk/dlls/soundent.h +++ b/dep/rehlsdk/dlls/soundent.h @@ -1,95 +1,95 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -//========================================================= -// Soundent.h - the entity that spawns when the world -// spawns, and handles the world's active and free sound -// lists. -//========================================================= - -#define MAX_WORLD_SOUNDS 64 // maximum number of sounds handled by the world at one time. - -#define bits_SOUND_NONE 0 -#define bits_SOUND_COMBAT ( 1 << 0 )// gunshots, explosions -#define bits_SOUND_WORLD ( 1 << 1 )// door opening/closing, glass breaking -#define bits_SOUND_PLAYER ( 1 << 2 )// all noises generated by player. walking, shooting, falling, splashing -#define bits_SOUND_CARCASS ( 1 << 3 )// dead body -#define bits_SOUND_MEAT ( 1 << 4 )// gib or pork chop -#define bits_SOUND_DANGER ( 1 << 5 )// pending danger. Grenade that is about to explode, explosive barrel that is damaged, falling crate -#define bits_SOUND_GARBAGE ( 1 << 6 )// trash cans, banana peels, old fast food bags. - -#define bits_ALL_SOUNDS 0xFFFFFFFF - -#define SOUNDLIST_EMPTY -1 - -#define SOUNDLISTTYPE_FREE 1// identifiers passed to functions that can operate on either list, to indicate which list to operate on. -#define SOUNDLISTTYPE_ACTIVE 2 - -#define SOUND_NEVER_EXPIRE -1 // with this set as a sound's ExpireTime, the sound will never expire. - -//========================================================= -// CSound - an instance of a sound in the world. -//========================================================= -class CSound -{ -public: - - void Clear ( void ); - void Reset ( void ); - - Vector m_vecOrigin; // sound's location in space - int m_iType; // what type of sound this is - int m_iVolume; // how loud the sound is - float m_flExpireTime; // when the sound should be purged from the list - int m_iNext; // index of next sound in this list ( Active or Free ) - int m_iNextAudible; // temporary link that monsters use to build a list of audible sounds - - BOOL FIsSound( void ); - BOOL FIsScent( void ); -}; - -//========================================================= -// CSoundEnt - a single instance of this entity spawns when -// the world spawns. The SoundEnt's job is to update the -// world's Free and Active sound lists. -//========================================================= -class CSoundEnt : public CBaseEntity -{ -public: - - void Precache ( void ); - void Spawn( void ); - void Think( void ); - void Initialize ( void ); - - static void InsertSound ( int iType, const Vector &vecOrigin, int iVolume, float flDuration ); - static void FreeSound ( int iSound, int iPrevious ); - static int ActiveList( void );// return the head of the active list - static int FreeList( void );// return the head of the free list - static CSound* SoundPointerForIndex( int iIndex );// return a pointer for this index in the sound list - static int ClientSoundIndex ( edict_t *pClient ); - - BOOL IsEmpty( void ) { return m_iActiveSound == SOUNDLIST_EMPTY; } - int ISoundsInList ( int iListType ); - int IAllocSound ( void ); - virtual int ObjectCaps( void ) { return FCAP_DONT_SAVE; } - - int m_iFreeSound; // index of the first sound in the free sound list - int m_iActiveSound; // indes of the first sound in the active sound list - int m_cLastActiveSounds; // keeps track of the number of active sounds at the last update. (for diagnostic work) - BOOL m_fShowReport; // if true, dump information about free/active sounds. - -private: - CSound m_SoundPool[ MAX_WORLD_SOUNDS ]; -}; +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +//========================================================= +// Soundent.h - the entity that spawns when the world +// spawns, and handles the world's active and free sound +// lists. +//========================================================= + +#define MAX_WORLD_SOUNDS 64 // maximum number of sounds handled by the world at one time. + +#define bits_SOUND_NONE 0 +#define bits_SOUND_COMBAT ( 1 << 0 )// gunshots, explosions +#define bits_SOUND_WORLD ( 1 << 1 )// door opening/closing, glass breaking +#define bits_SOUND_PLAYER ( 1 << 2 )// all noises generated by player. walking, shooting, falling, splashing +#define bits_SOUND_CARCASS ( 1 << 3 )// dead body +#define bits_SOUND_MEAT ( 1 << 4 )// gib or pork chop +#define bits_SOUND_DANGER ( 1 << 5 )// pending danger. Grenade that is about to explode, explosive barrel that is damaged, falling crate +#define bits_SOUND_GARBAGE ( 1 << 6 )// trash cans, banana peels, old fast food bags. + +#define bits_ALL_SOUNDS 0xFFFFFFFF + +#define SOUNDLIST_EMPTY -1 + +#define SOUNDLISTTYPE_FREE 1// identifiers passed to functions that can operate on either list, to indicate which list to operate on. +#define SOUNDLISTTYPE_ACTIVE 2 + +#define SOUND_NEVER_EXPIRE -1 // with this set as a sound's ExpireTime, the sound will never expire. + +//========================================================= +// CSound - an instance of a sound in the world. +//========================================================= +class CSound +{ +public: + + void Clear ( void ); + void Reset ( void ); + + Vector m_vecOrigin; // sound's location in space + int m_iType; // what type of sound this is + int m_iVolume; // how loud the sound is + float m_flExpireTime; // when the sound should be purged from the list + int m_iNext; // index of next sound in this list ( Active or Free ) + int m_iNextAudible; // temporary link that monsters use to build a list of audible sounds + + BOOL FIsSound( void ); + BOOL FIsScent( void ); +}; + +//========================================================= +// CSoundEnt - a single instance of this entity spawns when +// the world spawns. The SoundEnt's job is to update the +// world's Free and Active sound lists. +//========================================================= +class CSoundEnt : public CBaseEntity +{ +public: + + void Precache ( void ); + void Spawn( void ); + void Think( void ); + void Initialize ( void ); + + static void InsertSound ( int iType, const Vector &vecOrigin, int iVolume, float flDuration ); + static void FreeSound ( int iSound, int iPrevious ); + static int ActiveList( void );// return the head of the active list + static int FreeList( void );// return the head of the free list + static CSound* SoundPointerForIndex( int iIndex );// return a pointer for this index in the sound list + static int ClientSoundIndex ( edict_t *pClient ); + + BOOL IsEmpty( void ) { return m_iActiveSound == SOUNDLIST_EMPTY; } + int ISoundsInList ( int iListType ); + int IAllocSound ( void ); + virtual int ObjectCaps( void ) { return FCAP_DONT_SAVE; } + + int m_iFreeSound; // index of the first sound in the free sound list + int m_iActiveSound; // indes of the first sound in the active sound list + int m_cLastActiveSounds; // keeps track of the number of active sounds at the last update. (for diagnostic work) + BOOL m_fShowReport; // if true, dump information about free/active sounds. + +private: + CSound m_SoundPool[ MAX_WORLD_SOUNDS ]; +}; diff --git a/dep/rehlsdk/dlls/spectator.h b/dep/rehlsdk/dlls/spectator.h index 1a2c11f..2f755d6 100644 --- a/dep/rehlsdk/dlls/spectator.h +++ b/dep/rehlsdk/dlls/spectator.h @@ -1,27 +1,27 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// Spectator.h - -class CBaseSpectator : public CBaseEntity -{ -public: - void Spawn(); - void SpectatorConnect(void); - void SpectatorDisconnect(void); - void SpectatorThink(void); - -private: - void SpectatorImpulseCommand(void); -}; +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +// Spectator.h + +class CBaseSpectator : public CBaseEntity +{ +public: + void Spawn(); + void SpectatorConnect(void); + void SpectatorDisconnect(void); + void SpectatorThink(void); + +private: + void SpectatorImpulseCommand(void); +}; diff --git a/dep/rehlsdk/dlls/talkmonster.h b/dep/rehlsdk/dlls/talkmonster.h index 34fc40e..25c1fc6 100644 --- a/dep/rehlsdk/dlls/talkmonster.h +++ b/dep/rehlsdk/dlls/talkmonster.h @@ -1,26 +1,26 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#ifndef TALKMONSTER_H -#define TALKMONSTER_H - -class CTalkMonster : public CBaseMonster -{ -public: - static float g_talkWaitTime; - -}; - -#endif //TALKMONSTER_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +#ifndef TALKMONSTER_H +#define TALKMONSTER_H + +class CTalkMonster : public CBaseMonster +{ +public: + static float g_talkWaitTime; + +}; + +#endif //TALKMONSTER_H diff --git a/dep/rehlsdk/dlls/teamplay_gamerules.h b/dep/rehlsdk/dlls/teamplay_gamerules.h index c7c351e..5d4246b 100644 --- a/dep/rehlsdk/dlls/teamplay_gamerules.h +++ b/dep/rehlsdk/dlls/teamplay_gamerules.h @@ -1,57 +1,57 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// -// teamplay_gamerules.h -// - -#define MAX_TEAMNAME_LENGTH 16 -#define MAX_TEAMS 32 - -#define TEAMPLAY_TEAMLISTLENGTH MAX_TEAMS*MAX_TEAMNAME_LENGTH - -class CHalfLifeTeamplay : public CHalfLifeMultiplay -{ -public: - CHalfLifeTeamplay(); - - virtual BOOL ClientCommand( CBasePlayer *pPlayer, const char *pcmd ); - virtual void ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer ); - virtual BOOL IsTeamplay( void ); - virtual BOOL FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ); - virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget ); - virtual const char *GetTeamID( CBaseEntity *pEntity ); - virtual BOOL ShouldAutoAim( CBasePlayer *pPlayer, edict_t *target ); - virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ); - virtual void InitHUD( CBasePlayer *pl ); - virtual void DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor ); - virtual const char *GetGameDescription( void ) { return "HL Teamplay"; } // this is the game name that gets seen in the server browser - virtual void UpdateGameMode( CBasePlayer *pPlayer ); // the client needs to be informed of the current game mode - virtual void PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ); - virtual void Think ( void ); - virtual int GetTeamIndex( const char *pTeamName ); - virtual const char *GetIndexedTeamName( int teamIndex ); - virtual BOOL IsValidTeam( const char *pTeamName ); - const char *SetDefaultPlayerTeam( CBasePlayer *pPlayer ); - virtual void ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib ); - -private: - void RecountTeams( bool bResendInfo = FALSE ); - const char *TeamWithFewestPlayers( void ); - - BOOL m_DisableDeathMessages; - BOOL m_DisableDeathPenalty; - BOOL m_teamLimit; // This means the server set only some teams as valid - char m_szTeamList[TEAMPLAY_TEAMLISTLENGTH]; -}; +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +// +// teamplay_gamerules.h +// + +#define MAX_TEAMNAME_LENGTH 16 +#define MAX_TEAMS 32 + +#define TEAMPLAY_TEAMLISTLENGTH MAX_TEAMS*MAX_TEAMNAME_LENGTH + +class CHalfLifeTeamplay : public CHalfLifeMultiplay +{ +public: + CHalfLifeTeamplay(); + + virtual BOOL ClientCommand( CBasePlayer *pPlayer, const char *pcmd ); + virtual void ClientUserInfoChanged( CBasePlayer *pPlayer, char *infobuffer ); + virtual BOOL IsTeamplay( void ); + virtual BOOL FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker ); + virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget ); + virtual const char *GetTeamID( CBaseEntity *pEntity ); + virtual BOOL ShouldAutoAim( CBasePlayer *pPlayer, edict_t *target ); + virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled ); + virtual void InitHUD( CBasePlayer *pl ); + virtual void DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor ); + virtual const char *GetGameDescription( void ) { return "HL Teamplay"; } // this is the game name that gets seen in the server browser + virtual void UpdateGameMode( CBasePlayer *pPlayer ); // the client needs to be informed of the current game mode + virtual void PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor ); + virtual void Think ( void ); + virtual int GetTeamIndex( const char *pTeamName ); + virtual const char *GetIndexedTeamName( int teamIndex ); + virtual BOOL IsValidTeam( const char *pTeamName ); + const char *SetDefaultPlayerTeam( CBasePlayer *pPlayer ); + virtual void ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib ); + +private: + void RecountTeams( bool bResendInfo = FALSE ); + const char *TeamWithFewestPlayers( void ); + + BOOL m_DisableDeathMessages; + BOOL m_DisableDeathPenalty; + BOOL m_teamLimit; // This means the server set only some teams as valid + char m_szTeamList[TEAMPLAY_TEAMLISTLENGTH]; +}; diff --git a/dep/rehlsdk/dlls/trains.h b/dep/rehlsdk/dlls/trains.h index 4ee4411..87aec76 100644 --- a/dep/rehlsdk/dlls/trains.h +++ b/dep/rehlsdk/dlls/trains.h @@ -1,127 +1,127 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef TRAINS_H -#define TRAINS_H - -// Tracktrain spawn flags -#define SF_TRACKTRAIN_NOPITCH 0x0001 -#define SF_TRACKTRAIN_NOCONTROL 0x0002 -#define SF_TRACKTRAIN_FORWARDONLY 0x0004 -#define SF_TRACKTRAIN_PASSABLE 0x0008 - -// Spawnflag for CPathTrack -#define SF_PATH_DISABLED 0x00000001 -#define SF_PATH_FIREONCE 0x00000002 -#define SF_PATH_ALTREVERSE 0x00000004 -#define SF_PATH_DISABLE_TRAIN 0x00000008 -#define SF_PATH_ALTERNATE 0x00008000 - -// Spawnflags of CPathCorner -#define SF_CORNER_WAITFORTRIG 0x001 -#define SF_CORNER_TELEPORT 0x002 -#define SF_CORNER_FIREONCE 0x004 - -//#define PATH_SPARKLE_DEBUG 1 // This makes a particle effect around path_track entities for debugging -class CPathTrack : public CPointEntity -{ -public: - void Spawn( void ); - void Activate( void ); - void KeyValue( KeyValueData* pkvd); - - void SetPrevious( CPathTrack *pprevious ); - void Link( void ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - - CPathTrack *ValidPath( CPathTrack *ppath, int testFlag ); // Returns ppath if enabled, NULL otherwise - void Project( CPathTrack *pstart, CPathTrack *pend, Vector *origin, float dist ); - - static CPathTrack *Instance( edict_t *pent ); - - CPathTrack *LookAhead( Vector *origin, float dist, int move ); - CPathTrack *Nearest( Vector origin ); - - CPathTrack *GetNext( void ); - CPathTrack *GetPrevious( void ); - - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - static TYPEDESCRIPTION m_SaveData[]; -#if PATH_SPARKLE_DEBUG - void EXPORT Sparkle(void); -#endif - - float m_length; - string_t m_altName; - CPathTrack *m_pnext; - CPathTrack *m_pprevious; - CPathTrack *m_paltpath; -}; - - -class CFuncTrackTrain : public CBaseEntity -{ -public: - void Spawn( void ); - void Precache( void ); - - void Blocked( CBaseEntity *pOther ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void KeyValue( KeyValueData* pkvd ); - - void EXPORT Next( void ); - void EXPORT Find( void ); - void EXPORT NearestPath( void ); - void EXPORT DeadEnd( void ); - - void NextThink( float thinkTime, BOOL alwaysThink ); - - void SetTrack( CPathTrack *track ) { m_ppath = track->Nearest(pev->origin); } - void SetControls( entvars_t *pevControls ); - BOOL OnControls( entvars_t *pev ); - - void StopSound ( void ); - void UpdateSound ( void ); - - static CFuncTrackTrain *Instance( edict_t *pent ); - - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - - static TYPEDESCRIPTION m_SaveData[]; - virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DIRECTIONAL_USE; } - - virtual void OverrideReset( void ); - - CPathTrack *m_ppath; - float m_length; - float m_height; - float m_speed; - float m_dir; - float m_startSpeed; - Vector m_controlMins; - Vector m_controlMaxs; - int m_soundPlaying; - int m_sounds; - float m_flVolume; - float m_flBank; - float m_oldSpeed; - -private: - unsigned short m_usAdjustPitch; -}; - -#endif +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef TRAINS_H +#define TRAINS_H + +// Tracktrain spawn flags +#define SF_TRACKTRAIN_NOPITCH 0x0001 +#define SF_TRACKTRAIN_NOCONTROL 0x0002 +#define SF_TRACKTRAIN_FORWARDONLY 0x0004 +#define SF_TRACKTRAIN_PASSABLE 0x0008 + +// Spawnflag for CPathTrack +#define SF_PATH_DISABLED 0x00000001 +#define SF_PATH_FIREONCE 0x00000002 +#define SF_PATH_ALTREVERSE 0x00000004 +#define SF_PATH_DISABLE_TRAIN 0x00000008 +#define SF_PATH_ALTERNATE 0x00008000 + +// Spawnflags of CPathCorner +#define SF_CORNER_WAITFORTRIG 0x001 +#define SF_CORNER_TELEPORT 0x002 +#define SF_CORNER_FIREONCE 0x004 + +//#define PATH_SPARKLE_DEBUG 1 // This makes a particle effect around path_track entities for debugging +class CPathTrack : public CPointEntity +{ +public: + void Spawn( void ); + void Activate( void ); + void KeyValue( KeyValueData* pkvd); + + void SetPrevious( CPathTrack *pprevious ); + void Link( void ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + + CPathTrack *ValidPath( CPathTrack *ppath, int testFlag ); // Returns ppath if enabled, NULL otherwise + void Project( CPathTrack *pstart, CPathTrack *pend, Vector *origin, float dist ); + + static CPathTrack *Instance( edict_t *pent ); + + CPathTrack *LookAhead( Vector *origin, float dist, int move ); + CPathTrack *Nearest( Vector origin ); + + CPathTrack *GetNext( void ); + CPathTrack *GetPrevious( void ); + + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + + static TYPEDESCRIPTION m_SaveData[]; +#if PATH_SPARKLE_DEBUG + void EXPORT Sparkle(void); +#endif + + float m_length; + string_t m_altName; + CPathTrack *m_pnext; + CPathTrack *m_pprevious; + CPathTrack *m_paltpath; +}; + + +class CFuncTrackTrain : public CBaseEntity +{ +public: + void Spawn( void ); + void Precache( void ); + + void Blocked( CBaseEntity *pOther ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void KeyValue( KeyValueData* pkvd ); + + void EXPORT Next( void ); + void EXPORT Find( void ); + void EXPORT NearestPath( void ); + void EXPORT DeadEnd( void ); + + void NextThink( float thinkTime, BOOL alwaysThink ); + + void SetTrack( CPathTrack *track ) { m_ppath = track->Nearest(pev->origin); } + void SetControls( entvars_t *pevControls ); + BOOL OnControls( entvars_t *pev ); + + void StopSound ( void ); + void UpdateSound ( void ); + + static CFuncTrackTrain *Instance( edict_t *pent ); + + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + + static TYPEDESCRIPTION m_SaveData[]; + virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DIRECTIONAL_USE; } + + virtual void OverrideReset( void ); + + CPathTrack *m_ppath; + float m_length; + float m_height; + float m_speed; + float m_dir; + float m_startSpeed; + Vector m_controlMins; + Vector m_controlMaxs; + int m_soundPlaying; + int m_sounds; + float m_flVolume; + float m_flBank; + float m_oldSpeed; + +private: + unsigned short m_usAdjustPitch; +}; + +#endif diff --git a/dep/rehlsdk/dlls/util.h b/dep/rehlsdk/dlls/util.h index 951b52d..6ab9b4f 100644 --- a/dep/rehlsdk/dlls/util.h +++ b/dep/rehlsdk/dlls/util.h @@ -1,547 +1,547 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#include "archtypes.h" // DAL - -// -// Misc utility code -// -#ifndef ACTIVITY_H -#include "activity.h" -#endif - -#ifndef ENGINECALLBACK_H -#include "enginecallback.h" -#endif -inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent ); // implementation later in this file - -extern globalvars_t *gpGlobals; - -// Use this instead of ALLOC_STRING on constant strings -#define STRING(offset) ((const char *)(gpGlobals->pStringBase + (unsigned int)(offset))) -#define MAKE_STRING(str) ((uint64)(str) - (uint64)(STRING(0))) - -inline edict_t *FIND_ENTITY_BY_CLASSNAME(edict_t *entStart, const char *pszName) -{ - return FIND_ENTITY_BY_STRING(entStart, "classname", pszName); -} - -inline edict_t *FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, const char *pszName) -{ - return FIND_ENTITY_BY_STRING(entStart, "targetname", pszName); -} - -// for doing a reverse lookup. Say you have a door, and want to find its button. -inline edict_t *FIND_ENTITY_BY_TARGET(edict_t *entStart, const char *pszName) -{ - return FIND_ENTITY_BY_STRING(entStart, "target", pszName); -} - -// Keeps clutter down a bit, when writing key-value pairs -#define WRITEKEY_INT(pf, szKeyName, iKeyValue) ENGINE_FPRINTF(pf, "\"%s\" \"%d\"\n", szKeyName, iKeyValue) -#define WRITEKEY_FLOAT(pf, szKeyName, flKeyValue) \ - ENGINE_FPRINTF(pf, "\"%s\" \"%f\"\n", szKeyName, flKeyValue) -#define WRITEKEY_STRING(pf, szKeyName, szKeyValue) \ - ENGINE_FPRINTF(pf, "\"%s\" \"%s\"\n", szKeyName, szKeyValue) -#define WRITEKEY_VECTOR(pf, szKeyName, flX, flY, flZ) \ - ENGINE_FPRINTF(pf, "\"%s\" \"%f %f %f\"\n", szKeyName, flX, flY, flZ) - -// Keeps clutter down a bit, when using a float as a bit-vector -#define SetBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) | (bits)) -#define ClearBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) & ~(bits)) -#define FBitSet(flBitVector, bit) ((int)(flBitVector) & (bit)) - -// Makes these more explicit, and easier to find -#define FILE_GLOBAL static -#define DLL_GLOBAL - -// Until we figure out why "const" gives the compiler problems, we'll just have to use -// this bogus "empty" define to mark things as constant. -#define CONSTANT - -// More explicit than "int" -typedef int EOFFSET; - -// In case it's not alread defined -typedef int BOOL; - -// In case this ever changes -#define M_PI 3.14159265358979323846 - -// Keeps clutter down a bit, when declaring external entity/global method prototypes -#define DECLARE_GLOBAL_METHOD(MethodName) extern void UTIL_DLLEXPORT MethodName( void ) -#define GLOBAL_METHOD(funcname) void UTIL_DLLEXPORT funcname(void) - -#ifndef UTIL_DLLEXPORT -#ifdef _WIN32 -#define UTIL_DLLEXPORT _declspec( dllexport ) EXT_FUNC -#else -#define UTIL_DLLEXPORT __attribute__ ((visibility("default"))) EXT_FUNC -#endif -#endif - -// This is the glue that hooks .MAP entity class names to our CPP classes -// The _declspec forces them to be exported by name so we can do a lookup with GetProcAddress() -// The function is used to intialize / allocate the object for the entity -#define LINK_ENTITY_TO_CLASS(mapClassName,DLLClassName) \ - extern "C" UTIL_DLLEXPORT void mapClassName( entvars_t *pev ); \ - void mapClassName( entvars_t *pev ) { GetClassPtr( (DLLClassName *)pev ); } - - -// -// Conversion among the three types of "entity", including identity-conversions. -// -#ifdef DEBUG - extern edict_t *DBG_EntOfVars(const entvars_t *pev); - inline edict_t *ENT(const entvars_t *pev) { return DBG_EntOfVars(pev); } -#else - inline edict_t *ENT(const entvars_t *pev) { return pev->pContainingEntity; } -#endif -inline edict_t *ENT(edict_t *pent) { return pent; } -inline edict_t *ENT(EOFFSET eoffset) { return (*g_engfuncs.pfnPEntityOfEntOffset)(eoffset); } -inline EOFFSET OFFSET(EOFFSET eoffset) { return eoffset; } -inline EOFFSET OFFSET(const edict_t *pent) -{ -#if _DEBUG - if ( !pent ) - ALERT( at_error, "Bad ent in OFFSET()\n" ); -#endif - return (*g_engfuncs.pfnEntOffsetOfPEntity)(pent); -} -inline EOFFSET OFFSET(entvars_t *pev) -{ -#if _DEBUG - if ( !pev ) - ALERT( at_error, "Bad pev in OFFSET()\n" ); -#endif - return OFFSET(ENT(pev)); -} -inline entvars_t *VARS(entvars_t *pev) { return pev; } - -inline entvars_t *VARS(edict_t *pent) -{ - if ( !pent ) - return NULL; - - return &pent->v; -} - -inline entvars_t* VARS(EOFFSET eoffset) { return VARS(ENT(eoffset)); } -inline int ENTINDEX(edict_t *pEdict) { return (*g_engfuncs.pfnIndexOfEdict)(pEdict); } -inline edict_t* INDEXENT( int iEdictNum ) { return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum); } -inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent ) { - (*g_engfuncs.pfnMessageBegin)(msg_dest, msg_type, pOrigin, ENT(ent)); -} - -// Testing the three types of "entity" for nullity -#define eoNullEntity 0 -inline BOOL FNullEnt(EOFFSET eoffset) { return eoffset == 0; } -inline BOOL FNullEnt(const edict_t* pent) { return pent == NULL || FNullEnt(OFFSET(pent)); } -inline BOOL FNullEnt(entvars_t* pev) { return pev == NULL || FNullEnt(OFFSET(pev)); } - -// Testing strings for nullity -#define iStringNull 0 -inline BOOL FStringNull(int iString) { return iString == iStringNull; } - -#define cchMapNameMost 32 - -// Dot products for view cone checking -#define VIEW_FIELD_FULL (float)-1.0 // +-180 degrees -#define VIEW_FIELD_WIDE (float)-0.7 // +-135 degrees 0.1 // +-85 degrees, used for full FOV checks -#define VIEW_FIELD_NARROW (float)0.7 // +-45 degrees, more narrow check used to set up ranged attacks -#define VIEW_FIELD_ULTRA_NARROW (float)0.9 // +-25 degrees, more narrow check used to set up ranged attacks - -// All monsters need this data -#define DONT_BLEED -1 -#define BLOOD_COLOR_RED (BYTE)247 -#define BLOOD_COLOR_YELLOW (BYTE)195 -#define BLOOD_COLOR_GREEN BLOOD_COLOR_YELLOW - -typedef enum -{ - - MONSTERSTATE_NONE = 0, - MONSTERSTATE_IDLE, - MONSTERSTATE_COMBAT, - MONSTERSTATE_ALERT, - MONSTERSTATE_HUNT, - MONSTERSTATE_PRONE, - MONSTERSTATE_SCRIPT, - MONSTERSTATE_PLAYDEAD, - MONSTERSTATE_DEAD - -} MONSTERSTATE; - - - -// Things that toggle (buttons/triggers/doors) need this -typedef enum - { - TS_AT_TOP, - TS_AT_BOTTOM, - TS_GOING_UP, - TS_GOING_DOWN - } TOGGLE_STATE; - -// Misc useful -inline BOOL FStrEq(const char*sz1, const char*sz2) - { return (strcmp(sz1, sz2) == 0); } -inline BOOL FClassnameIs(edict_t* pent, const char* szClassname) - { return FStrEq(STRING(VARS(pent)->classname), szClassname); } -inline BOOL FClassnameIs(entvars_t* pev, const char* szClassname) - { return FStrEq(STRING(pev->classname), szClassname); } - -class CBaseEntity; - -// Misc. Prototypes -extern void UTIL_SetSize (entvars_t* pev, const Vector &vecMin, const Vector &vecMax); -extern float UTIL_VecToYaw (const Vector &vec); -extern Vector UTIL_VecToAngles (const Vector &vec); -extern float UTIL_AngleMod (float a); -extern float UTIL_AngleDiff ( float destAngle, float srcAngle ); - -extern CBaseEntity *UTIL_FindEntityInSphere(CBaseEntity *pStartEntity, const Vector &vecCenter, float flRadius); -extern CBaseEntity *UTIL_FindEntityByString(CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue ); -extern CBaseEntity *UTIL_FindEntityByClassname(CBaseEntity *pStartEntity, const char *szName ); -extern CBaseEntity *UTIL_FindEntityByTargetname(CBaseEntity *pStartEntity, const char *szName ); -extern CBaseEntity *UTIL_FindEntityGeneric(const char *szName, Vector &vecSrc, float flRadius ); - -// returns a CBaseEntity pointer to a player by index. Only returns if the player is spawned and connected -// otherwise returns NULL -// Index is 1 based -extern CBaseEntity *UTIL_PlayerByIndex( int playerIndex ); - -#define UTIL_EntitiesInPVS(pent) (*g_engfuncs.pfnEntitiesInPVS)(pent) -extern void UTIL_MakeVectors (const Vector &vecAngles); - -// Pass in an array of pointers and an array size, it fills the array and returns the number inserted -extern int UTIL_MonstersInSphere( CBaseEntity **pList, int listMax, const Vector ¢er, float radius ); -extern int UTIL_EntitiesInBox( CBaseEntity **pList, int listMax, const Vector &mins, const Vector &maxs, int flagMask ); - -inline void UTIL_MakeVectorsPrivate( const Vector &vecAngles, float *p_vForward, float *p_vRight, float *p_vUp ) -{ - g_engfuncs.pfnAngleVectors( vecAngles, p_vForward, p_vRight, p_vUp ); -} - -extern void UTIL_MakeAimVectors ( const Vector &vecAngles ); // like MakeVectors, but assumes pitch isn't inverted -extern void UTIL_MakeInvVectors ( const Vector &vec, globalvars_t *pgv ); - -extern void UTIL_SetOrigin ( entvars_t* pev, const Vector &vecOrigin ); -extern void UTIL_EmitAmbientSound ( edict_t *entity, const Vector &vecOrigin, const char *samp, float vol, float attenuation, int fFlags, int pitch ); -extern void UTIL_ParticleEffect ( const Vector &vecOrigin, const Vector &vecDirection, ULONG ulColor, ULONG ulCount ); -extern void UTIL_ScreenShake ( const Vector ¢er, float amplitude, float frequency, float duration, float radius ); -extern void UTIL_ScreenShakeAll ( const Vector ¢er, float amplitude, float frequency, float duration ); -extern void UTIL_ShowMessage ( const char *pString, CBaseEntity *pPlayer ); -extern void UTIL_ShowMessageAll ( const char *pString ); -extern void UTIL_ScreenFadeAll ( const Vector &color, float fadeTime, float holdTime, int alpha, int flags ); -extern void UTIL_ScreenFade ( CBaseEntity *pEntity, const Vector &color, float fadeTime, float fadeHold, int alpha, int flags ); - -typedef enum { ignore_monsters=1, dont_ignore_monsters=0, missile=2 } IGNORE_MONSTERS; -typedef enum { ignore_glass=1, dont_ignore_glass=0 } IGNORE_GLASS; -extern void UTIL_TraceLine (const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, edict_t *pentIgnore, TraceResult *ptr); -extern void UTIL_TraceLine (const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, IGNORE_GLASS ignoreGlass, edict_t *pentIgnore, TraceResult *ptr); -typedef enum { point_hull=0, human_hull=1, large_hull=2, head_hull=3 } __HLSDK_HULL_TYPE; -extern void UTIL_TraceHull (const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, int hullNumber, edict_t *pentIgnore, TraceResult *ptr); -extern TraceResult UTIL_GetGlobalTrace (void); -extern void UTIL_TraceModel (const Vector &vecStart, const Vector &vecEnd, int hullNumber, edict_t *pentModel, TraceResult *ptr); -extern Vector UTIL_GetAimVector (edict_t* pent, float flSpeed); -extern int UTIL_PointContents (const Vector &vec); - -extern int UTIL_IsMasterTriggered (string_t sMaster, CBaseEntity *pActivator); -extern void UTIL_BloodStream( const Vector &origin, const Vector &direction, int color, int amount ); -extern void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color, int amount ); -extern Vector UTIL_RandomBloodVector( void ); -extern BOOL UTIL_ShouldShowBlood( int bloodColor ); -extern void UTIL_BloodDecalTrace( TraceResult *pTrace, int bloodColor ); -extern void UTIL_DecalTrace( TraceResult *pTrace, int decalNumber ); -extern void UTIL_PlayerDecalTrace( TraceResult *pTrace, int playernum, int decalNumber, BOOL bIsCustom ); -extern void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber ); -extern void UTIL_Sparks( const Vector &position ); -extern void UTIL_Ricochet( const Vector &position, float scale ); -extern void UTIL_StringToVector( float *pVector, const char *pString ); -extern void UTIL_StringToIntArray( int *pVector, int count, const char *pString ); -extern Vector UTIL_ClampVectorToBox( const Vector &input, const Vector &clampSize ); -extern float UTIL_Approach( float target, float value, float speed ); -extern float UTIL_ApproachAngle( float target, float value, float speed ); -extern float UTIL_AngleDistance( float next, float cur ); - -extern char *UTIL_VarArgs( char *format, ... ); -extern void UTIL_Remove( CBaseEntity *pEntity ); -extern BOOL UTIL_IsValidEntity( edict_t *pent ); -extern BOOL UTIL_TeamsMatch( const char *pTeamName1, const char *pTeamName2 ); - -// Use for ease-in, ease-out style interpolation (accel/decel) -extern float UTIL_SplineFraction( float value, float scale ); - -// Search for water transition along a vertical line -extern float UTIL_WaterLevel( const Vector &position, float minz, float maxz ); -extern void UTIL_Bubbles( Vector mins, Vector maxs, int count ); -extern void UTIL_BubbleTrail( Vector from, Vector to, int count ); - -// allows precacheing of other entities -extern void UTIL_PrecacheOther( const char *szClassname ); - -// prints a message to each client -extern void UTIL_ClientPrintAll( int msg_dest, const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL ); -inline void UTIL_CenterPrintAll( const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL ) -{ - UTIL_ClientPrintAll( HUD_PRINTCENTER, msg_name, param1, param2, param3, param4 ); -} - -class CBasePlayerItem; -class CBasePlayer; -extern BOOL UTIL_GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ); - -// prints messages through the HUD -extern void ClientPrint( entvars_t *client, int msg_dest, const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL ); - -// prints a message to the HUD say (chat) -extern void UTIL_SayText( const char *pText, CBaseEntity *pEntity ); -extern void UTIL_SayTextAll( const char *pText, CBaseEntity *pEntity ); - - -typedef struct hudtextparms_s -{ - float x; - float y; - int effect; - byte r1, g1, b1, a1; - byte r2, g2, b2, a2; - float fadeinTime; - float fadeoutTime; - float holdTime; - float fxTime; - int channel; -} hudtextparms_t; - -// prints as transparent 'title' to the HUD -extern void UTIL_HudMessageAll( const hudtextparms_t &textparms, const char *pMessage ); -extern void UTIL_HudMessage( CBaseEntity *pEntity, const hudtextparms_t &textparms, const char *pMessage ); - -// for handy use with ClientPrint params -extern char *UTIL_dtos1( int d ); -extern char *UTIL_dtos2( int d ); -extern char *UTIL_dtos3( int d ); -extern char *UTIL_dtos4( int d ); - -// Writes message to console with timestamp and FragLog header. -extern void UTIL_LogPrintf( char *fmt, ... ); -extern void UTIL_ServerPrintf( const char *fmt, ... ); - -// Sorta like FInViewCone, but for nonmonsters. -extern float UTIL_DotPoints ( const Vector &vecSrc, const Vector &vecCheck, const Vector &vecDir ); - -extern void UTIL_StripToken( const char *pKey, char *pDest );// for redundant keynames - -// Misc functions -extern void SetMovedir(entvars_t* pev); -extern Vector VecBModelOrigin( entvars_t* pevBModel ); -extern int BuildChangeList( LEVELLIST *pLevelList, int maxList ); - -// -// How did I ever live without ASSERT? -// -#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) -#define ASSERTSZ(f, sz) DBG_AssertFunction(f, #f, __FILE__, __LINE__, sz) -#else // !DEBUG -#define ASSERT(f) -#define ASSERTSZ(f, sz) -#endif // !DEBUG - - -extern DLL_GLOBAL const Vector g_vecZero; - -// -// Constants that were used only by QC (maybe not used at all now) -// -// Un-comment only as needed -// -#define LANGUAGE_ENGLISH 0 -#define LANGUAGE_GERMAN 1 -#define LANGUAGE_FRENCH 2 -#define LANGUAGE_BRITISH 3 - -extern DLL_GLOBAL int g_Language; - -#define AMBIENT_SOUND_STATIC 0 // medium radius attenuation -#define AMBIENT_SOUND_EVERYWHERE 1 -#define AMBIENT_SOUND_SMALLRADIUS 2 -#define AMBIENT_SOUND_MEDIUMRADIUS 4 -#define AMBIENT_SOUND_LARGERADIUS 8 -#define AMBIENT_SOUND_START_SILENT 16 -#define AMBIENT_SOUND_NOT_LOOPING 32 - -#define SPEAKER_START_SILENT 1 // wait for trigger 'on' to start announcements - -#define SND_SPAWNING (1<<8) // duplicated in protocol.h we're spawing, used in some cases for ambients -#define SND_STOP (1<<5) // duplicated in protocol.h stop sound -#define SND_CHANGE_VOL (1<<6) // duplicated in protocol.h change sound vol -#define SND_CHANGE_PITCH (1<<7) // duplicated in protocol.h change sound pitch - -#define LFO_SQUARE 1 -#define LFO_TRIANGLE 2 -#define LFO_RANDOM 3 - -// func_rotating -#define SF_BRUSH_ROTATE_Y_AXIS 0 -#define SF_BRUSH_ROTATE_INSTANT 1 -#define SF_BRUSH_ROTATE_BACKWARDS 2 -#define SF_BRUSH_ROTATE_Z_AXIS 4 -#define SF_BRUSH_ROTATE_X_AXIS 8 -#define SF_PENDULUM_AUTO_RETURN 16 -#define SF_PENDULUM_PASSABLE 32 - - -#define SF_BRUSH_ROTATE_SMALLRADIUS 128 -#define SF_BRUSH_ROTATE_MEDIUMRADIUS 256 -#define SF_BRUSH_ROTATE_LARGERADIUS 512 - -#define PUSH_BLOCK_ONLY_X 1 -#define PUSH_BLOCK_ONLY_Y 2 - -#define VEC_HULL_MIN Vector(-16, -16, -36) -#define VEC_HULL_MAX Vector( 16, 16, 36) -#define VEC_HUMAN_HULL_MIN Vector( -16, -16, 0 ) -#define VEC_HUMAN_HULL_MAX Vector( 16, 16, 72 ) -#define VEC_HUMAN_HULL_DUCK Vector( 16, 16, 36 ) - -#define VEC_VIEW Vector( 0, 0, 28 ) - -#define VEC_DUCK_HULL_MIN Vector(-16, -16, -18 ) -#define VEC_DUCK_HULL_MAX Vector( 16, 16, 18) -#define VEC_DUCK_VIEW Vector( 0, 0, 12 ) - -#define SVC_TEMPENTITY 23 -#define SVC_INTERMISSION 30 -#define SVC_CDTRACK 32 -#define SVC_WEAPONANIM 35 -#define SVC_ROOMTYPE 37 -#define SVC_DIRECTOR 51 - - - -// triggers -#define SF_TRIGGER_ALLOWMONSTERS 1// monsters allowed to fire this trigger -#define SF_TRIGGER_NOCLIENTS 2// players not allowed to fire this trigger -#define SF_TRIGGER_PUSHABLES 4// only pushables can fire this trigger - -// func breakable -#define SF_BREAK_TRIGGER_ONLY 1// may only be broken by trigger -#define SF_BREAK_TOUCH 2// can be 'crashed through' by running player (plate glass) -#define SF_BREAK_PRESSURE 4// can be broken by a player standing on it -#define SF_BREAK_CROWBAR 256// instant break if hit with crowbar - -// func_pushable (it's also func_breakable, so don't collide with those flags) -#define SF_PUSH_BREAKABLE 128 - -#define SF_LIGHT_START_OFF 1 - -#define SPAWNFLAG_NOMESSAGE 1 -#define SPAWNFLAG_NOTOUCH 1 -#define SPAWNFLAG_DROIDONLY 4 - -#define SPAWNFLAG_USEONLY 1 // can't be touched, must be used (buttons) - -#define TELE_PLAYER_ONLY 1 -#define TELE_SILENT 2 - -#define SF_TRIG_PUSH_ONCE 1 - - -// Sound Utilities - -// sentence groups -#define CBSENTENCENAME_MAX 16 -#define CVOXFILESENTENCEMAX 1536 // max number of sentences in game. NOTE: this must match - // CVOXFILESENTENCEMAX in engine\sound.h!!! - -extern char gszallsentencenames[CVOXFILESENTENCEMAX][CBSENTENCENAME_MAX]; -extern int gcallsentences; - -int USENTENCEG_Pick(int isentenceg, char *szfound); -int USENTENCEG_PickSequential(int isentenceg, char *szfound, int ipick, int freset); -void USENTENCEG_InitLRU(unsigned char *plru, int count); - -void SENTENCEG_Init(); -void SENTENCEG_Stop(edict_t *entity, int isentenceg, int ipick); -int SENTENCEG_PlayRndI(edict_t *entity, int isentenceg, float volume, float attenuation, int flags, int pitch); -int SENTENCEG_PlayRndSz(edict_t *entity, const char *szrootname, float volume, float attenuation, int flags, int pitch); -int SENTENCEG_PlaySequentialSz(edict_t *entity, const char *szrootname, float volume, float attenuation, int flags, int pitch, int ipick, int freset); -int SENTENCEG_GetIndex(const char *szrootname); -int SENTENCEG_Lookup(const char *sample, char *sentencenum); - -void TEXTURETYPE_Init(); -char TEXTURETYPE_Find(char *name); -float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int iBulletType); - -// NOTE: use EMIT_SOUND_DYN to set the pitch of a sound. Pitch of 100 -// is no pitch shift. Pitch > 100 up to 255 is a higher pitch, pitch < 100 -// down to 1 is a lower pitch. 150 to 70 is the realistic range. -// EMIT_SOUND_DYN with pitch != 100 should be used sparingly, as it's not quite as -// fast as EMIT_SOUND (the pitchshift mixer is not native coded). - -void EMIT_SOUND_DYN(edict_t *entity, int channel, const char *sample, float volume, float attenuation, - int flags, int pitch); - - -inline void EMIT_SOUND(edict_t *entity, int channel, const char *sample, float volume, float attenuation) -{ - EMIT_SOUND_DYN(entity, channel, sample, volume, attenuation, 0, PITCH_NORM); -} - -inline void STOP_SOUND(edict_t *entity, int channel, const char *sample) -{ - EMIT_SOUND_DYN(entity, channel, sample, 0, 0, SND_STOP, PITCH_NORM); -} - -void EMIT_SOUND_SUIT(edict_t *entity, const char *sample); -void EMIT_GROUPID_SUIT(edict_t *entity, int isentenceg); -void EMIT_GROUPNAME_SUIT(edict_t *entity, const char *groupname); - -#define PRECACHE_SOUND_ARRAY( a ) \ - { for (int i = 0; i < ARRAYSIZE( a ); i++ ) PRECACHE_SOUND((char *) a [i]); } - -#define EMIT_SOUND_ARRAY_DYN( chan, array ) \ - EMIT_SOUND_DYN ( ENT(pev), chan , array [ RANDOM_LONG(0,ARRAYSIZE( array )-1) ], 1.0, ATTN_NORM, 0, RANDOM_LONG(95,105) ); - -#define RANDOM_SOUND_ARRAY( array ) (array) [ RANDOM_LONG(0,ARRAYSIZE( (array) )-1) ] - -#define PLAYBACK_EVENT( flags, who, index ) PLAYBACK_EVENT_FULL( flags, who, index, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0 ); -#define PLAYBACK_EVENT_DELAY( flags, who, index, delay ) PLAYBACK_EVENT_FULL( flags, who, index, delay, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0 ); - -#define GROUP_OP_AND 0 -#define GROUP_OP_NAND 1 - -extern int g_groupmask; -extern int g_groupop; - -class UTIL_GroupTrace -{ -public: - UTIL_GroupTrace( int groupmask, int op ); - ~UTIL_GroupTrace( void ); - -private: - int m_oldgroupmask, m_oldgroupop; -}; - -void UTIL_SetGroupTrace( int groupmask, int op ); -void UTIL_UnsetGroupTrace( void ); - -int UTIL_SharedRandomLong( unsigned int seed, int low, int high ); -float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ); - -float UTIL_WeaponTimeBase( void ); +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#include "archtypes.h" // DAL + +// +// Misc utility code +// +#ifndef ACTIVITY_H +#include "activity.h" +#endif + +#ifndef ENGINECALLBACK_H +#include "enginecallback.h" +#endif +inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent ); // implementation later in this file + +extern globalvars_t *gpGlobals; + +// Use this instead of ALLOC_STRING on constant strings +#define STRING(offset) ((const char *)(gpGlobals->pStringBase + (unsigned int)(offset))) +#define MAKE_STRING(str) ((uint64)(str) - (uint64)(STRING(0))) + +inline edict_t *FIND_ENTITY_BY_CLASSNAME(edict_t *entStart, const char *pszName) +{ + return FIND_ENTITY_BY_STRING(entStart, "classname", pszName); +} + +inline edict_t *FIND_ENTITY_BY_TARGETNAME(edict_t *entStart, const char *pszName) +{ + return FIND_ENTITY_BY_STRING(entStart, "targetname", pszName); +} + +// for doing a reverse lookup. Say you have a door, and want to find its button. +inline edict_t *FIND_ENTITY_BY_TARGET(edict_t *entStart, const char *pszName) +{ + return FIND_ENTITY_BY_STRING(entStart, "target", pszName); +} + +// Keeps clutter down a bit, when writing key-value pairs +#define WRITEKEY_INT(pf, szKeyName, iKeyValue) ENGINE_FPRINTF(pf, "\"%s\" \"%d\"\n", szKeyName, iKeyValue) +#define WRITEKEY_FLOAT(pf, szKeyName, flKeyValue) \ + ENGINE_FPRINTF(pf, "\"%s\" \"%f\"\n", szKeyName, flKeyValue) +#define WRITEKEY_STRING(pf, szKeyName, szKeyValue) \ + ENGINE_FPRINTF(pf, "\"%s\" \"%s\"\n", szKeyName, szKeyValue) +#define WRITEKEY_VECTOR(pf, szKeyName, flX, flY, flZ) \ + ENGINE_FPRINTF(pf, "\"%s\" \"%f %f %f\"\n", szKeyName, flX, flY, flZ) + +// Keeps clutter down a bit, when using a float as a bit-vector +#define SetBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) | (bits)) +#define ClearBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) & ~(bits)) +#define FBitSet(flBitVector, bit) ((int)(flBitVector) & (bit)) + +// Makes these more explicit, and easier to find +#define FILE_GLOBAL static +#define DLL_GLOBAL + +// Until we figure out why "const" gives the compiler problems, we'll just have to use +// this bogus "empty" define to mark things as constant. +#define CONSTANT + +// More explicit than "int" +typedef int EOFFSET; + +// In case it's not alread defined +typedef int BOOL; + +// In case this ever changes +#define M_PI 3.14159265358979323846 + +// Keeps clutter down a bit, when declaring external entity/global method prototypes +#define DECLARE_GLOBAL_METHOD(MethodName) extern void UTIL_DLLEXPORT MethodName( void ) +#define GLOBAL_METHOD(funcname) void UTIL_DLLEXPORT funcname(void) + +#ifndef UTIL_DLLEXPORT +#ifdef _WIN32 +#define UTIL_DLLEXPORT _declspec( dllexport ) EXT_FUNC +#else +#define UTIL_DLLEXPORT __attribute__ ((visibility("default"))) EXT_FUNC +#endif +#endif + +// This is the glue that hooks .MAP entity class names to our CPP classes +// The _declspec forces them to be exported by name so we can do a lookup with GetProcAddress() +// The function is used to intialize / allocate the object for the entity +#define LINK_ENTITY_TO_CLASS(mapClassName,DLLClassName) \ + extern "C" UTIL_DLLEXPORT void mapClassName( entvars_t *pev ); \ + void mapClassName( entvars_t *pev ) { GetClassPtr( (DLLClassName *)pev ); } + + +// +// Conversion among the three types of "entity", including identity-conversions. +// +#ifdef DEBUG + extern edict_t *DBG_EntOfVars(const entvars_t *pev); + inline edict_t *ENT(const entvars_t *pev) { return DBG_EntOfVars(pev); } +#else + inline edict_t *ENT(const entvars_t *pev) { return pev->pContainingEntity; } +#endif +inline edict_t *ENT(edict_t *pent) { return pent; } +inline edict_t *ENT(EOFFSET eoffset) { return (*g_engfuncs.pfnPEntityOfEntOffset)(eoffset); } +inline EOFFSET OFFSET(EOFFSET eoffset) { return eoffset; } +inline EOFFSET OFFSET(const edict_t *pent) +{ +#if _DEBUG + if ( !pent ) + ALERT( at_error, "Bad ent in OFFSET()\n" ); +#endif + return (*g_engfuncs.pfnEntOffsetOfPEntity)(pent); +} +inline EOFFSET OFFSET(entvars_t *pev) +{ +#if _DEBUG + if ( !pev ) + ALERT( at_error, "Bad pev in OFFSET()\n" ); +#endif + return OFFSET(ENT(pev)); +} +inline entvars_t *VARS(entvars_t *pev) { return pev; } + +inline entvars_t *VARS(edict_t *pent) +{ + if ( !pent ) + return NULL; + + return &pent->v; +} + +inline entvars_t* VARS(EOFFSET eoffset) { return VARS(ENT(eoffset)); } +inline int ENTINDEX(edict_t *pEdict) { return (*g_engfuncs.pfnIndexOfEdict)(pEdict); } +inline edict_t* INDEXENT( int iEdictNum ) { return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum); } +inline void MESSAGE_BEGIN( int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent ) { + (*g_engfuncs.pfnMessageBegin)(msg_dest, msg_type, pOrigin, ENT(ent)); +} + +// Testing the three types of "entity" for nullity +#define eoNullEntity 0 +inline BOOL FNullEnt(EOFFSET eoffset) { return eoffset == 0; } +inline BOOL FNullEnt(const edict_t* pent) { return pent == NULL || FNullEnt(OFFSET(pent)); } +inline BOOL FNullEnt(entvars_t* pev) { return pev == NULL || FNullEnt(OFFSET(pev)); } + +// Testing strings for nullity +#define iStringNull 0 +inline BOOL FStringNull(int iString) { return iString == iStringNull; } + +#define cchMapNameMost 32 + +// Dot products for view cone checking +#define VIEW_FIELD_FULL (float)-1.0 // +-180 degrees +#define VIEW_FIELD_WIDE (float)-0.7 // +-135 degrees 0.1 // +-85 degrees, used for full FOV checks +#define VIEW_FIELD_NARROW (float)0.7 // +-45 degrees, more narrow check used to set up ranged attacks +#define VIEW_FIELD_ULTRA_NARROW (float)0.9 // +-25 degrees, more narrow check used to set up ranged attacks + +// All monsters need this data +#define DONT_BLEED -1 +#define BLOOD_COLOR_RED (BYTE)247 +#define BLOOD_COLOR_YELLOW (BYTE)195 +#define BLOOD_COLOR_GREEN BLOOD_COLOR_YELLOW + +typedef enum +{ + + MONSTERSTATE_NONE = 0, + MONSTERSTATE_IDLE, + MONSTERSTATE_COMBAT, + MONSTERSTATE_ALERT, + MONSTERSTATE_HUNT, + MONSTERSTATE_PRONE, + MONSTERSTATE_SCRIPT, + MONSTERSTATE_PLAYDEAD, + MONSTERSTATE_DEAD + +} MONSTERSTATE; + + + +// Things that toggle (buttons/triggers/doors) need this +typedef enum + { + TS_AT_TOP, + TS_AT_BOTTOM, + TS_GOING_UP, + TS_GOING_DOWN + } TOGGLE_STATE; + +// Misc useful +inline BOOL FStrEq(const char*sz1, const char*sz2) + { return (strcmp(sz1, sz2) == 0); } +inline BOOL FClassnameIs(edict_t* pent, const char* szClassname) + { return FStrEq(STRING(VARS(pent)->classname), szClassname); } +inline BOOL FClassnameIs(entvars_t* pev, const char* szClassname) + { return FStrEq(STRING(pev->classname), szClassname); } + +class CBaseEntity; + +// Misc. Prototypes +extern void UTIL_SetSize (entvars_t* pev, const Vector &vecMin, const Vector &vecMax); +extern float UTIL_VecToYaw (const Vector &vec); +extern Vector UTIL_VecToAngles (const Vector &vec); +extern float UTIL_AngleMod (float a); +extern float UTIL_AngleDiff ( float destAngle, float srcAngle ); + +extern CBaseEntity *UTIL_FindEntityInSphere(CBaseEntity *pStartEntity, const Vector &vecCenter, float flRadius); +extern CBaseEntity *UTIL_FindEntityByString(CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue ); +extern CBaseEntity *UTIL_FindEntityByClassname(CBaseEntity *pStartEntity, const char *szName ); +extern CBaseEntity *UTIL_FindEntityByTargetname(CBaseEntity *pStartEntity, const char *szName ); +extern CBaseEntity *UTIL_FindEntityGeneric(const char *szName, Vector &vecSrc, float flRadius ); + +// returns a CBaseEntity pointer to a player by index. Only returns if the player is spawned and connected +// otherwise returns NULL +// Index is 1 based +extern CBaseEntity *UTIL_PlayerByIndex( int playerIndex ); + +#define UTIL_EntitiesInPVS(pent) (*g_engfuncs.pfnEntitiesInPVS)(pent) +extern void UTIL_MakeVectors (const Vector &vecAngles); + +// Pass in an array of pointers and an array size, it fills the array and returns the number inserted +extern int UTIL_MonstersInSphere( CBaseEntity **pList, int listMax, const Vector ¢er, float radius ); +extern int UTIL_EntitiesInBox( CBaseEntity **pList, int listMax, const Vector &mins, const Vector &maxs, int flagMask ); + +inline void UTIL_MakeVectorsPrivate( const Vector &vecAngles, float *p_vForward, float *p_vRight, float *p_vUp ) +{ + g_engfuncs.pfnAngleVectors( vecAngles, p_vForward, p_vRight, p_vUp ); +} + +extern void UTIL_MakeAimVectors ( const Vector &vecAngles ); // like MakeVectors, but assumes pitch isn't inverted +extern void UTIL_MakeInvVectors ( const Vector &vec, globalvars_t *pgv ); + +extern void UTIL_SetOrigin ( entvars_t* pev, const Vector &vecOrigin ); +extern void UTIL_EmitAmbientSound ( edict_t *entity, const Vector &vecOrigin, const char *samp, float vol, float attenuation, int fFlags, int pitch ); +extern void UTIL_ParticleEffect ( const Vector &vecOrigin, const Vector &vecDirection, ULONG ulColor, ULONG ulCount ); +extern void UTIL_ScreenShake ( const Vector ¢er, float amplitude, float frequency, float duration, float radius ); +extern void UTIL_ScreenShakeAll ( const Vector ¢er, float amplitude, float frequency, float duration ); +extern void UTIL_ShowMessage ( const char *pString, CBaseEntity *pPlayer ); +extern void UTIL_ShowMessageAll ( const char *pString ); +extern void UTIL_ScreenFadeAll ( const Vector &color, float fadeTime, float holdTime, int alpha, int flags ); +extern void UTIL_ScreenFade ( CBaseEntity *pEntity, const Vector &color, float fadeTime, float fadeHold, int alpha, int flags ); + +typedef enum { ignore_monsters=1, dont_ignore_monsters=0, missile=2 } IGNORE_MONSTERS; +typedef enum { ignore_glass=1, dont_ignore_glass=0 } IGNORE_GLASS; +extern void UTIL_TraceLine (const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, edict_t *pentIgnore, TraceResult *ptr); +extern void UTIL_TraceLine (const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, IGNORE_GLASS ignoreGlass, edict_t *pentIgnore, TraceResult *ptr); +typedef enum { point_hull=0, human_hull=1, large_hull=2, head_hull=3 } __HLSDK_HULL_TYPE; +extern void UTIL_TraceHull (const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, int hullNumber, edict_t *pentIgnore, TraceResult *ptr); +extern TraceResult UTIL_GetGlobalTrace (void); +extern void UTIL_TraceModel (const Vector &vecStart, const Vector &vecEnd, int hullNumber, edict_t *pentModel, TraceResult *ptr); +extern Vector UTIL_GetAimVector (edict_t* pent, float flSpeed); +extern int UTIL_PointContents (const Vector &vec); + +extern int UTIL_IsMasterTriggered (string_t sMaster, CBaseEntity *pActivator); +extern void UTIL_BloodStream( const Vector &origin, const Vector &direction, int color, int amount ); +extern void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color, int amount ); +extern Vector UTIL_RandomBloodVector( void ); +extern BOOL UTIL_ShouldShowBlood( int bloodColor ); +extern void UTIL_BloodDecalTrace( TraceResult *pTrace, int bloodColor ); +extern void UTIL_DecalTrace( TraceResult *pTrace, int decalNumber ); +extern void UTIL_PlayerDecalTrace( TraceResult *pTrace, int playernum, int decalNumber, BOOL bIsCustom ); +extern void UTIL_GunshotDecalTrace( TraceResult *pTrace, int decalNumber ); +extern void UTIL_Sparks( const Vector &position ); +extern void UTIL_Ricochet( const Vector &position, float scale ); +extern void UTIL_StringToVector( float *pVector, const char *pString ); +extern void UTIL_StringToIntArray( int *pVector, int count, const char *pString ); +extern Vector UTIL_ClampVectorToBox( const Vector &input, const Vector &clampSize ); +extern float UTIL_Approach( float target, float value, float speed ); +extern float UTIL_ApproachAngle( float target, float value, float speed ); +extern float UTIL_AngleDistance( float next, float cur ); + +extern char *UTIL_VarArgs( char *format, ... ); +extern void UTIL_Remove( CBaseEntity *pEntity ); +extern BOOL UTIL_IsValidEntity( edict_t *pent ); +extern BOOL UTIL_TeamsMatch( const char *pTeamName1, const char *pTeamName2 ); + +// Use for ease-in, ease-out style interpolation (accel/decel) +extern float UTIL_SplineFraction( float value, float scale ); + +// Search for water transition along a vertical line +extern float UTIL_WaterLevel( const Vector &position, float minz, float maxz ); +extern void UTIL_Bubbles( Vector mins, Vector maxs, int count ); +extern void UTIL_BubbleTrail( Vector from, Vector to, int count ); + +// allows precacheing of other entities +extern void UTIL_PrecacheOther( const char *szClassname ); + +// prints a message to each client +extern void UTIL_ClientPrintAll( int msg_dest, const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL ); +inline void UTIL_CenterPrintAll( const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL ) +{ + UTIL_ClientPrintAll( HUD_PRINTCENTER, msg_name, param1, param2, param3, param4 ); +} + +class CBasePlayerItem; +class CBasePlayer; +extern BOOL UTIL_GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon ); + +// prints messages through the HUD +extern void ClientPrint( entvars_t *client, int msg_dest, const char *msg_name, const char *param1 = NULL, const char *param2 = NULL, const char *param3 = NULL, const char *param4 = NULL ); + +// prints a message to the HUD say (chat) +extern void UTIL_SayText( const char *pText, CBaseEntity *pEntity ); +extern void UTIL_SayTextAll( const char *pText, CBaseEntity *pEntity ); + + +typedef struct hudtextparms_s +{ + float x; + float y; + int effect; + byte r1, g1, b1, a1; + byte r2, g2, b2, a2; + float fadeinTime; + float fadeoutTime; + float holdTime; + float fxTime; + int channel; +} hudtextparms_t; + +// prints as transparent 'title' to the HUD +extern void UTIL_HudMessageAll( const hudtextparms_t &textparms, const char *pMessage ); +extern void UTIL_HudMessage( CBaseEntity *pEntity, const hudtextparms_t &textparms, const char *pMessage ); + +// for handy use with ClientPrint params +extern char *UTIL_dtos1( int d ); +extern char *UTIL_dtos2( int d ); +extern char *UTIL_dtos3( int d ); +extern char *UTIL_dtos4( int d ); + +// Writes message to console with timestamp and FragLog header. +extern void UTIL_LogPrintf( char *fmt, ... ); +extern void UTIL_ServerPrintf( const char *fmt, ... ); + +// Sorta like FInViewCone, but for nonmonsters. +extern float UTIL_DotPoints ( const Vector &vecSrc, const Vector &vecCheck, const Vector &vecDir ); + +extern void UTIL_StripToken( const char *pKey, char *pDest );// for redundant keynames + +// Misc functions +extern void SetMovedir(entvars_t* pev); +extern Vector VecBModelOrigin( entvars_t* pevBModel ); +extern int BuildChangeList( LEVELLIST *pLevelList, int maxList ); + +// +// How did I ever live without ASSERT? +// +#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) +#define ASSERTSZ(f, sz) DBG_AssertFunction(f, #f, __FILE__, __LINE__, sz) +#else // !DEBUG +#define ASSERT(f) +#define ASSERTSZ(f, sz) +#endif // !DEBUG + + +extern DLL_GLOBAL const Vector g_vecZero; + +// +// Constants that were used only by QC (maybe not used at all now) +// +// Un-comment only as needed +// +#define LANGUAGE_ENGLISH 0 +#define LANGUAGE_GERMAN 1 +#define LANGUAGE_FRENCH 2 +#define LANGUAGE_BRITISH 3 + +extern DLL_GLOBAL int g_Language; + +#define AMBIENT_SOUND_STATIC 0 // medium radius attenuation +#define AMBIENT_SOUND_EVERYWHERE 1 +#define AMBIENT_SOUND_SMALLRADIUS 2 +#define AMBIENT_SOUND_MEDIUMRADIUS 4 +#define AMBIENT_SOUND_LARGERADIUS 8 +#define AMBIENT_SOUND_START_SILENT 16 +#define AMBIENT_SOUND_NOT_LOOPING 32 + +#define SPEAKER_START_SILENT 1 // wait for trigger 'on' to start announcements + +#define SND_SPAWNING (1<<8) // duplicated in protocol.h we're spawing, used in some cases for ambients +#define SND_STOP (1<<5) // duplicated in protocol.h stop sound +#define SND_CHANGE_VOL (1<<6) // duplicated in protocol.h change sound vol +#define SND_CHANGE_PITCH (1<<7) // duplicated in protocol.h change sound pitch + +#define LFO_SQUARE 1 +#define LFO_TRIANGLE 2 +#define LFO_RANDOM 3 + +// func_rotating +#define SF_BRUSH_ROTATE_Y_AXIS 0 +#define SF_BRUSH_ROTATE_INSTANT 1 +#define SF_BRUSH_ROTATE_BACKWARDS 2 +#define SF_BRUSH_ROTATE_Z_AXIS 4 +#define SF_BRUSH_ROTATE_X_AXIS 8 +#define SF_PENDULUM_AUTO_RETURN 16 +#define SF_PENDULUM_PASSABLE 32 + + +#define SF_BRUSH_ROTATE_SMALLRADIUS 128 +#define SF_BRUSH_ROTATE_MEDIUMRADIUS 256 +#define SF_BRUSH_ROTATE_LARGERADIUS 512 + +#define PUSH_BLOCK_ONLY_X 1 +#define PUSH_BLOCK_ONLY_Y 2 + +#define VEC_HULL_MIN Vector(-16, -16, -36) +#define VEC_HULL_MAX Vector( 16, 16, 36) +#define VEC_HUMAN_HULL_MIN Vector( -16, -16, 0 ) +#define VEC_HUMAN_HULL_MAX Vector( 16, 16, 72 ) +#define VEC_HUMAN_HULL_DUCK Vector( 16, 16, 36 ) + +#define VEC_VIEW Vector( 0, 0, 28 ) + +#define VEC_DUCK_HULL_MIN Vector(-16, -16, -18 ) +#define VEC_DUCK_HULL_MAX Vector( 16, 16, 18) +#define VEC_DUCK_VIEW Vector( 0, 0, 12 ) + +#define SVC_TEMPENTITY 23 +#define SVC_INTERMISSION 30 +#define SVC_CDTRACK 32 +#define SVC_WEAPONANIM 35 +#define SVC_ROOMTYPE 37 +#define SVC_DIRECTOR 51 + + + +// triggers +#define SF_TRIGGER_ALLOWMONSTERS 1// monsters allowed to fire this trigger +#define SF_TRIGGER_NOCLIENTS 2// players not allowed to fire this trigger +#define SF_TRIGGER_PUSHABLES 4// only pushables can fire this trigger + +// func breakable +#define SF_BREAK_TRIGGER_ONLY 1// may only be broken by trigger +#define SF_BREAK_TOUCH 2// can be 'crashed through' by running player (plate glass) +#define SF_BREAK_PRESSURE 4// can be broken by a player standing on it +#define SF_BREAK_CROWBAR 256// instant break if hit with crowbar + +// func_pushable (it's also func_breakable, so don't collide with those flags) +#define SF_PUSH_BREAKABLE 128 + +#define SF_LIGHT_START_OFF 1 + +#define SPAWNFLAG_NOMESSAGE 1 +#define SPAWNFLAG_NOTOUCH 1 +#define SPAWNFLAG_DROIDONLY 4 + +#define SPAWNFLAG_USEONLY 1 // can't be touched, must be used (buttons) + +#define TELE_PLAYER_ONLY 1 +#define TELE_SILENT 2 + +#define SF_TRIG_PUSH_ONCE 1 + + +// Sound Utilities + +// sentence groups +#define CBSENTENCENAME_MAX 16 +#define CVOXFILESENTENCEMAX 1536 // max number of sentences in game. NOTE: this must match + // CVOXFILESENTENCEMAX in engine\sound.h!!! + +extern char gszallsentencenames[CVOXFILESENTENCEMAX][CBSENTENCENAME_MAX]; +extern int gcallsentences; + +int USENTENCEG_Pick(int isentenceg, char *szfound); +int USENTENCEG_PickSequential(int isentenceg, char *szfound, int ipick, int freset); +void USENTENCEG_InitLRU(unsigned char *plru, int count); + +void SENTENCEG_Init(); +void SENTENCEG_Stop(edict_t *entity, int isentenceg, int ipick); +int SENTENCEG_PlayRndI(edict_t *entity, int isentenceg, float volume, float attenuation, int flags, int pitch); +int SENTENCEG_PlayRndSz(edict_t *entity, const char *szrootname, float volume, float attenuation, int flags, int pitch); +int SENTENCEG_PlaySequentialSz(edict_t *entity, const char *szrootname, float volume, float attenuation, int flags, int pitch, int ipick, int freset); +int SENTENCEG_GetIndex(const char *szrootname); +int SENTENCEG_Lookup(const char *sample, char *sentencenum); + +void TEXTURETYPE_Init(); +char TEXTURETYPE_Find(char *name); +float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int iBulletType); + +// NOTE: use EMIT_SOUND_DYN to set the pitch of a sound. Pitch of 100 +// is no pitch shift. Pitch > 100 up to 255 is a higher pitch, pitch < 100 +// down to 1 is a lower pitch. 150 to 70 is the realistic range. +// EMIT_SOUND_DYN with pitch != 100 should be used sparingly, as it's not quite as +// fast as EMIT_SOUND (the pitchshift mixer is not native coded). + +void EMIT_SOUND_DYN(edict_t *entity, int channel, const char *sample, float volume, float attenuation, + int flags, int pitch); + + +inline void EMIT_SOUND(edict_t *entity, int channel, const char *sample, float volume, float attenuation) +{ + EMIT_SOUND_DYN(entity, channel, sample, volume, attenuation, 0, PITCH_NORM); +} + +inline void STOP_SOUND(edict_t *entity, int channel, const char *sample) +{ + EMIT_SOUND_DYN(entity, channel, sample, 0, 0, SND_STOP, PITCH_NORM); +} + +void EMIT_SOUND_SUIT(edict_t *entity, const char *sample); +void EMIT_GROUPID_SUIT(edict_t *entity, int isentenceg); +void EMIT_GROUPNAME_SUIT(edict_t *entity, const char *groupname); + +#define PRECACHE_SOUND_ARRAY( a ) \ + { for (int i = 0; i < ARRAYSIZE( a ); i++ ) PRECACHE_SOUND((char *) a [i]); } + +#define EMIT_SOUND_ARRAY_DYN( chan, array ) \ + EMIT_SOUND_DYN ( ENT(pev), chan , array [ RANDOM_LONG(0,ARRAYSIZE( array )-1) ], 1.0, ATTN_NORM, 0, RANDOM_LONG(95,105) ); + +#define RANDOM_SOUND_ARRAY( array ) (array) [ RANDOM_LONG(0,ARRAYSIZE( (array) )-1) ] + +#define PLAYBACK_EVENT( flags, who, index ) PLAYBACK_EVENT_FULL( flags, who, index, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0 ); +#define PLAYBACK_EVENT_DELAY( flags, who, index, delay ) PLAYBACK_EVENT_FULL( flags, who, index, delay, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0 ); + +#define GROUP_OP_AND 0 +#define GROUP_OP_NAND 1 + +extern int g_groupmask; +extern int g_groupop; + +class UTIL_GroupTrace +{ +public: + UTIL_GroupTrace( int groupmask, int op ); + ~UTIL_GroupTrace( void ); + +private: + int m_oldgroupmask, m_oldgroupop; +}; + +void UTIL_SetGroupTrace( int groupmask, int op ); +void UTIL_UnsetGroupTrace( void ); + +int UTIL_SharedRandomLong( unsigned int seed, int low, int high ); +float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ); + +float UTIL_WeaponTimeBase( void ); diff --git a/dep/rehlsdk/dlls/vector.h b/dep/rehlsdk/dlls/vector.h index 5d0d743..de8924f 100644 --- a/dep/rehlsdk/dlls/vector.h +++ b/dep/rehlsdk/dlls/vector.h @@ -1,113 +1,113 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#ifndef VECTOR_H -#define VECTOR_H - - -//========================================================= -// 2DVector - used for many pathfinding and many other -// operations that are treated as planar rather than 3d. -//========================================================= -class Vector2D -{ -public: - inline Vector2D(void): x(0.0), y(0.0) { } - inline Vector2D(float X, float Y): x(0.0), y(0.0) { x = X; y = Y; } - inline Vector2D operator+(const Vector2D& v) const { return Vector2D(x+v.x, y+v.y); } - inline Vector2D operator-(const Vector2D& v) const { return Vector2D(x-v.x, y-v.y); } - inline Vector2D operator*(float fl) const { return Vector2D(x*fl, y*fl); } - inline Vector2D operator/(float fl) const { return Vector2D(x/fl, y/fl); } - - inline float Length(void) const { return sqrt(x*x + y*y ); } - - inline Vector2D Normalize ( void ) const - { - // Vector2D vec2; - - float flLen = Length(); - if ( flLen == 0 ) - { - return Vector2D( 0, 0 ); - } - else - { - flLen = 1 / flLen; - return Vector2D( x * flLen, y * flLen ); - } - } - - vec_t x, y; -}; - -inline float DotProduct(const Vector2D& a, const Vector2D& b) { return( a.x*b.x + a.y*b.y ); } -inline Vector2D operator*(float fl, const Vector2D& v) { return v * fl; } - -//========================================================= -// 3D Vector -//========================================================= -class Vector // same data-layout as engine's vec3_t, -{ // which is a vec_t[3] -public: - // Construction/destruction - inline Vector(void): x(0.0), y(0.0), z(0.0) { } - inline Vector(float X, float Y, float Z): x(0.0), y(0.0), z(0.0) { x = X; y = Y; z = Z; } - //inline Vector(double X, double Y, double Z) { x = (float)X; y = (float)Y; z = (float)Z; } - //inline Vector(int X, int Y, int Z) { x = (float)X; y = (float)Y; z = (float)Z; } - inline Vector(const Vector& v): x(0.0), y(0.0), z(0.0) { x = v.x; y = v.y; z = v.z; } - inline Vector(float rgfl[3]): x(0.0), y(0.0), z(0.0) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; } - - // Operators - inline Vector operator-(void) const { return Vector(-x,-y,-z); } - inline int operator==(const Vector& v) const { return x==v.x && y==v.y && z==v.z; } - inline int operator!=(const Vector& v) const { return !(*this==v); } - inline Vector operator+(const Vector& v) const { return Vector(x+v.x, y+v.y, z+v.z); } - inline Vector operator-(const Vector& v) const { return Vector(x-v.x, y-v.y, z-v.z); } - inline Vector operator*(float fl) const { return Vector(x*fl, y*fl, z*fl); } - inline Vector operator/(float fl) const { return Vector(x/fl, y/fl, z/fl); } - - // Methods - inline void CopyToArray(float* rgfl) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; } - inline float Length(void) const { return sqrt(x*x + y*y + z*z); } - operator float *() { return &x; } // Vectors will now automatically convert to float * when needed - operator const float *() const { return &x; } // Vectors will now automatically convert to float * when needed - inline Vector Normalize(void) const - { - float flLen = Length(); - if (flLen == 0) return Vector(0,0,1); // ???? - flLen = 1 / flLen; - return Vector(x * flLen, y * flLen, z * flLen); - } - - inline Vector2D Make2D ( void ) const - { - Vector2D Vec2; - - Vec2.x = x; - Vec2.y = y; - - return Vec2; - } - inline float Length2D(void) const { return sqrt(x*x + y*y); } - - // Members - vec_t x, y, z; -}; - -inline Vector operator*(float fl, const Vector& v) { return v * fl; } -inline float DotProduct(const Vector& a, const Vector& b) { return(a.x*b.x+a.y*b.y+a.z*b.z); } -inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x ); } - -#endif +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +#ifndef VECTOR_H +#define VECTOR_H + + +//========================================================= +// 2DVector - used for many pathfinding and many other +// operations that are treated as planar rather than 3d. +//========================================================= +class Vector2D +{ +public: + inline Vector2D(void): x(0.0), y(0.0) { } + inline Vector2D(float X, float Y): x(0.0), y(0.0) { x = X; y = Y; } + inline Vector2D operator+(const Vector2D& v) const { return Vector2D(x+v.x, y+v.y); } + inline Vector2D operator-(const Vector2D& v) const { return Vector2D(x-v.x, y-v.y); } + inline Vector2D operator*(float fl) const { return Vector2D(x*fl, y*fl); } + inline Vector2D operator/(float fl) const { return Vector2D(x/fl, y/fl); } + + inline float Length(void) const { return sqrt(x*x + y*y ); } + + inline Vector2D Normalize ( void ) const + { + // Vector2D vec2; + + float flLen = Length(); + if ( flLen == 0 ) + { + return Vector2D( 0, 0 ); + } + else + { + flLen = 1 / flLen; + return Vector2D( x * flLen, y * flLen ); + } + } + + vec_t x, y; +}; + +inline float DotProduct(const Vector2D& a, const Vector2D& b) { return( a.x*b.x + a.y*b.y ); } +inline Vector2D operator*(float fl, const Vector2D& v) { return v * fl; } + +//========================================================= +// 3D Vector +//========================================================= +class Vector // same data-layout as engine's vec3_t, +{ // which is a vec_t[3] +public: + // Construction/destruction + inline Vector(void): x(0.0), y(0.0), z(0.0) { } + inline Vector(float X, float Y, float Z): x(0.0), y(0.0), z(0.0) { x = X; y = Y; z = Z; } + //inline Vector(double X, double Y, double Z) { x = (float)X; y = (float)Y; z = (float)Z; } + //inline Vector(int X, int Y, int Z) { x = (float)X; y = (float)Y; z = (float)Z; } + inline Vector(const Vector& v): x(0.0), y(0.0), z(0.0) { x = v.x; y = v.y; z = v.z; } + inline Vector(float rgfl[3]): x(0.0), y(0.0), z(0.0) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; } + + // Operators + inline Vector operator-(void) const { return Vector(-x,-y,-z); } + inline int operator==(const Vector& v) const { return x==v.x && y==v.y && z==v.z; } + inline int operator!=(const Vector& v) const { return !(*this==v); } + inline Vector operator+(const Vector& v) const { return Vector(x+v.x, y+v.y, z+v.z); } + inline Vector operator-(const Vector& v) const { return Vector(x-v.x, y-v.y, z-v.z); } + inline Vector operator*(float fl) const { return Vector(x*fl, y*fl, z*fl); } + inline Vector operator/(float fl) const { return Vector(x/fl, y/fl, z/fl); } + + // Methods + inline void CopyToArray(float* rgfl) const { rgfl[0] = x, rgfl[1] = y, rgfl[2] = z; } + inline float Length(void) const { return sqrt(x*x + y*y + z*z); } + operator float *() { return &x; } // Vectors will now automatically convert to float * when needed + operator const float *() const { return &x; } // Vectors will now automatically convert to float * when needed + inline Vector Normalize(void) const + { + float flLen = Length(); + if (flLen == 0) return Vector(0,0,1); // ???? + flLen = 1 / flLen; + return Vector(x * flLen, y * flLen, z * flLen); + } + + inline Vector2D Make2D ( void ) const + { + Vector2D Vec2; + + Vec2.x = x; + Vec2.y = y; + + return Vec2; + } + inline float Length2D(void) const { return sqrt(x*x + y*y); } + + // Members + vec_t x, y, z; +}; + +inline Vector operator*(float fl, const Vector& v) { return v * fl; } +inline float DotProduct(const Vector& a, const Vector& b) { return(a.x*b.x+a.y*b.y+a.z*b.z); } +inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x ); } + +#endif diff --git a/dep/rehlsdk/dlls/weapons.h b/dep/rehlsdk/dlls/weapons.h index 47ec6b9..be407f5 100644 --- a/dep/rehlsdk/dlls/weapons.h +++ b/dep/rehlsdk/dlls/weapons.h @@ -1,1019 +1,1019 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef WEAPONS_H -#define WEAPONS_H - -#include "effects.h" - -class CBasePlayer; -extern int gmsgWeapPickup; - -void DeactivateSatchels( CBasePlayer *pOwner ); - -// Contact Grenade / Timed grenade / Satchel Charge -class CGrenade : public CBaseMonster -{ -public: - void Spawn( void ); - - typedef enum { SATCHEL_DETONATE = 0, SATCHEL_RELEASE } SATCHELCODE; - - static CGrenade *ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time ); - static CGrenade *ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ); - static CGrenade *ShootSatchelCharge( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ); - static void UseSatchelCharges( entvars_t *pevOwner, SATCHELCODE code ); - - void Explode( Vector vecSrc, Vector vecAim ); - void Explode( TraceResult *pTrace, int bitsDamageType ); - void EXPORT Smoke( void ); - - void EXPORT BounceTouch( CBaseEntity *pOther ); - void EXPORT SlideTouch( CBaseEntity *pOther ); - void EXPORT ExplodeTouch( CBaseEntity *pOther ); - void EXPORT DangerSoundThink( void ); - void EXPORT PreDetonate( void ); - void EXPORT Detonate( void ); - void EXPORT DetonateUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void EXPORT TumbleThink( void ); - - virtual void BounceSound( void ); - virtual int BloodColor( void ) { return DONT_BLEED; } - virtual void Killed( entvars_t *pevAttacker, int iGib ); - - BOOL m_fRegisteredSound;// whether or not this grenade has issued its DANGER sound to the world sound list yet. -}; - - -// constant items -#define ITEM_HEALTHKIT 1 -#define ITEM_ANTIDOTE 2 -#define ITEM_SECURITY 3 -#define ITEM_BATTERY 4 - -#define WEAPON_NONE 0 -#define WEAPON_CROWBAR 1 -#define WEAPON_GLOCK 2 -#define WEAPON_PYTHON 3 -#define WEAPON_MP5 4 -#define WEAPON_CHAINGUN 5 -#define WEAPON_CROSSBOW 6 -#define WEAPON_SHOTGUN 7 -#define WEAPON_RPG 8 -#define WEAPON_GAUSS 9 -#define WEAPON_EGON 10 -#define WEAPON_HORNETGUN 11 -#define WEAPON_HANDGRENADE 12 -#define WEAPON_TRIPMINE 13 -#define WEAPON_SATCHEL 14 -#define WEAPON_SNARK 15 - -#define WEAPON_ALLWEAPONS (~(1<absmin = pev->origin + Vector(-16, -16, -5); - pev->absmax = pev->origin + Vector(16, 16, 28); - } - - void PrimaryAttack( void ); - BOOL Deploy( void ); - void Holster( int skiplocal = 0 ); - void WeaponIdle( void ); - - virtual BOOL UseDecrement( void ) - { -#if defined( CLIENT_WEAPONS ) - return TRUE; -#else - return FALSE; -#endif - } - -private: - unsigned short m_usTripFire; - -}; - -class CSqueak : public CBasePlayerWeapon -{ -public: - void Spawn( void ); - void Precache( void ); - int iItemSlot( void ) { return 5; } - int GetItemInfo(ItemInfo *p); - - void PrimaryAttack( void ); - void SecondaryAttack( void ); - BOOL Deploy( void ); - void Holster( int skiplocal = 0 ); - void WeaponIdle( void ); - int m_fJustThrown; - - virtual BOOL UseDecrement( void ) - { -#if defined( CLIENT_WEAPONS ) - return TRUE; -#else - return FALSE; -#endif - } - -private: - unsigned short m_usSnarkFire; -}; - - -#endif // WEAPONS_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef WEAPONS_H +#define WEAPONS_H + +#include "effects.h" + +class CBasePlayer; +extern int gmsgWeapPickup; + +void DeactivateSatchels( CBasePlayer *pOwner ); + +// Contact Grenade / Timed grenade / Satchel Charge +class CGrenade : public CBaseMonster +{ +public: + void Spawn( void ); + + typedef enum { SATCHEL_DETONATE = 0, SATCHEL_RELEASE } SATCHELCODE; + + static CGrenade *ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time ); + static CGrenade *ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ); + static CGrenade *ShootSatchelCharge( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity ); + static void UseSatchelCharges( entvars_t *pevOwner, SATCHELCODE code ); + + void Explode( Vector vecSrc, Vector vecAim ); + void Explode( TraceResult *pTrace, int bitsDamageType ); + void EXPORT Smoke( void ); + + void EXPORT BounceTouch( CBaseEntity *pOther ); + void EXPORT SlideTouch( CBaseEntity *pOther ); + void EXPORT ExplodeTouch( CBaseEntity *pOther ); + void EXPORT DangerSoundThink( void ); + void EXPORT PreDetonate( void ); + void EXPORT Detonate( void ); + void EXPORT DetonateUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void EXPORT TumbleThink( void ); + + virtual void BounceSound( void ); + virtual int BloodColor( void ) { return DONT_BLEED; } + virtual void Killed( entvars_t *pevAttacker, int iGib ); + + BOOL m_fRegisteredSound;// whether or not this grenade has issued its DANGER sound to the world sound list yet. +}; + + +// constant items +#define ITEM_HEALTHKIT 1 +#define ITEM_ANTIDOTE 2 +#define ITEM_SECURITY 3 +#define ITEM_BATTERY 4 + +#define WEAPON_NONE 0 +#define WEAPON_CROWBAR 1 +#define WEAPON_GLOCK 2 +#define WEAPON_PYTHON 3 +#define WEAPON_MP5 4 +#define WEAPON_CHAINGUN 5 +#define WEAPON_CROSSBOW 6 +#define WEAPON_SHOTGUN 7 +#define WEAPON_RPG 8 +#define WEAPON_GAUSS 9 +#define WEAPON_EGON 10 +#define WEAPON_HORNETGUN 11 +#define WEAPON_HANDGRENADE 12 +#define WEAPON_TRIPMINE 13 +#define WEAPON_SATCHEL 14 +#define WEAPON_SNARK 15 + +#define WEAPON_ALLWEAPONS (~(1<absmin = pev->origin + Vector(-16, -16, -5); + pev->absmax = pev->origin + Vector(16, 16, 28); + } + + void PrimaryAttack( void ); + BOOL Deploy( void ); + void Holster( int skiplocal = 0 ); + void WeaponIdle( void ); + + virtual BOOL UseDecrement( void ) + { +#if defined( CLIENT_WEAPONS ) + return TRUE; +#else + return FALSE; +#endif + } + +private: + unsigned short m_usTripFire; + +}; + +class CSqueak : public CBasePlayerWeapon +{ +public: + void Spawn( void ); + void Precache( void ); + int iItemSlot( void ) { return 5; } + int GetItemInfo(ItemInfo *p); + + void PrimaryAttack( void ); + void SecondaryAttack( void ); + BOOL Deploy( void ); + void Holster( int skiplocal = 0 ); + void WeaponIdle( void ); + int m_fJustThrown; + + virtual BOOL UseDecrement( void ) + { +#if defined( CLIENT_WEAPONS ) + return TRUE; +#else + return FALSE; +#endif + } + +private: + unsigned short m_usSnarkFire; +}; + + +#endif // WEAPONS_H diff --git a/dep/rehlsdk/engine/FlightRecorder.h b/dep/rehlsdk/engine/FlightRecorder.h index 19f5c65..66a6477 100644 --- a/dep/rehlsdk/engine/FlightRecorder.h +++ b/dep/rehlsdk/engine/FlightRecorder.h @@ -1,61 +1,61 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "archtypes.h" - -class IRehldsFlightRecorder -{ -public: - virtual ~IRehldsFlightRecorder() { } - - virtual uint16 RegisterMessage(const char* module, const char *message, unsigned int version, bool inOut) = 0; - - virtual void StartMessage(uint16 msg, bool entrance) = 0; - virtual void EndMessage(uint16 msg, bool entrance) = 0; - - virtual void WriteInt8(int8 v) = 0; - virtual void WriteUInt8(uint8 v) = 0; - - virtual void WriteInt16(int16 v) = 0; - virtual void WriteUInt16(uint16 v) = 0; - - virtual void WriteInt32(int32 v) = 0; - virtual void WriteUInt32(uint32 v) = 0; - - virtual void WriteInt64(int64 v) = 0; - virtual void WriteUInt64(uint64 v) = 0; - - virtual void WriteFloat(float v) = 0; - virtual void WriteDouble(double v) = 0; - - virtual void WriteString(const char* s) = 0; - - virtual void WriteBuffer(const void* data ,unsigned int len) = 0; - -}; +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ +#pragma once + +#include "archtypes.h" + +class IRehldsFlightRecorder +{ +public: + virtual ~IRehldsFlightRecorder() { } + + virtual uint16 RegisterMessage(const char* module, const char *message, unsigned int version, bool inOut) = 0; + + virtual void StartMessage(uint16 msg, bool entrance) = 0; + virtual void EndMessage(uint16 msg, bool entrance) = 0; + + virtual void WriteInt8(int8 v) = 0; + virtual void WriteUInt8(uint8 v) = 0; + + virtual void WriteInt16(int16 v) = 0; + virtual void WriteUInt16(uint16 v) = 0; + + virtual void WriteInt32(int32 v) = 0; + virtual void WriteUInt32(uint32 v) = 0; + + virtual void WriteInt64(int64 v) = 0; + virtual void WriteUInt64(uint64 v) = 0; + + virtual void WriteFloat(float v) = 0; + virtual void WriteDouble(double v) = 0; + + virtual void WriteString(const char* s) = 0; + + virtual void WriteBuffer(const void* data ,unsigned int len) = 0; + +}; diff --git a/dep/rehlsdk/engine/Sequence.h b/dep/rehlsdk/engine/Sequence.h index a321b84..6253018 100644 --- a/dep/rehlsdk/engine/Sequence.h +++ b/dep/rehlsdk/engine/Sequence.h @@ -1,201 +1,201 @@ -//--------------------------------------------------------------------------- -// -// S c r i p t e d S e q u e n c e s -// -//--------------------------------------------------------------------------- -#ifndef _INCLUDE_SEQUENCE_H_ -#define _INCLUDE_SEQUENCE_H_ - - -#ifndef _DEF_BYTE_ -typedef unsigned char byte; -#endif - -//--------------------------------------------------------------------------- -// client_textmessage_t -//--------------------------------------------------------------------------- -typedef struct client_textmessage_s -{ - 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; -} client_textmessage_t; - - -//-------------------------------------------------------------------------- -// sequenceDefaultBits_e -// -// Enumerated list of possible modifiers for a command. This enumeration -// is used in a bitarray controlling what modifiers are specified for a command. -//--------------------------------------------------------------------------- -enum sequenceModifierBits -{ - SEQUENCE_MODIFIER_EFFECT_BIT = (1 << 1), - SEQUENCE_MODIFIER_POSITION_BIT = (1 << 2), - SEQUENCE_MODIFIER_COLOR_BIT = (1 << 3), - SEQUENCE_MODIFIER_COLOR2_BIT = (1 << 4), - SEQUENCE_MODIFIER_FADEIN_BIT = (1 << 5), - SEQUENCE_MODIFIER_FADEOUT_BIT = (1 << 6), - SEQUENCE_MODIFIER_HOLDTIME_BIT = (1 << 7), - SEQUENCE_MODIFIER_FXTIME_BIT = (1 << 8), - SEQUENCE_MODIFIER_SPEAKER_BIT = (1 << 9), - SEQUENCE_MODIFIER_LISTENER_BIT = (1 << 10), - SEQUENCE_MODIFIER_TEXTCHANNEL_BIT = (1 << 11), -}; -typedef enum sequenceModifierBits sequenceModifierBits_e ; - - -//--------------------------------------------------------------------------- -// sequenceCommandEnum_e -// -// Enumerated sequence command types. -//--------------------------------------------------------------------------- -enum sequenceCommandEnum_ -{ - SEQUENCE_COMMAND_ERROR = -1, - SEQUENCE_COMMAND_PAUSE = 0, - SEQUENCE_COMMAND_FIRETARGETS, - SEQUENCE_COMMAND_KILLTARGETS, - SEQUENCE_COMMAND_TEXT, - SEQUENCE_COMMAND_SOUND, - SEQUENCE_COMMAND_GOSUB, - SEQUENCE_COMMAND_SENTENCE, - SEQUENCE_COMMAND_REPEAT, - SEQUENCE_COMMAND_SETDEFAULTS, - SEQUENCE_COMMAND_MODIFIER, - SEQUENCE_COMMAND_POSTMODIFIER, - SEQUENCE_COMMAND_NOOP, - - SEQUENCE_MODIFIER_EFFECT, - SEQUENCE_MODIFIER_POSITION, - SEQUENCE_MODIFIER_COLOR, - SEQUENCE_MODIFIER_COLOR2, - SEQUENCE_MODIFIER_FADEIN, - SEQUENCE_MODIFIER_FADEOUT, - SEQUENCE_MODIFIER_HOLDTIME, - SEQUENCE_MODIFIER_FXTIME, - SEQUENCE_MODIFIER_SPEAKER, - SEQUENCE_MODIFIER_LISTENER, - SEQUENCE_MODIFIER_TEXTCHANNEL, -}; -typedef enum sequenceCommandEnum_ sequenceCommandEnum_e; - - -//--------------------------------------------------------------------------- -// sequenceCommandType_e -// -// Typeerated sequence command types. -//--------------------------------------------------------------------------- -enum sequenceCommandType_ -{ - SEQUENCE_TYPE_COMMAND, - SEQUENCE_TYPE_MODIFIER, -}; -typedef enum sequenceCommandType_ sequenceCommandType_e; - - -//--------------------------------------------------------------------------- -// sequenceCommandMapping_s -// -// A mapping of a command enumerated-value to its name. -//--------------------------------------------------------------------------- -typedef struct sequenceCommandMapping_ sequenceCommandMapping_s; -struct sequenceCommandMapping_ -{ - sequenceCommandEnum_e commandEnum; - const char* commandName; - sequenceCommandType_e commandType; -}; - - -//--------------------------------------------------------------------------- -// sequenceCommandLine_s -// -// Structure representing a single command (usually 1 line) from a -// .SEQ file entry. -//--------------------------------------------------------------------------- -typedef struct sequenceCommandLine_ sequenceCommandLine_s; -struct sequenceCommandLine_ -{ - int commandType; // Specifies the type of command - client_textmessage_t clientMessage; // Text HUD message struct - char* speakerName; // Targetname of speaking entity - char* listenerName; // Targetname of entity being spoken to - char* soundFileName; // Name of sound file to play - char* sentenceName; // Name of sentences.txt to play - char* fireTargetNames; // List of targetnames to fire - char* killTargetNames; // List of targetnames to remove - float delay; // Seconds 'till next command - int repeatCount; // If nonzero, reset execution pointer to top of block (N times, -1 = infinite) - int textChannel; // Display channel on which text message is sent - int modifierBitField; // Bit field to specify what clientmessage fields are valid - sequenceCommandLine_s* nextCommandLine; // Next command (linked list) -}; - - -//--------------------------------------------------------------------------- -// sequenceEntry_s -// -// Structure representing a single command (usually 1 line) from a -// .SEQ file entry. -//--------------------------------------------------------------------------- -typedef struct sequenceEntry_ sequenceEntry_s; -struct sequenceEntry_ -{ - char* fileName; // Name of sequence file without .SEQ extension - char* entryName; // Name of entry label in file - sequenceCommandLine_s* firstCommand; // Linked list of commands in entry - sequenceEntry_s* nextEntry; // Next loaded entry - qboolean isGlobal; // Is entry retained over level transitions? -}; - - - -//--------------------------------------------------------------------------- -// sentenceEntry_s -// Structure representing a single sentence of a group from a .SEQ -// file entry. Sentences are identical to entries in sentences.txt, but -// can be unique per level and are loaded/unloaded with the level. -//--------------------------------------------------------------------------- -typedef struct sentenceEntry_ sentenceEntry_s; -struct sentenceEntry_ -{ - char* data; // sentence data (ie "We have hostiles" ) - sentenceEntry_s* nextEntry; // Next loaded entry - qboolean isGlobal; // Is entry retained over level transitions? - unsigned int index; // this entry's position in the file. -}; - -//-------------------------------------------------------------------------- -// sentenceGroupEntry_s -// Structure representing a group of sentences found in a .SEQ file. -// A sentence group is defined by all sentences with the same name, ignoring -// the number at the end of the sentence name. Groups enable a sentence -// to be picked at random across a group. -//-------------------------------------------------------------------------- -typedef struct sentenceGroupEntry_ sentenceGroupEntry_s; -struct sentenceGroupEntry_ -{ - char* groupName; // name of the group (ie CT_ALERT ) - unsigned int numSentences; // number of sentences in group - sentenceEntry_s* firstSentence; // head of linked list of sentences in group - sentenceGroupEntry_s* nextEntry; // next loaded group -}; - -//--------------------------------------------------------------------------- -// Function declarations -//--------------------------------------------------------------------------- -sequenceEntry_s* SequenceGet( const char* fileName, const char* entryName ); -void Sequence_ParseFile( const char* fileName, qboolean isGlobal ); -void Sequence_OnLevelLoad( const char* mapName ); -sentenceEntry_s* SequencePickSentence( const char *groupName, int pickMethod, int *picked ); - -#endif /* _INCLUDE_SEQUENCE_H_ */ +//--------------------------------------------------------------------------- +// +// S c r i p t e d S e q u e n c e s +// +//--------------------------------------------------------------------------- +#ifndef _INCLUDE_SEQUENCE_H_ +#define _INCLUDE_SEQUENCE_H_ + + +#ifndef _DEF_BYTE_ +typedef unsigned char byte; +#endif + +//--------------------------------------------------------------------------- +// client_textmessage_t +//--------------------------------------------------------------------------- +typedef struct client_textmessage_s +{ + 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; +} client_textmessage_t; + + +//-------------------------------------------------------------------------- +// sequenceDefaultBits_e +// +// Enumerated list of possible modifiers for a command. This enumeration +// is used in a bitarray controlling what modifiers are specified for a command. +//--------------------------------------------------------------------------- +enum sequenceModifierBits +{ + SEQUENCE_MODIFIER_EFFECT_BIT = (1 << 1), + SEQUENCE_MODIFIER_POSITION_BIT = (1 << 2), + SEQUENCE_MODIFIER_COLOR_BIT = (1 << 3), + SEQUENCE_MODIFIER_COLOR2_BIT = (1 << 4), + SEQUENCE_MODIFIER_FADEIN_BIT = (1 << 5), + SEQUENCE_MODIFIER_FADEOUT_BIT = (1 << 6), + SEQUENCE_MODIFIER_HOLDTIME_BIT = (1 << 7), + SEQUENCE_MODIFIER_FXTIME_BIT = (1 << 8), + SEQUENCE_MODIFIER_SPEAKER_BIT = (1 << 9), + SEQUENCE_MODIFIER_LISTENER_BIT = (1 << 10), + SEQUENCE_MODIFIER_TEXTCHANNEL_BIT = (1 << 11), +}; +typedef enum sequenceModifierBits sequenceModifierBits_e ; + + +//--------------------------------------------------------------------------- +// sequenceCommandEnum_e +// +// Enumerated sequence command types. +//--------------------------------------------------------------------------- +enum sequenceCommandEnum_ +{ + SEQUENCE_COMMAND_ERROR = -1, + SEQUENCE_COMMAND_PAUSE = 0, + SEQUENCE_COMMAND_FIRETARGETS, + SEQUENCE_COMMAND_KILLTARGETS, + SEQUENCE_COMMAND_TEXT, + SEQUENCE_COMMAND_SOUND, + SEQUENCE_COMMAND_GOSUB, + SEQUENCE_COMMAND_SENTENCE, + SEQUENCE_COMMAND_REPEAT, + SEQUENCE_COMMAND_SETDEFAULTS, + SEQUENCE_COMMAND_MODIFIER, + SEQUENCE_COMMAND_POSTMODIFIER, + SEQUENCE_COMMAND_NOOP, + + SEQUENCE_MODIFIER_EFFECT, + SEQUENCE_MODIFIER_POSITION, + SEQUENCE_MODIFIER_COLOR, + SEQUENCE_MODIFIER_COLOR2, + SEQUENCE_MODIFIER_FADEIN, + SEQUENCE_MODIFIER_FADEOUT, + SEQUENCE_MODIFIER_HOLDTIME, + SEQUENCE_MODIFIER_FXTIME, + SEQUENCE_MODIFIER_SPEAKER, + SEQUENCE_MODIFIER_LISTENER, + SEQUENCE_MODIFIER_TEXTCHANNEL, +}; +typedef enum sequenceCommandEnum_ sequenceCommandEnum_e; + + +//--------------------------------------------------------------------------- +// sequenceCommandType_e +// +// Typeerated sequence command types. +//--------------------------------------------------------------------------- +enum sequenceCommandType_ +{ + SEQUENCE_TYPE_COMMAND, + SEQUENCE_TYPE_MODIFIER, +}; +typedef enum sequenceCommandType_ sequenceCommandType_e; + + +//--------------------------------------------------------------------------- +// sequenceCommandMapping_s +// +// A mapping of a command enumerated-value to its name. +//--------------------------------------------------------------------------- +typedef struct sequenceCommandMapping_ sequenceCommandMapping_s; +struct sequenceCommandMapping_ +{ + sequenceCommandEnum_e commandEnum; + const char* commandName; + sequenceCommandType_e commandType; +}; + + +//--------------------------------------------------------------------------- +// sequenceCommandLine_s +// +// Structure representing a single command (usually 1 line) from a +// .SEQ file entry. +//--------------------------------------------------------------------------- +typedef struct sequenceCommandLine_ sequenceCommandLine_s; +struct sequenceCommandLine_ +{ + int commandType; // Specifies the type of command + client_textmessage_t clientMessage; // Text HUD message struct + char* speakerName; // Targetname of speaking entity + char* listenerName; // Targetname of entity being spoken to + char* soundFileName; // Name of sound file to play + char* sentenceName; // Name of sentences.txt to play + char* fireTargetNames; // List of targetnames to fire + char* killTargetNames; // List of targetnames to remove + float delay; // Seconds 'till next command + int repeatCount; // If nonzero, reset execution pointer to top of block (N times, -1 = infinite) + int textChannel; // Display channel on which text message is sent + int modifierBitField; // Bit field to specify what clientmessage fields are valid + sequenceCommandLine_s* nextCommandLine; // Next command (linked list) +}; + + +//--------------------------------------------------------------------------- +// sequenceEntry_s +// +// Structure representing a single command (usually 1 line) from a +// .SEQ file entry. +//--------------------------------------------------------------------------- +typedef struct sequenceEntry_ sequenceEntry_s; +struct sequenceEntry_ +{ + char* fileName; // Name of sequence file without .SEQ extension + char* entryName; // Name of entry label in file + sequenceCommandLine_s* firstCommand; // Linked list of commands in entry + sequenceEntry_s* nextEntry; // Next loaded entry + qboolean isGlobal; // Is entry retained over level transitions? +}; + + + +//--------------------------------------------------------------------------- +// sentenceEntry_s +// Structure representing a single sentence of a group from a .SEQ +// file entry. Sentences are identical to entries in sentences.txt, but +// can be unique per level and are loaded/unloaded with the level. +//--------------------------------------------------------------------------- +typedef struct sentenceEntry_ sentenceEntry_s; +struct sentenceEntry_ +{ + char* data; // sentence data (ie "We have hostiles" ) + sentenceEntry_s* nextEntry; // Next loaded entry + qboolean isGlobal; // Is entry retained over level transitions? + unsigned int index; // this entry's position in the file. +}; + +//-------------------------------------------------------------------------- +// sentenceGroupEntry_s +// Structure representing a group of sentences found in a .SEQ file. +// A sentence group is defined by all sentences with the same name, ignoring +// the number at the end of the sentence name. Groups enable a sentence +// to be picked at random across a group. +//-------------------------------------------------------------------------- +typedef struct sentenceGroupEntry_ sentenceGroupEntry_s; +struct sentenceGroupEntry_ +{ + char* groupName; // name of the group (ie CT_ALERT ) + unsigned int numSentences; // number of sentences in group + sentenceEntry_s* firstSentence; // head of linked list of sentences in group + sentenceGroupEntry_s* nextEntry; // next loaded group +}; + +//--------------------------------------------------------------------------- +// Function declarations +//--------------------------------------------------------------------------- +sequenceEntry_s* SequenceGet( const char* fileName, const char* entryName ); +void Sequence_ParseFile( const char* fileName, qboolean isGlobal ); +void Sequence_OnLevelLoad( const char* mapName ); +sentenceEntry_s* SequencePickSentence( const char *groupName, int pickMethod, int *picked ); + +#endif /* _INCLUDE_SEQUENCE_H_ */ diff --git a/dep/rehlsdk/engine/archtypes.h b/dep/rehlsdk/engine/archtypes.h index f3f6a71..e528a6d 100644 --- a/dep/rehlsdk/engine/archtypes.h +++ b/dep/rehlsdk/engine/archtypes.h @@ -1,66 +1,66 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/#ifndef ARCHTYPES_H -#define ARCHTYPES_H - -#ifdef __x86_64__ -#define X64BITS -#endif - -#if defined( _WIN32 ) && (! defined( __MINGW32__ )) - -typedef __int8 int8; -typedef unsigned __int8 uint8; -typedef __int16 int16; -typedef unsigned __int16 uint16; -typedef __int32 int32; -typedef unsigned __int32 uint32; -typedef __int64 int64; -typedef unsigned __int64 uint64; -typedef __int32 intp; // intp is an integer that can accomodate a pointer -typedef unsigned __int32 uintp; // (ie, sizeof(intp) >= sizeof(int) && sizeof(intp) >= sizeof(void *) - -#else /* _WIN32 */ -typedef char int8; -typedef unsigned char uint8; -typedef short int16; -typedef unsigned short uint16; -typedef int int32; -typedef unsigned int uint32; -typedef long long int64; -typedef unsigned long long uint64; -#ifdef X64BITS -typedef long long intp; -typedef unsigned long long uintp; -#else -typedef int intp; -typedef unsigned int uintp; -#endif - -#endif /* else _WIN32 */ - -#endif /* ARCHTYPES_H */ +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/#ifndef ARCHTYPES_H +#define ARCHTYPES_H + +#ifdef __x86_64__ +#define X64BITS +#endif + +#if defined( _WIN32 ) && (! defined( __MINGW32__ )) + +typedef __int8 int8; +typedef unsigned __int8 uint8; +typedef __int16 int16; +typedef unsigned __int16 uint16; +typedef __int32 int32; +typedef unsigned __int32 uint32; +typedef __int64 int64; +typedef unsigned __int64 uint64; +typedef __int32 intp; // intp is an integer that can accomodate a pointer +typedef unsigned __int32 uintp; // (ie, sizeof(intp) >= sizeof(int) && sizeof(intp) >= sizeof(void *) + +#else /* _WIN32 */ +typedef char int8; +typedef unsigned char uint8; +typedef short int16; +typedef unsigned short uint16; +typedef int int32; +typedef unsigned int uint32; +typedef long long int64; +typedef unsigned long long uint64; +#ifdef X64BITS +typedef long long intp; +typedef unsigned long long uintp; +#else +typedef int intp; +typedef unsigned int uintp; +#endif + +#endif /* else _WIN32 */ + +#endif /* ARCHTYPES_H */ diff --git a/dep/rehlsdk/engine/bspfile.h b/dep/rehlsdk/engine/bspfile.h index 3c4dfee..b6d498c 100644 --- a/dep/rehlsdk/engine/bspfile.h +++ b/dep/rehlsdk/engine/bspfile.h @@ -1,160 +1,160 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -// header -#define Q1BSP_VERSION 29 // quake1 regular version (beta is 28) -#define HLBSP_VERSION 30 // half-life regular version - -#define MAX_MAP_HULLS 4 - -#define CONTENTS_ORIGIN -7 // removed at csg time -#define CONTENTS_CLIP -8 // changed to contents_solid -#define CONTENTS_CURRENT_0 -9 -#define CONTENTS_CURRENT_90 -10 -#define CONTENTS_CURRENT_180 -11 -#define CONTENTS_CURRENT_270 -12 -#define CONTENTS_CURRENT_UP -13 -#define CONTENTS_CURRENT_DOWN -14 - -#define CONTENTS_TRANSLUCENT -15 - -#define LUMP_ENTITIES 0 -#define LUMP_PLANES 1 -#define LUMP_TEXTURES 2 -#define LUMP_VERTEXES 3 -#define LUMP_VISIBILITY 4 -#define LUMP_NODES 5 -#define LUMP_TEXINFO 6 -#define LUMP_FACES 7 -#define LUMP_LIGHTING 8 -#define LUMP_CLIPNODES 9 -#define LUMP_LEAFS 10 -#define LUMP_MARKSURFACES 11 -#define LUMP_EDGES 12 -#define LUMP_SURFEDGES 13 -#define LUMP_MODELS 14 - -#define HEADER_LUMPS 15 - -typedef struct lump_s -{ - int fileofs; - int filelen; -} lump_t; - -typedef struct dmodel_s -{ - float mins[3], maxs[3]; - float origin[3]; - int headnode[MAX_MAP_HULLS]; - int visleafs; // not including the solid leaf 0 - int firstface, numfaces; -} dmodel_t; - -typedef struct dheader_s -{ - int version; - lump_t lumps[15]; -} dheader_t; - -typedef struct dmiptexlump_s -{ - int _nummiptex; - int dataofs[4]; -} dmiptexlump_t; - -typedef struct miptex_s -{ - char name[16]; - unsigned width; - unsigned height; - unsigned offsets[4]; -} miptex_t; - -typedef struct dvertex_s -{ - float point[3]; -} dvertex_t; - -typedef struct dplane_s -{ - float normal[3]; - float dist; - int type; -} dplane_t; - -typedef struct dnode_s -{ - int planenum; - short children[2]; - short mins[3]; - short maxs[3]; - unsigned short firstface; - unsigned short numfaces; -} dnode_t; - -typedef struct dclipnode_s -{ - int planenum; - short children[2]; // negative numbers are contents -} dclipnode_t; - -typedef struct texinfo_s -{ - float vecs[2][4]; - int _miptex; - int flags; -} texinfo_t; - -typedef struct dedge_s -{ - unsigned short v[2]; -} dedge_t; - -typedef struct dface_s -{ - short planenum; - short side; - int firstedge; - short numedges; - short texinfo; - byte styles[4]; - int lightofs; -} dface_t; - -typedef struct dleaf_s -{ - int contents; - int visofs; - short mins[3]; - short maxs[3]; - unsigned short firstmarksurface; - unsigned short nummarksurfaces; - byte ambient_level[4]; -} dleaf_t; +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ +#pragma once + +// header +#define Q1BSP_VERSION 29 // quake1 regular version (beta is 28) +#define HLBSP_VERSION 30 // half-life regular version + +#define MAX_MAP_HULLS 4 + +#define CONTENTS_ORIGIN -7 // removed at csg time +#define CONTENTS_CLIP -8 // changed to contents_solid +#define CONTENTS_CURRENT_0 -9 +#define CONTENTS_CURRENT_90 -10 +#define CONTENTS_CURRENT_180 -11 +#define CONTENTS_CURRENT_270 -12 +#define CONTENTS_CURRENT_UP -13 +#define CONTENTS_CURRENT_DOWN -14 + +#define CONTENTS_TRANSLUCENT -15 + +#define LUMP_ENTITIES 0 +#define LUMP_PLANES 1 +#define LUMP_TEXTURES 2 +#define LUMP_VERTEXES 3 +#define LUMP_VISIBILITY 4 +#define LUMP_NODES 5 +#define LUMP_TEXINFO 6 +#define LUMP_FACES 7 +#define LUMP_LIGHTING 8 +#define LUMP_CLIPNODES 9 +#define LUMP_LEAFS 10 +#define LUMP_MARKSURFACES 11 +#define LUMP_EDGES 12 +#define LUMP_SURFEDGES 13 +#define LUMP_MODELS 14 + +#define HEADER_LUMPS 15 + +typedef struct lump_s +{ + int fileofs; + int filelen; +} lump_t; + +typedef struct dmodel_s +{ + float mins[3], maxs[3]; + float origin[3]; + int headnode[MAX_MAP_HULLS]; + int visleafs; // not including the solid leaf 0 + int firstface, numfaces; +} dmodel_t; + +typedef struct dheader_s +{ + int version; + lump_t lumps[15]; +} dheader_t; + +typedef struct dmiptexlump_s +{ + int _nummiptex; + int dataofs[4]; +} dmiptexlump_t; + +typedef struct miptex_s +{ + char name[16]; + unsigned width; + unsigned height; + unsigned offsets[4]; +} miptex_t; + +typedef struct dvertex_s +{ + float point[3]; +} dvertex_t; + +typedef struct dplane_s +{ + float normal[3]; + float dist; + int type; +} dplane_t; + +typedef struct dnode_s +{ + int planenum; + short children[2]; + short mins[3]; + short maxs[3]; + unsigned short firstface; + unsigned short numfaces; +} dnode_t; + +typedef struct dclipnode_s +{ + int planenum; + short children[2]; // negative numbers are contents +} dclipnode_t; + +typedef struct texinfo_s +{ + float vecs[2][4]; + int _miptex; + int flags; +} texinfo_t; + +typedef struct dedge_s +{ + unsigned short v[2]; +} dedge_t; + +typedef struct dface_s +{ + short planenum; + short side; + int firstedge; + short numedges; + short texinfo; + byte styles[4]; + int lightofs; +} dface_t; + +typedef struct dleaf_s +{ + int contents; + int visofs; + short mins[3]; + short maxs[3]; + unsigned short firstmarksurface; + unsigned short nummarksurfaces; + byte ambient_level[4]; +} dleaf_t; diff --git a/dep/rehlsdk/engine/cmd_rehlds.h b/dep/rehlsdk/engine/cmd_rehlds.h index 9337575..003cb60 100644 --- a/dep/rehlsdk/engine/cmd_rehlds.h +++ b/dep/rehlsdk/engine/cmd_rehlds.h @@ -1,49 +1,49 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "archtypes.h" - -typedef void(*xcommand_t)(void); -typedef struct cmd_function_s -{ - struct cmd_function_s *next; - const char *name; - xcommand_t function; - int flags; -} cmd_function_t; - -typedef enum cmd_source_s -{ - src_client = 0, // came in over a net connection as a clc_stringcmd. host_client will be valid during this state. - src_command = 1, // from the command buffer. -} cmd_source_t; - -#define FCMD_HUD_COMMAND BIT(0) -#define FCMD_GAME_COMMAND BIT(1) -#define FCMD_WRAPPER_COMMAND BIT(2) +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ +#pragma once + +#include "archtypes.h" + +typedef void(*xcommand_t)(void); +typedef struct cmd_function_s +{ + struct cmd_function_s *next; + const char *name; + xcommand_t function; + int flags; +} cmd_function_t; + +typedef enum cmd_source_s +{ + src_client = 0, // came in over a net connection as a clc_stringcmd. host_client will be valid during this state. + src_command = 1, // from the command buffer. +} cmd_source_t; + +#define FCMD_HUD_COMMAND BIT(0) +#define FCMD_GAME_COMMAND BIT(1) +#define FCMD_WRAPPER_COMMAND BIT(2) diff --git a/dep/rehlsdk/engine/common_rehlds.h b/dep/rehlsdk/engine/common_rehlds.h index 853ee68..64a5d18 100644 --- a/dep/rehlsdk/engine/common_rehlds.h +++ b/dep/rehlsdk/engine/common_rehlds.h @@ -1,78 +1,78 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "const.h" -#include "qlimits.h" - -#ifdef REHLDS_FIXES -#define COM_TOKEN_LEN 2048 -#else -#define COM_TOKEN_LEN 1024 -#endif - -// Don't allow overflow -#define SIZEBUF_CHECK_OVERFLOW 0 -#define SIZEBUF_ALLOW_OVERFLOW BIT(0) -#define SIZEBUF_OVERFLOWED BIT(1) - -#define MAX_NUM_ARGVS 50 -#define NUM_SAFE_ARGVS 7 - -#define COM_COPY_CHUNK_SIZE 1024 -#define COM_MAX_CMD_LINE 256 - -typedef struct sizebuf_s -{ - const char *buffername; - uint16 flags; - byte *data; - int maxsize; - int cursize; -} sizebuf_t; - -typedef struct downloadtime_s -{ - qboolean bUsed; - float fTime; - int nBytesRemaining; -} downloadtime_t; - -typedef struct incomingtransfer_s -{ - qboolean doneregistering; - int percent; - qboolean downloadrequested; - downloadtime_t rgStats[8]; - int nCurStat; - int nTotalSize; - int nTotalToTransfer; - int nRemainingToTransfer; - float fLastStatusUpdate; - qboolean custom; -} incomingtransfer_t; +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ +#pragma once + +#include "const.h" +#include "qlimits.h" + +#ifdef REHLDS_FIXES +#define COM_TOKEN_LEN 2048 +#else +#define COM_TOKEN_LEN 1024 +#endif + +// Don't allow overflow +#define SIZEBUF_CHECK_OVERFLOW 0 +#define SIZEBUF_ALLOW_OVERFLOW BIT(0) +#define SIZEBUF_OVERFLOWED BIT(1) + +#define MAX_NUM_ARGVS 50 +#define NUM_SAFE_ARGVS 7 + +#define COM_COPY_CHUNK_SIZE 1024 +#define COM_MAX_CMD_LINE 256 + +typedef struct sizebuf_s +{ + const char *buffername; + uint16 flags; + byte *data; + int maxsize; + int cursize; +} sizebuf_t; + +typedef struct downloadtime_s +{ + qboolean bUsed; + float fTime; + int nBytesRemaining; +} downloadtime_t; + +typedef struct incomingtransfer_s +{ + qboolean doneregistering; + int percent; + qboolean downloadrequested; + downloadtime_t rgStats[8]; + int nCurStat; + int nTotalSize; + int nTotalToTransfer; + int nRemainingToTransfer; + float fLastStatusUpdate; + qboolean custom; +} incomingtransfer_t; diff --git a/dep/rehlsdk/engine/crc32c.cpp b/dep/rehlsdk/engine/crc32c.cpp index 669fc81..7e09002 100644 --- a/dep/rehlsdk/engine/crc32c.cpp +++ b/dep/rehlsdk/engine/crc32c.cpp @@ -1,145 +1,145 @@ -/* -Copyright (C) 2010 by Ronnie Sahlberg -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. -You should have received a copy of the GNU Lesser General Public License -along with this program; if not, see . -*/ - -#include "crc32c.h" -#include "sys_shared.h" -#include "immintrin.h" - -/*****************************************************************/ -/* */ -/* CRC LOOKUP TABLE */ -/* ================ */ -/* The following CRC lookup table was generated automagically */ -/* by the Rocksoft^tm Model CRC Algorithm Table Generation */ -/* Program V1.0 using the following model parameters: */ -/* */ -/* Width : 4 bytes. */ -/* Poly : 0x1EDC6F41L */ -/* Reverse : TRUE. */ -/* */ -/* For more information on the Rocksoft^tm Model CRC Algorithm, */ -/* see the document titled "A Painless Guide to CRC Error */ -/* Detection Algorithms" by Ross Williams */ -/* (ross@guest.adelaide.edu.au.). This document is likely to be */ -/* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */ -/* */ -/*****************************************************************/ - -static uint32 crctable[256] = { - 0x00000000L, 0xF26B8303L, 0xE13B70F7L, 0x1350F3F4L, - 0xC79A971FL, 0x35F1141CL, 0x26A1E7E8L, 0xD4CA64EBL, - 0x8AD958CFL, 0x78B2DBCCL, 0x6BE22838L, 0x9989AB3BL, - 0x4D43CFD0L, 0xBF284CD3L, 0xAC78BF27L, 0x5E133C24L, - 0x105EC76FL, 0xE235446CL, 0xF165B798L, 0x030E349BL, - 0xD7C45070L, 0x25AFD373L, 0x36FF2087L, 0xC494A384L, - 0x9A879FA0L, 0x68EC1CA3L, 0x7BBCEF57L, 0x89D76C54L, - 0x5D1D08BFL, 0xAF768BBCL, 0xBC267848L, 0x4E4DFB4BL, - 0x20BD8EDEL, 0xD2D60DDDL, 0xC186FE29L, 0x33ED7D2AL, - 0xE72719C1L, 0x154C9AC2L, 0x061C6936L, 0xF477EA35L, - 0xAA64D611L, 0x580F5512L, 0x4B5FA6E6L, 0xB93425E5L, - 0x6DFE410EL, 0x9F95C20DL, 0x8CC531F9L, 0x7EAEB2FAL, - 0x30E349B1L, 0xC288CAB2L, 0xD1D83946L, 0x23B3BA45L, - 0xF779DEAEL, 0x05125DADL, 0x1642AE59L, 0xE4292D5AL, - 0xBA3A117EL, 0x4851927DL, 0x5B016189L, 0xA96AE28AL, - 0x7DA08661L, 0x8FCB0562L, 0x9C9BF696L, 0x6EF07595L, - 0x417B1DBCL, 0xB3109EBFL, 0xA0406D4BL, 0x522BEE48L, - 0x86E18AA3L, 0x748A09A0L, 0x67DAFA54L, 0x95B17957L, - 0xCBA24573L, 0x39C9C670L, 0x2A993584L, 0xD8F2B687L, - 0x0C38D26CL, 0xFE53516FL, 0xED03A29BL, 0x1F682198L, - 0x5125DAD3L, 0xA34E59D0L, 0xB01EAA24L, 0x42752927L, - 0x96BF4DCCL, 0x64D4CECFL, 0x77843D3BL, 0x85EFBE38L, - 0xDBFC821CL, 0x2997011FL, 0x3AC7F2EBL, 0xC8AC71E8L, - 0x1C661503L, 0xEE0D9600L, 0xFD5D65F4L, 0x0F36E6F7L, - 0x61C69362L, 0x93AD1061L, 0x80FDE395L, 0x72966096L, - 0xA65C047DL, 0x5437877EL, 0x4767748AL, 0xB50CF789L, - 0xEB1FCBADL, 0x197448AEL, 0x0A24BB5AL, 0xF84F3859L, - 0x2C855CB2L, 0xDEEEDFB1L, 0xCDBE2C45L, 0x3FD5AF46L, - 0x7198540DL, 0x83F3D70EL, 0x90A324FAL, 0x62C8A7F9L, - 0xB602C312L, 0x44694011L, 0x5739B3E5L, 0xA55230E6L, - 0xFB410CC2L, 0x092A8FC1L, 0x1A7A7C35L, 0xE811FF36L, - 0x3CDB9BDDL, 0xCEB018DEL, 0xDDE0EB2AL, 0x2F8B6829L, - 0x82F63B78L, 0x709DB87BL, 0x63CD4B8FL, 0x91A6C88CL, - 0x456CAC67L, 0xB7072F64L, 0xA457DC90L, 0x563C5F93L, - 0x082F63B7L, 0xFA44E0B4L, 0xE9141340L, 0x1B7F9043L, - 0xCFB5F4A8L, 0x3DDE77ABL, 0x2E8E845FL, 0xDCE5075CL, - 0x92A8FC17L, 0x60C37F14L, 0x73938CE0L, 0x81F80FE3L, - 0x55326B08L, 0xA759E80BL, 0xB4091BFFL, 0x466298FCL, - 0x1871A4D8L, 0xEA1A27DBL, 0xF94AD42FL, 0x0B21572CL, - 0xDFEB33C7L, 0x2D80B0C4L, 0x3ED04330L, 0xCCBBC033L, - 0xA24BB5A6L, 0x502036A5L, 0x4370C551L, 0xB11B4652L, - 0x65D122B9L, 0x97BAA1BAL, 0x84EA524EL, 0x7681D14DL, - 0x2892ED69L, 0xDAF96E6AL, 0xC9A99D9EL, 0x3BC21E9DL, - 0xEF087A76L, 0x1D63F975L, 0x0E330A81L, 0xFC588982L, - 0xB21572C9L, 0x407EF1CAL, 0x532E023EL, 0xA145813DL, - 0x758FE5D6L, 0x87E466D5L, 0x94B49521L, 0x66DF1622L, - 0x38CC2A06L, 0xCAA7A905L, 0xD9F75AF1L, 0x2B9CD9F2L, - 0xFF56BD19L, 0x0D3D3E1AL, 0x1E6DCDEEL, 0xEC064EEDL, - 0xC38D26C4L, 0x31E6A5C7L, 0x22B65633L, 0xD0DDD530L, - 0x0417B1DBL, 0xF67C32D8L, 0xE52CC12CL, 0x1747422FL, - 0x49547E0BL, 0xBB3FFD08L, 0xA86F0EFCL, 0x5A048DFFL, - 0x8ECEE914L, 0x7CA56A17L, 0x6FF599E3L, 0x9D9E1AE0L, - 0xD3D3E1ABL, 0x21B862A8L, 0x32E8915CL, 0xC083125FL, - 0x144976B4L, 0xE622F5B7L, 0xF5720643L, 0x07198540L, - 0x590AB964L, 0xAB613A67L, 0xB831C993L, 0x4A5A4A90L, - 0x9E902E7BL, 0x6CFBAD78L, 0x7FAB5E8CL, 0x8DC0DD8FL, - 0xE330A81AL, 0x115B2B19L, 0x020BD8EDL, 0xF0605BEEL, - 0x24AA3F05L, 0xD6C1BC06L, 0xC5914FF2L, 0x37FACCF1L, - 0x69E9F0D5L, 0x9B8273D6L, 0x88D28022L, 0x7AB90321L, - 0xAE7367CAL, 0x5C18E4C9L, 0x4F48173DL, 0xBD23943EL, - 0xF36E6F75L, 0x0105EC76L, 0x12551F82L, 0xE03E9C81L, - 0x34F4F86AL, 0xC69F7B69L, 0xD5CF889DL, 0x27A40B9EL, - 0x79B737BAL, 0x8BDCB4B9L, 0x988C474DL, 0x6AE7C44EL, - 0xBE2DA0A5L, 0x4C4623A6L, 0x5F16D052L, 0xAD7D5351L -}; - -uint32 crc32c_t8_nosse(uint32 iCRC, uint8 u8) { - return (iCRC >> 8) ^ crctable[(iCRC ^ u8) & 0xFF]; -} - -uint32 crc32c_t_nosse(uint32 iCRC, const uint8 *buf, int len) { - uint32 crc = iCRC; - while (len-- > 0) { - crc = (crc >> 8) ^ crctable[(crc ^ (*buf++)) & 0xFF]; - } - return crc; -} - -FUNC_TARGET("sse4.2") -uint32 crc32c_t8_sse(uint32 iCRC, uint8 u8) { - return _mm_crc32_u8(iCRC, u8); -} - -FUNC_TARGET("sse4.2") -uint32 crc32c_t_sse(uint32 iCRC, const uint8 *buf, unsigned int len) { - uint32 crc32cval = iCRC; - unsigned int i = 0; - - for (; i < (len >> 2); i += 4) { - crc32cval = _mm_crc32_u32(crc32cval, *(uint32*)&buf[i]); - } - - for (; i < len; i++) { - crc32cval = _mm_crc32_u8(crc32cval, buf[i]); - } - - return crc32cval; -} - -uint32 crc32c_t(uint32 iCRC, const uint8 *buf, unsigned int len) { - return cpuinfo.sse4_2 ? crc32c_t_sse(iCRC, buf, len) : crc32c_t_nosse(iCRC, buf, len); -} - -uint32 crc32c(const uint8 *buf, int len) { - return crc32c_t(0xffffffff, buf, len); -} +/* +Copyright (C) 2010 by Ronnie Sahlberg +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. +You should have received a copy of the GNU Lesser General Public License +along with this program; if not, see . +*/ + +#include "crc32c.h" +#include "sys_shared.h" +#include "immintrin.h" + +/*****************************************************************/ +/* */ +/* CRC LOOKUP TABLE */ +/* ================ */ +/* The following CRC lookup table was generated automagically */ +/* by the Rocksoft^tm Model CRC Algorithm Table Generation */ +/* Program V1.0 using the following model parameters: */ +/* */ +/* Width : 4 bytes. */ +/* Poly : 0x1EDC6F41L */ +/* Reverse : TRUE. */ +/* */ +/* For more information on the Rocksoft^tm Model CRC Algorithm, */ +/* see the document titled "A Painless Guide to CRC Error */ +/* Detection Algorithms" by Ross Williams */ +/* (ross@guest.adelaide.edu.au.). This document is likely to be */ +/* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */ +/* */ +/*****************************************************************/ + +static uint32 crctable[256] = { + 0x00000000L, 0xF26B8303L, 0xE13B70F7L, 0x1350F3F4L, + 0xC79A971FL, 0x35F1141CL, 0x26A1E7E8L, 0xD4CA64EBL, + 0x8AD958CFL, 0x78B2DBCCL, 0x6BE22838L, 0x9989AB3BL, + 0x4D43CFD0L, 0xBF284CD3L, 0xAC78BF27L, 0x5E133C24L, + 0x105EC76FL, 0xE235446CL, 0xF165B798L, 0x030E349BL, + 0xD7C45070L, 0x25AFD373L, 0x36FF2087L, 0xC494A384L, + 0x9A879FA0L, 0x68EC1CA3L, 0x7BBCEF57L, 0x89D76C54L, + 0x5D1D08BFL, 0xAF768BBCL, 0xBC267848L, 0x4E4DFB4BL, + 0x20BD8EDEL, 0xD2D60DDDL, 0xC186FE29L, 0x33ED7D2AL, + 0xE72719C1L, 0x154C9AC2L, 0x061C6936L, 0xF477EA35L, + 0xAA64D611L, 0x580F5512L, 0x4B5FA6E6L, 0xB93425E5L, + 0x6DFE410EL, 0x9F95C20DL, 0x8CC531F9L, 0x7EAEB2FAL, + 0x30E349B1L, 0xC288CAB2L, 0xD1D83946L, 0x23B3BA45L, + 0xF779DEAEL, 0x05125DADL, 0x1642AE59L, 0xE4292D5AL, + 0xBA3A117EL, 0x4851927DL, 0x5B016189L, 0xA96AE28AL, + 0x7DA08661L, 0x8FCB0562L, 0x9C9BF696L, 0x6EF07595L, + 0x417B1DBCL, 0xB3109EBFL, 0xA0406D4BL, 0x522BEE48L, + 0x86E18AA3L, 0x748A09A0L, 0x67DAFA54L, 0x95B17957L, + 0xCBA24573L, 0x39C9C670L, 0x2A993584L, 0xD8F2B687L, + 0x0C38D26CL, 0xFE53516FL, 0xED03A29BL, 0x1F682198L, + 0x5125DAD3L, 0xA34E59D0L, 0xB01EAA24L, 0x42752927L, + 0x96BF4DCCL, 0x64D4CECFL, 0x77843D3BL, 0x85EFBE38L, + 0xDBFC821CL, 0x2997011FL, 0x3AC7F2EBL, 0xC8AC71E8L, + 0x1C661503L, 0xEE0D9600L, 0xFD5D65F4L, 0x0F36E6F7L, + 0x61C69362L, 0x93AD1061L, 0x80FDE395L, 0x72966096L, + 0xA65C047DL, 0x5437877EL, 0x4767748AL, 0xB50CF789L, + 0xEB1FCBADL, 0x197448AEL, 0x0A24BB5AL, 0xF84F3859L, + 0x2C855CB2L, 0xDEEEDFB1L, 0xCDBE2C45L, 0x3FD5AF46L, + 0x7198540DL, 0x83F3D70EL, 0x90A324FAL, 0x62C8A7F9L, + 0xB602C312L, 0x44694011L, 0x5739B3E5L, 0xA55230E6L, + 0xFB410CC2L, 0x092A8FC1L, 0x1A7A7C35L, 0xE811FF36L, + 0x3CDB9BDDL, 0xCEB018DEL, 0xDDE0EB2AL, 0x2F8B6829L, + 0x82F63B78L, 0x709DB87BL, 0x63CD4B8FL, 0x91A6C88CL, + 0x456CAC67L, 0xB7072F64L, 0xA457DC90L, 0x563C5F93L, + 0x082F63B7L, 0xFA44E0B4L, 0xE9141340L, 0x1B7F9043L, + 0xCFB5F4A8L, 0x3DDE77ABL, 0x2E8E845FL, 0xDCE5075CL, + 0x92A8FC17L, 0x60C37F14L, 0x73938CE0L, 0x81F80FE3L, + 0x55326B08L, 0xA759E80BL, 0xB4091BFFL, 0x466298FCL, + 0x1871A4D8L, 0xEA1A27DBL, 0xF94AD42FL, 0x0B21572CL, + 0xDFEB33C7L, 0x2D80B0C4L, 0x3ED04330L, 0xCCBBC033L, + 0xA24BB5A6L, 0x502036A5L, 0x4370C551L, 0xB11B4652L, + 0x65D122B9L, 0x97BAA1BAL, 0x84EA524EL, 0x7681D14DL, + 0x2892ED69L, 0xDAF96E6AL, 0xC9A99D9EL, 0x3BC21E9DL, + 0xEF087A76L, 0x1D63F975L, 0x0E330A81L, 0xFC588982L, + 0xB21572C9L, 0x407EF1CAL, 0x532E023EL, 0xA145813DL, + 0x758FE5D6L, 0x87E466D5L, 0x94B49521L, 0x66DF1622L, + 0x38CC2A06L, 0xCAA7A905L, 0xD9F75AF1L, 0x2B9CD9F2L, + 0xFF56BD19L, 0x0D3D3E1AL, 0x1E6DCDEEL, 0xEC064EEDL, + 0xC38D26C4L, 0x31E6A5C7L, 0x22B65633L, 0xD0DDD530L, + 0x0417B1DBL, 0xF67C32D8L, 0xE52CC12CL, 0x1747422FL, + 0x49547E0BL, 0xBB3FFD08L, 0xA86F0EFCL, 0x5A048DFFL, + 0x8ECEE914L, 0x7CA56A17L, 0x6FF599E3L, 0x9D9E1AE0L, + 0xD3D3E1ABL, 0x21B862A8L, 0x32E8915CL, 0xC083125FL, + 0x144976B4L, 0xE622F5B7L, 0xF5720643L, 0x07198540L, + 0x590AB964L, 0xAB613A67L, 0xB831C993L, 0x4A5A4A90L, + 0x9E902E7BL, 0x6CFBAD78L, 0x7FAB5E8CL, 0x8DC0DD8FL, + 0xE330A81AL, 0x115B2B19L, 0x020BD8EDL, 0xF0605BEEL, + 0x24AA3F05L, 0xD6C1BC06L, 0xC5914FF2L, 0x37FACCF1L, + 0x69E9F0D5L, 0x9B8273D6L, 0x88D28022L, 0x7AB90321L, + 0xAE7367CAL, 0x5C18E4C9L, 0x4F48173DL, 0xBD23943EL, + 0xF36E6F75L, 0x0105EC76L, 0x12551F82L, 0xE03E9C81L, + 0x34F4F86AL, 0xC69F7B69L, 0xD5CF889DL, 0x27A40B9EL, + 0x79B737BAL, 0x8BDCB4B9L, 0x988C474DL, 0x6AE7C44EL, + 0xBE2DA0A5L, 0x4C4623A6L, 0x5F16D052L, 0xAD7D5351L +}; + +uint32 crc32c_t8_nosse(uint32 iCRC, uint8 u8) { + return (iCRC >> 8) ^ crctable[(iCRC ^ u8) & 0xFF]; +} + +uint32 crc32c_t_nosse(uint32 iCRC, const uint8 *buf, int len) { + uint32 crc = iCRC; + while (len-- > 0) { + crc = (crc >> 8) ^ crctable[(crc ^ (*buf++)) & 0xFF]; + } + return crc; +} + +FUNC_TARGET("sse4.2") +uint32 crc32c_t8_sse(uint32 iCRC, uint8 u8) { + return _mm_crc32_u8(iCRC, u8); +} + +FUNC_TARGET("sse4.2") +uint32 crc32c_t_sse(uint32 iCRC, const uint8 *buf, unsigned int len) { + uint32 crc32cval = iCRC; + unsigned int i = 0; + + for (; i < (len >> 2); i += 4) { + crc32cval = _mm_crc32_u32(crc32cval, *(uint32*)&buf[i]); + } + + for (; i < len; i++) { + crc32cval = _mm_crc32_u8(crc32cval, buf[i]); + } + + return crc32cval; +} + +uint32 crc32c_t(uint32 iCRC, const uint8 *buf, unsigned int len) { + return cpuinfo.sse4_2 ? crc32c_t_sse(iCRC, buf, len) : crc32c_t_nosse(iCRC, buf, len); +} + +uint32 crc32c(const uint8 *buf, int len) { + return crc32c_t(0xffffffff, buf, len); +} diff --git a/dep/rehlsdk/engine/crc32c.h b/dep/rehlsdk/engine/crc32c.h index 55bed92..892919b 100644 --- a/dep/rehlsdk/engine/crc32c.h +++ b/dep/rehlsdk/engine/crc32c.h @@ -1,22 +1,22 @@ -/* -Copyright (C) 2010 by Ronnie Sahlberg -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. -You should have received a copy of the GNU Lesser General Public License -along with this program; if not, see . -*/ -#pragma once -#include "archtypes.h" - -extern uint32 crc32c_t8_nosse(uint32 iCRC, uint8 u8); -extern uint32 crc32c_t8_sse(uint32 iCRC, uint8 u8); -extern uint32 crc32c_t_nosse(uint32 iCRC, const uint8 *buf, int len); -extern uint32 crc32c_t_sse(uint32 iCRC, const uint8 *buf, unsigned int len); -extern uint32 crc32c_t(uint32 iCRC, const uint8 *buf, unsigned int len); -extern uint32 crc32c(const uint8 *buf, int len); +/* +Copyright (C) 2010 by Ronnie Sahlberg +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. +You should have received a copy of the GNU Lesser General Public License +along with this program; if not, see . +*/ +#pragma once +#include "archtypes.h" + +extern uint32 crc32c_t8_nosse(uint32 iCRC, uint8 u8); +extern uint32 crc32c_t8_sse(uint32 iCRC, uint8 u8); +extern uint32 crc32c_t_nosse(uint32 iCRC, const uint8 *buf, int len); +extern uint32 crc32c_t_sse(uint32 iCRC, const uint8 *buf, unsigned int len); +extern uint32 crc32c_t(uint32 iCRC, const uint8 *buf, unsigned int len); +extern uint32 crc32c(const uint8 *buf, int len); diff --git a/dep/rehlsdk/engine/custom.h b/dep/rehlsdk/engine/custom.h index d2ebd48..333a4a0 100644 --- a/dep/rehlsdk/engine/custom.h +++ b/dep/rehlsdk/engine/custom.h @@ -1,108 +1,108 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// Customization.h -#pragma once - -#include "const.h" - -#define MAX_QPATH 64 // Must match value in quakedefs.h -#define MAX_RESOURCE_LIST 1280 - -///////////////// -// Customization -// passed to pfnPlayerCustomization -// For automatic downloading. -typedef enum -{ - t_sound = 0, - t_skin, - t_model, - t_decal, - t_generic, - t_eventscript, - t_world, // Fake type for world, is really t_model - rt_unk, - - rt_max -} resourcetype_t; - - -typedef struct -{ - int size; -} _resourceinfo_t; - -typedef struct resourceinfo_s -{ - _resourceinfo_t info[ rt_max ]; -} resourceinfo_t; - -#define RES_FATALIFMISSING (1<<0) // Disconnect if we can't get this file. -#define RES_WASMISSING (1<<1) // Do we have the file locally, did we get it ok? -#define RES_CUSTOM (1<<2) // Is this resource one that corresponds to another player's customization - // or is it a server startup resource. -#define RES_REQUESTED (1<<3) // Already requested a download of this one -#define RES_PRECACHED (1<<4) // Already precached -#define RES_ALWAYS (1<<5) // download always even if available on client -#define RES_UNK_6 (1<<6) // TODO: what is it? -#define RES_CHECKFILE (1<<7) // check file on client - -#include "crc.h" - -typedef struct resource_s -{ -#ifdef HOOK_HLTV - // NOTE HLTV: array szFileName declared on 260 cell, - // this changes necessary for compatibility hookers. - char szFileName[MAX_PATH]; -#else - char szFileName[MAX_QPATH]; // File name to download/precache. -#endif // HOOK_HLTV - - resourcetype_t type; // t_sound, t_skin, t_model, t_decal. - int nIndex; // For t_decals - int nDownloadSize; // Size in Bytes if this must be downloaded. - unsigned char ucFlags; - -// For handling client to client resource propagation - unsigned char rgucMD5_hash[16]; // To determine if we already have it. - unsigned char playernum; // Which player index this resource is associated with, if it's a custom resource. - - unsigned char rguc_reserved[ 32 ]; // For future expansion - struct resource_s *pNext; // Next in chain. - -#if !defined(HLTV) - struct resource_s *pPrev; -#else - unsigned char *data; -#endif // !defined(HLTV) -} resource_t; - -typedef struct customization_s -{ - qboolean bInUse; // Is this customization in use; - resource_t resource; // The resource_t for this customization - qboolean bTranslated; // Has the raw data been translated into a useable format? - // (e.g., raw decal .wad make into texture_t *) - int nUserData1; // Customization specific data - int nUserData2; // Customization specific data - void *pInfo; // Buffer that holds the data structure that references the data (e.g., the cachewad_t) - void *pBuffer; // Buffer that holds the data for the customization (the raw .wad data) - struct customization_s *pNext; // Next in chain -} customization_t; - -#define FCUST_FROMHPAK ( 1<<0 ) -#define FCUST_WIPEDATA ( 1<<1 ) -#define FCUST_IGNOREINIT ( 1<<2 ) +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +// Customization.h +#pragma once + +#include "const.h" + +#define MAX_QPATH 64 // Must match value in quakedefs.h +#define MAX_RESOURCE_LIST 1280 + +///////////////// +// Customization +// passed to pfnPlayerCustomization +// For automatic downloading. +typedef enum +{ + t_sound = 0, + t_skin, + t_model, + t_decal, + t_generic, + t_eventscript, + t_world, // Fake type for world, is really t_model + rt_unk, + + rt_max +} resourcetype_t; + + +typedef struct +{ + int size; +} _resourceinfo_t; + +typedef struct resourceinfo_s +{ + _resourceinfo_t info[ rt_max ]; +} resourceinfo_t; + +#define RES_FATALIFMISSING (1<<0) // Disconnect if we can't get this file. +#define RES_WASMISSING (1<<1) // Do we have the file locally, did we get it ok? +#define RES_CUSTOM (1<<2) // Is this resource one that corresponds to another player's customization + // or is it a server startup resource. +#define RES_REQUESTED (1<<3) // Already requested a download of this one +#define RES_PRECACHED (1<<4) // Already precached +#define RES_ALWAYS (1<<5) // download always even if available on client +#define RES_UNK_6 (1<<6) // TODO: what is it? +#define RES_CHECKFILE (1<<7) // check file on client + +#include "crc.h" + +typedef struct resource_s +{ +#ifdef HOOK_HLTV + // NOTE HLTV: array szFileName declared on 260 cell, + // this changes necessary for compatibility hookers. + char szFileName[MAX_PATH]; +#else + char szFileName[MAX_QPATH]; // File name to download/precache. +#endif // HOOK_HLTV + + resourcetype_t type; // t_sound, t_skin, t_model, t_decal. + int nIndex; // For t_decals + int nDownloadSize; // Size in Bytes if this must be downloaded. + unsigned char ucFlags; + +// For handling client to client resource propagation + unsigned char rgucMD5_hash[16]; // To determine if we already have it. + unsigned char playernum; // Which player index this resource is associated with, if it's a custom resource. + + unsigned char rguc_reserved[ 32 ]; // For future expansion + struct resource_s *pNext; // Next in chain. + +#if !defined(HLTV) + struct resource_s *pPrev; +#else + unsigned char *data; +#endif // !defined(HLTV) +} resource_t; + +typedef struct customization_s +{ + qboolean bInUse; // Is this customization in use; + resource_t resource; // The resource_t for this customization + qboolean bTranslated; // Has the raw data been translated into a useable format? + // (e.g., raw decal .wad make into texture_t *) + int nUserData1; // Customization specific data + int nUserData2; // Customization specific data + void *pInfo; // Buffer that holds the data structure that references the data (e.g., the cachewad_t) + void *pBuffer; // Buffer that holds the data for the customization (the raw .wad data) + struct customization_s *pNext; // Next in chain +} customization_t; + +#define FCUST_FROMHPAK ( 1<<0 ) +#define FCUST_WIPEDATA ( 1<<1 ) +#define FCUST_IGNOREINIT ( 1<<2 ) diff --git a/dep/rehlsdk/engine/customentity.h b/dep/rehlsdk/engine/customentity.h index 2c4eb5e..0895bee 100644 --- a/dep/rehlsdk/engine/customentity.h +++ b/dep/rehlsdk/engine/customentity.h @@ -1,38 +1,38 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef CUSTOMENTITY_H -#define CUSTOMENTITY_H - -// Custom Entities - -// Start/End Entity is encoded as 12 bits of entity index, and 4 bits of attachment (4:12) -#define BEAMENT_ENTITY(x) ((x)&0xFFF) -#define BEAMENT_ATTACHMENT(x) (((x)>>12)&0xF) - -// Beam types, encoded as a byte -enum -{ - BEAM_POINTS = 0, - BEAM_ENTPOINT, - BEAM_ENTS, - BEAM_HOSE, -}; - -#define BEAM_FSINE 0x10 -#define BEAM_FSOLID 0x20 -#define BEAM_FSHADEIN 0x40 -#define BEAM_FSHADEOUT 0x80 - -#endif //CUSTOMENTITY_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef CUSTOMENTITY_H +#define CUSTOMENTITY_H + +// Custom Entities + +// Start/End Entity is encoded as 12 bits of entity index, and 4 bits of attachment (4:12) +#define BEAMENT_ENTITY(x) ((x)&0xFFF) +#define BEAMENT_ATTACHMENT(x) (((x)>>12)&0xF) + +// Beam types, encoded as a byte +enum +{ + BEAM_POINTS = 0, + BEAM_ENTPOINT, + BEAM_ENTS, + BEAM_HOSE, +}; + +#define BEAM_FSINE 0x10 +#define BEAM_FSOLID 0x20 +#define BEAM_FSHADEIN 0x40 +#define BEAM_FSHADEOUT 0x80 + +#endif //CUSTOMENTITY_H diff --git a/dep/rehlsdk/engine/d_local.h b/dep/rehlsdk/engine/d_local.h index 9ba7295..c2d2f59 100644 --- a/dep/rehlsdk/engine/d_local.h +++ b/dep/rehlsdk/engine/d_local.h @@ -1,43 +1,43 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#pragma once - -typedef struct surfcache_s -{ - struct surfcache_s *next; - struct surfcache_s **owner; - int lightadj[4]; - int dlight; - int size; - unsigned width; - unsigned height; - float mipscale; - struct texture_s *texture; - unsigned char data[4]; -} surfcache_t; +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + +#pragma once + +typedef struct surfcache_s +{ + struct surfcache_s *next; + struct surfcache_s **owner; + int lightadj[4]; + int dlight; + int size; + unsigned width; + unsigned height; + float mipscale; + struct texture_s *texture; + unsigned char data[4]; +} surfcache_t; diff --git a/dep/rehlsdk/engine/edict.h b/dep/rehlsdk/engine/edict.h index 6bb109d..9a38993 100644 --- a/dep/rehlsdk/engine/edict.h +++ b/dep/rehlsdk/engine/edict.h @@ -1,36 +1,36 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#if !defined EDICT_H -#define EDICT_H -#ifdef _WIN32 -#pragma once -#endif -#define MAX_ENT_LEAFS 48 - -#include "progdefs.h" - -struct edict_s -{ - qboolean free; - int serialnumber; - link_t area; // linked to a division node or leaf - - int headnode; // -1 to use normal leaf check - int num_leafs; - short leafnums[MAX_ENT_LEAFS]; - - float freetime; // sv.time when the object was freed - - void* pvPrivateData; // Alloced and freed by engine, used by DLLs - - entvars_t v; // C exported fields from progs - - // other fields from progs come immediately after -}; - -#endif +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#if !defined EDICT_H +#define EDICT_H +#ifdef _WIN32 +#pragma once +#endif +#define MAX_ENT_LEAFS 48 + +#include "progdefs.h" + +struct edict_s +{ + qboolean free; + int serialnumber; + link_t area; // linked to a division node or leaf + + int headnode; // -1 to use normal leaf check + int num_leafs; + short leafnums[MAX_ENT_LEAFS]; + + float freetime; // sv.time when the object was freed + + void* pvPrivateData; // Alloced and freed by engine, used by DLLs + + entvars_t v; // C exported fields from progs + + // other fields from progs come immediately after +}; + +#endif diff --git a/dep/rehlsdk/engine/eiface.h b/dep/rehlsdk/engine/eiface.h index 59680bc..63f3b3c 100644 --- a/dep/rehlsdk/engine/eiface.h +++ b/dep/rehlsdk/engine/eiface.h @@ -1,536 +1,536 @@ -/*** -* -* Copyright (c) 1999, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#pragma once - -#include "archtypes.h" // DAL - -#ifdef HLDEMO_BUILD -#define INTERFACE_VERSION 001 -#else // !HLDEMO_BUILD, i.e., regular version of HL -#define INTERFACE_VERSION 140 -#endif // !HLDEMO_BUILD - -#include -#include "custom.h" -#include "cvardef.h" -#include "Sequence.h" -// -// Defines entity interface between engine and DLLs. -// This header file included by engine files and DLL files. -// -// Before including this header, DLLs must: -// include progdefs.h -// This is conveniently done for them in extdll.h -// - -/* -#ifdef _WIN32 -#define DLLEXPORT __stdcall EXT_FUNC -#else -#define DLLEXPORT __attribute__ ((visibility("default"))) EXT_FUNC -#endif -*/ - -enum ALERT_TYPE -{ - at_notice, - at_console, // same as at_notice, but forces a ConPrintf, not a message box - at_aiconsole, // same as at_console, but only shown if developer level is 2! - at_warning, - at_error, - at_logged // Server print to console ( only in multiplayer games ). -}; - -// 4-22-98 JOHN: added for use in pfnClientPrintf -enum PRINT_TYPE -{ - print_console, - print_center, - print_chat, -}; - -// For integrity checking of content on clients -enum FORCE_TYPE -{ - force_exactfile, // File on client must exactly match server's file - force_model_samebounds, // For model files only, the geometry must fit in the same bbox - force_model_specifybounds, // For model files only, the geometry must fit in the specified bbox - force_model_specifybounds_if_avail, // For Steam model files only, the geometry must fit in the specified bbox (if the file is available) -}; - -// Returned by TraceLine -struct TraceResult -{ - int fAllSolid; // if true, plane is not valid - int fStartSolid; // if true, the initial point was in a solid area - int fInOpen; - int fInWater; - float flFraction; // time completed, 1.0 = didn't hit anything - vec3_t vecEndPos; // final position - float flPlaneDist; - vec3_t vecPlaneNormal; // surface normal at impact - edict_t *pHit; // entity the surface is on - int iHitgroup; // 0 == generic, non zero is specific body part -}; - -// CD audio status -typedef struct -{ - int fPlaying;// is sound playing right now? - int fWasPlaying;// if not, CD is paused if WasPlaying is true. - int fInitialized; - int fEnabled; - int fPlayLooping; - float cdvolume; - //BYTE remap[100]; - int fCDRom; - int fPlayTrack; -} CDStatus; - -#include "../common/crc.h" - - -// Engine hands this to DLLs for functionality callbacks -typedef struct enginefuncs_s -{ - int (*pfnPrecacheModel) (const char* s); - int (*pfnPrecacheSound) (const char* s); - void (*pfnSetModel) (edict_t *e, const char *m); - int (*pfnModelIndex) (const char *m); - int (*pfnModelFrames) (int modelIndex); - void (*pfnSetSize) (edict_t *e, const float *rgflMin, const float *rgflMax); - void (*pfnChangeLevel) (const char* s1, const char* s2); - void (*pfnGetSpawnParms) (edict_t *ent); - void (*pfnSaveSpawnParms) (edict_t *ent); - float (*pfnVecToYaw) (const float *rgflVector); - void (*pfnVecToAngles) (const float *rgflVectorIn, float *rgflVectorOut); - void (*pfnMoveToOrigin) (edict_t *ent, const float *pflGoal, float dist, int iMoveType); - void (*pfnChangeYaw) (edict_t* ent); - void (*pfnChangePitch) (edict_t* ent); - edict_t* (*pfnFindEntityByString) (edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue); - int (*pfnGetEntityIllum) (edict_t* pEnt); - edict_t* (*pfnFindEntityInSphere) (edict_t *pEdictStartSearchAfter, const float *org, float rad); - edict_t* (*pfnFindClientInPVS) (edict_t *pEdict); - edict_t* (*pfnEntitiesInPVS) (edict_t *pplayer); - void (*pfnMakeVectors) (const float *rgflVector); - void (*pfnAngleVectors) (const float *rgflVector, float *forward, float *right, float *up); - edict_t* (*pfnCreateEntity) (void); - void (*pfnRemoveEntity) (edict_t* e); - edict_t* (*pfnCreateNamedEntity) (int className); - void (*pfnMakeStatic) (edict_t *ent); - int (*pfnEntIsOnFloor) (edict_t *e); - int (*pfnDropToFloor) (edict_t* e); - int (*pfnWalkMove) (edict_t *ent, float yaw, float dist, int iMode); - void (*pfnSetOrigin) (edict_t *e, const float *rgflOrigin); - void (*pfnEmitSound) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch); - void (*pfnEmitAmbientSound) (edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch); - void (*pfnTraceLine) (const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); - void (*pfnTraceToss) (edict_t* pent, edict_t* pentToIgnore, TraceResult *ptr); - int (*pfnTraceMonsterHull) (edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); - void (*pfnTraceHull) (const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr); - void (*pfnTraceModel) (const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr); - const char *(*pfnTraceTexture) (edict_t *pTextureEntity, const float *v1, const float *v2 ); - void (*pfnTraceSphere) (const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr); - void (*pfnGetAimVector) (edict_t* ent, float speed, float *rgflReturn); - void (*pfnServerCommand) (const char* str); - void (*pfnServerExecute) (void); - void (*pfnClientCommand) (edict_t* pEdict, const char* szFmt, ...); - void (*pfnParticleEffect) (const float *org, const float *dir, float color, float count); - void (*pfnLightStyle) (int style, const char* val); - int (*pfnDecalIndex) (const char *name); - int (*pfnPointContents) (const float *rgflVector); - void (*pfnMessageBegin) (int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); - void (*pfnMessageEnd) (void); - void (*pfnWriteByte) (int iValue); - void (*pfnWriteChar) (int iValue); - void (*pfnWriteShort) (int iValue); - void (*pfnWriteLong) (int iValue); - void (*pfnWriteAngle) (float flValue); - void (*pfnWriteCoord) (float flValue); - void (*pfnWriteString) (const char *sz); - void (*pfnWriteEntity) (int iValue); - void (*pfnCVarRegister) (cvar_t *pCvar); - float (*pfnCVarGetFloat) (const char *szVarName); - const char* (*pfnCVarGetString) (const char *szVarName); - void (*pfnCVarSetFloat) (const char *szVarName, float flValue); - void (*pfnCVarSetString) (const char *szVarName, const char *szValue); - void (*pfnAlertMessage) (ALERT_TYPE atype, const char *szFmt, ...); - void (*pfnEngineFprintf) (void *pfile, const char *szFmt, ...); - void* (*pfnPvAllocEntPrivateData) (edict_t *pEdict, int32 cb); - void* (*pfnPvEntPrivateData) (edict_t *pEdict); - void (*pfnFreeEntPrivateData) (edict_t *pEdict); - const char* (*pfnSzFromIndex) (int iString); - int (*pfnAllocString) (const char *szValue); - struct entvars_s* (*pfnGetVarsOfEnt) (edict_t *pEdict); - edict_t* (*pfnPEntityOfEntOffset) (int iEntOffset); - int (*pfnEntOffsetOfPEntity) (const edict_t *pEdict); - int (*pfnIndexOfEdict) (const edict_t *pEdict); - edict_t* (*pfnPEntityOfEntIndex) (int iEntIndex); - edict_t* (*pfnFindEntityByVars) (struct entvars_s* pvars); - void* (*pfnGetModelPtr) (edict_t* pEdict); - int (*pfnRegUserMsg) (const char *pszName, int iSize); - void (*pfnAnimationAutomove) (const edict_t* pEdict, float flTime); - void (*pfnGetBonePosition) (const edict_t* pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); - uint32 (*pfnFunctionFromName) ( const char *pName ); - const char *(*pfnNameForFunction) ( uint32 function ); - void (*pfnClientPrintf) ( edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg ); // JOHN: engine callbacks so game DLL can print messages to individual clients - void (*pfnServerPrint) ( const char *szMsg ); - const char *(*pfnCmd_Args) ( void ); // these 3 added - const char *(*pfnCmd_Argv) ( int argc ); // so game DLL can easily - int (*pfnCmd_Argc) ( void ); // access client 'cmd' strings - void (*pfnGetAttachment) (const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles ); - void (*pfnCRC32_Init) (CRC32_t *pulCRC); - void (*pfnCRC32_ProcessBuffer) (CRC32_t *pulCRC, void *p, int len); - void (*pfnCRC32_ProcessByte) (CRC32_t *pulCRC, unsigned char ch); - CRC32_t (*pfnCRC32_Final) (CRC32_t pulCRC); - int32 (*pfnRandomLong) (int32 lLow, int32 lHigh); - float (*pfnRandomFloat) (float flLow, float flHigh); - void (*pfnSetView) (const edict_t *pClient, const edict_t *pViewent ); - float (*pfnTime) ( void ); - void (*pfnCrosshairAngle) (const edict_t *pClient, float pitch, float yaw); - byte * (*pfnLoadFileForMe) (const char *filename, int *pLength); - void (*pfnFreeFile) (void *buffer); - void (*pfnEndSection) (const char *pszSectionName); // trigger_endsection - int (*pfnCompareFileTime) (char *filename1, char *filename2, int *iCompare); - void (*pfnGetGameDir) (char *szGetGameDir); - void (*pfnCvar_RegisterVariable) (cvar_t *variable); - void (*pfnFadeClientVolume) (const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds); - void (*pfnSetClientMaxspeed) (edict_t *pEdict, float fNewMaxspeed); - edict_t * (*pfnCreateFakeClient) (const char *netname); // returns NULL if fake client can't be created - void (*pfnRunPlayerMove) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); - int (*pfnNumberOfEntities) (void); - char* (*pfnGetInfoKeyBuffer) (edict_t *e); // passing in NULL gets the serverinfo - char* (*pfnInfoKeyValue) (char *infobuffer, const char *key); - void (*pfnSetKeyValue) (char *infobuffer, const char *key, const char *value); - void (*pfnSetClientKeyValue) (int clientIndex, char *infobuffer, const char *key, const char *value); - int (*pfnIsMapValid) (const char *filename); - void (*pfnStaticDecal) ( const float *origin, int decalIndex, int entityIndex, int modelIndex ); - int (*pfnPrecacheGeneric) (const char* s); - int (*pfnGetPlayerUserId) (edict_t *e ); // returns the server assigned userid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients - void (*pfnBuildSoundMsg) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); - int (*pfnIsDedicatedServer) (void);// is this a dedicated server? - cvar_t *(*pfnCVarGetPointer) (const char *szVarName); - unsigned int (*pfnGetPlayerWONId) (edict_t *e); // returns the server assigned WONid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients - - // YWB 8/1/99 TFF Physics additions - void (*pfnInfo_RemoveKey) ( char *s, const char *key ); - const char *(*pfnGetPhysicsKeyValue) ( const edict_t *pClient, const char *key ); - void (*pfnSetPhysicsKeyValue) ( const edict_t *pClient, const char *key, const char *value ); - const char *(*pfnGetPhysicsInfoString) ( const edict_t *pClient ); - unsigned short (*pfnPrecacheEvent) ( int type, const char*psz ); - void (*pfnPlaybackEvent) ( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); - - unsigned char *(*pfnSetFatPVS) ( float *org ); - unsigned char *(*pfnSetFatPAS) ( float *org ); - - int (*pfnCheckVisibility ) ( edict_t *entity, unsigned char *pset ); - - void (*pfnDeltaSetField) ( struct delta_s *pFields, const char *fieldname ); - void (*pfnDeltaUnsetField) ( struct delta_s *pFields, const char *fieldname ); - void (*pfnDeltaAddEncoder) ( const char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); - int (*pfnGetCurrentPlayer) ( void ); - int (*pfnCanSkipPlayer) ( const edict_t *player ); - int (*pfnDeltaFindField) ( struct delta_s *pFields, const char *fieldname ); - void (*pfnDeltaSetFieldByIndex) ( struct delta_s *pFields, int fieldNumber ); - void (*pfnDeltaUnsetFieldByIndex)( struct delta_s *pFields, int fieldNumber ); - - void (*pfnSetGroupMask) ( int mask, int op ); - - int (*pfnCreateInstancedBaseline) ( int classname, struct entity_state_s *baseline ); - void (*pfnCvar_DirectSet) ( struct cvar_s *var, const char *value ); - - // Forces the client and server to be running with the same version of the specified file - // ( e.g., a player model ). - // Calling this has no effect in single player - void (*pfnForceUnmodified) ( FORCE_TYPE type, float *mins, float *maxs, const char *filename ); - - void (*pfnGetPlayerStats) ( const edict_t *pClient, int *ping, int *packet_loss ); - - void (*pfnAddServerCommand) ( const char *cmd_name, void (*function) (void) ); - - // For voice communications, set which clients hear eachother. - // NOTE: these functions take player entity indices (starting at 1). - qboolean (*pfnVoice_GetClientListening)(int iReceiver, int iSender); - qboolean (*pfnVoice_SetClientListening)(int iReceiver, int iSender, qboolean bListen); - - const char *(*pfnGetPlayerAuthId) ( edict_t *e ); - - // PSV: Added for CZ training map -// const char *(*pfnKeyNameForBinding) ( const char* pBinding ); - - sequenceEntry_s* (*pfnSequenceGet) ( const char* fileName, const char* entryName ); - sentenceEntry_s* (*pfnSequencePickSentence) ( const char* groupName, int pickMethod, int *picked ); - - // LH: Give access to filesize via filesystem - int (*pfnGetFileSize) ( const char *filename ); - - unsigned int (*pfnGetApproxWavePlayLen) (const char *filepath); - // MDC: Added for CZ career-mode - int (*pfnIsCareerMatch) ( void ); - - // BGC: return the number of characters of the localized string referenced by using "label" - int (*pfnGetLocalizedStringLength) (const char *label); - - // BGC: added to facilitate persistent storage of tutor message decay values for - // different career game profiles. Also needs to persist regardless of mp.dll being - // destroyed and recreated. - void (*pfnRegisterTutorMessageShown) (int mid); - int (*pfnGetTimesTutorMessageShown) (int mid); - void (*pfnProcessTutorMessageDecayBuffer) (int *buffer, int bufferLength); - void (*pfnConstructTutorMessageDecayBuffer) (int *buffer, int bufferLength); - void (*pfnResetTutorMessageDecayData) ( void ); - - // Added 2005/08/11 (no SDK update): - void(*pfnQueryClientCvarValue) (const edict_t *player, const char *cvarName); - - // Added 2005/11/21 (no SDK update): - void(*pfnQueryClientCvarValue2) (const edict_t *player, const char *cvarName, int requestID); - - // Added 2009/06/19 (no SDK update): - int(*pfnEngCheckParm) (const char *pchCmdLineToken, char **ppnext); -} enginefuncs_t; - - -// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 138 - -// Passed to pfnKeyValue -typedef struct KeyValueData_s -{ - char *szClassName; // in: entity classname - char *szKeyName; // in: name of key - char *szValue; // in: value of key - qboolean fHandled; // out: DLL sets to true if key-value pair was understood -} KeyValueData; - - -typedef struct -{ - char mapName[ 32 ]; - char landmarkName[ 32 ]; - edict_t *pentLandmark; - vec3_t vecLandmarkOrigin; -} LEVELLIST; -#define MAX_LEVEL_CONNECTIONS 16 // These are encoded in the lower 16bits of ENTITYTABLE->flags - -typedef struct -{ - int id; // Ordinal ID of this entity (used for entity <--> pointer conversions) - edict_t *pent; // Pointer to the in-game entity - - int location; // Offset from the base data of this entity - int size; // Byte size of this entity's data - int flags; // This could be a short -- bit mask of transitions that this entity is in the PVS of - string_t classname; // entity class name - -} ENTITYTABLE; - -#define FENTTABLE_PLAYER 0x80000000 -#define FENTTABLE_REMOVED 0x40000000 -#define FENTTABLE_MOVEABLE 0x20000000 -#define FENTTABLE_GLOBAL 0x10000000 - -typedef struct saverestore_s SAVERESTOREDATA; - -#ifdef _WIN32 -typedef -#endif -struct saverestore_s -{ - char *pBaseData; // Start of all entity save data - char *pCurrentData; // Current buffer pointer for sequential access - int size; // Current data size - int bufferSize; // Total space for data - int tokenSize; // Size of the linear list of tokens - int tokenCount; // Number of elements in the pTokens table - char **pTokens; // Hash table of entity strings (sparse) - int currentIndex; // Holds a global entity table ID - int tableCount; // Number of elements in the entity table - int connectionCount;// Number of elements in the levelList[] - ENTITYTABLE *pTable; // Array of ENTITYTABLE elements (1 for each entity) - LEVELLIST levelList[ MAX_LEVEL_CONNECTIONS ]; // List of connections from this level - - // smooth transition - int fUseLandmark; - char szLandmarkName[20];// landmark we'll spawn near in next level - vec3_t vecLandmarkOffset;// for landmark transitions - float time; - char szCurrentMapName[32]; // To check global entities - -} -#ifdef _WIN32 -SAVERESTOREDATA -#endif -; - -typedef enum _fieldtypes -{ - FIELD_FLOAT = 0, // Any floating point value - FIELD_STRING, // A string ID (return from ALLOC_STRING) - FIELD_ENTITY, // An entity offset (EOFFSET) - FIELD_CLASSPTR, // CBaseEntity * - FIELD_EHANDLE, // Entity handle - FIELD_EVARS, // EVARS * - FIELD_EDICT, // edict_t *, or edict_t * (same thing) - FIELD_VECTOR, // Any vector - FIELD_POSITION_VECTOR, // A world coordinate (these are fixed up across level transitions automagically) - FIELD_POINTER, // Arbitrary data pointer... to be removed, use an array of FIELD_CHARACTER - FIELD_INTEGER, // Any integer or enum - FIELD_FUNCTION, // A class function pointer (Think, Use, etc) - FIELD_BOOLEAN, // boolean, implemented as an int, I may use this as a hint for compression - FIELD_SHORT, // 2 byte integer - FIELD_CHARACTER, // a byte - FIELD_TIME, // a floating point time (these are fixed up automatically too!) - FIELD_MODELNAME, // Engine string that is a model name (needs precache) - FIELD_SOUNDNAME, // Engine string that is a sound name (needs precache) - - FIELD_TYPECOUNT, // MUST BE LAST -} FIELDTYPE; - -#if !defined(offsetof) && !defined(GNUC) -#define offsetof(s,m) (size_t)&(((s *)0)->m) -#endif - -#define _FIELD(type,name,fieldtype,count,flags) { fieldtype, #name, offsetof(type, name), count, flags } -#define DEFINE_FIELD(type,name,fieldtype) _FIELD(type, name, fieldtype, 1, 0) -#define DEFINE_ARRAY(type,name,fieldtype,count) _FIELD(type, name, fieldtype, count, 0) -#define DEFINE_ENTITY_FIELD(name,fieldtype) _FIELD(entvars_t, name, fieldtype, 1, 0 ) -#define DEFINE_ENTITY_GLOBAL_FIELD(name,fieldtype) _FIELD(entvars_t, name, fieldtype, 1, FTYPEDESC_GLOBAL ) -#define DEFINE_GLOBAL_FIELD(type,name,fieldtype) _FIELD(type, name, fieldtype, 1, FTYPEDESC_GLOBAL ) - - -#define FTYPEDESC_GLOBAL 0x0001 // This field is masked for global entity save/restore - -typedef struct -{ - FIELDTYPE fieldType; - char *fieldName; - int fieldOffset; - short fieldSize; - short flags; -} TYPEDESCRIPTION; - -#ifndef ARRAYSIZE -#define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) -#endif - -typedef struct -{ - // Initialize/shutdown the game (one-time call after loading of game .dll ) - void (*pfnGameInit) ( void ); - int (*pfnSpawn) ( edict_t *pent ); - void (*pfnThink) ( edict_t *pent ); - void (*pfnUse) ( edict_t *pentUsed, edict_t *pentOther ); - void (*pfnTouch) ( edict_t *pentTouched, edict_t *pentOther ); - void (*pfnBlocked) ( edict_t *pentBlocked, edict_t *pentOther ); - void (*pfnKeyValue) ( edict_t *pentKeyvalue, KeyValueData *pkvd ); - void (*pfnSave) ( edict_t *pent, SAVERESTOREDATA *pSaveData ); - int (*pfnRestore) ( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ); - void (*pfnSetAbsBox) ( edict_t *pent ); - - void (*pfnSaveWriteFields) ( SAVERESTOREDATA *, const char *, void *, TYPEDESCRIPTION *, int ); - void (*pfnSaveReadFields) ( SAVERESTOREDATA *, const char *, void *, TYPEDESCRIPTION *, int ); - - void (*pfnSaveGlobalState) ( SAVERESTOREDATA * ); - void (*pfnRestoreGlobalState) ( SAVERESTOREDATA * ); - void (*pfnResetGlobalState) ( void ); - - qboolean (*pfnClientConnect) ( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); - - void (*pfnClientDisconnect) ( edict_t *pEntity ); - void (*pfnClientKill) ( edict_t *pEntity ); - void (*pfnClientPutInServer) ( edict_t *pEntity ); - void (*pfnClientCommand) ( edict_t *pEntity ); - void (*pfnClientUserInfoChanged)( edict_t *pEntity, char *infobuffer ); - - void (*pfnServerActivate) ( edict_t *pEdictList, int edictCount, int clientMax ); - void (*pfnServerDeactivate) ( void ); - - void (*pfnPlayerPreThink) ( edict_t *pEntity ); - void (*pfnPlayerPostThink) ( edict_t *pEntity ); - - void (*pfnStartFrame) ( void ); - void (*pfnParmsNewLevel) ( void ); - void (*pfnParmsChangeLevel) ( void ); - - // Returns string describing current .dll. E.g., TeamFotrress 2, Half-Life - const char *(*pfnGetGameDescription)( void ); - - // Notify dll about a player customization. - void (*pfnPlayerCustomization) ( edict_t *pEntity, customization_t *pCustom ); - - // Spectator funcs - void (*pfnSpectatorConnect) ( edict_t *pEntity ); - void (*pfnSpectatorDisconnect) ( edict_t *pEntity ); - void (*pfnSpectatorThink) ( edict_t *pEntity ); - - // Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. - void (*pfnSys_Error) ( const char *error_string ); - - void (*pfnPM_Move) ( struct playermove_s *ppmove, qboolean server ); - void (*pfnPM_Init) ( struct playermove_s *ppmove ); - char (*pfnPM_FindTextureType)( char *name ); - void (*pfnSetupVisibility)( struct edict_s *pViewEntity, struct edict_s *pClient, unsigned char **pvs, unsigned char **pas ); - void (*pfnUpdateClientData) ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); - int (*pfnAddToFullPack)( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); - void (*pfnCreateBaseline) ( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ); - void (*pfnRegisterEncoders) ( void ); - int (*pfnGetWeaponData) ( struct edict_s *player, struct weapon_data_s *info ); - - void (*pfnCmdStart) ( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ); - void (*pfnCmdEnd) ( const edict_t *player ); - - // Return 1 if the packet is valid. Set response_buffer_size if you want to send a response packet. Incoming, it holds the max - // size of the response_buffer, so you must zero it out if you choose not to respond. - int (*pfnConnectionlessPacket ) ( const struct netadr_s *net_from_, const char *args, char *response_buffer, int *response_buffer_size ); - - // Enumerates player hulls. Returns 0 if the hull number doesn't exist, 1 otherwise - int (*pfnGetHullBounds) ( int hullnumber, float *mins, float *maxs ); - - // Create baselines for certain "unplaced" items. - void (*pfnCreateInstancedBaselines) ( void ); - - // One of the pfnForceUnmodified files failed the consistency check for the specified player - // Return 0 to allow the client to continue, 1 to force immediate disconnection ( with an optional disconnect message of up to 256 characters ) - int (*pfnInconsistentFile)( const struct edict_s *player, const char *filename, char *disconnect_message ); - - // The game .dll should return 1 if lag compensation should be allowed ( could also just set - // the sv_unlag cvar. - // Most games right now should return 0, until client-side weapon prediction code is written - // and tested for them. - int (*pfnAllowLagCompensation)( void ); -} DLL_FUNCTIONS; - -extern DLL_FUNCTIONS gEntityInterface; - -// Current version. -#define NEW_DLL_FUNCTIONS_VERSION 1 - -typedef struct -{ - // Called right before the object's memory is freed. - // Calls its destructor. - void (*pfnOnFreeEntPrivateData)(edict_t *pEnt); - void (*pfnGameShutdown)(void); - int (*pfnShouldCollide)( edict_t *pentTouched, edict_t *pentOther ); - void (*pfnCvarValue)( const edict_t *pEnt, const char *value ); - void (*pfnCvarValue2)( const edict_t *pEnt, int requestID, const char *cvarName, const char *value ); -} NEW_DLL_FUNCTIONS; -typedef int(*NEW_DLL_FUNCTIONS_FN)(NEW_DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion); - -// Pointers will be null if the game DLL doesn't support this API. -extern NEW_DLL_FUNCTIONS gNewDLLFunctions; - -typedef int(*APIFUNCTION)(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion); -typedef int(*APIFUNCTION2)(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion); +/*** +* +* Copyright (c) 1999, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#pragma once + +#include "archtypes.h" // DAL + +#ifdef HLDEMO_BUILD +#define INTERFACE_VERSION 001 +#else // !HLDEMO_BUILD, i.e., regular version of HL +#define INTERFACE_VERSION 140 +#endif // !HLDEMO_BUILD + +#include +#include "custom.h" +#include "cvardef.h" +#include "Sequence.h" +// +// Defines entity interface between engine and DLLs. +// This header file included by engine files and DLL files. +// +// Before including this header, DLLs must: +// include progdefs.h +// This is conveniently done for them in extdll.h +// + +/* +#ifdef _WIN32 +#define DLLEXPORT __stdcall EXT_FUNC +#else +#define DLLEXPORT __attribute__ ((visibility("default"))) EXT_FUNC +#endif +*/ + +enum ALERT_TYPE +{ + at_notice, + at_console, // same as at_notice, but forces a ConPrintf, not a message box + at_aiconsole, // same as at_console, but only shown if developer level is 2! + at_warning, + at_error, + at_logged // Server print to console ( only in multiplayer games ). +}; + +// 4-22-98 JOHN: added for use in pfnClientPrintf +enum PRINT_TYPE +{ + print_console, + print_center, + print_chat, +}; + +// For integrity checking of content on clients +enum FORCE_TYPE +{ + force_exactfile, // File on client must exactly match server's file + force_model_samebounds, // For model files only, the geometry must fit in the same bbox + force_model_specifybounds, // For model files only, the geometry must fit in the specified bbox + force_model_specifybounds_if_avail, // For Steam model files only, the geometry must fit in the specified bbox (if the file is available) +}; + +// Returned by TraceLine +struct TraceResult +{ + int fAllSolid; // if true, plane is not valid + int fStartSolid; // if true, the initial point was in a solid area + int fInOpen; + int fInWater; + float flFraction; // time completed, 1.0 = didn't hit anything + vec3_t vecEndPos; // final position + float flPlaneDist; + vec3_t vecPlaneNormal; // surface normal at impact + edict_t *pHit; // entity the surface is on + int iHitgroup; // 0 == generic, non zero is specific body part +}; + +// CD audio status +typedef struct +{ + int fPlaying;// is sound playing right now? + int fWasPlaying;// if not, CD is paused if WasPlaying is true. + int fInitialized; + int fEnabled; + int fPlayLooping; + float cdvolume; + //BYTE remap[100]; + int fCDRom; + int fPlayTrack; +} CDStatus; + +#include "../common/crc.h" + + +// Engine hands this to DLLs for functionality callbacks +typedef struct enginefuncs_s +{ + int (*pfnPrecacheModel) (const char* s); + int (*pfnPrecacheSound) (const char* s); + void (*pfnSetModel) (edict_t *e, const char *m); + int (*pfnModelIndex) (const char *m); + int (*pfnModelFrames) (int modelIndex); + void (*pfnSetSize) (edict_t *e, const float *rgflMin, const float *rgflMax); + void (*pfnChangeLevel) (const char* s1, const char* s2); + void (*pfnGetSpawnParms) (edict_t *ent); + void (*pfnSaveSpawnParms) (edict_t *ent); + float (*pfnVecToYaw) (const float *rgflVector); + void (*pfnVecToAngles) (const float *rgflVectorIn, float *rgflVectorOut); + void (*pfnMoveToOrigin) (edict_t *ent, const float *pflGoal, float dist, int iMoveType); + void (*pfnChangeYaw) (edict_t* ent); + void (*pfnChangePitch) (edict_t* ent); + edict_t* (*pfnFindEntityByString) (edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue); + int (*pfnGetEntityIllum) (edict_t* pEnt); + edict_t* (*pfnFindEntityInSphere) (edict_t *pEdictStartSearchAfter, const float *org, float rad); + edict_t* (*pfnFindClientInPVS) (edict_t *pEdict); + edict_t* (*pfnEntitiesInPVS) (edict_t *pplayer); + void (*pfnMakeVectors) (const float *rgflVector); + void (*pfnAngleVectors) (const float *rgflVector, float *forward, float *right, float *up); + edict_t* (*pfnCreateEntity) (void); + void (*pfnRemoveEntity) (edict_t* e); + edict_t* (*pfnCreateNamedEntity) (int className); + void (*pfnMakeStatic) (edict_t *ent); + int (*pfnEntIsOnFloor) (edict_t *e); + int (*pfnDropToFloor) (edict_t* e); + int (*pfnWalkMove) (edict_t *ent, float yaw, float dist, int iMode); + void (*pfnSetOrigin) (edict_t *e, const float *rgflOrigin); + void (*pfnEmitSound) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch); + void (*pfnEmitAmbientSound) (edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch); + void (*pfnTraceLine) (const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); + void (*pfnTraceToss) (edict_t* pent, edict_t* pentToIgnore, TraceResult *ptr); + int (*pfnTraceMonsterHull) (edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); + void (*pfnTraceHull) (const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr); + void (*pfnTraceModel) (const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr); + const char *(*pfnTraceTexture) (edict_t *pTextureEntity, const float *v1, const float *v2 ); + void (*pfnTraceSphere) (const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr); + void (*pfnGetAimVector) (edict_t* ent, float speed, float *rgflReturn); + void (*pfnServerCommand) (const char* str); + void (*pfnServerExecute) (void); + void (*pfnClientCommand) (edict_t* pEdict, const char* szFmt, ...); + void (*pfnParticleEffect) (const float *org, const float *dir, float color, float count); + void (*pfnLightStyle) (int style, const char* val); + int (*pfnDecalIndex) (const char *name); + int (*pfnPointContents) (const float *rgflVector); + void (*pfnMessageBegin) (int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); + void (*pfnMessageEnd) (void); + void (*pfnWriteByte) (int iValue); + void (*pfnWriteChar) (int iValue); + void (*pfnWriteShort) (int iValue); + void (*pfnWriteLong) (int iValue); + void (*pfnWriteAngle) (float flValue); + void (*pfnWriteCoord) (float flValue); + void (*pfnWriteString) (const char *sz); + void (*pfnWriteEntity) (int iValue); + void (*pfnCVarRegister) (cvar_t *pCvar); + float (*pfnCVarGetFloat) (const char *szVarName); + const char* (*pfnCVarGetString) (const char *szVarName); + void (*pfnCVarSetFloat) (const char *szVarName, float flValue); + void (*pfnCVarSetString) (const char *szVarName, const char *szValue); + void (*pfnAlertMessage) (ALERT_TYPE atype, const char *szFmt, ...); + void (*pfnEngineFprintf) (void *pfile, const char *szFmt, ...); + void* (*pfnPvAllocEntPrivateData) (edict_t *pEdict, int32 cb); + void* (*pfnPvEntPrivateData) (edict_t *pEdict); + void (*pfnFreeEntPrivateData) (edict_t *pEdict); + const char* (*pfnSzFromIndex) (int iString); + int (*pfnAllocString) (const char *szValue); + struct entvars_s* (*pfnGetVarsOfEnt) (edict_t *pEdict); + edict_t* (*pfnPEntityOfEntOffset) (int iEntOffset); + int (*pfnEntOffsetOfPEntity) (const edict_t *pEdict); + int (*pfnIndexOfEdict) (const edict_t *pEdict); + edict_t* (*pfnPEntityOfEntIndex) (int iEntIndex); + edict_t* (*pfnFindEntityByVars) (struct entvars_s* pvars); + void* (*pfnGetModelPtr) (edict_t* pEdict); + int (*pfnRegUserMsg) (const char *pszName, int iSize); + void (*pfnAnimationAutomove) (const edict_t* pEdict, float flTime); + void (*pfnGetBonePosition) (const edict_t* pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); + uint32 (*pfnFunctionFromName) ( const char *pName ); + const char *(*pfnNameForFunction) ( uint32 function ); + void (*pfnClientPrintf) ( edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg ); // JOHN: engine callbacks so game DLL can print messages to individual clients + void (*pfnServerPrint) ( const char *szMsg ); + const char *(*pfnCmd_Args) ( void ); // these 3 added + const char *(*pfnCmd_Argv) ( int argc ); // so game DLL can easily + int (*pfnCmd_Argc) ( void ); // access client 'cmd' strings + void (*pfnGetAttachment) (const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles ); + void (*pfnCRC32_Init) (CRC32_t *pulCRC); + void (*pfnCRC32_ProcessBuffer) (CRC32_t *pulCRC, void *p, int len); + void (*pfnCRC32_ProcessByte) (CRC32_t *pulCRC, unsigned char ch); + CRC32_t (*pfnCRC32_Final) (CRC32_t pulCRC); + int32 (*pfnRandomLong) (int32 lLow, int32 lHigh); + float (*pfnRandomFloat) (float flLow, float flHigh); + void (*pfnSetView) (const edict_t *pClient, const edict_t *pViewent ); + float (*pfnTime) ( void ); + void (*pfnCrosshairAngle) (const edict_t *pClient, float pitch, float yaw); + byte * (*pfnLoadFileForMe) (const char *filename, int *pLength); + void (*pfnFreeFile) (void *buffer); + void (*pfnEndSection) (const char *pszSectionName); // trigger_endsection + int (*pfnCompareFileTime) (char *filename1, char *filename2, int *iCompare); + void (*pfnGetGameDir) (char *szGetGameDir); + void (*pfnCvar_RegisterVariable) (cvar_t *variable); + void (*pfnFadeClientVolume) (const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds); + void (*pfnSetClientMaxspeed) (edict_t *pEdict, float fNewMaxspeed); + edict_t * (*pfnCreateFakeClient) (const char *netname); // returns NULL if fake client can't be created + void (*pfnRunPlayerMove) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); + int (*pfnNumberOfEntities) (void); + char* (*pfnGetInfoKeyBuffer) (edict_t *e); // passing in NULL gets the serverinfo + char* (*pfnInfoKeyValue) (char *infobuffer, const char *key); + void (*pfnSetKeyValue) (char *infobuffer, const char *key, const char *value); + void (*pfnSetClientKeyValue) (int clientIndex, char *infobuffer, const char *key, const char *value); + int (*pfnIsMapValid) (const char *filename); + void (*pfnStaticDecal) ( const float *origin, int decalIndex, int entityIndex, int modelIndex ); + int (*pfnPrecacheGeneric) (const char* s); + int (*pfnGetPlayerUserId) (edict_t *e ); // returns the server assigned userid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients + void (*pfnBuildSoundMsg) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); + int (*pfnIsDedicatedServer) (void);// is this a dedicated server? + cvar_t *(*pfnCVarGetPointer) (const char *szVarName); + unsigned int (*pfnGetPlayerWONId) (edict_t *e); // returns the server assigned WONid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients + + // YWB 8/1/99 TFF Physics additions + void (*pfnInfo_RemoveKey) ( char *s, const char *key ); + const char *(*pfnGetPhysicsKeyValue) ( const edict_t *pClient, const char *key ); + void (*pfnSetPhysicsKeyValue) ( const edict_t *pClient, const char *key, const char *value ); + const char *(*pfnGetPhysicsInfoString) ( const edict_t *pClient ); + unsigned short (*pfnPrecacheEvent) ( int type, const char*psz ); + void (*pfnPlaybackEvent) ( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); + + unsigned char *(*pfnSetFatPVS) ( float *org ); + unsigned char *(*pfnSetFatPAS) ( float *org ); + + int (*pfnCheckVisibility ) ( edict_t *entity, unsigned char *pset ); + + void (*pfnDeltaSetField) ( struct delta_s *pFields, const char *fieldname ); + void (*pfnDeltaUnsetField) ( struct delta_s *pFields, const char *fieldname ); + void (*pfnDeltaAddEncoder) ( const char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); + int (*pfnGetCurrentPlayer) ( void ); + int (*pfnCanSkipPlayer) ( const edict_t *player ); + int (*pfnDeltaFindField) ( struct delta_s *pFields, const char *fieldname ); + void (*pfnDeltaSetFieldByIndex) ( struct delta_s *pFields, int fieldNumber ); + void (*pfnDeltaUnsetFieldByIndex)( struct delta_s *pFields, int fieldNumber ); + + void (*pfnSetGroupMask) ( int mask, int op ); + + int (*pfnCreateInstancedBaseline) ( int classname, struct entity_state_s *baseline ); + void (*pfnCvar_DirectSet) ( struct cvar_s *var, const char *value ); + + // Forces the client and server to be running with the same version of the specified file + // ( e.g., a player model ). + // Calling this has no effect in single player + void (*pfnForceUnmodified) ( FORCE_TYPE type, float *mins, float *maxs, const char *filename ); + + void (*pfnGetPlayerStats) ( const edict_t *pClient, int *ping, int *packet_loss ); + + void (*pfnAddServerCommand) ( const char *cmd_name, void (*function) (void) ); + + // For voice communications, set which clients hear eachother. + // NOTE: these functions take player entity indices (starting at 1). + qboolean (*pfnVoice_GetClientListening)(int iReceiver, int iSender); + qboolean (*pfnVoice_SetClientListening)(int iReceiver, int iSender, qboolean bListen); + + const char *(*pfnGetPlayerAuthId) ( edict_t *e ); + + // PSV: Added for CZ training map +// const char *(*pfnKeyNameForBinding) ( const char* pBinding ); + + sequenceEntry_s* (*pfnSequenceGet) ( const char* fileName, const char* entryName ); + sentenceEntry_s* (*pfnSequencePickSentence) ( const char* groupName, int pickMethod, int *picked ); + + // LH: Give access to filesize via filesystem + int (*pfnGetFileSize) ( const char *filename ); + + unsigned int (*pfnGetApproxWavePlayLen) (const char *filepath); + // MDC: Added for CZ career-mode + int (*pfnIsCareerMatch) ( void ); + + // BGC: return the number of characters of the localized string referenced by using "label" + int (*pfnGetLocalizedStringLength) (const char *label); + + // BGC: added to facilitate persistent storage of tutor message decay values for + // different career game profiles. Also needs to persist regardless of mp.dll being + // destroyed and recreated. + void (*pfnRegisterTutorMessageShown) (int mid); + int (*pfnGetTimesTutorMessageShown) (int mid); + void (*pfnProcessTutorMessageDecayBuffer) (int *buffer, int bufferLength); + void (*pfnConstructTutorMessageDecayBuffer) (int *buffer, int bufferLength); + void (*pfnResetTutorMessageDecayData) ( void ); + + // Added 2005/08/11 (no SDK update): + void(*pfnQueryClientCvarValue) (const edict_t *player, const char *cvarName); + + // Added 2005/11/21 (no SDK update): + void(*pfnQueryClientCvarValue2) (const edict_t *player, const char *cvarName, int requestID); + + // Added 2009/06/19 (no SDK update): + int(*pfnEngCheckParm) (const char *pchCmdLineToken, char **ppnext); +} enginefuncs_t; + + +// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 138 + +// Passed to pfnKeyValue +typedef struct KeyValueData_s +{ + char *szClassName; // in: entity classname + char *szKeyName; // in: name of key + char *szValue; // in: value of key + qboolean fHandled; // out: DLL sets to true if key-value pair was understood +} KeyValueData; + + +typedef struct +{ + char mapName[ 32 ]; + char landmarkName[ 32 ]; + edict_t *pentLandmark; + vec3_t vecLandmarkOrigin; +} LEVELLIST; +#define MAX_LEVEL_CONNECTIONS 16 // These are encoded in the lower 16bits of ENTITYTABLE->flags + +typedef struct +{ + int id; // Ordinal ID of this entity (used for entity <--> pointer conversions) + edict_t *pent; // Pointer to the in-game entity + + int location; // Offset from the base data of this entity + int size; // Byte size of this entity's data + int flags; // This could be a short -- bit mask of transitions that this entity is in the PVS of + string_t classname; // entity class name + +} ENTITYTABLE; + +#define FENTTABLE_PLAYER 0x80000000 +#define FENTTABLE_REMOVED 0x40000000 +#define FENTTABLE_MOVEABLE 0x20000000 +#define FENTTABLE_GLOBAL 0x10000000 + +typedef struct saverestore_s SAVERESTOREDATA; + +#ifdef _WIN32 +typedef +#endif +struct saverestore_s +{ + char *pBaseData; // Start of all entity save data + char *pCurrentData; // Current buffer pointer for sequential access + int size; // Current data size + int bufferSize; // Total space for data + int tokenSize; // Size of the linear list of tokens + int tokenCount; // Number of elements in the pTokens table + char **pTokens; // Hash table of entity strings (sparse) + int currentIndex; // Holds a global entity table ID + int tableCount; // Number of elements in the entity table + int connectionCount;// Number of elements in the levelList[] + ENTITYTABLE *pTable; // Array of ENTITYTABLE elements (1 for each entity) + LEVELLIST levelList[ MAX_LEVEL_CONNECTIONS ]; // List of connections from this level + + // smooth transition + int fUseLandmark; + char szLandmarkName[20];// landmark we'll spawn near in next level + vec3_t vecLandmarkOffset;// for landmark transitions + float time; + char szCurrentMapName[32]; // To check global entities + +} +#ifdef _WIN32 +SAVERESTOREDATA +#endif +; + +typedef enum _fieldtypes +{ + FIELD_FLOAT = 0, // Any floating point value + FIELD_STRING, // A string ID (return from ALLOC_STRING) + FIELD_ENTITY, // An entity offset (EOFFSET) + FIELD_CLASSPTR, // CBaseEntity * + FIELD_EHANDLE, // Entity handle + FIELD_EVARS, // EVARS * + FIELD_EDICT, // edict_t *, or edict_t * (same thing) + FIELD_VECTOR, // Any vector + FIELD_POSITION_VECTOR, // A world coordinate (these are fixed up across level transitions automagically) + FIELD_POINTER, // Arbitrary data pointer... to be removed, use an array of FIELD_CHARACTER + FIELD_INTEGER, // Any integer or enum + FIELD_FUNCTION, // A class function pointer (Think, Use, etc) + FIELD_BOOLEAN, // boolean, implemented as an int, I may use this as a hint for compression + FIELD_SHORT, // 2 byte integer + FIELD_CHARACTER, // a byte + FIELD_TIME, // a floating point time (these are fixed up automatically too!) + FIELD_MODELNAME, // Engine string that is a model name (needs precache) + FIELD_SOUNDNAME, // Engine string that is a sound name (needs precache) + + FIELD_TYPECOUNT, // MUST BE LAST +} FIELDTYPE; + +#if !defined(offsetof) && !defined(GNUC) +#define offsetof(s,m) (size_t)&(((s *)0)->m) +#endif + +#define _FIELD(type,name,fieldtype,count,flags) { fieldtype, #name, offsetof(type, name), count, flags } +#define DEFINE_FIELD(type,name,fieldtype) _FIELD(type, name, fieldtype, 1, 0) +#define DEFINE_ARRAY(type,name,fieldtype,count) _FIELD(type, name, fieldtype, count, 0) +#define DEFINE_ENTITY_FIELD(name,fieldtype) _FIELD(entvars_t, name, fieldtype, 1, 0 ) +#define DEFINE_ENTITY_GLOBAL_FIELD(name,fieldtype) _FIELD(entvars_t, name, fieldtype, 1, FTYPEDESC_GLOBAL ) +#define DEFINE_GLOBAL_FIELD(type,name,fieldtype) _FIELD(type, name, fieldtype, 1, FTYPEDESC_GLOBAL ) + + +#define FTYPEDESC_GLOBAL 0x0001 // This field is masked for global entity save/restore + +typedef struct +{ + FIELDTYPE fieldType; + char *fieldName; + int fieldOffset; + short fieldSize; + short flags; +} TYPEDESCRIPTION; + +#ifndef ARRAYSIZE +#define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) +#endif + +typedef struct +{ + // Initialize/shutdown the game (one-time call after loading of game .dll ) + void (*pfnGameInit) ( void ); + int (*pfnSpawn) ( edict_t *pent ); + void (*pfnThink) ( edict_t *pent ); + void (*pfnUse) ( edict_t *pentUsed, edict_t *pentOther ); + void (*pfnTouch) ( edict_t *pentTouched, edict_t *pentOther ); + void (*pfnBlocked) ( edict_t *pentBlocked, edict_t *pentOther ); + void (*pfnKeyValue) ( edict_t *pentKeyvalue, KeyValueData *pkvd ); + void (*pfnSave) ( edict_t *pent, SAVERESTOREDATA *pSaveData ); + int (*pfnRestore) ( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ); + void (*pfnSetAbsBox) ( edict_t *pent ); + + void (*pfnSaveWriteFields) ( SAVERESTOREDATA *, const char *, void *, TYPEDESCRIPTION *, int ); + void (*pfnSaveReadFields) ( SAVERESTOREDATA *, const char *, void *, TYPEDESCRIPTION *, int ); + + void (*pfnSaveGlobalState) ( SAVERESTOREDATA * ); + void (*pfnRestoreGlobalState) ( SAVERESTOREDATA * ); + void (*pfnResetGlobalState) ( void ); + + qboolean (*pfnClientConnect) ( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); + + void (*pfnClientDisconnect) ( edict_t *pEntity ); + void (*pfnClientKill) ( edict_t *pEntity ); + void (*pfnClientPutInServer) ( edict_t *pEntity ); + void (*pfnClientCommand) ( edict_t *pEntity ); + void (*pfnClientUserInfoChanged)( edict_t *pEntity, char *infobuffer ); + + void (*pfnServerActivate) ( edict_t *pEdictList, int edictCount, int clientMax ); + void (*pfnServerDeactivate) ( void ); + + void (*pfnPlayerPreThink) ( edict_t *pEntity ); + void (*pfnPlayerPostThink) ( edict_t *pEntity ); + + void (*pfnStartFrame) ( void ); + void (*pfnParmsNewLevel) ( void ); + void (*pfnParmsChangeLevel) ( void ); + + // Returns string describing current .dll. E.g., TeamFotrress 2, Half-Life + const char *(*pfnGetGameDescription)( void ); + + // Notify dll about a player customization. + void (*pfnPlayerCustomization) ( edict_t *pEntity, customization_t *pCustom ); + + // Spectator funcs + void (*pfnSpectatorConnect) ( edict_t *pEntity ); + void (*pfnSpectatorDisconnect) ( edict_t *pEntity ); + void (*pfnSpectatorThink) ( edict_t *pEntity ); + + // Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. + void (*pfnSys_Error) ( const char *error_string ); + + void (*pfnPM_Move) ( struct playermove_s *ppmove, qboolean server ); + void (*pfnPM_Init) ( struct playermove_s *ppmove ); + char (*pfnPM_FindTextureType)( char *name ); + void (*pfnSetupVisibility)( struct edict_s *pViewEntity, struct edict_s *pClient, unsigned char **pvs, unsigned char **pas ); + void (*pfnUpdateClientData) ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); + int (*pfnAddToFullPack)( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); + void (*pfnCreateBaseline) ( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ); + void (*pfnRegisterEncoders) ( void ); + int (*pfnGetWeaponData) ( struct edict_s *player, struct weapon_data_s *info ); + + void (*pfnCmdStart) ( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ); + void (*pfnCmdEnd) ( const edict_t *player ); + + // Return 1 if the packet is valid. Set response_buffer_size if you want to send a response packet. Incoming, it holds the max + // size of the response_buffer, so you must zero it out if you choose not to respond. + int (*pfnConnectionlessPacket ) ( const struct netadr_s *net_from_, const char *args, char *response_buffer, int *response_buffer_size ); + + // Enumerates player hulls. Returns 0 if the hull number doesn't exist, 1 otherwise + int (*pfnGetHullBounds) ( int hullnumber, float *mins, float *maxs ); + + // Create baselines for certain "unplaced" items. + void (*pfnCreateInstancedBaselines) ( void ); + + // One of the pfnForceUnmodified files failed the consistency check for the specified player + // Return 0 to allow the client to continue, 1 to force immediate disconnection ( with an optional disconnect message of up to 256 characters ) + int (*pfnInconsistentFile)( const struct edict_s *player, const char *filename, char *disconnect_message ); + + // The game .dll should return 1 if lag compensation should be allowed ( could also just set + // the sv_unlag cvar. + // Most games right now should return 0, until client-side weapon prediction code is written + // and tested for them. + int (*pfnAllowLagCompensation)( void ); +} DLL_FUNCTIONS; + +extern DLL_FUNCTIONS gEntityInterface; + +// Current version. +#define NEW_DLL_FUNCTIONS_VERSION 1 + +typedef struct +{ + // Called right before the object's memory is freed. + // Calls its destructor. + void (*pfnOnFreeEntPrivateData)(edict_t *pEnt); + void (*pfnGameShutdown)(void); + int (*pfnShouldCollide)( edict_t *pentTouched, edict_t *pentOther ); + void (*pfnCvarValue)( const edict_t *pEnt, const char *value ); + void (*pfnCvarValue2)( const edict_t *pEnt, int requestID, const char *cvarName, const char *value ); +} NEW_DLL_FUNCTIONS; +typedef int(*NEW_DLL_FUNCTIONS_FN)(NEW_DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion); + +// Pointers will be null if the game DLL doesn't support this API. +extern NEW_DLL_FUNCTIONS gNewDLLFunctions; + +typedef int(*APIFUNCTION)(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion); +typedef int(*APIFUNCTION2)(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion); diff --git a/dep/rehlsdk/engine/hookchains.h b/dep/rehlsdk/engine/hookchains.h index a31109d..197b8a3 100644 --- a/dep/rehlsdk/engine/hookchains.h +++ b/dep/rehlsdk/engine/hookchains.h @@ -1,80 +1,80 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -template -class IHookChain { -protected: - virtual ~IHookChain() {} - -public: - virtual t_ret callNext(t_args... args) = 0; - virtual t_ret callOriginal(t_args... args) = 0; -}; - -template -class IVoidHookChain -{ -protected: - virtual ~IVoidHookChain() {} - -public: - virtual void callNext(t_args... args) = 0; - virtual void callOriginal(t_args... args) = 0; -}; - -// Specifies priorities for hooks call order in the chain. -// For equal priorities first registered hook will be called first. -enum HookChainPriority -{ - HC_PRIORITY_UNINTERRUPTABLE = 255, // Hook will be called before other hooks. - HC_PRIORITY_HIGH = 192, // Hook will be called before hooks with default priority. - HC_PRIORITY_DEFAULT = 128, // Default hook call priority. - HC_PRIORITY_MEDIUM = 64, // Hook will be called after hooks with default priority. - HC_PRIORITY_LOW = 0, // Hook will be called after all other hooks. -}; - -// Hook chain registry(for hooks [un]registration) -template -class IHookChainRegistry { -public: - typedef t_ret(*hookfunc_t)(IHookChain*, t_args...); - - virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0; - virtual void unregisterHook(hookfunc_t hook) = 0; -}; - -// Hook chain registry(for hooks [un]registration) -template -class IVoidHookChainRegistry { -public: - typedef void(*hookfunc_t)(IVoidHookChain*, t_args...); - - virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0; - virtual void unregisterHook(hookfunc_t hook) = 0; -}; +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ +#pragma once + +template +class IHookChain { +protected: + virtual ~IHookChain() {} + +public: + virtual t_ret callNext(t_args... args) = 0; + virtual t_ret callOriginal(t_args... args) = 0; +}; + +template +class IVoidHookChain +{ +protected: + virtual ~IVoidHookChain() {} + +public: + virtual void callNext(t_args... args) = 0; + virtual void callOriginal(t_args... args) = 0; +}; + +// Specifies priorities for hooks call order in the chain. +// For equal priorities first registered hook will be called first. +enum HookChainPriority +{ + HC_PRIORITY_UNINTERRUPTABLE = 255, // Hook will be called before other hooks. + HC_PRIORITY_HIGH = 192, // Hook will be called before hooks with default priority. + HC_PRIORITY_DEFAULT = 128, // Default hook call priority. + HC_PRIORITY_MEDIUM = 64, // Hook will be called after hooks with default priority. + HC_PRIORITY_LOW = 0, // Hook will be called after all other hooks. +}; + +// Hook chain registry(for hooks [un]registration) +template +class IHookChainRegistry { +public: + typedef t_ret(*hookfunc_t)(IHookChain*, t_args...); + + virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0; + virtual void unregisterHook(hookfunc_t hook) = 0; +}; + +// Hook chain registry(for hooks [un]registration) +template +class IVoidHookChainRegistry { +public: + typedef void(*hookfunc_t)(IVoidHookChain*, t_args...); + + virtual void registerHook(hookfunc_t hook, int priority = HC_PRIORITY_DEFAULT) = 0; + virtual void unregisterHook(hookfunc_t hook) = 0; +}; diff --git a/dep/rehlsdk/engine/keydefs.h b/dep/rehlsdk/engine/keydefs.h index 4adeeab..ef9b2fc 100644 --- a/dep/rehlsdk/engine/keydefs.h +++ b/dep/rehlsdk/engine/keydefs.h @@ -1,131 +1,131 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// keydefs.h -#ifndef KEYDEFS_H -#define KEYDEFS_H -#ifdef _WIN32 -#ifndef __MINGW32__ -#pragma once -#endif /* not __MINGW32__ */ -#endif - -// -// these are the key numbers that should be passed to Key_Event -// -#define K_TAB 9 -#define K_ENTER 13 -#define K_ESCAPE 27 -#define K_SPACE 32 - -// normal keys should be passed as lowercased ascii - -#define K_BACKSPACE 127 -#define K_UPARROW 128 -#define K_DOWNARROW 129 -#define K_LEFTARROW 130 -#define K_RIGHTARROW 131 - -#define K_ALT 132 -#define K_CTRL 133 -#define K_SHIFT 134 -#define K_F1 135 -#define K_F2 136 -#define K_F3 137 -#define K_F4 138 -#define K_F5 139 -#define K_F6 140 -#define K_F7 141 -#define K_F8 142 -#define K_F9 143 -#define K_F10 144 -#define K_F11 145 -#define K_F12 146 -#define K_INS 147 -#define K_DEL 148 -#define K_PGDN 149 -#define K_PGUP 150 -#define K_HOME 151 -#define K_END 152 - -#define K_KP_HOME 160 -#define K_KP_UPARROW 161 -#define K_KP_PGUP 162 -#define K_KP_LEFTARROW 163 -#define K_KP_5 164 -#define K_KP_RIGHTARROW 165 -#define K_KP_END 166 -#define K_KP_DOWNARROW 167 -#define K_KP_PGDN 168 -#define K_KP_ENTER 169 -#define K_KP_INS 170 -#define K_KP_DEL 171 -#define K_KP_SLASH 172 -#define K_KP_MINUS 173 -#define K_KP_PLUS 174 -#define K_CAPSLOCK 175 - - -// -// joystick buttons -// -#define K_JOY1 203 -#define K_JOY2 204 -#define K_JOY3 205 -#define K_JOY4 206 - -// -// aux keys are for multi-buttoned joysticks to generate so they can use -// the normal binding process -// -#define K_AUX1 207 -#define K_AUX2 208 -#define K_AUX3 209 -#define K_AUX4 210 -#define K_AUX5 211 -#define K_AUX6 212 -#define K_AUX7 213 -#define K_AUX8 214 -#define K_AUX9 215 -#define K_AUX10 216 -#define K_AUX11 217 -#define K_AUX12 218 -#define K_AUX13 219 -#define K_AUX14 220 -#define K_AUX15 221 -#define K_AUX16 222 -#define K_AUX17 223 -#define K_AUX18 224 -#define K_AUX19 225 -#define K_AUX20 226 -#define K_AUX21 227 -#define K_AUX22 228 -#define K_AUX23 229 -#define K_AUX24 230 -#define K_AUX25 231 -#define K_AUX26 232 -#define K_AUX27 233 -#define K_AUX28 234 -#define K_AUX29 235 -#define K_AUX30 236 -#define K_AUX31 237 -#define K_AUX32 238 -#define K_MWHEELDOWN 239 -#define K_MWHEELUP 240 - -#define K_PAUSE 255 - -// -// mouse buttons generate virtual keys -// -#define K_MOUSE1 241 -#define K_MOUSE2 242 -#define K_MOUSE3 243 -#define K_MOUSE4 244 -#define K_MOUSE5 245 - -#endif // KEYDEFS_H +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +// keydefs.h +#ifndef KEYDEFS_H +#define KEYDEFS_H +#ifdef _WIN32 +#ifndef __MINGW32__ +#pragma once +#endif /* not __MINGW32__ */ +#endif + +// +// these are the key numbers that should be passed to Key_Event +// +#define K_TAB 9 +#define K_ENTER 13 +#define K_ESCAPE 27 +#define K_SPACE 32 + +// normal keys should be passed as lowercased ascii + +#define K_BACKSPACE 127 +#define K_UPARROW 128 +#define K_DOWNARROW 129 +#define K_LEFTARROW 130 +#define K_RIGHTARROW 131 + +#define K_ALT 132 +#define K_CTRL 133 +#define K_SHIFT 134 +#define K_F1 135 +#define K_F2 136 +#define K_F3 137 +#define K_F4 138 +#define K_F5 139 +#define K_F6 140 +#define K_F7 141 +#define K_F8 142 +#define K_F9 143 +#define K_F10 144 +#define K_F11 145 +#define K_F12 146 +#define K_INS 147 +#define K_DEL 148 +#define K_PGDN 149 +#define K_PGUP 150 +#define K_HOME 151 +#define K_END 152 + +#define K_KP_HOME 160 +#define K_KP_UPARROW 161 +#define K_KP_PGUP 162 +#define K_KP_LEFTARROW 163 +#define K_KP_5 164 +#define K_KP_RIGHTARROW 165 +#define K_KP_END 166 +#define K_KP_DOWNARROW 167 +#define K_KP_PGDN 168 +#define K_KP_ENTER 169 +#define K_KP_INS 170 +#define K_KP_DEL 171 +#define K_KP_SLASH 172 +#define K_KP_MINUS 173 +#define K_KP_PLUS 174 +#define K_CAPSLOCK 175 + + +// +// joystick buttons +// +#define K_JOY1 203 +#define K_JOY2 204 +#define K_JOY3 205 +#define K_JOY4 206 + +// +// aux keys are for multi-buttoned joysticks to generate so they can use +// the normal binding process +// +#define K_AUX1 207 +#define K_AUX2 208 +#define K_AUX3 209 +#define K_AUX4 210 +#define K_AUX5 211 +#define K_AUX6 212 +#define K_AUX7 213 +#define K_AUX8 214 +#define K_AUX9 215 +#define K_AUX10 216 +#define K_AUX11 217 +#define K_AUX12 218 +#define K_AUX13 219 +#define K_AUX14 220 +#define K_AUX15 221 +#define K_AUX16 222 +#define K_AUX17 223 +#define K_AUX18 224 +#define K_AUX19 225 +#define K_AUX20 226 +#define K_AUX21 227 +#define K_AUX22 228 +#define K_AUX23 229 +#define K_AUX24 230 +#define K_AUX25 231 +#define K_AUX26 232 +#define K_AUX27 233 +#define K_AUX28 234 +#define K_AUX29 235 +#define K_AUX30 236 +#define K_AUX31 237 +#define K_AUX32 238 +#define K_MWHEELDOWN 239 +#define K_MWHEELUP 240 + +#define K_PAUSE 255 + +// +// mouse buttons generate virtual keys +// +#define K_MOUSE1 241 +#define K_MOUSE2 242 +#define K_MOUSE3 243 +#define K_MOUSE4 244 +#define K_MOUSE5 245 + +#endif // KEYDEFS_H diff --git a/dep/rehlsdk/engine/maintypes.h b/dep/rehlsdk/engine/maintypes.h index b211e2d..f55bac9 100644 --- a/dep/rehlsdk/engine/maintypes.h +++ b/dep/rehlsdk/engine/maintypes.h @@ -1,70 +1,70 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#ifndef MAINTYPES_H -#define MAINTYPES_H -#ifdef _WIN32 -#pragma once -#endif - -#include "osconfig.h" -#include "mathlib.h" - -// Has no references on server side. -#define NOXREF -// Function body is not implemented. -#define NOBODY -// Function is not tested at all. -#define UNTESTED - -#define CONST_INTEGER_AS_STRING(x) #x //Wraps the integer in quotes, allowing us to form constant strings with it -#define __HACK_LINE_AS_STRING__(x) CONST_INTEGER_AS_STRING(x) //__LINE__ can only be converted to an actual number by going through this, otherwise the output is literally "__LINE__" -#define __LINE__AS_STRING __HACK_LINE_AS_STRING__(__LINE__) //Gives you the line number in constant string form - -#if defined _MSC_VER || defined __INTEL_COMPILER -#define NOXREFCHECK int __retAddr; __asm { __asm mov eax, [ebp + 4] __asm mov __retAddr, eax }; Sys_Error("[NOXREFCHECK]: %s: (" __FILE__ ":" __LINE__AS_STRING ") NOXREF, but called from 0x%.08x", __func__, __retAddr) -#else -// For EBP based stack (older gcc) (uncomment version apropriate for your compiler) -//#define NOXREFCHECK int __retAddr; __asm__ __volatile__("movl 4(%%ebp), %%eax;" "movl %%eax, %0":"=r"(__retAddr)::"%eax"); Sys_Error("[NOXREFCHECK]: %s: (" __FILE__ ":" __LINE__AS_STRING ") NOXREF, but called from 0x%.08x", __func__, __retAddr); -// For ESP based stack (newer gcc) (uncomment version apropriate for your compiler) -#define NOXREFCHECK int __retAddr; __asm__ __volatile__("movl 16(%%esp), %%eax;" "movl %%eax, %0":"=r"(__retAddr)::"%eax"); Sys_Error("[NOXREFCHECK]: %s: (" __FILE__ ":" __LINE__AS_STRING ") NOXREF, but called from 0x%.08x", __func__, __retAddr); -#endif - -#define BIT(n) (1<<(n)) - -// From engine/pr_comp.h; -typedef unsigned int string_t; - -// From engine/server.h -typedef enum sv_delta_s -{ - sv_packet_nodelta, - sv_packet_delta, -} sv_delta_t; - -#endif // MAINTYPES_H +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + +#ifndef MAINTYPES_H +#define MAINTYPES_H +#ifdef _WIN32 +#pragma once +#endif + +#include "osconfig.h" +#include "mathlib.h" + +// Has no references on server side. +#define NOXREF +// Function body is not implemented. +#define NOBODY +// Function is not tested at all. +#define UNTESTED + +#define CONST_INTEGER_AS_STRING(x) #x //Wraps the integer in quotes, allowing us to form constant strings with it +#define __HACK_LINE_AS_STRING__(x) CONST_INTEGER_AS_STRING(x) //__LINE__ can only be converted to an actual number by going through this, otherwise the output is literally "__LINE__" +#define __LINE__AS_STRING __HACK_LINE_AS_STRING__(__LINE__) //Gives you the line number in constant string form + +#if defined _MSC_VER || defined __INTEL_COMPILER +#define NOXREFCHECK int __retAddr; __asm { __asm mov eax, [ebp + 4] __asm mov __retAddr, eax }; Sys_Error("[NOXREFCHECK]: %s: (" __FILE__ ":" __LINE__AS_STRING ") NOXREF, but called from 0x%.08x", __func__, __retAddr) +#else +// For EBP based stack (older gcc) (uncomment version apropriate for your compiler) +//#define NOXREFCHECK int __retAddr; __asm__ __volatile__("movl 4(%%ebp), %%eax;" "movl %%eax, %0":"=r"(__retAddr)::"%eax"); Sys_Error("[NOXREFCHECK]: %s: (" __FILE__ ":" __LINE__AS_STRING ") NOXREF, but called from 0x%.08x", __func__, __retAddr); +// For ESP based stack (newer gcc) (uncomment version apropriate for your compiler) +#define NOXREFCHECK int __retAddr; __asm__ __volatile__("movl 16(%%esp), %%eax;" "movl %%eax, %0":"=r"(__retAddr)::"%eax"); Sys_Error("[NOXREFCHECK]: %s: (" __FILE__ ":" __LINE__AS_STRING ") NOXREF, but called from 0x%.08x", __func__, __retAddr); +#endif + +#define BIT(n) (1<<(n)) + +// From engine/pr_comp.h; +typedef unsigned int string_t; + +// From engine/server.h +typedef enum sv_delta_s +{ + sv_packet_nodelta, + sv_packet_delta, +} sv_delta_t; + +#endif // MAINTYPES_H diff --git a/dep/rehlsdk/engine/model.h b/dep/rehlsdk/engine/model.h index bcb952a..354a815 100644 --- a/dep/rehlsdk/engine/model.h +++ b/dep/rehlsdk/engine/model.h @@ -1,409 +1,409 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "const.h" -#include "modelgen.h" -#include "spritegn.h" -#include "bspfile.h" -#include "crc.h" -#include "com_model.h" -#include "commonmacros.h" - -// header -#define ALIAS_MODEL_VERSION 0x006 -#define IDPOLYHEADER MAKEID('I', 'D', 'P', 'O') // little-endian "IDPO" - -#define MAX_LBM_HEIGHT 480 -#define MAX_ALIAS_MODEL_VERTS 2000 - -#define SURF_PLANEBACK 2 -#define SURF_DRAWSKY 4 -#define SURF_DRAWSPRITE 8 -#define SURF_DRAWTURB 0x10 -#define SURF_DRAWTILED 0x20 -#define SURF_DRAWBACKGROUND 0x40 - -#define MAX_MODEL_NAME 64 -#define MIPLEVELS 4 -#define NUM_AMBIENTS 4 // automatic ambient sounds -#define MAXLIGHTMAPS 4 -#define MAX_KNOWN_MODELS 1024 - -typedef struct mvertex_s -{ - vec3_t position; -} mvertex_t; - -typedef struct mplane_s -{ - vec3_t normal; // surface normal - float dist; // closest appoach to origin - byte type; // for texture axis selection and fast side tests - byte signbits; // signx + signy<<1 + signz<<1 - byte pad[2]; -} mplane_t; - -typedef struct texture_s -{ - char name[16]; - unsigned width, height; - -#if !defined(SWDS) && !defined(HLTV) - int gl_texturenum; - struct msurface_s * texturechain; -#endif - - int anim_total; // total tenths in sequence ( 0 = no) - int anim_min, anim_max; // time for this frame min <=time< max - struct texture_s *anim_next; // in the animation sequence - struct texture_s *alternate_anims; // bmodels in frame 1 use these - unsigned offsets[MIPLEVELS]; // four mip maps stored - -#if defined(SWDS) || defined(HLTV) - unsigned paloffset; -#else - byte *pPal; -#endif - -} texture_t; - -typedef struct medge_s -{ - unsigned short v[2]; - unsigned int cachededgeoffset; -} medge_t; - -typedef struct mtexinfo_s -{ - float vecs[2][4]; // [s/t] unit vectors in world space. - // [i][3] is the s/t offset relative to the origin. - // s or t = dot(3Dpoint,vecs[i])+vecs[i][3] - float mipadjust; // ?? mipmap limits for very small surfaces - texture_t *texture; - int flags; // sky or slime, no lightmap or 256 subdivision -} mtexinfo_t; -#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision - -typedef struct msurface_s msurface_t; -typedef struct decal_s decal_t; - -// JAY: Compress this as much as possible -struct decal_s -{ - decal_t *pnext; // linked list for each surface - msurface_t *psurface; // Surface id for persistence / unlinking - short dx; // Offsets into surface texture (in texture coordinates, so we don't need floats) - short dy; - short texture; // Decal texture - byte scale; // Pixel scale - byte flags; // Decal flags - - short entityIndex; // Entity this is attached to -}; - -struct msurface_s -{ - int visframe; // should be drawn when node is crossed - - int dlightframe; // last frame the surface was checked by an animated light - int dlightbits; // dynamically generated. Indicates if the surface illumination - // is modified by an animated light. - - mplane_t *plane; // pointer to shared plane - int flags; // see SURF_ #defines - - int firstedge; // look up in model->surfedges[], negative numbers - int numedges; // are backwards edges - - // surface generation data - struct surfcache_s *cachespots[MIPLEVELS]; - - short texturemins[2]; // smallest s/t position on the surface. - short extents[2]; // ?? s/t texture size, 1..256 for all non-sky surfaces - - mtexinfo_t *texinfo; - - // lighting info - byte styles[MAXLIGHTMAPS]; // index into d_lightstylevalue[] for animated lights - // no one surface can be effected by more than 4 - // animated lights. - color24 *samples; - - decal_t *pdecals; -}; - -typedef struct mnode_s -{ - // common with leaf - int contents; // 0, to differentiate from leafs - int visframe; // node needs to be traversed if current - - short minmaxs[6]; // for bounding box culling - - struct mnode_s *parent; - - // node specific - mplane_t *plane; - struct mnode_s *children[2]; - - unsigned short firstsurface; - unsigned short numsurfaces; -} mnode_t; - -typedef struct mleaf_s -{ - // common with node - int contents; // wil be a negative contents number - int visframe; // node needs to be traversed if current - - short minmaxs[6]; // for bounding box culling - - struct mnode_s *parent; - - // leaf specific - byte *compressed_vis; - struct efrag_s *efrags; - - msurface_t **firstmarksurface; - int nummarksurfaces; - int key; // BSP sequence number for leaf's contents - byte ambient_sound_level[NUM_AMBIENTS]; -} mleaf_t; - -typedef struct hull_s -{ - dclipnode_t *clipnodes; - mplane_t *planes; - int firstclipnode; - int lastclipnode; - vec3_t clip_mins, clip_maxs; -} hull_t; - -typedef struct mspriteframe_t -{ - int width; - int height; - void *pcachespot; - float up, down, left, right; - byte pixels[4]; -} mspriteframe_s; - -typedef struct mspritegroup_s -{ - int numframes; - float *intervals; - mspriteframe_t *frames[1]; -} mspritegroup_t; - -typedef struct mspriteframedesc_s -{ - spriteframetype_t type; - mspriteframe_t *frameptr; -} mspriteframedesc_t; - -typedef struct msprite_s -{ - short int type; - short int texFormat; - int maxwidth, maxheight; - int numframes; - int paloffset; - float beamlength; - void *cachespot; - mspriteframedesc_t frames[1]; -} msprite_t; - -typedef struct maliasframedesc_s -{ - aliasframetype_t type; - trivertx_t bboxmin, bboxmax; - int frame; - char name[16]; -} maliasframedesc_t; - -typedef struct maliasskindesc_s -{ - aliasskintype_t type; - void *pcachespot; - int skin; -} maliasskindesc_t; - -typedef struct maliasgroupframedesc_s -{ - trivertx_t bboxmin, bboxmax; - int frame; -} maliasgroupframedesc_t; - -typedef struct maliasgroup_s -{ - int numframes; - int intervals; - maliasgroupframedesc_t frames[1]; -} maliasgroup_t; - -typedef struct maliasskingroup_s -{ - int numskins; - int intervals; - maliasskindesc_t skindescs[1]; -} maliasskingroup_t; - -typedef struct mtriangle_s -{ - int facesfront; - int vertindex[3]; -} mtriangle_t; - -typedef struct aliashdr_s -{ - int model; - int stverts; - int skindesc; - int triangles; - int palette; - maliasframedesc_t frames[1]; -} aliashdr_t; - -typedef enum modtype_e -{ - mod_bad = -1, - mod_brush, - mod_sprite, - mod_alias, - mod_studio, -} modtype_t; - -typedef struct model_s -{ - char name[MAX_MODEL_NAME]; - - int needload; // bmodels and sprites don't cache normally - - modtype_t type; - int numframes; - synctype_t synctype; - - int flags; - - // - // volume occupied by the model - // - vec3_t mins, maxs; - float radius; - - // - // brush model - // - int firstmodelsurface, nummodelsurfaces; - - int numsubmodels; - dmodel_t *submodels; - - int numplanes; - mplane_t *planes; - - int numleafs; // number of visible leafs, not counting 0 - struct mleaf_s *leafs; - - int numvertexes; - mvertex_t *vertexes; - - int numedges; - medge_t *edges; - - int numnodes; - mnode_t *nodes; - - int numtexinfo; - mtexinfo_t *texinfo; - - int numsurfaces; - msurface_t *surfaces; - - int numsurfedges; - int *surfedges; - - int numclipnodes; - dclipnode_t *clipnodes; - - int nummarksurfaces; - msurface_t **marksurfaces; - - hull_t hulls[MAX_MAP_HULLS]; - - int numtextures; - texture_t **textures; - - byte *visdata; - - color24 *lightdata; - - char *entities; - - // - // additional model data - // - cache_user_t cache; // only access through Mod_Extradata -} model_t; - -typedef struct cachepic_s -{ - char name[64]; - cache_user_t cache; -} cachepic_t; - -typedef struct cachewad_s cachewad_t; - -typedef void(*PFNCACHE)(cachewad_t *, unsigned char *); - -typedef struct cachewad_s -{ - char *name; - cachepic_t *cache; - int cacheCount; - int cacheMax; - struct lumpinfo_s *lumps; - int lumpCount; - int cacheExtra; - PFNCACHE pfnCacheBuild; - int numpaths; - char **basedirs; - int *lumppathindices; -#ifndef SWDS - int tempWad; -#endif // SWDS -} cachewad_t; - -typedef struct mod_known_info_s -{ - qboolean shouldCRC; - qboolean firstCRCDone; - CRC32_t initialCRC; -} mod_known_info_t; - +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ +#pragma once + +#include "const.h" +#include "modelgen.h" +#include "spritegn.h" +#include "bspfile.h" +#include "crc.h" +#include "com_model.h" +#include "commonmacros.h" + +// header +#define ALIAS_MODEL_VERSION 0x006 +#define IDPOLYHEADER MAKEID('I', 'D', 'P', 'O') // little-endian "IDPO" + +#define MAX_LBM_HEIGHT 480 +#define MAX_ALIAS_MODEL_VERTS 2000 + +#define SURF_PLANEBACK 2 +#define SURF_DRAWSKY 4 +#define SURF_DRAWSPRITE 8 +#define SURF_DRAWTURB 0x10 +#define SURF_DRAWTILED 0x20 +#define SURF_DRAWBACKGROUND 0x40 + +#define MAX_MODEL_NAME 64 +#define MIPLEVELS 4 +#define NUM_AMBIENTS 4 // automatic ambient sounds +#define MAXLIGHTMAPS 4 +#define MAX_KNOWN_MODELS 1024 + +typedef struct mvertex_s +{ + vec3_t position; +} mvertex_t; + +typedef struct mplane_s +{ + vec3_t normal; // surface normal + float dist; // closest appoach to origin + byte type; // for texture axis selection and fast side tests + byte signbits; // signx + signy<<1 + signz<<1 + byte pad[2]; +} mplane_t; + +typedef struct texture_s +{ + char name[16]; + unsigned width, height; + +#if !defined(SWDS) && !defined(HLTV) + int gl_texturenum; + struct msurface_s * texturechain; +#endif + + int anim_total; // total tenths in sequence ( 0 = no) + int anim_min, anim_max; // time for this frame min <=time< max + struct texture_s *anim_next; // in the animation sequence + struct texture_s *alternate_anims; // bmodels in frame 1 use these + unsigned offsets[MIPLEVELS]; // four mip maps stored + +#if defined(SWDS) || defined(HLTV) + unsigned paloffset; +#else + byte *pPal; +#endif + +} texture_t; + +typedef struct medge_s +{ + unsigned short v[2]; + unsigned int cachededgeoffset; +} medge_t; + +typedef struct mtexinfo_s +{ + float vecs[2][4]; // [s/t] unit vectors in world space. + // [i][3] is the s/t offset relative to the origin. + // s or t = dot(3Dpoint,vecs[i])+vecs[i][3] + float mipadjust; // ?? mipmap limits for very small surfaces + texture_t *texture; + int flags; // sky or slime, no lightmap or 256 subdivision +} mtexinfo_t; +#define TEX_SPECIAL 1 // sky or slime, no lightmap or 256 subdivision + +typedef struct msurface_s msurface_t; +typedef struct decal_s decal_t; + +// JAY: Compress this as much as possible +struct decal_s +{ + decal_t *pnext; // linked list for each surface + msurface_t *psurface; // Surface id for persistence / unlinking + short dx; // Offsets into surface texture (in texture coordinates, so we don't need floats) + short dy; + short texture; // Decal texture + byte scale; // Pixel scale + byte flags; // Decal flags + + short entityIndex; // Entity this is attached to +}; + +struct msurface_s +{ + int visframe; // should be drawn when node is crossed + + int dlightframe; // last frame the surface was checked by an animated light + int dlightbits; // dynamically generated. Indicates if the surface illumination + // is modified by an animated light. + + mplane_t *plane; // pointer to shared plane + int flags; // see SURF_ #defines + + int firstedge; // look up in model->surfedges[], negative numbers + int numedges; // are backwards edges + + // surface generation data + struct surfcache_s *cachespots[MIPLEVELS]; + + short texturemins[2]; // smallest s/t position on the surface. + short extents[2]; // ?? s/t texture size, 1..256 for all non-sky surfaces + + mtexinfo_t *texinfo; + + // lighting info + byte styles[MAXLIGHTMAPS]; // index into d_lightstylevalue[] for animated lights + // no one surface can be effected by more than 4 + // animated lights. + color24 *samples; + + decal_t *pdecals; +}; + +typedef struct mnode_s +{ + // common with leaf + int contents; // 0, to differentiate from leafs + int visframe; // node needs to be traversed if current + + short minmaxs[6]; // for bounding box culling + + struct mnode_s *parent; + + // node specific + mplane_t *plane; + struct mnode_s *children[2]; + + unsigned short firstsurface; + unsigned short numsurfaces; +} mnode_t; + +typedef struct mleaf_s +{ + // common with node + int contents; // wil be a negative contents number + int visframe; // node needs to be traversed if current + + short minmaxs[6]; // for bounding box culling + + struct mnode_s *parent; + + // leaf specific + byte *compressed_vis; + struct efrag_s *efrags; + + msurface_t **firstmarksurface; + int nummarksurfaces; + int key; // BSP sequence number for leaf's contents + byte ambient_sound_level[NUM_AMBIENTS]; +} mleaf_t; + +typedef struct hull_s +{ + dclipnode_t *clipnodes; + mplane_t *planes; + int firstclipnode; + int lastclipnode; + vec3_t clip_mins, clip_maxs; +} hull_t; + +typedef struct mspriteframe_t +{ + int width; + int height; + void *pcachespot; + float up, down, left, right; + byte pixels[4]; +} mspriteframe_s; + +typedef struct mspritegroup_s +{ + int numframes; + float *intervals; + mspriteframe_t *frames[1]; +} mspritegroup_t; + +typedef struct mspriteframedesc_s +{ + spriteframetype_t type; + mspriteframe_t *frameptr; +} mspriteframedesc_t; + +typedef struct msprite_s +{ + short int type; + short int texFormat; + int maxwidth, maxheight; + int numframes; + int paloffset; + float beamlength; + void *cachespot; + mspriteframedesc_t frames[1]; +} msprite_t; + +typedef struct maliasframedesc_s +{ + aliasframetype_t type; + trivertx_t bboxmin, bboxmax; + int frame; + char name[16]; +} maliasframedesc_t; + +typedef struct maliasskindesc_s +{ + aliasskintype_t type; + void *pcachespot; + int skin; +} maliasskindesc_t; + +typedef struct maliasgroupframedesc_s +{ + trivertx_t bboxmin, bboxmax; + int frame; +} maliasgroupframedesc_t; + +typedef struct maliasgroup_s +{ + int numframes; + int intervals; + maliasgroupframedesc_t frames[1]; +} maliasgroup_t; + +typedef struct maliasskingroup_s +{ + int numskins; + int intervals; + maliasskindesc_t skindescs[1]; +} maliasskingroup_t; + +typedef struct mtriangle_s +{ + int facesfront; + int vertindex[3]; +} mtriangle_t; + +typedef struct aliashdr_s +{ + int model; + int stverts; + int skindesc; + int triangles; + int palette; + maliasframedesc_t frames[1]; +} aliashdr_t; + +typedef enum modtype_e +{ + mod_bad = -1, + mod_brush, + mod_sprite, + mod_alias, + mod_studio, +} modtype_t; + +typedef struct model_s +{ + char name[MAX_MODEL_NAME]; + + int needload; // bmodels and sprites don't cache normally + + modtype_t type; + int numframes; + synctype_t synctype; + + int flags; + + // + // volume occupied by the model + // + vec3_t mins, maxs; + float radius; + + // + // brush model + // + int firstmodelsurface, nummodelsurfaces; + + int numsubmodels; + dmodel_t *submodels; + + int numplanes; + mplane_t *planes; + + int numleafs; // number of visible leafs, not counting 0 + struct mleaf_s *leafs; + + int numvertexes; + mvertex_t *vertexes; + + int numedges; + medge_t *edges; + + int numnodes; + mnode_t *nodes; + + int numtexinfo; + mtexinfo_t *texinfo; + + int numsurfaces; + msurface_t *surfaces; + + int numsurfedges; + int *surfedges; + + int numclipnodes; + dclipnode_t *clipnodes; + + int nummarksurfaces; + msurface_t **marksurfaces; + + hull_t hulls[MAX_MAP_HULLS]; + + int numtextures; + texture_t **textures; + + byte *visdata; + + color24 *lightdata; + + char *entities; + + // + // additional model data + // + cache_user_t cache; // only access through Mod_Extradata +} model_t; + +typedef struct cachepic_s +{ + char name[64]; + cache_user_t cache; +} cachepic_t; + +typedef struct cachewad_s cachewad_t; + +typedef void(*PFNCACHE)(cachewad_t *, unsigned char *); + +typedef struct cachewad_s +{ + char *name; + cachepic_t *cache; + int cacheCount; + int cacheMax; + struct lumpinfo_s *lumps; + int lumpCount; + int cacheExtra; + PFNCACHE pfnCacheBuild; + int numpaths; + char **basedirs; + int *lumppathindices; +#ifndef SWDS + int tempWad; +#endif // SWDS +} cachewad_t; + +typedef struct mod_known_info_s +{ + qboolean shouldCRC; + qboolean firstCRCDone; + CRC32_t initialCRC; +} mod_known_info_t; + diff --git a/dep/rehlsdk/engine/modelgen.h b/dep/rehlsdk/engine/modelgen.h index 1fa3b88..48fd9b8 100644 --- a/dep/rehlsdk/engine/modelgen.h +++ b/dep/rehlsdk/engine/modelgen.h @@ -1,128 +1,128 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#ifndef MODELGEN_H -#define MODELGEN_H -#ifdef _WIN32 -#pragma once -#endif - -typedef enum synctype_e -{ - ST_SYNC = 0, - ST_RAND = 1, -} synctype_t; - -typedef enum aliasframetype_s -{ - ALIAS_SINGLE = 0, - ALIAS_GROUP = 1, -} aliasframetype_t; - -typedef enum aliasskintype_s -{ - ALIAS_SKIN_SINGLE = 0, - ALIAS_SKIN_GROUP = 1, -} aliasskintype_t; - -typedef struct mdl_s -{ - int ident; - int version; - vec3_t scale; - vec3_t scale_origin; - float boundingradius; - vec3_t eyeposition; - int numskins; - int skinwidth; - int skinheight; - int numverts; - int numtris; - int numframes; - synctype_t synctype; - int flags; - float size; -} mdl_t; - -typedef struct stvert_s -{ - int onseam; - int s; - int t; -} stvert_t; - -typedef struct dtriangle_s -{ - int facesfront; - int vertindex[3]; -} dtriangle_t; - -typedef struct trivertx_s -{ - byte v[3]; - byte lightnormalindex; -} trivertx_t; - -typedef struct daliasframe_s -{ - trivertx_t bboxmin, bboxmax; - char name[16]; -} daliasframe_t; - -typedef struct daliasgroup_s -{ - int numframes; - trivertx_t bboxmin, bboxmax; -} daliasgroup_t; - -typedef struct daliasskingroup_s -{ - int numskins; -} daliasskingroup_t; - -typedef struct daliasinterval_s -{ - float interval; -} daliasinterval_t; - -typedef struct daliasskininterval_s -{ - float interval; -} daliasskininterval_t; - -typedef struct daliasframetype_s -{ - aliasframetype_t type; -} daliasframetype_t; - -typedef struct daliasskintype_s -{ - aliasskintype_t type; -} daliasskintype_t; - -#endif // MODELGEN_H +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + +#ifndef MODELGEN_H +#define MODELGEN_H +#ifdef _WIN32 +#pragma once +#endif + +typedef enum synctype_e +{ + ST_SYNC = 0, + ST_RAND = 1, +} synctype_t; + +typedef enum aliasframetype_s +{ + ALIAS_SINGLE = 0, + ALIAS_GROUP = 1, +} aliasframetype_t; + +typedef enum aliasskintype_s +{ + ALIAS_SKIN_SINGLE = 0, + ALIAS_SKIN_GROUP = 1, +} aliasskintype_t; + +typedef struct mdl_s +{ + int ident; + int version; + vec3_t scale; + vec3_t scale_origin; + float boundingradius; + vec3_t eyeposition; + int numskins; + int skinwidth; + int skinheight; + int numverts; + int numtris; + int numframes; + synctype_t synctype; + int flags; + float size; +} mdl_t; + +typedef struct stvert_s +{ + int onseam; + int s; + int t; +} stvert_t; + +typedef struct dtriangle_s +{ + int facesfront; + int vertindex[3]; +} dtriangle_t; + +typedef struct trivertx_s +{ + byte v[3]; + byte lightnormalindex; +} trivertx_t; + +typedef struct daliasframe_s +{ + trivertx_t bboxmin, bboxmax; + char name[16]; +} daliasframe_t; + +typedef struct daliasgroup_s +{ + int numframes; + trivertx_t bboxmin, bboxmax; +} daliasgroup_t; + +typedef struct daliasskingroup_s +{ + int numskins; +} daliasskingroup_t; + +typedef struct daliasinterval_s +{ + float interval; +} daliasinterval_t; + +typedef struct daliasskininterval_s +{ + float interval; +} daliasskininterval_t; + +typedef struct daliasframetype_s +{ + aliasframetype_t type; +} daliasframetype_t; + +typedef struct daliasskintype_s +{ + aliasskintype_t type; +} daliasskintype_t; + +#endif // MODELGEN_H diff --git a/dep/rehlsdk/engine/osconfig.h b/dep/rehlsdk/engine/osconfig.h index 0e31743..f9bc583 100644 --- a/dep/rehlsdk/engine/osconfig.h +++ b/dep/rehlsdk/engine/osconfig.h @@ -1,220 +1,220 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#ifndef _OSCONFIG_H -#define _OSCONFIG_H - -#ifdef _WIN32 // WINDOWS - #pragma warning(disable : 4005) -#endif // _WIN32 - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#ifdef _WIN32 // WINDOWS - #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - #include - #include - #include // for support IPX - #define PSAPI_VERSION 1 - #include - #include - #include - #include - #include - #include -#else // _WIN32 - #include - #include - //#include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -#endif // _WIN32 - -#include -#include -#include -#include - -#include -#include - - -#ifdef _WIN32 // WINDOWS - // Define __func__ on VS less than 2015 - #if _MSC_VER < 1900 - #define __func__ __FUNCTION__ - #endif - - #define _CRT_SECURE_NO_WARNINGS - #define WIN32_LEAN_AND_MEAN - - #ifndef CDECL - #define CDECL __cdecl - #endif - #define FASTCALL __fastcall - #define STDCALL __stdcall - #define HIDDEN - #define FORCEINLINE __forceinline - #define NOINLINE __declspec(noinline) - #define ALIGN16 __declspec(align(16)) - #define NORETURN __declspec(noreturn) - #define FORCE_STACK_ALIGN - #define FUNC_TARGET(x) - - #define __builtin_bswap16 _byteswap_ushort - #define __builtin_bswap32 _byteswap_ulong - #define __builtin_bswap64 _byteswap_uint64 - - //inline bool SOCKET_FIONBIO(SOCKET s, int m) { return (ioctlsocket(s, FIONBIO, (u_long*)&m) == 0); } - //inline int SOCKET_MSGLEN(SOCKET s, u_long& r) { return ioctlsocket(s, FIONREAD, (u_long*)&r); } - typedef int socklen_t; - #define SOCKET_FIONBIO(s, m) ioctlsocket(s, FIONBIO, (u_long*)&m) - #define SOCKET_MSGLEN(s, r) ioctlsocket(s, FIONREAD, (u_long*)&r) - #define SIN_GET_ADDR(saddr, r) r = (saddr)->S_un.S_addr - #define SIN_SET_ADDR(saddr, r) (saddr)->S_un.S_addr = (r) - #define SOCKET_CLOSE(s) closesocket(s) - #define SOCKET_AGAIN() (WSAGetLastError() == WSAEWOULDBLOCK) - - inline void* sys_allocmem(unsigned int size) { - return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE); - } - - inline void sys_freemem(void* ptr, unsigned int size) { - VirtualFree(ptr, 0, MEM_RELEASE); - } -#else // _WIN32 - #ifndef PAGESIZE - #define PAGESIZE 4096 - #endif - #define ALIGN(addr) (size_t)((size_t)addr & ~(PAGESIZE-1)) - #define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) - - #define _MAX_FNAME NAME_MAX - #define MAX_PATH 260 - - typedef void *HWND; - - typedef unsigned long DWORD; - typedef unsigned short WORD; - typedef unsigned int UNINT32; - - #define FASTCALL - #define CDECL __attribute__ ((cdecl)) - #define STDCALL __attribute__ ((stdcall)) - #define HIDDEN __attribute__((visibility("hidden"))) - #define FORCEINLINE inline - #define NOINLINE __attribute__((noinline)) - #define ALIGN16 __attribute__((aligned(16))) - #define NORETURN __attribute__((noreturn)) - #define FORCE_STACK_ALIGN __attribute__((force_align_arg_pointer)) - -#if defined __INTEL_COMPILER - #define FUNC_TARGET(x) - - #define __builtin_bswap16 _bswap16 - #define __builtin_bswap32 _bswap - #define __builtin_bswap64 _bswap64 -#else - #define FUNC_TARGET(x) __attribute__((target(x))) -#endif // __INTEL_COMPILER - - //inline bool SOCKET_FIONBIO(SOCKET s, int m) { return (ioctl(s, FIONBIO, (int*)&m) == 0); } - //inline int SOCKET_MSGLEN(SOCKET s, u_long& r) { return ioctl(s, FIONREAD, (int*)&r); } - typedef int SOCKET; - #define INVALID_SOCKET (SOCKET)(~0) - #define SOCKET_FIONBIO(s, m) ioctl(s, FIONBIO, (char*)&m) - #define SOCKET_MSGLEN(s, r) ioctl(s, FIONREAD, (char*)&r) - #define SIN_GET_ADDR(saddr, r) r = (saddr)->s_addr - #define SIN_SET_ADDR(saddr, r) (saddr)->s_addr = (r) - #define SOCKET_CLOSE(s) close(s) - #define SOCKET_AGAIN() (errno == EAGAIN) - #define SOCKET_ERROR -1 - - inline int ioctlsocket(int fd, int cmd, unsigned int *argp) { return ioctl(fd, cmd, argp); } - inline int closesocket(int fd) { return close(fd); } - inline int WSAGetLastError() { return errno; } - - inline void* sys_allocmem(unsigned int size) { - return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - } - inline void sys_freemem(void* ptr, unsigned int size) { - munmap(ptr, size); - } - - #define WSAENOPROTOOPT ENOPROTOOPT - - #ifndef FALSE - #define FALSE 0 - #endif - #ifndef TRUE - #define TRUE 1 - #endif -#endif // _WIN32 - -#ifdef _WIN32 - static const bool __isWindows = true; - static const bool __isLinux = false; -#else - static const bool __isWindows = false; - static const bool __isLinux = true; -#endif - -#define EXT_FUNC FORCE_STACK_ALIGN - -// Used to obtain the string name of a variable. -#define nameof_variable(name) template_nameof_variable(name, #name) -template const char* template_nameof_variable(const T& /*validate_type*/, const char* name) { return name; } - -#endif // _OSCONFIG_H +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + +#ifndef _OSCONFIG_H +#define _OSCONFIG_H + +#ifdef _WIN32 // WINDOWS + #pragma warning(disable : 4005) +#endif // _WIN32 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef _WIN32 // WINDOWS + #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + #include + #include + #include // for support IPX + #define PSAPI_VERSION 1 + #include + #include + #include + #include + #include + #include +#else // _WIN32 + #include + #include + //#include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#endif // _WIN32 + +#include +#include +#include +#include + +#include +#include + + +#ifdef _WIN32 // WINDOWS + // Define __func__ on VS less than 2015 + #if _MSC_VER < 1900 + #define __func__ __FUNCTION__ + #endif + + #define _CRT_SECURE_NO_WARNINGS + #define WIN32_LEAN_AND_MEAN + + #ifndef CDECL + #define CDECL __cdecl + #endif + #define FASTCALL __fastcall + #define STDCALL __stdcall + #define HIDDEN + #define FORCEINLINE __forceinline + #define NOINLINE __declspec(noinline) + #define ALIGN16 __declspec(align(16)) + #define NORETURN __declspec(noreturn) + #define FORCE_STACK_ALIGN + #define FUNC_TARGET(x) + + #define __builtin_bswap16 _byteswap_ushort + #define __builtin_bswap32 _byteswap_ulong + #define __builtin_bswap64 _byteswap_uint64 + + //inline bool SOCKET_FIONBIO(SOCKET s, int m) { return (ioctlsocket(s, FIONBIO, (u_long*)&m) == 0); } + //inline int SOCKET_MSGLEN(SOCKET s, u_long& r) { return ioctlsocket(s, FIONREAD, (u_long*)&r); } + typedef int socklen_t; + #define SOCKET_FIONBIO(s, m) ioctlsocket(s, FIONBIO, (u_long*)&m) + #define SOCKET_MSGLEN(s, r) ioctlsocket(s, FIONREAD, (u_long*)&r) + #define SIN_GET_ADDR(saddr, r) r = (saddr)->S_un.S_addr + #define SIN_SET_ADDR(saddr, r) (saddr)->S_un.S_addr = (r) + #define SOCKET_CLOSE(s) closesocket(s) + #define SOCKET_AGAIN() (WSAGetLastError() == WSAEWOULDBLOCK) + + inline void* sys_allocmem(unsigned int size) { + return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE); + } + + inline void sys_freemem(void* ptr, unsigned int size) { + VirtualFree(ptr, 0, MEM_RELEASE); + } +#else // _WIN32 + #ifndef PAGESIZE + #define PAGESIZE 4096 + #endif + #define ALIGN(addr) (size_t)((size_t)addr & ~(PAGESIZE-1)) + #define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) + + #define _MAX_FNAME NAME_MAX + #define MAX_PATH 260 + + typedef void *HWND; + + typedef unsigned long DWORD; + typedef unsigned short WORD; + typedef unsigned int UNINT32; + + #define FASTCALL + #define CDECL __attribute__ ((cdecl)) + #define STDCALL __attribute__ ((stdcall)) + #define HIDDEN __attribute__((visibility("hidden"))) + #define FORCEINLINE inline + #define NOINLINE __attribute__((noinline)) + #define ALIGN16 __attribute__((aligned(16))) + #define NORETURN __attribute__((noreturn)) + #define FORCE_STACK_ALIGN __attribute__((force_align_arg_pointer)) + +#if defined __INTEL_COMPILER + #define FUNC_TARGET(x) + + #define __builtin_bswap16 _bswap16 + #define __builtin_bswap32 _bswap + #define __builtin_bswap64 _bswap64 +#else + #define FUNC_TARGET(x) __attribute__((target(x))) +#endif // __INTEL_COMPILER + + //inline bool SOCKET_FIONBIO(SOCKET s, int m) { return (ioctl(s, FIONBIO, (int*)&m) == 0); } + //inline int SOCKET_MSGLEN(SOCKET s, u_long& r) { return ioctl(s, FIONREAD, (int*)&r); } + typedef int SOCKET; + #define INVALID_SOCKET (SOCKET)(~0) + #define SOCKET_FIONBIO(s, m) ioctl(s, FIONBIO, (char*)&m) + #define SOCKET_MSGLEN(s, r) ioctl(s, FIONREAD, (char*)&r) + #define SIN_GET_ADDR(saddr, r) r = (saddr)->s_addr + #define SIN_SET_ADDR(saddr, r) (saddr)->s_addr = (r) + #define SOCKET_CLOSE(s) close(s) + #define SOCKET_AGAIN() (errno == EAGAIN) + #define SOCKET_ERROR -1 + + inline int ioctlsocket(int fd, int cmd, unsigned int *argp) { return ioctl(fd, cmd, argp); } + inline int closesocket(int fd) { return close(fd); } + inline int WSAGetLastError() { return errno; } + + inline void* sys_allocmem(unsigned int size) { + return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + } + inline void sys_freemem(void* ptr, unsigned int size) { + munmap(ptr, size); + } + + #define WSAENOPROTOOPT ENOPROTOOPT + + #ifndef FALSE + #define FALSE 0 + #endif + #ifndef TRUE + #define TRUE 1 + #endif +#endif // _WIN32 + +#ifdef _WIN32 + static const bool __isWindows = true; + static const bool __isLinux = false; +#else + static const bool __isWindows = false; + static const bool __isLinux = true; +#endif + +#define EXT_FUNC FORCE_STACK_ALIGN + +// Used to obtain the string name of a variable. +#define nameof_variable(name) template_nameof_variable(name, #name) +template const char* template_nameof_variable(const T& /*validate_type*/, const char* name) { return name; } + +#endif // _OSCONFIG_H diff --git a/dep/rehlsdk/engine/progdefs.h b/dep/rehlsdk/engine/progdefs.h index d35382a..e27dc50 100644 --- a/dep/rehlsdk/engine/progdefs.h +++ b/dep/rehlsdk/engine/progdefs.h @@ -1,224 +1,224 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef PROGDEFS_H -#define PROGDEFS_H -#ifdef _WIN32 -#pragma once -#endif - -typedef struct globalvars_s -{ - float time; - float frametime; - float force_retouch; - string_t mapname; - string_t startspot; - float deathmatch_; - float coop_; - float teamplay; - float serverflags; - float found_secrets; - vec3_t v_forward; - vec3_t v_up; - vec3_t v_right; - float trace_allsolid; - float trace_startsolid; - float trace_fraction; - vec3_t trace_endpos; - vec3_t trace_plane_normal; - float trace_plane_dist; - edict_t *trace_ent; - float trace_inopen; - float trace_inwater; - int trace_hitgroup; - int trace_flags; - int msg_entity; - int cdAudioTrack; - int maxClients; - int maxEntities; - const char *pStringBase; - - void *pSaveData; - vec3_t vecLandmarkOffset; -} globalvars_t; - - -typedef struct entvars_s -{ - string_t classname; - string_t globalname; - - vec3_t origin; - vec3_t oldorigin; - vec3_t velocity; - vec3_t basevelocity; - vec3_t clbasevelocity; // Base velocity that was passed in to server physics so - // client can predict conveyors correctly. Server zeroes it, so we need to store here, too. - vec3_t movedir; - - vec3_t angles; // Model angles - vec3_t avelocity; // angle velocity (degrees per second) - vec3_t punchangle; // auto-decaying view angle adjustment - vec3_t v_angle; // Viewing angle (player only) - - // For parametric entities - vec3_t endpos; - vec3_t startpos; - float impacttime; - float starttime; - - int fixangle; // 0:nothing, 1:force view angles, 2:add avelocity - float idealpitch; - float pitch_speed; - float ideal_yaw; - float yaw_speed; - - int modelindex; - string_t model; - - int viewmodel; // player's viewmodel - int weaponmodel; // what other players see - - vec3_t absmin; // BB max translated to world coord - vec3_t absmax; // BB max translated to world coord - vec3_t mins; // local BB min - vec3_t maxs; // local BB max - vec3_t size; // maxs - mins - - float ltime; - float nextthink; - - int movetype; - int solid; - - int skin; - int body; // sub-model selection for studiomodels - int effects; - - float gravity; // % of "normal" gravity - float friction; // inverse elasticity of MOVETYPE_BOUNCE - - int light_level; - - int sequence; // animation sequence - int gaitsequence; // movement animation sequence for player (0 for none) - float frame; // % playback position in animation sequences (0..255) - float animtime; // world time when frame was set - float framerate; // animation playback rate (-8x to 8x) - byte controller[4]; // bone controller setting (0..255) - byte blending[2]; // blending amount between sub-sequences (0..255) - - float scale; // sprite rendering scale (0..255) - - int rendermode; - float renderamt; - vec3_t rendercolor; - int renderfx; - - float health; - float frags; - int weapons; // bit mask for available weapons - float takedamage; - - int deadflag; - vec3_t view_ofs; // eye position - - int button; - int impulse; - - edict_t *chain; // Entity pointer when linked into a linked list - edict_t *dmg_inflictor; - edict_t *enemy; - edict_t *aiment; // entity pointer when MOVETYPE_FOLLOW - edict_t *owner; - edict_t *groundentity; - - int spawnflags; - int flags; - - int colormap; // lowbyte topcolor, highbyte bottomcolor - int team; - - float max_health; - float teleport_time; - float armortype; - float armorvalue; - int waterlevel; - int watertype; - - string_t target; - string_t targetname; - string_t netname; - string_t message; - - float dmg_take; - float dmg_save; - float dmg; - float dmgtime; - - string_t noise; - string_t noise1; - string_t noise2; - string_t noise3; - - float speed; - float air_finished; - float pain_finished; - float radsuit_finished; - - edict_t *pContainingEntity; - - int playerclass; - float maxspeed; - - float fov; - int weaponanim; - - int pushmsec; - - int bInDuck; - int flTimeStepSound; - int flSwimTime; - int flDuckTime; - int iStepLeft; - float flFallVelocity; - - int gamestate; - - int oldbuttons; - - int groupinfo; - - // For mods - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; - vec3_t vuser1; - vec3_t vuser2; - vec3_t vuser3; - vec3_t vuser4; - edict_t *euser1; - edict_t *euser2; - edict_t *euser3; - edict_t *euser4; -} entvars_t; - - -#endif // PROGDEFS_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef PROGDEFS_H +#define PROGDEFS_H +#ifdef _WIN32 +#pragma once +#endif + +typedef struct globalvars_s +{ + float time; + float frametime; + float force_retouch; + string_t mapname; + string_t startspot; + float deathmatch_; + float coop_; + float teamplay; + float serverflags; + float found_secrets; + vec3_t v_forward; + vec3_t v_up; + vec3_t v_right; + float trace_allsolid; + float trace_startsolid; + float trace_fraction; + vec3_t trace_endpos; + vec3_t trace_plane_normal; + float trace_plane_dist; + edict_t *trace_ent; + float trace_inopen; + float trace_inwater; + int trace_hitgroup; + int trace_flags; + int msg_entity; + int cdAudioTrack; + int maxClients; + int maxEntities; + const char *pStringBase; + + void *pSaveData; + vec3_t vecLandmarkOffset; +} globalvars_t; + + +typedef struct entvars_s +{ + string_t classname; + string_t globalname; + + vec3_t origin; + vec3_t oldorigin; + vec3_t velocity; + vec3_t basevelocity; + vec3_t clbasevelocity; // Base velocity that was passed in to server physics so + // client can predict conveyors correctly. Server zeroes it, so we need to store here, too. + vec3_t movedir; + + vec3_t angles; // Model angles + vec3_t avelocity; // angle velocity (degrees per second) + vec3_t punchangle; // auto-decaying view angle adjustment + vec3_t v_angle; // Viewing angle (player only) + + // For parametric entities + vec3_t endpos; + vec3_t startpos; + float impacttime; + float starttime; + + int fixangle; // 0:nothing, 1:force view angles, 2:add avelocity + float idealpitch; + float pitch_speed; + float ideal_yaw; + float yaw_speed; + + int modelindex; + string_t model; + + int viewmodel; // player's viewmodel + int weaponmodel; // what other players see + + vec3_t absmin; // BB max translated to world coord + vec3_t absmax; // BB max translated to world coord + vec3_t mins; // local BB min + vec3_t maxs; // local BB max + vec3_t size; // maxs - mins + + float ltime; + float nextthink; + + int movetype; + int solid; + + int skin; + int body; // sub-model selection for studiomodels + int effects; + + float gravity; // % of "normal" gravity + float friction; // inverse elasticity of MOVETYPE_BOUNCE + + int light_level; + + int sequence; // animation sequence + int gaitsequence; // movement animation sequence for player (0 for none) + float frame; // % playback position in animation sequences (0..255) + float animtime; // world time when frame was set + float framerate; // animation playback rate (-8x to 8x) + byte controller[4]; // bone controller setting (0..255) + byte blending[2]; // blending amount between sub-sequences (0..255) + + float scale; // sprite rendering scale (0..255) + + int rendermode; + float renderamt; + vec3_t rendercolor; + int renderfx; + + float health; + float frags; + int weapons; // bit mask for available weapons + float takedamage; + + int deadflag; + vec3_t view_ofs; // eye position + + int button; + int impulse; + + edict_t *chain; // Entity pointer when linked into a linked list + edict_t *dmg_inflictor; + edict_t *enemy; + edict_t *aiment; // entity pointer when MOVETYPE_FOLLOW + edict_t *owner; + edict_t *groundentity; + + int spawnflags; + int flags; + + int colormap; // lowbyte topcolor, highbyte bottomcolor + int team; + + float max_health; + float teleport_time; + float armortype; + float armorvalue; + int waterlevel; + int watertype; + + string_t target; + string_t targetname; + string_t netname; + string_t message; + + float dmg_take; + float dmg_save; + float dmg; + float dmgtime; + + string_t noise; + string_t noise1; + string_t noise2; + string_t noise3; + + float speed; + float air_finished; + float pain_finished; + float radsuit_finished; + + edict_t *pContainingEntity; + + int playerclass; + float maxspeed; + + float fov; + int weaponanim; + + int pushmsec; + + int bInDuck; + int flTimeStepSound; + int flSwimTime; + int flDuckTime; + int iStepLeft; + float flFallVelocity; + + int gamestate; + + int oldbuttons; + + int groupinfo; + + // For mods + int iuser1; + int iuser2; + int iuser3; + int iuser4; + float fuser1; + float fuser2; + float fuser3; + float fuser4; + vec3_t vuser1; + vec3_t vuser2; + vec3_t vuser3; + vec3_t vuser4; + edict_t *euser1; + edict_t *euser2; + edict_t *euser3; + edict_t *euser4; +} entvars_t; + + +#endif // PROGDEFS_H diff --git a/dep/rehlsdk/engine/progs.h b/dep/rehlsdk/engine/progs.h index 1d1f885..fe4796e 100644 --- a/dep/rehlsdk/engine/progs.h +++ b/dep/rehlsdk/engine/progs.h @@ -1,82 +1,82 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef PROGS_H -#define PROGS_H - -#include "progdefs.h" - -// 16 simultaneous events, max -#define MAX_EVENT_QUEUE 64 - -#define DEFAULT_EVENT_RESENDS 1 - -#include "event_flags.h" - -typedef struct event_info_s event_info_t; - -#include "event_args.h" - -struct event_info_s -{ - unsigned short index; // 0 implies not in use - - short packet_index; // Use data from state info for entity in delta_packet . -1 implies separate info based on event - // parameter signature - short entity_index; // The edict this event is associated with - - float fire_time; // if non-zero, the time when the event should be fired ( fixed up on the client ) - - event_args_t args; - -// CLIENT ONLY - int flags; // Reliable or not, etc. - -}; - -typedef struct event_state_s event_state_t; - -struct event_state_s -{ - struct event_info_s ei[ MAX_EVENT_QUEUE ]; -}; - -#if !defined( ENTITY_STATEH ) -#include "entity_state.h" -#endif - -#if !defined( EDICT_H ) -#include "edict.h" -#endif - -#define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (int)&(((t *)0)->m))) -#define EDICT_FROM_AREA(l) STRUCT_FROM_LINK(l,edict_t,area) - -//============================================================================ - -extern char *pr_strings; -extern globalvars_t gGlobalVariables; - -//============================================================================ - -edict_t *ED_Alloc (void); -void ED_Free (edict_t *ed); -void ED_LoadFromFile (char *data); - -edict_t *EDICT_NUM(int n); -int NUM_FOR_EDICT(const edict_t *e); - -#define PROG_TO_EDICT(e) ((edict_t *)((byte *)sv.edicts + e)) - -#endif // PROGS_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef PROGS_H +#define PROGS_H + +#include "progdefs.h" + +// 16 simultaneous events, max +#define MAX_EVENT_QUEUE 64 + +#define DEFAULT_EVENT_RESENDS 1 + +#include "event_flags.h" + +typedef struct event_info_s event_info_t; + +#include "event_args.h" + +struct event_info_s +{ + unsigned short index; // 0 implies not in use + + short packet_index; // Use data from state info for entity in delta_packet . -1 implies separate info based on event + // parameter signature + short entity_index; // The edict this event is associated with + + float fire_time; // if non-zero, the time when the event should be fired ( fixed up on the client ) + + event_args_t args; + +// CLIENT ONLY + int flags; // Reliable or not, etc. + +}; + +typedef struct event_state_s event_state_t; + +struct event_state_s +{ + struct event_info_s ei[ MAX_EVENT_QUEUE ]; +}; + +#if !defined( ENTITY_STATEH ) +#include "entity_state.h" +#endif + +#if !defined( EDICT_H ) +#include "edict.h" +#endif + +#define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (int)&(((t *)0)->m))) +#define EDICT_FROM_AREA(l) STRUCT_FROM_LINK(l,edict_t,area) + +//============================================================================ + +extern char *pr_strings; +extern globalvars_t gGlobalVariables; + +//============================================================================ + +edict_t *ED_Alloc (void); +void ED_Free (edict_t *ed); +void ED_LoadFromFile (char *data); + +edict_t *EDICT_NUM(int n); +int NUM_FOR_EDICT(const edict_t *e); + +#define PROG_TO_EDICT(e) ((edict_t *)((byte *)sv.edicts + e)) + +#endif // PROGS_H diff --git a/dep/rehlsdk/engine/rehlds_api.h b/dep/rehlsdk/engine/rehlds_api.h index 938bd0c..1c272e4 100644 --- a/dep/rehlsdk/engine/rehlds_api.h +++ b/dep/rehlsdk/engine/rehlds_api.h @@ -1,314 +1,314 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once -#include "archtypes.h" -#include "cmd_rehlds.h" -#include "rehlds_interfaces.h" -#include "hookchains.h" -#include "FlightRecorder.h" -#include "interface.h" -#include "model.h" -#include "ObjectList.h" -#include "pr_dlls.h" - -#define REHLDS_API_VERSION_MAJOR 3 -#define REHLDS_API_VERSION_MINOR 3 - -//Steam_NotifyClientConnect hook -typedef IHookChain IRehldsHook_Steam_NotifyClientConnect; -typedef IHookChainRegistry IRehldsHookRegistry_Steam_NotifyClientConnect; - -//SV_ConnectClient hook -typedef IVoidHookChain<> IRehldsHook_SV_ConnectClient; -typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_ConnectClient; - -//SV_GetIDString hook -typedef IHookChain IRehldsHook_SV_GetIDString; -typedef IHookChainRegistry IRehldsHookRegistry_SV_GetIDString; - -//SV_SendServerinfo hook -typedef IVoidHookChain IRehldsHook_SV_SendServerinfo; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_SendServerinfo; - -//SV_CheckProtocol hook -typedef IHookChain IRehldsHook_SV_CheckProtocol; -typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckProtocol; - -//SVC_GetChallenge_mod hook -typedef IVoidHookChain IRehldsHook_SVC_GetChallenge_mod; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SVC_GetChallenge_mod; - -//SV_CheckKeyInfo hook -typedef IHookChain IRehldsHook_SV_CheckKeyInfo; -typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckKeyInfo; - -//SV_CheckIPRestrictions hook -typedef IHookChain IRehldsHook_SV_CheckIPRestrictions; -typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckIPRestrictions; - -//SV_FinishCertificateCheck hook -typedef IHookChain IRehldsHook_SV_FinishCertificateCheck; -typedef IHookChainRegistry IRehldsHookRegistry_SV_FinishCertificateCheck; - -//Steam_NotifyBotConnect hook -typedef IHookChain IRehldsHook_Steam_NotifyBotConnect; -typedef IHookChainRegistry IRehldsHookRegistry_Steam_NotifyBotConnect; - -//SerializeSteamId -typedef IVoidHookChain IRehldsHook_SerializeSteamId; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SerializeSteamId; - -//SV_CompareUserID hook -typedef IHookChain IRehldsHook_SV_CompareUserID; -typedef IHookChainRegistry IRehldsHookRegistry_SV_CompareUserID; - -//Steam_NotifyClientDisconnect -typedef IVoidHookChain IRehldsHook_Steam_NotifyClientDisconnect; -typedef IVoidHookChainRegistry IRehldsHookRegistry_Steam_NotifyClientDisconnect; - -//PreProcessPacket -typedef IHookChain IRehldsHook_PreprocessPacket; -typedef IHookChainRegistry IRehldsHookRegistry_PreprocessPacket; - -//ValidateCommand -typedef IHookChain IRehldsHook_ValidateCommand; -typedef IHookChainRegistry IRehldsHookRegistry_ValidateCommand; - -//ExecuteServerStringCmd -typedef IVoidHookChain IRehldsHook_ExecuteServerStringCmd; -typedef IVoidHookChainRegistry IRehldsHookRegistry_ExecuteServerStringCmd; - -//ClientConnected -typedef IVoidHookChain IRehldsHook_ClientConnected; -typedef IVoidHookChainRegistry IRehldsHookRegistry_ClientConnected; - -//HandleNetCommand -typedef IVoidHookChain IRehldsHook_HandleNetCommand; -typedef IVoidHookChainRegistry IRehldsHookRegistry_HandleNetCommand; - -//Mod_LoadBrushModel -typedef IVoidHookChain IRehldsHook_Mod_LoadBrushModel; -typedef IVoidHookChainRegistry IRehldsHookRegistry_Mod_LoadBrushModel; - -//Mod_LoadStudioModel -typedef IVoidHookChain IRehldsHook_Mod_LoadStudioModel; -typedef IVoidHookChainRegistry IRehldsHookRegistry_Mod_LoadStudioModel; - -//SV_EmitEvents hook -typedef IVoidHookChain IRehldsHook_SV_EmitEvents; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_EmitEvents; - -//EV_PlayReliableEvent hook -typedef IVoidHookChain IRehldsHook_EV_PlayReliableEvent; -typedef IVoidHookChainRegistry IRehldsHookRegistry_EV_PlayReliableEvent; - -//SV_StartSound hook -typedef IVoidHookChain IRehldsHook_SV_StartSound; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_StartSound; - -//PF_Remove_I hook -typedef IVoidHookChain IRehldsHook_PF_Remove_I; -typedef IVoidHookChainRegistry IRehldsHookRegistry_PF_Remove_I; - -//PF_BuildSoundMsg_I hook -typedef IVoidHookChain IRehldsHook_PF_BuildSoundMsg_I; -typedef IVoidHookChainRegistry IRehldsHookRegistry_PF_BuildSoundMsg_I; - -//SV_WriteFullClientUpdate hook -typedef IVoidHookChain IRehldsHook_SV_WriteFullClientUpdate; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_WriteFullClientUpdate; - -//SV_CheckConsistencyResponse hook -typedef IHookChain IRehldsHook_SV_CheckConsistencyResponse; -typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckConsistencyResponse; - -//SV_DropClient hook -typedef IVoidHookChain IRehldsHook_SV_DropClient; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_DropClient; - -//SV_ActivateServer hook -typedef IVoidHookChain IRehldsHook_SV_ActivateServer; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_ActivateServer; - -//SV_WriteVoiceCodec hook -typedef IVoidHookChain IRehldsHook_SV_WriteVoiceCodec; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_WriteVoiceCodec; - -//Steam_GSGetSteamID hook -typedef IHookChain IRehldsHook_Steam_GSGetSteamID; -typedef IHookChainRegistry IRehldsHookRegistry_Steam_GSGetSteamID; - -//SV_TransferConsistencyInfo hook -typedef IHookChain IRehldsHook_SV_TransferConsistencyInfo; -typedef IHookChainRegistry IRehldsHookRegistry_SV_TransferConsistencyInfo; - -//Steam_GSBUpdateUserData hook -typedef IHookChain IRehldsHook_Steam_GSBUpdateUserData; -typedef IHookChainRegistry IRehldsHookRegistry_Steam_GSBUpdateUserData; - -//Cvar_DirectSet hook -typedef IVoidHookChain IRehldsHook_Cvar_DirectSet; -typedef IVoidHookChainRegistry IRehldsHookRegistry_Cvar_DirectSet; - -//SV_EstablishTimeBase hook -typedef IVoidHookChain IRehldsHook_SV_EstablishTimeBase; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_EstablishTimeBase; - -//SV_Spawn_f hook -typedef IVoidHookChain<> IRehldsHook_SV_Spawn_f; -typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Spawn_f; - -//SV_CreatePacketEntities hook -typedef IHookChain IRehldsHook_SV_CreatePacketEntities; -typedef IHookChainRegistry IRehldsHookRegistry_SV_CreatePacketEntities; - -//SV_EmitSound2 hook -typedef IHookChain IRehldsHook_SV_EmitSound2; -typedef IHookChainRegistry IRehldsHookRegistry_SV_EmitSound2; - -//CreateFakeClient hook -typedef IHookChain IRehldsHook_CreateFakeClient; -typedef IHookChainRegistry IRehldsHookRegistry_CreateFakeClient; - -class IRehldsHookchains { -public: - virtual ~IRehldsHookchains() { } - - virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect() = 0; - virtual IRehldsHookRegistry_SV_ConnectClient* SV_ConnectClient() = 0; - virtual IRehldsHookRegistry_SV_GetIDString* SV_GetIDString() = 0; - virtual IRehldsHookRegistry_SV_SendServerinfo* SV_SendServerinfo() = 0; - virtual IRehldsHookRegistry_SV_CheckProtocol* SV_CheckProtocol() = 0; - virtual IRehldsHookRegistry_SVC_GetChallenge_mod* SVC_GetChallenge_mod() = 0; - virtual IRehldsHookRegistry_SV_CheckKeyInfo* SV_CheckKeyInfo() = 0; - virtual IRehldsHookRegistry_SV_CheckIPRestrictions* SV_CheckIPRestrictions() = 0; - virtual IRehldsHookRegistry_SV_FinishCertificateCheck* SV_FinishCertificateCheck() = 0; - virtual IRehldsHookRegistry_Steam_NotifyBotConnect* Steam_NotifyBotConnect() = 0; - virtual IRehldsHookRegistry_SerializeSteamId* SerializeSteamId() = 0; - virtual IRehldsHookRegistry_SV_CompareUserID* SV_CompareUserID() = 0; - virtual IRehldsHookRegistry_Steam_NotifyClientDisconnect* Steam_NotifyClientDisconnect() = 0; - virtual IRehldsHookRegistry_PreprocessPacket* PreprocessPacket() = 0; - virtual IRehldsHookRegistry_ValidateCommand* ValidateCommand() = 0; - virtual IRehldsHookRegistry_ClientConnected* ClientConnected() = 0; - virtual IRehldsHookRegistry_HandleNetCommand* HandleNetCommand() = 0; - virtual IRehldsHookRegistry_Mod_LoadBrushModel* Mod_LoadBrushModel() = 0; - virtual IRehldsHookRegistry_Mod_LoadStudioModel* Mod_LoadStudioModel() = 0; - virtual IRehldsHookRegistry_ExecuteServerStringCmd* ExecuteServerStringCmd() = 0; - virtual IRehldsHookRegistry_SV_EmitEvents* SV_EmitEvents() = 0; - virtual IRehldsHookRegistry_EV_PlayReliableEvent* EV_PlayReliableEvent() = 0; - virtual IRehldsHookRegistry_SV_StartSound* SV_StartSound() = 0; - virtual IRehldsHookRegistry_PF_Remove_I* PF_Remove_I() = 0; - virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I() = 0; - virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate() = 0; - virtual IRehldsHookRegistry_SV_CheckConsistencyResponse* SV_CheckConsistencyResponse() = 0; - virtual IRehldsHookRegistry_SV_DropClient* SV_DropClient() = 0; - virtual IRehldsHookRegistry_SV_ActivateServer* SV_ActivateServer() = 0; - virtual IRehldsHookRegistry_SV_WriteVoiceCodec* SV_WriteVoiceCodec() = 0; - virtual IRehldsHookRegistry_Steam_GSGetSteamID* Steam_GSGetSteamID() = 0; - virtual IRehldsHookRegistry_SV_TransferConsistencyInfo* SV_TransferConsistencyInfo() = 0; - virtual IRehldsHookRegistry_Steam_GSBUpdateUserData* Steam_GSBUpdateUserData() = 0; - virtual IRehldsHookRegistry_Cvar_DirectSet* Cvar_DirectSet() = 0; - virtual IRehldsHookRegistry_SV_EstablishTimeBase* SV_EstablishTimeBase() = 0; - virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f() = 0; - virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities() = 0; - virtual IRehldsHookRegistry_SV_EmitSound2* SV_EmitSound2() = 0; - virtual IRehldsHookRegistry_CreateFakeClient* CreateFakeClient() = 0; -}; - -struct RehldsFuncs_t { - void(*DropClient)(IGameClient* cl, bool crash, const char* fmt, ...); - void(*RejectConnection)(netadr_t *adr, char *fmt, ...); - qboolean(*SteamNotifyBotConnect)(IGameClient* cl); - sizebuf_t*(*GetNetMessage)(); - IGameClient*(*GetHostClient)(); - int*(*GetMsgReadCount)(); - qboolean(*FilterUser)(USERID_t*); - void(*NET_SendPacket)(unsigned int length, void *data, const netadr_t &to); - void(*TokenizeString)(char* s); - bool(*CheckChallenge)(const netadr_t& adr, int challenge); - void(*SendUserReg)(sizebuf_t* msg); - void(*WriteDeltaDescriptionsToClient)(sizebuf_t* msg); - void(*SetMoveVars)(); - void(*WriteMovevarsToClient)(sizebuf_t* msg); - char*(*GetClientFallback)(); - int*(*GetAllowCheats)(); - bool(*GSBSecure)(); - int(*GetBuildNumber)(); - double(*GetRealTime)(); - int*(*GetMsgBadRead)(); - cmd_source_t*(*GetCmdSource)(); - void(*Log)(const char* prefix, const char* msg); - DLL_FUNCTIONS *(*GetEntityInterface)(); - void(*EV_PlayReliableEvent)(IGameClient *cl, int entindex, unsigned short eventindex, float delay, struct event_args_s *pargs); - int(*SV_LookupSoundIndex)(const char *sample); - void(*MSG_StartBitWriting)(sizebuf_t *buf); - void(*MSG_WriteBits)(uint32 data, int numbits); - void(*MSG_WriteBitVec3Coord)(const float *fa); - void(*MSG_EndBitWriting)(sizebuf_t *buf); - void*(*SZ_GetSpace)(sizebuf_t *buf, int length); - cvar_t*(*GetCvarVars)(); - int (*SV_GetChallenge)(const netadr_t& adr); - void (*SV_AddResource)(resourcetype_t type, const char *name, int size, unsigned char flags, int index); - int(*MSG_ReadShort)(); - int(*MSG_ReadBuf)(int iSize, void *pbuf); - void(*MSG_WriteBuf)(sizebuf_t *sb, int iSize, void *buf); - void(*MSG_WriteByte)(sizebuf_t *sb, int c); - void(*MSG_WriteShort)(sizebuf_t *sb, int c); - void(*MSG_WriteString)(sizebuf_t *sb, const char *s); - void*(*GetPluginApi)(const char *name); - void(*RegisterPluginApi)(const char *name, void *impl); - qboolean(*SV_FileInConsistencyList)(const char *filename, struct consistency_s **ppconsist); - qboolean(*Steam_NotifyClientConnect)(IGameClient *cl, const void *pvSteam2Key, unsigned int ucbSteam2Key); - void(*Steam_NotifyClientDisconnect)(IGameClient* cl); - void(*SV_StartSound)(int recipients, edict_t *entity, int channel, const char *sample, int volume, float attenuation, int flags, int pitch); - bool(*SV_EmitSound2)(edict_t *entity, IGameClient *receiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin); - void(*SV_UpdateUserInfo)(IGameClient *pGameClient); - bool(*StripUnprintableAndSpace)(char *pch); - void(*Cmd_RemoveCmd)(const char *cmd_name); - void(*GetCommandMatches)(const char *string, ObjectList *pMatchList); - bool(*AddExtDll)(void *hModule); - void(*AddCvarListener)(const char *var_name, cvar_callback_t func); - void(*RemoveExtDll)(void *hModule); - void(*RemoveCvarListener)(const char *var_name, cvar_callback_t func); - ENTITYINIT(*GetEntityInit)(char *pszClassName); -}; - -class IRehldsApi { -public: - virtual ~IRehldsApi() { } - - virtual int GetMajorVersion() = 0; - virtual int GetMinorVersion() = 0; - virtual const RehldsFuncs_t* GetFuncs() = 0; - virtual IRehldsHookchains* GetHookchains() = 0; - virtual IRehldsServerStatic* GetServerStatic() = 0; - virtual IRehldsServerData* GetServerData() = 0; - virtual IRehldsFlightRecorder* GetFlightRecorder() = 0; -}; - -#define VREHLDS_HLDS_API_VERSION "VREHLDS_HLDS_API_VERSION001" +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ +#pragma once +#include "archtypes.h" +#include "cmd_rehlds.h" +#include "rehlds_interfaces.h" +#include "hookchains.h" +#include "FlightRecorder.h" +#include "interface.h" +#include "model.h" +#include "ObjectList.h" +#include "pr_dlls.h" + +#define REHLDS_API_VERSION_MAJOR 3 +#define REHLDS_API_VERSION_MINOR 3 + +//Steam_NotifyClientConnect hook +typedef IHookChain IRehldsHook_Steam_NotifyClientConnect; +typedef IHookChainRegistry IRehldsHookRegistry_Steam_NotifyClientConnect; + +//SV_ConnectClient hook +typedef IVoidHookChain<> IRehldsHook_SV_ConnectClient; +typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_ConnectClient; + +//SV_GetIDString hook +typedef IHookChain IRehldsHook_SV_GetIDString; +typedef IHookChainRegistry IRehldsHookRegistry_SV_GetIDString; + +//SV_SendServerinfo hook +typedef IVoidHookChain IRehldsHook_SV_SendServerinfo; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_SendServerinfo; + +//SV_CheckProtocol hook +typedef IHookChain IRehldsHook_SV_CheckProtocol; +typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckProtocol; + +//SVC_GetChallenge_mod hook +typedef IVoidHookChain IRehldsHook_SVC_GetChallenge_mod; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SVC_GetChallenge_mod; + +//SV_CheckKeyInfo hook +typedef IHookChain IRehldsHook_SV_CheckKeyInfo; +typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckKeyInfo; + +//SV_CheckIPRestrictions hook +typedef IHookChain IRehldsHook_SV_CheckIPRestrictions; +typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckIPRestrictions; + +//SV_FinishCertificateCheck hook +typedef IHookChain IRehldsHook_SV_FinishCertificateCheck; +typedef IHookChainRegistry IRehldsHookRegistry_SV_FinishCertificateCheck; + +//Steam_NotifyBotConnect hook +typedef IHookChain IRehldsHook_Steam_NotifyBotConnect; +typedef IHookChainRegistry IRehldsHookRegistry_Steam_NotifyBotConnect; + +//SerializeSteamId +typedef IVoidHookChain IRehldsHook_SerializeSteamId; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SerializeSteamId; + +//SV_CompareUserID hook +typedef IHookChain IRehldsHook_SV_CompareUserID; +typedef IHookChainRegistry IRehldsHookRegistry_SV_CompareUserID; + +//Steam_NotifyClientDisconnect +typedef IVoidHookChain IRehldsHook_Steam_NotifyClientDisconnect; +typedef IVoidHookChainRegistry IRehldsHookRegistry_Steam_NotifyClientDisconnect; + +//PreProcessPacket +typedef IHookChain IRehldsHook_PreprocessPacket; +typedef IHookChainRegistry IRehldsHookRegistry_PreprocessPacket; + +//ValidateCommand +typedef IHookChain IRehldsHook_ValidateCommand; +typedef IHookChainRegistry IRehldsHookRegistry_ValidateCommand; + +//ExecuteServerStringCmd +typedef IVoidHookChain IRehldsHook_ExecuteServerStringCmd; +typedef IVoidHookChainRegistry IRehldsHookRegistry_ExecuteServerStringCmd; + +//ClientConnected +typedef IVoidHookChain IRehldsHook_ClientConnected; +typedef IVoidHookChainRegistry IRehldsHookRegistry_ClientConnected; + +//HandleNetCommand +typedef IVoidHookChain IRehldsHook_HandleNetCommand; +typedef IVoidHookChainRegistry IRehldsHookRegistry_HandleNetCommand; + +//Mod_LoadBrushModel +typedef IVoidHookChain IRehldsHook_Mod_LoadBrushModel; +typedef IVoidHookChainRegistry IRehldsHookRegistry_Mod_LoadBrushModel; + +//Mod_LoadStudioModel +typedef IVoidHookChain IRehldsHook_Mod_LoadStudioModel; +typedef IVoidHookChainRegistry IRehldsHookRegistry_Mod_LoadStudioModel; + +//SV_EmitEvents hook +typedef IVoidHookChain IRehldsHook_SV_EmitEvents; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_EmitEvents; + +//EV_PlayReliableEvent hook +typedef IVoidHookChain IRehldsHook_EV_PlayReliableEvent; +typedef IVoidHookChainRegistry IRehldsHookRegistry_EV_PlayReliableEvent; + +//SV_StartSound hook +typedef IVoidHookChain IRehldsHook_SV_StartSound; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_StartSound; + +//PF_Remove_I hook +typedef IVoidHookChain IRehldsHook_PF_Remove_I; +typedef IVoidHookChainRegistry IRehldsHookRegistry_PF_Remove_I; + +//PF_BuildSoundMsg_I hook +typedef IVoidHookChain IRehldsHook_PF_BuildSoundMsg_I; +typedef IVoidHookChainRegistry IRehldsHookRegistry_PF_BuildSoundMsg_I; + +//SV_WriteFullClientUpdate hook +typedef IVoidHookChain IRehldsHook_SV_WriteFullClientUpdate; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_WriteFullClientUpdate; + +//SV_CheckConsistencyResponse hook +typedef IHookChain IRehldsHook_SV_CheckConsistencyResponse; +typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckConsistencyResponse; + +//SV_DropClient hook +typedef IVoidHookChain IRehldsHook_SV_DropClient; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_DropClient; + +//SV_ActivateServer hook +typedef IVoidHookChain IRehldsHook_SV_ActivateServer; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_ActivateServer; + +//SV_WriteVoiceCodec hook +typedef IVoidHookChain IRehldsHook_SV_WriteVoiceCodec; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_WriteVoiceCodec; + +//Steam_GSGetSteamID hook +typedef IHookChain IRehldsHook_Steam_GSGetSteamID; +typedef IHookChainRegistry IRehldsHookRegistry_Steam_GSGetSteamID; + +//SV_TransferConsistencyInfo hook +typedef IHookChain IRehldsHook_SV_TransferConsistencyInfo; +typedef IHookChainRegistry IRehldsHookRegistry_SV_TransferConsistencyInfo; + +//Steam_GSBUpdateUserData hook +typedef IHookChain IRehldsHook_Steam_GSBUpdateUserData; +typedef IHookChainRegistry IRehldsHookRegistry_Steam_GSBUpdateUserData; + +//Cvar_DirectSet hook +typedef IVoidHookChain IRehldsHook_Cvar_DirectSet; +typedef IVoidHookChainRegistry IRehldsHookRegistry_Cvar_DirectSet; + +//SV_EstablishTimeBase hook +typedef IVoidHookChain IRehldsHook_SV_EstablishTimeBase; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_EstablishTimeBase; + +//SV_Spawn_f hook +typedef IVoidHookChain<> IRehldsHook_SV_Spawn_f; +typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Spawn_f; + +//SV_CreatePacketEntities hook +typedef IHookChain IRehldsHook_SV_CreatePacketEntities; +typedef IHookChainRegistry IRehldsHookRegistry_SV_CreatePacketEntities; + +//SV_EmitSound2 hook +typedef IHookChain IRehldsHook_SV_EmitSound2; +typedef IHookChainRegistry IRehldsHookRegistry_SV_EmitSound2; + +//CreateFakeClient hook +typedef IHookChain IRehldsHook_CreateFakeClient; +typedef IHookChainRegistry IRehldsHookRegistry_CreateFakeClient; + +class IRehldsHookchains { +public: + virtual ~IRehldsHookchains() { } + + virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect() = 0; + virtual IRehldsHookRegistry_SV_ConnectClient* SV_ConnectClient() = 0; + virtual IRehldsHookRegistry_SV_GetIDString* SV_GetIDString() = 0; + virtual IRehldsHookRegistry_SV_SendServerinfo* SV_SendServerinfo() = 0; + virtual IRehldsHookRegistry_SV_CheckProtocol* SV_CheckProtocol() = 0; + virtual IRehldsHookRegistry_SVC_GetChallenge_mod* SVC_GetChallenge_mod() = 0; + virtual IRehldsHookRegistry_SV_CheckKeyInfo* SV_CheckKeyInfo() = 0; + virtual IRehldsHookRegistry_SV_CheckIPRestrictions* SV_CheckIPRestrictions() = 0; + virtual IRehldsHookRegistry_SV_FinishCertificateCheck* SV_FinishCertificateCheck() = 0; + virtual IRehldsHookRegistry_Steam_NotifyBotConnect* Steam_NotifyBotConnect() = 0; + virtual IRehldsHookRegistry_SerializeSteamId* SerializeSteamId() = 0; + virtual IRehldsHookRegistry_SV_CompareUserID* SV_CompareUserID() = 0; + virtual IRehldsHookRegistry_Steam_NotifyClientDisconnect* Steam_NotifyClientDisconnect() = 0; + virtual IRehldsHookRegistry_PreprocessPacket* PreprocessPacket() = 0; + virtual IRehldsHookRegistry_ValidateCommand* ValidateCommand() = 0; + virtual IRehldsHookRegistry_ClientConnected* ClientConnected() = 0; + virtual IRehldsHookRegistry_HandleNetCommand* HandleNetCommand() = 0; + virtual IRehldsHookRegistry_Mod_LoadBrushModel* Mod_LoadBrushModel() = 0; + virtual IRehldsHookRegistry_Mod_LoadStudioModel* Mod_LoadStudioModel() = 0; + virtual IRehldsHookRegistry_ExecuteServerStringCmd* ExecuteServerStringCmd() = 0; + virtual IRehldsHookRegistry_SV_EmitEvents* SV_EmitEvents() = 0; + virtual IRehldsHookRegistry_EV_PlayReliableEvent* EV_PlayReliableEvent() = 0; + virtual IRehldsHookRegistry_SV_StartSound* SV_StartSound() = 0; + virtual IRehldsHookRegistry_PF_Remove_I* PF_Remove_I() = 0; + virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I() = 0; + virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate() = 0; + virtual IRehldsHookRegistry_SV_CheckConsistencyResponse* SV_CheckConsistencyResponse() = 0; + virtual IRehldsHookRegistry_SV_DropClient* SV_DropClient() = 0; + virtual IRehldsHookRegistry_SV_ActivateServer* SV_ActivateServer() = 0; + virtual IRehldsHookRegistry_SV_WriteVoiceCodec* SV_WriteVoiceCodec() = 0; + virtual IRehldsHookRegistry_Steam_GSGetSteamID* Steam_GSGetSteamID() = 0; + virtual IRehldsHookRegistry_SV_TransferConsistencyInfo* SV_TransferConsistencyInfo() = 0; + virtual IRehldsHookRegistry_Steam_GSBUpdateUserData* Steam_GSBUpdateUserData() = 0; + virtual IRehldsHookRegistry_Cvar_DirectSet* Cvar_DirectSet() = 0; + virtual IRehldsHookRegistry_SV_EstablishTimeBase* SV_EstablishTimeBase() = 0; + virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f() = 0; + virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities() = 0; + virtual IRehldsHookRegistry_SV_EmitSound2* SV_EmitSound2() = 0; + virtual IRehldsHookRegistry_CreateFakeClient* CreateFakeClient() = 0; +}; + +struct RehldsFuncs_t { + void(*DropClient)(IGameClient* cl, bool crash, const char* fmt, ...); + void(*RejectConnection)(netadr_t *adr, char *fmt, ...); + qboolean(*SteamNotifyBotConnect)(IGameClient* cl); + sizebuf_t*(*GetNetMessage)(); + IGameClient*(*GetHostClient)(); + int*(*GetMsgReadCount)(); + qboolean(*FilterUser)(USERID_t*); + void(*NET_SendPacket)(unsigned int length, void *data, const netadr_t &to); + void(*TokenizeString)(char* s); + bool(*CheckChallenge)(const netadr_t& adr, int challenge); + void(*SendUserReg)(sizebuf_t* msg); + void(*WriteDeltaDescriptionsToClient)(sizebuf_t* msg); + void(*SetMoveVars)(); + void(*WriteMovevarsToClient)(sizebuf_t* msg); + char*(*GetClientFallback)(); + int*(*GetAllowCheats)(); + bool(*GSBSecure)(); + int(*GetBuildNumber)(); + double(*GetRealTime)(); + int*(*GetMsgBadRead)(); + cmd_source_t*(*GetCmdSource)(); + void(*Log)(const char* prefix, const char* msg); + DLL_FUNCTIONS *(*GetEntityInterface)(); + void(*EV_PlayReliableEvent)(IGameClient *cl, int entindex, unsigned short eventindex, float delay, struct event_args_s *pargs); + int(*SV_LookupSoundIndex)(const char *sample); + void(*MSG_StartBitWriting)(sizebuf_t *buf); + void(*MSG_WriteBits)(uint32 data, int numbits); + void(*MSG_WriteBitVec3Coord)(const float *fa); + void(*MSG_EndBitWriting)(sizebuf_t *buf); + void*(*SZ_GetSpace)(sizebuf_t *buf, int length); + cvar_t*(*GetCvarVars)(); + int (*SV_GetChallenge)(const netadr_t& adr); + void (*SV_AddResource)(resourcetype_t type, const char *name, int size, unsigned char flags, int index); + int(*MSG_ReadShort)(); + int(*MSG_ReadBuf)(int iSize, void *pbuf); + void(*MSG_WriteBuf)(sizebuf_t *sb, int iSize, void *buf); + void(*MSG_WriteByte)(sizebuf_t *sb, int c); + void(*MSG_WriteShort)(sizebuf_t *sb, int c); + void(*MSG_WriteString)(sizebuf_t *sb, const char *s); + void*(*GetPluginApi)(const char *name); + void(*RegisterPluginApi)(const char *name, void *impl); + qboolean(*SV_FileInConsistencyList)(const char *filename, struct consistency_s **ppconsist); + qboolean(*Steam_NotifyClientConnect)(IGameClient *cl, const void *pvSteam2Key, unsigned int ucbSteam2Key); + void(*Steam_NotifyClientDisconnect)(IGameClient* cl); + void(*SV_StartSound)(int recipients, edict_t *entity, int channel, const char *sample, int volume, float attenuation, int flags, int pitch); + bool(*SV_EmitSound2)(edict_t *entity, IGameClient *receiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin); + void(*SV_UpdateUserInfo)(IGameClient *pGameClient); + bool(*StripUnprintableAndSpace)(char *pch); + void(*Cmd_RemoveCmd)(const char *cmd_name); + void(*GetCommandMatches)(const char *string, ObjectList *pMatchList); + bool(*AddExtDll)(void *hModule); + void(*AddCvarListener)(const char *var_name, cvar_callback_t func); + void(*RemoveExtDll)(void *hModule); + void(*RemoveCvarListener)(const char *var_name, cvar_callback_t func); + ENTITYINIT(*GetEntityInit)(char *pszClassName); +}; + +class IRehldsApi { +public: + virtual ~IRehldsApi() { } + + virtual int GetMajorVersion() = 0; + virtual int GetMinorVersion() = 0; + virtual const RehldsFuncs_t* GetFuncs() = 0; + virtual IRehldsHookchains* GetHookchains() = 0; + virtual IRehldsServerStatic* GetServerStatic() = 0; + virtual IRehldsServerData* GetServerData() = 0; + virtual IRehldsFlightRecorder* GetFlightRecorder() = 0; +}; + +#define VREHLDS_HLDS_API_VERSION "VREHLDS_HLDS_API_VERSION001" diff --git a/dep/rehlsdk/engine/rehlds_interfaces.h b/dep/rehlsdk/engine/rehlds_interfaces.h index 7d6a086..e2b909f 100644 --- a/dep/rehlsdk/engine/rehlds_interfaces.h +++ b/dep/rehlsdk/engine/rehlds_interfaces.h @@ -1,132 +1,132 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -class INetChan; -class IGameClient; - -#include "archtypes.h" -#include "const.h" -#include "netadr.h" - -#include "common_rehlds.h" -#include "userid_rehlds.h" - -#ifdef REHLDS_SELF -#include "server.h" -#endif - -class INetChan; -class IGameClient; - -class IGameClient { -public: - virtual int GetId() = 0; - - virtual bool IsActive() = 0; - virtual void SetActive(bool active) = 0; - - virtual bool IsSpawned() = 0; - virtual void SetSpawned(bool spawned) = 0; - - virtual INetChan* GetNetChan() = 0; - - virtual sizebuf_t* GetDatagram() = 0; - - virtual edict_t* GetEdict() = 0; - - virtual USERID_t* GetNetworkUserID() = 0; - - virtual const char* GetName() = 0; - - virtual bool IsConnected() = 0; - virtual void SetConnected(bool connected) = 0; - - virtual uint32 GetVoiceStream(int stream_id) = 0; - virtual void SetLastVoiceTime(double time) = 0; - virtual double GetLastVoiceTime() = 0; - virtual bool GetLoopback() = 0; - virtual struct usercmd_s *GetLastCmd() = 0; - - // this must be the last virtual function in class -#ifdef REHLDS_SELF - virtual client_t* GetClient() = 0; -#endif -}; - -class INetChan { -public: - virtual const netadr_t* GetRemoteAdr() = 0; - virtual sizebuf_t* GetMessageBuf() = 0; - - - // this must be the last virtual function in class -#ifdef REHLDS_SELF - virtual netchan_t* GetChan() = 0; -#endif -}; - -#ifndef REHLDS_SELF -struct client_t; -#endif - -class IRehldsServerStatic { -public: - virtual ~IRehldsServerStatic() { } - - virtual int GetMaxClients() = 0; - virtual bool IsLogActive() = 0; - virtual IGameClient* GetClient(int id) = 0; - virtual client_t* GetClient_t(int id) = 0; - virtual int GetIndexOfClient_t(client_t* client) = 0; -}; - -class IRehldsServerData { -public: - virtual ~IRehldsServerData() { } - - virtual const char* GetModelName() = 0; - virtual const char* GetName() = 0; - virtual uint32 GetWorldmapCrc() = 0; - virtual uint8* GetClientDllMd5() = 0; - virtual sizebuf_t* GetDatagram() = 0; - virtual sizebuf_t* GetReliableDatagram() = 0; - - virtual void SetModelName(const char* modelname) = 0; - virtual void SetConsistencyNum(int num) = 0; - virtual int GetConsistencyNum() = 0; - virtual int GetResourcesNum() = 0; - virtual int GetDecalNameNum() = 0; - - virtual double GetTime() = 0; - virtual void SetResourcesNum(int num) = 0; - virtual struct resource_s *GetResource(int index) = 0; - virtual void SetName(const char* name) = 0; - virtual class ISteamGameServer *GetSteamGameServer() = 0; - virtual struct netadr_s *GetNetFrom() = 0; -}; +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ +#pragma once + +class INetChan; +class IGameClient; + +#include "archtypes.h" +#include "const.h" +#include "netadr.h" + +#include "common_rehlds.h" +#include "userid_rehlds.h" + +#ifdef REHLDS_SELF +#include "server.h" +#endif + +class INetChan; +class IGameClient; + +class IGameClient { +public: + virtual int GetId() = 0; + + virtual bool IsActive() = 0; + virtual void SetActive(bool active) = 0; + + virtual bool IsSpawned() = 0; + virtual void SetSpawned(bool spawned) = 0; + + virtual INetChan* GetNetChan() = 0; + + virtual sizebuf_t* GetDatagram() = 0; + + virtual edict_t* GetEdict() = 0; + + virtual USERID_t* GetNetworkUserID() = 0; + + virtual const char* GetName() = 0; + + virtual bool IsConnected() = 0; + virtual void SetConnected(bool connected) = 0; + + virtual uint32 GetVoiceStream(int stream_id) = 0; + virtual void SetLastVoiceTime(double time) = 0; + virtual double GetLastVoiceTime() = 0; + virtual bool GetLoopback() = 0; + virtual struct usercmd_s *GetLastCmd() = 0; + + // this must be the last virtual function in class +#ifdef REHLDS_SELF + virtual client_t* GetClient() = 0; +#endif +}; + +class INetChan { +public: + virtual const netadr_t* GetRemoteAdr() = 0; + virtual sizebuf_t* GetMessageBuf() = 0; + + + // this must be the last virtual function in class +#ifdef REHLDS_SELF + virtual netchan_t* GetChan() = 0; +#endif +}; + +#ifndef REHLDS_SELF +struct client_t; +#endif + +class IRehldsServerStatic { +public: + virtual ~IRehldsServerStatic() { } + + virtual int GetMaxClients() = 0; + virtual bool IsLogActive() = 0; + virtual IGameClient* GetClient(int id) = 0; + virtual client_t* GetClient_t(int id) = 0; + virtual int GetIndexOfClient_t(client_t* client) = 0; +}; + +class IRehldsServerData { +public: + virtual ~IRehldsServerData() { } + + virtual const char* GetModelName() = 0; + virtual const char* GetName() = 0; + virtual uint32 GetWorldmapCrc() = 0; + virtual uint8* GetClientDllMd5() = 0; + virtual sizebuf_t* GetDatagram() = 0; + virtual sizebuf_t* GetReliableDatagram() = 0; + + virtual void SetModelName(const char* modelname) = 0; + virtual void SetConsistencyNum(int num) = 0; + virtual int GetConsistencyNum() = 0; + virtual int GetResourcesNum() = 0; + virtual int GetDecalNameNum() = 0; + + virtual double GetTime() = 0; + virtual void SetResourcesNum(int num) = 0; + virtual struct resource_s *GetResource(int index) = 0; + virtual void SetName(const char* name) = 0; + virtual class ISteamGameServer *GetSteamGameServer() = 0; + virtual struct netadr_s *GetNetFrom() = 0; +}; diff --git a/dep/rehlsdk/engine/shake.h b/dep/rehlsdk/engine/shake.h index b31f478..1146a5e 100644 --- a/dep/rehlsdk/engine/shake.h +++ b/dep/rehlsdk/engine/shake.h @@ -1,57 +1,57 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef SHAKE_H -#define SHAKE_H - -// Screen / View effects - -// screen shake -extern int gmsgShake; - -// This structure is sent over the net to describe a screen shake event -typedef struct -{ - unsigned short amplitude; // FIXED 4.12 amount of shake - unsigned short duration; // FIXED 4.12 seconds duration - unsigned short frequency; // FIXED 8.8 noise frequency (low frequency is a jerk,high frequency is a rumble) -} ScreenShake; - -extern void V_ApplyShake( float *origin, float *angles, float factor ); -extern void V_CalcShake( void ); -extern int V_ScreenShake( const char *pszName, int iSize, void *pbuf ); -extern int V_ScreenFade( const char *pszName, int iSize, void *pbuf ); - - -// Fade in/out -extern int gmsgFade; - -#define FFADE_IN 0x0000 // Just here so we don't pass 0 into the function -#define FFADE_OUT 0x0001 // Fade out (not in) -#define FFADE_MODULATE 0x0002 // Modulate (don't blend) -#define FFADE_STAYOUT 0x0004 // ignores the duration, stays faded out until new ScreenFade message received -#define FFADE_LONGFADE 0x0008 // used to indicate the fade can be longer than 16 seconds (added for czero) - - -// This structure is sent over the net to describe a screen fade event -typedef struct -{ - unsigned short duration; // FIXED 4.12 seconds duration - unsigned short holdTime; // FIXED 4.12 seconds duration until reset (fade & hold) - short fadeFlags; // flags - byte r, g, b, a; // fade to color ( max alpha ) -} ScreenFade; - -#endif // SHAKE_H - +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef SHAKE_H +#define SHAKE_H + +// Screen / View effects + +// screen shake +extern int gmsgShake; + +// This structure is sent over the net to describe a screen shake event +typedef struct +{ + unsigned short amplitude; // FIXED 4.12 amount of shake + unsigned short duration; // FIXED 4.12 seconds duration + unsigned short frequency; // FIXED 8.8 noise frequency (low frequency is a jerk,high frequency is a rumble) +} ScreenShake; + +extern void V_ApplyShake( float *origin, float *angles, float factor ); +extern void V_CalcShake( void ); +extern int V_ScreenShake( const char *pszName, int iSize, void *pbuf ); +extern int V_ScreenFade( const char *pszName, int iSize, void *pbuf ); + + +// Fade in/out +extern int gmsgFade; + +#define FFADE_IN 0x0000 // Just here so we don't pass 0 into the function +#define FFADE_OUT 0x0001 // Fade out (not in) +#define FFADE_MODULATE 0x0002 // Modulate (don't blend) +#define FFADE_STAYOUT 0x0004 // ignores the duration, stays faded out until new ScreenFade message received +#define FFADE_LONGFADE 0x0008 // used to indicate the fade can be longer than 16 seconds (added for czero) + + +// This structure is sent over the net to describe a screen fade event +typedef struct +{ + unsigned short duration; // FIXED 4.12 seconds duration + unsigned short holdTime; // FIXED 4.12 seconds duration until reset (fade & hold) + short fadeFlags; // flags + byte r, g, b, a; // fade to color ( max alpha ) +} ScreenFade; + +#endif // SHAKE_H + diff --git a/dep/rehlsdk/engine/spritegn.h b/dep/rehlsdk/engine/spritegn.h index 959b3d6..f6145d7 100644 --- a/dep/rehlsdk/engine/spritegn.h +++ b/dep/rehlsdk/engine/spritegn.h @@ -1,84 +1,84 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#ifndef SPRITEGN_H -#define SPRITEGN_H -#ifdef _WIN32 -#pragma once -#endif - -#include "modelgen.h" -#include "commonmacros.h" - -#define SPRITE_VERSION 2 // Half-Life sprites -#define IDSPRITEHEADER MAKEID('I', 'D', 'S', 'P') // little-endian "IDSP" - -typedef enum spriteframetype_e -{ - SPR_SINGLE = 0, - SPR_GROUP, - SPR_ANGLED -} spriteframetype_t; - -typedef struct dsprite_s -{ - int ident; - int version; - int type; - int texFormat; - float boundingradius; - int width; - int height; - int numframes; - float beamlength; - synctype_t synctype; -} dsprite_t; - -typedef struct dspriteframe_s -{ - int origin[2]; - int width; - int height; -} dspriteframe_t; - -typedef struct dspritegroup_s -{ - int numframes; -} dspritegroup_t; - -typedef struct dspriteinterval_s -{ - float interval; -} dspriteinterval_t; - -typedef struct dspriteframetype_s -{ - spriteframetype_t type; -} dspriteframetype_t; - -#endif // SPRITEGN_H +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ + +#ifndef SPRITEGN_H +#define SPRITEGN_H +#ifdef _WIN32 +#pragma once +#endif + +#include "modelgen.h" +#include "commonmacros.h" + +#define SPRITE_VERSION 2 // Half-Life sprites +#define IDSPRITEHEADER MAKEID('I', 'D', 'S', 'P') // little-endian "IDSP" + +typedef enum spriteframetype_e +{ + SPR_SINGLE = 0, + SPR_GROUP, + SPR_ANGLED +} spriteframetype_t; + +typedef struct dsprite_s +{ + int ident; + int version; + int type; + int texFormat; + float boundingradius; + int width; + int height; + int numframes; + float beamlength; + synctype_t synctype; +} dsprite_t; + +typedef struct dspriteframe_s +{ + int origin[2]; + int width; + int height; +} dspriteframe_t; + +typedef struct dspritegroup_s +{ + int numframes; +} dspritegroup_t; + +typedef struct dspriteinterval_s +{ + float interval; +} dspriteinterval_t; + +typedef struct dspriteframetype_s +{ + spriteframetype_t type; +} dspriteframetype_t; + +#endif // SPRITEGN_H diff --git a/dep/rehlsdk/engine/static_map.h b/dep/rehlsdk/engine/static_map.h index 11235d7..d19033a 100644 --- a/dep/rehlsdk/engine/static_map.h +++ b/dep/rehlsdk/engine/static_map.h @@ -1,257 +1,257 @@ -#pragma once - -#include "archtypes.h" -#include "crc32c.h" - -template -class CStaticMap { -protected: - virtual uint32 hash(const T_KEY& val) { - return crc32c((const unsigned char*)&val, sizeof(T_KEY)); - } - - virtual bool equals(const T_KEY& val1, const T_KEY& val2) { - return 0 == memcmp(&val1, &val2, sizeof(T_KEY)); - } - - struct map_node_t { - map_node_t* prev; - map_node_t* next; - T_KEY key; - T_VAL val; - }; - -private: - map_node_t* m_RootNodes[1 << ASSOC_2N]; - map_node_t m_AllNodes[MAX_VALS]; - map_node_t* m_FreeRoot; - - unsigned int GetRoodNodeId(const T_KEY& val) { return hash(val) & (0xFFFFFFFF >> (32 - ASSOC_2N)); } - - void unlink(map_node_t* node) { - map_node_t* prev = node->prev; - map_node_t* next = node->next; - - if (prev) { - prev->next = next; - } - - if (next) { - next->prev = prev; - } - - if (!prev) { - // this was a root node - unsigned int rootId = GetRoodNodeId(node->key); - if (m_RootNodes[rootId] != node) { - Sys_Error("%s: invalid root node", __func__); - return; - } - - m_RootNodes[rootId] = next; - } - } - - void link(map_node_t* node) { - unsigned int rootId = GetRoodNodeId(node->key); - map_node_t* root = m_RootNodes[rootId]; - node->prev = NULL; - node->next = root; - - if (root) { - root->prev = node; - } - - m_RootNodes[rootId] = node; - } - - void linkToFreeStack(map_node_t* node) { - node->next = m_FreeRoot; - if (m_FreeRoot) { - m_FreeRoot->prev = node; - } - m_FreeRoot = node; - } - -public: - CStaticMap() { - clear(); - } - - void clear() { - memset(m_RootNodes, 0, sizeof(m_RootNodes)); - memset(m_AllNodes, 0, sizeof(m_AllNodes)); - m_FreeRoot = NULL; - - for (int i = 0; i < MAX_VALS; i++) { - linkToFreeStack(&m_AllNodes[i]); - } - } - - map_node_t* get(const T_KEY& key) { - unsigned int rootId = GetRoodNodeId(key); - map_node_t* n = m_RootNodes[rootId]; - while (n) { - if (equals(n->key, key)) { - return n; - } - n = n->next; - } - return NULL; - } - - bool put(const T_KEY& key, T_VAL& val) { - map_node_t* n = get(key); - if (n) { - n->val = val; - return true; - } - - if (!m_FreeRoot) { - return false; - } - - n = m_FreeRoot; - m_FreeRoot = m_FreeRoot->next; - - n->key = key; - n->val = val; - - unsigned int rootId = GetRoodNodeId(key); - map_node_t* root = m_RootNodes[rootId]; - - if (root) { - root->prev = n; - } - - n->prev = NULL; - n->next = root; - m_RootNodes[rootId] = n; - - return true; - } - - void remove(map_node_t* node) { - unlink(node); - linkToFreeStack(node); - } - - bool remove(const T_KEY& key) { - map_node_t* n = get(key); - if (!n) { - return false; - } - - remove(n); - return true; - } - - class Iterator { - friend class CStaticMap; - protected: - CStaticMap* m_Map; - map_node_t** m_RootNodes; - unsigned int m_NextRootNode; - map_node_t* m_CurNode; - - void searchForNextNode() { - if (m_CurNode && m_CurNode->next) { - m_CurNode = m_CurNode->next; - return; - } - - m_CurNode = NULL; - while (!m_CurNode) { - if (m_NextRootNode >= (1 << ASSOC_2N)) { - return; - } - m_CurNode = m_RootNodes[m_NextRootNode++]; - } - } - - - Iterator(CStaticMap* m) { - m_Map = m; - m_RootNodes = m_Map->m_RootNodes; - m_NextRootNode = 0; - m_CurNode = NULL; - searchForNextNode(); - } - - public: - map_node_t* next() { - searchForNextNode(); - return m_CurNode; - } - - map_node_t* current() { - return m_CurNode; - } - - void remove() { - m_Map->remove(m_CurNode); - m_CurNode = NULL; - } - - bool hasElement() { - return m_CurNode != NULL; - } - }; - - Iterator iterator() { - return Iterator(this); - } -}; - -template -class CStringKeyStaticMap : public CStaticMap { -protected: - virtual uint32 hash(const char* const &val) { - return crc32c((const unsigned char*)val, strlen(val)); - } - - virtual bool equals(const char* const &val1, const char* const &val2) { - return !strcmp(val1, val2); - } - -public: - CStringKeyStaticMap() { - } - -}; - -template -class CICaseStringKeyStaticMap : public CStaticMap { -protected: - virtual uint32 hash(const char* const &val) { - uint32 cksum = 0; - const char* pcc = val; - if (cpuinfo.sse4_2) { - while (*pcc) { - char cc = *(pcc++); - if (cc >= 'A' || cc <= 'Z') { - cc |= 0x20; - } - cksum = crc32c_t8_sse(cksum, cc); - } - } else { - while (*pcc) { - char cc = *(pcc++); - if (cc >= 'A' || cc <= 'Z') { - cc |= 0x20; - } - cksum = crc32c_t8_nosse(cksum, cc); - } - } - return cksum; - } - - virtual bool equals(const char* const &val1, const char* const &val2) { - return !_stricmp(val1, val2); - } - -public: - CICaseStringKeyStaticMap() { - } - -}; +#pragma once + +#include "archtypes.h" +#include "crc32c.h" + +template +class CStaticMap { +protected: + virtual uint32 hash(const T_KEY& val) { + return crc32c((const unsigned char*)&val, sizeof(T_KEY)); + } + + virtual bool equals(const T_KEY& val1, const T_KEY& val2) { + return 0 == memcmp(&val1, &val2, sizeof(T_KEY)); + } + + struct map_node_t { + map_node_t* prev; + map_node_t* next; + T_KEY key; + T_VAL val; + }; + +private: + map_node_t* m_RootNodes[1 << ASSOC_2N]; + map_node_t m_AllNodes[MAX_VALS]; + map_node_t* m_FreeRoot; + + unsigned int GetRoodNodeId(const T_KEY& val) { return hash(val) & (0xFFFFFFFF >> (32 - ASSOC_2N)); } + + void unlink(map_node_t* node) { + map_node_t* prev = node->prev; + map_node_t* next = node->next; + + if (prev) { + prev->next = next; + } + + if (next) { + next->prev = prev; + } + + if (!prev) { + // this was a root node + unsigned int rootId = GetRoodNodeId(node->key); + if (m_RootNodes[rootId] != node) { + Sys_Error("%s: invalid root node", __func__); + return; + } + + m_RootNodes[rootId] = next; + } + } + + void link(map_node_t* node) { + unsigned int rootId = GetRoodNodeId(node->key); + map_node_t* root = m_RootNodes[rootId]; + node->prev = NULL; + node->next = root; + + if (root) { + root->prev = node; + } + + m_RootNodes[rootId] = node; + } + + void linkToFreeStack(map_node_t* node) { + node->next = m_FreeRoot; + if (m_FreeRoot) { + m_FreeRoot->prev = node; + } + m_FreeRoot = node; + } + +public: + CStaticMap() { + clear(); + } + + void clear() { + memset(m_RootNodes, 0, sizeof(m_RootNodes)); + memset(m_AllNodes, 0, sizeof(m_AllNodes)); + m_FreeRoot = NULL; + + for (int i = 0; i < MAX_VALS; i++) { + linkToFreeStack(&m_AllNodes[i]); + } + } + + map_node_t* get(const T_KEY& key) { + unsigned int rootId = GetRoodNodeId(key); + map_node_t* n = m_RootNodes[rootId]; + while (n) { + if (equals(n->key, key)) { + return n; + } + n = n->next; + } + return NULL; + } + + bool put(const T_KEY& key, T_VAL& val) { + map_node_t* n = get(key); + if (n) { + n->val = val; + return true; + } + + if (!m_FreeRoot) { + return false; + } + + n = m_FreeRoot; + m_FreeRoot = m_FreeRoot->next; + + n->key = key; + n->val = val; + + unsigned int rootId = GetRoodNodeId(key); + map_node_t* root = m_RootNodes[rootId]; + + if (root) { + root->prev = n; + } + + n->prev = NULL; + n->next = root; + m_RootNodes[rootId] = n; + + return true; + } + + void remove(map_node_t* node) { + unlink(node); + linkToFreeStack(node); + } + + bool remove(const T_KEY& key) { + map_node_t* n = get(key); + if (!n) { + return false; + } + + remove(n); + return true; + } + + class Iterator { + friend class CStaticMap; + protected: + CStaticMap* m_Map; + map_node_t** m_RootNodes; + unsigned int m_NextRootNode; + map_node_t* m_CurNode; + + void searchForNextNode() { + if (m_CurNode && m_CurNode->next) { + m_CurNode = m_CurNode->next; + return; + } + + m_CurNode = NULL; + while (!m_CurNode) { + if (m_NextRootNode >= (1 << ASSOC_2N)) { + return; + } + m_CurNode = m_RootNodes[m_NextRootNode++]; + } + } + + + Iterator(CStaticMap* m) { + m_Map = m; + m_RootNodes = m_Map->m_RootNodes; + m_NextRootNode = 0; + m_CurNode = NULL; + searchForNextNode(); + } + + public: + map_node_t* next() { + searchForNextNode(); + return m_CurNode; + } + + map_node_t* current() { + return m_CurNode; + } + + void remove() { + m_Map->remove(m_CurNode); + m_CurNode = NULL; + } + + bool hasElement() { + return m_CurNode != NULL; + } + }; + + Iterator iterator() { + return Iterator(this); + } +}; + +template +class CStringKeyStaticMap : public CStaticMap { +protected: + virtual uint32 hash(const char* const &val) { + return crc32c((const unsigned char*)val, strlen(val)); + } + + virtual bool equals(const char* const &val1, const char* const &val2) { + return !strcmp(val1, val2); + } + +public: + CStringKeyStaticMap() { + } + +}; + +template +class CICaseStringKeyStaticMap : public CStaticMap { +protected: + virtual uint32 hash(const char* const &val) { + uint32 cksum = 0; + const char* pcc = val; + if (cpuinfo.sse4_2) { + while (*pcc) { + char cc = *(pcc++); + if (cc >= 'A' || cc <= 'Z') { + cc |= 0x20; + } + cksum = crc32c_t8_sse(cksum, cc); + } + } else { + while (*pcc) { + char cc = *(pcc++); + if (cc >= 'A' || cc <= 'Z') { + cc |= 0x20; + } + cksum = crc32c_t8_nosse(cksum, cc); + } + } + return cksum; + } + + virtual bool equals(const char* const &val1, const char* const &val2) { + return !_stricmp(val1, val2); + } + +public: + CICaseStringKeyStaticMap() { + } + +}; diff --git a/dep/rehlsdk/engine/studio.h b/dep/rehlsdk/engine/studio.h index 940f5f9..412543e 100644 --- a/dep/rehlsdk/engine/studio.h +++ b/dep/rehlsdk/engine/studio.h @@ -1,361 +1,361 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#pragma once - -/* -============================================================================== - -STUDIO MODELS - -Studio models are position independent, so the cache manager can move them. -============================================================================== -*/ - - -#define MAXSTUDIOTRIANGLES 20000 // TODO: tune this -#define MAXSTUDIOVERTS 2048 // TODO: tune this -#define MAXSTUDIOSEQUENCES 2048 // total animation sequences -#define MAXSTUDIOSKINS 100 // total textures -#define MAXSTUDIOSRCBONES 512 // bones allowed at source movement -#define MAXSTUDIOBONES 128 // total bones actually used -#define MAXSTUDIOMODELS 32 // sub-models per model -#define MAXSTUDIOBODYPARTS 32 -#define MAXSTUDIOGROUPS 16 -#define MAXSTUDIOANIMATIONS 2048 // per sequence -#define MAXSTUDIOMESHES 256 -#define MAXSTUDIOEVENTS 1024 -#define MAXSTUDIOPIVOTS 256 -#define MAXSTUDIOCONTROLLERS 8 - -typedef struct -{ - int id; - int version; - - char name[64]; - int length; - - vec3_t eyeposition; // ideal eye position - vec3_t min; // ideal movement hull size - vec3_t max; - - vec3_t bbmin; // clipping bounding box - vec3_t bbmax; - - int flags; - - int numbones; // bones - int boneindex; - - int numbonecontrollers; // bone controllers - int bonecontrollerindex; - - int numhitboxes; // complex bounding boxes - int hitboxindex; - - int numseq; // animation sequences - int seqindex; - - int numseqgroups; // demand loaded sequences - int seqgroupindex; - - int numtextures; // raw textures - int textureindex; - int texturedataindex; - - int numskinref; // replaceable textures - int numskinfamilies; - int skinindex; - - int numbodyparts; - int bodypartindex; - - int numattachments; // queryable attachable points - int attachmentindex; - - int soundtable; - int soundindex; - int soundgroups; - int soundgroupindex; - - int numtransitions; // animation node to animation node transition graph - int transitionindex; -} studiohdr_t; - -// header for demand loaded sequence group data -typedef struct -{ - int id; - int version; - - char name[64]; - int length; -} studioseqhdr_t; - -// bones -typedef struct -{ - char name[32]; // bone name for symbolic links - int parent; // parent bone - int flags; // ?? - int bonecontroller[6]; // bone controller index, -1 == none - float value[6]; // default DoF values - float scale[6]; // scale for delta DoF values -} mstudiobone_t; - - -// bone controllers -typedef struct -{ - int bone; // -1 == 0 - int type; // X, Y, Z, XR, YR, ZR, M - float start; - float end; - int rest; // byte index value at rest - int index; // 0-3 user set controller, 4 mouth -} mstudiobonecontroller_t; - -// intersection boxes -typedef struct -{ - int bone; - int group; // intersection group - vec3_t bbmin; // bounding box - vec3_t bbmax; -} mstudiobbox_t; - -// demand loaded sequence groups -typedef struct -{ - char label[32]; // textual name - char name[64]; // file name - int32 unused1; // was "cache" - index pointer - int unused2; // was "data" - hack for group 0 -} mstudioseqgroup_t; - -// sequence descriptions -typedef struct -{ - char label[32]; // sequence label - - float fps; // frames per second - int flags; // looping/non-looping flags - - int activity; - int actweight; - - int numevents; - int eventindex; - - int numframes; // number of frames per sequence - - int numpivots; // number of foot pivots - int pivotindex; - - int motiontype; - int motionbone; - vec3_t linearmovement; - int automoveposindex; - int automoveangleindex; - - vec3_t bbmin; // per sequence bounding box - vec3_t bbmax; - - int numblends; - int animindex; // mstudioanim_t pointer relative to start of sequence group data - // [blend][bone][X, Y, Z, XR, YR, ZR] - - int blendtype[2]; // X, Y, Z, XR, YR, ZR - float blendstart[2]; // starting value - float blendend[2]; // ending value - int blendparent; - - int seqgroup; // sequence group for demand loading - - int entrynode; // transition node at entry - int exitnode; // transition node at exit - int nodeflags; // transition rules - - int nextseq; // auto advancing sequences -} mstudioseqdesc_t; - -// events -#include "studio_event.h" -/* -typedef struct -{ - int frame; - int event; - int type; - char options[64]; -} mstudioevent_t; -*/ - -// pivots -typedef struct -{ - vec3_t org; // pivot point - int start; - int end; -} mstudiopivot_t; - -// attachment -typedef struct -{ - char name[32]; - int type; - int bone; - vec3_t org; // attachment point - vec3_t vectors[3]; -} mstudioattachment_t; - -typedef struct -{ - unsigned short offset[6]; -} mstudioanim_t; - -// animation frames -typedef union -{ - struct { - byte valid; - byte total; - } num; - short value; -} mstudioanimvalue_t; - - - -// body part index -typedef struct -{ - char name[64]; - int nummodels; - int base; - int modelindex; // index into models array -} mstudiobodyparts_t; - - - -// skin info -typedef struct -{ - char name[64]; - int flags; - int width; - int height; - int index; -} mstudiotexture_t; - - -// skin families -// short index[skinfamilies][skinref] - -// studio models -typedef struct -{ - char name[64]; - - int type; - - float boundingradius; - - int nummesh; - int meshindex; - - int numverts; // number of unique vertices - int vertinfoindex; // vertex bone info - int vertindex; // vertex vec3_t - int numnorms; // number of unique surface normals - int norminfoindex; // normal bone info - int normindex; // normal vec3_t - - int numgroups; // deformation groups - int groupindex; -} mstudiomodel_t; - - -// vec3_t boundingbox[model][bone][2]; // complex intersection info - - -// meshes -typedef struct -{ - int numtris; - int triindex; - int skinref; - int numnorms; // per mesh normals - int normindex; // normal vec3_t -} mstudiomesh_t; - -// triangles -#if 0 -typedef struct -{ - short vertindex; // index into vertex array - short normindex; // index into normal array - short s,t; // s,t position on skin -} mstudiotrivert_t; -#endif - -#define STUDIO_DYNAMIC_LIGHT 0x0100 // dynamically get lighting from floor or ceil (flying monsters) -#define STUDIO_TRACE_HITBOX 0x0200 // always use hitbox trace instead of bbox - -// lighting options -#define STUDIO_NF_FLATSHADE 0x0001 -#define STUDIO_NF_CHROME 0x0002 -#define STUDIO_NF_FULLBRIGHT 0x0004 -#define STUDIO_NF_NOMIPS 0x0008 -#define STUDIO_NF_ALPHA 0x0010 -#define STUDIO_NF_ADDITIVE 0x0020 -#define STUDIO_NF_MASKED 0x0040 - -// motion flags -#define STUDIO_X 0x0001 -#define STUDIO_Y 0x0002 -#define STUDIO_Z 0x0004 -#define STUDIO_XR 0x0008 -#define STUDIO_YR 0x0010 -#define STUDIO_ZR 0x0020 -#define STUDIO_LX 0x0040 -#define STUDIO_LY 0x0080 -#define STUDIO_LZ 0x0100 -#define STUDIO_AX 0x0200 -#define STUDIO_AY 0x0400 -#define STUDIO_AZ 0x0800 -#define STUDIO_AXR 0x1000 -#define STUDIO_AYR 0x2000 -#define STUDIO_AZR 0x4000 -#define STUDIO_TYPES 0x7FFF -#define STUDIO_RLOOP 0x8000 // controller that wraps shortest distance - -// sequence flags -#define STUDIO_LOOPING 0x0001 - -// bone flags -#define STUDIO_HAS_NORMALS 0x0001 -#define STUDIO_HAS_VERTICES 0x0002 -#define STUDIO_HAS_BBOX 0x0004 -#define STUDIO_HAS_CHROME 0x0008 // if any of the textures have chrome on them - -#define RAD_TO_STUDIO (32768.0/M_PI) -#define STUDIO_TO_RAD (M_PI/32768.0) - - -#define STUDIO_NUM_HULLS 128 -#define STUDIO_NUM_PLANES (STUDIO_NUM_HULLS * 6) -#define STUDIO_CACHE_SIZE 16 - - +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#pragma once + +/* +============================================================================== + +STUDIO MODELS + +Studio models are position independent, so the cache manager can move them. +============================================================================== +*/ + + +#define MAXSTUDIOTRIANGLES 20000 // TODO: tune this +#define MAXSTUDIOVERTS 2048 // TODO: tune this +#define MAXSTUDIOSEQUENCES 2048 // total animation sequences +#define MAXSTUDIOSKINS 100 // total textures +#define MAXSTUDIOSRCBONES 512 // bones allowed at source movement +#define MAXSTUDIOBONES 128 // total bones actually used +#define MAXSTUDIOMODELS 32 // sub-models per model +#define MAXSTUDIOBODYPARTS 32 +#define MAXSTUDIOGROUPS 16 +#define MAXSTUDIOANIMATIONS 2048 // per sequence +#define MAXSTUDIOMESHES 256 +#define MAXSTUDIOEVENTS 1024 +#define MAXSTUDIOPIVOTS 256 +#define MAXSTUDIOCONTROLLERS 8 + +typedef struct +{ + int id; + int version; + + char name[64]; + int length; + + vec3_t eyeposition; // ideal eye position + vec3_t min; // ideal movement hull size + vec3_t max; + + vec3_t bbmin; // clipping bounding box + vec3_t bbmax; + + int flags; + + int numbones; // bones + int boneindex; + + int numbonecontrollers; // bone controllers + int bonecontrollerindex; + + int numhitboxes; // complex bounding boxes + int hitboxindex; + + int numseq; // animation sequences + int seqindex; + + int numseqgroups; // demand loaded sequences + int seqgroupindex; + + int numtextures; // raw textures + int textureindex; + int texturedataindex; + + int numskinref; // replaceable textures + int numskinfamilies; + int skinindex; + + int numbodyparts; + int bodypartindex; + + int numattachments; // queryable attachable points + int attachmentindex; + + int soundtable; + int soundindex; + int soundgroups; + int soundgroupindex; + + int numtransitions; // animation node to animation node transition graph + int transitionindex; +} studiohdr_t; + +// header for demand loaded sequence group data +typedef struct +{ + int id; + int version; + + char name[64]; + int length; +} studioseqhdr_t; + +// bones +typedef struct +{ + char name[32]; // bone name for symbolic links + int parent; // parent bone + int flags; // ?? + int bonecontroller[6]; // bone controller index, -1 == none + float value[6]; // default DoF values + float scale[6]; // scale for delta DoF values +} mstudiobone_t; + + +// bone controllers +typedef struct +{ + int bone; // -1 == 0 + int type; // X, Y, Z, XR, YR, ZR, M + float start; + float end; + int rest; // byte index value at rest + int index; // 0-3 user set controller, 4 mouth +} mstudiobonecontroller_t; + +// intersection boxes +typedef struct +{ + int bone; + int group; // intersection group + vec3_t bbmin; // bounding box + vec3_t bbmax; +} mstudiobbox_t; + +// demand loaded sequence groups +typedef struct +{ + char label[32]; // textual name + char name[64]; // file name + int32 unused1; // was "cache" - index pointer + int unused2; // was "data" - hack for group 0 +} mstudioseqgroup_t; + +// sequence descriptions +typedef struct +{ + char label[32]; // sequence label + + float fps; // frames per second + int flags; // looping/non-looping flags + + int activity; + int actweight; + + int numevents; + int eventindex; + + int numframes; // number of frames per sequence + + int numpivots; // number of foot pivots + int pivotindex; + + int motiontype; + int motionbone; + vec3_t linearmovement; + int automoveposindex; + int automoveangleindex; + + vec3_t bbmin; // per sequence bounding box + vec3_t bbmax; + + int numblends; + int animindex; // mstudioanim_t pointer relative to start of sequence group data + // [blend][bone][X, Y, Z, XR, YR, ZR] + + int blendtype[2]; // X, Y, Z, XR, YR, ZR + float blendstart[2]; // starting value + float blendend[2]; // ending value + int blendparent; + + int seqgroup; // sequence group for demand loading + + int entrynode; // transition node at entry + int exitnode; // transition node at exit + int nodeflags; // transition rules + + int nextseq; // auto advancing sequences +} mstudioseqdesc_t; + +// events +#include "studio_event.h" +/* +typedef struct +{ + int frame; + int event; + int type; + char options[64]; +} mstudioevent_t; +*/ + +// pivots +typedef struct +{ + vec3_t org; // pivot point + int start; + int end; +} mstudiopivot_t; + +// attachment +typedef struct +{ + char name[32]; + int type; + int bone; + vec3_t org; // attachment point + vec3_t vectors[3]; +} mstudioattachment_t; + +typedef struct +{ + unsigned short offset[6]; +} mstudioanim_t; + +// animation frames +typedef union +{ + struct { + byte valid; + byte total; + } num; + short value; +} mstudioanimvalue_t; + + + +// body part index +typedef struct +{ + char name[64]; + int nummodels; + int base; + int modelindex; // index into models array +} mstudiobodyparts_t; + + + +// skin info +typedef struct +{ + char name[64]; + int flags; + int width; + int height; + int index; +} mstudiotexture_t; + + +// skin families +// short index[skinfamilies][skinref] + +// studio models +typedef struct +{ + char name[64]; + + int type; + + float boundingradius; + + int nummesh; + int meshindex; + + int numverts; // number of unique vertices + int vertinfoindex; // vertex bone info + int vertindex; // vertex vec3_t + int numnorms; // number of unique surface normals + int norminfoindex; // normal bone info + int normindex; // normal vec3_t + + int numgroups; // deformation groups + int groupindex; +} mstudiomodel_t; + + +// vec3_t boundingbox[model][bone][2]; // complex intersection info + + +// meshes +typedef struct +{ + int numtris; + int triindex; + int skinref; + int numnorms; // per mesh normals + int normindex; // normal vec3_t +} mstudiomesh_t; + +// triangles +#if 0 +typedef struct +{ + short vertindex; // index into vertex array + short normindex; // index into normal array + short s,t; // s,t position on skin +} mstudiotrivert_t; +#endif + +#define STUDIO_DYNAMIC_LIGHT 0x0100 // dynamically get lighting from floor or ceil (flying monsters) +#define STUDIO_TRACE_HITBOX 0x0200 // always use hitbox trace instead of bbox + +// lighting options +#define STUDIO_NF_FLATSHADE 0x0001 +#define STUDIO_NF_CHROME 0x0002 +#define STUDIO_NF_FULLBRIGHT 0x0004 +#define STUDIO_NF_NOMIPS 0x0008 +#define STUDIO_NF_ALPHA 0x0010 +#define STUDIO_NF_ADDITIVE 0x0020 +#define STUDIO_NF_MASKED 0x0040 + +// motion flags +#define STUDIO_X 0x0001 +#define STUDIO_Y 0x0002 +#define STUDIO_Z 0x0004 +#define STUDIO_XR 0x0008 +#define STUDIO_YR 0x0010 +#define STUDIO_ZR 0x0020 +#define STUDIO_LX 0x0040 +#define STUDIO_LY 0x0080 +#define STUDIO_LZ 0x0100 +#define STUDIO_AX 0x0200 +#define STUDIO_AY 0x0400 +#define STUDIO_AZ 0x0800 +#define STUDIO_AXR 0x1000 +#define STUDIO_AYR 0x2000 +#define STUDIO_AZR 0x4000 +#define STUDIO_TYPES 0x7FFF +#define STUDIO_RLOOP 0x8000 // controller that wraps shortest distance + +// sequence flags +#define STUDIO_LOOPING 0x0001 + +// bone flags +#define STUDIO_HAS_NORMALS 0x0001 +#define STUDIO_HAS_VERTICES 0x0002 +#define STUDIO_HAS_BBOX 0x0004 +#define STUDIO_HAS_CHROME 0x0008 // if any of the textures have chrome on them + +#define RAD_TO_STUDIO (32768.0/M_PI) +#define STUDIO_TO_RAD (M_PI/32768.0) + + +#define STUDIO_NUM_HULLS 128 +#define STUDIO_NUM_PLANES (STUDIO_NUM_HULLS * 6) +#define STUDIO_CACHE_SIZE 16 + + diff --git a/dep/rehlsdk/engine/sys_shared.cpp b/dep/rehlsdk/engine/sys_shared.cpp index c9d0893..b9a5033 100644 --- a/dep/rehlsdk/engine/sys_shared.cpp +++ b/dep/rehlsdk/engine/sys_shared.cpp @@ -1,74 +1,74 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#include "sys_shared.h" - -#if defined(__GNUC__) -#include -#elif _MSC_VER >= 1400 && !defined(ASMLIB_H) -#include // __cpuidex -#endif - -#define SSE3_FLAG (1<<0) -#define SSSE3_FLAG (1<<9) -#define SSE4_1_FLAG (1<<19) -#define SSE4_2_FLAG (1<<20) -#define POPCNT_FLAG (1<<23) -#define AVX_FLAG (1<<28) -#define AVX2_FLAG (1<<5) - -cpuinfo_t cpuinfo; - -void Sys_CheckCpuInstructionsSupport(void) -{ - unsigned int cpuid_data[4]; - -#if defined ASMLIB_H - cpuid_ex((int *)cpuid_data, 1, 0); -#elif defined(__GNUC__) - __get_cpuid(0x1, &cpuid_data[0], &cpuid_data[1], &cpuid_data[2], &cpuid_data[3]); -#else - __cpuidex((int *)cpuid_data, 1, 0); -#endif - - cpuinfo.sse3 = (cpuid_data[2] & SSE3_FLAG) ? 1 : 0; // ecx - cpuinfo.ssse3 = (cpuid_data[2] & SSSE3_FLAG) ? 1 : 0; - cpuinfo.sse4_1 = (cpuid_data[2] & SSE4_1_FLAG) ? 1 : 0; - cpuinfo.sse4_2 = (cpuid_data[2] & SSE4_2_FLAG) ? 1 : 0; - cpuinfo.popcnt = (cpuid_data[2] & POPCNT_FLAG) ? 1 : 0; - cpuinfo.avx = (cpuid_data[2] & AVX_FLAG) ? 1 : 0; - -#if defined ASMLIB_H - cpuid_ex((int *)cpuid_data, 7, 0); -#elif defined(__GNUC__) - __get_cpuid(0x7, &cpuid_data[0], &cpuid_data[1], &cpuid_data[2], &cpuid_data[3]); -#else - __cpuidex((int *)cpuid_data, 7, 0); -#endif - - cpuinfo.avx2 = (cpuid_data[1] & AVX2_FLAG) ? 1 : 0; // ebx -} +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ +#include "sys_shared.h" + +#if defined(__GNUC__) +#include +#elif _MSC_VER >= 1400 && !defined(ASMLIB_H) +#include // __cpuidex +#endif + +#define SSE3_FLAG (1<<0) +#define SSSE3_FLAG (1<<9) +#define SSE4_1_FLAG (1<<19) +#define SSE4_2_FLAG (1<<20) +#define POPCNT_FLAG (1<<23) +#define AVX_FLAG (1<<28) +#define AVX2_FLAG (1<<5) + +cpuinfo_t cpuinfo; + +void Sys_CheckCpuInstructionsSupport(void) +{ + unsigned int cpuid_data[4]; + +#if defined ASMLIB_H + cpuid_ex((int *)cpuid_data, 1, 0); +#elif defined(__GNUC__) + __get_cpuid(0x1, &cpuid_data[0], &cpuid_data[1], &cpuid_data[2], &cpuid_data[3]); +#else + __cpuidex((int *)cpuid_data, 1, 0); +#endif + + cpuinfo.sse3 = (cpuid_data[2] & SSE3_FLAG) ? 1 : 0; // ecx + cpuinfo.ssse3 = (cpuid_data[2] & SSSE3_FLAG) ? 1 : 0; + cpuinfo.sse4_1 = (cpuid_data[2] & SSE4_1_FLAG) ? 1 : 0; + cpuinfo.sse4_2 = (cpuid_data[2] & SSE4_2_FLAG) ? 1 : 0; + cpuinfo.popcnt = (cpuid_data[2] & POPCNT_FLAG) ? 1 : 0; + cpuinfo.avx = (cpuid_data[2] & AVX_FLAG) ? 1 : 0; + +#if defined ASMLIB_H + cpuid_ex((int *)cpuid_data, 7, 0); +#elif defined(__GNUC__) + __get_cpuid(0x7, &cpuid_data[0], &cpuid_data[1], &cpuid_data[2], &cpuid_data[3]); +#else + __cpuidex((int *)cpuid_data, 7, 0); +#endif + + cpuinfo.avx2 = (cpuid_data[1] & AVX2_FLAG) ? 1 : 0; // ebx +} diff --git a/dep/rehlsdk/engine/sys_shared.h b/dep/rehlsdk/engine/sys_shared.h index 768b51f..5b5da98 100644 --- a/dep/rehlsdk/engine/sys_shared.h +++ b/dep/rehlsdk/engine/sys_shared.h @@ -1,39 +1,39 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include - -typedef struct cpuinfo_s -{ - uint8 sse3, ssse3, sse4_1, sse4_2, avx, avx2, popcnt; -} cpuinfo_t; - -extern cpuinfo_t cpuinfo; - -void Sys_CheckCpuInstructionsSupport(void); +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ +#pragma once + +#include + +typedef struct cpuinfo_s +{ + uint8 sse3, ssse3, sse4_1, sse4_2, avx, avx2, popcnt; +} cpuinfo_t; + +extern cpuinfo_t cpuinfo; + +void Sys_CheckCpuInstructionsSupport(void); diff --git a/dep/rehlsdk/engine/userid_rehlds.h b/dep/rehlsdk/engine/userid_rehlds.h index 6a22221..53b76f4 100644 --- a/dep/rehlsdk/engine/userid_rehlds.h +++ b/dep/rehlsdk/engine/userid_rehlds.h @@ -1,46 +1,46 @@ -/* -* -* 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 2 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. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ -#pragma once - -#include "archtypes.h" - -// Authentication types -enum AUTH_IDTYPE -{ - AUTH_IDTYPE_UNKNOWN = 0, - AUTH_IDTYPE_STEAM = 1, - AUTH_IDTYPE_VALVE = 2, - AUTH_IDTYPE_LOCAL = 3 -}; - -typedef struct USERID_s -{ - int idtype; - uint64 m_SteamID; - unsigned int clientip; -} USERID_t; +/* +* +* 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 2 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. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* In addition, as a special exception, the author gives permission to +* link the code of this program with the Half-Life Game Engine ("HL +* Engine") and Modified Game Libraries ("MODs") developed by Valve, +* L.L.C ("Valve"). You must obey the GNU General Public License in all +* respects for all of the code used other than the HL Engine and MODs +* from Valve. If you modify this file, you may extend this exception +* to your version of the file, but you are not obligated to do so. If +* you do not wish to do so, delete this exception statement from your +* version. +* +*/ +#pragma once + +#include "archtypes.h" + +// Authentication types +enum AUTH_IDTYPE +{ + AUTH_IDTYPE_UNKNOWN = 0, + AUTH_IDTYPE_STEAM = 1, + AUTH_IDTYPE_VALVE = 2, + AUTH_IDTYPE_LOCAL = 3 +}; + +typedef struct USERID_s +{ + int idtype; + uint64 m_SteamID; + unsigned int clientip; +} USERID_t; diff --git a/dep/rehlsdk/pm_shared/pm_debug.h b/dep/rehlsdk/pm_shared/pm_debug.h index b9be095..6eca1f0 100644 --- a/dep/rehlsdk/pm_shared/pm_debug.h +++ b/dep/rehlsdk/pm_shared/pm_debug.h @@ -1,26 +1,26 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef PM_DEBUG_H -#define PM_DEBUG_H -#ifdef _WIN32 -#pragma once -#endif - -void PM_ViewEntity( void ); -void PM_DrawBBox(vec3_t mins, vec3_t maxs, vec3_t origin, int pcolor, float life); -void PM_ParticleLine(vec3_t start, vec3_t end, int pcolor, float life, float vert); -void PM_ShowClipBox( void ); - -#endif // PMOVEDBG_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#ifndef PM_DEBUG_H +#define PM_DEBUG_H +#ifdef _WIN32 +#pragma once +#endif + +void PM_ViewEntity( void ); +void PM_DrawBBox(vec3_t mins, vec3_t maxs, vec3_t origin, int pcolor, float life); +void PM_ParticleLine(vec3_t start, vec3_t end, int pcolor, float life, float vert); +void PM_ShowClipBox( void ); + +#endif // PMOVEDBG_H diff --git a/dep/rehlsdk/pm_shared/pm_defs.h b/dep/rehlsdk/pm_shared/pm_defs.h index 7350c1a..a6248d9 100644 --- a/dep/rehlsdk/pm_shared/pm_defs.h +++ b/dep/rehlsdk/pm_shared/pm_defs.h @@ -1,228 +1,228 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// pm_defs.h -#if !defined( PM_DEFSH ) -#define PM_DEFSH -#ifdef _WIN32 -#pragma once -#endif - -#include "archtypes.h" // DAL -#define MAX_PHYSENTS 600 // Must have room for all entities in the world. -#define MAX_MOVEENTS 64 -#define MAX_CLIP_PLANES 5 - -#define PM_NORMAL 0x00000000 -#define PM_STUDIO_IGNORE 0x00000001 // Skip studio models -#define PM_STUDIO_BOX 0x00000002 // Use boxes for non-complex studio models (even in traceline) -#define PM_GLASS_IGNORE 0x00000004 // Ignore entities with non-normal rendermode -#define PM_WORLD_ONLY 0x00000008 // Only trace against the world - -// Values for flags parameter of PM_TraceLine -#define PM_TRACELINE_PHYSENTSONLY 0 -#define PM_TRACELINE_ANYVISIBLE 1 - - -#include "pm_info.h" - -// PM_PlayerTrace results. -#include "pmtrace.h" - -#if !defined ( USERCMD_H ) -#include "usercmd.h" -#endif - -#include "const.h" - - -// physent_t -typedef struct physent_s -{ - char name[32]; // Name of model, or "player" or "world". - int player; - vec3_t origin; // Model's origin in world coordinates. - struct model_s *model; // only for bsp models - struct model_s *studiomodel; // SOLID_BBOX, but studio clip intersections. - vec3_t mins, maxs; // only for non-bsp models - int info; // For client or server to use to identify (index into edicts or cl_entities) - vec3_t angles; // rotated entities need this info for hull testing to work. - - int solid; // Triggers and func_door type WATER brushes are SOLID_NOT - int skin; // BSP Contents for such things like fun_door water brushes. - int rendermode; // So we can ignore glass - - // Complex collision detection. - float frame; - int sequence; - byte controller[4]; - byte blending[2]; - - int movetype; - int takedamage; - int blooddecal; - int team; - int classnumber; - - // For mods - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; - vec3_t vuser1; - vec3_t vuser2; - vec3_t vuser3; - vec3_t vuser4; -} physent_t; - - -typedef struct playermove_s -{ - int player_index; // So we don't try to run the PM_CheckStuck nudging too quickly. - qboolean server; // For debugging, are we running physics code on server side? - - qboolean multiplayer; // 1 == multiplayer server - float time; // realtime on host, for reckoning duck timing - float frametime; // Duration of this frame - - vec3_t forward, right, up; // Vectors for angles - // player state - vec3_t origin; // Movement origin. - vec3_t angles; // Movement view angles. - vec3_t oldangles; // Angles before movement view angles were looked at. - vec3_t velocity; // Current movement direction. - vec3_t movedir; // For waterjumping, a forced forward velocity so we can fly over lip of ledge. - vec3_t basevelocity; // Velocity of the conveyor we are standing, e.g. - - // For ducking/dead - vec3_t view_ofs; // Our eye position. - float flDuckTime; // Time we started duck - qboolean bInDuck; // In process of ducking or ducked already? - - // For walking/falling - int flTimeStepSound; // Next time we can play a step sound - int iStepLeft; - - float flFallVelocity; - vec3_t punchangle; - - float flSwimTime; - - float flNextPrimaryAttack; - - int effects; // MUZZLE FLASH, e.g. - - int flags; // FL_ONGROUND, FL_DUCKING, etc. - int usehull; // 0 = regular player hull, 1 = ducked player hull, 2 = point hull - float gravity; // Our current gravity and friction. - float friction; - int oldbuttons; // Buttons last usercmd - float waterjumptime; // Amount of time left in jumping out of water cycle. - qboolean dead; // Are we a dead player? - int deadflag; - int spectator; // Should we use spectator physics model? - int movetype; // Our movement type, NOCLIP, WALK, FLY - - int onground; - int waterlevel; - int watertype; - int oldwaterlevel; - - char sztexturename[256]; - char chtexturetype; - - float maxspeed; - float clientmaxspeed; // Player specific maxspeed - - // For mods - int iuser1; - int iuser2; - int iuser3; - int iuser4; - float fuser1; - float fuser2; - float fuser3; - float fuser4; - vec3_t vuser1; - vec3_t vuser2; - vec3_t vuser3; - vec3_t vuser4; - // world state - // Number of entities to clip against. - int numphysent; - physent_t physents[MAX_PHYSENTS]; - // Number of momvement entities (ladders) - int nummoveent; - // just a list of ladders - physent_t moveents[MAX_MOVEENTS]; - - // All things being rendered, for tracing against things you don't actually collide with - int numvisent; - physent_t visents[ MAX_PHYSENTS ]; - - // input to run through physics. - usercmd_t cmd; - - // Trace results for objects we collided with. - int numtouch; - pmtrace_t touchindex[MAX_PHYSENTS]; - - char physinfo[ MAX_PHYSINFO_STRING ]; // Physics info string - - struct movevars_s *_movevars; - vec3_t _player_mins[ 4 ]; - vec3_t _player_maxs[ 4 ]; - - // Common functions - const char *(*PM_Info_ValueForKey) ( const char *s, const char *key ); - void (*PM_Particle)( float *origin, int color, float life, int zpos, int zvel); - int (*PM_TestPlayerPosition) (float *pos, pmtrace_t *ptrace ); - void (*Con_NPrintf)( int idx, char *fmt, ... ); - void (*Con_DPrintf)( char *fmt, ... ); - void (*Con_Printf)( char *fmt, ... ); - double (*Sys_FloatTime)( void ); - void (*PM_StuckTouch)( int hitent, pmtrace_t *ptraceresult ); - int (*PM_PointContents) (float *p, int *truecontents /*filled in if this is non-null*/ ); - int (*PM_TruePointContents) (float *p); - int (*PM_HullPointContents) ( struct hull_s *hull, int num, float *p); - pmtrace_t (*PM_PlayerTrace) (float *start, float *end, int traceFlags, int ignore_pe ); - struct pmtrace_s *(*PM_TraceLine)( float *start, float *end, int flags, int usehulll, int ignore_pe ); - int32 (*RandomLong)( int32 lLow, int32 lHigh ); - float (*RandomFloat)( float flLow, float flHigh ); - int (*PM_GetModelType)( struct model_s *mod ); - void (*PM_GetModelBounds)( struct model_s *mod, float *mins, float *maxs ); - void *(*PM_HullForBsp)( physent_t *pe, float *offset ); - float (*PM_TraceModel)( physent_t *pEnt, float *start, float *end, trace_t *trace ); - int (*COM_FileSize)(const char *filename); - byte *(*COM_LoadFile) (const char *path, int usehunk, int *pLength); - void (*COM_FreeFile) ( void *buffer ); - char *(*memfgets)( byte *pMemFile, int fileSize, int *pFilePos, char *pBuffer, int bufferSize ); - - // Functions - // Run functions for this frame? - qboolean runfuncs; - void (*PM_PlaySound) ( int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch ); - const char *(*PM_TraceTexture) ( int ground, float *vstart, float *vend ); - void (*PM_PlaybackEventFull) ( int flags, int clientindex, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); - - pmtrace_t (*PM_PlayerTraceEx) (float *start, float *end, int traceFlags, int (*pfnIgnore)( physent_t *pe ) ); - int (*PM_TestPlayerPositionEx) (float *pos, pmtrace_t *ptrace, int (*pfnIgnore)( physent_t *pe ) ); - struct pmtrace_s *(*PM_TraceLineEx)( float *start, float *end, int flags, int usehulll, int (*pfnIgnore)( physent_t *pe ) ); -} playermove_t; - -#endif +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +// pm_defs.h +#if !defined( PM_DEFSH ) +#define PM_DEFSH +#ifdef _WIN32 +#pragma once +#endif + +#include "archtypes.h" // DAL +#define MAX_PHYSENTS 600 // Must have room for all entities in the world. +#define MAX_MOVEENTS 64 +#define MAX_CLIP_PLANES 5 + +#define PM_NORMAL 0x00000000 +#define PM_STUDIO_IGNORE 0x00000001 // Skip studio models +#define PM_STUDIO_BOX 0x00000002 // Use boxes for non-complex studio models (even in traceline) +#define PM_GLASS_IGNORE 0x00000004 // Ignore entities with non-normal rendermode +#define PM_WORLD_ONLY 0x00000008 // Only trace against the world + +// Values for flags parameter of PM_TraceLine +#define PM_TRACELINE_PHYSENTSONLY 0 +#define PM_TRACELINE_ANYVISIBLE 1 + + +#include "pm_info.h" + +// PM_PlayerTrace results. +#include "pmtrace.h" + +#if !defined ( USERCMD_H ) +#include "usercmd.h" +#endif + +#include "const.h" + + +// physent_t +typedef struct physent_s +{ + char name[32]; // Name of model, or "player" or "world". + int player; + vec3_t origin; // Model's origin in world coordinates. + struct model_s *model; // only for bsp models + struct model_s *studiomodel; // SOLID_BBOX, but studio clip intersections. + vec3_t mins, maxs; // only for non-bsp models + int info; // For client or server to use to identify (index into edicts or cl_entities) + vec3_t angles; // rotated entities need this info for hull testing to work. + + int solid; // Triggers and func_door type WATER brushes are SOLID_NOT + int skin; // BSP Contents for such things like fun_door water brushes. + int rendermode; // So we can ignore glass + + // Complex collision detection. + float frame; + int sequence; + byte controller[4]; + byte blending[2]; + + int movetype; + int takedamage; + int blooddecal; + int team; + int classnumber; + + // For mods + int iuser1; + int iuser2; + int iuser3; + int iuser4; + float fuser1; + float fuser2; + float fuser3; + float fuser4; + vec3_t vuser1; + vec3_t vuser2; + vec3_t vuser3; + vec3_t vuser4; +} physent_t; + + +typedef struct playermove_s +{ + int player_index; // So we don't try to run the PM_CheckStuck nudging too quickly. + qboolean server; // For debugging, are we running physics code on server side? + + qboolean multiplayer; // 1 == multiplayer server + float time; // realtime on host, for reckoning duck timing + float frametime; // Duration of this frame + + vec3_t forward, right, up; // Vectors for angles + // player state + vec3_t origin; // Movement origin. + vec3_t angles; // Movement view angles. + vec3_t oldangles; // Angles before movement view angles were looked at. + vec3_t velocity; // Current movement direction. + vec3_t movedir; // For waterjumping, a forced forward velocity so we can fly over lip of ledge. + vec3_t basevelocity; // Velocity of the conveyor we are standing, e.g. + + // For ducking/dead + vec3_t view_ofs; // Our eye position. + float flDuckTime; // Time we started duck + qboolean bInDuck; // In process of ducking or ducked already? + + // For walking/falling + int flTimeStepSound; // Next time we can play a step sound + int iStepLeft; + + float flFallVelocity; + vec3_t punchangle; + + float flSwimTime; + + float flNextPrimaryAttack; + + int effects; // MUZZLE FLASH, e.g. + + int flags; // FL_ONGROUND, FL_DUCKING, etc. + int usehull; // 0 = regular player hull, 1 = ducked player hull, 2 = point hull + float gravity; // Our current gravity and friction. + float friction; + int oldbuttons; // Buttons last usercmd + float waterjumptime; // Amount of time left in jumping out of water cycle. + qboolean dead; // Are we a dead player? + int deadflag; + int spectator; // Should we use spectator physics model? + int movetype; // Our movement type, NOCLIP, WALK, FLY + + int onground; + int waterlevel; + int watertype; + int oldwaterlevel; + + char sztexturename[256]; + char chtexturetype; + + float maxspeed; + float clientmaxspeed; // Player specific maxspeed + + // For mods + int iuser1; + int iuser2; + int iuser3; + int iuser4; + float fuser1; + float fuser2; + float fuser3; + float fuser4; + vec3_t vuser1; + vec3_t vuser2; + vec3_t vuser3; + vec3_t vuser4; + // world state + // Number of entities to clip against. + int numphysent; + physent_t physents[MAX_PHYSENTS]; + // Number of momvement entities (ladders) + int nummoveent; + // just a list of ladders + physent_t moveents[MAX_MOVEENTS]; + + // All things being rendered, for tracing against things you don't actually collide with + int numvisent; + physent_t visents[ MAX_PHYSENTS ]; + + // input to run through physics. + usercmd_t cmd; + + // Trace results for objects we collided with. + int numtouch; + pmtrace_t touchindex[MAX_PHYSENTS]; + + char physinfo[ MAX_PHYSINFO_STRING ]; // Physics info string + + struct movevars_s *_movevars; + vec3_t _player_mins[ 4 ]; + vec3_t _player_maxs[ 4 ]; + + // Common functions + const char *(*PM_Info_ValueForKey) ( const char *s, const char *key ); + void (*PM_Particle)( float *origin, int color, float life, int zpos, int zvel); + int (*PM_TestPlayerPosition) (float *pos, pmtrace_t *ptrace ); + void (*Con_NPrintf)( int idx, char *fmt, ... ); + void (*Con_DPrintf)( char *fmt, ... ); + void (*Con_Printf)( char *fmt, ... ); + double (*Sys_FloatTime)( void ); + void (*PM_StuckTouch)( int hitent, pmtrace_t *ptraceresult ); + int (*PM_PointContents) (float *p, int *truecontents /*filled in if this is non-null*/ ); + int (*PM_TruePointContents) (float *p); + int (*PM_HullPointContents) ( struct hull_s *hull, int num, float *p); + pmtrace_t (*PM_PlayerTrace) (float *start, float *end, int traceFlags, int ignore_pe ); + struct pmtrace_s *(*PM_TraceLine)( float *start, float *end, int flags, int usehulll, int ignore_pe ); + int32 (*RandomLong)( int32 lLow, int32 lHigh ); + float (*RandomFloat)( float flLow, float flHigh ); + int (*PM_GetModelType)( struct model_s *mod ); + void (*PM_GetModelBounds)( struct model_s *mod, float *mins, float *maxs ); + void *(*PM_HullForBsp)( physent_t *pe, float *offset ); + float (*PM_TraceModel)( physent_t *pEnt, float *start, float *end, trace_t *trace ); + int (*COM_FileSize)(const char *filename); + byte *(*COM_LoadFile) (const char *path, int usehunk, int *pLength); + void (*COM_FreeFile) ( void *buffer ); + char *(*memfgets)( byte *pMemFile, int fileSize, int *pFilePos, char *pBuffer, int bufferSize ); + + // Functions + // Run functions for this frame? + qboolean runfuncs; + void (*PM_PlaySound) ( int channel, const char *sample, float volume, float attenuation, int fFlags, int pitch ); + const char *(*PM_TraceTexture) ( int ground, float *vstart, float *vend ); + void (*PM_PlaybackEventFull) ( int flags, int clientindex, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); + + pmtrace_t (*PM_PlayerTraceEx) (float *start, float *end, int traceFlags, int (*pfnIgnore)( physent_t *pe ) ); + int (*PM_TestPlayerPositionEx) (float *pos, pmtrace_t *ptrace, int (*pfnIgnore)( physent_t *pe ) ); + struct pmtrace_s *(*PM_TraceLineEx)( float *start, float *end, int flags, int usehulll, int (*pfnIgnore)( physent_t *pe ) ); +} playermove_t; + +#endif diff --git a/dep/rehlsdk/pm_shared/pm_info.h b/dep/rehlsdk/pm_shared/pm_info.h index 3525e79..9b705cd 100644 --- a/dep/rehlsdk/pm_shared/pm_info.h +++ b/dep/rehlsdk/pm_shared/pm_info.h @@ -1,25 +1,25 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -// Physics info string definition - -#ifndef PM_INFO_H -#define PM_INFO_H -#ifdef _WIN32 -#pragma once -#endif - -#define MAX_PHYSINFO_STRING 256 - -#endif // PM_INFO_H +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +// Physics info string definition + +#ifndef PM_INFO_H +#define PM_INFO_H +#ifdef _WIN32 +#pragma once +#endif + +#define MAX_PHYSINFO_STRING 256 + +#endif // PM_INFO_H diff --git a/dep/rehlsdk/pm_shared/pm_materials.h b/dep/rehlsdk/pm_shared/pm_materials.h index c5816d7..1b88b2d 100644 --- a/dep/rehlsdk/pm_shared/pm_materials.h +++ b/dep/rehlsdk/pm_shared/pm_materials.h @@ -1,36 +1,36 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#if !defined( PM_MATERIALSH ) -#define PM_MATERIALSH -#ifdef _WIN32 -#pragma once -#endif - -#define CBTEXTURENAMEMAX 13 // only load first n chars of name - -#define CHAR_TEX_CONCRETE 'C' // texture types -#define CHAR_TEX_METAL 'M' -#define CHAR_TEX_DIRT 'D' -#define CHAR_TEX_VENT 'V' -#define CHAR_TEX_GRATE 'G' -#define CHAR_TEX_TILE 'T' -#define CHAR_TEX_SLOSH 'S' -#define CHAR_TEX_WOOD 'W' -#define CHAR_TEX_COMPUTER 'P' -#define CHAR_TEX_GLASS 'Y' -#define CHAR_TEX_FLESH 'F' -#define CHAR_TEX_SNOW 'N' - -#endif // !PM_MATERIALSH +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +#if !defined( PM_MATERIALSH ) +#define PM_MATERIALSH +#ifdef _WIN32 +#pragma once +#endif + +#define CBTEXTURENAMEMAX 13 // only load first n chars of name + +#define CHAR_TEX_CONCRETE 'C' // texture types +#define CHAR_TEX_METAL 'M' +#define CHAR_TEX_DIRT 'D' +#define CHAR_TEX_VENT 'V' +#define CHAR_TEX_GRATE 'G' +#define CHAR_TEX_TILE 'T' +#define CHAR_TEX_SLOSH 'S' +#define CHAR_TEX_WOOD 'W' +#define CHAR_TEX_COMPUTER 'P' +#define CHAR_TEX_GLASS 'Y' +#define CHAR_TEX_FLESH 'F' +#define CHAR_TEX_SNOW 'N' + +#endif // !PM_MATERIALSH diff --git a/dep/rehlsdk/pm_shared/pm_movevars.h b/dep/rehlsdk/pm_shared/pm_movevars.h index 3bea8b3..66c99ee 100644 --- a/dep/rehlsdk/pm_shared/pm_movevars.h +++ b/dep/rehlsdk/pm_shared/pm_movevars.h @@ -1,47 +1,47 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// pm_movevars.h -#if !defined( PM_MOVEVARSH ) -#define PM_MOVEVARSH - -// movevars_t // Physics variables. -typedef struct movevars_s movevars_t; - -struct movevars_s -{ - float gravity; // Gravity for map - float stopspeed; // Deceleration when not moving - float maxspeed; // Max allowed speed - float spectatormaxspeed; - float accelerate; // Acceleration factor - float airaccelerate; // Same for when in open air - float wateraccelerate; // Same for when in water - float friction; - float edgefriction; // Extra friction near dropofs - float waterfriction; // Less in water - float entgravity; // 1.0 - float bounce; // Wall bounce value. 1.0 - float stepsize; // sv_stepsize; - float maxvelocity; // maximum server velocity. - float zmax; // Max z-buffer range (for GL) - float waveHeight; // Water wave height (for GL) - qboolean footsteps; // Play footstep sounds - char skyName[32]; // Name of the sky map - float rollangle; - float rollspeed; - float skycolor_r; // Sky color - float skycolor_g; // - float skycolor_b; // - float skyvec_x; // Sky vector - float skyvec_y; // - float skyvec_z; // -}; - -extern movevars_t movevars; - -#endif +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +// pm_movevars.h +#if !defined( PM_MOVEVARSH ) +#define PM_MOVEVARSH + +// movevars_t // Physics variables. +typedef struct movevars_s movevars_t; + +struct movevars_s +{ + float gravity; // Gravity for map + float stopspeed; // Deceleration when not moving + float maxspeed; // Max allowed speed + float spectatormaxspeed; + float accelerate; // Acceleration factor + float airaccelerate; // Same for when in open air + float wateraccelerate; // Same for when in water + float friction; + float edgefriction; // Extra friction near dropofs + float waterfriction; // Less in water + float entgravity; // 1.0 + float bounce; // Wall bounce value. 1.0 + float stepsize; // sv_stepsize; + float maxvelocity; // maximum server velocity. + float zmax; // Max z-buffer range (for GL) + float waveHeight; // Water wave height (for GL) + qboolean footsteps; // Play footstep sounds + char skyName[32]; // Name of the sky map + float rollangle; + float rollspeed; + float skycolor_r; // Sky color + float skycolor_g; // + float skycolor_b; // + float skyvec_x; // Sky vector + float skyvec_y; // + float skyvec_z; // +}; + +extern movevars_t movevars; + +#endif diff --git a/dep/rehlsdk/pm_shared/pm_shared.h b/dep/rehlsdk/pm_shared/pm_shared.h index 5a73495..c860aa8 100644 --- a/dep/rehlsdk/pm_shared/pm_shared.h +++ b/dep/rehlsdk/pm_shared/pm_shared.h @@ -1,38 +1,38 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -// -// pm_shared.h -// -#if !defined( PM_SHAREDH ) -#define PM_SHAREDH -#ifdef _WIN32 -#pragma once -#endif - -void PM_Init( struct playermove_s *ppmove ); -void PM_Move ( struct playermove_s *ppmove, int server ); -char PM_FindTextureType( char *name ); - -// Spectator Movement modes (stored in pev->iuser1, so the physics code can get at them) -#define OBS_NONE 0 -#define OBS_CHASE_LOCKED 1 -#define OBS_CHASE_FREE 2 -#define OBS_ROAMING 3 -#define OBS_IN_EYE 4 -#define OBS_MAP_FREE 5 -#define OBS_MAP_CHASE 6 - -#endif +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +// +// pm_shared.h +// +#if !defined( PM_SHAREDH ) +#define PM_SHAREDH +#ifdef _WIN32 +#pragma once +#endif + +void PM_Init( struct playermove_s *ppmove ); +void PM_Move ( struct playermove_s *ppmove, int server ); +char PM_FindTextureType( char *name ); + +// Spectator Movement modes (stored in pev->iuser1, so the physics code can get at them) +#define OBS_NONE 0 +#define OBS_CHASE_LOCKED 1 +#define OBS_CHASE_FREE 2 +#define OBS_ROAMING 3 +#define OBS_IN_EYE 4 +#define OBS_MAP_FREE 5 +#define OBS_MAP_CHASE 6 + +#endif diff --git a/dep/rehlsdk/public/FileSystem.h b/dep/rehlsdk/public/FileSystem.h index 4a3c621..e1ce53c 100644 --- a/dep/rehlsdk/public/FileSystem.h +++ b/dep/rehlsdk/public/FileSystem.h @@ -1,189 +1,189 @@ -//========= Copyright � 1996-2001, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef FILESYSTEM_H -#define FILESYSTEM_H -#ifdef _WIN32 -#pragma once -#endif - -#include "interface.h" -#include -#include - - -//----------------------------------------------------------------------------- -// Forward declarations -//----------------------------------------------------------------------------- -typedef FILE * FileHandle_t; -typedef int FileFindHandle_t; -typedef int WaitForResourcesHandle_t; - - -//----------------------------------------------------------------------------- -// Enums used by the interface -//----------------------------------------------------------------------------- -#ifndef FILESYSTEM_INTERNAL_H -typedef enum -{ - FILESYSTEM_SEEK_HEAD = 0, - FILESYSTEM_SEEK_CURRENT, - FILESYSTEM_SEEK_TAIL, -} FileSystemSeek_t; - -enum -{ - FILESYSTEM_INVALID_FIND_HANDLE = -1 -}; - -typedef enum -{ - // Don't print anything - FILESYSTEM_WARNING_QUIET = 0, - - // On shutdown, report names of files left unclosed - FILESYSTEM_WARNING_REPORTUNCLOSED, - - // Report number of times a file was opened, closed - FILESYSTEM_WARNING_REPORTUSAGE, - - // Report all open/close events to console ( !slow! ) - FILESYSTEM_WARNING_REPORTALLACCESSES -} FileWarningLevel_t; - -#define FILESYSTEM_INVALID_HANDLE ( FileHandle_t )0 -#endif - -// turn off any windows defines -#undef GetCurrentDirectory - -//----------------------------------------------------------------------------- -// Purpose: Main file system interface -//----------------------------------------------------------------------------- -class IFileSystem : public IBaseInterface -{ -public: - // Mount and unmount the filesystem - virtual void Mount( void ) = 0; - virtual void Unmount( void ) = 0; - - // Remove all search paths (including write path?) - virtual void RemoveAllSearchPaths( void ) = 0; - - // Add paths in priority order (mod dir, game dir, ....) - // If one or more .pak files are in the specified directory, then they are - // added after the file system path - // If the path is the relative path to a .bsp file, then any previous .bsp file - // override is cleared and the current .bsp is searched for an embedded PAK file - // and this file becomes the highest priority search path ( i.e., it's looked at first - // even before the mod's file system path ). - virtual void AddSearchPath( const char *pPath, const char *pathID ) = 0; - virtual bool RemoveSearchPath( const char *pPath ) = 0; - - // Deletes a file - virtual void RemoveFile( const char *pRelativePath, const char *pathID ) = 0; - - // this isn't implementable on STEAM as is. - virtual void CreateDirHierarchy( const char *path, const char *pathID ) = 0; - - // File I/O and info - virtual bool FileExists( const char *pFileName ) = 0; - virtual bool IsDirectory( const char *pFileName ) = 0; - - // opens a file - // if pathID is NULL, all paths will be searched for the file - virtual FileHandle_t Open( const char *pFileName, const char *pOptions, const char *pathID = 0L ) = 0; - - virtual void Close( FileHandle_t file ) = 0; - - virtual void Seek( FileHandle_t file, int pos, FileSystemSeek_t seekType ) = 0; - virtual unsigned int Tell( FileHandle_t file ) = 0; - - virtual unsigned int Size( FileHandle_t file ) = 0; - virtual unsigned int Size( const char *pFileName ) = 0; - - virtual long GetFileTime( const char *pFileName ) = 0; - virtual void FileTimeToString( char* pStrip, int maxCharsIncludingTerminator, long fileTime ) = 0; - - virtual bool IsOk( FileHandle_t file ) = 0; - - virtual void Flush( FileHandle_t file ) = 0; - virtual bool EndOfFile( FileHandle_t file ) = 0; - - virtual int Read( void* pOutput, int size, FileHandle_t file ) = 0; - virtual int Write( void const* pInput, int size, FileHandle_t file ) = 0; - virtual char *ReadLine( char *pOutput, int maxChars, FileHandle_t file ) = 0; - virtual int FPrintf( FileHandle_t file, char *pFormat, ... ) = 0; - - // direct filesystem buffer access - // returns a handle to a buffer containing the file data - // this is the optimal way to access the complete data for a file, - // since the file preloader has probably already got it in memory - virtual void *GetReadBuffer( FileHandle_t file, int *outBufferSize, bool failIfNotInCache ) = 0; - virtual void ReleaseReadBuffer( FileHandle_t file, void *readBuffer ) = 0; - - // FindFirst/FindNext - virtual const char *FindFirst( const char *pWildCard, FileFindHandle_t *pHandle, const char *pathID = 0L ) = 0; - virtual const char *FindNext( FileFindHandle_t handle ) = 0; - virtual bool FindIsDirectory( FileFindHandle_t handle ) = 0; - virtual void FindClose( FileFindHandle_t handle ) = 0; - - virtual void GetLocalCopy( const char *pFileName ) = 0; - - virtual const char *GetLocalPath( const char *pFileName, char *pLocalPath, int localPathBufferSize ) = 0; - - // Note: This is sort of a secondary feature; but it's really useful to have it here - virtual char *ParseFile( char* pFileBytes, char* pToken, bool* pWasQuoted ) = 0; - - // Returns true on success ( based on current list of search paths, otherwise false if it can't be resolved ) - virtual bool FullPathToRelativePath( const char *pFullpath, char *pRelative ) = 0; - - // Gets the current working directory - virtual bool GetCurrentDirectory( char* pDirectory, int maxlen ) = 0; - - // Dump to printf/OutputDebugString the list of files that have not been closed - virtual void PrintOpenedFiles( void ) = 0; - - virtual void SetWarningFunc( void (*pfnWarning)( const char *fmt, ... ) ) = 0; - virtual void SetWarningLevel( FileWarningLevel_t level ) = 0; - - virtual void LogLevelLoadStarted( const char *name ) = 0; - virtual void LogLevelLoadFinished( const char *name ) = 0; - virtual int HintResourceNeed( const char *hintlist, int forgetEverything ) = 0; - virtual int PauseResourcePreloading( void ) = 0; - virtual int ResumeResourcePreloading( void ) = 0; - virtual int SetVBuf( FileHandle_t stream, char *buffer, int mode, long size ) = 0; - virtual void GetInterfaceVersion( char *p, int maxlen ) = 0; - virtual bool IsFileImmediatelyAvailable(const char *pFileName) = 0; - - // starts waiting for resources to be available - // returns FILESYSTEM_INVALID_HANDLE if there is nothing to wait on - virtual WaitForResourcesHandle_t WaitForResources( const char *resourcelist ) = 0; - // get progress on waiting for resources; progress is a float [0, 1], complete is true on the waiting being done - // returns false if no progress is available - // any calls after complete is true or on an invalid handle will return false, 0.0f, true - virtual bool GetWaitForResourcesProgress( WaitForResourcesHandle_t handle, float *progress /* out */ , bool *complete /* out */ ) = 0; - // cancels a progress call - virtual void CancelWaitForResources( WaitForResourcesHandle_t handle ) = 0; - // returns true if the appID has all its caches fully preloaded - virtual bool IsAppReadyForOfflinePlay( int appID ) = 0; - - // interface for custom pack files > 4Gb - virtual bool AddPackFile( const char *fullpath, const char *pathID ) = 0; - - // open a file but force the data to come from the steam cache, NOT from disk - virtual FileHandle_t OpenFromCacheForRead( const char *pFileName, const char *pOptions, const char *pathID = 0L ) = 0; - - virtual void AddSearchPathNoWrite( const char *pPath, const char *pathID ) = 0; -}; - -// Steam3/Src compat -#define IBaseFileSystem IFileSystem - -#define FILESYSTEM_INTERFACE_VERSION "VFileSystem009" - -#endif // FILESYSTEM_H +//========= Copyright � 1996-2001, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef FILESYSTEM_H +#define FILESYSTEM_H +#ifdef _WIN32 +#pragma once +#endif + +#include "interface.h" +#include +#include + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +typedef FILE * FileHandle_t; +typedef int FileFindHandle_t; +typedef int WaitForResourcesHandle_t; + + +//----------------------------------------------------------------------------- +// Enums used by the interface +//----------------------------------------------------------------------------- +#ifndef FILESYSTEM_INTERNAL_H +typedef enum +{ + FILESYSTEM_SEEK_HEAD = 0, + FILESYSTEM_SEEK_CURRENT, + FILESYSTEM_SEEK_TAIL, +} FileSystemSeek_t; + +enum +{ + FILESYSTEM_INVALID_FIND_HANDLE = -1 +}; + +typedef enum +{ + // Don't print anything + FILESYSTEM_WARNING_QUIET = 0, + + // On shutdown, report names of files left unclosed + FILESYSTEM_WARNING_REPORTUNCLOSED, + + // Report number of times a file was opened, closed + FILESYSTEM_WARNING_REPORTUSAGE, + + // Report all open/close events to console ( !slow! ) + FILESYSTEM_WARNING_REPORTALLACCESSES +} FileWarningLevel_t; + +#define FILESYSTEM_INVALID_HANDLE ( FileHandle_t )0 +#endif + +// turn off any windows defines +#undef GetCurrentDirectory + +//----------------------------------------------------------------------------- +// Purpose: Main file system interface +//----------------------------------------------------------------------------- +class IFileSystem : public IBaseInterface +{ +public: + // Mount and unmount the filesystem + virtual void Mount( void ) = 0; + virtual void Unmount( void ) = 0; + + // Remove all search paths (including write path?) + virtual void RemoveAllSearchPaths( void ) = 0; + + // Add paths in priority order (mod dir, game dir, ....) + // If one or more .pak files are in the specified directory, then they are + // added after the file system path + // If the path is the relative path to a .bsp file, then any previous .bsp file + // override is cleared and the current .bsp is searched for an embedded PAK file + // and this file becomes the highest priority search path ( i.e., it's looked at first + // even before the mod's file system path ). + virtual void AddSearchPath( const char *pPath, const char *pathID ) = 0; + virtual bool RemoveSearchPath( const char *pPath ) = 0; + + // Deletes a file + virtual void RemoveFile( const char *pRelativePath, const char *pathID ) = 0; + + // this isn't implementable on STEAM as is. + virtual void CreateDirHierarchy( const char *path, const char *pathID ) = 0; + + // File I/O and info + virtual bool FileExists( const char *pFileName ) = 0; + virtual bool IsDirectory( const char *pFileName ) = 0; + + // opens a file + // if pathID is NULL, all paths will be searched for the file + virtual FileHandle_t Open( const char *pFileName, const char *pOptions, const char *pathID = 0L ) = 0; + + virtual void Close( FileHandle_t file ) = 0; + + virtual void Seek( FileHandle_t file, int pos, FileSystemSeek_t seekType ) = 0; + virtual unsigned int Tell( FileHandle_t file ) = 0; + + virtual unsigned int Size( FileHandle_t file ) = 0; + virtual unsigned int Size( const char *pFileName ) = 0; + + virtual long GetFileTime( const char *pFileName ) = 0; + virtual void FileTimeToString( char* pStrip, int maxCharsIncludingTerminator, long fileTime ) = 0; + + virtual bool IsOk( FileHandle_t file ) = 0; + + virtual void Flush( FileHandle_t file ) = 0; + virtual bool EndOfFile( FileHandle_t file ) = 0; + + virtual int Read( void* pOutput, int size, FileHandle_t file ) = 0; + virtual int Write( void const* pInput, int size, FileHandle_t file ) = 0; + virtual char *ReadLine( char *pOutput, int maxChars, FileHandle_t file ) = 0; + virtual int FPrintf( FileHandle_t file, char *pFormat, ... ) = 0; + + // direct filesystem buffer access + // returns a handle to a buffer containing the file data + // this is the optimal way to access the complete data for a file, + // since the file preloader has probably already got it in memory + virtual void *GetReadBuffer( FileHandle_t file, int *outBufferSize, bool failIfNotInCache ) = 0; + virtual void ReleaseReadBuffer( FileHandle_t file, void *readBuffer ) = 0; + + // FindFirst/FindNext + virtual const char *FindFirst( const char *pWildCard, FileFindHandle_t *pHandle, const char *pathID = 0L ) = 0; + virtual const char *FindNext( FileFindHandle_t handle ) = 0; + virtual bool FindIsDirectory( FileFindHandle_t handle ) = 0; + virtual void FindClose( FileFindHandle_t handle ) = 0; + + virtual void GetLocalCopy( const char *pFileName ) = 0; + + virtual const char *GetLocalPath( const char *pFileName, char *pLocalPath, int localPathBufferSize ) = 0; + + // Note: This is sort of a secondary feature; but it's really useful to have it here + virtual char *ParseFile( char* pFileBytes, char* pToken, bool* pWasQuoted ) = 0; + + // Returns true on success ( based on current list of search paths, otherwise false if it can't be resolved ) + virtual bool FullPathToRelativePath( const char *pFullpath, char *pRelative ) = 0; + + // Gets the current working directory + virtual bool GetCurrentDirectory( char* pDirectory, int maxlen ) = 0; + + // Dump to printf/OutputDebugString the list of files that have not been closed + virtual void PrintOpenedFiles( void ) = 0; + + virtual void SetWarningFunc( void (*pfnWarning)( const char *fmt, ... ) ) = 0; + virtual void SetWarningLevel( FileWarningLevel_t level ) = 0; + + virtual void LogLevelLoadStarted( const char *name ) = 0; + virtual void LogLevelLoadFinished( const char *name ) = 0; + virtual int HintResourceNeed( const char *hintlist, int forgetEverything ) = 0; + virtual int PauseResourcePreloading( void ) = 0; + virtual int ResumeResourcePreloading( void ) = 0; + virtual int SetVBuf( FileHandle_t stream, char *buffer, int mode, long size ) = 0; + virtual void GetInterfaceVersion( char *p, int maxlen ) = 0; + virtual bool IsFileImmediatelyAvailable(const char *pFileName) = 0; + + // starts waiting for resources to be available + // returns FILESYSTEM_INVALID_HANDLE if there is nothing to wait on + virtual WaitForResourcesHandle_t WaitForResources( const char *resourcelist ) = 0; + // get progress on waiting for resources; progress is a float [0, 1], complete is true on the waiting being done + // returns false if no progress is available + // any calls after complete is true or on an invalid handle will return false, 0.0f, true + virtual bool GetWaitForResourcesProgress( WaitForResourcesHandle_t handle, float *progress /* out */ , bool *complete /* out */ ) = 0; + // cancels a progress call + virtual void CancelWaitForResources( WaitForResourcesHandle_t handle ) = 0; + // returns true if the appID has all its caches fully preloaded + virtual bool IsAppReadyForOfflinePlay( int appID ) = 0; + + // interface for custom pack files > 4Gb + virtual bool AddPackFile( const char *fullpath, const char *pathID ) = 0; + + // open a file but force the data to come from the steam cache, NOT from disk + virtual FileHandle_t OpenFromCacheForRead( const char *pFileName, const char *pOptions, const char *pathID = 0L ) = 0; + + virtual void AddSearchPathNoWrite( const char *pPath, const char *pathID ) = 0; +}; + +// Steam3/Src compat +#define IBaseFileSystem IFileSystem + +#define FILESYSTEM_INTERFACE_VERSION "VFileSystem009" + +#endif // FILESYSTEM_H diff --git a/dep/rehlsdk/public/interface.cpp b/dep/rehlsdk/public/interface.cpp index 440e719..08fa937 100644 --- a/dep/rehlsdk/public/interface.cpp +++ b/dep/rehlsdk/public/interface.cpp @@ -1,263 +1,263 @@ -#include "interface.h" - - -#if !defined ( _WIN32 ) -// Linux doesn't have this function so this emulates its functionality -// -// -void *GetModuleHandle(const char *name) -{ - void *handle; - - if (name == NULL) - { - // hmm, how can this be handled under linux.... - // is it even needed? - return NULL; - } - - if ((handle=dlopen(name, RTLD_NOW)) == NULL) - { - //printf("Error:%s\n",dlerror()); - // couldn't open this file - return NULL; - } - - // read "man dlopen" for details - // in short dlopen() inc a ref count - // so dec the ref count by performing the close - dlclose(handle); - return handle; -} -#endif - -// ------------------------------------------------------------------------------------ // -// InterfaceReg. -// ------------------------------------------------------------------------------------ // -InterfaceReg *InterfaceReg::s_pInterfaceRegs = NULL; - - -InterfaceReg::InterfaceReg( InstantiateInterfaceFn fn, const char *pName ) : m_pName(pName) -{ - m_CreateFn = fn; - m_pNext = s_pInterfaceRegs; - s_pInterfaceRegs = this; -} - - - -// ------------------------------------------------------------------------------------ // -// CreateInterface. -// ------------------------------------------------------------------------------------ // -EXPORT_FUNCTION IBaseInterface *CreateInterface( const char *pName, int *pReturnCode ) -{ - InterfaceReg *pCur; - - for(pCur=InterfaceReg::s_pInterfaceRegs; pCur; pCur=pCur->m_pNext) - { - if(strcmp(pCur->m_pName, pName) == 0) - { - if ( pReturnCode ) - { - *pReturnCode = IFACE_OK; - } - return pCur->m_CreateFn(); - } - } - - if ( pReturnCode ) - { - *pReturnCode = IFACE_FAILED; - } - return NULL; -} - -#ifdef LINUX -static IBaseInterface *CreateInterfaceLocal( const char *pName, int *pReturnCode ) -{ - InterfaceReg *pCur; - - for(pCur=InterfaceReg::s_pInterfaceRegs; pCur; pCur=pCur->m_pNext) - { - if(strcmp(pCur->m_pName, pName) == 0) - { - if ( pReturnCode ) - { - *pReturnCode = IFACE_OK; - } - return pCur->m_CreateFn(); - } - } - - if ( pReturnCode ) - { - *pReturnCode = IFACE_FAILED; - } - return NULL; -} -#endif - -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include "windows.h" -#endif - -//----------------------------------------------------------------------------- -// Purpose: returns a pointer to a function, given a module -// Input : pModuleName - module name -// *pName - proc name -//----------------------------------------------------------------------------- -//static hlds_run wants to use this function -void *Sys_GetProcAddress( const char *pModuleName, const char *pName ) -{ - return GetProcAddress( GetModuleHandle(pModuleName), pName ); -} - -//----------------------------------------------------------------------------- -// Purpose: returns a pointer to a function, given a module -// Input : pModuleName - module name -// *pName - proc name -//----------------------------------------------------------------------------- -// hlds_run wants to use this function -void *Sys_GetProcAddress( void *pModuleHandle, const char *pName ) -{ -#if defined ( _WIN32 ) - return GetProcAddress( (HINSTANCE)pModuleHandle, pName ); -#else - return GetProcAddress( pModuleHandle, pName ); -#endif -} - -//----------------------------------------------------------------------------- -// Purpose: Loads a DLL/component from disk and returns a handle to it -// Input : *pModuleName - filename of the component -// Output : opaque handle to the module (hides system dependency) -//----------------------------------------------------------------------------- -CSysModule *Sys_LoadModule( const char *pModuleName ) -{ -#if defined ( _WIN32 ) - HMODULE hDLL = LoadLibrary( pModuleName ); -#else - HMODULE hDLL = NULL; - char szAbsoluteModuleName[1024]; - szAbsoluteModuleName[0] = 0; - if ( pModuleName[0] != '/' ) - { - char szCwd[1024]; - char szAbsoluteModuleName[1024]; - - getcwd( szCwd, sizeof( szCwd ) ); - if ( szCwd[ strlen( szCwd ) - 1 ] == '/' ) - szCwd[ strlen( szCwd ) - 1 ] = 0; - - _snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/%s", szCwd, pModuleName ); - - hDLL = dlopen( szAbsoluteModuleName, RTLD_NOW ); - } - else - { - _snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s", pModuleName ); - hDLL = dlopen( pModuleName, RTLD_NOW ); - } -#endif - - if( !hDLL ) - { - char str[512]; -#if defined ( _WIN32 ) - _snprintf( str, sizeof(str), "%s.dll", pModuleName ); - hDLL = LoadLibrary( str ); -#elif defined(OSX) - printf("Error:%s\n",dlerror()); - _snprintf( str, sizeof(str), "%s.dylib", szAbsoluteModuleName ); - hDLL = dlopen(str, RTLD_NOW); -#else - printf("Error:%s\n",dlerror()); - _snprintf( str, sizeof(str), "%s.so", szAbsoluteModuleName ); - hDLL = dlopen(str, RTLD_NOW); -#endif - } - - return reinterpret_cast(hDLL); -} - -//----------------------------------------------------------------------------- -// Purpose: Unloads a DLL/component from -// Input : *pModuleName - filename of the component -// Output : opaque handle to the module (hides system dependency) -//----------------------------------------------------------------------------- -void Sys_UnloadModule( CSysModule *pModule ) -{ - if ( !pModule ) - return; - - HMODULE hDLL = reinterpret_cast(pModule); -#if defined ( _WIN32 ) - FreeLibrary( hDLL ); -#else - dlclose((void *)hDLL); -#endif - -} - -//----------------------------------------------------------------------------- -// Purpose: returns a pointer to a function, given a module -// Input : module - windows HMODULE from Sys_LoadModule() -// *pName - proc name -// Output : factory for this module -//----------------------------------------------------------------------------- -CreateInterfaceFn Sys_GetFactory( CSysModule *pModule ) -{ - if ( !pModule ) - return NULL; - - HMODULE hDLL = reinterpret_cast(pModule); -#if defined ( _WIN32 ) - return reinterpret_cast(GetProcAddress( hDLL, CREATEINTERFACE_PROCNAME )); -#else -// Linux gives this error: -//../public/interface.cpp: In function `IBaseInterface *(*Sys_GetFactory -//(CSysModule *)) (const char *, int *)': -//../public/interface.cpp:154: ISO C++ forbids casting between -//pointer-to-function and pointer-to-object -// -// so lets get around it :) - return (CreateInterfaceFn)(GetProcAddress( hDLL, CREATEINTERFACE_PROCNAME )); -#endif -} - - - -//----------------------------------------------------------------------------- -// Purpose: returns the instance of this module -// Output : interface_instance_t -//----------------------------------------------------------------------------- -CreateInterfaceFn Sys_GetFactoryThis( void ) -{ -#ifdef LINUX - return CreateInterfaceLocal; -#else - return CreateInterface; -#endif -} - -//----------------------------------------------------------------------------- -// Purpose: returns the instance of the named module -// Input : *pModuleName - name of the module -// Output : interface_instance_t - instance of that module -//----------------------------------------------------------------------------- -CreateInterfaceFn Sys_GetFactory( const char *pModuleName ) -{ -#if defined ( _WIN32 ) - return static_cast( Sys_GetProcAddress( pModuleName, CREATEINTERFACE_PROCNAME ) ); -#else -// Linux gives this error: -//../public/interface.cpp: In function `IBaseInterface *(*Sys_GetFactory -//(const char *)) (const char *, int *)': -//../public/interface.cpp:186: invalid static_cast from type `void *' to -//type `IBaseInterface *(*) (const char *, int *)' -// -// so lets use the old style cast. - return (CreateInterfaceFn)( Sys_GetProcAddress( pModuleName, CREATEINTERFACE_PROCNAME ) ); -#endif -} +#include "interface.h" + + +#if !defined ( _WIN32 ) +// Linux doesn't have this function so this emulates its functionality +// +// +void *GetModuleHandle(const char *name) +{ + void *handle; + + if (name == NULL) + { + // hmm, how can this be handled under linux.... + // is it even needed? + return NULL; + } + + if ((handle=dlopen(name, RTLD_NOW)) == NULL) + { + //printf("Error:%s\n",dlerror()); + // couldn't open this file + return NULL; + } + + // read "man dlopen" for details + // in short dlopen() inc a ref count + // so dec the ref count by performing the close + dlclose(handle); + return handle; +} +#endif + +// ------------------------------------------------------------------------------------ // +// InterfaceReg. +// ------------------------------------------------------------------------------------ // +InterfaceReg *InterfaceReg::s_pInterfaceRegs = NULL; + + +InterfaceReg::InterfaceReg( InstantiateInterfaceFn fn, const char *pName ) : m_pName(pName) +{ + m_CreateFn = fn; + m_pNext = s_pInterfaceRegs; + s_pInterfaceRegs = this; +} + + + +// ------------------------------------------------------------------------------------ // +// CreateInterface. +// ------------------------------------------------------------------------------------ // +EXPORT_FUNCTION IBaseInterface *CreateInterface( const char *pName, int *pReturnCode ) +{ + InterfaceReg *pCur; + + for(pCur=InterfaceReg::s_pInterfaceRegs; pCur; pCur=pCur->m_pNext) + { + if(strcmp(pCur->m_pName, pName) == 0) + { + if ( pReturnCode ) + { + *pReturnCode = IFACE_OK; + } + return pCur->m_CreateFn(); + } + } + + if ( pReturnCode ) + { + *pReturnCode = IFACE_FAILED; + } + return NULL; +} + +#ifdef LINUX +static IBaseInterface *CreateInterfaceLocal( const char *pName, int *pReturnCode ) +{ + InterfaceReg *pCur; + + for(pCur=InterfaceReg::s_pInterfaceRegs; pCur; pCur=pCur->m_pNext) + { + if(strcmp(pCur->m_pName, pName) == 0) + { + if ( pReturnCode ) + { + *pReturnCode = IFACE_OK; + } + return pCur->m_CreateFn(); + } + } + + if ( pReturnCode ) + { + *pReturnCode = IFACE_FAILED; + } + return NULL; +} +#endif + +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include "windows.h" +#endif + +//----------------------------------------------------------------------------- +// Purpose: returns a pointer to a function, given a module +// Input : pModuleName - module name +// *pName - proc name +//----------------------------------------------------------------------------- +//static hlds_run wants to use this function +void *Sys_GetProcAddress( const char *pModuleName, const char *pName ) +{ + return GetProcAddress( GetModuleHandle(pModuleName), pName ); +} + +//----------------------------------------------------------------------------- +// Purpose: returns a pointer to a function, given a module +// Input : pModuleName - module name +// *pName - proc name +//----------------------------------------------------------------------------- +// hlds_run wants to use this function +void *Sys_GetProcAddress( void *pModuleHandle, const char *pName ) +{ +#if defined ( _WIN32 ) + return GetProcAddress( (HINSTANCE)pModuleHandle, pName ); +#else + return GetProcAddress( pModuleHandle, pName ); +#endif +} + +//----------------------------------------------------------------------------- +// Purpose: Loads a DLL/component from disk and returns a handle to it +// Input : *pModuleName - filename of the component +// Output : opaque handle to the module (hides system dependency) +//----------------------------------------------------------------------------- +CSysModule *Sys_LoadModule( const char *pModuleName ) +{ +#if defined ( _WIN32 ) + HMODULE hDLL = LoadLibrary( pModuleName ); +#else + HMODULE hDLL = NULL; + char szAbsoluteModuleName[1024]; + szAbsoluteModuleName[0] = 0; + if ( pModuleName[0] != '/' ) + { + char szCwd[1024]; + char szAbsoluteModuleName[1024]; + + getcwd( szCwd, sizeof( szCwd ) ); + if ( szCwd[ strlen( szCwd ) - 1 ] == '/' ) + szCwd[ strlen( szCwd ) - 1 ] = 0; + + _snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s/%s", szCwd, pModuleName ); + + hDLL = dlopen( szAbsoluteModuleName, RTLD_NOW ); + } + else + { + _snprintf( szAbsoluteModuleName, sizeof(szAbsoluteModuleName), "%s", pModuleName ); + hDLL = dlopen( pModuleName, RTLD_NOW ); + } +#endif + + if( !hDLL ) + { + char str[512]; +#if defined ( _WIN32 ) + _snprintf( str, sizeof(str), "%s.dll", pModuleName ); + hDLL = LoadLibrary( str ); +#elif defined(OSX) + printf("Error:%s\n",dlerror()); + _snprintf( str, sizeof(str), "%s.dylib", szAbsoluteModuleName ); + hDLL = dlopen(str, RTLD_NOW); +#else + printf("Error:%s\n",dlerror()); + _snprintf( str, sizeof(str), "%s.so", szAbsoluteModuleName ); + hDLL = dlopen(str, RTLD_NOW); +#endif + } + + return reinterpret_cast(hDLL); +} + +//----------------------------------------------------------------------------- +// Purpose: Unloads a DLL/component from +// Input : *pModuleName - filename of the component +// Output : opaque handle to the module (hides system dependency) +//----------------------------------------------------------------------------- +void Sys_UnloadModule( CSysModule *pModule ) +{ + if ( !pModule ) + return; + + HMODULE hDLL = reinterpret_cast(pModule); +#if defined ( _WIN32 ) + FreeLibrary( hDLL ); +#else + dlclose((void *)hDLL); +#endif + +} + +//----------------------------------------------------------------------------- +// Purpose: returns a pointer to a function, given a module +// Input : module - windows HMODULE from Sys_LoadModule() +// *pName - proc name +// Output : factory for this module +//----------------------------------------------------------------------------- +CreateInterfaceFn Sys_GetFactory( CSysModule *pModule ) +{ + if ( !pModule ) + return NULL; + + HMODULE hDLL = reinterpret_cast(pModule); +#if defined ( _WIN32 ) + return reinterpret_cast(GetProcAddress( hDLL, CREATEINTERFACE_PROCNAME )); +#else +// Linux gives this error: +//../public/interface.cpp: In function `IBaseInterface *(*Sys_GetFactory +//(CSysModule *)) (const char *, int *)': +//../public/interface.cpp:154: ISO C++ forbids casting between +//pointer-to-function and pointer-to-object +// +// so lets get around it :) + return (CreateInterfaceFn)(GetProcAddress( hDLL, CREATEINTERFACE_PROCNAME )); +#endif +} + + + +//----------------------------------------------------------------------------- +// Purpose: returns the instance of this module +// Output : interface_instance_t +//----------------------------------------------------------------------------- +CreateInterfaceFn Sys_GetFactoryThis( void ) +{ +#ifdef LINUX + return CreateInterfaceLocal; +#else + return CreateInterface; +#endif +} + +//----------------------------------------------------------------------------- +// Purpose: returns the instance of the named module +// Input : *pModuleName - name of the module +// Output : interface_instance_t - instance of that module +//----------------------------------------------------------------------------- +CreateInterfaceFn Sys_GetFactory( const char *pModuleName ) +{ +#if defined ( _WIN32 ) + return static_cast( Sys_GetProcAddress( pModuleName, CREATEINTERFACE_PROCNAME ) ); +#else +// Linux gives this error: +//../public/interface.cpp: In function `IBaseInterface *(*Sys_GetFactory +//(const char *)) (const char *, int *)': +//../public/interface.cpp:186: invalid static_cast from type `void *' to +//type `IBaseInterface *(*) (const char *, int *)' +// +// so lets use the old style cast. + return (CreateInterfaceFn)( Sys_GetProcAddress( pModuleName, CREATEINTERFACE_PROCNAME ) ); +#endif +} diff --git a/dep/rehlsdk/public/interface.h b/dep/rehlsdk/public/interface.h index 980a5af..3349146 100644 --- a/dep/rehlsdk/public/interface.h +++ b/dep/rehlsdk/public/interface.h @@ -1,150 +1,150 @@ - -// This header defines the interface convention used in the valve engine. -// To make an interface and expose it: -// 1. Derive from IBaseInterface. -// 2. The interface must be ALL pure virtuals, and have no data members. -// 3. Define a name for it. -// 4. In its implementation file, use EXPOSE_INTERFACE or EXPOSE_SINGLE_INTERFACE. - -// Versioning -// There are two versioning cases that are handled by this: -// 1. You add functions to the end of an interface, so it is binary compatible with the previous interface. In this case, -// you need two EXPOSE_INTERFACEs: one to expose your class as the old interface and one to expose it as the new interface. -// 2. You update an interface so it's not compatible anymore (but you still want to be able to expose the old interface -// for legacy code). In this case, you need to make a new version name for your new interface, and make a wrapper interface and -// expose it for the old interface. - -//#if _MSC_VER >= 1300 // VC7 -//#include "tier1/interface.h" -//#else - -#ifndef INTERFACE_H -#define INTERFACE_H - -#if !defined ( _WIN32 ) - -#include // dlopen,dlclose, et al -#include - -#define HMODULE void * -#define GetProcAddress dlsym - -#define _snprintf snprintf - -#endif - -void *Sys_GetProcAddress(const char *pModuleName, const char *pName); -void *Sys_GetProcAddress(void *pModuleHandle, const char *pName); - -// All interfaces derive from this. -class IBaseInterface -{ -public: - - virtual ~IBaseInterface() {} -}; - - -#define CREATEINTERFACE_PROCNAME "CreateInterface" -typedef IBaseInterface* (*CreateInterfaceFn)(const char *pName, int *pReturnCode); - - -typedef IBaseInterface* (*InstantiateInterfaceFn)(); - - -// Used internally to register classes. -class InterfaceReg -{ -public: - InterfaceReg(InstantiateInterfaceFn fn, const char *pName); - -public: - - InstantiateInterfaceFn m_CreateFn; - const char *m_pName; - - InterfaceReg *m_pNext; // For the global list. - static InterfaceReg *s_pInterfaceRegs; -}; - - -// Use this to expose an interface that can have multiple instances. -// e.g.: -// EXPOSE_INTERFACE( CInterfaceImp, IInterface, "MyInterface001" ) -// This will expose a class called CInterfaceImp that implements IInterface (a pure class) -// clients can receive a pointer to this class by calling CreateInterface( "MyInterface001" ) -// -// In practice, the shared header file defines the interface (IInterface) and version name ("MyInterface001") -// so that each component can use these names/vtables to communicate -// -// A single class can support multiple interfaces through multiple inheritance -// -// Use this if you want to write the factory function. -#define EXPOSE_INTERFACE_FN(functionName, interfaceName, versionName) \ - static InterfaceReg __g_Create##className##_reg(functionName, versionName); - -#define EXPOSE_INTERFACE(className, interfaceName, versionName) \ - static IBaseInterface* __Create##className##_interface() {return (interfaceName *)new className;}\ - static InterfaceReg __g_Create##className##_reg(__Create##className##_interface, versionName ); - -// Use this to expose a singleton interface with a global variable you've created. -#define EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, globalVarName) \ - static IBaseInterface* __Create##className##interfaceName##_interface() {return (IBaseInterface *)&globalVarName;}\ - static InterfaceReg __g_Create##className##interfaceName##_reg(__Create##className##interfaceName##_interface, versionName); - -// Use this to expose a singleton interface. This creates the global variable for you automatically. -#define EXPOSE_SINGLE_INTERFACE(className, interfaceName, versionName) \ - static className __g_##className##_singleton;\ - EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, __g_##className##_singleton) - - -#ifdef _WIN32 - #define EXPORT_FUNCTION __declspec(dllexport) -#else - #define EXPORT_FUNCTION __attribute__ ((visibility("default"))) -#endif - - -// This function is automatically exported and allows you to access any interfaces exposed with the above macros. -// if pReturnCode is set, it will return one of the following values -// extend this for other error conditions/code -enum -{ - IFACE_OK = 0, - IFACE_FAILED -}; - - -extern "C" -{ - EXPORT_FUNCTION IBaseInterface* CreateInterface(const char *pName, int *pReturnCode); -}; - - -extern CreateInterfaceFn Sys_GetFactoryThis( void ); - - -//----------------------------------------------------------------------------- -// UNDONE: This is obsolete, use the module load/unload/get instead!!! -//----------------------------------------------------------------------------- -extern CreateInterfaceFn Sys_GetFactory( const char *pModuleName ); - - -// load/unload components -class CSysModule; - -//----------------------------------------------------------------------------- -// Load & Unload should be called in exactly one place for each module -// The factory for that module should be passed on to dependent components for -// proper versioning. -//----------------------------------------------------------------------------- -extern CSysModule *Sys_LoadModule( const char *pModuleName ); -extern void Sys_UnloadModule( CSysModule *pModule ); - -extern CreateInterfaceFn Sys_GetFactory( CSysModule *pModule ); - - -#endif -//#endif // MSVC 6.0 - - + +// This header defines the interface convention used in the valve engine. +// To make an interface and expose it: +// 1. Derive from IBaseInterface. +// 2. The interface must be ALL pure virtuals, and have no data members. +// 3. Define a name for it. +// 4. In its implementation file, use EXPOSE_INTERFACE or EXPOSE_SINGLE_INTERFACE. + +// Versioning +// There are two versioning cases that are handled by this: +// 1. You add functions to the end of an interface, so it is binary compatible with the previous interface. In this case, +// you need two EXPOSE_INTERFACEs: one to expose your class as the old interface and one to expose it as the new interface. +// 2. You update an interface so it's not compatible anymore (but you still want to be able to expose the old interface +// for legacy code). In this case, you need to make a new version name for your new interface, and make a wrapper interface and +// expose it for the old interface. + +//#if _MSC_VER >= 1300 // VC7 +//#include "tier1/interface.h" +//#else + +#ifndef INTERFACE_H +#define INTERFACE_H + +#if !defined ( _WIN32 ) + +#include // dlopen,dlclose, et al +#include + +#define HMODULE void * +#define GetProcAddress dlsym + +#define _snprintf snprintf + +#endif + +void *Sys_GetProcAddress(const char *pModuleName, const char *pName); +void *Sys_GetProcAddress(void *pModuleHandle, const char *pName); + +// All interfaces derive from this. +class IBaseInterface +{ +public: + + virtual ~IBaseInterface() {} +}; + + +#define CREATEINTERFACE_PROCNAME "CreateInterface" +typedef IBaseInterface* (*CreateInterfaceFn)(const char *pName, int *pReturnCode); + + +typedef IBaseInterface* (*InstantiateInterfaceFn)(); + + +// Used internally to register classes. +class InterfaceReg +{ +public: + InterfaceReg(InstantiateInterfaceFn fn, const char *pName); + +public: + + InstantiateInterfaceFn m_CreateFn; + const char *m_pName; + + InterfaceReg *m_pNext; // For the global list. + static InterfaceReg *s_pInterfaceRegs; +}; + + +// Use this to expose an interface that can have multiple instances. +// e.g.: +// EXPOSE_INTERFACE( CInterfaceImp, IInterface, "MyInterface001" ) +// This will expose a class called CInterfaceImp that implements IInterface (a pure class) +// clients can receive a pointer to this class by calling CreateInterface( "MyInterface001" ) +// +// In practice, the shared header file defines the interface (IInterface) and version name ("MyInterface001") +// so that each component can use these names/vtables to communicate +// +// A single class can support multiple interfaces through multiple inheritance +// +// Use this if you want to write the factory function. +#define EXPOSE_INTERFACE_FN(functionName, interfaceName, versionName) \ + static InterfaceReg __g_Create##className##_reg(functionName, versionName); + +#define EXPOSE_INTERFACE(className, interfaceName, versionName) \ + static IBaseInterface* __Create##className##_interface() {return (interfaceName *)new className;}\ + static InterfaceReg __g_Create##className##_reg(__Create##className##_interface, versionName ); + +// Use this to expose a singleton interface with a global variable you've created. +#define EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, globalVarName) \ + static IBaseInterface* __Create##className##interfaceName##_interface() {return (IBaseInterface *)&globalVarName;}\ + static InterfaceReg __g_Create##className##interfaceName##_reg(__Create##className##interfaceName##_interface, versionName); + +// Use this to expose a singleton interface. This creates the global variable for you automatically. +#define EXPOSE_SINGLE_INTERFACE(className, interfaceName, versionName) \ + static className __g_##className##_singleton;\ + EXPOSE_SINGLE_INTERFACE_GLOBALVAR(className, interfaceName, versionName, __g_##className##_singleton) + + +#ifdef _WIN32 + #define EXPORT_FUNCTION __declspec(dllexport) +#else + #define EXPORT_FUNCTION __attribute__ ((visibility("default"))) +#endif + + +// This function is automatically exported and allows you to access any interfaces exposed with the above macros. +// if pReturnCode is set, it will return one of the following values +// extend this for other error conditions/code +enum +{ + IFACE_OK = 0, + IFACE_FAILED +}; + + +extern "C" +{ + EXPORT_FUNCTION IBaseInterface* CreateInterface(const char *pName, int *pReturnCode); +}; + + +extern CreateInterfaceFn Sys_GetFactoryThis( void ); + + +//----------------------------------------------------------------------------- +// UNDONE: This is obsolete, use the module load/unload/get instead!!! +//----------------------------------------------------------------------------- +extern CreateInterfaceFn Sys_GetFactory( const char *pModuleName ); + + +// load/unload components +class CSysModule; + +//----------------------------------------------------------------------------- +// Load & Unload should be called in exactly one place for each module +// The factory for that module should be passed on to dependent components for +// proper versioning. +//----------------------------------------------------------------------------- +extern CSysModule *Sys_LoadModule( const char *pModuleName ); +extern void Sys_UnloadModule( CSysModule *pModule ); + +extern CreateInterfaceFn Sys_GetFactory( CSysModule *pModule ); + + +#endif +//#endif // MSVC 6.0 + + diff --git a/revoice/include/dllapi.h b/revoice/include/dllapi.h index 02431d6..1563be0 100644 --- a/revoice/include/dllapi.h +++ b/revoice/include/dllapi.h @@ -1,189 +1,189 @@ -// dllapi.h - prototypes and typedefs for Half-Life DLL API routines - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef DLLAPI_H -#define DLLAPI_H - -#include "sdk_util.h" // BOOL -#include "osdep.h" // DLLEXPORT, etc - -// Typedefs for these are provided in SDK engine/eiface.h, but I didn't -// like the names (APIFUNCTION, APIFUNCTION2, NEW_DLL_FUNCTIONS_FN). -typedef int (*GETENTITYAPI_FN) (DLL_FUNCTIONS *pFunctionTable, int interfaceVersion); -typedef int (*GETENTITYAPI2_FN) (DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion); -typedef int (*GETNEWDLLFUNCTIONS_FN) (NEW_DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion); - -// From SDK dlls/cbase.h: -C_DLLEXPORT int GetEntityAPI( DLL_FUNCTIONS *pFunctionTable, int interfaceVersion ); -C_DLLEXPORT int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ); - -// No example in SDK.. -// From Adminmod dll.cpp: -C_DLLEXPORT int GetNewDLLFunctions( NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion ); - - -// From SDK dlls/game.h: -extern void mm_GameDLLInit( void ); - -// From SDK dlls/cbase.h: -extern int mm_DispatchSpawn( edict_t *pent ); -extern void mm_DispatchThink( edict_t *pent ); -extern void mm_DispatchUse( edict_t *pentUsed, edict_t *pentOther ); -extern void mm_DispatchTouch( edict_t *pentTouched, edict_t *pentOther ); -extern void mm_DispatchBlocked( edict_t *pentBlocked, edict_t *pentOther ); -extern void mm_DispatchKeyValue( edict_t *pentKeyvalue, KeyValueData *pkvd ); -extern void mm_DispatchSave( edict_t *pent, SAVERESTOREDATA *pSaveData ); -extern int mm_DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ); -extern void mm_DispatchObjectCollisionBox( edict_t *pent ); -extern void mm_SaveWriteFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); -extern void mm_SaveReadFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); -extern void mm_SaveGlobalState( SAVERESTOREDATA *pSaveData ); -extern void mm_RestoreGlobalState( SAVERESTOREDATA *pSaveData ); -extern void mm_ResetGlobalState( void ); - -// From SDK dlls/client.h: -extern BOOL mm_ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); -extern void mm_ClientDisconnect( edict_t *pEntity ); -extern void mm_ClientKill( edict_t *pEntity ); -extern void mm_ClientPutInServer( edict_t *pEntity ); -extern void mm_ClientCommand( edict_t *pEntity ); -extern void mm_ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ); -extern void mm_ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ); -extern void mm_ServerDeactivate( void ); -extern void mm_PlayerPreThink( edict_t *pEntity ); -extern void mm_PlayerPostThink( edict_t *pEntity ); -extern void mm_StartFrame( void ); -extern void mm_ParmsNewLevel( void ); -extern void mm_ParmsChangeLevel( void ); -extern const char *mm_GetGameDescription( void ); -extern void mm_PlayerCustomization( edict_t *pEntity, customization_t *pCust ); -extern void mm_SpectatorConnect ( edict_t *pEntity ); -extern void mm_SpectatorDisconnect ( edict_t *pEntity ); -extern void mm_SpectatorThink ( edict_t *pEntity ); -extern void mm_Sys_Error( const char *error_string ); - -// From SDK pm_shared/pm_shared.h: -extern void mm_PM_Move ( struct playermove_s *ppmove, int server ); -extern void mm_PM_Init ( struct playermove_s *ppmove ); -extern char mm_PM_FindTextureType ( char *name ); - -// From SDK dlls/client.h: -extern void mm_SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas ); -extern void mm_UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); -extern int mm_AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); -extern void mm_CreateBaseline( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ); -extern void mm_RegisterEncoders( void ); -extern int mm_GetWeaponData( struct edict_s *player, struct weapon_data_s *info ); -extern void mm_CmdStart( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ); -extern void mm_CmdEnd ( const edict_t *player ); -extern int mm_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); -extern int mm_GetHullBounds( int hullnumber, float *mins, float *maxs ); -extern void mm_CreateInstancedBaselines ( void ); -extern int mm_InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message ); -extern int mm_AllowLagCompensation( void ); - -// No example from SDK... -extern void mm_OnFreeEntPrivateData(edict_t pEnt); -extern void mm_GameShutdown(void); -extern int mm_ShouldCollide(edict_t *pentTouched, edict_t *pentOther); -//Added 2005-08-11 (no SDK update) -extern void mm_CvarValue(const edict_t *pEnt, const char *value); //! Obsolete! Use mm_CvarValue2 instead -//Added 2005-11-22 (no SDK update) -extern void mm_CvarValue2(const edict_t *pEnt, int requestID, const char *cvarName, const char *value); - - -// Typedefs for the above functions: - -typedef void (*FN_GAMEINIT) ( void ); -typedef int (*FN_DISPATCHSPAWN) ( edict_t *pent ); -typedef void (*FN_DISPATCHTHINK) ( edict_t *pent ); -typedef void (*FN_DISPATCHUSE) ( edict_t *pentUsed, edict_t *pentOther ); -typedef void (*FN_DISPATCHTOUCH) ( edict_t *pentTouched, edict_t *pentOther ); -typedef void (*FN_DISPATCHBLOCKED) ( edict_t *pentBlocked, edict_t *pentOther ); -typedef void (*FN_DISPATCHKEYVALUE) ( edict_t *pentKeyvalue, KeyValueData *pkvd ); -typedef void (*FN_DISPATCHSAVE) ( edict_t *pent, SAVERESTOREDATA *pSaveData ); -typedef int (*FN_DISPATCHRESTORE) ( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ); -typedef void (*FN_DISPATCHOBJECTCOLLISIONBOX) ( edict_t *pent ); -typedef void (*FN_SAVEWRITEFIELDS) ( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); -typedef void (*FN_SAVEREADFIELDS) ( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); -typedef void (*FN_SAVEGLOBALSTATE) ( SAVERESTOREDATA *pSaveData ); -typedef void (*FN_RESTOREGLOBALSTATE) ( SAVERESTOREDATA *pSaveData ); -typedef void (*FN_RESETGLOBALSTATE) ( void ); - -typedef BOOL (*FN_CLIENTCONNECT) ( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); -typedef void (*FN_CLIENTDISCONNECT) ( edict_t *pEntity ); -typedef void (*FN_CLIENTKILL) ( edict_t *pEntity ); -typedef void (*FN_CLIENTPUTINSERVER) ( edict_t *pEntity ); -typedef void (*FN_CLIENTCOMMAND) ( edict_t *pEntity ); -typedef void (*FN_CLIENTUSERINFOCHANGED) ( edict_t *pEntity, char *infobuffer ); -typedef void (*FN_SERVERACTIVATE) ( edict_t *pEdictList, int edictCount, int clientMax ); -typedef void (*FN_SERVERDEACTIVATE) ( void ); -typedef void (*FN_PLAYERPRETHINK) ( edict_t *pEntity ); -typedef void (*FN_PLAYERPOSTTHINK) ( edict_t *pEntity ); -typedef void (*FN_STARTFRAME) ( void ); -typedef void (*FN_PARMSNEWLEVEL) ( void ); -typedef void (*FN_PARMSCHANGELEVEL) ( void ); -typedef const char *(*FN_GETGAMEDESCRIPTION) ( void ); -typedef void (*FN_PLAYERCUSTOMIZATION) ( edict_t *pEntity, customization_t *pCust ); -typedef void (*FN_SPECTATORCONNECT) ( edict_t *pEntity ); -typedef void (*FN_SPECTATORDISCONNECT) ( edict_t *pEntity ); -typedef void (*FN_SPECTATORTHINK) ( edict_t *pEntity ); -typedef void (*FN_SYS_ERROR) ( const char *error_string ); - -typedef void (*FN_PM_MOVE) ( struct playermove_s *ppmove, int server ); -typedef void (*FN_PM_INIT) ( struct playermove_s *ppmove ); -typedef char (*FN_PM_FINDTEXTURETYPE) ( char *name ); - -typedef void (*FN_SETUPVISIBILITY) ( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas ); -typedef void (*FN_UPDATECLIENTDATA) ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); -typedef int (*FN_ADDTOFULLPACK) ( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); -typedef void (*FN_CREATEBASELINE) ( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ); -typedef void (*FN_REGISTERENCODERS) ( void ); -typedef int (*FN_GETWEAPONDATA) ( struct edict_s *player, struct weapon_data_s *info ); -typedef void (*FN_CMDSTART) ( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ); -typedef void (*FN_CMDEND) ( const edict_t *player ); -typedef int (*FN_CONNECTIONLESSPACKET) ( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); -typedef int (*FN_GETHULLBOUNDS) ( int hullnumber, float *mins, float *maxs ); -typedef void (*FN_CREATEINSTANCEDBASELINES) ( void ); -typedef int (*FN_INCONSISTENTFILE) ( const edict_t *player, const char *filename, char *disconnect_message ); -typedef int (*FN_ALLOWLAGCOMPENSATION) ( void ); - -typedef void (*FN_ONFREEENTPRIVATEDATA) (edict_t *pEnt); -typedef void (*FN_GAMESHUTDOWN) (void); -typedef int (*FN_SHOULDCOLLIDE) (edict_t *pentTouched, edict_t *pentOther); -//Added 2005-08-11 (no SDK update) -typedef void (*FN_CVARVALUE)(const edict_t *pEnt, const char *value); //! Obsolete! Use FN_CVARVALUE2 instead -//Added 2005-11-22 (no SDK update) -typedef void (*FN_CVARVALUE2)(const edict_t *pEnt, int requestID, const char *cvarName, const char *value); - -#endif /* DLLAPI_H */ +// dllapi.h - prototypes and typedefs for Half-Life DLL API routines + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef DLLAPI_H +#define DLLAPI_H + +#include "sdk_util.h" // BOOL +#include "osdep.h" // DLLEXPORT, etc + +// Typedefs for these are provided in SDK engine/eiface.h, but I didn't +// like the names (APIFUNCTION, APIFUNCTION2, NEW_DLL_FUNCTIONS_FN). +typedef int (*GETENTITYAPI_FN) (DLL_FUNCTIONS *pFunctionTable, int interfaceVersion); +typedef int (*GETENTITYAPI2_FN) (DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion); +typedef int (*GETNEWDLLFUNCTIONS_FN) (NEW_DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion); + +// From SDK dlls/cbase.h: +C_DLLEXPORT int GetEntityAPI( DLL_FUNCTIONS *pFunctionTable, int interfaceVersion ); +C_DLLEXPORT int GetEntityAPI2( DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion ); + +// No example in SDK.. +// From Adminmod dll.cpp: +C_DLLEXPORT int GetNewDLLFunctions( NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion ); + + +// From SDK dlls/game.h: +extern void mm_GameDLLInit( void ); + +// From SDK dlls/cbase.h: +extern int mm_DispatchSpawn( edict_t *pent ); +extern void mm_DispatchThink( edict_t *pent ); +extern void mm_DispatchUse( edict_t *pentUsed, edict_t *pentOther ); +extern void mm_DispatchTouch( edict_t *pentTouched, edict_t *pentOther ); +extern void mm_DispatchBlocked( edict_t *pentBlocked, edict_t *pentOther ); +extern void mm_DispatchKeyValue( edict_t *pentKeyvalue, KeyValueData *pkvd ); +extern void mm_DispatchSave( edict_t *pent, SAVERESTOREDATA *pSaveData ); +extern int mm_DispatchRestore( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ); +extern void mm_DispatchObjectCollisionBox( edict_t *pent ); +extern void mm_SaveWriteFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); +extern void mm_SaveReadFields( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); +extern void mm_SaveGlobalState( SAVERESTOREDATA *pSaveData ); +extern void mm_RestoreGlobalState( SAVERESTOREDATA *pSaveData ); +extern void mm_ResetGlobalState( void ); + +// From SDK dlls/client.h: +extern BOOL mm_ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); +extern void mm_ClientDisconnect( edict_t *pEntity ); +extern void mm_ClientKill( edict_t *pEntity ); +extern void mm_ClientPutInServer( edict_t *pEntity ); +extern void mm_ClientCommand( edict_t *pEntity ); +extern void mm_ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ); +extern void mm_ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ); +extern void mm_ServerDeactivate( void ); +extern void mm_PlayerPreThink( edict_t *pEntity ); +extern void mm_PlayerPostThink( edict_t *pEntity ); +extern void mm_StartFrame( void ); +extern void mm_ParmsNewLevel( void ); +extern void mm_ParmsChangeLevel( void ); +extern const char *mm_GetGameDescription( void ); +extern void mm_PlayerCustomization( edict_t *pEntity, customization_t *pCust ); +extern void mm_SpectatorConnect ( edict_t *pEntity ); +extern void mm_SpectatorDisconnect ( edict_t *pEntity ); +extern void mm_SpectatorThink ( edict_t *pEntity ); +extern void mm_Sys_Error( const char *error_string ); + +// From SDK pm_shared/pm_shared.h: +extern void mm_PM_Move ( struct playermove_s *ppmove, int server ); +extern void mm_PM_Init ( struct playermove_s *ppmove ); +extern char mm_PM_FindTextureType ( char *name ); + +// From SDK dlls/client.h: +extern void mm_SetupVisibility( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas ); +extern void mm_UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); +extern int mm_AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); +extern void mm_CreateBaseline( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ); +extern void mm_RegisterEncoders( void ); +extern int mm_GetWeaponData( struct edict_s *player, struct weapon_data_s *info ); +extern void mm_CmdStart( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ); +extern void mm_CmdEnd ( const edict_t *player ); +extern int mm_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); +extern int mm_GetHullBounds( int hullnumber, float *mins, float *maxs ); +extern void mm_CreateInstancedBaselines ( void ); +extern int mm_InconsistentFile( const edict_t *player, const char *filename, char *disconnect_message ); +extern int mm_AllowLagCompensation( void ); + +// No example from SDK... +extern void mm_OnFreeEntPrivateData(edict_t pEnt); +extern void mm_GameShutdown(void); +extern int mm_ShouldCollide(edict_t *pentTouched, edict_t *pentOther); +//Added 2005-08-11 (no SDK update) +extern void mm_CvarValue(const edict_t *pEnt, const char *value); //! Obsolete! Use mm_CvarValue2 instead +//Added 2005-11-22 (no SDK update) +extern void mm_CvarValue2(const edict_t *pEnt, int requestID, const char *cvarName, const char *value); + + +// Typedefs for the above functions: + +typedef void (*FN_GAMEINIT) ( void ); +typedef int (*FN_DISPATCHSPAWN) ( edict_t *pent ); +typedef void (*FN_DISPATCHTHINK) ( edict_t *pent ); +typedef void (*FN_DISPATCHUSE) ( edict_t *pentUsed, edict_t *pentOther ); +typedef void (*FN_DISPATCHTOUCH) ( edict_t *pentTouched, edict_t *pentOther ); +typedef void (*FN_DISPATCHBLOCKED) ( edict_t *pentBlocked, edict_t *pentOther ); +typedef void (*FN_DISPATCHKEYVALUE) ( edict_t *pentKeyvalue, KeyValueData *pkvd ); +typedef void (*FN_DISPATCHSAVE) ( edict_t *pent, SAVERESTOREDATA *pSaveData ); +typedef int (*FN_DISPATCHRESTORE) ( edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity ); +typedef void (*FN_DISPATCHOBJECTCOLLISIONBOX) ( edict_t *pent ); +typedef void (*FN_SAVEWRITEFIELDS) ( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); +typedef void (*FN_SAVEREADFIELDS) ( SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); +typedef void (*FN_SAVEGLOBALSTATE) ( SAVERESTOREDATA *pSaveData ); +typedef void (*FN_RESTOREGLOBALSTATE) ( SAVERESTOREDATA *pSaveData ); +typedef void (*FN_RESETGLOBALSTATE) ( void ); + +typedef BOOL (*FN_CLIENTCONNECT) ( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); +typedef void (*FN_CLIENTDISCONNECT) ( edict_t *pEntity ); +typedef void (*FN_CLIENTKILL) ( edict_t *pEntity ); +typedef void (*FN_CLIENTPUTINSERVER) ( edict_t *pEntity ); +typedef void (*FN_CLIENTCOMMAND) ( edict_t *pEntity ); +typedef void (*FN_CLIENTUSERINFOCHANGED) ( edict_t *pEntity, char *infobuffer ); +typedef void (*FN_SERVERACTIVATE) ( edict_t *pEdictList, int edictCount, int clientMax ); +typedef void (*FN_SERVERDEACTIVATE) ( void ); +typedef void (*FN_PLAYERPRETHINK) ( edict_t *pEntity ); +typedef void (*FN_PLAYERPOSTTHINK) ( edict_t *pEntity ); +typedef void (*FN_STARTFRAME) ( void ); +typedef void (*FN_PARMSNEWLEVEL) ( void ); +typedef void (*FN_PARMSCHANGELEVEL) ( void ); +typedef const char *(*FN_GETGAMEDESCRIPTION) ( void ); +typedef void (*FN_PLAYERCUSTOMIZATION) ( edict_t *pEntity, customization_t *pCust ); +typedef void (*FN_SPECTATORCONNECT) ( edict_t *pEntity ); +typedef void (*FN_SPECTATORDISCONNECT) ( edict_t *pEntity ); +typedef void (*FN_SPECTATORTHINK) ( edict_t *pEntity ); +typedef void (*FN_SYS_ERROR) ( const char *error_string ); + +typedef void (*FN_PM_MOVE) ( struct playermove_s *ppmove, int server ); +typedef void (*FN_PM_INIT) ( struct playermove_s *ppmove ); +typedef char (*FN_PM_FINDTEXTURETYPE) ( char *name ); + +typedef void (*FN_SETUPVISIBILITY) ( edict_t *pViewEntity, edict_t *pClient, unsigned char **pvs, unsigned char **pas ); +typedef void (*FN_UPDATECLIENTDATA) ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); +typedef int (*FN_ADDTOFULLPACK) ( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); +typedef void (*FN_CREATEBASELINE) ( int player, int eindex, struct entity_state_s *baseline, struct edict_s *entity, int playermodelindex, vec3_t player_mins, vec3_t player_maxs ); +typedef void (*FN_REGISTERENCODERS) ( void ); +typedef int (*FN_GETWEAPONDATA) ( struct edict_s *player, struct weapon_data_s *info ); +typedef void (*FN_CMDSTART) ( const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed ); +typedef void (*FN_CMDEND) ( const edict_t *player ); +typedef int (*FN_CONNECTIONLESSPACKET) ( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ); +typedef int (*FN_GETHULLBOUNDS) ( int hullnumber, float *mins, float *maxs ); +typedef void (*FN_CREATEINSTANCEDBASELINES) ( void ); +typedef int (*FN_INCONSISTENTFILE) ( const edict_t *player, const char *filename, char *disconnect_message ); +typedef int (*FN_ALLOWLAGCOMPENSATION) ( void ); + +typedef void (*FN_ONFREEENTPRIVATEDATA) (edict_t *pEnt); +typedef void (*FN_GAMESHUTDOWN) (void); +typedef int (*FN_SHOULDCOLLIDE) (edict_t *pentTouched, edict_t *pentOther); +//Added 2005-08-11 (no SDK update) +typedef void (*FN_CVARVALUE)(const edict_t *pEnt, const char *value); //! Obsolete! Use FN_CVARVALUE2 instead +//Added 2005-11-22 (no SDK update) +typedef void (*FN_CVARVALUE2)(const edict_t *pEnt, int requestID, const char *cvarName, const char *value); + +#endif /* DLLAPI_H */ diff --git a/revoice/include/engine_api.h b/revoice/include/engine_api.h index 9076bc3..3e46d28 100644 --- a/revoice/include/engine_api.h +++ b/revoice/include/engine_api.h @@ -1,461 +1,461 @@ -// engine_api.h - prototypes and typedefs for Half-Life engine functions - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef ENGINE_API_H -#define ENGINE_API_H - -#include - -// Plugin's GetEngineFunctions, called by metamod. -typedef int (*GET_ENGINE_FUNCTIONS_FN) (enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion); - -// According to SDK engine/eiface.h: -//! enginefuncs_t -//! ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 138 -#define ENGINE_INTERFACE_VERSION 138 - -// Protect against other projects which use this include file but use the -// normal enginefuncs_t type for their meta_engfuncs. -#ifdef METAMOD_CORE -# include "meta_eiface.h" // meta_enginefuncs_t -extern meta_enginefuncs_t meta_engfuncs; -#else -extern enginefuncs_t meta_engfuncs; -#endif - -// From SDK engine/eiface.h: -extern int mm_PrecacheModel(char *s); -extern int mm_PrecacheSound(char *s); -extern void mm_SetModel(edict_t *e, const char *m); -extern int mm_ModelIndex(const char *m); -extern int mm_ModelFrames(int modelIndex); - -extern void mm_SetSize(edict_t *e, const float *rgflMin, const float *rgflMax); -extern void mm_ChangeLevel(char *s1, char *s2); -extern void mm_GetSpawnParms(edict_t *ent); -extern void mm_SaveSpawnParms(edict_t *ent); - -extern float mm_VecToYaw(const float *rgflVector); -extern void mm_VecToAngles(const float *rgflVectorIn, float *rgflVectorOut); -extern void mm_MoveToOrigin(edict_t *ent, const float *pflGoal, float dist, int iMoveType); -extern void mm_ChangeYaw(edict_t *ent); -extern void mm_ChangePitch(edict_t *ent); - -extern edict_t *mm_FindEntityByString(edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue); -extern int mm_GetEntityIllum(edict_t *pEnt); -extern edict_t *mm_FindEntityInSphere(edict_t *pEdictStartSearchAfter, const float *org, float rad); -extern edict_t *mm_FindClientInPVS(edict_t *pEdict); -extern edict_t *mm_EntitiesInPVS(edict_t *pplayer); - -extern void mm_MakeVectors(const float *rgflVector); -extern void mm_AngleVectors(const float *rgflVector, float *forward, float *right, float *up); - -extern edict_t *mm_CreateEntity(void); -extern void mm_RemoveEntity(edict_t *e); -extern edict_t *mm_CreateNamedEntity(int className); - -extern void mm_MakeStatic(edict_t *ent); -extern int mm_EntIsOnFloor(edict_t *e); -extern int mm_DropToFloor(edict_t *e); - -extern int mm_WalkMove(edict_t *ent, float yaw, float dist, int iMode); -extern void mm_SetOrigin(edict_t *e, const float *rgflOrigin); - -extern void mm_EmitSound(edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch); -extern void mm_EmitAmbientSound(edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch); - -extern void mm_TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); -extern void mm_TraceToss(edict_t *pent, edict_t *pentToIgnore, TraceResult *ptr); -extern int mm_TraceMonsterHull(edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); -extern void mm_TraceHull(const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr); -extern void mm_TraceModel(const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr); -extern const char *mm_TraceTexture(edict_t *pTextureEntity, const float *v1, const float *v2 ); -extern void mm_TraceSphere(const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr); -extern void mm_GetAimVector(edict_t *ent, float speed, float *rgflReturn); - -extern void mm_ServerCommand(char *str); -extern void mm_ServerExecute(void); -extern void ClientCommand(edict_t *pEdict, char *szFmt, ...); - -extern void mm_ParticleEffect(const float *org, const float *dir, float color, float count); -extern void mm_LightStyle(int style, char *val); -extern int mm_DecalIndex(const char *name); -extern int mm_PointContents(const float *rgflVector); - -extern void mm_MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); -extern void mm_MessageEnd(void); - -extern void mm_WriteByte(int iValue); -extern void mm_WriteChar(int iValue); -extern void mm_WriteShort(int iValue); -extern void mm_WriteLong(int iValue); -extern void mm_WriteAngle(float flValue); -extern void mm_WriteCoord(float flValue); -extern void mm_WriteString(const char *sz); -extern void mm_WriteEntity(int iValue); - -extern void mm_CVarRegister(cvar_t *pCvar); -extern float mm_CVarGetFloat(const char *szVarName); -extern const char* mm_CVarGetString(const char *szVarName); -extern void mm_CVarSetFloat(const char *szVarName, float flValue); -extern void mm_CVarSetString(const char *szVarName, const char *szValue); - -extern void mm_AlertMessage(ALERT_TYPE atype, char *szFmt, ...); -#ifdef HLSDK_3_2_OLD_EIFACE -extern void mm_EngineFprintf(FILE *pfile, char *szFmt, ...); -#else -extern void mm_EngineFprintf(void *pfile, char *szFmt, ...); -#endif - -#ifdef HLSDK_3_2_OLD_EIFACE -extern void *mm_PvAllocEntPrivateData(edict_t *pEdict, long cb); -#else -extern void *mm_PvAllocEntPrivateData(edict_t *pEdict, int32 cb); -#endif -extern void *mm_PvEntPrivateData(edict_t *pEdict); -extern void mm_FreeEntPrivateData(edict_t *pEdict); - -extern const char *mm_SzFromIndex(int iString); -extern int mm_AllocString(const char *szValue); - -extern struct entvars_s *mm_GetVarsOfEnt(edict_t *pEdict); -extern edict_t *mm_PEntityOfEntOffset(int iEntOffset); -extern int mm_EntOffsetOfPEntity(const edict_t *pEdict); -extern int mm_IndexOfEdict(const edict_t *pEdict); -extern edict_t *mm_PEntityOfEntIndex(int iEntIndex); -extern edict_t *mm_FindEntityByVars(struct entvars_s *pvars); -extern void *mm_GetModelPtr(edict_t *pEdict); - -extern int mm_RegUserMsg(const char *pszName, int iSize); - -extern void mm_AnimationAutomove(const edict_t *pEdict, float flTime); -extern void mm_GetBonePosition(const edict_t *pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); - -#ifdef HLSDK_3_2_OLD_EIFACE -extern unsigned long mm_FunctionFromName( const char *pName ); -extern const char *mm_NameForFunction( unsigned long function ); -#else -extern uint32 mm_FunctionFromName( const char *pName ); -extern const char *mm_NameForFunction( uint32 function ); -#endif - -extern void mm_ClientPrintf( edict_t *pEdict, PRINT_TYPE ptype, const char *szMsg ); //! JOHN: engine callbacks so game DLL can print messages to individual clients -extern void mm_ServerPrint( const char *szMsg ); - -extern const char *mm_Cmd_Args( void ); //! these 3 added -extern const char *mm_Cmd_Argv( int argc ); //! so game DLL can easily -extern int mm_Cmd_Argc( void ); //! access client 'cmd' strings - -extern void mm_GetAttachment(const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles ); - -extern void mm_CRC32_Init(CRC32_t *pulCRC); -extern void mm_CRC32_ProcessBuffer(CRC32_t *pulCRC, void *p, int len); -extern void mm_CRC32_ProcessByte(CRC32_t *pulCRC, unsigned char ch); -extern CRC32_t mm_CRC32_Final(CRC32_t pulCRC); - -#ifdef HLSDK_3_2_OLD_EIFACE -extern long mm_RandomLong(long lLow, long lHigh); -#else -extern int32 mm_RandomLong(int32 lLow, int32 lHigh); -#endif -extern float mm_RandomFloat(float flLow, float flHigh); - -extern void mm_SetView(const edict_t *pClient, const edict_t *pViewent ); -extern float mm_Time( void ); -extern void mm_CrosshairAngle(const edict_t *pClient, float pitch, float yaw); - -extern byte * mm_LoadFileForMe(char *filename, int *pLength); -extern void mm_FreeFile(void *buffer); - -extern void mm_EndSection(const char *pszSectionName); //! trigger_endsection -extern int mm_CompareFileTime(char *filename1, char *filename2, int *iCompare); -extern void mm_GetGameDir(char *szGetGameDir); -extern void mm_Cvar_RegisterVariable(cvar_t *variable); -extern void mm_FadeClientVolume(const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds); -extern void mm_SetClientMaxspeed(const edict_t *pEdict, float fNewMaxspeed); -extern edict_t * mm_CreateFakeClient(const char *netname); //! returns NULL if fake client can't be created -extern void mm_RunPlayerMove(edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); -extern int mm_NumberOfEntities(void); - -extern char *mm_GetInfoKeyBuffer(edict_t *e); //! passing in NULL gets the serverinfo -extern char *mm_InfoKeyValue(char *infobuffer, char *key); -extern void mm_SetKeyValue(char *infobuffer, char *key, char *value); -extern void mm_SetClientKeyValue(int clientIndex, char *infobuffer, char *key, char *value); - -extern int mm_IsMapValid(char *filename); -extern void mm_StaticDecal( const float *origin, int decalIndex, int entityIndex, int modelIndex ); -extern int mm_PrecacheGeneric(char *s); -extern int mm_GetPlayerUserId(edict_t *e ); //! returns the server assigned userid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients -extern void mm_BuildSoundMsg(edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); -extern int mm_IsDedicatedServer(void);//! is this a dedicated server? -extern cvar_t *mm_CVarGetPointer(const char *szVarName); -extern unsigned int mm_GetPlayerWONId(edict_t *e); //! returns the server assigned WONid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients - -//! YWB 8/1/99 TFF Physics additions -extern void mm_Info_RemoveKey( char *s, const char *key ); -extern const char *mm_GetPhysicsKeyValue( const edict_t *pClient, const char *key ); -extern void mm_SetPhysicsKeyValue( const edict_t *pClient, const char *key, const char *value ); -extern const char *mm_GetPhysicsInfoString( const edict_t *pClient ); -extern unsigned short mm_PrecacheEvent( int type, const char *psz ); -extern void mm_PlaybackEvent( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); - -extern unsigned char *mm_SetFatPVS( float *org ); -extern unsigned char *mm_SetFatPAS( float *org ); - -extern int mm_CheckVisibility( const edict_t *entity, unsigned char *pset ); - -extern void mm_DeltaSetField( struct delta_s *pFields, const char *fieldname ); -extern void mm_DeltaUnsetField( struct delta_s *pFields, const char *fieldname ); -extern void mm_DeltaAddEncoder( char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); -extern int mm_GetCurrentPlayer( void ); -extern int mm_CanSkipPlayer( const edict_t *player ); -extern int mm_DeltaFindField( struct delta_s *pFields, const char *fieldname ); -extern void mm_DeltaSetFieldByIndex( struct delta_s *pFields, int fieldNumber ); -extern void mm_DeltaUnsetFieldByIndex( struct delta_s *pFields, int fieldNumber ); - -extern void mm_SetGroupMask( int mask, int op ); - -extern int CreateInstancedBaseline( int classname, struct entity_state_s *baseline ); -extern void mm_Cvar_DirectSet( struct cvar_s *var, char *value ); - -//! Forces the client and server to be running with the same version of the specified file -//!( e.g., a player model ). -//! Calling this has no effect in single player -extern void mm_ForceUnmodified( FORCE_TYPE type, float *mins, float *maxs, const char *filename ); - -extern void mm_GetPlayerStats( const edict_t *pClient, int *ping, int *packet_loss ); - -extern void mm_AddServerCommand( char *cmd_name, void (*function) (void) ); -// Added in SDK 2.2: -extern qboolean mm_Voice_GetClientListening(int iReceiver, int iSender); -extern qboolean mm_Voice_SetClientListening(int iReceiver, int iSender, qboolean bListen); -// Added for HL 1109 (no SDK update): -extern const char *mm_pfnGetPlayerAuthId(edict_t *e); -// Added 2003-11-10 (no SDK update): -extern sequenceEntry_s * mm_SequenceGet(const char* fileName, const char* entryName); -extern sentenceEntry_s * mm_SequencePickSentence(const char* groupName, int pickMethod, int *picked); -extern int mm_GetFileSize(char *filename); -extern unsigned int mm_GetApproxWavePlayLen(const char *filepath); -extern int mm_IsCareerMatch(void); -extern int mm_GetLocalizedStringLength(const char *label); -extern void mm_RegisterTutorMessageShown(int mid); -extern int mm_GetTimesTutorMessageShown(int mid); -extern void mm_ProcessTutorMessageDecayBuffer(int *buffer, int bufferLength); -extern void mm_ConstructTutorMessageDecayBuffer(int *buffer, int bufferLength); -extern void mm_ResetTutorMessageDecayData(void); -//Added 2005-08-11 (no SDK update) -extern void mm_QueryClientCvarValue(const edict_t *pEdict, const char *cvarName); //! Obsolete! Use mm_QueryClientCvarValue2 instead -//Added 2005-11-22 (no SDK update) -extern void mm_QueryClientCvarValue2(const edict_t *pEdict, const char *cvarName, int requestID); - - -// Typedefs for the above functions: - -typedef int (*FN_PRECACHEMODEL) (char* s); -typedef int (*FN_PRECACHESOUND) (char* s); -typedef void (*FN_SETMODEL) (edict_t *e, const char *m); -typedef int (*FN_MODELINDEX) (const char *m); -typedef int (*FN_MODELFRAMES) (int modelIndex); -typedef void (*FN_SETSIZE) (edict_t *e, const float *rgflMin, const float *rgflMax); -typedef void (*FN_CHANGELEVEL) (char *s1, char *s2); -typedef void (*FN_GETSPAWNPARMS) (edict_t *ent); -typedef void (*FN_SAVESPAWNPARMS) (edict_t *ent); -typedef float (*FN_VECTOYAW) (const float *rgflVector); -typedef void (*FN_VECTOANGLES) (const float *rgflVectorIn, float *rgflVectorOut); -typedef void (*FN_MOVETOORIGIN) (edict_t *ent, const float *pflGoal, float dist, int iMoveType); -typedef void (*FN_CHANGEYAW) (edict_t *ent); -typedef void (*FN_CHANGEPITCH) (edict_t *ent); -typedef edict_t * (*FN_FINDENTITYBYSTRING) (edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue); -typedef int (*FN_GETENTITYILLUM) (edict_t *pEnt); -typedef edict_t * (*FN_FINDENTITYINSPHERE) (edict_t *pEdictStartSearchAfter, const float *org, float rad); -typedef edict_t * (*FN_FINDCLIENTINPVS) (edict_t *pEdict); -typedef edict_t * (*FN_ENTITIESINPVS) (edict_t *pplayer); -typedef void (*FN_MAKEVECTORS) (const float *rgflVector); -typedef void (*FN_ANGLEVECTORS) (const float *rgflVector, float *forward, float *right, float *up); -typedef edict_t * (*FN_CREATEENTITY) (void); -typedef void (*FN_REMOVEENTITY) (edict_t *e); -typedef edict_t * (*FN_CREATENAMEDENTITY) (int className); -typedef void (*FN_MAKESTATIC) (edict_t *ent); -typedef int (*FN_ENTISONFLOOR) (edict_t *e); -typedef int (*FN_DROPTOFLOOR) (edict_t *e); -typedef int (*FN_WALKMOVE) (edict_t *ent, float yaw, float dist, int iMode); -typedef void (*FN_SETORIGIN) (edict_t *e, const float *rgflOrigin); -typedef void (*FN_EMITSOUND) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch); -typedef void (*FN_EMITAMBIENTSOUND) (edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch); -typedef void (*FN_TRACELINE) (const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); -typedef void (*FN_TRACETOSS) (edict_t *pent, edict_t *pentToIgnore, TraceResult *ptr); -typedef int (*FN_TRACEMONSTERHULL) (edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); -typedef void (*FN_TRACEHULL) (const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr); -typedef void (*FN_TRACEMODEL) (const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr); -typedef const char * (*FN_TRACETEXTURE) (edict_t *pTextureEntity, const float *v1, const float *v2 ); -typedef void (*FN_TRACESPHERE) (const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr); -typedef void (*FN_GETAIMVECTOR) (edict_t *ent, float speed, float *rgflReturn); -typedef void (*FN_SERVERCOMMAND) (char *str); -typedef void (*FN_SERVEREXECUTE) (void); -typedef void (*FN_CLIENTCOMMAND_ENG) (edict_t *pEdict, char *szFmt, ...); -typedef void (*FN_PARTICLEEFFECT) (const float *org, const float *dir, float color, float count); -typedef void (*FN_LIGHTSTYLE) (int style, char *val); -typedef int (*FN_DECALINDEX) (const char *name); -typedef int (*FN_POINTCONTENTS) (const float *rgflVector); -typedef void (*FN_MESSAGEBEGIN) (int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); -typedef void (*FN_MESSAGEEND) (void); -typedef void (*FN_WRITEBYTE) (int iValue); -typedef void (*FN_WRITECHAR) (int iValue); -typedef void (*FN_WRITESHORT) (int iValue); -typedef void (*FN_WRITELONG) (int iValue); -typedef void (*FN_WRITEANGLE) (float flValue); -typedef void (*FN_WRITECOORD) (float flValue); -typedef void (*FN_WRITESTRING) (const char *sz); -typedef void (*FN_WRITEENTITY) (int iValue); -typedef void (*FN_CVARREGISTER) (cvar_t *pCvar); -typedef float (*FN_CVARGETFLOAT) (const char *szVarName); -typedef const char * (*FN_CVARGETSTRING) (const char *szVarName); -typedef void (*FN_CVARSETFLOAT) (const char *szVarName, float flValue); -typedef void (*FN_CVARSETSTRING) (const char *szVarName, const char *szValue); -typedef void (*FN_ALERTMESSAGE) (ALERT_TYPE atype, char *szFmt, ...); -#ifdef HLSDK_3_2_OLD_EIFACE -typedef void (*FN_ENGINEFPRINTF) (FILE *pfile, char *szFmt, ...); -typedef void * (*FN_PVALLOCENTPRIVATEDATA) (edict_t *pEdict, long cb); -#else -typedef void (*FN_ENGINEFPRINTF) (void *pfile, char *szFmt, ...); -typedef void * (*FN_PVALLOCENTPRIVATEDATA) (edict_t *pEdict, int32 cb); -#endif -typedef void * (*FN_PVENTPRIVATEDATA) (edict_t *pEdict); -typedef void (*FN_FREEENTPRIVATEDATA) (edict_t *pEdict); -typedef const char * (*FN_SZFROMINDEX) (int iString); -typedef int (*FN_ALLOCSTRING) (const char *szValue); -typedef struct entvars_s * (*FN_GETVARSOFENT) (edict_t *pEdict); -typedef edict_t * (*FN_PENTITYOFENTOFFSET) (int iEntOffset); -typedef int (*FN_ENTOFFSETOFPENTITY) (const edict_t *pEdict); -typedef int (*FN_INDEXOFEDICT) (const edict_t *pEdict); -typedef edict_t * (*FN_PENTITYOFENTINDEX) (int iEntIndex); -typedef edict_t * (*FN_FINDENTITYBYVARS) (struct entvars_s *pvars); -typedef void * (*FN_GETMODELPTR) (edict_t *pEdict); -typedef int (*FN_REGUSERMSG) (const char *pszName, int iSize); -typedef void (*FN_ANIMATIONAUTOMOVE) (const edict_t *pEdict, float flTime); -typedef void (*FN_GETBONEPOSITION) (const edict_t *pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); -#ifdef HLSDK_3_2_OLD_EIFACE -typedef unsigned long (*FN_FUNCTIONFROMNAME) ( const char *pName ); -typedef const char * (*FN_NAMEFORFUNCTION) ( unsigned long function ); -#else -typedef uint32 (*FN_FUNCTIONFROMNAME) ( const char *pName ); -typedef const char * (*FN_NAMEFORFUNCTION) ( uint32 function ); -#endif -typedef void (*FN_CLIENTPRINTF) ( edict_t *pEdict, PRINT_TYPE ptype, const char *szMsg ); -typedef void (*FN_SERVERPRINT) ( const char *szMsg ); -typedef const char * (*FN_CMD_ARGS) ( void ); -typedef const char * (*FN_CMD_ARGV) ( int argc ); -typedef int (*FN_CMD_ARGC) ( void ); -typedef void (*FN_GETATTACHMENT) (const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles ); -typedef void (*FN_CRC32_INIT) (CRC32_t *pulCRC); -typedef void (*FN_CRC32_PROCESSBUFFER) (CRC32_t *pulCRC, void *p, int len); -typedef void (*FN_CRC32_PROCESSBYTE) (CRC32_t *pulCRC, unsigned char ch); -typedef CRC32_t (*FN_CRC32_FINAL) (CRC32_t pulCRC); -#ifdef HLSDK_3_2_OLD_EIFACE -typedef long (*FN_RANDOMLONG) (long lLow, long lHigh); -#else -typedef int32 (*FN_RANDOMLONG) (int32 lLow, int32 lHigh); -#endif -typedef float (*FN_RANDOMFLOAT) (float flLow, float flHigh); -typedef void (*FN_SETVIEW) (const edict_t *pClient, const edict_t *pViewent ); -typedef float (*FN_TIME) ( void ); -typedef void (*FN_CROSSHAIRANGLE) (const edict_t *pClient, float pitch, float yaw); -typedef byte * (*FN_LOADFILEFORME) (char *filename, int *pLength); -typedef void (*FN_FREEFILE) (void *buffer); -typedef void (*FN_ENDSECTION) (const char *pszSectionName); -typedef int (*FN_COMPAREFILETIME) (char *filename1, char *filename2, int *iCompare); -typedef void (*FN_GETGAMEDIR) (char *szGetGameDir); -typedef void (*FN_CVAR_REGISTERVARIABLE) (cvar_t *variable); -typedef void (*FN_FADECLIENTVOLUME) (const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds); -typedef void (*FN_SETCLIENTMAXSPEED) (const edict_t *pEdict, float fNewMaxspeed); -typedef edict_t * (*FN_CREATEFAKECLIENT) (const char *netname); -typedef void (*FN_RUNPLAYERMOVE) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); -typedef int (*FN_NUMBEROFENTITIES) (void); -typedef char * (*FN_GETINFOKEYBUFFER) (edict_t *e); -typedef char * (*FN_INFOKEYVALUE) (char *infobuffer, char *key); -typedef void (*FN_SETKEYVALUE) (char *infobuffer, char *key, char *value); -typedef void (*FN_SETCLIENTKEYVALUE) (int clientIndex, char *infobuffer, char *key, char *value); -typedef int (*FN_ISMAPVALID) (char *filename); -typedef void (*FN_STATICDECAL) ( const float *origin, int decalIndex, int entityIndex, int modelIndex ); -typedef int (*FN_PRECACHEGENERIC) (char *s); -typedef int (*FN_GETPLAYERUSERID) (edict_t *e ); -typedef void (*FN_BUILDSOUNDMSG) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); -typedef int (*FN_ISDEDICATEDSERVER) (void); -typedef cvar_t * (*FN_CVARGETPOINTER) (const char *szVarName); -typedef unsigned int (*FN_GETPLAYERWONID) (edict_t *e); -typedef void (*FN_INFO_REMOVEKEY) ( char *s, const char *key ); -typedef const char * (*FN_GETPHYSICSKEYVALUE) ( const edict_t *pClient, const char *key ); -typedef void (*FN_SETPHYSICSKEYVALUE) ( const edict_t *pClient, const char *key, const char *value ); -typedef const char * (*FN_GETPHYSICSINFOSTRING) ( const edict_t *pClient ); -typedef unsigned short (*FN_PRECACHEEVENT) ( int type, const char *psz ); -typedef void (*FN_PLAYBACKEVENT) ( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); -typedef unsigned char * (*FN_SETFATPVS) ( float *org ); -typedef unsigned char * (*FN_SETFATPAS) ( float *org ); -typedef int (*FN_CHECKVISIBILITY) ( const edict_t *entity, unsigned char *pset ); -typedef void (*FN_DELTASETFIELD) ( struct delta_s *pFields, const char *fieldname ); -typedef void (*FN_DELTAUNSETFIELD) ( struct delta_s *pFields, const char *fieldname ); -typedef void (*FN_DELTAADDENCODER) ( char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); -typedef int (*FN_GETCURRENTPLAYER) ( void ); -typedef int (*FN_CANSKIPPLAYER) ( const edict_t *player ); -typedef int (*FN_DELTAFINDFIELD) ( struct delta_s *pFields, const char *fieldname ); -typedef void (*FN_DELTASETFIELDBYINDEX) ( struct delta_s *pFields, int fieldNumber ); -typedef void (*FN_DELTAUNSETFIELDBYINDEX) ( struct delta_s *pFields, int fieldNumber ); -typedef void (*FN_SETGROUPMASK) ( int mask, int op ); -typedef int (*FN_CREATEINSTANCEDBASELINE) ( int classname, struct entity_state_s *baseline ); -typedef void (*FN_CVAR_DIRECTSET) ( struct cvar_s *var, char *value ); -typedef void (*FN_FORCEUNMODIFIED) ( FORCE_TYPE type, float *mins, float *maxs, const char *filename ); -typedef void (*FN_GETPLAYERSTATS) ( const edict_t *pClient, int *ping, int *packet_loss ); -typedef void (*FN_ADDSERVERCOMMAND) ( char *cmd_name, void (*function) (void) ); -// Added in SDK 2.2: -typedef qboolean (*FN_VOICE_GETCLIENTLISTENING) (int iReceiver, int iSender); -typedef qboolean (*FN_VOICE_SETCLIENTLISTENING) (int iReceiver, int iSender, qboolean bListen); -// Added for HL 1109 (no SDK update): -typedef const char * (*FN_GETPLAYERAUTHID) (edict_t *e); -// Added 2003-11-10 (no SDK update): -typedef sequenceEntry_s * (*FN_SEQUENCEGET) (const char* fileName, const char* entryName); -typedef sentenceEntry_s * (*FN_SEQUENCEPICKSENTENCE) (const char* groupName, int pickMethod, int *picked); -typedef int (*FN_GETFILESIZE) (char *filename); -typedef unsigned int (*FN_GETAPPROXWAVEPLAYLEN) (const char *filepath); -typedef int (*FN_ISCAREERMATCH) (void); -typedef int (*FN_GETLOCALIZEDSTRINGLENGTH) (const char *label); -typedef void (*FN_REGISTERTUTORMESSAGESHOWN) (int mid); -typedef int (*FN_GETTIMESTUTORMESSAGESHOWN) (int mid); -typedef void (*FN_PROCESSTUTORMESSAGEDECAYBUFFER) (int *buffer, int bufferLength); -typedef void (*FN_CONSTRUCTTUTORMESSAGEDECAYBUFFER) (int *buffer, int bufferLength); -typedef void (*FN_RESETTUTORMESSAGEDECAYDATA) (void); -//Added 2005-08-11 (no SDK update) -typedef void (*FN_QUERYCLIENTCVARVALUE)(const edict_t *pEdict, const char *cvarName); //! Obsolete! Use FN_QUERYCLIENTCVARVALUE2 instead -//Added 2005-11-22 (no SDK update) -typedef void (*FN_QUERYCLIENTCVARVALUE2)(const edict_t *pEdict, const char *cvarName, int requestID); - +// engine_api.h - prototypes and typedefs for Half-Life engine functions + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef ENGINE_API_H +#define ENGINE_API_H + +#include + +// Plugin's GetEngineFunctions, called by metamod. +typedef int (*GET_ENGINE_FUNCTIONS_FN) (enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion); + +// According to SDK engine/eiface.h: +//! enginefuncs_t +//! ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 138 +#define ENGINE_INTERFACE_VERSION 138 + +// Protect against other projects which use this include file but use the +// normal enginefuncs_t type for their meta_engfuncs. +#ifdef METAMOD_CORE +# include "meta_eiface.h" // meta_enginefuncs_t +extern meta_enginefuncs_t meta_engfuncs; +#else +extern enginefuncs_t meta_engfuncs; +#endif + +// From SDK engine/eiface.h: +extern int mm_PrecacheModel(char *s); +extern int mm_PrecacheSound(char *s); +extern void mm_SetModel(edict_t *e, const char *m); +extern int mm_ModelIndex(const char *m); +extern int mm_ModelFrames(int modelIndex); + +extern void mm_SetSize(edict_t *e, const float *rgflMin, const float *rgflMax); +extern void mm_ChangeLevel(char *s1, char *s2); +extern void mm_GetSpawnParms(edict_t *ent); +extern void mm_SaveSpawnParms(edict_t *ent); + +extern float mm_VecToYaw(const float *rgflVector); +extern void mm_VecToAngles(const float *rgflVectorIn, float *rgflVectorOut); +extern void mm_MoveToOrigin(edict_t *ent, const float *pflGoal, float dist, int iMoveType); +extern void mm_ChangeYaw(edict_t *ent); +extern void mm_ChangePitch(edict_t *ent); + +extern edict_t *mm_FindEntityByString(edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue); +extern int mm_GetEntityIllum(edict_t *pEnt); +extern edict_t *mm_FindEntityInSphere(edict_t *pEdictStartSearchAfter, const float *org, float rad); +extern edict_t *mm_FindClientInPVS(edict_t *pEdict); +extern edict_t *mm_EntitiesInPVS(edict_t *pplayer); + +extern void mm_MakeVectors(const float *rgflVector); +extern void mm_AngleVectors(const float *rgflVector, float *forward, float *right, float *up); + +extern edict_t *mm_CreateEntity(void); +extern void mm_RemoveEntity(edict_t *e); +extern edict_t *mm_CreateNamedEntity(int className); + +extern void mm_MakeStatic(edict_t *ent); +extern int mm_EntIsOnFloor(edict_t *e); +extern int mm_DropToFloor(edict_t *e); + +extern int mm_WalkMove(edict_t *ent, float yaw, float dist, int iMode); +extern void mm_SetOrigin(edict_t *e, const float *rgflOrigin); + +extern void mm_EmitSound(edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch); +extern void mm_EmitAmbientSound(edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch); + +extern void mm_TraceLine(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); +extern void mm_TraceToss(edict_t *pent, edict_t *pentToIgnore, TraceResult *ptr); +extern int mm_TraceMonsterHull(edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); +extern void mm_TraceHull(const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr); +extern void mm_TraceModel(const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr); +extern const char *mm_TraceTexture(edict_t *pTextureEntity, const float *v1, const float *v2 ); +extern void mm_TraceSphere(const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr); +extern void mm_GetAimVector(edict_t *ent, float speed, float *rgflReturn); + +extern void mm_ServerCommand(char *str); +extern void mm_ServerExecute(void); +extern void ClientCommand(edict_t *pEdict, char *szFmt, ...); + +extern void mm_ParticleEffect(const float *org, const float *dir, float color, float count); +extern void mm_LightStyle(int style, char *val); +extern int mm_DecalIndex(const char *name); +extern int mm_PointContents(const float *rgflVector); + +extern void mm_MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); +extern void mm_MessageEnd(void); + +extern void mm_WriteByte(int iValue); +extern void mm_WriteChar(int iValue); +extern void mm_WriteShort(int iValue); +extern void mm_WriteLong(int iValue); +extern void mm_WriteAngle(float flValue); +extern void mm_WriteCoord(float flValue); +extern void mm_WriteString(const char *sz); +extern void mm_WriteEntity(int iValue); + +extern void mm_CVarRegister(cvar_t *pCvar); +extern float mm_CVarGetFloat(const char *szVarName); +extern const char* mm_CVarGetString(const char *szVarName); +extern void mm_CVarSetFloat(const char *szVarName, float flValue); +extern void mm_CVarSetString(const char *szVarName, const char *szValue); + +extern void mm_AlertMessage(ALERT_TYPE atype, char *szFmt, ...); +#ifdef HLSDK_3_2_OLD_EIFACE +extern void mm_EngineFprintf(FILE *pfile, char *szFmt, ...); +#else +extern void mm_EngineFprintf(void *pfile, char *szFmt, ...); +#endif + +#ifdef HLSDK_3_2_OLD_EIFACE +extern void *mm_PvAllocEntPrivateData(edict_t *pEdict, long cb); +#else +extern void *mm_PvAllocEntPrivateData(edict_t *pEdict, int32 cb); +#endif +extern void *mm_PvEntPrivateData(edict_t *pEdict); +extern void mm_FreeEntPrivateData(edict_t *pEdict); + +extern const char *mm_SzFromIndex(int iString); +extern int mm_AllocString(const char *szValue); + +extern struct entvars_s *mm_GetVarsOfEnt(edict_t *pEdict); +extern edict_t *mm_PEntityOfEntOffset(int iEntOffset); +extern int mm_EntOffsetOfPEntity(const edict_t *pEdict); +extern int mm_IndexOfEdict(const edict_t *pEdict); +extern edict_t *mm_PEntityOfEntIndex(int iEntIndex); +extern edict_t *mm_FindEntityByVars(struct entvars_s *pvars); +extern void *mm_GetModelPtr(edict_t *pEdict); + +extern int mm_RegUserMsg(const char *pszName, int iSize); + +extern void mm_AnimationAutomove(const edict_t *pEdict, float flTime); +extern void mm_GetBonePosition(const edict_t *pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); + +#ifdef HLSDK_3_2_OLD_EIFACE +extern unsigned long mm_FunctionFromName( const char *pName ); +extern const char *mm_NameForFunction( unsigned long function ); +#else +extern uint32 mm_FunctionFromName( const char *pName ); +extern const char *mm_NameForFunction( uint32 function ); +#endif + +extern void mm_ClientPrintf( edict_t *pEdict, PRINT_TYPE ptype, const char *szMsg ); //! JOHN: engine callbacks so game DLL can print messages to individual clients +extern void mm_ServerPrint( const char *szMsg ); + +extern const char *mm_Cmd_Args( void ); //! these 3 added +extern const char *mm_Cmd_Argv( int argc ); //! so game DLL can easily +extern int mm_Cmd_Argc( void ); //! access client 'cmd' strings + +extern void mm_GetAttachment(const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles ); + +extern void mm_CRC32_Init(CRC32_t *pulCRC); +extern void mm_CRC32_ProcessBuffer(CRC32_t *pulCRC, void *p, int len); +extern void mm_CRC32_ProcessByte(CRC32_t *pulCRC, unsigned char ch); +extern CRC32_t mm_CRC32_Final(CRC32_t pulCRC); + +#ifdef HLSDK_3_2_OLD_EIFACE +extern long mm_RandomLong(long lLow, long lHigh); +#else +extern int32 mm_RandomLong(int32 lLow, int32 lHigh); +#endif +extern float mm_RandomFloat(float flLow, float flHigh); + +extern void mm_SetView(const edict_t *pClient, const edict_t *pViewent ); +extern float mm_Time( void ); +extern void mm_CrosshairAngle(const edict_t *pClient, float pitch, float yaw); + +extern byte * mm_LoadFileForMe(char *filename, int *pLength); +extern void mm_FreeFile(void *buffer); + +extern void mm_EndSection(const char *pszSectionName); //! trigger_endsection +extern int mm_CompareFileTime(char *filename1, char *filename2, int *iCompare); +extern void mm_GetGameDir(char *szGetGameDir); +extern void mm_Cvar_RegisterVariable(cvar_t *variable); +extern void mm_FadeClientVolume(const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds); +extern void mm_SetClientMaxspeed(const edict_t *pEdict, float fNewMaxspeed); +extern edict_t * mm_CreateFakeClient(const char *netname); //! returns NULL if fake client can't be created +extern void mm_RunPlayerMove(edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); +extern int mm_NumberOfEntities(void); + +extern char *mm_GetInfoKeyBuffer(edict_t *e); //! passing in NULL gets the serverinfo +extern char *mm_InfoKeyValue(char *infobuffer, char *key); +extern void mm_SetKeyValue(char *infobuffer, char *key, char *value); +extern void mm_SetClientKeyValue(int clientIndex, char *infobuffer, char *key, char *value); + +extern int mm_IsMapValid(char *filename); +extern void mm_StaticDecal( const float *origin, int decalIndex, int entityIndex, int modelIndex ); +extern int mm_PrecacheGeneric(char *s); +extern int mm_GetPlayerUserId(edict_t *e ); //! returns the server assigned userid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients +extern void mm_BuildSoundMsg(edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); +extern int mm_IsDedicatedServer(void);//! is this a dedicated server? +extern cvar_t *mm_CVarGetPointer(const char *szVarName); +extern unsigned int mm_GetPlayerWONId(edict_t *e); //! returns the server assigned WONid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients + +//! YWB 8/1/99 TFF Physics additions +extern void mm_Info_RemoveKey( char *s, const char *key ); +extern const char *mm_GetPhysicsKeyValue( const edict_t *pClient, const char *key ); +extern void mm_SetPhysicsKeyValue( const edict_t *pClient, const char *key, const char *value ); +extern const char *mm_GetPhysicsInfoString( const edict_t *pClient ); +extern unsigned short mm_PrecacheEvent( int type, const char *psz ); +extern void mm_PlaybackEvent( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); + +extern unsigned char *mm_SetFatPVS( float *org ); +extern unsigned char *mm_SetFatPAS( float *org ); + +extern int mm_CheckVisibility( const edict_t *entity, unsigned char *pset ); + +extern void mm_DeltaSetField( struct delta_s *pFields, const char *fieldname ); +extern void mm_DeltaUnsetField( struct delta_s *pFields, const char *fieldname ); +extern void mm_DeltaAddEncoder( char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); +extern int mm_GetCurrentPlayer( void ); +extern int mm_CanSkipPlayer( const edict_t *player ); +extern int mm_DeltaFindField( struct delta_s *pFields, const char *fieldname ); +extern void mm_DeltaSetFieldByIndex( struct delta_s *pFields, int fieldNumber ); +extern void mm_DeltaUnsetFieldByIndex( struct delta_s *pFields, int fieldNumber ); + +extern void mm_SetGroupMask( int mask, int op ); + +extern int CreateInstancedBaseline( int classname, struct entity_state_s *baseline ); +extern void mm_Cvar_DirectSet( struct cvar_s *var, char *value ); + +//! Forces the client and server to be running with the same version of the specified file +//!( e.g., a player model ). +//! Calling this has no effect in single player +extern void mm_ForceUnmodified( FORCE_TYPE type, float *mins, float *maxs, const char *filename ); + +extern void mm_GetPlayerStats( const edict_t *pClient, int *ping, int *packet_loss ); + +extern void mm_AddServerCommand( char *cmd_name, void (*function) (void) ); +// Added in SDK 2.2: +extern qboolean mm_Voice_GetClientListening(int iReceiver, int iSender); +extern qboolean mm_Voice_SetClientListening(int iReceiver, int iSender, qboolean bListen); +// Added for HL 1109 (no SDK update): +extern const char *mm_pfnGetPlayerAuthId(edict_t *e); +// Added 2003-11-10 (no SDK update): +extern sequenceEntry_s * mm_SequenceGet(const char* fileName, const char* entryName); +extern sentenceEntry_s * mm_SequencePickSentence(const char* groupName, int pickMethod, int *picked); +extern int mm_GetFileSize(char *filename); +extern unsigned int mm_GetApproxWavePlayLen(const char *filepath); +extern int mm_IsCareerMatch(void); +extern int mm_GetLocalizedStringLength(const char *label); +extern void mm_RegisterTutorMessageShown(int mid); +extern int mm_GetTimesTutorMessageShown(int mid); +extern void mm_ProcessTutorMessageDecayBuffer(int *buffer, int bufferLength); +extern void mm_ConstructTutorMessageDecayBuffer(int *buffer, int bufferLength); +extern void mm_ResetTutorMessageDecayData(void); +//Added 2005-08-11 (no SDK update) +extern void mm_QueryClientCvarValue(const edict_t *pEdict, const char *cvarName); //! Obsolete! Use mm_QueryClientCvarValue2 instead +//Added 2005-11-22 (no SDK update) +extern void mm_QueryClientCvarValue2(const edict_t *pEdict, const char *cvarName, int requestID); + + +// Typedefs for the above functions: + +typedef int (*FN_PRECACHEMODEL) (char* s); +typedef int (*FN_PRECACHESOUND) (char* s); +typedef void (*FN_SETMODEL) (edict_t *e, const char *m); +typedef int (*FN_MODELINDEX) (const char *m); +typedef int (*FN_MODELFRAMES) (int modelIndex); +typedef void (*FN_SETSIZE) (edict_t *e, const float *rgflMin, const float *rgflMax); +typedef void (*FN_CHANGELEVEL) (char *s1, char *s2); +typedef void (*FN_GETSPAWNPARMS) (edict_t *ent); +typedef void (*FN_SAVESPAWNPARMS) (edict_t *ent); +typedef float (*FN_VECTOYAW) (const float *rgflVector); +typedef void (*FN_VECTOANGLES) (const float *rgflVectorIn, float *rgflVectorOut); +typedef void (*FN_MOVETOORIGIN) (edict_t *ent, const float *pflGoal, float dist, int iMoveType); +typedef void (*FN_CHANGEYAW) (edict_t *ent); +typedef void (*FN_CHANGEPITCH) (edict_t *ent); +typedef edict_t * (*FN_FINDENTITYBYSTRING) (edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue); +typedef int (*FN_GETENTITYILLUM) (edict_t *pEnt); +typedef edict_t * (*FN_FINDENTITYINSPHERE) (edict_t *pEdictStartSearchAfter, const float *org, float rad); +typedef edict_t * (*FN_FINDCLIENTINPVS) (edict_t *pEdict); +typedef edict_t * (*FN_ENTITIESINPVS) (edict_t *pplayer); +typedef void (*FN_MAKEVECTORS) (const float *rgflVector); +typedef void (*FN_ANGLEVECTORS) (const float *rgflVector, float *forward, float *right, float *up); +typedef edict_t * (*FN_CREATEENTITY) (void); +typedef void (*FN_REMOVEENTITY) (edict_t *e); +typedef edict_t * (*FN_CREATENAMEDENTITY) (int className); +typedef void (*FN_MAKESTATIC) (edict_t *ent); +typedef int (*FN_ENTISONFLOOR) (edict_t *e); +typedef int (*FN_DROPTOFLOOR) (edict_t *e); +typedef int (*FN_WALKMOVE) (edict_t *ent, float yaw, float dist, int iMode); +typedef void (*FN_SETORIGIN) (edict_t *e, const float *rgflOrigin); +typedef void (*FN_EMITSOUND) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch); +typedef void (*FN_EMITAMBIENTSOUND) (edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch); +typedef void (*FN_TRACELINE) (const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); +typedef void (*FN_TRACETOSS) (edict_t *pent, edict_t *pentToIgnore, TraceResult *ptr); +typedef int (*FN_TRACEMONSTERHULL) (edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); +typedef void (*FN_TRACEHULL) (const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr); +typedef void (*FN_TRACEMODEL) (const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr); +typedef const char * (*FN_TRACETEXTURE) (edict_t *pTextureEntity, const float *v1, const float *v2 ); +typedef void (*FN_TRACESPHERE) (const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr); +typedef void (*FN_GETAIMVECTOR) (edict_t *ent, float speed, float *rgflReturn); +typedef void (*FN_SERVERCOMMAND) (char *str); +typedef void (*FN_SERVEREXECUTE) (void); +typedef void (*FN_CLIENTCOMMAND_ENG) (edict_t *pEdict, char *szFmt, ...); +typedef void (*FN_PARTICLEEFFECT) (const float *org, const float *dir, float color, float count); +typedef void (*FN_LIGHTSTYLE) (int style, char *val); +typedef int (*FN_DECALINDEX) (const char *name); +typedef int (*FN_POINTCONTENTS) (const float *rgflVector); +typedef void (*FN_MESSAGEBEGIN) (int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); +typedef void (*FN_MESSAGEEND) (void); +typedef void (*FN_WRITEBYTE) (int iValue); +typedef void (*FN_WRITECHAR) (int iValue); +typedef void (*FN_WRITESHORT) (int iValue); +typedef void (*FN_WRITELONG) (int iValue); +typedef void (*FN_WRITEANGLE) (float flValue); +typedef void (*FN_WRITECOORD) (float flValue); +typedef void (*FN_WRITESTRING) (const char *sz); +typedef void (*FN_WRITEENTITY) (int iValue); +typedef void (*FN_CVARREGISTER) (cvar_t *pCvar); +typedef float (*FN_CVARGETFLOAT) (const char *szVarName); +typedef const char * (*FN_CVARGETSTRING) (const char *szVarName); +typedef void (*FN_CVARSETFLOAT) (const char *szVarName, float flValue); +typedef void (*FN_CVARSETSTRING) (const char *szVarName, const char *szValue); +typedef void (*FN_ALERTMESSAGE) (ALERT_TYPE atype, char *szFmt, ...); +#ifdef HLSDK_3_2_OLD_EIFACE +typedef void (*FN_ENGINEFPRINTF) (FILE *pfile, char *szFmt, ...); +typedef void * (*FN_PVALLOCENTPRIVATEDATA) (edict_t *pEdict, long cb); +#else +typedef void (*FN_ENGINEFPRINTF) (void *pfile, char *szFmt, ...); +typedef void * (*FN_PVALLOCENTPRIVATEDATA) (edict_t *pEdict, int32 cb); +#endif +typedef void * (*FN_PVENTPRIVATEDATA) (edict_t *pEdict); +typedef void (*FN_FREEENTPRIVATEDATA) (edict_t *pEdict); +typedef const char * (*FN_SZFROMINDEX) (int iString); +typedef int (*FN_ALLOCSTRING) (const char *szValue); +typedef struct entvars_s * (*FN_GETVARSOFENT) (edict_t *pEdict); +typedef edict_t * (*FN_PENTITYOFENTOFFSET) (int iEntOffset); +typedef int (*FN_ENTOFFSETOFPENTITY) (const edict_t *pEdict); +typedef int (*FN_INDEXOFEDICT) (const edict_t *pEdict); +typedef edict_t * (*FN_PENTITYOFENTINDEX) (int iEntIndex); +typedef edict_t * (*FN_FINDENTITYBYVARS) (struct entvars_s *pvars); +typedef void * (*FN_GETMODELPTR) (edict_t *pEdict); +typedef int (*FN_REGUSERMSG) (const char *pszName, int iSize); +typedef void (*FN_ANIMATIONAUTOMOVE) (const edict_t *pEdict, float flTime); +typedef void (*FN_GETBONEPOSITION) (const edict_t *pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); +#ifdef HLSDK_3_2_OLD_EIFACE +typedef unsigned long (*FN_FUNCTIONFROMNAME) ( const char *pName ); +typedef const char * (*FN_NAMEFORFUNCTION) ( unsigned long function ); +#else +typedef uint32 (*FN_FUNCTIONFROMNAME) ( const char *pName ); +typedef const char * (*FN_NAMEFORFUNCTION) ( uint32 function ); +#endif +typedef void (*FN_CLIENTPRINTF) ( edict_t *pEdict, PRINT_TYPE ptype, const char *szMsg ); +typedef void (*FN_SERVERPRINT) ( const char *szMsg ); +typedef const char * (*FN_CMD_ARGS) ( void ); +typedef const char * (*FN_CMD_ARGV) ( int argc ); +typedef int (*FN_CMD_ARGC) ( void ); +typedef void (*FN_GETATTACHMENT) (const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles ); +typedef void (*FN_CRC32_INIT) (CRC32_t *pulCRC); +typedef void (*FN_CRC32_PROCESSBUFFER) (CRC32_t *pulCRC, void *p, int len); +typedef void (*FN_CRC32_PROCESSBYTE) (CRC32_t *pulCRC, unsigned char ch); +typedef CRC32_t (*FN_CRC32_FINAL) (CRC32_t pulCRC); +#ifdef HLSDK_3_2_OLD_EIFACE +typedef long (*FN_RANDOMLONG) (long lLow, long lHigh); +#else +typedef int32 (*FN_RANDOMLONG) (int32 lLow, int32 lHigh); +#endif +typedef float (*FN_RANDOMFLOAT) (float flLow, float flHigh); +typedef void (*FN_SETVIEW) (const edict_t *pClient, const edict_t *pViewent ); +typedef float (*FN_TIME) ( void ); +typedef void (*FN_CROSSHAIRANGLE) (const edict_t *pClient, float pitch, float yaw); +typedef byte * (*FN_LOADFILEFORME) (char *filename, int *pLength); +typedef void (*FN_FREEFILE) (void *buffer); +typedef void (*FN_ENDSECTION) (const char *pszSectionName); +typedef int (*FN_COMPAREFILETIME) (char *filename1, char *filename2, int *iCompare); +typedef void (*FN_GETGAMEDIR) (char *szGetGameDir); +typedef void (*FN_CVAR_REGISTERVARIABLE) (cvar_t *variable); +typedef void (*FN_FADECLIENTVOLUME) (const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds); +typedef void (*FN_SETCLIENTMAXSPEED) (const edict_t *pEdict, float fNewMaxspeed); +typedef edict_t * (*FN_CREATEFAKECLIENT) (const char *netname); +typedef void (*FN_RUNPLAYERMOVE) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); +typedef int (*FN_NUMBEROFENTITIES) (void); +typedef char * (*FN_GETINFOKEYBUFFER) (edict_t *e); +typedef char * (*FN_INFOKEYVALUE) (char *infobuffer, char *key); +typedef void (*FN_SETKEYVALUE) (char *infobuffer, char *key, char *value); +typedef void (*FN_SETCLIENTKEYVALUE) (int clientIndex, char *infobuffer, char *key, char *value); +typedef int (*FN_ISMAPVALID) (char *filename); +typedef void (*FN_STATICDECAL) ( const float *origin, int decalIndex, int entityIndex, int modelIndex ); +typedef int (*FN_PRECACHEGENERIC) (char *s); +typedef int (*FN_GETPLAYERUSERID) (edict_t *e ); +typedef void (*FN_BUILDSOUNDMSG) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); +typedef int (*FN_ISDEDICATEDSERVER) (void); +typedef cvar_t * (*FN_CVARGETPOINTER) (const char *szVarName); +typedef unsigned int (*FN_GETPLAYERWONID) (edict_t *e); +typedef void (*FN_INFO_REMOVEKEY) ( char *s, const char *key ); +typedef const char * (*FN_GETPHYSICSKEYVALUE) ( const edict_t *pClient, const char *key ); +typedef void (*FN_SETPHYSICSKEYVALUE) ( const edict_t *pClient, const char *key, const char *value ); +typedef const char * (*FN_GETPHYSICSINFOSTRING) ( const edict_t *pClient ); +typedef unsigned short (*FN_PRECACHEEVENT) ( int type, const char *psz ); +typedef void (*FN_PLAYBACKEVENT) ( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); +typedef unsigned char * (*FN_SETFATPVS) ( float *org ); +typedef unsigned char * (*FN_SETFATPAS) ( float *org ); +typedef int (*FN_CHECKVISIBILITY) ( const edict_t *entity, unsigned char *pset ); +typedef void (*FN_DELTASETFIELD) ( struct delta_s *pFields, const char *fieldname ); +typedef void (*FN_DELTAUNSETFIELD) ( struct delta_s *pFields, const char *fieldname ); +typedef void (*FN_DELTAADDENCODER) ( char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); +typedef int (*FN_GETCURRENTPLAYER) ( void ); +typedef int (*FN_CANSKIPPLAYER) ( const edict_t *player ); +typedef int (*FN_DELTAFINDFIELD) ( struct delta_s *pFields, const char *fieldname ); +typedef void (*FN_DELTASETFIELDBYINDEX) ( struct delta_s *pFields, int fieldNumber ); +typedef void (*FN_DELTAUNSETFIELDBYINDEX) ( struct delta_s *pFields, int fieldNumber ); +typedef void (*FN_SETGROUPMASK) ( int mask, int op ); +typedef int (*FN_CREATEINSTANCEDBASELINE) ( int classname, struct entity_state_s *baseline ); +typedef void (*FN_CVAR_DIRECTSET) ( struct cvar_s *var, char *value ); +typedef void (*FN_FORCEUNMODIFIED) ( FORCE_TYPE type, float *mins, float *maxs, const char *filename ); +typedef void (*FN_GETPLAYERSTATS) ( const edict_t *pClient, int *ping, int *packet_loss ); +typedef void (*FN_ADDSERVERCOMMAND) ( char *cmd_name, void (*function) (void) ); +// Added in SDK 2.2: +typedef qboolean (*FN_VOICE_GETCLIENTLISTENING) (int iReceiver, int iSender); +typedef qboolean (*FN_VOICE_SETCLIENTLISTENING) (int iReceiver, int iSender, qboolean bListen); +// Added for HL 1109 (no SDK update): +typedef const char * (*FN_GETPLAYERAUTHID) (edict_t *e); +// Added 2003-11-10 (no SDK update): +typedef sequenceEntry_s * (*FN_SEQUENCEGET) (const char* fileName, const char* entryName); +typedef sentenceEntry_s * (*FN_SEQUENCEPICKSENTENCE) (const char* groupName, int pickMethod, int *picked); +typedef int (*FN_GETFILESIZE) (char *filename); +typedef unsigned int (*FN_GETAPPROXWAVEPLAYLEN) (const char *filepath); +typedef int (*FN_ISCAREERMATCH) (void); +typedef int (*FN_GETLOCALIZEDSTRINGLENGTH) (const char *label); +typedef void (*FN_REGISTERTUTORMESSAGESHOWN) (int mid); +typedef int (*FN_GETTIMESTUTORMESSAGESHOWN) (int mid); +typedef void (*FN_PROCESSTUTORMESSAGEDECAYBUFFER) (int *buffer, int bufferLength); +typedef void (*FN_CONSTRUCTTUTORMESSAGEDECAYBUFFER) (int *buffer, int bufferLength); +typedef void (*FN_RESETTUTORMESSAGEDECAYDATA) (void); +//Added 2005-08-11 (no SDK update) +typedef void (*FN_QUERYCLIENTCVARVALUE)(const edict_t *pEdict, const char *cvarName); //! Obsolete! Use FN_QUERYCLIENTCVARVALUE2 instead +//Added 2005-11-22 (no SDK update) +typedef void (*FN_QUERYCLIENTCVARVALUE2)(const edict_t *pEdict, const char *cvarName, int requestID); + #endif /* ENGINE_API_H */ \ No newline at end of file diff --git a/revoice/include/enginecallbacks.h b/revoice/include/enginecallbacks.h index 876d086..7045fbb 100644 --- a/revoice/include/enginecallbacks.h +++ b/revoice/include/enginecallbacks.h @@ -1,74 +1,74 @@ -// enginecallbacks.h - wrapper for - -/* - * Copyright (c) 2001-2006 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef MM_ENGINECALLBACKS_H -#define MM_ENGINECALLBACKS_H - -// This file is a wrapper around the SDK's enginecallback.h file. We need -// this because we use a different type for the global object g_engfuncs, -// which is still compatible with the enginefuncs_t that the SDK -// uses. -// This is only done for files that belong to Metamod, not other projects -// like plugins that use this file, or others that include it, too. -// Since we don't have a clean seperation of include files right now we -// "hack" our way around that by using a flag METAMOD_CORE which is set -// when compiling Metamod proper. - -#ifdef METAMOD_CORE -# include "meta_eiface.h" // HL_enginefuncs_t - -// Use a #define to bend the enginefuncs_t type to our HL_enginefuncs_t -// type instead as we now use that for the global object g_engfuncs. -# define enginefuncs_t HL_enginefuncs_t -#endif /* METAMOD_CORE */ - -#include // ALERT, etc - -#ifdef METAMOD_CORE -# undef enginefuncs_t -#endif /* METAMOD_CORE */ - -// Also, create some additional macros for engine callback functions, which -// weren't in SDK dlls/enginecallbacks.h but probably should have been. - -#define GET_INFOKEYBUFFER (*g_engfuncs.pfnGetInfoKeyBuffer) -#define INFOKEY_VALUE (*g_engfuncs.pfnInfoKeyValue) -#define SET_CLIENT_KEYVALUE (*g_engfuncs.pfnSetClientKeyValue) -#define REG_SVR_COMMAND (*g_engfuncs.pfnAddServerCommand) -#define SERVER_PRINT (*g_engfuncs.pfnServerPrint) -#define SET_SERVER_KEYVALUE (*g_engfuncs.pfnSetKeyValue) -#define QUERY_CLIENT_CVAR_VALUE (*g_engfuncs.pfnQueryClientCvarValue) -#define QUERY_CLIENT_CVAR_VALUE2 (*g_engfuncs.pfnQueryClientCvarValue2) - - -#endif /* MM_ENGINECALLBACKS_H */ +// enginecallbacks.h - wrapper for + +/* + * Copyright (c) 2001-2006 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef MM_ENGINECALLBACKS_H +#define MM_ENGINECALLBACKS_H + +// This file is a wrapper around the SDK's enginecallback.h file. We need +// this because we use a different type for the global object g_engfuncs, +// which is still compatible with the enginefuncs_t that the SDK +// uses. +// This is only done for files that belong to Metamod, not other projects +// like plugins that use this file, or others that include it, too. +// Since we don't have a clean seperation of include files right now we +// "hack" our way around that by using a flag METAMOD_CORE which is set +// when compiling Metamod proper. + +#ifdef METAMOD_CORE +# include "meta_eiface.h" // HL_enginefuncs_t + +// Use a #define to bend the enginefuncs_t type to our HL_enginefuncs_t +// type instead as we now use that for the global object g_engfuncs. +# define enginefuncs_t HL_enginefuncs_t +#endif /* METAMOD_CORE */ + +#include // ALERT, etc + +#ifdef METAMOD_CORE +# undef enginefuncs_t +#endif /* METAMOD_CORE */ + +// Also, create some additional macros for engine callback functions, which +// weren't in SDK dlls/enginecallbacks.h but probably should have been. + +#define GET_INFOKEYBUFFER (*g_engfuncs.pfnGetInfoKeyBuffer) +#define INFOKEY_VALUE (*g_engfuncs.pfnInfoKeyValue) +#define SET_CLIENT_KEYVALUE (*g_engfuncs.pfnSetClientKeyValue) +#define REG_SVR_COMMAND (*g_engfuncs.pfnAddServerCommand) +#define SERVER_PRINT (*g_engfuncs.pfnServerPrint) +#define SET_SERVER_KEYVALUE (*g_engfuncs.pfnSetKeyValue) +#define QUERY_CLIENT_CVAR_VALUE (*g_engfuncs.pfnQueryClientCvarValue) +#define QUERY_CLIENT_CVAR_VALUE2 (*g_engfuncs.pfnQueryClientCvarValue2) + + +#endif /* MM_ENGINECALLBACKS_H */ diff --git a/revoice/include/h_export.h b/revoice/include/h_export.h index a5a603d..878acd1 100644 --- a/revoice/include/h_export.h +++ b/revoice/include/h_export.h @@ -1,46 +1,46 @@ -// h_export.h - prototypes for h_export.cpp - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef H_EXPORT_H -#define H_EXPORT_H - -#include "osdep.h" // DLLEXPORT, WINAPI, etc - -// Our GiveFnptrsToDll, called by engine. -typedef void (WINAPI *GIVE_ENGINE_FUNCTIONS_FN) (enginefuncs_t - *pengfuncsFromEngine, globalvars_t *pGlobals); - -C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t *pengfuncsFromEngine, - globalvars_t *pGlobals); - -#endif /* H_EXPORT_H */ +// h_export.h - prototypes for h_export.cpp + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef H_EXPORT_H +#define H_EXPORT_H + +#include "osdep.h" // DLLEXPORT, WINAPI, etc + +// Our GiveFnptrsToDll, called by engine. +typedef void (WINAPI *GIVE_ENGINE_FUNCTIONS_FN) (enginefuncs_t + *pengfuncsFromEngine, globalvars_t *pGlobals); + +C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t *pengfuncsFromEngine, + globalvars_t *pGlobals); + +#endif /* H_EXPORT_H */ diff --git a/revoice/include/log_meta.h b/revoice/include/log_meta.h index a701041..ec47c6d 100644 --- a/revoice/include/log_meta.h +++ b/revoice/include/log_meta.h @@ -1,99 +1,99 @@ -// log_meta.h - functions & macros for logging - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef LOG_META_H -#define LOG_META_H - -#include "enginecallbacks.h" // ALERT, etc -#include "sdk_util.h" // UTIL_VarArgs, etc - -// Debug logging. -// -// This is done as a macro, rather than a function. This way, you can add -// DEBUG statements all over, without worrying about performance -// implications. If the debugging level is set low, all those statements -// will only generate a simple float/int compare each; if we were to use a -// function instead of a macro, it would end up wasting a lot of cpu cycles -// calling/returning from the function every time. With a fair number of -// DEBUG statements, or if they're placed in frequently excuted code, the -// overhead of the wasted function calls could significantly impact server -// performance. -// -// For this reason, we also compare directly to the float value of the -// cvar, rather than calling CVAR_GET_FLOAT() and thus generating a string -// compare for each DEBUG statement. -// -// Called as: -// META_DEBUG(3, ("return code: %d", ret)); -// -// Note the double parens, and the missing parens around "args" in the -// macro itself. Note also the "do..while(0)" loop wrapping the -// statements, so they become a single statement when expanded, necessary -// for times when it might be called as a single-statement result of an -// else (or other flow control). -// -// As suggested by Jussi Kivilinna: Use "if(meta_debug.value < level); else -// DO(something);" style because "meta_debug.value < level" is in most common -// case "false". Check disasm, contitional jumps are predicted not to be -// taken by CPU. -// -// Yes, it's all a bit of a hack. - -#define META_DEBUG(level, args) \ - do { if(meta_debug.value < level) break; else ALERT(at_logged, "[META] (debug:%d) %s\n", level, UTIL_VarArgs args ); } while(0) - -// max buffer size for printed messages -#define MAX_LOGMSG_LEN 1024 - -// max buffer size for client messages -#define MAX_CLIENTMSG_LEN 128 - -extern cvar_t meta_debug; - -// META_DEV provides debug logging via the cvar "developer" (when set to 1) -// and uses a function call rather than a macro as it's really intended to -// be used only during startup, before meta_debug has been set from reading -// server.cfg. -// NOTE: META_DEV has now been mostly obsoleted in the code. - -void META_CONS(char *fmt, ...); -void META_DEV(char *fmt, ...); -void META_INFO(char *fmt, ...); -void META_WARNING(char *fmt, ...); -void META_ERROR(char *fmt, ...); -void META_LOG(char *fmt, ...); -void META_CLIENT(edict_t *pEntity, char *fmt, ...); - -void flush_ALERT_buffer(void); - -#endif /* LOG_META_H */ +// log_meta.h - functions & macros for logging + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef LOG_META_H +#define LOG_META_H + +#include "enginecallbacks.h" // ALERT, etc +#include "sdk_util.h" // UTIL_VarArgs, etc + +// Debug logging. +// +// This is done as a macro, rather than a function. This way, you can add +// DEBUG statements all over, without worrying about performance +// implications. If the debugging level is set low, all those statements +// will only generate a simple float/int compare each; if we were to use a +// function instead of a macro, it would end up wasting a lot of cpu cycles +// calling/returning from the function every time. With a fair number of +// DEBUG statements, or if they're placed in frequently excuted code, the +// overhead of the wasted function calls could significantly impact server +// performance. +// +// For this reason, we also compare directly to the float value of the +// cvar, rather than calling CVAR_GET_FLOAT() and thus generating a string +// compare for each DEBUG statement. +// +// Called as: +// META_DEBUG(3, ("return code: %d", ret)); +// +// Note the double parens, and the missing parens around "args" in the +// macro itself. Note also the "do..while(0)" loop wrapping the +// statements, so they become a single statement when expanded, necessary +// for times when it might be called as a single-statement result of an +// else (or other flow control). +// +// As suggested by Jussi Kivilinna: Use "if(meta_debug.value < level); else +// DO(something);" style because "meta_debug.value < level" is in most common +// case "false". Check disasm, contitional jumps are predicted not to be +// taken by CPU. +// +// Yes, it's all a bit of a hack. + +#define META_DEBUG(level, args) \ + do { if(meta_debug.value < level) break; else ALERT(at_logged, "[META] (debug:%d) %s\n", level, UTIL_VarArgs args ); } while(0) + +// max buffer size for printed messages +#define MAX_LOGMSG_LEN 1024 + +// max buffer size for client messages +#define MAX_CLIENTMSG_LEN 128 + +extern cvar_t meta_debug; + +// META_DEV provides debug logging via the cvar "developer" (when set to 1) +// and uses a function call rather than a macro as it's really intended to +// be used only during startup, before meta_debug has been set from reading +// server.cfg. +// NOTE: META_DEV has now been mostly obsoleted in the code. + +void META_CONS(char *fmt, ...); +void META_DEV(char *fmt, ...); +void META_INFO(char *fmt, ...); +void META_WARNING(char *fmt, ...); +void META_ERROR(char *fmt, ...); +void META_LOG(char *fmt, ...); +void META_CLIENT(edict_t *pEntity, char *fmt, ...); + +void flush_ALERT_buffer(void); + +#endif /* LOG_META_H */ diff --git a/revoice/include/meta_api.h b/revoice/include/meta_api.h index 456f45c..3bbccfa 100644 --- a/revoice/include/meta_api.h +++ b/revoice/include/meta_api.h @@ -1,232 +1,232 @@ -// meta_api.h - description of metamod's DLL interface - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef META_API_H -#define META_API_H - -#include "dllapi.h" // GETENTITYAPI_FN, etc -#include "engine_api.h" // GET_ENGINE_FUNCTIONS_FN, etc -#include "plinfo.h" // plugin_info_t, etc -#include "mutil.h" // mutil_funcs_t, etc -#include "osdep.h" // DLLEXPORT, etc - -// Version consists of "major:minor", two separate integer numbers. -// Version 1 original -// Version 2 added plugin_info_t **pinfo -// Version 3 init split into query and attach, added detach -// Version 4 added (PLUG_LOADTIME now) to attach -// Version 5 changed mm ifvers int* to string, moved pl ifvers to info -// Version 5:1 added link support for entity "adminmod_timer" (adminmod) -// Version 5:2 added gamedll_funcs to meta_attach() [v1.0-rc2] -// Version 5:3 added mutil_funcs to meta_query() [v1.05] -// Version 5:4 added centersay utility functions [v1.06] -// Version 5:5 added Meta_Init to plugin API [v1.08] -// Version 5:6 added CallGameEntity utility function [v1.09] -// Version 5:7 added GetUserMsgID, GetUserMsgName util funcs [v1.11] -// Version 5:8 added GetPluginPath [v1.11] -// Version 5:9 added GetGameInfo [v1.14] -// Version 5:10 added GINFO_REALDLL_FULLPATH for GetGameInfo [v1.17] -// Version 5:11 added plugin loading and unloading API [v1.18] -// Version 5:12 added util code for checking player query status [v1.18] -// Version 5:13 added cvarquery2 support and api for calling hook tables [v1.19] -#define META_INTERFACE_VERSION "5:13" - -#ifdef UNFINISHED -// Version 5:99 added event hook utility functions [v.???] -#define META_INTERFACE_VERSION "5:99" -#endif /* UNFINISHED */ - -// Flags returned by a plugin's api function. -// NOTE: order is crucial, as greater/less comparisons are made. -typedef enum { - MRES_UNSET = 0, - MRES_IGNORED, // plugin didn't take any action - MRES_HANDLED, // plugin did something, but real function should still be called - MRES_OVERRIDE, // call real function, but use my return value - MRES_SUPERCEDE, // skip real function; use my return value -} META_RES; - -// Variables provided to plugins. -typedef struct meta_globals_s { - META_RES mres; // writable; plugin's return flag - META_RES prev_mres; // readable; return flag of the previous plugin called - META_RES status; // readable; "highest" return flag so far - void *orig_ret; // readable; return value from "real" function - void *override_ret; // readable; return value from overriding/superceding plugin -} meta_globals_t; - -extern meta_globals_t *gpMetaGlobals; -#define SET_META_RESULT(result) gpMetaGlobals->mres=result -#define RETURN_META(result) \ - do { gpMetaGlobals->mres=result; return; } while(0) - -#define RETURN_META_VALUE(result, value) \ - do { gpMetaGlobals->mres=result; return(value); } while(0) - -#define META_RESULT_STATUS gpMetaGlobals->status -#define META_RESULT_PREVIOUS gpMetaGlobals->prev_mres -#define META_RESULT_ORIG_RET(type) *(type *)gpMetaGlobals->orig_ret -#define META_RESULT_OVERRIDE_RET(type) *(type *)gpMetaGlobals->override_ret - -// Table of getapi functions, retrieved from each plugin. -typedef struct { - GETENTITYAPI_FN pfnGetEntityAPI; - GETENTITYAPI_FN pfnGetEntityAPI_Post; - GETENTITYAPI2_FN pfnGetEntityAPI2; - GETENTITYAPI2_FN pfnGetEntityAPI2_Post; - GETNEWDLLFUNCTIONS_FN pfnGetNewDLLFunctions; - GETNEWDLLFUNCTIONS_FN pfnGetNewDLLFunctions_Post; - GET_ENGINE_FUNCTIONS_FN pfnGetEngineFunctions; - GET_ENGINE_FUNCTIONS_FN pfnGetEngineFunctions_Post; -} META_FUNCTIONS; - -// Pair of function tables provided by game DLL. -typedef struct { - DLL_FUNCTIONS *dllapi_table; - NEW_DLL_FUNCTIONS *newapi_table; -} gamedll_funcs_t; - -// Declared in plugin; referenced in macros. -extern gamedll_funcs_t *gpGamedllFuncs; -extern mutil_funcs_t *gpMetaUtilFuncs; - -// Tell the dll that we'll be loading it as a metamod plugin, in case it -// needs to do something special prior to the standard query/attach -// procedure. In particular, this will allow for DLL's that can be used as -// both standalone DLL's and metamod plugins. (optional; not required in -// plugin) -C_DLLEXPORT void Meta_Init(void); -typedef void (*META_INIT_FN) (void); - -// Get info about plugin, compare meta_interface versions, provide meta -// utility callback functions. -C_DLLEXPORT int Meta_Query(char *interfaceVersion, - plugin_info_t **plinfo, - mutil_funcs_t *pMetaUtilFuncs); -typedef int (*META_QUERY_FN) (char *interfaceVersion, - plugin_info_t **plinfo, - mutil_funcs_t *pMetaUtilFuncs); - -// Attach the plugin to the API; get the table of getapi functions; give -// meta_globals and gamedll_funcs. -C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, - META_FUNCTIONS *pFunctionTable, - meta_globals_t *pMGlobals, - gamedll_funcs_t *pGamedllFuncs); -typedef int (*META_ATTACH_FN) (PLUG_LOADTIME now, - META_FUNCTIONS *pFunctionTable, - meta_globals_t *pMGlobals, - gamedll_funcs_t *pGamedllFuncs); - -// Detach the plugin; tell why and when. -C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason); -typedef int (*META_DETACH_FN) (PLUG_LOADTIME now, PL_UNLOAD_REASON reason); - -// Standard HL SDK interface function prototypes. -C_DLLEXPORT int GetEntityAPI_Post(DLL_FUNCTIONS *pFunctionTable, - int interfaceVersion ); -C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, - int *interfaceVersion ); - -// Additional SDK-like interface function prototypes. -C_DLLEXPORT int GetNewDLLFunctions_Post(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion ); -C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion); -C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion); - -// Convenience macros for accessing GameDLL functions. Note: these talk -// _directly_ to the gamedll, and are not multiplexed through Metamod to -// the other plugins. -// DLL API functions: -#define MDLL_FUNC gpGamedllFuncs->dllapi_table - -#define MDLL_GameDLLInit MDLL_FUNC->pfnGameInit -#define MDLL_Spawn MDLL_FUNC->pfnSpawn -#define MDLL_Think MDLL_FUNC->pfnThink -#define MDLL_Use MDLL_FUNC->pfnUse -#define MDLL_Touch MDLL_FUNC->pfnTouch -#define MDLL_Blocked MDLL_FUNC->pfnBlocked -#define MDLL_KeyValue MDLL_FUNC->pfnKeyValue -#define MDLL_Save MDLL_FUNC->pfnSave -#define MDLL_Restore MDLL_FUNC->pfnRestore -#define MDLL_ObjectCollsionBox MDLL_FUNC->pfnAbsBox -#define MDLL_SaveWriteFields MDLL_FUNC->pfnSaveWriteFields -#define MDLL_SaveReadFields MDLL_FUNC->pfnSaveReadFields -#define MDLL_SaveGlobalState MDLL_FUNC->pfnSaveGlobalState -#define MDLL_RestoreGlobalState MDLL_FUNC->pfnRestoreGlobalState -#define MDLL_ResetGlobalState MDLL_FUNC->pfnResetGlobalState -#define MDLL_ClientConnect MDLL_FUNC->pfnClientConnect -#define MDLL_ClientDisconnect MDLL_FUNC->pfnClientDisconnect -#define MDLL_ClientKill MDLL_FUNC->pfnClientKill -#define MDLL_ClientPutInServer MDLL_FUNC->pfnClientPutInServer -#define MDLL_ClientCommand MDLL_FUNC->pfnClientCommand -#define MDLL_ClientUserInfoChanged MDLL_FUNC->pfnClientUserInfoChanged -#define MDLL_ServerActivate MDLL_FUNC->pfnServerActivate -#define MDLL_ServerDeactivate MDLL_FUNC->pfnServerDeactivate -#define MDLL_PlayerPreThink MDLL_FUNC->pfnPlayerPreThink -#define MDLL_PlayerPostThink MDLL_FUNC->pfnPlayerPostThink -#define MDLL_StartFrame MDLL_FUNC->pfnStartFrame -#define MDLL_ParmsNewLevel MDLL_FUNC->pfnParmsNewLevel -#define MDLL_ParmsChangeLevel MDLL_FUNC->pfnParmsChangeLevel -#define MDLL_GetGameDescription MDLL_FUNC->pfnGetGameDescription -#define MDLL_PlayerCustomization MDLL_FUNC->pfnPlayerCustomization -#define MDLL_SpectatorConnect MDLL_FUNC->pfnSpectatorConnect -#define MDLL_SpectatorDisconnect MDLL_FUNC->pfnSpectatorDisconnect -#define MDLL_SpectatorThink MDLL_FUNC->pfnSpectatorThink -#define MDLL_Sys_Error MDLL_FUNC->pfnSys_Error -#define MDLL_PM_Move MDLL_FUNC->pfnPM_Move -#define MDLL_PM_Init MDLL_FUNC->pfnPM_Init -#define MDLL_PM_FindTextureType MDLL_FUNC->pfnPM_FindTextureType -#define MDLL_SetupVisibility MDLL_FUNC->pfnSetupVisibility -#define MDLL_UpdateClientData MDLL_FUNC->pfnUpdateClientData -#define MDLL_AddToFullPack MDLL_FUNC->pfnAddToFullPack -#define MDLL_CreateBaseline MDLL_FUNC->pfnCreateBaseline -#define MDLL_RegisterEncoders MDLL_FUNC->pfnRegisterEncoders -#define MDLL_GetWeaponData MDLL_FUNC->pfnGetWeaponData -#define MDLL_CmdStart MDLL_FUNC->pfnCmdStart -#define MDLL_CmdEnd MDLL_FUNC->pfnCmdEnd -#define MDLL_ConnectionlessPacket MDLL_FUNC->pfnConnectionlessPacket -#define MDLL_GetHullBounds MDLL_FUNC->pfnGetHullBounds -#define MDLL_CreateInstancedBaselines MDLL_FUNC->pfnCreateInstancedBaselines -#define MDLL_InconsistentFile MDLL_FUNC->pfnInconsistentFile -#define MDLL_AllowLagCompensation MDLL_FUNC->pfnAllowLagCompensation - -// NEW API functions: -#define MNEW_FUNC gpGamedllFuncs->newapi_table - -#define MNEW_OnFreeEntPrivateData MNEW_FUNC->pfnOnFreeEntPrivateData -#define MNEW_GameShutdown MNEW_FUNC->pfnGameShutdown -#define MNEW_ShouldCollide MNEW_FUNC->pfnShouldCollide -#define MNEW_CvarValue MNEW_FUNC->pfnCvarValue -#define MNEW_CvarValue2 MNEW_FUNC->pfnCvarValue2 - -#endif /* META_API_H */ +// meta_api.h - description of metamod's DLL interface + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef META_API_H +#define META_API_H + +#include "dllapi.h" // GETENTITYAPI_FN, etc +#include "engine_api.h" // GET_ENGINE_FUNCTIONS_FN, etc +#include "plinfo.h" // plugin_info_t, etc +#include "mutil.h" // mutil_funcs_t, etc +#include "osdep.h" // DLLEXPORT, etc + +// Version consists of "major:minor", two separate integer numbers. +// Version 1 original +// Version 2 added plugin_info_t **pinfo +// Version 3 init split into query and attach, added detach +// Version 4 added (PLUG_LOADTIME now) to attach +// Version 5 changed mm ifvers int* to string, moved pl ifvers to info +// Version 5:1 added link support for entity "adminmod_timer" (adminmod) +// Version 5:2 added gamedll_funcs to meta_attach() [v1.0-rc2] +// Version 5:3 added mutil_funcs to meta_query() [v1.05] +// Version 5:4 added centersay utility functions [v1.06] +// Version 5:5 added Meta_Init to plugin API [v1.08] +// Version 5:6 added CallGameEntity utility function [v1.09] +// Version 5:7 added GetUserMsgID, GetUserMsgName util funcs [v1.11] +// Version 5:8 added GetPluginPath [v1.11] +// Version 5:9 added GetGameInfo [v1.14] +// Version 5:10 added GINFO_REALDLL_FULLPATH for GetGameInfo [v1.17] +// Version 5:11 added plugin loading and unloading API [v1.18] +// Version 5:12 added util code for checking player query status [v1.18] +// Version 5:13 added cvarquery2 support and api for calling hook tables [v1.19] +#define META_INTERFACE_VERSION "5:13" + +#ifdef UNFINISHED +// Version 5:99 added event hook utility functions [v.???] +#define META_INTERFACE_VERSION "5:99" +#endif /* UNFINISHED */ + +// Flags returned by a plugin's api function. +// NOTE: order is crucial, as greater/less comparisons are made. +typedef enum { + MRES_UNSET = 0, + MRES_IGNORED, // plugin didn't take any action + MRES_HANDLED, // plugin did something, but real function should still be called + MRES_OVERRIDE, // call real function, but use my return value + MRES_SUPERCEDE, // skip real function; use my return value +} META_RES; + +// Variables provided to plugins. +typedef struct meta_globals_s { + META_RES mres; // writable; plugin's return flag + META_RES prev_mres; // readable; return flag of the previous plugin called + META_RES status; // readable; "highest" return flag so far + void *orig_ret; // readable; return value from "real" function + void *override_ret; // readable; return value from overriding/superceding plugin +} meta_globals_t; + +extern meta_globals_t *gpMetaGlobals; +#define SET_META_RESULT(result) gpMetaGlobals->mres=result +#define RETURN_META(result) \ + do { gpMetaGlobals->mres=result; return; } while(0) + +#define RETURN_META_VALUE(result, value) \ + do { gpMetaGlobals->mres=result; return(value); } while(0) + +#define META_RESULT_STATUS gpMetaGlobals->status +#define META_RESULT_PREVIOUS gpMetaGlobals->prev_mres +#define META_RESULT_ORIG_RET(type) *(type *)gpMetaGlobals->orig_ret +#define META_RESULT_OVERRIDE_RET(type) *(type *)gpMetaGlobals->override_ret + +// Table of getapi functions, retrieved from each plugin. +typedef struct { + GETENTITYAPI_FN pfnGetEntityAPI; + GETENTITYAPI_FN pfnGetEntityAPI_Post; + GETENTITYAPI2_FN pfnGetEntityAPI2; + GETENTITYAPI2_FN pfnGetEntityAPI2_Post; + GETNEWDLLFUNCTIONS_FN pfnGetNewDLLFunctions; + GETNEWDLLFUNCTIONS_FN pfnGetNewDLLFunctions_Post; + GET_ENGINE_FUNCTIONS_FN pfnGetEngineFunctions; + GET_ENGINE_FUNCTIONS_FN pfnGetEngineFunctions_Post; +} META_FUNCTIONS; + +// Pair of function tables provided by game DLL. +typedef struct { + DLL_FUNCTIONS *dllapi_table; + NEW_DLL_FUNCTIONS *newapi_table; +} gamedll_funcs_t; + +// Declared in plugin; referenced in macros. +extern gamedll_funcs_t *gpGamedllFuncs; +extern mutil_funcs_t *gpMetaUtilFuncs; + +// Tell the dll that we'll be loading it as a metamod plugin, in case it +// needs to do something special prior to the standard query/attach +// procedure. In particular, this will allow for DLL's that can be used as +// both standalone DLL's and metamod plugins. (optional; not required in +// plugin) +C_DLLEXPORT void Meta_Init(void); +typedef void (*META_INIT_FN) (void); + +// Get info about plugin, compare meta_interface versions, provide meta +// utility callback functions. +C_DLLEXPORT int Meta_Query(char *interfaceVersion, + plugin_info_t **plinfo, + mutil_funcs_t *pMetaUtilFuncs); +typedef int (*META_QUERY_FN) (char *interfaceVersion, + plugin_info_t **plinfo, + mutil_funcs_t *pMetaUtilFuncs); + +// Attach the plugin to the API; get the table of getapi functions; give +// meta_globals and gamedll_funcs. +C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now, + META_FUNCTIONS *pFunctionTable, + meta_globals_t *pMGlobals, + gamedll_funcs_t *pGamedllFuncs); +typedef int (*META_ATTACH_FN) (PLUG_LOADTIME now, + META_FUNCTIONS *pFunctionTable, + meta_globals_t *pMGlobals, + gamedll_funcs_t *pGamedllFuncs); + +// Detach the plugin; tell why and when. +C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason); +typedef int (*META_DETACH_FN) (PLUG_LOADTIME now, PL_UNLOAD_REASON reason); + +// Standard HL SDK interface function prototypes. +C_DLLEXPORT int GetEntityAPI_Post(DLL_FUNCTIONS *pFunctionTable, + int interfaceVersion ); +C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, + int *interfaceVersion ); + +// Additional SDK-like interface function prototypes. +C_DLLEXPORT int GetNewDLLFunctions_Post(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion ); +C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion); +C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion); + +// Convenience macros for accessing GameDLL functions. Note: these talk +// _directly_ to the gamedll, and are not multiplexed through Metamod to +// the other plugins. +// DLL API functions: +#define MDLL_FUNC gpGamedllFuncs->dllapi_table + +#define MDLL_GameDLLInit MDLL_FUNC->pfnGameInit +#define MDLL_Spawn MDLL_FUNC->pfnSpawn +#define MDLL_Think MDLL_FUNC->pfnThink +#define MDLL_Use MDLL_FUNC->pfnUse +#define MDLL_Touch MDLL_FUNC->pfnTouch +#define MDLL_Blocked MDLL_FUNC->pfnBlocked +#define MDLL_KeyValue MDLL_FUNC->pfnKeyValue +#define MDLL_Save MDLL_FUNC->pfnSave +#define MDLL_Restore MDLL_FUNC->pfnRestore +#define MDLL_ObjectCollsionBox MDLL_FUNC->pfnAbsBox +#define MDLL_SaveWriteFields MDLL_FUNC->pfnSaveWriteFields +#define MDLL_SaveReadFields MDLL_FUNC->pfnSaveReadFields +#define MDLL_SaveGlobalState MDLL_FUNC->pfnSaveGlobalState +#define MDLL_RestoreGlobalState MDLL_FUNC->pfnRestoreGlobalState +#define MDLL_ResetGlobalState MDLL_FUNC->pfnResetGlobalState +#define MDLL_ClientConnect MDLL_FUNC->pfnClientConnect +#define MDLL_ClientDisconnect MDLL_FUNC->pfnClientDisconnect +#define MDLL_ClientKill MDLL_FUNC->pfnClientKill +#define MDLL_ClientPutInServer MDLL_FUNC->pfnClientPutInServer +#define MDLL_ClientCommand MDLL_FUNC->pfnClientCommand +#define MDLL_ClientUserInfoChanged MDLL_FUNC->pfnClientUserInfoChanged +#define MDLL_ServerActivate MDLL_FUNC->pfnServerActivate +#define MDLL_ServerDeactivate MDLL_FUNC->pfnServerDeactivate +#define MDLL_PlayerPreThink MDLL_FUNC->pfnPlayerPreThink +#define MDLL_PlayerPostThink MDLL_FUNC->pfnPlayerPostThink +#define MDLL_StartFrame MDLL_FUNC->pfnStartFrame +#define MDLL_ParmsNewLevel MDLL_FUNC->pfnParmsNewLevel +#define MDLL_ParmsChangeLevel MDLL_FUNC->pfnParmsChangeLevel +#define MDLL_GetGameDescription MDLL_FUNC->pfnGetGameDescription +#define MDLL_PlayerCustomization MDLL_FUNC->pfnPlayerCustomization +#define MDLL_SpectatorConnect MDLL_FUNC->pfnSpectatorConnect +#define MDLL_SpectatorDisconnect MDLL_FUNC->pfnSpectatorDisconnect +#define MDLL_SpectatorThink MDLL_FUNC->pfnSpectatorThink +#define MDLL_Sys_Error MDLL_FUNC->pfnSys_Error +#define MDLL_PM_Move MDLL_FUNC->pfnPM_Move +#define MDLL_PM_Init MDLL_FUNC->pfnPM_Init +#define MDLL_PM_FindTextureType MDLL_FUNC->pfnPM_FindTextureType +#define MDLL_SetupVisibility MDLL_FUNC->pfnSetupVisibility +#define MDLL_UpdateClientData MDLL_FUNC->pfnUpdateClientData +#define MDLL_AddToFullPack MDLL_FUNC->pfnAddToFullPack +#define MDLL_CreateBaseline MDLL_FUNC->pfnCreateBaseline +#define MDLL_RegisterEncoders MDLL_FUNC->pfnRegisterEncoders +#define MDLL_GetWeaponData MDLL_FUNC->pfnGetWeaponData +#define MDLL_CmdStart MDLL_FUNC->pfnCmdStart +#define MDLL_CmdEnd MDLL_FUNC->pfnCmdEnd +#define MDLL_ConnectionlessPacket MDLL_FUNC->pfnConnectionlessPacket +#define MDLL_GetHullBounds MDLL_FUNC->pfnGetHullBounds +#define MDLL_CreateInstancedBaselines MDLL_FUNC->pfnCreateInstancedBaselines +#define MDLL_InconsistentFile MDLL_FUNC->pfnInconsistentFile +#define MDLL_AllowLagCompensation MDLL_FUNC->pfnAllowLagCompensation + +// NEW API functions: +#define MNEW_FUNC gpGamedllFuncs->newapi_table + +#define MNEW_OnFreeEntPrivateData MNEW_FUNC->pfnOnFreeEntPrivateData +#define MNEW_GameShutdown MNEW_FUNC->pfnGameShutdown +#define MNEW_ShouldCollide MNEW_FUNC->pfnShouldCollide +#define MNEW_CvarValue MNEW_FUNC->pfnCvarValue +#define MNEW_CvarValue2 MNEW_FUNC->pfnCvarValue2 + +#endif /* META_API_H */ diff --git a/revoice/include/mhook.h b/revoice/include/mhook.h index 64f2e95..b56b0a6 100644 --- a/revoice/include/mhook.h +++ b/revoice/include/mhook.h @@ -1,157 +1,157 @@ -#ifdef UNFINISHED - -// mhook.h - class and types to describe hooks and hooklists - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef MHOOK_H -#define MHOOK_H - -#include "plinfo.h" // plid_t, etc -#include "types_meta.h" // mBOOL -#include "osdep.h" // MUTEX_T, etc - -#define MAX_HOOKS 100 - -// Particular game events that we detect, though whatever means we can best -// find. -typedef enum { - EV_NONE = 0, // no event here... - // non-log detected - EV_PLAYER_CONNECT, // ie ClientConnect - EV_PLAYER_ENTER, // ie ClientPutInServer - EV_PLAYER_LEAVE, // ie ClientDisconnect (opposite PutInServer) - EV_PLAYER_SPAWN, // deadflag change to DEAD_NO - EV_PLAYER_DEATH, // deadflag change to DEAD_DEAD - EV_PLAYER_CHANGE_NAME, // netname change in ClientUserInfoChanged - // log detected - EV_PLAYER_JOIN_TEAM, // ie "Joe<15><785><>" joined team "CT" - EV_PLAYER_SUICIDE, // ie "Joe<15><785>" committed suicide ... - EV_PLAYER_CHANGE_ROLE, // TFC: ie "Joe<15><785>" changed role to "Pyro" - EV_TEAM_KILL, // ie "Joe<15><785>" killed "Bob<16><342>" ... - EV_WEAPON_KILL, // ie "Joe<15><785>" killed "Sam<17><197>" with "sg552" - EV_TEAM_SCORE, // ie Team "CT" scored "7" with "2" players -} game_event_t; - -// Info corresponding to a player, in particular the info found in the logline. -typedef struct { - char *name; - int userid; - int wonid; - char *team; -} event_player_t; - -// Info for an event, mostly corresponding to info from a logline. -typedef struct { - game_event_t evtype; // specific event, if identified. - char *buf; // copy of the logmsg, with embedded NULLs - event_player_t *player; - char *action; // "triggered" string, or a generic action string - event_player_t *target; - char *with; -} event_args_t; - -// Types for callback functions to be called for requested event/logline. -typedef void (*event_func_t) (game_event_t event, event_args_t *args, - const char *logline); -typedef void (*logmatch_func_t) (const char *pattern, event_args_t *args, - const char *logline); - -// The 4 types of hook requests we accept. -typedef enum { - H_NONE = 0, - H_EVENT, // Specific event, from a short list. - H_TRIGGER, // A given "triggered" string. - H_STRING, // Any substring of logline. - H_REGEX, // A regular expression matching of logline. -} hook_t; - - -// Class for individual hook function, as registered by a plugin. -class MHook { - friend class MHookList; - friend class MFuncQueue; - private: - // data: - int index; - hook_t type; // EVENT, TRIGGER, etc - plid_t plid; - int pl_index; // index of matching plugin - void *pfnHandle; - game_event_t event; // if type is H_EVENT - const char *match; // if type is TRIGGER, STRING, or REGEX - // Copy/Assignment constructors, to satisfy -Weffc++. - // Note however, we declare them private and don't define them, since - // we don't ever want to copy or assign instances of the class. - // (thanks to O'Reilly "C++: The Core Language", page 113) - MHook(const MHook &src); - void operator=(const MHook &src); - // constructors: - MHook(void); - MHook(int idx, plid_t pid, game_event_t evt, event_func_t pfn); - MHook(int idx, plid_t pid, hook_t tp, const char *cp, logmatch_func_t pfn); - // functions: - mBOOL call(event_args_t *args, const char *logline); - mBOOL enqueue(MFuncQueue *mfq, event_args_t *args, const char *logline); - public: - // no public interfaces; everything done from friend MHookList. -}; - - -// Class for list of registered hook functions. -class MHookList { - private: - // data: - MHook *hlist[MAX_HOOKS]; - int size; // set to MAX_HOOKS in constructor - int endlist; - MUTEX_T mx_hlist; - int MXlock(void) { return(MUTEX_LOCK(&mx_hlist)); }; - int MXunlock(void) { return(MUTEX_UNLOCK(&mx_hlist)); }; - public: - // constructor: - MHookList(void); - // functions: - int add(plid_t plid, game_event_t event, event_func_t pfnHandle); - int add(plid_t plid, hook_t type, const char *match, - logmatch_func_t pfnHandle); - mBOOL remove(plid_t plid, int hindex); - int remove_all(plid_t plid); - mBOOL call(event_args_t *args, const char *logline); - mBOOL enqueue(MFuncQueue *mfq, hook_t htype, event_args_t *evargs, - const char *logline); - char *str_htype(hook_t htype); -}; - -#endif /* MHOOK_H */ - -#endif /* UNFINISHED */ +#ifdef UNFINISHED + +// mhook.h - class and types to describe hooks and hooklists + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef MHOOK_H +#define MHOOK_H + +#include "plinfo.h" // plid_t, etc +#include "types_meta.h" // mBOOL +#include "osdep.h" // MUTEX_T, etc + +#define MAX_HOOKS 100 + +// Particular game events that we detect, though whatever means we can best +// find. +typedef enum { + EV_NONE = 0, // no event here... + // non-log detected + EV_PLAYER_CONNECT, // ie ClientConnect + EV_PLAYER_ENTER, // ie ClientPutInServer + EV_PLAYER_LEAVE, // ie ClientDisconnect (opposite PutInServer) + EV_PLAYER_SPAWN, // deadflag change to DEAD_NO + EV_PLAYER_DEATH, // deadflag change to DEAD_DEAD + EV_PLAYER_CHANGE_NAME, // netname change in ClientUserInfoChanged + // log detected + EV_PLAYER_JOIN_TEAM, // ie "Joe<15><785><>" joined team "CT" + EV_PLAYER_SUICIDE, // ie "Joe<15><785>" committed suicide ... + EV_PLAYER_CHANGE_ROLE, // TFC: ie "Joe<15><785>" changed role to "Pyro" + EV_TEAM_KILL, // ie "Joe<15><785>" killed "Bob<16><342>" ... + EV_WEAPON_KILL, // ie "Joe<15><785>" killed "Sam<17><197>" with "sg552" + EV_TEAM_SCORE, // ie Team "CT" scored "7" with "2" players +} game_event_t; + +// Info corresponding to a player, in particular the info found in the logline. +typedef struct { + char *name; + int userid; + int wonid; + char *team; +} event_player_t; + +// Info for an event, mostly corresponding to info from a logline. +typedef struct { + game_event_t evtype; // specific event, if identified. + char *buf; // copy of the logmsg, with embedded NULLs + event_player_t *player; + char *action; // "triggered" string, or a generic action string + event_player_t *target; + char *with; +} event_args_t; + +// Types for callback functions to be called for requested event/logline. +typedef void (*event_func_t) (game_event_t event, event_args_t *args, + const char *logline); +typedef void (*logmatch_func_t) (const char *pattern, event_args_t *args, + const char *logline); + +// The 4 types of hook requests we accept. +typedef enum { + H_NONE = 0, + H_EVENT, // Specific event, from a short list. + H_TRIGGER, // A given "triggered" string. + H_STRING, // Any substring of logline. + H_REGEX, // A regular expression matching of logline. +} hook_t; + + +// Class for individual hook function, as registered by a plugin. +class MHook { + friend class MHookList; + friend class MFuncQueue; + private: + // data: + int index; + hook_t type; // EVENT, TRIGGER, etc + plid_t plid; + int pl_index; // index of matching plugin + void *pfnHandle; + game_event_t event; // if type is H_EVENT + const char *match; // if type is TRIGGER, STRING, or REGEX + // Copy/Assignment constructors, to satisfy -Weffc++. + // Note however, we declare them private and don't define them, since + // we don't ever want to copy or assign instances of the class. + // (thanks to O'Reilly "C++: The Core Language", page 113) + MHook(const MHook &src); + void operator=(const MHook &src); + // constructors: + MHook(void); + MHook(int idx, plid_t pid, game_event_t evt, event_func_t pfn); + MHook(int idx, plid_t pid, hook_t tp, const char *cp, logmatch_func_t pfn); + // functions: + mBOOL call(event_args_t *args, const char *logline); + mBOOL enqueue(MFuncQueue *mfq, event_args_t *args, const char *logline); + public: + // no public interfaces; everything done from friend MHookList. +}; + + +// Class for list of registered hook functions. +class MHookList { + private: + // data: + MHook *hlist[MAX_HOOKS]; + int size; // set to MAX_HOOKS in constructor + int endlist; + MUTEX_T mx_hlist; + int MXlock(void) { return(MUTEX_LOCK(&mx_hlist)); }; + int MXunlock(void) { return(MUTEX_UNLOCK(&mx_hlist)); }; + public: + // constructor: + MHookList(void); + // functions: + int add(plid_t plid, game_event_t event, event_func_t pfnHandle); + int add(plid_t plid, hook_t type, const char *match, + logmatch_func_t pfnHandle); + mBOOL remove(plid_t plid, int hindex); + int remove_all(plid_t plid); + mBOOL call(event_args_t *args, const char *logline); + mBOOL enqueue(MFuncQueue *mfq, hook_t htype, event_args_t *evargs, + const char *logline); + char *str_htype(hook_t htype); +}; + +#endif /* MHOOK_H */ + +#endif /* UNFINISHED */ diff --git a/revoice/include/mreg.h b/revoice/include/mreg.h index b66395e..00fe0c9 100644 --- a/revoice/include/mreg.h +++ b/revoice/include/mreg.h @@ -1,183 +1,183 @@ -// mreg.h - description of registered items (classes MRegCmd, MRegCmdList) - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef MREG_H -#define MREG_H - -#include "types_meta.h" // mBOOL - -// Number of entries to add to reglists when they need to grow. Typically -// more cvars than commands, so we grow them at different increments. -#define REG_CMD_GROWSIZE 32 -#define REG_CVAR_GROWSIZE 64 - -// Width required to printf a Reg*List index number, for show() functions. -// This used to correspond to the number of digits in MAX_REG, which was a -// fixed, compile-time limit. However, now that the reg lists are grown -// dynamically, this has less strong correspondance to list sizes. So for -// the moment, it reflects what one might normally expect to be the max -// width needed to print an index number; 4 allows 9999 (which is a damn -// lot, if you ask me). -#define WIDTH_MAX_REG 4 - -// Max number of registered user msgs we can manage. -#define MAX_REG_MSGS 256 - -// Flags to indicate if given cvar or func is part of a loaded plugin. -typedef enum { - RG_INVALID, - RG_VALID, -} REG_STATUS; - -// Pointer to function registered by AddServerCommand. -typedef void (*REG_CMD_FN) (void); - - -// An individual registered function/command. -class MRegCmd { - friend class MRegCmdList; - private: - // data: - int index; // 1-based - public: - char *name; // space is malloc'd - REG_CMD_FN pfnCmd; // pointer to the function - int plugid; // index id of corresponding plugin - REG_STATUS status; // whether corresponding plugin is loaded - // functions: - void init(int idx); // init values, as not using constructors - mBOOL call(void); // try to call the function -}; - - -// A list of registered commands. -class MRegCmdList { - private: - // data: - MRegCmd *mlist; // malloc'd array of registered commands - int size; // current size of list - int endlist; // index of last used entry - // Private; to satisfy -Weffc++ "has pointer data members but does - // not override" copy/assignment constructor. - void operator=(const MRegCmdList &src); - MRegCmdList(const MRegCmdList &src); - - public: - // constructor: - MRegCmdList(void); - - // functions: - MRegCmd *find(const char *findname); // find by MRegCmd->name - MRegCmd *add(const char *addname); - void disable(int plugin_id); // change status to Invalid - void show(void); // list all funcs to console - void show(int plugin_id); // list given plugin's funcs to console -}; - - - -// An individual registered cvar. -class MRegCvar { - friend class MRegCvarList; - private: - // data: - int index; // 1-based - public: - cvar_t *data; // actual cvar structure, malloc'd - int plugid; // index id of corresponding plugin - REG_STATUS status; // whether corresponding plugin is loaded - // functions: - void init(int idx); // init values, as not using constructors - mBOOL set(cvar_t *src); -}; - - -// A list of registered cvars. -class MRegCvarList { - private: - // data: - MRegCvar *vlist; // malloc'd array of registered cvars - int size; // size of list, ie MAX_REG_CVARS - int endlist; // index of last used entry - // Private; to satisfy -Weffc++ "has pointer data members but does - // not override" copy/assignment constructor. - void operator=(const MRegCvarList &src); - MRegCvarList(const MRegCvarList &src); - - public: - // constructor: - MRegCvarList(void); - - // functions: - MRegCvar *add(const char *addname); - MRegCvar *find(const char *findname); // find by MRegCvar->data.name - void disable(int plugin_id); // change status to Invalid - void show(void); // list all cvars to console - void show(int plugin_id); // list given plugin's cvars to console -}; - - - -// An individual registered user msg, from gamedll. -class MRegMsg { - friend class MRegMsgList; - private: - // data: - int index; // 1-based - public: - const char *name; // name, assumed constant string in gamedll - int msgid; // msgid, assigned by engine - int size; // size, if given by gamedll -}; - - -// A list of registered user msgs. -class MRegMsgList { - private: - // data: - MRegMsg mlist[MAX_REG_MSGS]; // array of registered msgs - int size; // size of list, ie MAX_REG_MSGS - int endlist; // index of last used entry - - public: - // constructor: - MRegMsgList(void); - - // functions: - MRegMsg *add(const char *addname, int addmsgid, int addsize); - MRegMsg *find(const char *findname); - MRegMsg *find(int findmsgid); - void show(void); // list all msgs to console -}; - -#endif /* MREG_H */ +// mreg.h - description of registered items (classes MRegCmd, MRegCmdList) + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef MREG_H +#define MREG_H + +#include "types_meta.h" // mBOOL + +// Number of entries to add to reglists when they need to grow. Typically +// more cvars than commands, so we grow them at different increments. +#define REG_CMD_GROWSIZE 32 +#define REG_CVAR_GROWSIZE 64 + +// Width required to printf a Reg*List index number, for show() functions. +// This used to correspond to the number of digits in MAX_REG, which was a +// fixed, compile-time limit. However, now that the reg lists are grown +// dynamically, this has less strong correspondance to list sizes. So for +// the moment, it reflects what one might normally expect to be the max +// width needed to print an index number; 4 allows 9999 (which is a damn +// lot, if you ask me). +#define WIDTH_MAX_REG 4 + +// Max number of registered user msgs we can manage. +#define MAX_REG_MSGS 256 + +// Flags to indicate if given cvar or func is part of a loaded plugin. +typedef enum { + RG_INVALID, + RG_VALID, +} REG_STATUS; + +// Pointer to function registered by AddServerCommand. +typedef void (*REG_CMD_FN) (void); + + +// An individual registered function/command. +class MRegCmd { + friend class MRegCmdList; + private: + // data: + int index; // 1-based + public: + char *name; // space is malloc'd + REG_CMD_FN pfnCmd; // pointer to the function + int plugid; // index id of corresponding plugin + REG_STATUS status; // whether corresponding plugin is loaded + // functions: + void init(int idx); // init values, as not using constructors + mBOOL call(void); // try to call the function +}; + + +// A list of registered commands. +class MRegCmdList { + private: + // data: + MRegCmd *mlist; // malloc'd array of registered commands + int size; // current size of list + int endlist; // index of last used entry + // Private; to satisfy -Weffc++ "has pointer data members but does + // not override" copy/assignment constructor. + void operator=(const MRegCmdList &src); + MRegCmdList(const MRegCmdList &src); + + public: + // constructor: + MRegCmdList(void); + + // functions: + MRegCmd *find(const char *findname); // find by MRegCmd->name + MRegCmd *add(const char *addname); + void disable(int plugin_id); // change status to Invalid + void show(void); // list all funcs to console + void show(int plugin_id); // list given plugin's funcs to console +}; + + + +// An individual registered cvar. +class MRegCvar { + friend class MRegCvarList; + private: + // data: + int index; // 1-based + public: + cvar_t *data; // actual cvar structure, malloc'd + int plugid; // index id of corresponding plugin + REG_STATUS status; // whether corresponding plugin is loaded + // functions: + void init(int idx); // init values, as not using constructors + mBOOL set(cvar_t *src); +}; + + +// A list of registered cvars. +class MRegCvarList { + private: + // data: + MRegCvar *vlist; // malloc'd array of registered cvars + int size; // size of list, ie MAX_REG_CVARS + int endlist; // index of last used entry + // Private; to satisfy -Weffc++ "has pointer data members but does + // not override" copy/assignment constructor. + void operator=(const MRegCvarList &src); + MRegCvarList(const MRegCvarList &src); + + public: + // constructor: + MRegCvarList(void); + + // functions: + MRegCvar *add(const char *addname); + MRegCvar *find(const char *findname); // find by MRegCvar->data.name + void disable(int plugin_id); // change status to Invalid + void show(void); // list all cvars to console + void show(int plugin_id); // list given plugin's cvars to console +}; + + + +// An individual registered user msg, from gamedll. +class MRegMsg { + friend class MRegMsgList; + private: + // data: + int index; // 1-based + public: + const char *name; // name, assumed constant string in gamedll + int msgid; // msgid, assigned by engine + int size; // size, if given by gamedll +}; + + +// A list of registered user msgs. +class MRegMsgList { + private: + // data: + MRegMsg mlist[MAX_REG_MSGS]; // array of registered msgs + int size; // size of list, ie MAX_REG_MSGS + int endlist; // index of last used entry + + public: + // constructor: + MRegMsgList(void); + + // functions: + MRegMsg *add(const char *addname, int addmsgid, int addsize); + MRegMsg *find(const char *findname); + MRegMsg *find(int findmsgid); + void show(void); // list all msgs to console +}; + +#endif /* MREG_H */ diff --git a/revoice/include/mutil.h b/revoice/include/mutil.h index 2d6c9f7..eb7edc4 100644 --- a/revoice/include/mutil.h +++ b/revoice/include/mutil.h @@ -1,157 +1,157 @@ -// mutil.h - prototypes for utility functions to provide to plugins - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef MUTIL_H -#define MUTIL_H - -#include "plinfo.h" // plugin_info_t, etc -#include "mhook.h" // game_event_t, etc -#include "sdk_util.h" // hudtextparms_t, etc - -// max buffer size for printed messages -#define MAX_LOGMSG_LEN 1024 - -// For GetGameInfo: -typedef enum { - GINFO_NAME = 0, - GINFO_DESC, - GINFO_GAMEDIR, - GINFO_DLL_FULLPATH, - GINFO_DLL_FILENAME, - GINFO_REALDLL_FULLPATH, -} ginfo_t; - -// Meta Utility Function table type. -typedef struct meta_util_funcs_s { - void (*pfnLogConsole) (plid_t plid, const char *fmt, ...); - void (*pfnLogMessage) (plid_t plid, const char *fmt, ...); - void (*pfnLogError) (plid_t plid, const char *fmt, ...); - void (*pfnLogDeveloper) (plid_t plid, const char *fmt, ...); - void (*pfnCenterSay) (plid_t plid, const char *fmt, ...); - void (*pfnCenterSayParms) (plid_t plid, hudtextparms_t tparms, - const char *fmt, ...); - void (*pfnCenterSayVarargs) (plid_t plid, hudtextparms_t tparms, - const char *fmt, va_list ap); - qboolean (*pfnCallGameEntity) (plid_t plid, const char *entStr, - entvars_t *pev); - int (*pfnGetUserMsgID) (plid_t plid, const char *msgname, int *size); - const char *(*pfnGetUserMsgName) (plid_t plid, int msgid, int *size); - const char *(*pfnGetPluginPath) (plid_t plid); - const char *(*pfnGetGameInfo) (plid_t plid, ginfo_t tag); - int (*pfnLoadPlugin) (plid_t plid, const char *cmdline, PLUG_LOADTIME now, void **plugin_handle); - int (*pfnUnloadPlugin) (plid_t plid, const char *cmdline, PLUG_LOADTIME now, PL_UNLOAD_REASON reason); - int (*pfnUnloadPluginByHandle) (plid_t plid, void *plugin_handle, PLUG_LOADTIME now, PL_UNLOAD_REASON reason); - const char *(*pfnIsQueryingClientCvar) (plid_t plid, const edict_t *pEdict); - int (*pfnMakeRequestId) (plid_t plid); - void (*pfnGetHookTables) (plid_t plid, enginefuncs_t **peng, DLL_FUNCTIONS **pdll, NEW_DLL_FUNCTIONS **pnewdll); -#ifdef UNFINISHED - int (*pfnHookGameEvent) (plid_t plid, game_event_t event, - event_func_t pfnHandle); - int (*pfnHookLogTrigger) (plid_t plid, const char *trigger, - logmatch_func_t pfnHandle); - int (*pfnHookLogString) (plid_t plid, const char *string, - logmatch_func_t pfnHandle); - int (*pfnHookLogRegex) (plid_t plid, const char *pattern, - logmatch_func_t pfnHandle); - qboolean (*pfnRemoveHookID) (plid_t plid, int hookid); - int (*pfnRemoveHookAll) (plid_t plid); -#endif /* UNFINISHED */ -} mutil_funcs_t; -extern mutil_funcs_t MetaUtilFunctions; - -// Meta Utility Functions -void mutil_LogConsole(plid_t plid, const char *fmt, ...); -void mutil_LogMessage(plid_t plid, const char *fmt, ...); -void mutil_LogError(plid_t plid, const char *fmt, ...); -void mutil_LogDeveloper(plid_t plid, const char *fmt, ...); - -void mutil_CenterSay(plid_t plid, const char *fmt, ...); -void mutil_CenterSayParms(plid_t plid, hudtextparms_t tparms, - const char *fmt, ...); -void mutil_CenterSayVarargs(plid_t plid, hudtextparms_t tparms, - const char *fmt, va_list ap); - -qboolean mutil_CallGameEntity(plid_t plid, const char *entStr, entvars_t *pev); - -int mutil_GetUserMsgID(plid_t plid, const char *name, int *size); -const char *mutil_GetUserMsgName(plid_t plid, int msgid, int *size); -const char *mutil_GetPluginPath(plid_t plid); -const char *mutil_GetGameInfo(plid_t plid, ginfo_t tag); -const char *mutil_IsQueryingClientCvar(plid_t plid, const edict_t *pEdict); -int mutil_MakeRequestId(plid_t plid); -void mutil_GetHookTables(plid_t plid, enginefuncs_t **peng, DLL_FUNCTIONS **pdll, NEW_DLL_FUNCTIONS **pnewdll); - -#ifdef UNFINISHED -int mutil_HookGameEvent(plid_t plid, game_event_t event, - event_func_t pfnHandle); -int mutil_HookLogTrigger(plid_t plid, const char *trigger, - logmatch_func_t pfnHandle); -int mutil_HookLogString(plid_t plid, const char *string, - logmatch_func_t pfnHandle); -int mutil_HookLogRegex(plid_t plid, const char *pattern, - logmatch_func_t pfnHandle); - -qboolean mutil_RemoveHookID(plid_t plid, int hookid); -int mutil_RemoveHookAll(plid_t plid); -#endif /* UNFINISHED */ - -// Convenience macros for MetaUtil functions -#define LOG_CONSOLE (*gpMetaUtilFuncs->pfnLogConsole) -#define LOG_MESSAGE (*gpMetaUtilFuncs->pfnLogMessage) -#define LOG_ERROR (*gpMetaUtilFuncs->pfnLogError) -#define LOG_DEVELOPER (*gpMetaUtilFuncs->pfnLogDeveloper) -#define CENTER_SAY (*gpMetaUtilFuncs->pfnCenterSay) -#define CENTER_SAY_PARMS (*gpMetaUtilFuncs->pfnCenterSayParms) -#define CENTER_SAY_VARARGS (*gpMetaUtilFuncs->pfnCenterSayVarargs) -#define CALL_GAME_ENTITY (*gpMetaUtilFuncs->pfnCallGameEntity) -#define GET_USER_MSG_ID (*gpMetaUtilFuncs->pfnGetUserMsgID) -#define GET_USER_MSG_NAME (*gpMetaUtilFuncs->pfnGetUserMsgName) -#define GET_PLUGIN_PATH (*gpMetaUtilFuncs->pfnGetPluginPath) -#define GET_GAME_INFO (*gpMetaUtilFuncs->pfnGetGameInfo) -#define LOAD_PLUGIN (*gpMetaUtilFuncs->pfnLoadPlugin) -#define UNLOAD_PLUGIN (*gpMetaUtilFuncs->pfnUnloadPlugin) -#define UNLOAD_PLUGIN_BY_HANDLE (*gpMetaUtilFuncs->pfnUnloadPluginByHandle) -#define IS_QUERYING_CLIENT_CVAR (*gpMetaUtilFuncs->pfnIsQueryingClientCvar) -#define MAKE_REQUESTID (*gpMetaUtilFuncs->pfnMakeRequestId) -#define GET_HOOK_TABLES (*gpMetaUtilFuncs->pfnGetHookTables) - -#ifdef UNFINISHED -#define HOOK_GAME_EVENT (*gpMetaUtilFuncs->pfnHookGameEvent) -#define HOOK_LOG_TRIGGER (*gpMetaUtilFuncs->pfnHookLogTrigger) -#define HOOK_LOG_STRING (*gpMetaUtilFuncs->pfnHookLogString) -#define HOOK_LOG_REGEX (*gpMetaUtilFuncs->pfnHookLogRegex) -#define REMOVE_HOOK_ID (*gpMetaUtilFuncs->pfnRemoveHookID) -#define REMOVE_HOOK_ALL (*gpMetaUtilFuncs->pfnRemoveHookAll) -#endif /* UNFINISHED */ - -#endif /* MUTIL_H */ +// mutil.h - prototypes for utility functions to provide to plugins + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef MUTIL_H +#define MUTIL_H + +#include "plinfo.h" // plugin_info_t, etc +#include "mhook.h" // game_event_t, etc +#include "sdk_util.h" // hudtextparms_t, etc + +// max buffer size for printed messages +#define MAX_LOGMSG_LEN 1024 + +// For GetGameInfo: +typedef enum { + GINFO_NAME = 0, + GINFO_DESC, + GINFO_GAMEDIR, + GINFO_DLL_FULLPATH, + GINFO_DLL_FILENAME, + GINFO_REALDLL_FULLPATH, +} ginfo_t; + +// Meta Utility Function table type. +typedef struct meta_util_funcs_s { + void (*pfnLogConsole) (plid_t plid, const char *fmt, ...); + void (*pfnLogMessage) (plid_t plid, const char *fmt, ...); + void (*pfnLogError) (plid_t plid, const char *fmt, ...); + void (*pfnLogDeveloper) (plid_t plid, const char *fmt, ...); + void (*pfnCenterSay) (plid_t plid, const char *fmt, ...); + void (*pfnCenterSayParms) (plid_t plid, hudtextparms_t tparms, + const char *fmt, ...); + void (*pfnCenterSayVarargs) (plid_t plid, hudtextparms_t tparms, + const char *fmt, va_list ap); + qboolean (*pfnCallGameEntity) (plid_t plid, const char *entStr, + entvars_t *pev); + int (*pfnGetUserMsgID) (plid_t plid, const char *msgname, int *size); + const char *(*pfnGetUserMsgName) (plid_t plid, int msgid, int *size); + const char *(*pfnGetPluginPath) (plid_t plid); + const char *(*pfnGetGameInfo) (plid_t plid, ginfo_t tag); + int (*pfnLoadPlugin) (plid_t plid, const char *cmdline, PLUG_LOADTIME now, void **plugin_handle); + int (*pfnUnloadPlugin) (plid_t plid, const char *cmdline, PLUG_LOADTIME now, PL_UNLOAD_REASON reason); + int (*pfnUnloadPluginByHandle) (plid_t plid, void *plugin_handle, PLUG_LOADTIME now, PL_UNLOAD_REASON reason); + const char *(*pfnIsQueryingClientCvar) (plid_t plid, const edict_t *pEdict); + int (*pfnMakeRequestId) (plid_t plid); + void (*pfnGetHookTables) (plid_t plid, enginefuncs_t **peng, DLL_FUNCTIONS **pdll, NEW_DLL_FUNCTIONS **pnewdll); +#ifdef UNFINISHED + int (*pfnHookGameEvent) (plid_t plid, game_event_t event, + event_func_t pfnHandle); + int (*pfnHookLogTrigger) (plid_t plid, const char *trigger, + logmatch_func_t pfnHandle); + int (*pfnHookLogString) (plid_t plid, const char *string, + logmatch_func_t pfnHandle); + int (*pfnHookLogRegex) (plid_t plid, const char *pattern, + logmatch_func_t pfnHandle); + qboolean (*pfnRemoveHookID) (plid_t plid, int hookid); + int (*pfnRemoveHookAll) (plid_t plid); +#endif /* UNFINISHED */ +} mutil_funcs_t; +extern mutil_funcs_t MetaUtilFunctions; + +// Meta Utility Functions +void mutil_LogConsole(plid_t plid, const char *fmt, ...); +void mutil_LogMessage(plid_t plid, const char *fmt, ...); +void mutil_LogError(plid_t plid, const char *fmt, ...); +void mutil_LogDeveloper(plid_t plid, const char *fmt, ...); + +void mutil_CenterSay(plid_t plid, const char *fmt, ...); +void mutil_CenterSayParms(plid_t plid, hudtextparms_t tparms, + const char *fmt, ...); +void mutil_CenterSayVarargs(plid_t plid, hudtextparms_t tparms, + const char *fmt, va_list ap); + +qboolean mutil_CallGameEntity(plid_t plid, const char *entStr, entvars_t *pev); + +int mutil_GetUserMsgID(plid_t plid, const char *name, int *size); +const char *mutil_GetUserMsgName(plid_t plid, int msgid, int *size); +const char *mutil_GetPluginPath(plid_t plid); +const char *mutil_GetGameInfo(plid_t plid, ginfo_t tag); +const char *mutil_IsQueryingClientCvar(plid_t plid, const edict_t *pEdict); +int mutil_MakeRequestId(plid_t plid); +void mutil_GetHookTables(plid_t plid, enginefuncs_t **peng, DLL_FUNCTIONS **pdll, NEW_DLL_FUNCTIONS **pnewdll); + +#ifdef UNFINISHED +int mutil_HookGameEvent(plid_t plid, game_event_t event, + event_func_t pfnHandle); +int mutil_HookLogTrigger(plid_t plid, const char *trigger, + logmatch_func_t pfnHandle); +int mutil_HookLogString(plid_t plid, const char *string, + logmatch_func_t pfnHandle); +int mutil_HookLogRegex(plid_t plid, const char *pattern, + logmatch_func_t pfnHandle); + +qboolean mutil_RemoveHookID(plid_t plid, int hookid); +int mutil_RemoveHookAll(plid_t plid); +#endif /* UNFINISHED */ + +// Convenience macros for MetaUtil functions +#define LOG_CONSOLE (*gpMetaUtilFuncs->pfnLogConsole) +#define LOG_MESSAGE (*gpMetaUtilFuncs->pfnLogMessage) +#define LOG_ERROR (*gpMetaUtilFuncs->pfnLogError) +#define LOG_DEVELOPER (*gpMetaUtilFuncs->pfnLogDeveloper) +#define CENTER_SAY (*gpMetaUtilFuncs->pfnCenterSay) +#define CENTER_SAY_PARMS (*gpMetaUtilFuncs->pfnCenterSayParms) +#define CENTER_SAY_VARARGS (*gpMetaUtilFuncs->pfnCenterSayVarargs) +#define CALL_GAME_ENTITY (*gpMetaUtilFuncs->pfnCallGameEntity) +#define GET_USER_MSG_ID (*gpMetaUtilFuncs->pfnGetUserMsgID) +#define GET_USER_MSG_NAME (*gpMetaUtilFuncs->pfnGetUserMsgName) +#define GET_PLUGIN_PATH (*gpMetaUtilFuncs->pfnGetPluginPath) +#define GET_GAME_INFO (*gpMetaUtilFuncs->pfnGetGameInfo) +#define LOAD_PLUGIN (*gpMetaUtilFuncs->pfnLoadPlugin) +#define UNLOAD_PLUGIN (*gpMetaUtilFuncs->pfnUnloadPlugin) +#define UNLOAD_PLUGIN_BY_HANDLE (*gpMetaUtilFuncs->pfnUnloadPluginByHandle) +#define IS_QUERYING_CLIENT_CVAR (*gpMetaUtilFuncs->pfnIsQueryingClientCvar) +#define MAKE_REQUESTID (*gpMetaUtilFuncs->pfnMakeRequestId) +#define GET_HOOK_TABLES (*gpMetaUtilFuncs->pfnGetHookTables) + +#ifdef UNFINISHED +#define HOOK_GAME_EVENT (*gpMetaUtilFuncs->pfnHookGameEvent) +#define HOOK_LOG_TRIGGER (*gpMetaUtilFuncs->pfnHookLogTrigger) +#define HOOK_LOG_STRING (*gpMetaUtilFuncs->pfnHookLogString) +#define HOOK_LOG_REGEX (*gpMetaUtilFuncs->pfnHookLogRegex) +#define REMOVE_HOOK_ID (*gpMetaUtilFuncs->pfnRemoveHookID) +#define REMOVE_HOOK_ALL (*gpMetaUtilFuncs->pfnRemoveHookAll) +#endif /* UNFINISHED */ + +#endif /* MUTIL_H */ diff --git a/revoice/include/osdep.h b/revoice/include/osdep.h index e969616..e11a8b7 100644 --- a/revoice/include/osdep.h +++ b/revoice/include/osdep.h @@ -1,519 +1,519 @@ -// osdep.h - operating system dependencies - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef OSDEP_H -#define OSDEP_H - -#include // strerror() -#include // isupper, tolower -#include // errno - -// Various differences between WIN32 and Linux. - -#include "types_meta.h" // mBOOL -#include "mreg.h" // REG_CMD_FN, etc -#include "log_meta.h" // LOG_ERROR, etc - -extern mBOOL dlclose_handle_invalid; - -// String describing platform/DLL-type, for matching lines in plugins.ini. -#ifdef __linux__ - #define PLATFORM "linux" -# ifdef __amd64__ - #define PLATFORM_SPC "lin64" -# else - #define PLATFORM_SPC "lin32" -# endif -#elif defined(_WIN32) - #define PLATFORM "mswin" - #define PLATFORM_SPC "win32" -#else /* unknown */ - #error "OS unrecognized" -#endif /* unknown */ - - -// Macro for function-exporting from DLL.. -// from SDK dlls/cbase.h: -//! C functions for external declarations that call the appropriate C++ methods - -// Windows uses "__declspec(dllexport)" to mark functions in the DLL that -// should be visible/callable externally. -// -// It also apparently requires WINAPI for GiveFnptrsToDll(). -// -// See doc/notes_windows_coding for more information.. - -// Attributes to specify an "exported" function, visible from outside the -// DLL. -#undef DLLEXPORT -#ifdef _WIN32 - #define DLLEXPORT __declspec(dllexport) - // WINAPI should be provided in the windows compiler headers. - // It's usually defined to something like "__stdcall". -#elif defined(__linux__) - #define DLLEXPORT /* */ - #define WINAPI /* */ -#endif /* linux */ - -#ifdef __GNUC__ -# define DECLSPEC(kw) -# define ATTRIBUTE(kw) __attribute__((kw)) -# define MM_CDECL -#elif defined(_MSC_VER) -# define DECLSPEC(kw) __declspec(kw) -# define ATTRIBUTE(kw) -# define MM_CDECL __cdecl -#endif /* _MSC_VER */ - - -// Simplified macro for declaring/defining exported DLL functions. They -// need to be 'extern "C"' so that the C++ compiler enforces parameter -// type-matching, rather than considering routines with mis-matched -// arguments/types to be overloaded functions... -// -// AFAIK, this is os-independent, but it's included here in osdep.h where -// DLLEXPORT is defined, for convenience. -#define C_DLLEXPORT extern "C" DLLEXPORT - - -#ifdef _MSC_VER - // Disable MSVC warning: - // 4390 : empty controlled statement found; is this what was intended? - // generated by the RETURN macros. - #pragma warning(disable: 4390) -#endif /* _MSC_VER */ - - -// Functions & types for DLL open/close/etc operations. -#ifdef __linux__ - #include - typedef void* DLHANDLE; - typedef void* DLFUNC; - inline DLHANDLE DLOPEN(const char *filename) { - return(dlopen(filename, RTLD_NOW)); - } - inline DLFUNC DLSYM(DLHANDLE handle, const char *string) { - return(dlsym(handle, string)); - } - inline int DLCLOSE(DLHANDLE handle) { - if (!handle) { - dlclose_handle_invalid = mTRUE; - return(1); - } - dlclose_handle_invalid = mFALSE; - return(dlclose(handle)); - } - inline char* DLERROR(void) { - if (dlclose_handle_invalid) - return("Invalid handle."); - return(dlerror()); - } -#elif defined(_WIN32) - typedef HINSTANCE DLHANDLE; - typedef FARPROC DLFUNC; - inline DLHANDLE DLOPEN(const char *filename) { - return(LoadLibrary(filename)); - } - inline DLFUNC DLSYM(DLHANDLE handle, const char *string) { - return(GetProcAddress(handle, string)); - } - inline int DLCLOSE(DLHANDLE handle) { - if (!handle) { - dlclose_handle_invalid = mTRUE; - return(1); - } - dlclose_handle_invalid = mFALSE; - // NOTE: Windows FreeLibrary returns success=nonzero, fail=zero, - // which is the opposite of the unix convention, thus the '!'. - return(!FreeLibrary(handle)); - } - // Windows doesn't provide a function corresponding to dlerror(), so - // we make our own. - char *str_GetLastError(void); - inline char* DLERROR(void) { - if (dlclose_handle_invalid) - return("Invalid handle."); - return(str_GetLastError()); - } -#endif /* _WIN32 */ -const char *DLFNAME(void *memptr); -mBOOL IS_VALID_PTR(void *memptr); - - -// Attempt to call the given function pointer, without segfaulting. -mBOOL os_safe_call(REG_CMD_FN pfn); - - -// Windows doesn't have an strtok_r() routine, so we write our own. -#ifdef _WIN32 - #define strtok_r(s, delim, ptrptr) my_strtok_r(s, delim, ptrptr) - char *my_strtok_r(char *s, const char *delim, char **ptrptr); -#endif /* _WIN32 */ - - -// Set filename and pathname maximum lengths. Note some windows compilers -// provide a which is incomplete and/or causes problems; see -// doc/windows_notes.txt for more information. -// -// Note that both OS's include room for null-termination: -// linux: "# chars in a path name including nul" -// win32: "note that the sizes include space for 0-terminator" -#ifdef __linux__ - #include -#elif defined(_WIN32) - #include - #define NAME_MAX _MAX_FNAME - #define PATH_MAX _MAX_PATH -#endif /* _WIN32 */ - - -// Various other windows routine differences. -#ifdef __linux__ - #include // sleep - #ifndef O_BINARY - #define O_BINARY 0 - #endif -#elif defined(_WIN32) - #define snprintf _snprintf - #define vsnprintf _vsnprintf - #define sleep(x) Sleep(x*1000) - #define strcasecmp _stricmp - #define strncasecmp _strnicmp - #include - #define open _open - #define read _read - #define write _write - #define close _close -#endif /* _WIN32 */ - -#ifdef __GNUC__ - #include // getcwd -#elif defined(_MSC_VER) - #include // getcwd -#endif /* _MSC_VER */ - -#include -#ifndef S_ISREG - // Linux gcc defines this; earlier mingw didn't, later mingw does; - // MSVC doesn't seem to. - #define S_ISREG(m) ((m) & S_IFREG) -#endif /* not S_ISREG */ -#ifdef _WIN32 - // The following two are defined in mingw but not in MSVC - #ifndef S_IRUSR - #define S_IRUSR _S_IREAD - #endif - #ifndef S_IWUSR - #define S_IWUSR _S_IWRITE - #endif - - // The following two are defined neither in mingw nor in MSVC - #ifndef S_IRGRP - #define S_IRGRP S_IRUSR - #endif - #ifndef S_IWGRP - #define S_IWGRP S_IWUSR - #endif -#endif /* _WIN32 */ - - -// Our handler for new(). -// -// Thanks to notes from: -// http://dragon.klte.hu/~kollarl/C++/node45.html -// -// At one point it appeared MSVC++ was no longer different from gcc, according -// to: -// http://msdn.microsoft.com/library/en-us/vclang98/stdlib/info/NEW.asp -// -// However, this page is apparently no longer available from MSDN. The -// only thing now is: -// http://msdn.microsoft.com/library/en-us/vccore98/HTML/_crt_malloc.asp -// -// According to Fritz Elfert : -// set_new_handler() is just a stub which (according to comments in the -// MSVCRT debugging sources) should never be used. It is just an ugly -// hack to make STL compile. It does _not_ set the new handler but -// always calls _set_new_handler(0) instead. _set_new_handler is the -// "real" function and uses the "old" semantic; handler-type is: -// int newhandler(size_t) -// -#if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 1300)) - void MM_CDECL meta_new_handler(void); -#elif defined(_MSC_VER) - int meta_new_handler(size_t size); -#endif /* _MSC_VER */ - - -// To keep the rest of the sources clean and keep not only OS but also -// compiler dependant differences in this file, we define a local function -// to set the new handler. -void mm_set_new_handler( void ); - - - -// Thread handling... -#ifdef __linux__ - #include - typedef pthread_t THREAD_T; - // returns 0==success, non-zero==failure - inline int THREAD_CREATE(THREAD_T *tid, void (*func)(void)) { - int ret; - ret=pthread_create(tid, NULL, (void *(*)(void*)) func, NULL); - if(ret != 0) { - META_ERROR("Failure starting thread: %s", strerror(ret)); - return(ret); - } - ret=pthread_detach(*tid); - if(ret != 0) - META_ERROR("Failure detaching thread: %s", strerror(ret)); - return(ret); - } -#elif defined(_WIN32) - // See: - // http://msdn.microsoft.com/library/en-us/dllproc/prothred_4084.asp - typedef DWORD THREAD_T; - // returns 0==success, non-zero==failure - inline int THREAD_CREATE(THREAD_T *tid, void (*func)(void)) { - HANDLE ret; - // win32 returns NULL==failure, non-NULL==success - ret=CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) func, NULL, 0, tid); - if(ret==NULL) - META_ERROR("Failure starting thread: %s", str_GetLastError()); - return(ret==NULL); - } -#endif /* _WIN32 */ -#define THREAD_OK 0 - - -// Mutex handling... -#ifdef __linux__ - typedef pthread_mutex_t MUTEX_T; - inline int MUTEX_INIT(MUTEX_T *mutex) { - int ret; - ret=pthread_mutex_init(mutex, NULL); - if(ret!=THREAD_OK) - META_ERROR("mutex_init failed: %s", strerror(ret)); - return(ret); - } - inline int MUTEX_LOCK(MUTEX_T *mutex) { - int ret; - ret=pthread_mutex_lock(mutex); - if(ret!=THREAD_OK) - META_ERROR("mutex_lock failed: %s", strerror(ret)); - return(ret); - } - inline int MUTEX_UNLOCK(MUTEX_T *mutex) { - int ret; - ret=pthread_mutex_unlock(mutex); - if(ret!=THREAD_OK) - META_ERROR("mutex_unlock failed: %s", strerror(ret)); - return(ret); - } -#elif defined(_WIN32) - // Win32 has "mutexes" as well, but CS's are simpler. - // See: - // http://msdn.microsoft.com/library/en-us/dllproc/synchro_2a2b.asp - typedef CRITICAL_SECTION MUTEX_T; - // Note win32 routines don't return any error (return void). - inline int MUTEX_INIT(MUTEX_T *mutex) { - InitializeCriticalSection(mutex); - return(THREAD_OK); - } - inline int MUTEX_LOCK(MUTEX_T *mutex) { - EnterCriticalSection(mutex); - return(THREAD_OK); - } - inline int MUTEX_UNLOCK(MUTEX_T *mutex) { - LeaveCriticalSection(mutex); - return(THREAD_OK); - } -#endif /* _WIN32 (mutex) */ - - -// Condition variables... -#ifdef __linux__ - typedef pthread_cond_t COND_T; - inline int COND_INIT(COND_T *cond) { - int ret; - ret=pthread_cond_init(cond, NULL); - if(ret!=THREAD_OK) - META_ERROR("cond_init failed: %s", strerror(ret)); - return(ret); - } - inline int COND_WAIT(COND_T *cond, MUTEX_T *mutex) { - int ret; - ret=pthread_cond_wait(cond, mutex); - if(ret!=THREAD_OK) - META_ERROR("cond_wait failed: %s", strerror(ret)); - return(ret); - } - inline int COND_SIGNAL(COND_T *cond) { - int ret; - ret=pthread_cond_signal(cond); - if(ret!=THREAD_OK) - META_ERROR("cond_signal failed: %s", strerror(ret)); - return(ret); - } -#elif defined(_WIN32) - // Since win32 doesn't provide condition-variables, we have to model - // them with mutex/critical-sections and win32 events. This uses the - // second (SetEvent) solution from: - // - // http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - // - // but without the waiters_count overhead, since we don't need - // broadcast functionality anyway. Or actually, I guess it's more like - // the first (PulseEvent) solution, but with SetEven rather than - // PulseEvent. :) - // - // See also: - // http://msdn.microsoft.com/library/en-us/dllproc/synchro_8ann.asp - typedef HANDLE COND_T; - inline int COND_INIT(COND_T *cond) { - *cond = CreateEvent(NULL, // security attributes (none) - FALSE, // manual-reset type (false==auto-reset) - FALSE, // initial state (unsignaled) - NULL); // object name (unnamed) - // returns NULL on error - if(*cond==NULL) { - META_ERROR("cond_init failed: %s", str_GetLastError()); - return(-1); - } - else - return(0); - } - inline int COND_WAIT(COND_T *cond, MUTEX_T *mutex) { - DWORD ret; - LeaveCriticalSection(mutex); - ret=WaitForSingleObject(*cond, INFINITE); - EnterCriticalSection(mutex); - // returns WAIT_OBJECT_0 if object was signaled; other return - // values indicate errors. - if(ret == WAIT_OBJECT_0) - return(0); - else { - META_ERROR("cond_wait failed: %s", str_GetLastError()); - return(-1); - } - } - inline int COND_SIGNAL(COND_T *cond) { - BOOL ret; - ret=SetEvent(*cond); - // returns zero on failure - if(ret==0) { - META_ERROR("cond_signal failed: %s", str_GetLastError()); - return(-1); - } - else - return(0); - } -#endif /* _WIN32 (condition variable) */ - -// Normalize/standardize a pathname. -// - For win32, this involves: -// - Turning backslashes (\) into slashes (/), so that config files and -// Metamod internal code can be simpler and just use slashes (/). -// - Turning upper/mixed case into lowercase, since windows is -// non-case-sensitive. -// - For linux, this requires no work, as paths uses slashes (/) natively, -// and pathnames are case-sensitive. -#ifdef __linux__ -#define normalize_pathname(a) -#elif defined(_WIN32) -inline void normalize_pathname(char *path) { - char *cp; - - META_DEBUG(8, ("normalize: %s", path)); - for(cp=path; *cp; cp++) { - if(isupper(*cp)) *cp=tolower(*cp); - if(*cp=='\\') *cp='/'; - } - META_DEBUG(8, ("normalized: %s", path)); -} -#endif /* _WIN32 */ - -// Indicate if pathname appears to be an absolute-path. Under linux this -// is a leading slash (/). Under win32, this can be: -// - a drive-letter path (ie "D:blah" or "C:\blah") -// - a toplevel path (ie "\blah") -// - a UNC network address (ie "\\srv1\blah"). -// Also, handle both native and normalized pathnames. -inline int is_absolute_path(const char *path) { - if(path[0]=='/') return(TRUE); -#ifdef _WIN32 - if(path[1]==':') return(TRUE); - if(path[0]=='\\') return(TRUE); -#endif /* _WIN32 */ - return(FALSE); -} - -#ifdef _WIN32 -// Buffer pointed to by resolved_name is assumed to be able to store a -// string of PATH_MAX length. -inline char *realpath(const char *file_name, char *resolved_name) { - int ret; - ret=GetFullPathName(file_name, PATH_MAX, resolved_name, NULL); - if(ret > PATH_MAX) { - errno=ENAMETOOLONG; - return(NULL); - } - else if(ret > 0) { - HANDLE handle; - WIN32_FIND_DATA find_data; - handle=FindFirstFile(resolved_name, &find_data); - if(INVALID_HANDLE_VALUE == handle) { - errno=ENOENT; - return NULL; - } - FindClose(handle); - normalize_pathname(resolved_name); - return(resolved_name); - } - else - return(NULL); -} -#endif /* _WIN32 */ - -// Generic "error string" from a recent OS call. For linux, this is based -// on errno. For win32, it's based on GetLastError. -inline const char *str_os_error(void) { -#ifdef __linux__ - return(strerror(errno)); -#elif defined(_WIN32) - return(str_GetLastError()); -#endif /* _WIN32 */ -} - - -#endif /* OSDEP_H */ +// osdep.h - operating system dependencies + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef OSDEP_H +#define OSDEP_H + +#include // strerror() +#include // isupper, tolower +#include // errno + +// Various differences between WIN32 and Linux. + +#include "types_meta.h" // mBOOL +#include "mreg.h" // REG_CMD_FN, etc +#include "log_meta.h" // LOG_ERROR, etc + +extern mBOOL dlclose_handle_invalid; + +// String describing platform/DLL-type, for matching lines in plugins.ini. +#ifdef __linux__ + #define PLATFORM "linux" +# ifdef __amd64__ + #define PLATFORM_SPC "lin64" +# else + #define PLATFORM_SPC "lin32" +# endif +#elif defined(_WIN32) + #define PLATFORM "mswin" + #define PLATFORM_SPC "win32" +#else /* unknown */ + #error "OS unrecognized" +#endif /* unknown */ + + +// Macro for function-exporting from DLL.. +// from SDK dlls/cbase.h: +//! C functions for external declarations that call the appropriate C++ methods + +// Windows uses "__declspec(dllexport)" to mark functions in the DLL that +// should be visible/callable externally. +// +// It also apparently requires WINAPI for GiveFnptrsToDll(). +// +// See doc/notes_windows_coding for more information.. + +// Attributes to specify an "exported" function, visible from outside the +// DLL. +#undef DLLEXPORT +#ifdef _WIN32 + #define DLLEXPORT __declspec(dllexport) + // WINAPI should be provided in the windows compiler headers. + // It's usually defined to something like "__stdcall". +#elif defined(__linux__) + #define DLLEXPORT /* */ + #define WINAPI /* */ +#endif /* linux */ + +#ifdef __GNUC__ +# define DECLSPEC(kw) +# define ATTRIBUTE(kw) __attribute__((kw)) +# define MM_CDECL +#elif defined(_MSC_VER) +# define DECLSPEC(kw) __declspec(kw) +# define ATTRIBUTE(kw) +# define MM_CDECL __cdecl +#endif /* _MSC_VER */ + + +// Simplified macro for declaring/defining exported DLL functions. They +// need to be 'extern "C"' so that the C++ compiler enforces parameter +// type-matching, rather than considering routines with mis-matched +// arguments/types to be overloaded functions... +// +// AFAIK, this is os-independent, but it's included here in osdep.h where +// DLLEXPORT is defined, for convenience. +#define C_DLLEXPORT extern "C" DLLEXPORT + + +#ifdef _MSC_VER + // Disable MSVC warning: + // 4390 : empty controlled statement found; is this what was intended? + // generated by the RETURN macros. + #pragma warning(disable: 4390) +#endif /* _MSC_VER */ + + +// Functions & types for DLL open/close/etc operations. +#ifdef __linux__ + #include + typedef void* DLHANDLE; + typedef void* DLFUNC; + inline DLHANDLE DLOPEN(const char *filename) { + return(dlopen(filename, RTLD_NOW)); + } + inline DLFUNC DLSYM(DLHANDLE handle, const char *string) { + return(dlsym(handle, string)); + } + inline int DLCLOSE(DLHANDLE handle) { + if (!handle) { + dlclose_handle_invalid = mTRUE; + return(1); + } + dlclose_handle_invalid = mFALSE; + return(dlclose(handle)); + } + inline char* DLERROR(void) { + if (dlclose_handle_invalid) + return("Invalid handle."); + return(dlerror()); + } +#elif defined(_WIN32) + typedef HINSTANCE DLHANDLE; + typedef FARPROC DLFUNC; + inline DLHANDLE DLOPEN(const char *filename) { + return(LoadLibrary(filename)); + } + inline DLFUNC DLSYM(DLHANDLE handle, const char *string) { + return(GetProcAddress(handle, string)); + } + inline int DLCLOSE(DLHANDLE handle) { + if (!handle) { + dlclose_handle_invalid = mTRUE; + return(1); + } + dlclose_handle_invalid = mFALSE; + // NOTE: Windows FreeLibrary returns success=nonzero, fail=zero, + // which is the opposite of the unix convention, thus the '!'. + return(!FreeLibrary(handle)); + } + // Windows doesn't provide a function corresponding to dlerror(), so + // we make our own. + char *str_GetLastError(void); + inline char* DLERROR(void) { + if (dlclose_handle_invalid) + return("Invalid handle."); + return(str_GetLastError()); + } +#endif /* _WIN32 */ +const char *DLFNAME(void *memptr); +mBOOL IS_VALID_PTR(void *memptr); + + +// Attempt to call the given function pointer, without segfaulting. +mBOOL os_safe_call(REG_CMD_FN pfn); + + +// Windows doesn't have an strtok_r() routine, so we write our own. +#ifdef _WIN32 + #define strtok_r(s, delim, ptrptr) my_strtok_r(s, delim, ptrptr) + char *my_strtok_r(char *s, const char *delim, char **ptrptr); +#endif /* _WIN32 */ + + +// Set filename and pathname maximum lengths. Note some windows compilers +// provide a which is incomplete and/or causes problems; see +// doc/windows_notes.txt for more information. +// +// Note that both OS's include room for null-termination: +// linux: "# chars in a path name including nul" +// win32: "note that the sizes include space for 0-terminator" +#ifdef __linux__ + #include +#elif defined(_WIN32) + #include + #define NAME_MAX _MAX_FNAME + #define PATH_MAX _MAX_PATH +#endif /* _WIN32 */ + + +// Various other windows routine differences. +#ifdef __linux__ + #include // sleep + #ifndef O_BINARY + #define O_BINARY 0 + #endif +#elif defined(_WIN32) + #define snprintf _snprintf + #define vsnprintf _vsnprintf + #define sleep(x) Sleep(x*1000) + #define strcasecmp _stricmp + #define strncasecmp _strnicmp + #include + #define open _open + #define read _read + #define write _write + #define close _close +#endif /* _WIN32 */ + +#ifdef __GNUC__ + #include // getcwd +#elif defined(_MSC_VER) + #include // getcwd +#endif /* _MSC_VER */ + +#include +#ifndef S_ISREG + // Linux gcc defines this; earlier mingw didn't, later mingw does; + // MSVC doesn't seem to. + #define S_ISREG(m) ((m) & S_IFREG) +#endif /* not S_ISREG */ +#ifdef _WIN32 + // The following two are defined in mingw but not in MSVC + #ifndef S_IRUSR + #define S_IRUSR _S_IREAD + #endif + #ifndef S_IWUSR + #define S_IWUSR _S_IWRITE + #endif + + // The following two are defined neither in mingw nor in MSVC + #ifndef S_IRGRP + #define S_IRGRP S_IRUSR + #endif + #ifndef S_IWGRP + #define S_IWGRP S_IWUSR + #endif +#endif /* _WIN32 */ + + +// Our handler for new(). +// +// Thanks to notes from: +// http://dragon.klte.hu/~kollarl/C++/node45.html +// +// At one point it appeared MSVC++ was no longer different from gcc, according +// to: +// http://msdn.microsoft.com/library/en-us/vclang98/stdlib/info/NEW.asp +// +// However, this page is apparently no longer available from MSDN. The +// only thing now is: +// http://msdn.microsoft.com/library/en-us/vccore98/HTML/_crt_malloc.asp +// +// According to Fritz Elfert : +// set_new_handler() is just a stub which (according to comments in the +// MSVCRT debugging sources) should never be used. It is just an ugly +// hack to make STL compile. It does _not_ set the new handler but +// always calls _set_new_handler(0) instead. _set_new_handler is the +// "real" function and uses the "old" semantic; handler-type is: +// int newhandler(size_t) +// +#if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 1300)) + void MM_CDECL meta_new_handler(void); +#elif defined(_MSC_VER) + int meta_new_handler(size_t size); +#endif /* _MSC_VER */ + + +// To keep the rest of the sources clean and keep not only OS but also +// compiler dependant differences in this file, we define a local function +// to set the new handler. +void mm_set_new_handler( void ); + + + +// Thread handling... +#ifdef __linux__ + #include + typedef pthread_t THREAD_T; + // returns 0==success, non-zero==failure + inline int THREAD_CREATE(THREAD_T *tid, void (*func)(void)) { + int ret; + ret=pthread_create(tid, NULL, (void *(*)(void*)) func, NULL); + if(ret != 0) { + META_ERROR("Failure starting thread: %s", strerror(ret)); + return(ret); + } + ret=pthread_detach(*tid); + if(ret != 0) + META_ERROR("Failure detaching thread: %s", strerror(ret)); + return(ret); + } +#elif defined(_WIN32) + // See: + // http://msdn.microsoft.com/library/en-us/dllproc/prothred_4084.asp + typedef DWORD THREAD_T; + // returns 0==success, non-zero==failure + inline int THREAD_CREATE(THREAD_T *tid, void (*func)(void)) { + HANDLE ret; + // win32 returns NULL==failure, non-NULL==success + ret=CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) func, NULL, 0, tid); + if(ret==NULL) + META_ERROR("Failure starting thread: %s", str_GetLastError()); + return(ret==NULL); + } +#endif /* _WIN32 */ +#define THREAD_OK 0 + + +// Mutex handling... +#ifdef __linux__ + typedef pthread_mutex_t MUTEX_T; + inline int MUTEX_INIT(MUTEX_T *mutex) { + int ret; + ret=pthread_mutex_init(mutex, NULL); + if(ret!=THREAD_OK) + META_ERROR("mutex_init failed: %s", strerror(ret)); + return(ret); + } + inline int MUTEX_LOCK(MUTEX_T *mutex) { + int ret; + ret=pthread_mutex_lock(mutex); + if(ret!=THREAD_OK) + META_ERROR("mutex_lock failed: %s", strerror(ret)); + return(ret); + } + inline int MUTEX_UNLOCK(MUTEX_T *mutex) { + int ret; + ret=pthread_mutex_unlock(mutex); + if(ret!=THREAD_OK) + META_ERROR("mutex_unlock failed: %s", strerror(ret)); + return(ret); + } +#elif defined(_WIN32) + // Win32 has "mutexes" as well, but CS's are simpler. + // See: + // http://msdn.microsoft.com/library/en-us/dllproc/synchro_2a2b.asp + typedef CRITICAL_SECTION MUTEX_T; + // Note win32 routines don't return any error (return void). + inline int MUTEX_INIT(MUTEX_T *mutex) { + InitializeCriticalSection(mutex); + return(THREAD_OK); + } + inline int MUTEX_LOCK(MUTEX_T *mutex) { + EnterCriticalSection(mutex); + return(THREAD_OK); + } + inline int MUTEX_UNLOCK(MUTEX_T *mutex) { + LeaveCriticalSection(mutex); + return(THREAD_OK); + } +#endif /* _WIN32 (mutex) */ + + +// Condition variables... +#ifdef __linux__ + typedef pthread_cond_t COND_T; + inline int COND_INIT(COND_T *cond) { + int ret; + ret=pthread_cond_init(cond, NULL); + if(ret!=THREAD_OK) + META_ERROR("cond_init failed: %s", strerror(ret)); + return(ret); + } + inline int COND_WAIT(COND_T *cond, MUTEX_T *mutex) { + int ret; + ret=pthread_cond_wait(cond, mutex); + if(ret!=THREAD_OK) + META_ERROR("cond_wait failed: %s", strerror(ret)); + return(ret); + } + inline int COND_SIGNAL(COND_T *cond) { + int ret; + ret=pthread_cond_signal(cond); + if(ret!=THREAD_OK) + META_ERROR("cond_signal failed: %s", strerror(ret)); + return(ret); + } +#elif defined(_WIN32) + // Since win32 doesn't provide condition-variables, we have to model + // them with mutex/critical-sections and win32 events. This uses the + // second (SetEvent) solution from: + // + // http://www.cs.wustl.edu/~schmidt/win32-cv-1.html + // + // but without the waiters_count overhead, since we don't need + // broadcast functionality anyway. Or actually, I guess it's more like + // the first (PulseEvent) solution, but with SetEven rather than + // PulseEvent. :) + // + // See also: + // http://msdn.microsoft.com/library/en-us/dllproc/synchro_8ann.asp + typedef HANDLE COND_T; + inline int COND_INIT(COND_T *cond) { + *cond = CreateEvent(NULL, // security attributes (none) + FALSE, // manual-reset type (false==auto-reset) + FALSE, // initial state (unsignaled) + NULL); // object name (unnamed) + // returns NULL on error + if(*cond==NULL) { + META_ERROR("cond_init failed: %s", str_GetLastError()); + return(-1); + } + else + return(0); + } + inline int COND_WAIT(COND_T *cond, MUTEX_T *mutex) { + DWORD ret; + LeaveCriticalSection(mutex); + ret=WaitForSingleObject(*cond, INFINITE); + EnterCriticalSection(mutex); + // returns WAIT_OBJECT_0 if object was signaled; other return + // values indicate errors. + if(ret == WAIT_OBJECT_0) + return(0); + else { + META_ERROR("cond_wait failed: %s", str_GetLastError()); + return(-1); + } + } + inline int COND_SIGNAL(COND_T *cond) { + BOOL ret; + ret=SetEvent(*cond); + // returns zero on failure + if(ret==0) { + META_ERROR("cond_signal failed: %s", str_GetLastError()); + return(-1); + } + else + return(0); + } +#endif /* _WIN32 (condition variable) */ + +// Normalize/standardize a pathname. +// - For win32, this involves: +// - Turning backslashes (\) into slashes (/), so that config files and +// Metamod internal code can be simpler and just use slashes (/). +// - Turning upper/mixed case into lowercase, since windows is +// non-case-sensitive. +// - For linux, this requires no work, as paths uses slashes (/) natively, +// and pathnames are case-sensitive. +#ifdef __linux__ +#define normalize_pathname(a) +#elif defined(_WIN32) +inline void normalize_pathname(char *path) { + char *cp; + + META_DEBUG(8, ("normalize: %s", path)); + for(cp=path; *cp; cp++) { + if(isupper(*cp)) *cp=tolower(*cp); + if(*cp=='\\') *cp='/'; + } + META_DEBUG(8, ("normalized: %s", path)); +} +#endif /* _WIN32 */ + +// Indicate if pathname appears to be an absolute-path. Under linux this +// is a leading slash (/). Under win32, this can be: +// - a drive-letter path (ie "D:blah" or "C:\blah") +// - a toplevel path (ie "\blah") +// - a UNC network address (ie "\\srv1\blah"). +// Also, handle both native and normalized pathnames. +inline int is_absolute_path(const char *path) { + if(path[0]=='/') return(TRUE); +#ifdef _WIN32 + if(path[1]==':') return(TRUE); + if(path[0]=='\\') return(TRUE); +#endif /* _WIN32 */ + return(FALSE); +} + +#ifdef _WIN32 +// Buffer pointed to by resolved_name is assumed to be able to store a +// string of PATH_MAX length. +inline char *realpath(const char *file_name, char *resolved_name) { + int ret; + ret=GetFullPathName(file_name, PATH_MAX, resolved_name, NULL); + if(ret > PATH_MAX) { + errno=ENAMETOOLONG; + return(NULL); + } + else if(ret > 0) { + HANDLE handle; + WIN32_FIND_DATA find_data; + handle=FindFirstFile(resolved_name, &find_data); + if(INVALID_HANDLE_VALUE == handle) { + errno=ENOENT; + return NULL; + } + FindClose(handle); + normalize_pathname(resolved_name); + return(resolved_name); + } + else + return(NULL); +} +#endif /* _WIN32 */ + +// Generic "error string" from a recent OS call. For linux, this is based +// on errno. For win32, it's based on GetLastError. +inline const char *str_os_error(void) { +#ifdef __linux__ + return(strerror(errno)); +#elif defined(_WIN32) + return(str_GetLastError()); +#endif /* _WIN32 */ +} + + +#endif /* OSDEP_H */ diff --git a/revoice/include/plinfo.h b/revoice/include/plinfo.h index f781864..9e5b744 100644 --- a/revoice/include/plinfo.h +++ b/revoice/include/plinfo.h @@ -1,79 +1,79 @@ -// plinfo.h - typedefs for plugin info structure - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef PLINFO_H -#define PLINFO_H - -// Flags for plugin to indicate when it can be be loaded/unloaded. -// NOTE: order is crucial, as greater/less comparisons are made. -typedef enum { - PT_NEVER = 0, - PT_STARTUP, // should only be loaded/unloaded at initial hlds execution - PT_CHANGELEVEL, // can be loaded/unloaded between maps - PT_ANYTIME, // can be loaded/unloaded at any time - PT_ANYPAUSE, // can be loaded/unloaded at any time, and can be "paused" during a map -} PLUG_LOADTIME; - -// Flags to indicate why the plugin is being unloaded. -typedef enum { - PNL_NULL = 0, - PNL_INI_DELETED, // was deleted from plugins.ini - PNL_FILE_NEWER, // file on disk is newer than last load - PNL_COMMAND, // requested by server/console command - PNL_CMD_FORCED, // forced by server/console command - PNL_DELAYED, // delayed from previous request; can't tell origin -//only used for 'real_reason' on MPlugin::unload() - PNL_PLUGIN, // requested by plugin function call - PNL_PLG_FORCED, // forced by plugin function call - PNL_RELOAD, // forced unload by reload() -} PL_UNLOAD_REASON; - -// Information plugin provides about itself. -typedef struct { - char *ifvers; // meta_interface version - char *name; // full name of plugin - char *version; // version - char *date; // date - char *author; // author name/email - char *url; // URL - char *logtag; // log message prefix (unused right now) - PLUG_LOADTIME loadable; // when loadable - PLUG_LOADTIME unloadable; // when unloadable -} plugin_info_t; -extern plugin_info_t Plugin_info; - -// Plugin identifier, passed to all Meta Utility Functions. -typedef plugin_info_t* plid_t; -#define PLID &Plugin_info - -#endif /* PLINFO_H */ +// plinfo.h - typedefs for plugin info structure + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef PLINFO_H +#define PLINFO_H + +// Flags for plugin to indicate when it can be be loaded/unloaded. +// NOTE: order is crucial, as greater/less comparisons are made. +typedef enum { + PT_NEVER = 0, + PT_STARTUP, // should only be loaded/unloaded at initial hlds execution + PT_CHANGELEVEL, // can be loaded/unloaded between maps + PT_ANYTIME, // can be loaded/unloaded at any time + PT_ANYPAUSE, // can be loaded/unloaded at any time, and can be "paused" during a map +} PLUG_LOADTIME; + +// Flags to indicate why the plugin is being unloaded. +typedef enum { + PNL_NULL = 0, + PNL_INI_DELETED, // was deleted from plugins.ini + PNL_FILE_NEWER, // file on disk is newer than last load + PNL_COMMAND, // requested by server/console command + PNL_CMD_FORCED, // forced by server/console command + PNL_DELAYED, // delayed from previous request; can't tell origin +//only used for 'real_reason' on MPlugin::unload() + PNL_PLUGIN, // requested by plugin function call + PNL_PLG_FORCED, // forced by plugin function call + PNL_RELOAD, // forced unload by reload() +} PL_UNLOAD_REASON; + +// Information plugin provides about itself. +typedef struct { + char *ifvers; // meta_interface version + char *name; // full name of plugin + char *version; // version + char *date; // date + char *author; // author name/email + char *url; // URL + char *logtag; // log message prefix (unused right now) + PLUG_LOADTIME loadable; // when loadable + PLUG_LOADTIME unloadable; // when unloadable +} plugin_info_t; +extern plugin_info_t Plugin_info; + +// Plugin identifier, passed to all Meta Utility Functions. +typedef plugin_info_t* plid_t; +#define PLID &Plugin_info + +#endif /* PLINFO_H */ diff --git a/revoice/include/sdk_util.h b/revoice/include/sdk_util.h index 9a997f6..5b70010 100644 --- a/revoice/include/sdk_util.h +++ b/revoice/include/sdk_util.h @@ -1,112 +1,112 @@ -// sdk_util.h - wrapper & extension of util.h from HL SDK - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -// Wrap util.h from SDK with ifndef/endif, to avoid problems from multiple -// inclusions. Dunno why Valve didn't do that in util.h themselves.. - -#ifndef SDK_UTIL_H -#define SDK_UTIL_H - -// We're not including the DBG_EntOfVars and DBG_AssertFunction routines -// mentioned in the SDK util.h, so we're going to unset DEBUG here so that -// we don't get "unresolved symbol" errors. -#ifdef DEBUG -#undef DEBUG -#endif /* DEBUG */ - -// Inlcude local enginecallbacks wrapper *first* so that the g_engfuncs -// type is correct and the header protection is already -// defined. -#include "enginecallbacks.h" - -#include - - - -// Add overloaded ENTINDEX() version for const edict_t pointer. -// The pfnIndexOfEdict() function takes a const edict_t pointer -// as parameter anyway, so there is no reason why ENTINDEX() -// shouldn't. -inline int ENTINDEX(const edict_t *pEdict) { - return (*g_engfuncs.pfnIndexOfEdict)(pEdict); -} - - -// Also, create some nice inlines for engine callback combos. - -// Get a setinfo value from a player entity. -inline char *ENTITY_KEYVALUE(edict_t *entity, char *key) { - char *ifbuf=GET_INFOKEYBUFFER(entity); - return(INFOKEY_VALUE(ifbuf, key)); -} - -// Set a setinfo value for a player entity. -inline void ENTITY_SET_KEYVALUE(edict_t *entity, char *key, char *value) { - char *ifbuf=GET_INFOKEYBUFFER(entity); - SET_CLIENT_KEYVALUE(ENTINDEX(entity), ifbuf, key, value); -} - -// Get a "serverinfo" value. -inline char *SERVERINFO(char *key) { - edict_t *server=INDEXENT(0); - return(ENTITY_KEYVALUE(server, key)); -} - -// Set a "serverinfo" value. -inline void SET_SERVERINFO(char *key, char *value) { - edict_t *server=INDEXENT(0); - char *ifbuf=GET_INFOKEYBUFFER(server); - SET_SERVER_KEYVALUE(ifbuf, key, value); -} - -// Get a "localinfo" value. -inline char *LOCALINFO(char *key) { - edict_t *server=NULL; - return(ENTITY_KEYVALUE(server, key)); -} - -// Set a "localinfo" value. -inline void SET_LOCALINFO(char *key, char *value) { - edict_t *server=NULL; - char *ifbuf=GET_INFOKEYBUFFER(server); - SET_SERVER_KEYVALUE(ifbuf, key, value); -} - -short FixedSigned16(float value, float scale); -unsigned short FixedUnsigned16(float value, float scale); - -// Our slightly modified version, using an edict_t pointer instead of a -// CBaseEntity pointer. -void META_UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, const char *pMessage); - -#endif /* SDK_UTIL_H */ +// sdk_util.h - wrapper & extension of util.h from HL SDK + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +// Wrap util.h from SDK with ifndef/endif, to avoid problems from multiple +// inclusions. Dunno why Valve didn't do that in util.h themselves.. + +#ifndef SDK_UTIL_H +#define SDK_UTIL_H + +// We're not including the DBG_EntOfVars and DBG_AssertFunction routines +// mentioned in the SDK util.h, so we're going to unset DEBUG here so that +// we don't get "unresolved symbol" errors. +#ifdef DEBUG +#undef DEBUG +#endif /* DEBUG */ + +// Inlcude local enginecallbacks wrapper *first* so that the g_engfuncs +// type is correct and the header protection is already +// defined. +#include "enginecallbacks.h" + +#include + + + +// Add overloaded ENTINDEX() version for const edict_t pointer. +// The pfnIndexOfEdict() function takes a const edict_t pointer +// as parameter anyway, so there is no reason why ENTINDEX() +// shouldn't. +inline int ENTINDEX(const edict_t *pEdict) { + return (*g_engfuncs.pfnIndexOfEdict)(pEdict); +} + + +// Also, create some nice inlines for engine callback combos. + +// Get a setinfo value from a player entity. +inline char *ENTITY_KEYVALUE(edict_t *entity, char *key) { + char *ifbuf=GET_INFOKEYBUFFER(entity); + return(INFOKEY_VALUE(ifbuf, key)); +} + +// Set a setinfo value for a player entity. +inline void ENTITY_SET_KEYVALUE(edict_t *entity, char *key, char *value) { + char *ifbuf=GET_INFOKEYBUFFER(entity); + SET_CLIENT_KEYVALUE(ENTINDEX(entity), ifbuf, key, value); +} + +// Get a "serverinfo" value. +inline char *SERVERINFO(char *key) { + edict_t *server=INDEXENT(0); + return(ENTITY_KEYVALUE(server, key)); +} + +// Set a "serverinfo" value. +inline void SET_SERVERINFO(char *key, char *value) { + edict_t *server=INDEXENT(0); + char *ifbuf=GET_INFOKEYBUFFER(server); + SET_SERVER_KEYVALUE(ifbuf, key, value); +} + +// Get a "localinfo" value. +inline char *LOCALINFO(char *key) { + edict_t *server=NULL; + return(ENTITY_KEYVALUE(server, key)); +} + +// Set a "localinfo" value. +inline void SET_LOCALINFO(char *key, char *value) { + edict_t *server=NULL; + char *ifbuf=GET_INFOKEYBUFFER(server); + SET_SERVER_KEYVALUE(ifbuf, key, value); +} + +short FixedSigned16(float value, float scale); +unsigned short FixedUnsigned16(float value, float scale); + +// Our slightly modified version, using an edict_t pointer instead of a +// CBaseEntity pointer. +void META_UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, const char *pMessage); + +#endif /* SDK_UTIL_H */ diff --git a/revoice/include/types_meta.h b/revoice/include/types_meta.h index db4a226..6f5bb5d 100644 --- a/revoice/include/types_meta.h +++ b/revoice/include/types_meta.h @@ -1,79 +1,79 @@ -// types_meta.h - common internal type, etc definitions - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#ifndef TYPES_META_H -#define TYPES_META_H - -// Our own boolean type, for stricter type matching. -typedef enum mBOOL { - mFALSE = 0, - mTRUE, -} mBOOL; - -// Like C's errno, for our various functions; describes causes of failure -// or mFALSE returns. -typedef enum { - ME_NOERROR = 0, - ME_FORMAT, // invalid format - ME_COMMENT, // ignored comment - ME_BLANK, // ignored blank (empty) line - ME_ALREADY, // request had already been done - ME_DELAYED, // request is delayed - ME_NOTALLOWED, // request not allowed - ME_SKIPPED, // request is being skipped for whatever reason - ME_BADREQ, // invalid request for this - ME_ARGUMENT, // invalid arguments - ME_NULLRESULT, // resulting data was empty or null - ME_MAXREACHED, // reached max/limit - ME_NOTUNIQ, // not unique (ambigious match) - ME_NOTFOUND, // in find operation, match not found - ME_NOFILE, // file empty or missing - ME_NOMEM, // malloc failed - ME_BADMEMPTR, // invalid memory address - ME_OSNOTSUP, // OS doesn't support this operation - ME_DLOPEN, // failed to open shared lib/dll - ME_DLMISSING, // symbol missing in lib/dll - ME_DLERROR, // some other error encountered calling functions from dll - ME_IFVERSION, // incompatible interface version - ME_UNLOAD_UNLOADER, // tried to unload unloader - ME_UNLOAD_SELF, // tried to unload self -} META_ERRNO; -extern META_ERRNO meta_errno; - -#define RETURN_ERRNO(retval, errval) \ - do { meta_errno=errval; return(retval); } while(0) - -#define RETURN_LOGERR_ERRNO(errargs, retval, errval) \ - do { META_ERROR errargs ; meta_errno=errval; return(retval); } while(0) - -#endif /* TYPES_META_H */ +// types_meta.h - common internal type, etc definitions + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#ifndef TYPES_META_H +#define TYPES_META_H + +// Our own boolean type, for stricter type matching. +typedef enum mBOOL { + mFALSE = 0, + mTRUE, +} mBOOL; + +// Like C's errno, for our various functions; describes causes of failure +// or mFALSE returns. +typedef enum { + ME_NOERROR = 0, + ME_FORMAT, // invalid format + ME_COMMENT, // ignored comment + ME_BLANK, // ignored blank (empty) line + ME_ALREADY, // request had already been done + ME_DELAYED, // request is delayed + ME_NOTALLOWED, // request not allowed + ME_SKIPPED, // request is being skipped for whatever reason + ME_BADREQ, // invalid request for this + ME_ARGUMENT, // invalid arguments + ME_NULLRESULT, // resulting data was empty or null + ME_MAXREACHED, // reached max/limit + ME_NOTUNIQ, // not unique (ambigious match) + ME_NOTFOUND, // in find operation, match not found + ME_NOFILE, // file empty or missing + ME_NOMEM, // malloc failed + ME_BADMEMPTR, // invalid memory address + ME_OSNOTSUP, // OS doesn't support this operation + ME_DLOPEN, // failed to open shared lib/dll + ME_DLMISSING, // symbol missing in lib/dll + ME_DLERROR, // some other error encountered calling functions from dll + ME_IFVERSION, // incompatible interface version + ME_UNLOAD_UNLOADER, // tried to unload unloader + ME_UNLOAD_SELF, // tried to unload self +} META_ERRNO; +extern META_ERRNO meta_errno; + +#define RETURN_ERRNO(retval, errval) \ + do { meta_errno=errval; return(retval); } while(0) + +#define RETURN_LOGERR_ERRNO(errargs, retval, errval) \ + do { META_ERROR errargs ; meta_errno=errval; return(retval); } while(0) + +#endif /* TYPES_META_H */ diff --git a/revoice/msvc/PostBuild.bat b/revoice/msvc/PostBuild.bat index aa8a294..8583878 100644 --- a/revoice/msvc/PostBuild.bat +++ b/revoice/msvc/PostBuild.bat @@ -1,39 +1,39 @@ -@echo OFF -:: -:: Post-build auto-deploy script -:: Create and fill PublishPath.txt file with path to deployment folder -:: I.e. PublishPath.txt should contain one line with a folder path -:: Call it so: -:: IF EXIST "$(ProjectDir)PostBuild.bat" (CALL "$(ProjectDir)PostBuild.bat" "$(TargetDir)" "$(TargetName)" "$(TargetExt)" "$(ProjectDir)") -:: - -SET targetDir=%~1 -SET targetName=%~2 -SET targetExt=%~3 -SET projectDir=%~4 -SET destination= - -IF NOT EXIST "%projectDir%\PublishPath.txt" ( - ECHO No deployment path specified. Create PublishPath.txt near PostBuild.bat with paths on separate lines for auto deployment. - exit /B 0 -) - -FOR /f "tokens=* delims= usebackq" %%a IN ("%projectDir%\PublishPath.txt") DO ( - ECHO Deploying to: %%a - IF NOT "%%a" == "" ( - copy /Y "%targetDir%%targetName%%targetExt%" "%%a" - IF NOT ERRORLEVEL 1 ( - IF EXIST "%targetDir%%targetName%.pdb" ( - copy /Y "%targetDir%%targetName%.pdb" "%%a" - ) - ) ELSE ( - ECHO PostBuild.bat ^(27^) : warning : Can't copy '%targetName%%targetExt%' to deploy path '%%a' - ) - ) -) - -IF "%%a" == "" ( - ECHO No deployment path specified. -) - +@echo OFF +:: +:: Post-build auto-deploy script +:: Create and fill PublishPath.txt file with path to deployment folder +:: I.e. PublishPath.txt should contain one line with a folder path +:: Call it so: +:: IF EXIST "$(ProjectDir)PostBuild.bat" (CALL "$(ProjectDir)PostBuild.bat" "$(TargetDir)" "$(TargetName)" "$(TargetExt)" "$(ProjectDir)") +:: + +SET targetDir=%~1 +SET targetName=%~2 +SET targetExt=%~3 +SET projectDir=%~4 +SET destination= + +IF NOT EXIST "%projectDir%\PublishPath.txt" ( + ECHO No deployment path specified. Create PublishPath.txt near PostBuild.bat with paths on separate lines for auto deployment. + exit /B 0 +) + +FOR /f "tokens=* delims= usebackq" %%a IN ("%projectDir%\PublishPath.txt") DO ( + ECHO Deploying to: %%a + IF NOT "%%a" == "" ( + copy /Y "%targetDir%%targetName%%targetExt%" "%%a" + IF NOT ERRORLEVEL 1 ( + IF EXIST "%targetDir%%targetName%.pdb" ( + copy /Y "%targetDir%%targetName%.pdb" "%%a" + ) + ) ELSE ( + ECHO PostBuild.bat ^(27^) : warning : Can't copy '%targetName%%targetExt%' to deploy path '%%a' + ) + ) +) + +IF "%%a" == "" ( + ECHO No deployment path specified. +) + exit /B 0 \ No newline at end of file diff --git a/revoice/public/IVoiceCodec.h b/revoice/public/IVoiceCodec.h index 632c45b..c45a41a 100644 --- a/revoice/public/IVoiceCodec.h +++ b/revoice/public/IVoiceCodec.h @@ -1,30 +1,30 @@ -#pragma once - -#include "interface.h" - -class IGameClient; -class IVoiceCodec: public IBaseInterface { -protected: - virtual ~IVoiceCodec() {} - static const int BYTES_PER_SAMPLE = 2; - -public: - // Initialize the object. The uncompressed format is always 8-bit signed mono. - virtual bool Init(int quality) = 0; - virtual void Release() = 0; - - // Compress the voice data. - // pUncompressed - 16-bit signed mono voice data. - // maxCompressedBytes - The length of the pCompressed buffer. Don't exceed this. - // bFinal - Set to true on the last call to Compress (the user stopped talking). - // Some codecs like big block sizes and will hang onto data you give them in Compress calls. - // When you call with bFinal, the codec will give you compressed data no matter what. - // Return the number of bytes you filled into pCompressed. - virtual int Compress(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal) = 0; - - // Decompress voice data. pUncompressed is 16-bit signed mono. - virtual int Decompress(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes) = 0; - - // Some codecs maintain state between Compress and Decompress calls. This should clear that state. - virtual bool ResetState() = 0; -}; +#pragma once + +#include "interface.h" + +class IGameClient; +class IVoiceCodec: public IBaseInterface { +protected: + virtual ~IVoiceCodec() {} + static const int BYTES_PER_SAMPLE = 2; + +public: + // Initialize the object. The uncompressed format is always 8-bit signed mono. + virtual bool Init(int quality) = 0; + virtual void Release() = 0; + + // Compress the voice data. + // pUncompressed - 16-bit signed mono voice data. + // maxCompressedBytes - The length of the pCompressed buffer. Don't exceed this. + // bFinal - Set to true on the last call to Compress (the user stopped talking). + // Some codecs like big block sizes and will hang onto data you give them in Compress calls. + // When you call with bFinal, the codec will give you compressed data no matter what. + // Return the number of bytes you filled into pCompressed. + virtual int Compress(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal) = 0; + + // Decompress voice data. pUncompressed is 16-bit signed mono. + virtual int Decompress(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes) = 0; + + // Some codecs maintain state between Compress and Decompress calls. This should clear that state. + virtual bool ResetState() = 0; +}; diff --git a/revoice/public/utlbuffer.cpp b/revoice/public/utlbuffer.cpp index d0498b2..c9f4508 100644 --- a/revoice/public/utlbuffer.cpp +++ b/revoice/public/utlbuffer.cpp @@ -1,419 +1,419 @@ -//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============ -// -// The copyright to the contents herein is the property of Valve, L.L.C. -// The contents may be used and/or copied only with the written permission of -// Valve, L.L.C., or in accordance with the terms and conditions stipulated in -// the agreement/contract under which the contents have been supplied. -// -// $Header: $ -// $NoKeywords: $ -// -// Serialization buffer -//============================================================================= - -#include "precompiled.h" - -//----------------------------------------------------------------------------- -// constructors -//----------------------------------------------------------------------------- -CUtlBuffer::CUtlBuffer(int growSize, int initSize, bool text) : -m_Memory(growSize, initSize), m_Error(0) -{ - m_Get = 0; - m_Put = 0; - m_Flags = 0; - if (text) - { - m_Flags |= TEXT_BUFFER; - } -} - -CUtlBuffer::CUtlBuffer(void const* pBuffer, int size, bool text) : -m_Memory((unsigned char*)pBuffer, size), m_Error(0) -{ - m_Get = 0; - m_Put = 0; - m_Flags = 0; - if (text) - m_Flags |= TEXT_BUFFER; -} - - -//----------------------------------------------------------------------------- -// Attaches the buffer to external memory.... -//----------------------------------------------------------------------------- -void CUtlBuffer::SetExternalBuffer(void* pMemory, int numElements, bool text) -{ - m_Memory.SetExternalBuffer((unsigned char*)pMemory, numElements); - - // Reset all indices; we just changed memory - m_Get = 0; - m_Put = 0; - m_Flags = 0; - if (text) - m_Flags |= TEXT_BUFFER; -} - - -//----------------------------------------------------------------------------- -// Makes sure we've got at least this much memory -//----------------------------------------------------------------------------- -void CUtlBuffer::EnsureCapacity(int num) -{ - m_Memory.EnsureCapacity(num); -} - - -//----------------------------------------------------------------------------- -// Base get method from which all others derive -//----------------------------------------------------------------------------- -void CUtlBuffer::Get(void* pMem, int size) -{ - Assert(m_Get + size <= m_Memory.NumAllocated()); - memcpy(pMem, &m_Memory[m_Get], size); - m_Get += size; -} - - -//----------------------------------------------------------------------------- -// Eats whitespace -//----------------------------------------------------------------------------- -void CUtlBuffer::EatWhiteSpace() -{ - if (IsText() && IsValid()) - { - int lastpos = Size(); - while (m_Get < lastpos) - { - if (!isspace(*(char*)&m_Memory[m_Get])) - break; - m_Get += sizeof(char); - } - } -} - - -//----------------------------------------------------------------------------- -// Reads a null-terminated string -//----------------------------------------------------------------------------- -void CUtlBuffer::GetString(char* pString, int nMaxLen) -{ - if (!IsValid()) - { - *pString = 0; - return; - } - - if (nMaxLen == 0) - { - nMaxLen = INT_MAX; - } - - if (!IsText()) - { - int len = strlen((char*)&m_Memory[m_Get]) + 1; - if (len <= nMaxLen) - { - Get(pString, len); - } - else - { - Get(pString, nMaxLen); - pString[nMaxLen - 1] = 0; - SeekGet(SEEK_CURRENT, len - nMaxLen); - } - } - else - { - // eat all whitespace - EatWhiteSpace(); - - // Eat characters - int nCount = 0; - int nLastPos = Size(); - while (m_Get < nLastPos) - { - char c = *(char*)&m_Memory[m_Get]; - if (isspace(c) || (!c)) - break; - - if (nCount < nMaxLen - 1) - { - *pString++ = c; - } - ++nCount; - ++m_Get; - } - - // Terminate - *pString = 0; - } -} - - -//----------------------------------------------------------------------------- -// Checks if a get is ok -//----------------------------------------------------------------------------- -bool CUtlBuffer::CheckGet(int size) -{ - if (m_Error) - return false; - - if (m_Memory.NumAllocated() >= m_Get + size) - return true; - - m_Error |= GET_OVERFLOW; - return false; -} - - -//----------------------------------------------------------------------------- -// Change where I'm reading -//----------------------------------------------------------------------------- -void CUtlBuffer::SeekGet(SeekType_t type, int offset) -{ - switch (type) - { - case SEEK_HEAD: - m_Get = offset; - break; - - case SEEK_CURRENT: - m_Get += offset; - break; - - case SEEK_TAIL: - m_Get = m_Memory.NumAllocated() - offset; - break; - } -} - - -//----------------------------------------------------------------------------- -// Parse... -//----------------------------------------------------------------------------- - -#pragma warning ( disable : 4706 ) - -int CUtlBuffer::VaScanf(char const* pFmt, va_list list) -{ - Assert(pFmt); - if (m_Error || !IsText()) - return 0; - - int numScanned = 0; - - char c; - char* pEnd; - while (c = *pFmt++) - { - // Stop if we hit the end of the buffer - if (m_Get >= Size()) - { - m_Error |= GET_OVERFLOW; - break; - } - - switch (c) - { - case ' ': - // eat all whitespace - EatWhiteSpace(); - break; - - case '%': - { - // Conversion character... try to convert baby! - char type = *pFmt++; - if (type == 0) - return numScanned; - - switch (type) - { - case 'c': - { - char* ch = va_arg(list, char *); - *ch = (char)m_Memory[m_Get]; - ++m_Get; - } - break; - - case 'i': - case 'd': - { - int* i = va_arg(list, int *); - *i = strtol((char*)PeekGet(), &pEnd, 10); - if (pEnd == PeekGet()) - return numScanned; - m_Get = (int)pEnd - (int)Base(); - } - break; - - case 'x': - { - int* i = va_arg(list, int *); - *i = strtol((char*)PeekGet(), &pEnd, 16); - if (pEnd == PeekGet()) - return numScanned; - m_Get = (int)pEnd - (int)Base(); - } - break; - - case 'u': - { - unsigned int* u = va_arg(list, unsigned int *); - *u = strtoul((char*)PeekGet(), &pEnd, 10); - if (pEnd == PeekGet()) - return numScanned; - m_Get = (int)pEnd - (int)Base(); - } - break; - - case 'f': - { - float* f = va_arg(list, float *); - *f = (float)strtod((char*)PeekGet(), &pEnd); - if (pEnd == PeekGet()) - return numScanned; - m_Get = (int)pEnd - (int)Base(); - } - break; - - case 's': - { - char* s = va_arg(list, char *); - GetString(s); - } - break; - - default: - { - // unimplemented scanf type - Assert(0); - return numScanned; - } - break; - } - - ++numScanned; - } - break; - - default: - { - // Here we have to match the format string character - // against what's in the buffer or we're done. - if (c != m_Memory[m_Get]) - return numScanned; - ++m_Get; - } - } - } - return numScanned; -} - -#pragma warning ( default : 4706 ) - -int CUtlBuffer::Scanf(char const* pFmt, ...) -{ - va_list args; - - va_start(args, pFmt); - int count = VaScanf(pFmt, args); - va_end(args); - - return count; -} - - -//----------------------------------------------------------------------------- -// Serialization -//----------------------------------------------------------------------------- - -void CUtlBuffer::Put(void const* pMem, int size) -{ - if (CheckPut(size)) - { - memcpy(&m_Memory[m_Put], pMem, size); - m_Put += size; - } -} - - -//----------------------------------------------------------------------------- -// Writes a null-terminated string -//----------------------------------------------------------------------------- - -void CUtlBuffer::PutString(char const* pString) -{ - int len = strlen(pString); - - // Not text? append a null at the end. - if (!IsText()) - ++len; - - Put(pString, len); -} - -void CUtlBuffer::VaPrintf(char const* pFmt, va_list list) -{ - char temp[2048]; - int len = vsprintf(temp, pFmt, list); - Assert(len < 2048); - - // Not text? append a null at the end. - if (!IsText()) - ++len; - - Put(temp, len); -} - -void CUtlBuffer::Printf(char const* pFmt, ...) -{ - va_list args; - - va_start(args, pFmt); - VaPrintf(pFmt, args); - va_end(args); -} - - -//----------------------------------------------------------------------------- -// Checks if a put is ok -//----------------------------------------------------------------------------- - -bool CUtlBuffer::CheckPut(int size) -{ - if (m_Error) - return false; - - while (m_Memory.NumAllocated() < m_Put + size) - { - if (m_Memory.IsExternallyAllocated()) - { - m_Error |= PUT_OVERFLOW; - return false; - } - - m_Memory.Grow(); - } - return true; -} - -void CUtlBuffer::SeekPut(SeekType_t type, int offset) -{ - switch (type) - { - case SEEK_HEAD: - m_Put = offset; - break; - - case SEEK_CURRENT: - m_Put += offset; - break; - - case SEEK_TAIL: - m_Put = m_Memory.NumAllocated() - offset; - break; - } +//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============ +// +// The copyright to the contents herein is the property of Valve, L.L.C. +// The contents may be used and/or copied only with the written permission of +// Valve, L.L.C., or in accordance with the terms and conditions stipulated in +// the agreement/contract under which the contents have been supplied. +// +// $Header: $ +// $NoKeywords: $ +// +// Serialization buffer +//============================================================================= + +#include "precompiled.h" + +//----------------------------------------------------------------------------- +// constructors +//----------------------------------------------------------------------------- +CUtlBuffer::CUtlBuffer(int growSize, int initSize, bool text) : +m_Memory(growSize, initSize), m_Error(0) +{ + m_Get = 0; + m_Put = 0; + m_Flags = 0; + if (text) + { + m_Flags |= TEXT_BUFFER; + } +} + +CUtlBuffer::CUtlBuffer(void const* pBuffer, int size, bool text) : +m_Memory((unsigned char*)pBuffer, size), m_Error(0) +{ + m_Get = 0; + m_Put = 0; + m_Flags = 0; + if (text) + m_Flags |= TEXT_BUFFER; +} + + +//----------------------------------------------------------------------------- +// Attaches the buffer to external memory.... +//----------------------------------------------------------------------------- +void CUtlBuffer::SetExternalBuffer(void* pMemory, int numElements, bool text) +{ + m_Memory.SetExternalBuffer((unsigned char*)pMemory, numElements); + + // Reset all indices; we just changed memory + m_Get = 0; + m_Put = 0; + m_Flags = 0; + if (text) + m_Flags |= TEXT_BUFFER; +} + + +//----------------------------------------------------------------------------- +// Makes sure we've got at least this much memory +//----------------------------------------------------------------------------- +void CUtlBuffer::EnsureCapacity(int num) +{ + m_Memory.EnsureCapacity(num); +} + + +//----------------------------------------------------------------------------- +// Base get method from which all others derive +//----------------------------------------------------------------------------- +void CUtlBuffer::Get(void* pMem, int size) +{ + Assert(m_Get + size <= m_Memory.NumAllocated()); + memcpy(pMem, &m_Memory[m_Get], size); + m_Get += size; +} + + +//----------------------------------------------------------------------------- +// Eats whitespace +//----------------------------------------------------------------------------- +void CUtlBuffer::EatWhiteSpace() +{ + if (IsText() && IsValid()) + { + int lastpos = Size(); + while (m_Get < lastpos) + { + if (!isspace(*(char*)&m_Memory[m_Get])) + break; + m_Get += sizeof(char); + } + } +} + + +//----------------------------------------------------------------------------- +// Reads a null-terminated string +//----------------------------------------------------------------------------- +void CUtlBuffer::GetString(char* pString, int nMaxLen) +{ + if (!IsValid()) + { + *pString = 0; + return; + } + + if (nMaxLen == 0) + { + nMaxLen = INT_MAX; + } + + if (!IsText()) + { + int len = strlen((char*)&m_Memory[m_Get]) + 1; + if (len <= nMaxLen) + { + Get(pString, len); + } + else + { + Get(pString, nMaxLen); + pString[nMaxLen - 1] = 0; + SeekGet(SEEK_CURRENT, len - nMaxLen); + } + } + else + { + // eat all whitespace + EatWhiteSpace(); + + // Eat characters + int nCount = 0; + int nLastPos = Size(); + while (m_Get < nLastPos) + { + char c = *(char*)&m_Memory[m_Get]; + if (isspace(c) || (!c)) + break; + + if (nCount < nMaxLen - 1) + { + *pString++ = c; + } + ++nCount; + ++m_Get; + } + + // Terminate + *pString = 0; + } +} + + +//----------------------------------------------------------------------------- +// Checks if a get is ok +//----------------------------------------------------------------------------- +bool CUtlBuffer::CheckGet(int size) +{ + if (m_Error) + return false; + + if (m_Memory.NumAllocated() >= m_Get + size) + return true; + + m_Error |= GET_OVERFLOW; + return false; +} + + +//----------------------------------------------------------------------------- +// Change where I'm reading +//----------------------------------------------------------------------------- +void CUtlBuffer::SeekGet(SeekType_t type, int offset) +{ + switch (type) + { + case SEEK_HEAD: + m_Get = offset; + break; + + case SEEK_CURRENT: + m_Get += offset; + break; + + case SEEK_TAIL: + m_Get = m_Memory.NumAllocated() - offset; + break; + } +} + + +//----------------------------------------------------------------------------- +// Parse... +//----------------------------------------------------------------------------- + +#pragma warning ( disable : 4706 ) + +int CUtlBuffer::VaScanf(char const* pFmt, va_list list) +{ + Assert(pFmt); + if (m_Error || !IsText()) + return 0; + + int numScanned = 0; + + char c; + char* pEnd; + while (c = *pFmt++) + { + // Stop if we hit the end of the buffer + if (m_Get >= Size()) + { + m_Error |= GET_OVERFLOW; + break; + } + + switch (c) + { + case ' ': + // eat all whitespace + EatWhiteSpace(); + break; + + case '%': + { + // Conversion character... try to convert baby! + char type = *pFmt++; + if (type == 0) + return numScanned; + + switch (type) + { + case 'c': + { + char* ch = va_arg(list, char *); + *ch = (char)m_Memory[m_Get]; + ++m_Get; + } + break; + + case 'i': + case 'd': + { + int* i = va_arg(list, int *); + *i = strtol((char*)PeekGet(), &pEnd, 10); + if (pEnd == PeekGet()) + return numScanned; + m_Get = (int)pEnd - (int)Base(); + } + break; + + case 'x': + { + int* i = va_arg(list, int *); + *i = strtol((char*)PeekGet(), &pEnd, 16); + if (pEnd == PeekGet()) + return numScanned; + m_Get = (int)pEnd - (int)Base(); + } + break; + + case 'u': + { + unsigned int* u = va_arg(list, unsigned int *); + *u = strtoul((char*)PeekGet(), &pEnd, 10); + if (pEnd == PeekGet()) + return numScanned; + m_Get = (int)pEnd - (int)Base(); + } + break; + + case 'f': + { + float* f = va_arg(list, float *); + *f = (float)strtod((char*)PeekGet(), &pEnd); + if (pEnd == PeekGet()) + return numScanned; + m_Get = (int)pEnd - (int)Base(); + } + break; + + case 's': + { + char* s = va_arg(list, char *); + GetString(s); + } + break; + + default: + { + // unimplemented scanf type + Assert(0); + return numScanned; + } + break; + } + + ++numScanned; + } + break; + + default: + { + // Here we have to match the format string character + // against what's in the buffer or we're done. + if (c != m_Memory[m_Get]) + return numScanned; + ++m_Get; + } + } + } + return numScanned; +} + +#pragma warning ( default : 4706 ) + +int CUtlBuffer::Scanf(char const* pFmt, ...) +{ + va_list args; + + va_start(args, pFmt); + int count = VaScanf(pFmt, args); + va_end(args); + + return count; +} + + +//----------------------------------------------------------------------------- +// Serialization +//----------------------------------------------------------------------------- + +void CUtlBuffer::Put(void const* pMem, int size) +{ + if (CheckPut(size)) + { + memcpy(&m_Memory[m_Put], pMem, size); + m_Put += size; + } +} + + +//----------------------------------------------------------------------------- +// Writes a null-terminated string +//----------------------------------------------------------------------------- + +void CUtlBuffer::PutString(char const* pString) +{ + int len = strlen(pString); + + // Not text? append a null at the end. + if (!IsText()) + ++len; + + Put(pString, len); +} + +void CUtlBuffer::VaPrintf(char const* pFmt, va_list list) +{ + char temp[2048]; + int len = vsprintf(temp, pFmt, list); + Assert(len < 2048); + + // Not text? append a null at the end. + if (!IsText()) + ++len; + + Put(temp, len); +} + +void CUtlBuffer::Printf(char const* pFmt, ...) +{ + va_list args; + + va_start(args, pFmt); + VaPrintf(pFmt, args); + va_end(args); +} + + +//----------------------------------------------------------------------------- +// Checks if a put is ok +//----------------------------------------------------------------------------- + +bool CUtlBuffer::CheckPut(int size) +{ + if (m_Error) + return false; + + while (m_Memory.NumAllocated() < m_Put + size) + { + if (m_Memory.IsExternallyAllocated()) + { + m_Error |= PUT_OVERFLOW; + return false; + } + + m_Memory.Grow(); + } + return true; +} + +void CUtlBuffer::SeekPut(SeekType_t type, int offset) +{ + switch (type) + { + case SEEK_HEAD: + m_Put = offset; + break; + + case SEEK_CURRENT: + m_Put += offset; + break; + + case SEEK_TAIL: + m_Put = m_Memory.NumAllocated() - offset; + break; + } } \ No newline at end of file diff --git a/revoice/public/utlbuffer.h b/revoice/public/utlbuffer.h index 768010c..9d7a55d 100644 --- a/revoice/public/utlbuffer.h +++ b/revoice/public/utlbuffer.h @@ -1,354 +1,354 @@ -//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============ -// -// The copyright to the contents herein is the property of Valve, L.L.C. -// The contents may be used and/or copied only with the written permission of -// Valve, L.L.C., or in accordance with the terms and conditions stipulated in -// the agreement/contract under which the contents have been supplied. -// -// $Header: $ -// $NoKeywords: $ -// -// Serialization/unserialization buffer -//============================================================================= - -#ifndef UTLBUFFER_H -#define UTLBUFFER_H - -#include "utlmemory.h" -#include -#include -#include -#include -#include -#include - -//----------------------------------------------------------------------------- -// Command parsing.. -//----------------------------------------------------------------------------- - -class CUtlBuffer -{ -public: - enum SeekType_t - { - SEEK_HEAD = 0, - SEEK_CURRENT, - SEEK_TAIL - }; - - CUtlBuffer(int growSize = 0, int initSize = 0, bool text = false); - CUtlBuffer(void const* pBuffer, int size, bool text = false); - - // Makes sure we've got at least this much memory - void EnsureCapacity(int num); - - // Attaches the buffer to external memory.... - void SetExternalBuffer(void* pMemory, int numElements, bool text = false); - - // Read stuff out. - // Binary mode: it'll just read the bits directly in, and characters will be - // read for strings until a null character is reached. - // Text mode: it'll parse the file, turning text #s into real numbers. - // GetString will read a string until a space is reaced - char GetChar(); - unsigned char GetUnsignedChar(); - short GetShort(); - unsigned short GetUnsignedShort(); - int GetInt(); - int GetIntHex(); - unsigned int GetUnsignedInt(); - float GetFloat(); - double GetDouble(); - void GetString(char* pString, int nMaxLen = 0); - void Get(void* pMem, int size); - - // Just like scanf, but doesn't work in binary mode - int Scanf(char const* pFmt, ...); - int VaScanf(char const* pFmt, va_list list); - - // Eats white space, advances Get index - void EatWhiteSpace(); - - // Write stuff in - // Binary mode: it'll just write the bits directly in, and strings will be - // written with a null terminating character - // Text mode: it'll convert the numbers to text versions - // PutString will not write a terminating character - void PutChar(char c); - void PutUnsignedChar(unsigned char uc); - void PutShort(short s); - void PutUnsignedShort(unsigned short us); - void PutInt(int i); - void PutUnsignedInt(unsigned int u); - void PutFloat(float f); - void PutDouble(double d); - void PutString(char const* pString); - void Put(void const* pMem, int size); - - // Just like printf, writes a terminating zero in binary mode - void Printf(char const* pFmt, ...); - void VaPrintf(char const* pFmt, va_list list); - - // What am I writing (put)/reading (get)? - void* PeekPut(int offset = 0); - void const* PeekGet(int offset = 0) const; - - // Where am I writing (put)/reading (get)? - int TellPut() const; - int TellGet() const; - - // Change where I'm writing (put)/reading (get) - void SeekPut(SeekType_t type, int offset); - void SeekGet(SeekType_t type, int offset); - - // Buffer base - void const* Base() const; - void* Base(); - - // memory allocation size, does *not* reflect size written or read, - // use TellPut or TellGet for that - int Size() const; - - // Am I a text buffer? - inline bool IsText() const { return (m_Flags & TEXT_BUFFER) != 0; } - - // Am I valid? (overflow or underflow error), Once invalid it stays invalid - inline bool IsValid() const { return m_Error == 0; } - - void Clear(); - -private: - // error flags - enum - { - PUT_OVERFLOW = 0x1, - GET_OVERFLOW = 0x2, - }; - - // flags - enum - { - TEXT_BUFFER = 0x1, - }; - - // Checks if a get/put is ok - bool CheckPut(int size); - bool CheckGet(int size); - - CUtlMemory m_Memory; - int m_Get; - int m_Put; - unsigned char m_Error; - unsigned char m_Flags; -}; - - -//----------------------------------------------------------------------------- -// Where am I reading? -//----------------------------------------------------------------------------- - -inline int CUtlBuffer::TellGet() const -{ - return m_Get; -} - - -//----------------------------------------------------------------------------- -// What am I reading? -//----------------------------------------------------------------------------- -inline void const* CUtlBuffer::PeekGet(int offset) const -{ - return &m_Memory[m_Get + offset]; -} - - -//----------------------------------------------------------------------------- -// Unserialization -//----------------------------------------------------------------------------- -#define GET_TYPE( _type, _val, _fmt ) \ - if (!IsText()) \ - { \ - if (CheckGet( sizeof(_type) )) \ - { \ - _val = *(_type *)PeekGet(); \ - m_Get += sizeof(_type); \ - } \ - else \ - { \ - _val = 0; \ - } \ - } \ - else \ - { \ - _val = 0; \ - Scanf( _fmt, &_val ); \ - } - -inline char CUtlBuffer::GetChar() -{ - char c; - GET_TYPE(char, c, "%c"); - return c; -} - -inline unsigned char CUtlBuffer::GetUnsignedChar() -{ - unsigned char c; - GET_TYPE(unsigned char, c, "%u"); - return c; -} - -inline short CUtlBuffer::GetShort() -{ - short s; - GET_TYPE(short, s, "%d"); - return s; -} - -inline unsigned short CUtlBuffer::GetUnsignedShort() -{ - unsigned short s; - GET_TYPE(unsigned short, s, "%u"); - return s; -} - -inline int CUtlBuffer::GetInt() -{ - int i; - GET_TYPE(int, i, "%d"); - return i; -} - -inline int CUtlBuffer::GetIntHex() -{ - int i; - GET_TYPE(int, i, "%x"); - return i; -} - -inline unsigned int CUtlBuffer::GetUnsignedInt() -{ - unsigned int u; - GET_TYPE(unsigned int, u, "%u"); - return u; -} - -inline float CUtlBuffer::GetFloat() -{ - float f; - GET_TYPE(float, f, "%f"); - return f; -} - -inline double CUtlBuffer::GetDouble() -{ - double d; - GET_TYPE(double, d, "%f"); - return d; -} - - -//----------------------------------------------------------------------------- -// Where am I writing? -//----------------------------------------------------------------------------- -inline int CUtlBuffer::TellPut() const -{ - return m_Put; -} - - -//----------------------------------------------------------------------------- -// What am I reading? -//----------------------------------------------------------------------------- -inline void* CUtlBuffer::PeekPut(int offset) -{ - return &m_Memory[m_Put + offset]; -} - - -//----------------------------------------------------------------------------- -// Various put methods -//----------------------------------------------------------------------------- -#define PUT_TYPE( _type, _val, _fmt ) \ - if (!IsText()) \ - { \ - if (CheckPut( sizeof(_type) )) \ - { \ - *(_type *)PeekPut() = _val; \ - m_Put += sizeof(_type); \ - } \ - } \ - else \ - { \ - Printf( _fmt, _val ); \ - } - - -inline void CUtlBuffer::PutChar(char c) -{ - PUT_TYPE(char, c, "%c"); -} - -inline void CUtlBuffer::PutUnsignedChar(unsigned char c) -{ - PUT_TYPE(unsigned char, c, "%u"); -} - -inline void CUtlBuffer::PutShort(short s) -{ - PUT_TYPE(short, s, "%d"); -} - -inline void CUtlBuffer::PutUnsignedShort(unsigned short s) -{ - PUT_TYPE(unsigned short, s, "%u"); -} - -inline void CUtlBuffer::PutInt(int i) -{ - PUT_TYPE(int, i, "%d"); -} - -inline void CUtlBuffer::PutUnsignedInt(unsigned int u) -{ - PUT_TYPE(unsigned int, u, "%u"); -} - -inline void CUtlBuffer::PutFloat(float f) -{ - PUT_TYPE(float, f, "%f"); -} - -inline void CUtlBuffer::PutDouble(double d) -{ - PUT_TYPE(double, d, "%f"); -} - -//----------------------------------------------------------------------------- -// Buffer base and size -//----------------------------------------------------------------------------- - -inline void const* CUtlBuffer::Base() const -{ - return m_Memory.Base(); -} - -inline void* CUtlBuffer::Base() -{ - return m_Memory.Base(); -} - -inline int CUtlBuffer::Size() const -{ - return m_Memory.NumAllocated(); -} - -inline void CUtlBuffer::Clear() -{ - m_Get = 0; - m_Put = 0; - m_Error = 0; -} - - -#endif // UTLBUFFER_H +//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============ +// +// The copyright to the contents herein is the property of Valve, L.L.C. +// The contents may be used and/or copied only with the written permission of +// Valve, L.L.C., or in accordance with the terms and conditions stipulated in +// the agreement/contract under which the contents have been supplied. +// +// $Header: $ +// $NoKeywords: $ +// +// Serialization/unserialization buffer +//============================================================================= + +#ifndef UTLBUFFER_H +#define UTLBUFFER_H + +#include "utlmemory.h" +#include +#include +#include +#include +#include +#include + +//----------------------------------------------------------------------------- +// Command parsing.. +//----------------------------------------------------------------------------- + +class CUtlBuffer +{ +public: + enum SeekType_t + { + SEEK_HEAD = 0, + SEEK_CURRENT, + SEEK_TAIL + }; + + CUtlBuffer(int growSize = 0, int initSize = 0, bool text = false); + CUtlBuffer(void const* pBuffer, int size, bool text = false); + + // Makes sure we've got at least this much memory + void EnsureCapacity(int num); + + // Attaches the buffer to external memory.... + void SetExternalBuffer(void* pMemory, int numElements, bool text = false); + + // Read stuff out. + // Binary mode: it'll just read the bits directly in, and characters will be + // read for strings until a null character is reached. + // Text mode: it'll parse the file, turning text #s into real numbers. + // GetString will read a string until a space is reaced + char GetChar(); + unsigned char GetUnsignedChar(); + short GetShort(); + unsigned short GetUnsignedShort(); + int GetInt(); + int GetIntHex(); + unsigned int GetUnsignedInt(); + float GetFloat(); + double GetDouble(); + void GetString(char* pString, int nMaxLen = 0); + void Get(void* pMem, int size); + + // Just like scanf, but doesn't work in binary mode + int Scanf(char const* pFmt, ...); + int VaScanf(char const* pFmt, va_list list); + + // Eats white space, advances Get index + void EatWhiteSpace(); + + // Write stuff in + // Binary mode: it'll just write the bits directly in, and strings will be + // written with a null terminating character + // Text mode: it'll convert the numbers to text versions + // PutString will not write a terminating character + void PutChar(char c); + void PutUnsignedChar(unsigned char uc); + void PutShort(short s); + void PutUnsignedShort(unsigned short us); + void PutInt(int i); + void PutUnsignedInt(unsigned int u); + void PutFloat(float f); + void PutDouble(double d); + void PutString(char const* pString); + void Put(void const* pMem, int size); + + // Just like printf, writes a terminating zero in binary mode + void Printf(char const* pFmt, ...); + void VaPrintf(char const* pFmt, va_list list); + + // What am I writing (put)/reading (get)? + void* PeekPut(int offset = 0); + void const* PeekGet(int offset = 0) const; + + // Where am I writing (put)/reading (get)? + int TellPut() const; + int TellGet() const; + + // Change where I'm writing (put)/reading (get) + void SeekPut(SeekType_t type, int offset); + void SeekGet(SeekType_t type, int offset); + + // Buffer base + void const* Base() const; + void* Base(); + + // memory allocation size, does *not* reflect size written or read, + // use TellPut or TellGet for that + int Size() const; + + // Am I a text buffer? + inline bool IsText() const { return (m_Flags & TEXT_BUFFER) != 0; } + + // Am I valid? (overflow or underflow error), Once invalid it stays invalid + inline bool IsValid() const { return m_Error == 0; } + + void Clear(); + +private: + // error flags + enum + { + PUT_OVERFLOW = 0x1, + GET_OVERFLOW = 0x2, + }; + + // flags + enum + { + TEXT_BUFFER = 0x1, + }; + + // Checks if a get/put is ok + bool CheckPut(int size); + bool CheckGet(int size); + + CUtlMemory m_Memory; + int m_Get; + int m_Put; + unsigned char m_Error; + unsigned char m_Flags; +}; + + +//----------------------------------------------------------------------------- +// Where am I reading? +//----------------------------------------------------------------------------- + +inline int CUtlBuffer::TellGet() const +{ + return m_Get; +} + + +//----------------------------------------------------------------------------- +// What am I reading? +//----------------------------------------------------------------------------- +inline void const* CUtlBuffer::PeekGet(int offset) const +{ + return &m_Memory[m_Get + offset]; +} + + +//----------------------------------------------------------------------------- +// Unserialization +//----------------------------------------------------------------------------- +#define GET_TYPE( _type, _val, _fmt ) \ + if (!IsText()) \ + { \ + if (CheckGet( sizeof(_type) )) \ + { \ + _val = *(_type *)PeekGet(); \ + m_Get += sizeof(_type); \ + } \ + else \ + { \ + _val = 0; \ + } \ + } \ + else \ + { \ + _val = 0; \ + Scanf( _fmt, &_val ); \ + } + +inline char CUtlBuffer::GetChar() +{ + char c; + GET_TYPE(char, c, "%c"); + return c; +} + +inline unsigned char CUtlBuffer::GetUnsignedChar() +{ + unsigned char c; + GET_TYPE(unsigned char, c, "%u"); + return c; +} + +inline short CUtlBuffer::GetShort() +{ + short s; + GET_TYPE(short, s, "%d"); + return s; +} + +inline unsigned short CUtlBuffer::GetUnsignedShort() +{ + unsigned short s; + GET_TYPE(unsigned short, s, "%u"); + return s; +} + +inline int CUtlBuffer::GetInt() +{ + int i; + GET_TYPE(int, i, "%d"); + return i; +} + +inline int CUtlBuffer::GetIntHex() +{ + int i; + GET_TYPE(int, i, "%x"); + return i; +} + +inline unsigned int CUtlBuffer::GetUnsignedInt() +{ + unsigned int u; + GET_TYPE(unsigned int, u, "%u"); + return u; +} + +inline float CUtlBuffer::GetFloat() +{ + float f; + GET_TYPE(float, f, "%f"); + return f; +} + +inline double CUtlBuffer::GetDouble() +{ + double d; + GET_TYPE(double, d, "%f"); + return d; +} + + +//----------------------------------------------------------------------------- +// Where am I writing? +//----------------------------------------------------------------------------- +inline int CUtlBuffer::TellPut() const +{ + return m_Put; +} + + +//----------------------------------------------------------------------------- +// What am I reading? +//----------------------------------------------------------------------------- +inline void* CUtlBuffer::PeekPut(int offset) +{ + return &m_Memory[m_Put + offset]; +} + + +//----------------------------------------------------------------------------- +// Various put methods +//----------------------------------------------------------------------------- +#define PUT_TYPE( _type, _val, _fmt ) \ + if (!IsText()) \ + { \ + if (CheckPut( sizeof(_type) )) \ + { \ + *(_type *)PeekPut() = _val; \ + m_Put += sizeof(_type); \ + } \ + } \ + else \ + { \ + Printf( _fmt, _val ); \ + } + + +inline void CUtlBuffer::PutChar(char c) +{ + PUT_TYPE(char, c, "%c"); +} + +inline void CUtlBuffer::PutUnsignedChar(unsigned char c) +{ + PUT_TYPE(unsigned char, c, "%u"); +} + +inline void CUtlBuffer::PutShort(short s) +{ + PUT_TYPE(short, s, "%d"); +} + +inline void CUtlBuffer::PutUnsignedShort(unsigned short s) +{ + PUT_TYPE(unsigned short, s, "%u"); +} + +inline void CUtlBuffer::PutInt(int i) +{ + PUT_TYPE(int, i, "%d"); +} + +inline void CUtlBuffer::PutUnsignedInt(unsigned int u) +{ + PUT_TYPE(unsigned int, u, "%u"); +} + +inline void CUtlBuffer::PutFloat(float f) +{ + PUT_TYPE(float, f, "%f"); +} + +inline void CUtlBuffer::PutDouble(double d) +{ + PUT_TYPE(double, d, "%f"); +} + +//----------------------------------------------------------------------------- +// Buffer base and size +//----------------------------------------------------------------------------- + +inline void const* CUtlBuffer::Base() const +{ + return m_Memory.Base(); +} + +inline void* CUtlBuffer::Base() +{ + return m_Memory.Base(); +} + +inline int CUtlBuffer::Size() const +{ + return m_Memory.NumAllocated(); +} + +inline void CUtlBuffer::Clear() +{ + m_Get = 0; + m_Put = 0; + m_Error = 0; +} + + +#endif // UTLBUFFER_H diff --git a/revoice/public/utlmemory.h b/revoice/public/utlmemory.h index 029d4a8..476d5ea 100644 --- a/revoice/public/utlmemory.h +++ b/revoice/public/utlmemory.h @@ -1,322 +1,322 @@ -//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. =========== -// -// The copyright to the contents herein is the property of Valve, L.L.C. -// The contents may be used and/or copied only with the written permission of -// Valve, L.L.C., or in accordance with the terms and conditions stipulated in -// the agreement/contract under which the contents have been supplied. -// -// $Header: $ -// $NoKeywords: $ -// -// A growable memory class. -//============================================================================= - -#ifndef UTLMEMORY_H -#define UTLMEMORY_H - -#ifdef _WIN32 -#pragma once -#endif - -#include - -#pragma warning (disable:4100) -#pragma warning (disable:4514) - -#define Assert(expr) ((void)0) - -//----------------------------------------------------------------------------- -// The CUtlMemory class: -// A growable memory class which doubles in size by default. -//----------------------------------------------------------------------------- -template< class T > -class CUtlMemory -{ -public: - // constructor, destructor - CUtlMemory(int nGrowSize = 0, int nInitSize = 0); - CUtlMemory(T* pMemory, int numElements); - ~CUtlMemory(); - - // element access - T& operator[](int i); - T const& operator[](int i) const; - T& Element(int i); - T const& Element(int i) const; - - // Can we use this index? - bool IsIdxValid(int i) const; - - // Gets the base address (can change when adding elements!) - T* Base(); - T const* Base() const; - - // Attaches the buffer to external memory.... - void SetExternalBuffer(T* pMemory, int numElements); - - // Size - int NumAllocated() const; - int Count() const; - - // Grows the memory, so that at least allocated + num elements are allocated - void Grow(int num = 1); - - // Makes sure we've got at least this much memory - void EnsureCapacity(int num); - - // Memory deallocation - void Purge(); - - // is the memory externally allocated? - bool IsExternallyAllocated() const; - - // Set the size by which the memory grows - void SetGrowSize(int size); - -private: - enum - { - EXTERNAL_BUFFER_MARKER = -1, - }; - - T* m_pMemory; - int m_nAllocationCount; - int m_nGrowSize; -}; - - -//----------------------------------------------------------------------------- -// constructor, destructor -//----------------------------------------------------------------------------- -template< class T > -CUtlMemory::CUtlMemory(int nGrowSize, int nInitAllocationCount) : m_pMemory(0), -m_nAllocationCount(nInitAllocationCount), m_nGrowSize(nGrowSize) -{ - Assert((nGrowSize >= 0) && (nGrowSize != EXTERNAL_BUFFER_MARKER)); - if (m_nAllocationCount) - { - m_pMemory = (T*)malloc(m_nAllocationCount * sizeof(T)); - } -} - -template< class T > -CUtlMemory::CUtlMemory(T* pMemory, int numElements) : m_pMemory(pMemory), -m_nAllocationCount(numElements) -{ - // Special marker indicating externally supplied memory - m_nGrowSize = EXTERNAL_BUFFER_MARKER; -} - -template< class T > -CUtlMemory::~CUtlMemory() -{ - Purge(); -} - - -//----------------------------------------------------------------------------- -// Attaches the buffer to external memory.... -//----------------------------------------------------------------------------- -template< class T > -void CUtlMemory::SetExternalBuffer(T* pMemory, int numElements) -{ - // Blow away any existing allocated memory - Purge(); - - m_pMemory = pMemory; - m_nAllocationCount = numElements; - - // Indicate that we don't own the memory - m_nGrowSize = EXTERNAL_BUFFER_MARKER; -} - - -//----------------------------------------------------------------------------- -// element access -//----------------------------------------------------------------------------- -template< class T > -inline T& CUtlMemory::operator[](int i) -{ - Assert(IsIdxValid(i)); - return m_pMemory[i]; -} - -template< class T > -inline T const& CUtlMemory::operator[](int i) const -{ - Assert(IsIdxValid(i)); - return m_pMemory[i]; -} - -template< class T > -inline T& CUtlMemory::Element(int i) -{ - Assert(IsIdxValid(i)); - return m_pMemory[i]; -} - -template< class T > -inline T const& CUtlMemory::Element(int i) const -{ - Assert(IsIdxValid(i)); - return m_pMemory[i]; -} - - -//----------------------------------------------------------------------------- -// is the memory externally allocated? -//----------------------------------------------------------------------------- -template< class T > -bool CUtlMemory::IsExternallyAllocated() const -{ - return m_nGrowSize == EXTERNAL_BUFFER_MARKER; -} - - -template< class T > -void CUtlMemory::SetGrowSize(int nSize) -{ - Assert((nSize >= 0) && (nSize != EXTERNAL_BUFFER_MARKER)); - m_nGrowSize = nSize; -} - - -//----------------------------------------------------------------------------- -// Gets the base address (can change when adding elements!) -//----------------------------------------------------------------------------- -template< class T > -inline T* CUtlMemory::Base() -{ - return m_pMemory; -} - -template< class T > -inline T const* CUtlMemory::Base() const -{ - return m_pMemory; -} - - -//----------------------------------------------------------------------------- -// Size -//----------------------------------------------------------------------------- -template< class T > -inline int CUtlMemory::NumAllocated() const -{ - return m_nAllocationCount; -} - -template< class T > -inline int CUtlMemory::Count() const -{ - return m_nAllocationCount; -} - - -//----------------------------------------------------------------------------- -// Is element index valid? -//----------------------------------------------------------------------------- -template< class T > -inline bool CUtlMemory::IsIdxValid(int i) const -{ - return (i >= 0) && (i < m_nAllocationCount); -} - - -//----------------------------------------------------------------------------- -// Grows the memory -//----------------------------------------------------------------------------- -template< class T > -void CUtlMemory::Grow(int num) -{ - Assert(num > 0); - - if (IsExternallyAllocated()) - { - // Can't grow a buffer whose memory was externally allocated - Assert(0); - return; - } - - // Make sure we have at least numallocated + num allocations. - // Use the grow rules specified for this memory (in m_nGrowSize) - int nAllocationRequested = m_nAllocationCount + num; - while (m_nAllocationCount < nAllocationRequested) - { - if (m_nAllocationCount != 0) - { - if (m_nGrowSize) - { - m_nAllocationCount += m_nGrowSize; - } - else - { - m_nAllocationCount += m_nAllocationCount; - } - } - else - { - // Compute an allocation which is at least as big as a cache line... - m_nAllocationCount = (31 + sizeof(T)) / sizeof(T); - Assert(m_nAllocationCount != 0); - } - } - - if (m_pMemory) - { - m_pMemory = (T*)realloc(m_pMemory, m_nAllocationCount * sizeof(T)); - } - else - { - m_pMemory = (T*)malloc(m_nAllocationCount * sizeof(T)); - } -} - - -//----------------------------------------------------------------------------- -// Makes sure we've got at least this much memory -//----------------------------------------------------------------------------- -template< class T > -inline void CUtlMemory::EnsureCapacity(int num) -{ - if (m_nAllocationCount >= num) - return; - - if (IsExternallyAllocated()) - { - // Can't grow a buffer whose memory was externally allocated - Assert(0); - return; - } - - m_nAllocationCount = num; - if (m_pMemory) - { - m_pMemory = (T*)realloc(m_pMemory, m_nAllocationCount * sizeof(T)); - } - else - { - m_pMemory = (T*)malloc(m_nAllocationCount * sizeof(T)); - } -} - - -//----------------------------------------------------------------------------- -// Memory deallocation -//----------------------------------------------------------------------------- -template< class T > -void CUtlMemory::Purge() -{ - if (!IsExternallyAllocated()) - { - if (m_pMemory) - { - free((void*)m_pMemory); - m_pMemory = 0; - } - m_nAllocationCount = 0; - } -} - - +//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. =========== +// +// The copyright to the contents herein is the property of Valve, L.L.C. +// The contents may be used and/or copied only with the written permission of +// Valve, L.L.C., or in accordance with the terms and conditions stipulated in +// the agreement/contract under which the contents have been supplied. +// +// $Header: $ +// $NoKeywords: $ +// +// A growable memory class. +//============================================================================= + +#ifndef UTLMEMORY_H +#define UTLMEMORY_H + +#ifdef _WIN32 +#pragma once +#endif + +#include + +#pragma warning (disable:4100) +#pragma warning (disable:4514) + +#define Assert(expr) ((void)0) + +//----------------------------------------------------------------------------- +// The CUtlMemory class: +// A growable memory class which doubles in size by default. +//----------------------------------------------------------------------------- +template< class T > +class CUtlMemory +{ +public: + // constructor, destructor + CUtlMemory(int nGrowSize = 0, int nInitSize = 0); + CUtlMemory(T* pMemory, int numElements); + ~CUtlMemory(); + + // element access + T& operator[](int i); + T const& operator[](int i) const; + T& Element(int i); + T const& Element(int i) const; + + // Can we use this index? + bool IsIdxValid(int i) const; + + // Gets the base address (can change when adding elements!) + T* Base(); + T const* Base() const; + + // Attaches the buffer to external memory.... + void SetExternalBuffer(T* pMemory, int numElements); + + // Size + int NumAllocated() const; + int Count() const; + + // Grows the memory, so that at least allocated + num elements are allocated + void Grow(int num = 1); + + // Makes sure we've got at least this much memory + void EnsureCapacity(int num); + + // Memory deallocation + void Purge(); + + // is the memory externally allocated? + bool IsExternallyAllocated() const; + + // Set the size by which the memory grows + void SetGrowSize(int size); + +private: + enum + { + EXTERNAL_BUFFER_MARKER = -1, + }; + + T* m_pMemory; + int m_nAllocationCount; + int m_nGrowSize; +}; + + +//----------------------------------------------------------------------------- +// constructor, destructor +//----------------------------------------------------------------------------- +template< class T > +CUtlMemory::CUtlMemory(int nGrowSize, int nInitAllocationCount) : m_pMemory(0), +m_nAllocationCount(nInitAllocationCount), m_nGrowSize(nGrowSize) +{ + Assert((nGrowSize >= 0) && (nGrowSize != EXTERNAL_BUFFER_MARKER)); + if (m_nAllocationCount) + { + m_pMemory = (T*)malloc(m_nAllocationCount * sizeof(T)); + } +} + +template< class T > +CUtlMemory::CUtlMemory(T* pMemory, int numElements) : m_pMemory(pMemory), +m_nAllocationCount(numElements) +{ + // Special marker indicating externally supplied memory + m_nGrowSize = EXTERNAL_BUFFER_MARKER; +} + +template< class T > +CUtlMemory::~CUtlMemory() +{ + Purge(); +} + + +//----------------------------------------------------------------------------- +// Attaches the buffer to external memory.... +//----------------------------------------------------------------------------- +template< class T > +void CUtlMemory::SetExternalBuffer(T* pMemory, int numElements) +{ + // Blow away any existing allocated memory + Purge(); + + m_pMemory = pMemory; + m_nAllocationCount = numElements; + + // Indicate that we don't own the memory + m_nGrowSize = EXTERNAL_BUFFER_MARKER; +} + + +//----------------------------------------------------------------------------- +// element access +//----------------------------------------------------------------------------- +template< class T > +inline T& CUtlMemory::operator[](int i) +{ + Assert(IsIdxValid(i)); + return m_pMemory[i]; +} + +template< class T > +inline T const& CUtlMemory::operator[](int i) const +{ + Assert(IsIdxValid(i)); + return m_pMemory[i]; +} + +template< class T > +inline T& CUtlMemory::Element(int i) +{ + Assert(IsIdxValid(i)); + return m_pMemory[i]; +} + +template< class T > +inline T const& CUtlMemory::Element(int i) const +{ + Assert(IsIdxValid(i)); + return m_pMemory[i]; +} + + +//----------------------------------------------------------------------------- +// is the memory externally allocated? +//----------------------------------------------------------------------------- +template< class T > +bool CUtlMemory::IsExternallyAllocated() const +{ + return m_nGrowSize == EXTERNAL_BUFFER_MARKER; +} + + +template< class T > +void CUtlMemory::SetGrowSize(int nSize) +{ + Assert((nSize >= 0) && (nSize != EXTERNAL_BUFFER_MARKER)); + m_nGrowSize = nSize; +} + + +//----------------------------------------------------------------------------- +// Gets the base address (can change when adding elements!) +//----------------------------------------------------------------------------- +template< class T > +inline T* CUtlMemory::Base() +{ + return m_pMemory; +} + +template< class T > +inline T const* CUtlMemory::Base() const +{ + return m_pMemory; +} + + +//----------------------------------------------------------------------------- +// Size +//----------------------------------------------------------------------------- +template< class T > +inline int CUtlMemory::NumAllocated() const +{ + return m_nAllocationCount; +} + +template< class T > +inline int CUtlMemory::Count() const +{ + return m_nAllocationCount; +} + + +//----------------------------------------------------------------------------- +// Is element index valid? +//----------------------------------------------------------------------------- +template< class T > +inline bool CUtlMemory::IsIdxValid(int i) const +{ + return (i >= 0) && (i < m_nAllocationCount); +} + + +//----------------------------------------------------------------------------- +// Grows the memory +//----------------------------------------------------------------------------- +template< class T > +void CUtlMemory::Grow(int num) +{ + Assert(num > 0); + + if (IsExternallyAllocated()) + { + // Can't grow a buffer whose memory was externally allocated + Assert(0); + return; + } + + // Make sure we have at least numallocated + num allocations. + // Use the grow rules specified for this memory (in m_nGrowSize) + int nAllocationRequested = m_nAllocationCount + num; + while (m_nAllocationCount < nAllocationRequested) + { + if (m_nAllocationCount != 0) + { + if (m_nGrowSize) + { + m_nAllocationCount += m_nGrowSize; + } + else + { + m_nAllocationCount += m_nAllocationCount; + } + } + else + { + // Compute an allocation which is at least as big as a cache line... + m_nAllocationCount = (31 + sizeof(T)) / sizeof(T); + Assert(m_nAllocationCount != 0); + } + } + + if (m_pMemory) + { + m_pMemory = (T*)realloc(m_pMemory, m_nAllocationCount * sizeof(T)); + } + else + { + m_pMemory = (T*)malloc(m_nAllocationCount * sizeof(T)); + } +} + + +//----------------------------------------------------------------------------- +// Makes sure we've got at least this much memory +//----------------------------------------------------------------------------- +template< class T > +inline void CUtlMemory::EnsureCapacity(int num) +{ + if (m_nAllocationCount >= num) + return; + + if (IsExternallyAllocated()) + { + // Can't grow a buffer whose memory was externally allocated + Assert(0); + return; + } + + m_nAllocationCount = num; + if (m_pMemory) + { + m_pMemory = (T*)realloc(m_pMemory, m_nAllocationCount * sizeof(T)); + } + else + { + m_pMemory = (T*)malloc(m_nAllocationCount * sizeof(T)); + } +} + + +//----------------------------------------------------------------------------- +// Memory deallocation +//----------------------------------------------------------------------------- +template< class T > +void CUtlMemory::Purge() +{ + if (!IsExternallyAllocated()) + { + if (m_pMemory) + { + free((void*)m_pMemory); + m_pMemory = 0; + } + m_nAllocationCount = 0; + } +} + + #endif // UTLSTORAGE_H \ No newline at end of file diff --git a/revoice/src/SteamP2PCodec.cpp b/revoice/src/SteamP2PCodec.cpp index b1cc45f..406aa49 100644 --- a/revoice/src/SteamP2PCodec.cpp +++ b/revoice/src/SteamP2PCodec.cpp @@ -1,151 +1,151 @@ -#include "precompiled.h" - -CSteamP2PCodec::CSteamP2PCodec(IVoiceCodec *backend) -{ - m_BackendCodec = backend; -} - -bool CSteamP2PCodec::Init(int quality) -{ - return m_BackendCodec->Init(quality); -} - -void CSteamP2PCodec::SetClient(IGameClient *client) -{ - m_Client = client; -} - -void CSteamP2PCodec::Release() -{ - m_BackendCodec->Release(); - delete this; -} - -bool CSteamP2PCodec::ResetState() -{ - return m_BackendCodec->ResetState(); -} - -int CSteamP2PCodec::StreamDecode(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes) const -{ - const char *maxReadPos = pCompressed + compressedBytes; - const char *readPos = pCompressed; - - while (readPos < maxReadPos) - { - PayLoadType opcode = *(PayLoadType *)readPos; - readPos++; - - switch (opcode) - { - // Set sampling rate - case PLT_SamplingRate: - { - if (readPos + 2 > maxReadPos) { - return 0; - } - readPos += 2; - break; - } - // Voice payload - case PLT_Silk: // silk deprecated - case PLT_OPUS: // opus deprecated - { - break; - } - case PLT_OPUS_PLC: // opus plc - { - if (readPos + 2 > maxReadPos) { - return 0; - } - - uint16 len = *(uint16 *)readPos; - readPos += 2; - - if (readPos + len > maxReadPos) { - return 0; - } - - int decompressedLen = m_BackendCodec->Decompress(readPos, len, pUncompressed, maxUncompressedBytes); - return decompressedLen; - } - - // Invalid or unknown opcode - default: - // LCPrintf(true, "CSteamP2PCodec::StreamDecode() called on client(%d) with unknown voice codec opcode (%d)\n", m_Client->GetId(), opcode); - return 0; - } - } - - // no voice payload in the stream - return 0; -} - -int CSteamP2PCodec::StreamEncode(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal) const -{ - char *writePos = pCompressed; - - if (maxCompressedBytes < 10) { // no room - return 0; - } - - *(writePos++) = PLT_SamplingRate; // Set sampling rate - *(uint16 *)writePos = 16000; - writePos += 2; - - *(writePos++) = PLT_Silk; // Voice payload - - int compressRes = m_BackendCodec->Compress(pUncompressedBytes, nSamples, writePos + 2, maxCompressedBytes - (1 + 2 + 1 + 2), bFinal); - if (compressRes == 0) { - return 0; - } - - *(uint16 *)writePos = compressRes; - writePos += 2; - writePos += compressRes; - - return writePos - pCompressed; -} - -int CSteamP2PCodec::Decompress(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes) -{ - if (compressedBytes < 12) { - return 0; - } - - uint32 computedChecksum = crc32(pCompressed, compressedBytes - 4); - uint32 wireChecksum = *(uint32 *)(pCompressed + compressedBytes - 4); - - if (computedChecksum != wireChecksum) { - return 0; - } - - return StreamDecode(pCompressed + 8, compressedBytes - 12, pUncompressed, maxUncompressedBytes); -} - -int CSteamP2PCodec::Compress(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal) -{ - if (maxCompressedBytes < 12) { // no room - return 0; - } - - char *writePos = pCompressed; - *(uint32 *)writePos = 0x00000011; // steamid (low part) - writePos += 4; - - *(uint32 *)writePos = 0x01100001; // steamid (high part) - writePos += 4; - - int encodeRes = StreamEncode(pUncompressedBytes, nSamples, writePos, maxCompressedBytes - 12, bFinal); - if (encodeRes <= 0) { - return 0; - } - - writePos += encodeRes; - - uint32 cksum = crc32(pCompressed, writePos - pCompressed); - *(uint32 *)writePos = cksum; - writePos += 4; - - return writePos - pCompressed; -} +#include "precompiled.h" + +CSteamP2PCodec::CSteamP2PCodec(IVoiceCodec *backend) +{ + m_BackendCodec = backend; +} + +bool CSteamP2PCodec::Init(int quality) +{ + return m_BackendCodec->Init(quality); +} + +void CSteamP2PCodec::SetClient(IGameClient *client) +{ + m_Client = client; +} + +void CSteamP2PCodec::Release() +{ + m_BackendCodec->Release(); + delete this; +} + +bool CSteamP2PCodec::ResetState() +{ + return m_BackendCodec->ResetState(); +} + +int CSteamP2PCodec::StreamDecode(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes) const +{ + const char *maxReadPos = pCompressed + compressedBytes; + const char *readPos = pCompressed; + + while (readPos < maxReadPos) + { + PayLoadType opcode = *(PayLoadType *)readPos; + readPos++; + + switch (opcode) + { + // Set sampling rate + case PLT_SamplingRate: + { + if (readPos + 2 > maxReadPos) { + return 0; + } + readPos += 2; + break; + } + // Voice payload + case PLT_Silk: // silk deprecated + case PLT_OPUS: // opus deprecated + { + break; + } + case PLT_OPUS_PLC: // opus plc + { + if (readPos + 2 > maxReadPos) { + return 0; + } + + uint16 len = *(uint16 *)readPos; + readPos += 2; + + if (readPos + len > maxReadPos) { + return 0; + } + + int decompressedLen = m_BackendCodec->Decompress(readPos, len, pUncompressed, maxUncompressedBytes); + return decompressedLen; + } + + // Invalid or unknown opcode + default: + // LCPrintf(true, "CSteamP2PCodec::StreamDecode() called on client(%d) with unknown voice codec opcode (%d)\n", m_Client->GetId(), opcode); + return 0; + } + } + + // no voice payload in the stream + return 0; +} + +int CSteamP2PCodec::StreamEncode(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal) const +{ + char *writePos = pCompressed; + + if (maxCompressedBytes < 10) { // no room + return 0; + } + + *(writePos++) = PLT_SamplingRate; // Set sampling rate + *(uint16 *)writePos = 16000; + writePos += 2; + + *(writePos++) = PLT_Silk; // Voice payload + + int compressRes = m_BackendCodec->Compress(pUncompressedBytes, nSamples, writePos + 2, maxCompressedBytes - (1 + 2 + 1 + 2), bFinal); + if (compressRes == 0) { + return 0; + } + + *(uint16 *)writePos = compressRes; + writePos += 2; + writePos += compressRes; + + return writePos - pCompressed; +} + +int CSteamP2PCodec::Decompress(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes) +{ + if (compressedBytes < 12) { + return 0; + } + + uint32 computedChecksum = crc32(pCompressed, compressedBytes - 4); + uint32 wireChecksum = *(uint32 *)(pCompressed + compressedBytes - 4); + + if (computedChecksum != wireChecksum) { + return 0; + } + + return StreamDecode(pCompressed + 8, compressedBytes - 12, pUncompressed, maxUncompressedBytes); +} + +int CSteamP2PCodec::Compress(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal) +{ + if (maxCompressedBytes < 12) { // no room + return 0; + } + + char *writePos = pCompressed; + *(uint32 *)writePos = 0x00000011; // steamid (low part) + writePos += 4; + + *(uint32 *)writePos = 0x01100001; // steamid (high part) + writePos += 4; + + int encodeRes = StreamEncode(pUncompressedBytes, nSamples, writePos, maxCompressedBytes - 12, bFinal); + if (encodeRes <= 0) { + return 0; + } + + writePos += encodeRes; + + uint32 cksum = crc32(pCompressed, writePos - pCompressed); + *(uint32 *)writePos = cksum; + writePos += 4; + + return writePos - pCompressed; +} diff --git a/revoice/src/SteamP2PCodec.h b/revoice/src/SteamP2PCodec.h index f8a99c3..d0b759b 100644 --- a/revoice/src/SteamP2PCodec.h +++ b/revoice/src/SteamP2PCodec.h @@ -1,39 +1,39 @@ -#pragma once - -#include "revoice_shared.h" -#include "IVoiceCodec.h" - -class CSteamP2PCodec: public IVoiceCodec { -public: - CSteamP2PCodec(IVoiceCodec *backend); - - enum PayLoadType : uint8 - { - PLT_Silence = 0, // Number of empty samples, which should be set to NULL. - PLT_UnknownCodec = 1, - PLT_Speex = 2, - PLT_Raw = 3, - PLT_Silk = 4, - PLT_OPUS = 5, - PLT_OPUS_PLC = 6, - PLT_Unknown = 10, - PLT_SamplingRate = 11 - }; - - virtual bool Init(int quality); - virtual void Release(); - virtual int Compress(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal); - virtual int Decompress(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes); - virtual bool ResetState(); - - void SetClient(IGameClient *client); - IVoiceCodec *GetCodec() const { return m_BackendCodec; } - -private: - int StreamDecode(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes) const; - int StreamEncode(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal) const; - -private: - IGameClient *m_Client; - IVoiceCodec *m_BackendCodec; -}; +#pragma once + +#include "revoice_shared.h" +#include "IVoiceCodec.h" + +class CSteamP2PCodec: public IVoiceCodec { +public: + CSteamP2PCodec(IVoiceCodec *backend); + + enum PayLoadType : uint8 + { + PLT_Silence = 0, // Number of empty samples, which should be set to NULL. + PLT_UnknownCodec = 1, + PLT_Speex = 2, + PLT_Raw = 3, + PLT_Silk = 4, + PLT_OPUS = 5, + PLT_OPUS_PLC = 6, + PLT_Unknown = 10, + PLT_SamplingRate = 11 + }; + + virtual bool Init(int quality); + virtual void Release(); + virtual int Compress(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal); + virtual int Decompress(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes); + virtual bool ResetState(); + + void SetClient(IGameClient *client); + IVoiceCodec *GetCodec() const { return m_BackendCodec; } + +private: + int StreamDecode(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes) const; + int StreamEncode(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal) const; + +private: + IGameClient *m_Client; + IVoiceCodec *m_BackendCodec; +}; diff --git a/revoice/src/VoiceEncoder_Silk.cpp b/revoice/src/VoiceEncoder_Silk.cpp index 6a61820..f33baa1 100644 --- a/revoice/src/VoiceEncoder_Silk.cpp +++ b/revoice/src/VoiceEncoder_Silk.cpp @@ -1,215 +1,215 @@ -#include "precompiled.h" - -VoiceEncoder_Silk::VoiceEncoder_Silk() -{ - m_pEncoder = nullptr; - m_pDecoder = nullptr; - m_targetRate_bps = 25000; - m_packetLoss_perc = 0; -} - -VoiceEncoder_Silk::~VoiceEncoder_Silk() -{ - if (m_pEncoder) { - free(m_pEncoder); - m_pEncoder = nullptr; - } - - if (m_pDecoder) { - free(m_pDecoder); - m_pDecoder = nullptr; - } -} - -bool VoiceEncoder_Silk::Init(int quality) -{ - m_targetRate_bps = 25000; - m_packetLoss_perc = 0; - - int encSizeBytes; - SKP_Silk_SDK_Get_Encoder_Size(&encSizeBytes); - m_pEncoder = malloc(encSizeBytes); - SKP_Silk_SDK_InitEncoder(m_pEncoder, &this->m_encControl); - - int decSizeBytes; - SKP_Silk_SDK_Get_Decoder_Size(&decSizeBytes); - m_pDecoder = malloc(decSizeBytes); - SKP_Silk_SDK_InitDecoder(m_pDecoder); - - return true; -} - -void VoiceEncoder_Silk::Release() -{ - delete this; -} - -bool VoiceEncoder_Silk::ResetState() -{ - if (m_pEncoder) - SKP_Silk_SDK_InitEncoder(m_pEncoder, &this->m_encControl); - - if (m_pDecoder) - SKP_Silk_SDK_InitDecoder(m_pDecoder); - - m_bufOverflowBytes.Clear(); - - return true; -} - -int VoiceEncoder_Silk::Compress(const char *pUncompressedIn, int nSamplesIn, char *pCompressed, int maxCompressedBytes, bool bFinal) -{ - signed int nSamplesToUse; // edi@4 - const __int16 *psRead; // ecx@4 - int nSamples; // edi@5 - int nSamplesToEncode; // esi@6 - char *pWritePos; // ebp@6 - int nSamplesPerFrame; // [sp+28h] [bp-44h]@5 - const char *pWritePosMax; // [sp+2Ch] [bp-40h]@5 - int nSamplesRemaining; // [sp+38h] [bp-34h]@5 - - const int inSampleRate = 8000; - const int nSampleDataMinMS = 100; - const int nSamplesMin = inSampleRate * nSampleDataMinMS / 1000; - - /* - if ((nSamplesIn + m_bufOverflowBytes.TellPut() / 2) < nSamplesMin && !bFinal) { - m_bufOverflowBytes.Put(pUncompressedIn, 2 * nSamplesIn); - return 0; - } - */ - - if (m_bufOverflowBytes.TellPut()) { - m_bufOverflowBytes.Put(pUncompressedIn, 2 * nSamplesIn); - - psRead = (const __int16 *)m_bufOverflowBytes.Base(); - nSamplesToUse = m_bufOverflowBytes.TellPut() / 2; - } else { - psRead = (const __int16 *)pUncompressedIn; - nSamplesToUse = nSamplesIn; - } - - nSamplesPerFrame = inSampleRate / 50; - nSamplesRemaining = nSamplesToUse % nSamplesPerFrame; - pWritePosMax = pCompressed + maxCompressedBytes; - nSamples = nSamplesToUse - nSamplesRemaining; - pWritePos = pCompressed; - - while (nSamples > 0) - { - int16 *pWritePayloadSize = (int16 *)pWritePos; - pWritePos += sizeof(int16); //leave 2 bytes for the frame size (will be written after encoding) - - int originalNBytes = (pWritePosMax - pWritePos > 0xFFFF) ? -1 : (pWritePosMax - pWritePos); - nSamplesToEncode = (nSamples < nSamplesPerFrame) ? nSamples : nSamplesPerFrame; - - this->m_encControl.useDTX = 0; - this->m_encControl.maxInternalSampleRate = 16000; - this->m_encControl.useInBandFEC = 0; - this->m_encControl.API_sampleRate = inSampleRate; - this->m_encControl.complexity = 2; - this->m_encControl.packetSize = 20 * (inSampleRate / 1000); - this->m_encControl.packetLossPercentage = this->m_packetLoss_perc; - this->m_encControl.bitRate = (m_targetRate_bps >= 0) ? m_targetRate_bps : 0; - - nSamples -= nSamplesToEncode; - - int16 nBytes = originalNBytes; - int res = SKP_Silk_SDK_Encode(this->m_pEncoder, &this->m_encControl, psRead, nSamplesToEncode, (unsigned char *)pWritePos, &nBytes); - *pWritePayloadSize = nBytes; //write frame size - - pWritePos += nBytes; - psRead += nSamplesToEncode; - } - - m_bufOverflowBytes.Clear(); - - if (nSamplesRemaining <= nSamplesIn && nSamplesRemaining) { - m_bufOverflowBytes.Put(&pUncompressedIn[2 * (nSamplesIn - nSamplesRemaining)], 2 * nSamplesRemaining); - } - - if (bFinal) - { - ResetState(); - - if (pWritePosMax > pWritePos + 2) { - uint16 *pWriteEndFlag = (uint16*)pWritePos; - pWritePos += sizeof(uint16); - *pWriteEndFlag = 0xFFFF; - } - } - - return pWritePos - pCompressed; -} - -int VoiceEncoder_Silk::Decompress(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes) -{ - int nPayloadSize; // ebp@2 - char *pWritePos; // ebx@5 - const char *pReadPos; // edx@5 - char *pWritePosMax; // [sp+28h] [bp-44h]@4 - const char *pReadPosMax; // [sp+3Ch] [bp-30h]@1 - - const int outSampleRate = 8000; - - m_decControl.API_sampleRate = outSampleRate; - int nSamplesPerFrame = outSampleRate / 50; - - if (compressedBytes <= 0) { - return 0; - } - - pReadPosMax = &pCompressed[compressedBytes]; - pReadPos = pCompressed; - - pWritePos = pUncompressed; - pWritePosMax = &pUncompressed[maxUncompressedBytes]; - - while (pReadPos < pReadPosMax) - { - if (pReadPosMax - pReadPos < 2) { - break; - } - - nPayloadSize = *(uint16 *)pReadPos; - pReadPos += sizeof(uint16); - - if (nPayloadSize == 0xFFFF) { - ResetState(); - break; - } - - if (nPayloadSize == 0) { - //DTX (discontinued transmission) - int numEmptySamples = nSamplesPerFrame; - short nSamples = (pWritePosMax - pWritePos) / 2; - - if (nSamples < numEmptySamples) { - break; - } - - memset(pWritePos, 0, numEmptySamples * 2); - pWritePos += numEmptySamples * 2; - - continue; - } - - if ((pReadPos + nPayloadSize) > pReadPosMax) { - break; - } - - do { - short nSamples = (pWritePosMax - pWritePos) / 2; - int decodeRes = SKP_Silk_SDK_Decode(m_pDecoder, &m_decControl, 0, (const unsigned char*)pReadPos, nPayloadSize, (__int16 *)pWritePos, &nSamples); - - if (SKP_SILK_NO_ERROR != decodeRes) { - return (pWritePos - pUncompressed) / 2; - } - - pWritePos += nSamples * sizeof(int16); - } while (m_decControl.moreInternalDecoderFrames); - pReadPos += nPayloadSize; - } - - return (pWritePos - pUncompressed) / 2; +#include "precompiled.h" + +VoiceEncoder_Silk::VoiceEncoder_Silk() +{ + m_pEncoder = nullptr; + m_pDecoder = nullptr; + m_targetRate_bps = 25000; + m_packetLoss_perc = 0; +} + +VoiceEncoder_Silk::~VoiceEncoder_Silk() +{ + if (m_pEncoder) { + free(m_pEncoder); + m_pEncoder = nullptr; + } + + if (m_pDecoder) { + free(m_pDecoder); + m_pDecoder = nullptr; + } +} + +bool VoiceEncoder_Silk::Init(int quality) +{ + m_targetRate_bps = 25000; + m_packetLoss_perc = 0; + + int encSizeBytes; + SKP_Silk_SDK_Get_Encoder_Size(&encSizeBytes); + m_pEncoder = malloc(encSizeBytes); + SKP_Silk_SDK_InitEncoder(m_pEncoder, &this->m_encControl); + + int decSizeBytes; + SKP_Silk_SDK_Get_Decoder_Size(&decSizeBytes); + m_pDecoder = malloc(decSizeBytes); + SKP_Silk_SDK_InitDecoder(m_pDecoder); + + return true; +} + +void VoiceEncoder_Silk::Release() +{ + delete this; +} + +bool VoiceEncoder_Silk::ResetState() +{ + if (m_pEncoder) + SKP_Silk_SDK_InitEncoder(m_pEncoder, &this->m_encControl); + + if (m_pDecoder) + SKP_Silk_SDK_InitDecoder(m_pDecoder); + + m_bufOverflowBytes.Clear(); + + return true; +} + +int VoiceEncoder_Silk::Compress(const char *pUncompressedIn, int nSamplesIn, char *pCompressed, int maxCompressedBytes, bool bFinal) +{ + signed int nSamplesToUse; // edi@4 + const __int16 *psRead; // ecx@4 + int nSamples; // edi@5 + int nSamplesToEncode; // esi@6 + char *pWritePos; // ebp@6 + int nSamplesPerFrame; // [sp+28h] [bp-44h]@5 + const char *pWritePosMax; // [sp+2Ch] [bp-40h]@5 + int nSamplesRemaining; // [sp+38h] [bp-34h]@5 + + const int inSampleRate = 8000; + const int nSampleDataMinMS = 100; + const int nSamplesMin = inSampleRate * nSampleDataMinMS / 1000; + + /* + if ((nSamplesIn + m_bufOverflowBytes.TellPut() / 2) < nSamplesMin && !bFinal) { + m_bufOverflowBytes.Put(pUncompressedIn, 2 * nSamplesIn); + return 0; + } + */ + + if (m_bufOverflowBytes.TellPut()) { + m_bufOverflowBytes.Put(pUncompressedIn, 2 * nSamplesIn); + + psRead = (const __int16 *)m_bufOverflowBytes.Base(); + nSamplesToUse = m_bufOverflowBytes.TellPut() / 2; + } else { + psRead = (const __int16 *)pUncompressedIn; + nSamplesToUse = nSamplesIn; + } + + nSamplesPerFrame = inSampleRate / 50; + nSamplesRemaining = nSamplesToUse % nSamplesPerFrame; + pWritePosMax = pCompressed + maxCompressedBytes; + nSamples = nSamplesToUse - nSamplesRemaining; + pWritePos = pCompressed; + + while (nSamples > 0) + { + int16 *pWritePayloadSize = (int16 *)pWritePos; + pWritePos += sizeof(int16); //leave 2 bytes for the frame size (will be written after encoding) + + int originalNBytes = (pWritePosMax - pWritePos > 0xFFFF) ? -1 : (pWritePosMax - pWritePos); + nSamplesToEncode = (nSamples < nSamplesPerFrame) ? nSamples : nSamplesPerFrame; + + this->m_encControl.useDTX = 0; + this->m_encControl.maxInternalSampleRate = 16000; + this->m_encControl.useInBandFEC = 0; + this->m_encControl.API_sampleRate = inSampleRate; + this->m_encControl.complexity = 2; + this->m_encControl.packetSize = 20 * (inSampleRate / 1000); + this->m_encControl.packetLossPercentage = this->m_packetLoss_perc; + this->m_encControl.bitRate = (m_targetRate_bps >= 0) ? m_targetRate_bps : 0; + + nSamples -= nSamplesToEncode; + + int16 nBytes = originalNBytes; + int res = SKP_Silk_SDK_Encode(this->m_pEncoder, &this->m_encControl, psRead, nSamplesToEncode, (unsigned char *)pWritePos, &nBytes); + *pWritePayloadSize = nBytes; //write frame size + + pWritePos += nBytes; + psRead += nSamplesToEncode; + } + + m_bufOverflowBytes.Clear(); + + if (nSamplesRemaining <= nSamplesIn && nSamplesRemaining) { + m_bufOverflowBytes.Put(&pUncompressedIn[2 * (nSamplesIn - nSamplesRemaining)], 2 * nSamplesRemaining); + } + + if (bFinal) + { + ResetState(); + + if (pWritePosMax > pWritePos + 2) { + uint16 *pWriteEndFlag = (uint16*)pWritePos; + pWritePos += sizeof(uint16); + *pWriteEndFlag = 0xFFFF; + } + } + + return pWritePos - pCompressed; +} + +int VoiceEncoder_Silk::Decompress(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes) +{ + int nPayloadSize; // ebp@2 + char *pWritePos; // ebx@5 + const char *pReadPos; // edx@5 + char *pWritePosMax; // [sp+28h] [bp-44h]@4 + const char *pReadPosMax; // [sp+3Ch] [bp-30h]@1 + + const int outSampleRate = 8000; + + m_decControl.API_sampleRate = outSampleRate; + int nSamplesPerFrame = outSampleRate / 50; + + if (compressedBytes <= 0) { + return 0; + } + + pReadPosMax = &pCompressed[compressedBytes]; + pReadPos = pCompressed; + + pWritePos = pUncompressed; + pWritePosMax = &pUncompressed[maxUncompressedBytes]; + + while (pReadPos < pReadPosMax) + { + if (pReadPosMax - pReadPos < 2) { + break; + } + + nPayloadSize = *(uint16 *)pReadPos; + pReadPos += sizeof(uint16); + + if (nPayloadSize == 0xFFFF) { + ResetState(); + break; + } + + if (nPayloadSize == 0) { + //DTX (discontinued transmission) + int numEmptySamples = nSamplesPerFrame; + short nSamples = (pWritePosMax - pWritePos) / 2; + + if (nSamples < numEmptySamples) { + break; + } + + memset(pWritePos, 0, numEmptySamples * 2); + pWritePos += numEmptySamples * 2; + + continue; + } + + if ((pReadPos + nPayloadSize) > pReadPosMax) { + break; + } + + do { + short nSamples = (pWritePosMax - pWritePos) / 2; + int decodeRes = SKP_Silk_SDK_Decode(m_pDecoder, &m_decControl, 0, (const unsigned char*)pReadPos, nPayloadSize, (__int16 *)pWritePos, &nSamples); + + if (SKP_SILK_NO_ERROR != decodeRes) { + return (pWritePos - pUncompressed) / 2; + } + + pWritePos += nSamples * sizeof(int16); + } while (m_decControl.moreInternalDecoderFrames); + pReadPos += nPayloadSize; + } + + return (pWritePos - pUncompressed) / 2; } \ No newline at end of file diff --git a/revoice/src/VoiceEncoder_Silk.h b/revoice/src/VoiceEncoder_Silk.h index c3c0d35..ebbdff5 100644 --- a/revoice/src/VoiceEncoder_Silk.h +++ b/revoice/src/VoiceEncoder_Silk.h @@ -1,31 +1,31 @@ -#pragma once - -#include "IVoiceCodec.h" -#include "utlbuffer.h" -#include "SKP_Silk_SDK_API.h" - -class VoiceEncoder_Silk : public IVoiceCodec { -private: - void * m_pEncoder; /* 4 4 */ - //int m_API_fs_Hz; /* 8 4 */ - int m_targetRate_bps; /* 12 4 */ - int m_packetLoss_perc; /* 16 4 */ - SKP_SILK_SDK_EncControlStruct m_encControl; /* 20 32 */ - CUtlBuffer m_bufOverflowBytes; /* 52 24 */ - - void * m_pDecoder; /* 76 4 */ - SKP_SILK_SDK_DecControlStruct m_decControl; /* 80 20 */ - -public: - VoiceEncoder_Silk(); - - virtual ~VoiceEncoder_Silk(); - - virtual bool Init(int quality); - virtual void Release(); - virtual bool ResetState(); - virtual int Compress(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal); - virtual int Decompress(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes); - - int GetNumQueuedEncodingSamples() const { return m_bufOverflowBytes.TellPut() / 2; } -}; /* size: 100 */ +#pragma once + +#include "IVoiceCodec.h" +#include "utlbuffer.h" +#include "SKP_Silk_SDK_API.h" + +class VoiceEncoder_Silk : public IVoiceCodec { +private: + void * m_pEncoder; /* 4 4 */ + //int m_API_fs_Hz; /* 8 4 */ + int m_targetRate_bps; /* 12 4 */ + int m_packetLoss_perc; /* 16 4 */ + SKP_SILK_SDK_EncControlStruct m_encControl; /* 20 32 */ + CUtlBuffer m_bufOverflowBytes; /* 52 24 */ + + void * m_pDecoder; /* 76 4 */ + SKP_SILK_SDK_DecControlStruct m_decControl; /* 80 20 */ + +public: + VoiceEncoder_Silk(); + + virtual ~VoiceEncoder_Silk(); + + virtual bool Init(int quality); + virtual void Release(); + virtual bool ResetState(); + virtual int Compress(const char *pUncompressedBytes, int nSamples, char *pCompressed, int maxCompressedBytes, bool bFinal); + virtual int Decompress(const char *pCompressed, int compressedBytes, char *pUncompressed, int maxUncompressedBytes); + + int GetNumQueuedEncodingSamples() const { return m_bufOverflowBytes.TellPut() / 2; } +}; /* size: 100 */ diff --git a/revoice/src/dllapi.cpp b/revoice/src/dllapi.cpp index 8b5e149..0d38aca 100644 --- a/revoice/src/dllapi.cpp +++ b/revoice/src/dllapi.cpp @@ -1,208 +1,208 @@ -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#include "precompiled.h" - -DLL_FUNCTIONS g_DLLFuncTable = -{ - NULL, // pfnGameInit - NULL, // pfnSpawn - NULL, // pfnThink - NULL, // pfnUse - NULL, // pfnTouch - NULL, // pfnBlocked - NULL, // pfnKeyValue - NULL, // pfnSave - NULL, // pfnRestore - NULL, // pfnSetAbsBox - NULL, // pfnSaveWriteFields - NULL, // pfnSaveReadFields - NULL, // pfnSaveGlobalState - NULL, // pfnRestoreGlobalState - NULL, // pfnResetGlobalState - &ClientConnect_PreHook, // pfnClientDisconnect - NULL, // pfnClientDisconnect - NULL, // pfnClientKill - NULL, // pfnClientPutInServer - NULL, // pfnClientCommand - NULL, // pfnClientUserInfoChanged - NULL, // pfnServerActivate - NULL, // pfnServerDeactivate - NULL, // pfnPlayerPreThink - NULL, // pfnPlayerPostThink - NULL, // pfnStartFrame - NULL, // pfnParmsNewLevel - NULL, // pfnParmsChangeLevel - NULL, // pfnGetGameDescription - NULL, // pfnPlayerCustomization - NULL, // pfnSpectatorConnect - NULL, // pfnSpectatorDisconnect - NULL, // pfnSpectatorThink - NULL, // pfnSys_Error - NULL, // pfnPM_Move - NULL, // pfnPM_Init - NULL, // pfnPM_FindTextureType - NULL, // pfnSetupVisibility - NULL, // pfnUpdateClientData - NULL, // pfnAddToFullPack - NULL, // pfnCreateBaseline - NULL, // pfnRegisterEncoders - NULL, // pfnGetWeaponData - NULL, // pfnCmdStart - NULL, // pfnCmdEnd - NULL, // pfnConnectionlessPacket - NULL, // pfnGetHullBounds - NULL, // pfnCreateInstancedBaselines - NULL, // pfnInconsistentFile - NULL, // pfnAllowLagCompensation -}; - -DLL_FUNCTIONS g_DLLFuncTable_Post = -{ - NULL, // pfnGameInit - NULL, // pfnSpawn - NULL, // pfnThink - NULL, // pfnUse - NULL, // pfnTouch - NULL, // pfnBlocked - NULL, // pfnKeyValue - NULL, // pfnSave - NULL, // pfnRestore - NULL, // pfnSetAbsBox - NULL, // pfnSaveWriteFields - NULL, // pfnSaveReadFields - NULL, // pfnSaveGlobalState - NULL, // pfnRestoreGlobalState - NULL, // pfnResetGlobalState - NULL, // pfnClientConnect - NULL, // pfnClientDisconnect - NULL, // pfnClientKill - NULL, // pfnClientPutInServer - NULL, // pfnClientCommand - NULL, // pfnClientUserInfoChanged - &ServerActivate_PostHook, // pfnServerActivate - NULL, // pfnServerDeactivate - NULL, // pfnPlayerPreThink - NULL, // pfnPlayerPostThink - NULL, // pfnStartFrame - NULL, // pfnParmsNewLevel - NULL, // pfnParmsChangeLevel - NULL, // pfnGetGameDescription - NULL, // pfnPlayerCustomization - NULL, // pfnSpectatorConnect - NULL, // pfnSpectatorDisconnect - NULL, // pfnSpectatorThink - NULL, // pfnSys_Error - NULL, // pfnPM_Move - NULL, // pfnPM_Init - NULL, // pfnPM_FindTextureType - NULL, // pfnSetupVisibility - NULL, // pfnUpdateClientData - NULL, // pfnAddToFullPack - NULL, // pfnCreateBaseline - NULL, // pfnRegisterEncoders - NULL, // pfnGetWeaponData - NULL, // pfnCmdStart - NULL, // pfnCmdEnd - NULL, // pfnConnectionlessPacket - NULL, // pfnGetHullBounds - NULL, // pfnCreateInstancedBaselines - NULL, // pfnInconsistentFile - NULL, // pfnAllowLagCompensation -}; - -NEW_DLL_FUNCTIONS g_NewDLLFuncTable = -{ - NULL, //! pfnOnFreeEntPrivateData() Called right before the object's memory is freed. Calls its destructor. - NULL, //! pfnGameShutdown() - NULL, //! pfnShouldCollide() - NULL, //! pfnCvarValue() - &CvarValue2_PreHook, //! pfnCvarValue2() -}; - -C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion) -{ - if (!pFunctionTable) - { - UTIL_LogPrintf("GetEntityAPI2 called with null pFunctionTable"); - return FALSE; - } - - if (*interfaceVersion != INTERFACE_VERSION) - { - UTIL_LogPrintf("GetEntityAPI2 version mismatch; requested=%d ours=%d", *interfaceVersion, INTERFACE_VERSION); - //! Tell metamod what version we had, so it can figure out who is out of date. - *interfaceVersion = INTERFACE_VERSION; - return FALSE; - } - - memcpy(pFunctionTable, &g_DLLFuncTable, sizeof(DLL_FUNCTIONS)); - return TRUE; -} - -C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion) -{ - if (!pFunctionTable) - { - ALERT(at_logged, "%s called with null pFunctionTable", __FUNCTION__); - return FALSE; - } - - if (*interfaceVersion != INTERFACE_VERSION) - { - ALERT(at_logged, "%s version mismatch; requested=%d ours=%d", __FUNCTION__, *interfaceVersion, INTERFACE_VERSION); - *interfaceVersion = INTERFACE_VERSION; - return FALSE; - } - - memcpy(pFunctionTable, &g_DLLFuncTable_Post, sizeof(DLL_FUNCTIONS)); - return TRUE; -} - -C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion) -{ - if (!pNewFunctionTable) - { - UTIL_LogPrintf("GetNewDLLFunctions called with null pNewFunctionTable"); - return(FALSE); - } - - if (*interfaceVersion != NEW_DLL_FUNCTIONS_VERSION) - { - UTIL_LogPrintf("GetNewDLLFunctions version mismatch; requested=%d ours=%d", *interfaceVersion, NEW_DLL_FUNCTIONS_VERSION); - //! Tell metamod what version we had, so it can figure out who is out of date. - *interfaceVersion = NEW_DLL_FUNCTIONS_VERSION; - return FALSE; - } - - memcpy(pNewFunctionTable, &g_NewDLLFuncTable, sizeof(NEW_DLL_FUNCTIONS)); - return TRUE; -} +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#include "precompiled.h" + +DLL_FUNCTIONS g_DLLFuncTable = +{ + NULL, // pfnGameInit + NULL, // pfnSpawn + NULL, // pfnThink + NULL, // pfnUse + NULL, // pfnTouch + NULL, // pfnBlocked + NULL, // pfnKeyValue + NULL, // pfnSave + NULL, // pfnRestore + NULL, // pfnSetAbsBox + NULL, // pfnSaveWriteFields + NULL, // pfnSaveReadFields + NULL, // pfnSaveGlobalState + NULL, // pfnRestoreGlobalState + NULL, // pfnResetGlobalState + &ClientConnect_PreHook, // pfnClientDisconnect + NULL, // pfnClientDisconnect + NULL, // pfnClientKill + NULL, // pfnClientPutInServer + NULL, // pfnClientCommand + NULL, // pfnClientUserInfoChanged + NULL, // pfnServerActivate + NULL, // pfnServerDeactivate + NULL, // pfnPlayerPreThink + NULL, // pfnPlayerPostThink + NULL, // pfnStartFrame + NULL, // pfnParmsNewLevel + NULL, // pfnParmsChangeLevel + NULL, // pfnGetGameDescription + NULL, // pfnPlayerCustomization + NULL, // pfnSpectatorConnect + NULL, // pfnSpectatorDisconnect + NULL, // pfnSpectatorThink + NULL, // pfnSys_Error + NULL, // pfnPM_Move + NULL, // pfnPM_Init + NULL, // pfnPM_FindTextureType + NULL, // pfnSetupVisibility + NULL, // pfnUpdateClientData + NULL, // pfnAddToFullPack + NULL, // pfnCreateBaseline + NULL, // pfnRegisterEncoders + NULL, // pfnGetWeaponData + NULL, // pfnCmdStart + NULL, // pfnCmdEnd + NULL, // pfnConnectionlessPacket + NULL, // pfnGetHullBounds + NULL, // pfnCreateInstancedBaselines + NULL, // pfnInconsistentFile + NULL, // pfnAllowLagCompensation +}; + +DLL_FUNCTIONS g_DLLFuncTable_Post = +{ + NULL, // pfnGameInit + NULL, // pfnSpawn + NULL, // pfnThink + NULL, // pfnUse + NULL, // pfnTouch + NULL, // pfnBlocked + NULL, // pfnKeyValue + NULL, // pfnSave + NULL, // pfnRestore + NULL, // pfnSetAbsBox + NULL, // pfnSaveWriteFields + NULL, // pfnSaveReadFields + NULL, // pfnSaveGlobalState + NULL, // pfnRestoreGlobalState + NULL, // pfnResetGlobalState + NULL, // pfnClientConnect + NULL, // pfnClientDisconnect + NULL, // pfnClientKill + NULL, // pfnClientPutInServer + NULL, // pfnClientCommand + NULL, // pfnClientUserInfoChanged + &ServerActivate_PostHook, // pfnServerActivate + NULL, // pfnServerDeactivate + NULL, // pfnPlayerPreThink + NULL, // pfnPlayerPostThink + NULL, // pfnStartFrame + NULL, // pfnParmsNewLevel + NULL, // pfnParmsChangeLevel + NULL, // pfnGetGameDescription + NULL, // pfnPlayerCustomization + NULL, // pfnSpectatorConnect + NULL, // pfnSpectatorDisconnect + NULL, // pfnSpectatorThink + NULL, // pfnSys_Error + NULL, // pfnPM_Move + NULL, // pfnPM_Init + NULL, // pfnPM_FindTextureType + NULL, // pfnSetupVisibility + NULL, // pfnUpdateClientData + NULL, // pfnAddToFullPack + NULL, // pfnCreateBaseline + NULL, // pfnRegisterEncoders + NULL, // pfnGetWeaponData + NULL, // pfnCmdStart + NULL, // pfnCmdEnd + NULL, // pfnConnectionlessPacket + NULL, // pfnGetHullBounds + NULL, // pfnCreateInstancedBaselines + NULL, // pfnInconsistentFile + NULL, // pfnAllowLagCompensation +}; + +NEW_DLL_FUNCTIONS g_NewDLLFuncTable = +{ + NULL, //! pfnOnFreeEntPrivateData() Called right before the object's memory is freed. Calls its destructor. + NULL, //! pfnGameShutdown() + NULL, //! pfnShouldCollide() + NULL, //! pfnCvarValue() + &CvarValue2_PreHook, //! pfnCvarValue2() +}; + +C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion) +{ + if (!pFunctionTable) + { + UTIL_LogPrintf("GetEntityAPI2 called with null pFunctionTable"); + return FALSE; + } + + if (*interfaceVersion != INTERFACE_VERSION) + { + UTIL_LogPrintf("GetEntityAPI2 version mismatch; requested=%d ours=%d", *interfaceVersion, INTERFACE_VERSION); + //! Tell metamod what version we had, so it can figure out who is out of date. + *interfaceVersion = INTERFACE_VERSION; + return FALSE; + } + + memcpy(pFunctionTable, &g_DLLFuncTable, sizeof(DLL_FUNCTIONS)); + return TRUE; +} + +C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion) +{ + if (!pFunctionTable) + { + ALERT(at_logged, "%s called with null pFunctionTable", __FUNCTION__); + return FALSE; + } + + if (*interfaceVersion != INTERFACE_VERSION) + { + ALERT(at_logged, "%s version mismatch; requested=%d ours=%d", __FUNCTION__, *interfaceVersion, INTERFACE_VERSION); + *interfaceVersion = INTERFACE_VERSION; + return FALSE; + } + + memcpy(pFunctionTable, &g_DLLFuncTable_Post, sizeof(DLL_FUNCTIONS)); + return TRUE; +} + +C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion) +{ + if (!pNewFunctionTable) + { + UTIL_LogPrintf("GetNewDLLFunctions called with null pNewFunctionTable"); + return(FALSE); + } + + if (*interfaceVersion != NEW_DLL_FUNCTIONS_VERSION) + { + UTIL_LogPrintf("GetNewDLLFunctions version mismatch; requested=%d ours=%d", *interfaceVersion, NEW_DLL_FUNCTIONS_VERSION); + //! Tell metamod what version we had, so it can figure out who is out of date. + *interfaceVersion = NEW_DLL_FUNCTIONS_VERSION; + return FALSE; + } + + memcpy(pNewFunctionTable, &g_NewDLLFuncTable, sizeof(NEW_DLL_FUNCTIONS)); + return TRUE; +} diff --git a/revoice/src/engine_api.cpp b/revoice/src/engine_api.cpp index e10a6be..dfc9e0b 100644 --- a/revoice/src/engine_api.cpp +++ b/revoice/src/engine_api.cpp @@ -1,257 +1,257 @@ -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#include "precompiled.h" - -enginefuncs_t meta_engfuncs = { - NULL, // pfnPrecacheModel() - NULL, // pfnPrecacheSound() - NULL, // pfnSetModel() - NULL, // pfnModelIndex() - NULL, // pfnModelFrames() - - NULL, // pfnSetSize() - NULL, // pfnChangeLevel() - NULL, // pfnGetSpawnParms() - NULL, // pfnSaveSpawnParms() - - NULL, // pfnVecToYaw() - NULL, // pfnVecToAngles() - NULL, // pfnMoveToOrigin() - NULL, // pfnChangeYaw() - NULL, // pfnChangePitch() - - NULL, // pfnFindEntityByString() - NULL, // pfnGetEntityIllum() - NULL, // pfnFindEntityInSphere() - NULL, // pfnFindClientInPVS() - NULL, // pfnEntitiesInPVS() - - NULL, // pfnMakeVectors() - NULL, // pfnAngleVectors() - - NULL, // pfnCreateEntity() - NULL, // pfnRemoveEntity() - NULL, // pfnCreateNamedEntity() - - NULL, // pfnMakeStatic() - NULL, // pfnEntIsOnFloor() - NULL, // pfnDropToFloor() - - NULL, // pfnWalkMove() - NULL, // pfnSetOrigin() - - NULL, // pfnEmitSound() - NULL, // pfnEmitAmbientSound() - - NULL, // pfnTraceLine() - NULL, // pfnTraceToss() - NULL, // pfnTraceMonsterHull() - NULL, // pfnTraceHull() - NULL, // pfnTraceModel() - NULL, // pfnTraceTexture() - NULL, // pfnTraceSphere() - NULL, // pfnGetAimVector() - - NULL, // pfnServerCommand() - NULL, // pfnServerExecute() - NULL, // pfnClientCommand() - - NULL, // pfnParticleEffect() - NULL, // pfnLightStyle() - NULL, // pfnDecalIndex() - NULL, // pfnPointContents() - - NULL, // pfnMessageBegin() - NULL, // pfnMessageEnd() - - NULL, // pfnWriteByte() - NULL, // pfnWriteChar() - NULL, // pfnWriteShort() - NULL, // pfnWriteLong() - NULL, // pfnWriteAngle() - NULL, // pfnWriteCoord() - NULL, // pfnWriteString() - NULL, // pfnWriteEntity() - - NULL, // pfnCVarRegister() - NULL, // pfnCVarGetFloat() - NULL, // pfnCVarGetString() - NULL, // pfnCVarSetFloat() - NULL, // pfnCVarSetString() - - NULL, // pfnAlertMessage() - NULL, // pfnEngineFprintf() - - NULL, // pfnPvAllocEntPrivateData() - NULL, // pfnPvEntPrivateData() - NULL, // pfnFreeEntPrivateData() - - NULL, // pfnSzFromIndex() - NULL, // pfnAllocString() - - NULL, // pfnGetVarsOfEnt() - NULL, // pfnPEntityOfEntOffset() - NULL, // pfnEntOffsetOfPEntity() - NULL, // pfnIndexOfEdict() - NULL, // pfnPEntityOfEntIndex() - NULL, // pfnFindEntityByVars() - NULL, // pfnGetModelPtr() - - NULL, // pfnRegUserMsg() - - NULL, // pfnAnimationAutomove() - NULL, // pfnGetBonePosition() - - NULL, // pfnFunctionFromName() - NULL, // pfnNameForFunction() - - NULL, // pfnClientPrintf() - NULL, // pfnServerPrint() - - NULL, // pfnCmd_Args() - NULL, // pfnCmd_Argv() - NULL, // pfnCmd_Argc() - - NULL, // pfnGetAttachment() - - NULL, // pfnCRC32_Init() - NULL, // pfnCRC32_ProcessBuffer() - NULL, // pfnCRC32_ProcessByte() - NULL, // pfnCRC32_Final() - - NULL, // pfnRandomLong() - NULL, // pfnRandomFloat() - - NULL, // pfnSetView() - NULL, // pfnTime() - NULL, // pfnCrosshairAngle() - - NULL, // pfnLoadFileForMe() - NULL, // pfnFreeFile() - - NULL, // pfnEndSection() - NULL, // pfnCompareFileTime() - NULL, // pfnGetGameDir() - NULL, // pfnCvar_RegisterVariable() - NULL, // pfnFadeClientVolume() - NULL, // pfnSetClientMaxspeed() - NULL, // pfnCreateFakeClient() - NULL, // pfnRunPlayerMove() - NULL, // pfnNumberOfEntities() - - NULL, // pfnGetInfoKeyBuffer() - NULL, // pfnInfoKeyValue() - NULL, // pfnSetKeyValue() - NULL, // pfnSetClientKeyValue() - - NULL, // pfnIsMapValid() - NULL, // pfnStaticDecal() - NULL, // pfnPrecacheGeneric() - NULL, // pfnGetPlayerUserId() - NULL, // pfnBuildSoundMsg() - NULL, // pfnIsDedicatedServer() - NULL, // pfnCVarGetPointer() - NULL, // pfnGetPlayerWONId() - - NULL, // pfnInfo_RemoveKey() - NULL, // pfnGetPhysicsKeyValue() - NULL, // pfnSetPhysicsKeyValue() - NULL, // pfnGetPhysicsInfoString() - NULL, // pfnPrecacheEvent() - NULL, // pfnPlaybackEvent() - - NULL, // pfnSetFatPVS() - NULL, // pfnSetFatPAS() - - NULL, // pfnCheckVisibility() - - NULL, // pfnDeltaSetField() - NULL, // pfnDeltaUnsetField() - NULL, // pfnDeltaAddEncoder() - NULL, // pfnGetCurrentPlayer() - NULL, // pfnCanSkipPlayer() - NULL, // pfnDeltaFindField() - NULL, // pfnDeltaSetFieldByIndex() - NULL, // pfnDeltaUnsetFieldByIndex() - - NULL, // pfnSetGroupMask() - - NULL, // pfnCreateInstancedBaseline() - NULL, // pfnCvar_DirectSet() - - NULL, // pfnForceUnmodified() - - NULL, // pfnGetPlayerStats() - - NULL, // pfnAddServerCommand() - - // Added in SDK 2.2: - NULL, // pfnVoice_GetClientListening() - NULL, // pfnVoice_SetClientListening() - - // Added for HL 1109 (no SDK update): - NULL, // pfnGetPlayerAuthId() - - // Added 2003-11-10 (no SDK update): - NULL, // pfnSequenceGet() - NULL, // pfnSequencePickSentence() - NULL, // pfnGetFileSize() - NULL, // pfnGetApproxWavePlayLen() - NULL, // pfnIsCareerMatch() - NULL, // pfnGetLocalizedStringLength() - NULL, // pfnRegisterTutorMessageShown() - NULL, // pfnGetTimesTutorMessageShown() - NULL, // pfnProcessTutorMessageDecayBuffer() - NULL, // pfnConstructTutorMessageDecayBuffer() - NULL, // pfnResetTutorMessageDecayData() - - // Added Added 2005-08-11 (no SDK update) - NULL, // pfnQueryClientCvarValue() - // Added Added 2005-11-22 (no SDK update) - NULL, // pfnQueryClientCvarValue2() -}; - -C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion) -{ - if(!pengfuncsFromEngine) { - UTIL_LogPrintf("GetEngineFunctions called with null pengfuncsFromEngine"); - return(FALSE); - } - else if(*interfaceVersion != ENGINE_INTERFACE_VERSION) { - UTIL_LogPrintf("GetEngineFunctions version mismatch; requested=%d ours=%d", *interfaceVersion, ENGINE_INTERFACE_VERSION); - // Tell metamod what version we had, so it can figure out who is out of date. - *interfaceVersion = ENGINE_INTERFACE_VERSION; - return(FALSE); - } - memcpy(pengfuncsFromEngine, &meta_engfuncs, sizeof(enginefuncs_t)); - return(TRUE); -} +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#include "precompiled.h" + +enginefuncs_t meta_engfuncs = { + NULL, // pfnPrecacheModel() + NULL, // pfnPrecacheSound() + NULL, // pfnSetModel() + NULL, // pfnModelIndex() + NULL, // pfnModelFrames() + + NULL, // pfnSetSize() + NULL, // pfnChangeLevel() + NULL, // pfnGetSpawnParms() + NULL, // pfnSaveSpawnParms() + + NULL, // pfnVecToYaw() + NULL, // pfnVecToAngles() + NULL, // pfnMoveToOrigin() + NULL, // pfnChangeYaw() + NULL, // pfnChangePitch() + + NULL, // pfnFindEntityByString() + NULL, // pfnGetEntityIllum() + NULL, // pfnFindEntityInSphere() + NULL, // pfnFindClientInPVS() + NULL, // pfnEntitiesInPVS() + + NULL, // pfnMakeVectors() + NULL, // pfnAngleVectors() + + NULL, // pfnCreateEntity() + NULL, // pfnRemoveEntity() + NULL, // pfnCreateNamedEntity() + + NULL, // pfnMakeStatic() + NULL, // pfnEntIsOnFloor() + NULL, // pfnDropToFloor() + + NULL, // pfnWalkMove() + NULL, // pfnSetOrigin() + + NULL, // pfnEmitSound() + NULL, // pfnEmitAmbientSound() + + NULL, // pfnTraceLine() + NULL, // pfnTraceToss() + NULL, // pfnTraceMonsterHull() + NULL, // pfnTraceHull() + NULL, // pfnTraceModel() + NULL, // pfnTraceTexture() + NULL, // pfnTraceSphere() + NULL, // pfnGetAimVector() + + NULL, // pfnServerCommand() + NULL, // pfnServerExecute() + NULL, // pfnClientCommand() + + NULL, // pfnParticleEffect() + NULL, // pfnLightStyle() + NULL, // pfnDecalIndex() + NULL, // pfnPointContents() + + NULL, // pfnMessageBegin() + NULL, // pfnMessageEnd() + + NULL, // pfnWriteByte() + NULL, // pfnWriteChar() + NULL, // pfnWriteShort() + NULL, // pfnWriteLong() + NULL, // pfnWriteAngle() + NULL, // pfnWriteCoord() + NULL, // pfnWriteString() + NULL, // pfnWriteEntity() + + NULL, // pfnCVarRegister() + NULL, // pfnCVarGetFloat() + NULL, // pfnCVarGetString() + NULL, // pfnCVarSetFloat() + NULL, // pfnCVarSetString() + + NULL, // pfnAlertMessage() + NULL, // pfnEngineFprintf() + + NULL, // pfnPvAllocEntPrivateData() + NULL, // pfnPvEntPrivateData() + NULL, // pfnFreeEntPrivateData() + + NULL, // pfnSzFromIndex() + NULL, // pfnAllocString() + + NULL, // pfnGetVarsOfEnt() + NULL, // pfnPEntityOfEntOffset() + NULL, // pfnEntOffsetOfPEntity() + NULL, // pfnIndexOfEdict() + NULL, // pfnPEntityOfEntIndex() + NULL, // pfnFindEntityByVars() + NULL, // pfnGetModelPtr() + + NULL, // pfnRegUserMsg() + + NULL, // pfnAnimationAutomove() + NULL, // pfnGetBonePosition() + + NULL, // pfnFunctionFromName() + NULL, // pfnNameForFunction() + + NULL, // pfnClientPrintf() + NULL, // pfnServerPrint() + + NULL, // pfnCmd_Args() + NULL, // pfnCmd_Argv() + NULL, // pfnCmd_Argc() + + NULL, // pfnGetAttachment() + + NULL, // pfnCRC32_Init() + NULL, // pfnCRC32_ProcessBuffer() + NULL, // pfnCRC32_ProcessByte() + NULL, // pfnCRC32_Final() + + NULL, // pfnRandomLong() + NULL, // pfnRandomFloat() + + NULL, // pfnSetView() + NULL, // pfnTime() + NULL, // pfnCrosshairAngle() + + NULL, // pfnLoadFileForMe() + NULL, // pfnFreeFile() + + NULL, // pfnEndSection() + NULL, // pfnCompareFileTime() + NULL, // pfnGetGameDir() + NULL, // pfnCvar_RegisterVariable() + NULL, // pfnFadeClientVolume() + NULL, // pfnSetClientMaxspeed() + NULL, // pfnCreateFakeClient() + NULL, // pfnRunPlayerMove() + NULL, // pfnNumberOfEntities() + + NULL, // pfnGetInfoKeyBuffer() + NULL, // pfnInfoKeyValue() + NULL, // pfnSetKeyValue() + NULL, // pfnSetClientKeyValue() + + NULL, // pfnIsMapValid() + NULL, // pfnStaticDecal() + NULL, // pfnPrecacheGeneric() + NULL, // pfnGetPlayerUserId() + NULL, // pfnBuildSoundMsg() + NULL, // pfnIsDedicatedServer() + NULL, // pfnCVarGetPointer() + NULL, // pfnGetPlayerWONId() + + NULL, // pfnInfo_RemoveKey() + NULL, // pfnGetPhysicsKeyValue() + NULL, // pfnSetPhysicsKeyValue() + NULL, // pfnGetPhysicsInfoString() + NULL, // pfnPrecacheEvent() + NULL, // pfnPlaybackEvent() + + NULL, // pfnSetFatPVS() + NULL, // pfnSetFatPAS() + + NULL, // pfnCheckVisibility() + + NULL, // pfnDeltaSetField() + NULL, // pfnDeltaUnsetField() + NULL, // pfnDeltaAddEncoder() + NULL, // pfnGetCurrentPlayer() + NULL, // pfnCanSkipPlayer() + NULL, // pfnDeltaFindField() + NULL, // pfnDeltaSetFieldByIndex() + NULL, // pfnDeltaUnsetFieldByIndex() + + NULL, // pfnSetGroupMask() + + NULL, // pfnCreateInstancedBaseline() + NULL, // pfnCvar_DirectSet() + + NULL, // pfnForceUnmodified() + + NULL, // pfnGetPlayerStats() + + NULL, // pfnAddServerCommand() + + // Added in SDK 2.2: + NULL, // pfnVoice_GetClientListening() + NULL, // pfnVoice_SetClientListening() + + // Added for HL 1109 (no SDK update): + NULL, // pfnGetPlayerAuthId() + + // Added 2003-11-10 (no SDK update): + NULL, // pfnSequenceGet() + NULL, // pfnSequencePickSentence() + NULL, // pfnGetFileSize() + NULL, // pfnGetApproxWavePlayLen() + NULL, // pfnIsCareerMatch() + NULL, // pfnGetLocalizedStringLength() + NULL, // pfnRegisterTutorMessageShown() + NULL, // pfnGetTimesTutorMessageShown() + NULL, // pfnProcessTutorMessageDecayBuffer() + NULL, // pfnConstructTutorMessageDecayBuffer() + NULL, // pfnResetTutorMessageDecayData() + + // Added Added 2005-08-11 (no SDK update) + NULL, // pfnQueryClientCvarValue() + // Added Added 2005-11-22 (no SDK update) + NULL, // pfnQueryClientCvarValue2() +}; + +C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *interfaceVersion) +{ + if(!pengfuncsFromEngine) { + UTIL_LogPrintf("GetEngineFunctions called with null pengfuncsFromEngine"); + return(FALSE); + } + else if(*interfaceVersion != ENGINE_INTERFACE_VERSION) { + UTIL_LogPrintf("GetEngineFunctions version mismatch; requested=%d ours=%d", *interfaceVersion, ENGINE_INTERFACE_VERSION); + // Tell metamod what version we had, so it can figure out who is out of date. + *interfaceVersion = ENGINE_INTERFACE_VERSION; + return(FALSE); + } + memcpy(pengfuncsFromEngine, &meta_engfuncs, sizeof(enginefuncs_t)); + return(TRUE); +} diff --git a/revoice/src/h_export.cpp b/revoice/src/h_export.cpp index 7a89316..a738290 100644 --- a/revoice/src/h_export.cpp +++ b/revoice/src/h_export.cpp @@ -1,40 +1,40 @@ -// From SDK dlls/h_export.cpp: - -/*** -* -* Copyright (c) 1999, 2000 Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -/* - -===== h_export.cpp ======================================================== - - Entity classes exported by Halflife. - -*/ - -#include "precompiled.h" - -// From SDK dlls/h_export.cpp: - -//! Holds engine functionality callbacks -enginefuncs_t g_engfuncs; -globalvars_t *gpGlobals; - -// Receive engine function table from engine. -// This appears to be the _first_ DLL routine called by the engine, so we -// do some setup operations here. -C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals) -{ - memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t)); - gpGlobals = pGlobals; -} +// From SDK dlls/h_export.cpp: + +/*** +* +* Copyright (c) 1999, 2000 Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ +/* + +===== h_export.cpp ======================================================== + + Entity classes exported by Halflife. + +*/ + +#include "precompiled.h" + +// From SDK dlls/h_export.cpp: + +//! Holds engine functionality callbacks +enginefuncs_t g_engfuncs; +globalvars_t *gpGlobals; + +// Receive engine function table from engine. +// This appears to be the _first_ DLL routine called by the engine, so we +// do some setup operations here. +C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals) +{ + memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t)); + gpGlobals = pGlobals; +} diff --git a/revoice/src/meta_api.cpp b/revoice/src/meta_api.cpp index f4f5787..7472cb2 100644 --- a/revoice/src/meta_api.cpp +++ b/revoice/src/meta_api.cpp @@ -1,117 +1,117 @@ -// meta_api.cpp - minimal implementation of metamod's plugin interface - -// This is intended to illustrate the (more or less) bare minimum code -// required for a valid metamod plugin, and is targeted at those who want -// to port existing HL/SDK DLL code to run as a metamod plugin. - -/* - * Copyright (c) 2001-2003 Will Day - * - * This file is part of Metamod. - * - * Metamod 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 2 of the License, or (at - * your option) any later version. - * - * Metamod 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. - * - * You should have received a copy of the GNU General Public License - * along with Metamod; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * In addition, as a special exception, the author gives permission to - * link the code of this program with the Half-Life Game Engine ("HL - * Engine") and Modified Game Libraries ("MODs") developed by Valve, - * L.L.C ("Valve"). You must obey the GNU General Public License in all - * respects for all of the code used other than the HL Engine and MODs - * from Valve. If you modify this file, you may extend this exception - * to your version of the file, but you are not obligated to do so. If - * you do not wish to do so, delete this exception statement from your - * version. - * - */ - -#include "precompiled.h" - -// Must provide at least one of these.. -static META_FUNCTIONS gMetaFunctionTable = { - NULL, // pfnGetEntityAPI HL SDK; called before game DLL - NULL, // pfnGetEntityAPI_Post META; called after game DLL - &GetEntityAPI2, // pfnGetEntityAPI2 HL SDK2; called before game DLL - &GetEntityAPI2_Post, // pfnGetEntityAPI2_Post META; called after game DLL - &GetNewDLLFunctions, // pfnGetNewDLLFunctions HL SDK2; called before game DLL - NULL, // pfnGetNewDLLFunctions_Post META; called after game DLL - NULL, // pfnGetEngineFunctions META; called before HL engine - NULL, // pfnGetEngineFunctions_Post META; called after HL engine -}; - -// Description of plugin -plugin_info_t Plugin_info = { - META_INTERFACE_VERSION, // ifvers - "Revoice", // name - APP_VERSION, // version - APP_COMMIT_DATE, // date - "The Legion", // author - "", // url - "REVOICE", // logtag, all caps please - PT_STARTUP, // (when) loadable - PT_NEVER, // (when) unloadable -}; - -// Global vars from metamod: -meta_globals_t *gpMetaGlobals; // metamod globals -gamedll_funcs_t *gpGamedllFuncs; // gameDLL function tables -mutil_funcs_t *gpMetaUtilFuncs; // metamod utility functions - -// Metamod requesting info about this plugin: -// ifvers (given) interface_version metamod is using -// pPlugInfo (requested) struct with info about plugin -// pMetaUtilFuncs (given) table of utility functions provided by metamod -C_DLLEXPORT int Meta_Query(char * /*ifvers */, plugin_info_t **pPlugInfo, mutil_funcs_t *pMetaUtilFuncs) -{ - // Give metamod our plugin_info struct - *pPlugInfo = &Plugin_info; - - // Get metamod utility function table. - gpMetaUtilFuncs = pMetaUtilFuncs; - - return TRUE; -} - -// Metamod attaching plugin to the server. -// now (given) current phase, ie during map, during changelevel, or at startup -// pFunctionTable (requested) table of function tables this plugin catches -// pMGlobals (given) global vars from metamod -// pGamedllFuncs (given) copy of function tables from game dll -C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME /* now */, META_FUNCTIONS *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs) -{ - if(!pMGlobals) { - LOG_ERROR(PLID, "Meta_Attach called with null pMGlobals"); - return FALSE; - } - - gpMetaGlobals = pMGlobals; - - if(!pFunctionTable) { - LOG_ERROR(PLID, "Meta_Attach called with null pFunctionTable"); - return FALSE; - } - - memcpy(pFunctionTable, &gMetaFunctionTable, sizeof(META_FUNCTIONS)); - gpGamedllFuncs = pGamedllFuncs; - - return Revoice_Load() ? TRUE : FALSE; -} - -// Metamod detaching plugin from the server. -// now (given) current phase, ie during map, etc -// reason (given) why detaching (refresh, console unload, forced unload, etc) -C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME /* now */, PL_UNLOAD_REASON /* reason */) -{ - Revoice_Main_DeInit(); - return TRUE; -} +// meta_api.cpp - minimal implementation of metamod's plugin interface + +// This is intended to illustrate the (more or less) bare minimum code +// required for a valid metamod plugin, and is targeted at those who want +// to port existing HL/SDK DLL code to run as a metamod plugin. + +/* + * Copyright (c) 2001-2003 Will Day + * + * This file is part of Metamod. + * + * Metamod 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 2 of the License, or (at + * your option) any later version. + * + * Metamod 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. + * + * You should have received a copy of the GNU General Public License + * along with Metamod; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, the author gives permission to + * link the code of this program with the Half-Life Game Engine ("HL + * Engine") and Modified Game Libraries ("MODs") developed by Valve, + * L.L.C ("Valve"). You must obey the GNU General Public License in all + * respects for all of the code used other than the HL Engine and MODs + * from Valve. If you modify this file, you may extend this exception + * to your version of the file, but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. + * + */ + +#include "precompiled.h" + +// Must provide at least one of these.. +static META_FUNCTIONS gMetaFunctionTable = { + NULL, // pfnGetEntityAPI HL SDK; called before game DLL + NULL, // pfnGetEntityAPI_Post META; called after game DLL + &GetEntityAPI2, // pfnGetEntityAPI2 HL SDK2; called before game DLL + &GetEntityAPI2_Post, // pfnGetEntityAPI2_Post META; called after game DLL + &GetNewDLLFunctions, // pfnGetNewDLLFunctions HL SDK2; called before game DLL + NULL, // pfnGetNewDLLFunctions_Post META; called after game DLL + NULL, // pfnGetEngineFunctions META; called before HL engine + NULL, // pfnGetEngineFunctions_Post META; called after HL engine +}; + +// Description of plugin +plugin_info_t Plugin_info = { + META_INTERFACE_VERSION, // ifvers + "Revoice", // name + APP_VERSION, // version + APP_COMMIT_DATE, // date + "The Legion", // author + "", // url + "REVOICE", // logtag, all caps please + PT_STARTUP, // (when) loadable + PT_NEVER, // (when) unloadable +}; + +// Global vars from metamod: +meta_globals_t *gpMetaGlobals; // metamod globals +gamedll_funcs_t *gpGamedllFuncs; // gameDLL function tables +mutil_funcs_t *gpMetaUtilFuncs; // metamod utility functions + +// Metamod requesting info about this plugin: +// ifvers (given) interface_version metamod is using +// pPlugInfo (requested) struct with info about plugin +// pMetaUtilFuncs (given) table of utility functions provided by metamod +C_DLLEXPORT int Meta_Query(char * /*ifvers */, plugin_info_t **pPlugInfo, mutil_funcs_t *pMetaUtilFuncs) +{ + // Give metamod our plugin_info struct + *pPlugInfo = &Plugin_info; + + // Get metamod utility function table. + gpMetaUtilFuncs = pMetaUtilFuncs; + + return TRUE; +} + +// Metamod attaching plugin to the server. +// now (given) current phase, ie during map, during changelevel, or at startup +// pFunctionTable (requested) table of function tables this plugin catches +// pMGlobals (given) global vars from metamod +// pGamedllFuncs (given) copy of function tables from game dll +C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME /* now */, META_FUNCTIONS *pFunctionTable, meta_globals_t *pMGlobals, gamedll_funcs_t *pGamedllFuncs) +{ + if(!pMGlobals) { + LOG_ERROR(PLID, "Meta_Attach called with null pMGlobals"); + return FALSE; + } + + gpMetaGlobals = pMGlobals; + + if(!pFunctionTable) { + LOG_ERROR(PLID, "Meta_Attach called with null pFunctionTable"); + return FALSE; + } + + memcpy(pFunctionTable, &gMetaFunctionTable, sizeof(META_FUNCTIONS)); + gpGamedllFuncs = pGamedllFuncs; + + return Revoice_Load() ? TRUE : FALSE; +} + +// Metamod detaching plugin from the server. +// now (given) current phase, ie during map, etc +// reason (given) why detaching (refresh, console unload, forced unload, etc) +C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME /* now */, PL_UNLOAD_REASON /* reason */) +{ + Revoice_Main_DeInit(); + return TRUE; +} diff --git a/revoice/src/osconf.h b/revoice/src/osconf.h index f884edf..f08624b 100644 --- a/revoice/src/osconf.h +++ b/revoice/src/osconf.h @@ -1,21 +1,21 @@ -#pragma once - -#include "appversion.h" - -#ifdef WIN32 - #define WIN32_LEAN_AND_MEAN - #include - #include - #include - #include - #include -#else //WIN32 - #include - #include - #include - #include - #include - #include - #include - #define HIDDEN __attribute__((visibility("hidden"))) -#endif //WIN32 +#pragma once + +#include "appversion.h" + +#ifdef WIN32 + #define WIN32_LEAN_AND_MEAN + #include + #include + #include + #include + #include +#else //WIN32 + #include + #include + #include + #include + #include + #include + #include + #define HIDDEN __attribute__((visibility("hidden"))) +#endif //WIN32 diff --git a/revoice/src/precompiled.cpp b/revoice/src/precompiled.cpp index 7ff8df5..5f656a4 100644 --- a/revoice/src/precompiled.cpp +++ b/revoice/src/precompiled.cpp @@ -1 +1 @@ -#include "precompiled.h" +#include "precompiled.h" diff --git a/revoice/src/precompiled.h b/revoice/src/precompiled.h index aa055d2..cebbb24 100644 --- a/revoice/src/precompiled.h +++ b/revoice/src/precompiled.h @@ -1,32 +1,32 @@ -#pragma once - -#include "osconf.h" -#include "sys_shared.h" -#include "crc32c.h" - -#include - -#include -#include "rehlds_api.h" -#include // ALERT() -#include "osdep.h" // win32 vsnprintf, etc -#include -#include -#include -#include "sdk_util.h" // UTIL_LogPrintf, etc - -#include "revoice_shared.h" -#include "revoice_cfg.h" -#include "revoice_rehlds_api.h" -#include "VoiceEncoder_Silk.h" -#include "VoiceEncoder_Speex.h" -#include "VoiceEncoder_Opus.h" -#include "voice_codec_frame.h" -#include "SteamP2PCodec.h" -#include "revoice_player.h" -#include "revoice_main.h" - -#include "interface.h" -#include "utlbuffer.h" -#include "reunion_api.h" -#include "revoice_reunion_api.h" +#pragma once + +#include "osconf.h" +#include "sys_shared.h" +#include "crc32c.h" + +#include + +#include +#include "rehlds_api.h" +#include // ALERT() +#include "osdep.h" // win32 vsnprintf, etc +#include +#include +#include +#include "sdk_util.h" // UTIL_LogPrintf, etc + +#include "revoice_shared.h" +#include "revoice_cfg.h" +#include "revoice_rehlds_api.h" +#include "VoiceEncoder_Silk.h" +#include "VoiceEncoder_Speex.h" +#include "VoiceEncoder_Opus.h" +#include "voice_codec_frame.h" +#include "SteamP2PCodec.h" +#include "revoice_player.h" +#include "revoice_main.h" + +#include "interface.h" +#include "utlbuffer.h" +#include "reunion_api.h" +#include "revoice_reunion_api.h" diff --git a/revoice/src/public_amalgamation.cpp b/revoice/src/public_amalgamation.cpp index 95d312a..d3e05c7 100644 --- a/revoice/src/public_amalgamation.cpp +++ b/revoice/src/public_amalgamation.cpp @@ -1,5 +1,5 @@ -#include "precompiled.h" - -#include "sys_shared.cpp" -#include "interface.cpp" -#include "crc32c.cpp" +#include "precompiled.h" + +#include "sys_shared.cpp" +#include "interface.cpp" +#include "crc32c.cpp" diff --git a/revoice/src/revoice_cfg.cpp b/revoice/src/revoice_cfg.cpp index 12d8286..3e941b6 100644 --- a/revoice/src/revoice_cfg.cpp +++ b/revoice/src/revoice_cfg.cpp @@ -1,107 +1,107 @@ -#include "precompiled.h" - -char g_ExecConfigCmd[MAX_PATH]; -const char REVOICE_CFG_FILE[] = "revoice.cfg"; - -void Revoice_Exec_Config() -{ - if (!g_ExecConfigCmd[0]) { - return; - } - - g_engfuncs.pfnServerCommand(g_ExecConfigCmd); - g_engfuncs.pfnServerExecute(); -} - -bool Revoice_Init_Config() -{ - const char *pszGameDir = GET_GAME_INFO(PLID, GINFO_GAMEDIR); - const char *pszPluginDir = GET_PLUGIN_PATH(PLID); - - char szRelativePath[MAX_PATH]; - strncpy(szRelativePath, &pszPluginDir[strlen(pszGameDir) + 1], sizeof(szRelativePath) - 1); - szRelativePath[sizeof(szRelativePath) - 1] = '\0'; - NormalizePath(szRelativePath); - - char *pos = strrchr(szRelativePath, '/'); - if (pos) { - *(pos + 1) = '\0'; - } - - snprintf(g_ExecConfigCmd, sizeof(g_ExecConfigCmd), "exec \"%s%s\"\n", szRelativePath, REVOICE_CFG_FILE); - return true; -} - -cvar_t g_cv_rev_hltv_codec = { "REV_HltvCodec", "opus", 0, 0.0f, nullptr }; -cvar_t g_cv_rev_default_codec = { "REV_DefaultCodec", "speex", 0, 0.0f, nullptr }; -cvar_t g_cv_rev_version = { "revoice_version", APP_VERSION, FCVAR_SERVER, 0.0f, nullptr }; - -cvar_t *g_pcv_rev_hltv_codec = nullptr; -cvar_t *g_pcv_rev_default_codec = nullptr; -cvar_t *g_pcv_sv_voiceenable = nullptr; - -void Revoice_Init_Cvars() -{ - g_engfuncs.pfnAddServerCommand("rev", Revoice_Cmds_Handler); - - g_engfuncs.pfnCvar_RegisterVariable(&g_cv_rev_version); - g_engfuncs.pfnCvar_RegisterVariable(&g_cv_rev_hltv_codec); - g_engfuncs.pfnCvar_RegisterVariable(&g_cv_rev_default_codec); - - g_pcv_sv_voiceenable = g_engfuncs.pfnCVarGetPointer("sv_voiceenable"); - g_pcv_rev_hltv_codec = g_engfuncs.pfnCVarGetPointer(g_cv_rev_hltv_codec.name); - g_pcv_rev_default_codec = g_engfuncs.pfnCVarGetPointer(g_cv_rev_default_codec.name); - - g_RehldsFuncs->AddCvarListener(g_cv_rev_hltv_codec.name, Revoice_Update_Hltv); - g_RehldsFuncs->AddCvarListener(g_cv_rev_default_codec.name, Revoice_Update_Players); -} - -void Revoice_DeInit_Cvars() -{ - g_RehldsFuncs->RemoveCvarListener(g_cv_rev_hltv_codec.name, Revoice_Update_Hltv); - g_RehldsFuncs->RemoveCvarListener(g_cv_rev_default_codec.name, Revoice_Update_Players); -} - -REVCmds g_revoice_cmds[] = { - { "version", Cmd_REV_Version }, - { "status", Cmd_REV_Status } -}; - -void Revoice_Cmds_Handler() -{ - const char *pcmd = CMD_ARGV(1); - for (auto& cmds : g_revoice_cmds) - { - if (_stricmp(cmds.name, pcmd) == 0 && cmds.func) { - cmds.func(); - } - } -} - -void Cmd_REV_Version() -{ - // print version - g_engfuncs.pfnServerPrint("Revoice version: " APP_VERSION "\n"); - g_engfuncs.pfnServerPrint("Build date: " APP_COMMIT_TIME " " APP_COMMIT_DATE "\n"); - g_engfuncs.pfnServerPrint("Build from: " APP_COMMIT_URL APP_COMMIT_SHA "\n"); -} - -void Cmd_REV_Status() -{ - int nUsers = 0; - UTIL_ServerPrintf("\n%-5s %-32s %-6s %-4s %5s", "#", "name", "codec", "rate", "proto"); - - for (int i = 0; i < g_RehldsSvs->GetMaxClients(); i++) { - auto plr = &g_Players[i]; - if (plr->IsConnected()) { - printf("#%-4i %-32s %-6s %-4i %-2i %-3s", i + 1, UTIL_VarArgs("\"%s\"", plr->GetClient()->GetName()), plr->GetCodecTypeToString(), plr->GetVoiceRate(), plr->GetProtocol(), plr->IsHLTV() ? " (HLTV)" : ""); - nUsers++; - } - } - - if (!nUsers) { - UTIL_ServerPrintf("0 users"); - } - - UTIL_ServerPrintf("\n"); -} +#include "precompiled.h" + +char g_ExecConfigCmd[MAX_PATH]; +const char REVOICE_CFG_FILE[] = "revoice.cfg"; + +void Revoice_Exec_Config() +{ + if (!g_ExecConfigCmd[0]) { + return; + } + + g_engfuncs.pfnServerCommand(g_ExecConfigCmd); + g_engfuncs.pfnServerExecute(); +} + +bool Revoice_Init_Config() +{ + const char *pszGameDir = GET_GAME_INFO(PLID, GINFO_GAMEDIR); + const char *pszPluginDir = GET_PLUGIN_PATH(PLID); + + char szRelativePath[MAX_PATH]; + strncpy(szRelativePath, &pszPluginDir[strlen(pszGameDir) + 1], sizeof(szRelativePath) - 1); + szRelativePath[sizeof(szRelativePath) - 1] = '\0'; + NormalizePath(szRelativePath); + + char *pos = strrchr(szRelativePath, '/'); + if (pos) { + *(pos + 1) = '\0'; + } + + snprintf(g_ExecConfigCmd, sizeof(g_ExecConfigCmd), "exec \"%s%s\"\n", szRelativePath, REVOICE_CFG_FILE); + return true; +} + +cvar_t g_cv_rev_hltv_codec = { "REV_HltvCodec", "opus", 0, 0.0f, nullptr }; +cvar_t g_cv_rev_default_codec = { "REV_DefaultCodec", "speex", 0, 0.0f, nullptr }; +cvar_t g_cv_rev_version = { "revoice_version", APP_VERSION, FCVAR_SERVER, 0.0f, nullptr }; + +cvar_t *g_pcv_rev_hltv_codec = nullptr; +cvar_t *g_pcv_rev_default_codec = nullptr; +cvar_t *g_pcv_sv_voiceenable = nullptr; + +void Revoice_Init_Cvars() +{ + g_engfuncs.pfnAddServerCommand("rev", Revoice_Cmds_Handler); + + g_engfuncs.pfnCvar_RegisterVariable(&g_cv_rev_version); + g_engfuncs.pfnCvar_RegisterVariable(&g_cv_rev_hltv_codec); + g_engfuncs.pfnCvar_RegisterVariable(&g_cv_rev_default_codec); + + g_pcv_sv_voiceenable = g_engfuncs.pfnCVarGetPointer("sv_voiceenable"); + g_pcv_rev_hltv_codec = g_engfuncs.pfnCVarGetPointer(g_cv_rev_hltv_codec.name); + g_pcv_rev_default_codec = g_engfuncs.pfnCVarGetPointer(g_cv_rev_default_codec.name); + + g_RehldsFuncs->AddCvarListener(g_cv_rev_hltv_codec.name, Revoice_Update_Hltv); + g_RehldsFuncs->AddCvarListener(g_cv_rev_default_codec.name, Revoice_Update_Players); +} + +void Revoice_DeInit_Cvars() +{ + g_RehldsFuncs->RemoveCvarListener(g_cv_rev_hltv_codec.name, Revoice_Update_Hltv); + g_RehldsFuncs->RemoveCvarListener(g_cv_rev_default_codec.name, Revoice_Update_Players); +} + +REVCmds g_revoice_cmds[] = { + { "version", Cmd_REV_Version }, + { "status", Cmd_REV_Status } +}; + +void Revoice_Cmds_Handler() +{ + const char *pcmd = CMD_ARGV(1); + for (auto& cmds : g_revoice_cmds) + { + if (_stricmp(cmds.name, pcmd) == 0 && cmds.func) { + cmds.func(); + } + } +} + +void Cmd_REV_Version() +{ + // print version + g_engfuncs.pfnServerPrint("Revoice version: " APP_VERSION "\n"); + g_engfuncs.pfnServerPrint("Build date: " APP_COMMIT_TIME " " APP_COMMIT_DATE "\n"); + g_engfuncs.pfnServerPrint("Build from: " APP_COMMIT_URL APP_COMMIT_SHA "\n"); +} + +void Cmd_REV_Status() +{ + int nUsers = 0; + UTIL_ServerPrintf("\n%-5s %-32s %-6s %-4s %5s", "#", "name", "codec", "rate", "proto"); + + for (int i = 0; i < g_RehldsSvs->GetMaxClients(); i++) { + auto plr = &g_Players[i]; + if (plr->IsConnected()) { + printf("#%-4i %-32s %-6s %-4i %-2i %-3s", i + 1, UTIL_VarArgs("\"%s\"", plr->GetClient()->GetName()), plr->GetCodecTypeToString(), plr->GetVoiceRate(), plr->GetProtocol(), plr->IsHLTV() ? " (HLTV)" : ""); + nUsers++; + } + } + + if (!nUsers) { + UTIL_ServerPrintf("0 users"); + } + + UTIL_ServerPrintf("\n"); +} diff --git a/revoice/src/revoice_cfg.h b/revoice/src/revoice_cfg.h index 8f415aa..d780661 100644 --- a/revoice/src/revoice_cfg.h +++ b/revoice/src/revoice_cfg.h @@ -1,22 +1,22 @@ -#pragma once - -#include "revoice_shared.h" - -struct REVCmds { - const char *name; - void (*func)(); -}; - -void Revoice_Exec_Config(); -bool Revoice_Init_Config(); -void Revoice_Init_Cvars(); -void Revoice_DeInit_Cvars(); - -void Revoice_Cmds_Handler(); - -void Cmd_REV_Status(); -void Cmd_REV_Version(); - -extern cvar_t *g_pcv_sv_voiceenable; -extern cvar_t *g_pcv_rev_hltv_codec; -extern cvar_t *g_pcv_rev_default_codec; +#pragma once + +#include "revoice_shared.h" + +struct REVCmds { + const char *name; + void (*func)(); +}; + +void Revoice_Exec_Config(); +bool Revoice_Init_Config(); +void Revoice_Init_Cvars(); +void Revoice_DeInit_Cvars(); + +void Revoice_Cmds_Handler(); + +void Cmd_REV_Status(); +void Cmd_REV_Version(); + +extern cvar_t *g_pcv_sv_voiceenable; +extern cvar_t *g_pcv_rev_hltv_codec; +extern cvar_t *g_pcv_rev_default_codec; diff --git a/revoice/src/revoice_main.cpp b/revoice/src/revoice_main.cpp index 672f2a4..30919bb 100644 --- a/revoice/src/revoice_main.cpp +++ b/revoice/src/revoice_main.cpp @@ -1,265 +1,265 @@ -#include "precompiled.h" - -void SV_DropClient_hook(IRehldsHook_SV_DropClient *chain, IGameClient *cl, bool crash, const char *msg) -{ - CRevoicePlayer *plr = GetPlayerByClientPtr(cl); - - plr->OnDisconnected(); - - chain->callNext(cl, crash, msg); -} - -void CvarValue2_PreHook(const edict_t *pEnt, int requestID, const char *cvarName, const char *cvarValue) -{ - CRevoicePlayer *plr = GetPlayerByEdict(pEnt); - if (plr->GetRequestId() != requestID) { - RETURN_META(MRES_IGNORED); - } - - const char *lastSeparator = strrchr(cvarValue, ','); - if (lastSeparator) - { - int buildNumber = atoi(lastSeparator + 1); - if (buildNumber > 4554) { - plr->SetCodecType(vct_opus); - } - } - - RETURN_META(MRES_IGNORED); -} - -int TranscodeVoice(CRevoicePlayer *srcPlayer, const char *srcBuf, int srcBufLen, IVoiceCodec *srcCodec, IVoiceCodec *dstCodec, char *dstBuf, int dstBufSize) -{ - char decodedBuf[32768]; - - int numDecodedSamples = srcCodec->Decompress(srcBuf, srcBufLen, decodedBuf, sizeof(decodedBuf)); - if (numDecodedSamples <= 0) { - return 0; - } - - int compressedSize = dstCodec->Compress(decodedBuf, numDecodedSamples, dstBuf, dstBufSize, false); - if (compressedSize <= 0) { - return 0; - } - - /* - int numDecodedSamples2 = dstCodec->Decompress(dstBuf, compressedSize, decodedBuf, sizeof(decodedBuf)); - if (numDecodedSamples2 <= 0) { - return compressedSize; - } - - FILE *rawSndFile = fopen("d:\\revoice_raw.snd", "ab"); - if (rawSndFile) { - fwrite(decodedBuf, 2, numDecodedSamples2, rawSndFile); - fclose(rawSndFile); - } - */ - - return compressedSize; -} - -void SV_ParseVoiceData_emu(IGameClient *cl) -{ - char chReceived[4096]; - unsigned int nDataLength = g_RehldsFuncs->MSG_ReadShort(); - - if (nDataLength > sizeof(chReceived)) { - g_RehldsFuncs->DropClient(cl, FALSE, "Invalid voice data\n"); - return; - } - - g_RehldsFuncs->MSG_ReadBuf(nDataLength, chReceived); - - if (g_pcv_sv_voiceenable->value == 0.0f) { - return; - } - - CRevoicePlayer *srcPlayer = GetPlayerByClientPtr(cl); - srcPlayer->SetLastVoiceTime(g_RehldsSv->GetTime()); - srcPlayer->IncreaseVoiceRate(nDataLength); - - char transcodedBuf[4096]; - - char *silkData = nullptr; - char *speexData = nullptr; - - int silkDataLen = 0; - int speexDataLen = 0; - - switch (srcPlayer->GetCodecType()) - { - case vct_silk: - { - if (nDataLength > MAX_SILK_DATA_LEN || srcPlayer->GetVoiceRate() > MAX_SILK_VOICE_RATE) - return; - - silkData = chReceived; silkDataLen = nDataLength; - speexData = transcodedBuf; - speexDataLen = TranscodeVoice(srcPlayer, silkData, silkDataLen, srcPlayer->GetSilkCodec(), srcPlayer->GetSpeexCodec(), transcodedBuf, sizeof(transcodedBuf)); - break; - } - case vct_opus: - { - if (nDataLength > MAX_OPUS_DATA_LEN || srcPlayer->GetVoiceRate() > MAX_OPUS_VOICE_RATE) - return; - - silkData = chReceived; silkDataLen = nDataLength; - speexData = transcodedBuf; - - int numDecodedSamples = TranscodeVoice(srcPlayer, silkData, silkDataLen, srcPlayer->GetOpusCodec(), srcPlayer->GetSpeexCodec(), transcodedBuf, sizeof(transcodedBuf)); - if (numDecodedSamples <= 0) - return; - - speexDataLen = numDecodedSamples; - break; - } - case vct_speex: - { - if (nDataLength > MAX_SPEEX_DATA_LEN || srcPlayer->GetVoiceRate() > MAX_SPEEX_VOICE_RATE) - return; - - speexData = chReceived; speexDataLen = nDataLength; - silkData = transcodedBuf; - silkDataLen = TranscodeVoice(srcPlayer, speexData, speexDataLen, srcPlayer->GetSpeexCodec(), srcPlayer->GetSilkCodec(), transcodedBuf, sizeof(transcodedBuf)); - break; - } - default: - return; - } - - int maxclients = g_RehldsSvs->GetMaxClients(); - for (int i = 0; i < maxclients; i++) - { - CRevoicePlayer *dstPlayer = &g_Players[i]; - IGameClient *dstClient = dstPlayer->GetClient(); - - if (!((1 << i) & cl->GetVoiceStream(0)) && dstPlayer != srcPlayer) - continue; - - if (!dstClient->IsActive() && !dstClient->IsConnected() && dstPlayer != srcPlayer) - continue; - - char *sendBuf; - int nSendLen; - switch (dstPlayer->GetCodecType()) - { - case vct_silk: - case vct_opus: - sendBuf = silkData; - nSendLen = silkDataLen; - break; - case vct_speex: - sendBuf = speexData; - nSendLen = speexDataLen; - break; - default: - sendBuf = nullptr; - nSendLen = 0; - break; - } - - if (sendBuf == nullptr || nSendLen == 0) - continue; - - if (dstPlayer == srcPlayer && !dstClient->GetLoopback()) - nSendLen = 0; - - sizebuf_t *dstDatagram = dstClient->GetDatagram(); - if (dstDatagram->cursize + nSendLen + 6 < dstDatagram->maxsize) { - g_RehldsFuncs->MSG_WriteByte(dstDatagram, svc_voicedata); - g_RehldsFuncs->MSG_WriteByte(dstDatagram, cl->GetId()); - g_RehldsFuncs->MSG_WriteShort(dstDatagram, nSendLen); - g_RehldsFuncs->MSG_WriteBuf(dstDatagram, nSendLen, sendBuf); - } - } -} - -void Rehlds_HandleNetCommand(IRehldsHook_HandleNetCommand *chain, IGameClient *cl, int8 opcode) -{ - const int clc_voicedata = 8; - if (opcode == clc_voicedata) { - SV_ParseVoiceData_emu(cl); - return; - } - - chain->callNext(cl, opcode); -} - -qboolean ClientConnect_PreHook(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]) -{ - CRevoicePlayer *plr = GetPlayerByEdict(pEntity); - plr->OnConnected(); - - RETURN_META_VALUE(MRES_IGNORED, TRUE); -} - -void ServerActivate_PostHook(edict_t *pEdictList, int edictCount, int clientMax) -{ - Revoice_Exec_Config(); - SET_META_RESULT(MRES_IGNORED); -} - -void SV_WriteVoiceCodec_hooked(IRehldsHook_SV_WriteVoiceCodec *chain, sizebuf_t *sb) -{ - IGameClient *cl = g_RehldsFuncs->GetHostClient(); - CRevoicePlayer *plr = GetPlayerByClientPtr(cl); - - switch (plr->GetCodecType()) - { - case vct_silk: - case vct_opus: - case vct_speex: - { - g_RehldsFuncs->MSG_WriteByte(sb, svc_voiceinit); - g_RehldsFuncs->MSG_WriteString(sb, "voice_speex"); // codec id - g_RehldsFuncs->MSG_WriteByte(sb, 5); // quality - break; - } - default: - LCPrintf(true, "SV_WriteVoiceCodec() called on client(%d) with unknown voice codec\n", cl->GetId()); - break; - } -} - -bool Revoice_Load() -{ - if (!Revoice_Utils_Init()) - return false; - - if (!Revoice_RehldsApi_Init()) { - LCPrintf(true, "Failed to locate REHLDS API\n"); - return false; - } - - if (!Revoice_ReunionApi_Init()) - return false; - - Revoice_Init_Cvars(); - Revoice_Init_Config(); - Revoice_Init_Players(); - - if (!Revoice_Main_Init()) { - LCPrintf(true, "Initialization failed\n"); - return false; - } - - return true; -} - -bool Revoice_Main_Init() -{ - g_RehldsHookchains->SV_DropClient()->registerHook(&SV_DropClient_hook, HC_PRIORITY_DEFAULT + 1); - g_RehldsHookchains->HandleNetCommand()->registerHook(&Rehlds_HandleNetCommand, HC_PRIORITY_DEFAULT + 1); - g_RehldsHookchains->SV_WriteVoiceCodec()->registerHook(&SV_WriteVoiceCodec_hooked, HC_PRIORITY_DEFAULT + 1); - - return true; -} - -void Revoice_Main_DeInit() -{ - g_RehldsHookchains->SV_DropClient()->unregisterHook(&SV_DropClient_hook); - g_RehldsHookchains->HandleNetCommand()->unregisterHook(&Rehlds_HandleNetCommand); - g_RehldsHookchains->SV_WriteVoiceCodec()->unregisterHook(&SV_WriteVoiceCodec_hooked); - - Revoice_DeInit_Cvars(); -} +#include "precompiled.h" + +void SV_DropClient_hook(IRehldsHook_SV_DropClient *chain, IGameClient *cl, bool crash, const char *msg) +{ + CRevoicePlayer *plr = GetPlayerByClientPtr(cl); + + plr->OnDisconnected(); + + chain->callNext(cl, crash, msg); +} + +void CvarValue2_PreHook(const edict_t *pEnt, int requestID, const char *cvarName, const char *cvarValue) +{ + CRevoicePlayer *plr = GetPlayerByEdict(pEnt); + if (plr->GetRequestId() != requestID) { + RETURN_META(MRES_IGNORED); + } + + const char *lastSeparator = strrchr(cvarValue, ','); + if (lastSeparator) + { + int buildNumber = atoi(lastSeparator + 1); + if (buildNumber > 4554) { + plr->SetCodecType(vct_opus); + } + } + + RETURN_META(MRES_IGNORED); +} + +int TranscodeVoice(CRevoicePlayer *srcPlayer, const char *srcBuf, int srcBufLen, IVoiceCodec *srcCodec, IVoiceCodec *dstCodec, char *dstBuf, int dstBufSize) +{ + char decodedBuf[32768]; + + int numDecodedSamples = srcCodec->Decompress(srcBuf, srcBufLen, decodedBuf, sizeof(decodedBuf)); + if (numDecodedSamples <= 0) { + return 0; + } + + int compressedSize = dstCodec->Compress(decodedBuf, numDecodedSamples, dstBuf, dstBufSize, false); + if (compressedSize <= 0) { + return 0; + } + + /* + int numDecodedSamples2 = dstCodec->Decompress(dstBuf, compressedSize, decodedBuf, sizeof(decodedBuf)); + if (numDecodedSamples2 <= 0) { + return compressedSize; + } + + FILE *rawSndFile = fopen("d:\\revoice_raw.snd", "ab"); + if (rawSndFile) { + fwrite(decodedBuf, 2, numDecodedSamples2, rawSndFile); + fclose(rawSndFile); + } + */ + + return compressedSize; +} + +void SV_ParseVoiceData_emu(IGameClient *cl) +{ + char chReceived[4096]; + unsigned int nDataLength = g_RehldsFuncs->MSG_ReadShort(); + + if (nDataLength > sizeof(chReceived)) { + g_RehldsFuncs->DropClient(cl, FALSE, "Invalid voice data\n"); + return; + } + + g_RehldsFuncs->MSG_ReadBuf(nDataLength, chReceived); + + if (g_pcv_sv_voiceenable->value == 0.0f) { + return; + } + + CRevoicePlayer *srcPlayer = GetPlayerByClientPtr(cl); + srcPlayer->SetLastVoiceTime(g_RehldsSv->GetTime()); + srcPlayer->IncreaseVoiceRate(nDataLength); + + char transcodedBuf[4096]; + + char *silkData = nullptr; + char *speexData = nullptr; + + int silkDataLen = 0; + int speexDataLen = 0; + + switch (srcPlayer->GetCodecType()) + { + case vct_silk: + { + if (nDataLength > MAX_SILK_DATA_LEN || srcPlayer->GetVoiceRate() > MAX_SILK_VOICE_RATE) + return; + + silkData = chReceived; silkDataLen = nDataLength; + speexData = transcodedBuf; + speexDataLen = TranscodeVoice(srcPlayer, silkData, silkDataLen, srcPlayer->GetSilkCodec(), srcPlayer->GetSpeexCodec(), transcodedBuf, sizeof(transcodedBuf)); + break; + } + case vct_opus: + { + if (nDataLength > MAX_OPUS_DATA_LEN || srcPlayer->GetVoiceRate() > MAX_OPUS_VOICE_RATE) + return; + + silkData = chReceived; silkDataLen = nDataLength; + speexData = transcodedBuf; + + int numDecodedSamples = TranscodeVoice(srcPlayer, silkData, silkDataLen, srcPlayer->GetOpusCodec(), srcPlayer->GetSpeexCodec(), transcodedBuf, sizeof(transcodedBuf)); + if (numDecodedSamples <= 0) + return; + + speexDataLen = numDecodedSamples; + break; + } + case vct_speex: + { + if (nDataLength > MAX_SPEEX_DATA_LEN || srcPlayer->GetVoiceRate() > MAX_SPEEX_VOICE_RATE) + return; + + speexData = chReceived; speexDataLen = nDataLength; + silkData = transcodedBuf; + silkDataLen = TranscodeVoice(srcPlayer, speexData, speexDataLen, srcPlayer->GetSpeexCodec(), srcPlayer->GetSilkCodec(), transcodedBuf, sizeof(transcodedBuf)); + break; + } + default: + return; + } + + int maxclients = g_RehldsSvs->GetMaxClients(); + for (int i = 0; i < maxclients; i++) + { + CRevoicePlayer *dstPlayer = &g_Players[i]; + IGameClient *dstClient = dstPlayer->GetClient(); + + if (!((1 << i) & cl->GetVoiceStream(0)) && dstPlayer != srcPlayer) + continue; + + if (!dstClient->IsActive() && !dstClient->IsConnected() && dstPlayer != srcPlayer) + continue; + + char *sendBuf; + int nSendLen; + switch (dstPlayer->GetCodecType()) + { + case vct_silk: + case vct_opus: + sendBuf = silkData; + nSendLen = silkDataLen; + break; + case vct_speex: + sendBuf = speexData; + nSendLen = speexDataLen; + break; + default: + sendBuf = nullptr; + nSendLen = 0; + break; + } + + if (sendBuf == nullptr || nSendLen == 0) + continue; + + if (dstPlayer == srcPlayer && !dstClient->GetLoopback()) + nSendLen = 0; + + sizebuf_t *dstDatagram = dstClient->GetDatagram(); + if (dstDatagram->cursize + nSendLen + 6 < dstDatagram->maxsize) { + g_RehldsFuncs->MSG_WriteByte(dstDatagram, svc_voicedata); + g_RehldsFuncs->MSG_WriteByte(dstDatagram, cl->GetId()); + g_RehldsFuncs->MSG_WriteShort(dstDatagram, nSendLen); + g_RehldsFuncs->MSG_WriteBuf(dstDatagram, nSendLen, sendBuf); + } + } +} + +void Rehlds_HandleNetCommand(IRehldsHook_HandleNetCommand *chain, IGameClient *cl, int8 opcode) +{ + const int clc_voicedata = 8; + if (opcode == clc_voicedata) { + SV_ParseVoiceData_emu(cl); + return; + } + + chain->callNext(cl, opcode); +} + +qboolean ClientConnect_PreHook(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]) +{ + CRevoicePlayer *plr = GetPlayerByEdict(pEntity); + plr->OnConnected(); + + RETURN_META_VALUE(MRES_IGNORED, TRUE); +} + +void ServerActivate_PostHook(edict_t *pEdictList, int edictCount, int clientMax) +{ + Revoice_Exec_Config(); + SET_META_RESULT(MRES_IGNORED); +} + +void SV_WriteVoiceCodec_hooked(IRehldsHook_SV_WriteVoiceCodec *chain, sizebuf_t *sb) +{ + IGameClient *cl = g_RehldsFuncs->GetHostClient(); + CRevoicePlayer *plr = GetPlayerByClientPtr(cl); + + switch (plr->GetCodecType()) + { + case vct_silk: + case vct_opus: + case vct_speex: + { + g_RehldsFuncs->MSG_WriteByte(sb, svc_voiceinit); + g_RehldsFuncs->MSG_WriteString(sb, "voice_speex"); // codec id + g_RehldsFuncs->MSG_WriteByte(sb, 5); // quality + break; + } + default: + LCPrintf(true, "SV_WriteVoiceCodec() called on client(%d) with unknown voice codec\n", cl->GetId()); + break; + } +} + +bool Revoice_Load() +{ + if (!Revoice_Utils_Init()) + return false; + + if (!Revoice_RehldsApi_Init()) { + LCPrintf(true, "Failed to locate REHLDS API\n"); + return false; + } + + if (!Revoice_ReunionApi_Init()) + return false; + + Revoice_Init_Cvars(); + Revoice_Init_Config(); + Revoice_Init_Players(); + + if (!Revoice_Main_Init()) { + LCPrintf(true, "Initialization failed\n"); + return false; + } + + return true; +} + +bool Revoice_Main_Init() +{ + g_RehldsHookchains->SV_DropClient()->registerHook(&SV_DropClient_hook, HC_PRIORITY_DEFAULT + 1); + g_RehldsHookchains->HandleNetCommand()->registerHook(&Rehlds_HandleNetCommand, HC_PRIORITY_DEFAULT + 1); + g_RehldsHookchains->SV_WriteVoiceCodec()->registerHook(&SV_WriteVoiceCodec_hooked, HC_PRIORITY_DEFAULT + 1); + + return true; +} + +void Revoice_Main_DeInit() +{ + g_RehldsHookchains->SV_DropClient()->unregisterHook(&SV_DropClient_hook); + g_RehldsHookchains->HandleNetCommand()->unregisterHook(&Rehlds_HandleNetCommand); + g_RehldsHookchains->SV_WriteVoiceCodec()->unregisterHook(&SV_WriteVoiceCodec_hooked); + + Revoice_DeInit_Cvars(); +} diff --git a/revoice/src/revoice_main.h b/revoice/src/revoice_main.h index b920130..d407732 100644 --- a/revoice/src/revoice_main.h +++ b/revoice/src/revoice_main.h @@ -1,13 +1,13 @@ -#pragma once - -#include "revoice_shared.h" -#include "revoice_player.h" - -bool Revoice_Load(); -void Revoice_Main_DeInit(); -bool Revoice_Main_Init(); - -void CvarValue2_PreHook(const edict_t *pEnt, int requestID, const char *cvarName, const char *cvarValue); -qboolean ClientConnect_PreHook(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]); -void ServerActivate_PostHook(edict_t *pEdictList, int edictCount, int clientMax); - +#pragma once + +#include "revoice_shared.h" +#include "revoice_player.h" + +bool Revoice_Load(); +void Revoice_Main_DeInit(); +bool Revoice_Main_Init(); + +void CvarValue2_PreHook(const edict_t *pEnt, int requestID, const char *cvarName, const char *cvarValue); +qboolean ClientConnect_PreHook(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]); +void ServerActivate_PostHook(edict_t *pEdictList, int edictCount, int clientMax); + diff --git a/revoice/src/revoice_player.cpp b/revoice/src/revoice_player.cpp index 92bb503..e778424 100644 --- a/revoice/src/revoice_player.cpp +++ b/revoice/src/revoice_player.cpp @@ -1,195 +1,195 @@ -#include "precompiled.h" - -const char *CRevoicePlayer::m_szCodecType[] = { - "none", - "silk", - "opus", - "speex" -}; - -CRevoicePlayer g_Players[MAX_PLAYERS]; - -CRevoicePlayer::CRevoicePlayer() -{ - m_CodecType = vct_none; - m_SpeexCodec = new VoiceCodec_Frame(new VoiceEncoder_Speex()); - m_SilkCodec = new CSteamP2PCodec(new VoiceEncoder_Silk()); - m_OpusCodec = new CSteamP2PCodec(new VoiceEncoder_Opus()); - - m_SpeexCodec->Init(SPEEX_VOICE_QUALITY); - m_SilkCodec ->Init(SILK_VOICE_QUALITY); - m_OpusCodec ->Init(OPUS_VOICE_QUALITY); - - m_Protocol = 0; - m_HLTV = false; - m_Connected = false; - m_Client = nullptr; -} - -void CRevoicePlayer::Initialize(IGameClient *cl) -{ - m_Client = cl; - - m_SpeexCodec->SetClient(cl); - m_SilkCodec ->SetClient(cl); - m_OpusCodec ->SetClient(cl); -} - -void CRevoicePlayer::OnConnected() -{ - // already connected, suppose now there is a change of level? - if (m_Connected) { - m_VoiceRate = 0; - return; - } - - int protocol = g_ReunionApi->GetClientProtocol(m_Client->GetId()); - if (protocol != 47 && protocol != 48) { - return; - } - - // reset codec state - m_SilkCodec->ResetState(); - m_OpusCodec->ResetState(); - m_SpeexCodec->ResetState(); - - // default codec - m_CodecType = GetCodecTypeByString(g_pcv_rev_default_codec->string); - m_VoiceRate = 0; - m_Connected = true; - m_RequestId = MAKE_REQUESTID(PLID); - m_Protocol = protocol; - - if (g_ReunionApi->GetClientAuthtype(m_Client->GetId()) == DP_AUTH_HLTV) { - m_CodecType = GetCodecTypeByString(g_pcv_rev_hltv_codec->string); - m_HLTV = true; - } - else if (m_Protocol == 48) { - g_engfuncs.pfnQueryClientCvarValue2(m_Client->GetEdict(), "sv_version", m_RequestId); - } -} - -void CRevoicePlayer::OnDisconnected() -{ - m_HLTV = false; - m_Connected = false; - m_Protocol = 0; - m_CodecType = vct_none; - m_VoiceRate = 0; - m_RequestId = 0; -} - -void CRevoicePlayer::Update() -{ - if (m_HLTV) { - m_CodecType = GetCodecTypeByString(g_pcv_rev_hltv_codec->string); - return; - } - - m_CodecType = GetCodecTypeByString(g_pcv_rev_default_codec->string); - m_RequestId = MAKE_REQUESTID(PLID); - - if (m_Protocol == 48) { - g_engfuncs.pfnQueryClientCvarValue2(m_Client->GetEdict(), "sv_version", m_RequestId); - } -} - -void Revoice_Init_Players() -{ - int maxclients = g_RehldsSvs->GetMaxClients(); - for (int i = 0; i < maxclients; i++) { - g_Players[i].Initialize(g_RehldsSvs->GetClient(i)); - } -} - -void Revoice_Update_Players(const char *pszNewValue) -{ - for (int i = 0; i < g_RehldsSvs->GetMaxClients(); i++) { - auto plr = &g_Players[i]; - if (plr->IsConnected()) { - plr->Update(); - } - } -} - -void Revoice_Update_Hltv(const char *pszNewValue) -{ - int maxclients = g_RehldsSvs->GetMaxClients(); - for (int i = 0; i < g_RehldsSvs->GetMaxClients(); i++) { - auto plr = &g_Players[i]; - if (plr->IsConnected() && plr->IsHLTV()) { - plr->Update(); - } - } -} - -CRevoicePlayer *GetPlayerByClientPtr(IGameClient *cl) -{ - return &g_Players[ cl->GetId() ]; -} - -CRevoicePlayer *GetPlayerByEdict(const edict_t *ed) -{ - int clientId = g_engfuncs.pfnIndexOfEdict(ed) - 1; - - if (clientId < 0 || clientId >= g_RehldsSvs->GetMaxClients()) { - util_syserror("Invalid player edict id=%d\n", clientId); - } - - return &g_Players[ clientId ]; -} - -void CRevoicePlayer::SetLastVoiceTime(double time) -{ - UpdateVoiceRate(time - m_Client->GetLastVoiceTime()); - m_Client->SetLastVoiceTime(time); -} - -void CRevoicePlayer::UpdateVoiceRate(double delta) -{ - if (m_VoiceRate) - { - switch (m_CodecType) - { - case vct_silk: - m_VoiceRate -= int(delta * MAX_SILK_VOICE_RATE) + MAX_SILK_DATA_LEN; - break; - case vct_opus: - m_VoiceRate -= int(delta * MAX_OPUS_VOICE_RATE) + MAX_OPUS_DATA_LEN; - break; - case vct_speex: - m_VoiceRate -= int(delta * MAX_SPEEX_VOICE_RATE) + MAX_SPEEX_DATA_LEN; - break; - default: - break; - } - - if (m_VoiceRate < 0) - m_VoiceRate = 0; - } -} - -const char *CRevoicePlayer::GetCodecTypeToString() -{ - return m_szCodecType[ m_CodecType ]; -} - -void CRevoicePlayer::IncreaseVoiceRate(int dataLength) -{ - m_VoiceRate += dataLength; -} - -CodecType CRevoicePlayer::GetCodecTypeByString(const char *codec) -{ -#define REV_CODEC(know_codec)\ - if (_stricmp(codec, #know_codec) == 0) {\ - return vct_##know_codec;\ - }\ - - REV_CODEC(opus); - REV_CODEC(silk); - REV_CODEC(speex); -#undef REV_CODEC - - return vct_none; -} +#include "precompiled.h" + +const char *CRevoicePlayer::m_szCodecType[] = { + "none", + "silk", + "opus", + "speex" +}; + +CRevoicePlayer g_Players[MAX_PLAYERS]; + +CRevoicePlayer::CRevoicePlayer() +{ + m_CodecType = vct_none; + m_SpeexCodec = new VoiceCodec_Frame(new VoiceEncoder_Speex()); + m_SilkCodec = new CSteamP2PCodec(new VoiceEncoder_Silk()); + m_OpusCodec = new CSteamP2PCodec(new VoiceEncoder_Opus()); + + m_SpeexCodec->Init(SPEEX_VOICE_QUALITY); + m_SilkCodec ->Init(SILK_VOICE_QUALITY); + m_OpusCodec ->Init(OPUS_VOICE_QUALITY); + + m_Protocol = 0; + m_HLTV = false; + m_Connected = false; + m_Client = nullptr; +} + +void CRevoicePlayer::Initialize(IGameClient *cl) +{ + m_Client = cl; + + m_SpeexCodec->SetClient(cl); + m_SilkCodec ->SetClient(cl); + m_OpusCodec ->SetClient(cl); +} + +void CRevoicePlayer::OnConnected() +{ + // already connected, suppose now there is a change of level? + if (m_Connected) { + m_VoiceRate = 0; + return; + } + + int protocol = g_ReunionApi->GetClientProtocol(m_Client->GetId()); + if (protocol != 47 && protocol != 48) { + return; + } + + // reset codec state + m_SilkCodec->ResetState(); + m_OpusCodec->ResetState(); + m_SpeexCodec->ResetState(); + + // default codec + m_CodecType = GetCodecTypeByString(g_pcv_rev_default_codec->string); + m_VoiceRate = 0; + m_Connected = true; + m_RequestId = MAKE_REQUESTID(PLID); + m_Protocol = protocol; + + if (g_ReunionApi->GetClientAuthtype(m_Client->GetId()) == DP_AUTH_HLTV) { + m_CodecType = GetCodecTypeByString(g_pcv_rev_hltv_codec->string); + m_HLTV = true; + } + else if (m_Protocol == 48) { + g_engfuncs.pfnQueryClientCvarValue2(m_Client->GetEdict(), "sv_version", m_RequestId); + } +} + +void CRevoicePlayer::OnDisconnected() +{ + m_HLTV = false; + m_Connected = false; + m_Protocol = 0; + m_CodecType = vct_none; + m_VoiceRate = 0; + m_RequestId = 0; +} + +void CRevoicePlayer::Update() +{ + if (m_HLTV) { + m_CodecType = GetCodecTypeByString(g_pcv_rev_hltv_codec->string); + return; + } + + m_CodecType = GetCodecTypeByString(g_pcv_rev_default_codec->string); + m_RequestId = MAKE_REQUESTID(PLID); + + if (m_Protocol == 48) { + g_engfuncs.pfnQueryClientCvarValue2(m_Client->GetEdict(), "sv_version", m_RequestId); + } +} + +void Revoice_Init_Players() +{ + int maxclients = g_RehldsSvs->GetMaxClients(); + for (int i = 0; i < maxclients; i++) { + g_Players[i].Initialize(g_RehldsSvs->GetClient(i)); + } +} + +void Revoice_Update_Players(const char *pszNewValue) +{ + for (int i = 0; i < g_RehldsSvs->GetMaxClients(); i++) { + auto plr = &g_Players[i]; + if (plr->IsConnected()) { + plr->Update(); + } + } +} + +void Revoice_Update_Hltv(const char *pszNewValue) +{ + int maxclients = g_RehldsSvs->GetMaxClients(); + for (int i = 0; i < g_RehldsSvs->GetMaxClients(); i++) { + auto plr = &g_Players[i]; + if (plr->IsConnected() && plr->IsHLTV()) { + plr->Update(); + } + } +} + +CRevoicePlayer *GetPlayerByClientPtr(IGameClient *cl) +{ + return &g_Players[ cl->GetId() ]; +} + +CRevoicePlayer *GetPlayerByEdict(const edict_t *ed) +{ + int clientId = g_engfuncs.pfnIndexOfEdict(ed) - 1; + + if (clientId < 0 || clientId >= g_RehldsSvs->GetMaxClients()) { + util_syserror("Invalid player edict id=%d\n", clientId); + } + + return &g_Players[ clientId ]; +} + +void CRevoicePlayer::SetLastVoiceTime(double time) +{ + UpdateVoiceRate(time - m_Client->GetLastVoiceTime()); + m_Client->SetLastVoiceTime(time); +} + +void CRevoicePlayer::UpdateVoiceRate(double delta) +{ + if (m_VoiceRate) + { + switch (m_CodecType) + { + case vct_silk: + m_VoiceRate -= int(delta * MAX_SILK_VOICE_RATE) + MAX_SILK_DATA_LEN; + break; + case vct_opus: + m_VoiceRate -= int(delta * MAX_OPUS_VOICE_RATE) + MAX_OPUS_DATA_LEN; + break; + case vct_speex: + m_VoiceRate -= int(delta * MAX_SPEEX_VOICE_RATE) + MAX_SPEEX_DATA_LEN; + break; + default: + break; + } + + if (m_VoiceRate < 0) + m_VoiceRate = 0; + } +} + +const char *CRevoicePlayer::GetCodecTypeToString() +{ + return m_szCodecType[ m_CodecType ]; +} + +void CRevoicePlayer::IncreaseVoiceRate(int dataLength) +{ + m_VoiceRate += dataLength; +} + +CodecType CRevoicePlayer::GetCodecTypeByString(const char *codec) +{ +#define REV_CODEC(know_codec)\ + if (_stricmp(codec, #know_codec) == 0) {\ + return vct_##know_codec;\ + }\ + + REV_CODEC(opus); + REV_CODEC(silk); + REV_CODEC(speex); +#undef REV_CODEC + + return vct_none; +} diff --git a/revoice/src/revoice_player.h b/revoice/src/revoice_player.h index dc0fc4f..29c1b3f 100644 --- a/revoice/src/revoice_player.h +++ b/revoice/src/revoice_player.h @@ -1,58 +1,58 @@ -#pragma once - -#include "revoice_shared.h" -#include "VoiceEncoder_Silk.h" -#include "SteamP2PCodec.h" -#include "VoiceEncoder_Speex.h" -#include "voice_codec_frame.h" - -class CRevoicePlayer { -private: - IGameClient *m_Client; - CodecType m_CodecType; - CSteamP2PCodec *m_SilkCodec; - CSteamP2PCodec *m_OpusCodec; - VoiceCodec_Frame *m_SpeexCodec; - int m_Protocol; - int m_VoiceRate; - int m_RequestId; - bool m_Connected; - bool m_HLTV; - -public: - CRevoicePlayer(); - void Update(); - void Initialize(IGameClient *cl); - void OnConnected(); - void OnDisconnected(); - - void SetLastVoiceTime(double time); - void UpdateVoiceRate(double delta); - void IncreaseVoiceRate(int dataLength); - CodecType GetCodecTypeByString(const char *codec); - const char *GetCodecTypeToString(); - - int GetProtocol() const { return m_Protocol; } - int GetVoiceRate() const { return m_VoiceRate; } - int GetRequestId() const { return m_RequestId; } - bool IsConnected() const { return m_Connected; } - bool IsHLTV() const { return m_HLTV; } - - static const char *m_szCodecType[]; - void SetCodecType(CodecType codecType) { m_CodecType = codecType; } - - CodecType GetCodecType() const { return m_CodecType; } - CSteamP2PCodec *GetSilkCodec() const { return m_SilkCodec; } - CSteamP2PCodec *GetOpusCodec() const { return m_OpusCodec; } - VoiceCodec_Frame *GetSpeexCodec() const { return m_SpeexCodec; } - IGameClient *GetClient() const { return m_Client; } -}; - -extern CRevoicePlayer g_Players[MAX_PLAYERS]; - -CRevoicePlayer *GetPlayerByClientPtr(IGameClient *cl); -CRevoicePlayer *GetPlayerByEdict(const edict_t *ed); - -void Revoice_Init_Players(); -void Revoice_Update_Players(const char *pszNewValue); -void Revoice_Update_Hltv(const char *pszNewValue); +#pragma once + +#include "revoice_shared.h" +#include "VoiceEncoder_Silk.h" +#include "SteamP2PCodec.h" +#include "VoiceEncoder_Speex.h" +#include "voice_codec_frame.h" + +class CRevoicePlayer { +private: + IGameClient *m_Client; + CodecType m_CodecType; + CSteamP2PCodec *m_SilkCodec; + CSteamP2PCodec *m_OpusCodec; + VoiceCodec_Frame *m_SpeexCodec; + int m_Protocol; + int m_VoiceRate; + int m_RequestId; + bool m_Connected; + bool m_HLTV; + +public: + CRevoicePlayer(); + void Update(); + void Initialize(IGameClient *cl); + void OnConnected(); + void OnDisconnected(); + + void SetLastVoiceTime(double time); + void UpdateVoiceRate(double delta); + void IncreaseVoiceRate(int dataLength); + CodecType GetCodecTypeByString(const char *codec); + const char *GetCodecTypeToString(); + + int GetProtocol() const { return m_Protocol; } + int GetVoiceRate() const { return m_VoiceRate; } + int GetRequestId() const { return m_RequestId; } + bool IsConnected() const { return m_Connected; } + bool IsHLTV() const { return m_HLTV; } + + static const char *m_szCodecType[]; + void SetCodecType(CodecType codecType) { m_CodecType = codecType; } + + CodecType GetCodecType() const { return m_CodecType; } + CSteamP2PCodec *GetSilkCodec() const { return m_SilkCodec; } + CSteamP2PCodec *GetOpusCodec() const { return m_OpusCodec; } + VoiceCodec_Frame *GetSpeexCodec() const { return m_SpeexCodec; } + IGameClient *GetClient() const { return m_Client; } +}; + +extern CRevoicePlayer g_Players[MAX_PLAYERS]; + +CRevoicePlayer *GetPlayerByClientPtr(IGameClient *cl); +CRevoicePlayer *GetPlayerByEdict(const edict_t *ed); + +void Revoice_Init_Players(); +void Revoice_Update_Players(const char *pszNewValue); +void Revoice_Update_Hltv(const char *pszNewValue); diff --git a/revoice/src/revoice_rehlds_api.cpp b/revoice/src/revoice_rehlds_api.cpp index 0b53165..6fa5091 100644 --- a/revoice/src/revoice_rehlds_api.cpp +++ b/revoice/src/revoice_rehlds_api.cpp @@ -1,70 +1,70 @@ -#include "precompiled.h" - -IRehldsApi *g_RehldsApi; -const RehldsFuncs_t *g_RehldsFuncs; -IRehldsHookchains *g_RehldsHookchains; -IRehldsServerStatic *g_RehldsSvs; -IRehldsServerData *g_RehldsSv; - -bool Revoice_RehldsApi_TryInit(CSysModule *engineModule, char *failureReason) -{ - if (!engineModule) { - LCPrintf(true, "Failed to locate engine module\n"); - return false; - } - - CreateInterfaceFn ifaceFactory = Sys_GetFactory(engineModule); - - if (!ifaceFactory) { - sprintf(failureReason, "Failed to locate interface factory in engine module\n"); - return false; - } - - int retCode = 0; - g_RehldsApi = (IRehldsApi*)ifaceFactory(VREHLDS_HLDS_API_VERSION, &retCode); - - if (!g_RehldsApi) { - sprintf(failureReason, "Failed to locate retrieve rehlds api interface from engine module, return code is %d\n", retCode); - return false; - } - - int majorVersion = g_RehldsApi->GetMajorVersion(); - int minorVersion = g_RehldsApi->GetMinorVersion(); - - if (majorVersion != REHLDS_API_VERSION_MAJOR) { - sprintf(failureReason, "REHLDS Api major version mismatch; expected %d, real %d\n", REHLDS_API_VERSION_MAJOR, majorVersion); - return false; - } - - if (minorVersion < REHLDS_API_VERSION_MINOR) { - sprintf(failureReason, "REHLDS Api minor version mismatch; expected at least %d, real %d\n", REHLDS_API_VERSION_MINOR, minorVersion); - return false; - } - - g_RehldsFuncs = g_RehldsApi->GetFuncs(); - g_RehldsHookchains = g_RehldsApi->GetHookchains(); - g_RehldsSvs = g_RehldsApi->GetServerStatic(); - g_RehldsSv = g_RehldsApi->GetServerData(); - - return true; -} - -bool Revoice_RehldsApi_Init() { - char failReason[2048]; - -#ifdef WIN32 - CSysModule *engineModule = Sys_LoadModule("swds.dll"); - if (!Revoice_RehldsApi_TryInit(engineModule, failReason)) { - LCPrintf(true, "%s", failReason); - return false; - } -#else - CSysModule *engineModule = Sys_LoadModule("engine_i486.so"); - if (!Revoice_RehldsApi_TryInit(engineModule, failReason)) { - LCPrintf(true, "%s", failReason); - return false; - } -#endif - - return true; -} +#include "precompiled.h" + +IRehldsApi *g_RehldsApi; +const RehldsFuncs_t *g_RehldsFuncs; +IRehldsHookchains *g_RehldsHookchains; +IRehldsServerStatic *g_RehldsSvs; +IRehldsServerData *g_RehldsSv; + +bool Revoice_RehldsApi_TryInit(CSysModule *engineModule, char *failureReason) +{ + if (!engineModule) { + LCPrintf(true, "Failed to locate engine module\n"); + return false; + } + + CreateInterfaceFn ifaceFactory = Sys_GetFactory(engineModule); + + if (!ifaceFactory) { + sprintf(failureReason, "Failed to locate interface factory in engine module\n"); + return false; + } + + int retCode = 0; + g_RehldsApi = (IRehldsApi*)ifaceFactory(VREHLDS_HLDS_API_VERSION, &retCode); + + if (!g_RehldsApi) { + sprintf(failureReason, "Failed to locate retrieve rehlds api interface from engine module, return code is %d\n", retCode); + return false; + } + + int majorVersion = g_RehldsApi->GetMajorVersion(); + int minorVersion = g_RehldsApi->GetMinorVersion(); + + if (majorVersion != REHLDS_API_VERSION_MAJOR) { + sprintf(failureReason, "REHLDS Api major version mismatch; expected %d, real %d\n", REHLDS_API_VERSION_MAJOR, majorVersion); + return false; + } + + if (minorVersion < REHLDS_API_VERSION_MINOR) { + sprintf(failureReason, "REHLDS Api minor version mismatch; expected at least %d, real %d\n", REHLDS_API_VERSION_MINOR, minorVersion); + return false; + } + + g_RehldsFuncs = g_RehldsApi->GetFuncs(); + g_RehldsHookchains = g_RehldsApi->GetHookchains(); + g_RehldsSvs = g_RehldsApi->GetServerStatic(); + g_RehldsSv = g_RehldsApi->GetServerData(); + + return true; +} + +bool Revoice_RehldsApi_Init() { + char failReason[2048]; + +#ifdef WIN32 + CSysModule *engineModule = Sys_LoadModule("swds.dll"); + if (!Revoice_RehldsApi_TryInit(engineModule, failReason)) { + LCPrintf(true, "%s", failReason); + return false; + } +#else + CSysModule *engineModule = Sys_LoadModule("engine_i486.so"); + if (!Revoice_RehldsApi_TryInit(engineModule, failReason)) { + LCPrintf(true, "%s", failReason); + return false; + } +#endif + + return true; +} diff --git a/revoice/src/revoice_rehlds_api.h b/revoice/src/revoice_rehlds_api.h index 80bbf08..aada353 100644 --- a/revoice/src/revoice_rehlds_api.h +++ b/revoice/src/revoice_rehlds_api.h @@ -1,11 +1,11 @@ -#pragma once - -#include "revoice_shared.h" - -extern IRehldsApi* g_RehldsApi; -extern const RehldsFuncs_t* g_RehldsFuncs; -extern IRehldsHookchains* g_RehldsHookchains; -extern IRehldsServerStatic* g_RehldsSvs; -extern IRehldsServerData* g_RehldsSv; - -extern bool Revoice_RehldsApi_Init(); +#pragma once + +#include "revoice_shared.h" + +extern IRehldsApi* g_RehldsApi; +extern const RehldsFuncs_t* g_RehldsFuncs; +extern IRehldsHookchains* g_RehldsHookchains; +extern IRehldsServerStatic* g_RehldsSvs; +extern IRehldsServerData* g_RehldsSv; + +extern bool Revoice_RehldsApi_Init(); diff --git a/revoice/src/revoice_shared.h b/revoice/src/revoice_shared.h index 0ce756c..2511ef8 100644 --- a/revoice/src/revoice_shared.h +++ b/revoice/src/revoice_shared.h @@ -1,47 +1,47 @@ -#pragma once - -#include "rehlds_api.h" - -#define MAX_PLAYERS 32 - -#define LOG_PREFIX "[REVOICE]: " - -#define MAX_SILK_DATA_LEN 650 -#define MAX_OPUS_DATA_LEN 960 -#define MAX_SPEEX_DATA_LEN 228 - -#define MAX_SILK_VOICE_RATE 3800 -#define MAX_OPUS_VOICE_RATE 3100 -#define MAX_SPEEX_VOICE_RATE 2014 - -#define SILK_VOICE_QUALITY 5 -#define OPUS_VOICE_QUALITY 5 -#define SPEEX_VOICE_QUALITY 5 - -enum revoice_log_mode { - rl_none = 0, - rl_console = 1, - rl_logfile = 2, -}; - -enum CodecType { - vct_none, - vct_silk, - vct_opus, - vct_speex, -}; - -enum svc_messages { - svc_voiceinit = 52, - svc_voicedata = 53 -}; - -extern char* trimbuf(char *str); -extern void NormalizePath(char *path); -extern bool IsFileExists(const char *path); -extern void LCPrintf(bool critical, const char *fmt, ...); -extern uint32 crc32(const void *buf, unsigned int bufLen); - -extern bool Revoice_Load(); -extern bool Revoice_Utils_Init(); -extern void util_syserror(const char *fmt, ...); +#pragma once + +#include "rehlds_api.h" + +#define MAX_PLAYERS 32 + +#define LOG_PREFIX "[REVOICE]: " + +#define MAX_SILK_DATA_LEN 650 +#define MAX_OPUS_DATA_LEN 960 +#define MAX_SPEEX_DATA_LEN 228 + +#define MAX_SILK_VOICE_RATE 3800 +#define MAX_OPUS_VOICE_RATE 3100 +#define MAX_SPEEX_VOICE_RATE 2014 + +#define SILK_VOICE_QUALITY 5 +#define OPUS_VOICE_QUALITY 5 +#define SPEEX_VOICE_QUALITY 5 + +enum revoice_log_mode { + rl_none = 0, + rl_console = 1, + rl_logfile = 2, +}; + +enum CodecType { + vct_none, + vct_silk, + vct_opus, + vct_speex, +}; + +enum svc_messages { + svc_voiceinit = 52, + svc_voicedata = 53 +}; + +extern char* trimbuf(char *str); +extern void NormalizePath(char *path); +extern bool IsFileExists(const char *path); +extern void LCPrintf(bool critical, const char *fmt, ...); +extern uint32 crc32(const void *buf, unsigned int bufLen); + +extern bool Revoice_Load(); +extern bool Revoice_Utils_Init(); +extern void util_syserror(const char *fmt, ...); diff --git a/revoice/src/revoice_utils.cpp b/revoice/src/revoice_utils.cpp index 7439a68..5cffca1 100644 --- a/revoice/src/revoice_utils.cpp +++ b/revoice/src/revoice_utils.cpp @@ -1,102 +1,102 @@ -#include "precompiled.h" - -cvar_t *pcv_mp_logecho; -char g_szLogstring[2048]; - -void LCPrintf(bool critical, const char *fmt, ...) -{ - va_list argptr; - const int prefixlen = 11; //sizeof(LOG_PREFIX) - 1; - - va_start(argptr, fmt); - vsnprintf(g_szLogstring + prefixlen, sizeof(g_szLogstring) - prefixlen, fmt, argptr); - va_end(argptr); - - bool bNeedWriteInConsole = critical; - bool bNeedWriteInLog = critical; - - if (bNeedWriteInConsole && bNeedWriteInLog && g_RehldsSvs && g_RehldsSvs->IsLogActive()) - { - if (pcv_mp_logecho && pcv_mp_logecho->value != 0.0) - bNeedWriteInConsole = false; - } - - if (bNeedWriteInConsole) - SERVER_PRINT(g_szLogstring); - - if (bNeedWriteInLog) - ALERT(at_logged, g_szLogstring); -} - -bool Revoice_Utils_Init() -{ - pcv_mp_logecho = g_engfuncs.pfnCVarGetPointer("mp_logecho"); - strcpy(g_szLogstring, LOG_PREFIX); - - return true; -} - -char *trimbuf(char *str) -{ - char *ibuf = str; - int i = 0; - - if (str == NULL) - return NULL; - - for (ibuf = str; *ibuf && (byte)(*ibuf) < (byte)0x80 && isspace(*ibuf); ++ibuf) - ; - - i = strlen(ibuf); - - if (str != ibuf) - memmove(str, ibuf, i); - - str[i] = 0; - - while (--i >= 0) { - if (!isspace(ibuf[i])) - break; - } - - ibuf[++i] = 0; - - return str; -} - -uint32 crc32(const void *buf, unsigned int bufLen) -{ - CRC32_t hCrc; - g_engfuncs.pfnCRC32_Init(&hCrc); - g_engfuncs.pfnCRC32_ProcessBuffer(&hCrc, (void*)buf, bufLen); - hCrc = g_engfuncs.pfnCRC32_Final(hCrc); - return hCrc; -} - -void NormalizePath(char *path) -{ - for (char *cp = path; *cp; cp++) { - if (isupper(*cp)) - *cp = tolower(*cp); - - if (*cp == '\\') - *cp = '/'; - } -} - -void util_syserror(const char *fmt, ...) -{ - va_list argptr; - char buf[4096]; - - va_start(argptr, fmt); - vsnprintf(buf, ARRAYSIZE(buf) - 1, fmt, argptr); - buf[ARRAYSIZE(buf) - 1] = 0; - va_end(argptr); - - LCPrintf(true, "ERROR: %s", buf); - - int *null = 0; - *null = 0; - exit(-1); -} +#include "precompiled.h" + +cvar_t *pcv_mp_logecho; +char g_szLogstring[2048]; + +void LCPrintf(bool critical, const char *fmt, ...) +{ + va_list argptr; + const int prefixlen = 11; //sizeof(LOG_PREFIX) - 1; + + va_start(argptr, fmt); + vsnprintf(g_szLogstring + prefixlen, sizeof(g_szLogstring) - prefixlen, fmt, argptr); + va_end(argptr); + + bool bNeedWriteInConsole = critical; + bool bNeedWriteInLog = critical; + + if (bNeedWriteInConsole && bNeedWriteInLog && g_RehldsSvs && g_RehldsSvs->IsLogActive()) + { + if (pcv_mp_logecho && pcv_mp_logecho->value != 0.0) + bNeedWriteInConsole = false; + } + + if (bNeedWriteInConsole) + SERVER_PRINT(g_szLogstring); + + if (bNeedWriteInLog) + ALERT(at_logged, g_szLogstring); +} + +bool Revoice_Utils_Init() +{ + pcv_mp_logecho = g_engfuncs.pfnCVarGetPointer("mp_logecho"); + strcpy(g_szLogstring, LOG_PREFIX); + + return true; +} + +char *trimbuf(char *str) +{ + char *ibuf = str; + int i = 0; + + if (str == NULL) + return NULL; + + for (ibuf = str; *ibuf && (byte)(*ibuf) < (byte)0x80 && isspace(*ibuf); ++ibuf) + ; + + i = strlen(ibuf); + + if (str != ibuf) + memmove(str, ibuf, i); + + str[i] = 0; + + while (--i >= 0) { + if (!isspace(ibuf[i])) + break; + } + + ibuf[++i] = 0; + + return str; +} + +uint32 crc32(const void *buf, unsigned int bufLen) +{ + CRC32_t hCrc; + g_engfuncs.pfnCRC32_Init(&hCrc); + g_engfuncs.pfnCRC32_ProcessBuffer(&hCrc, (void*)buf, bufLen); + hCrc = g_engfuncs.pfnCRC32_Final(hCrc); + return hCrc; +} + +void NormalizePath(char *path) +{ + for (char *cp = path; *cp; cp++) { + if (isupper(*cp)) + *cp = tolower(*cp); + + if (*cp == '\\') + *cp = '/'; + } +} + +void util_syserror(const char *fmt, ...) +{ + va_list argptr; + char buf[4096]; + + va_start(argptr, fmt); + vsnprintf(buf, ARRAYSIZE(buf) - 1, fmt, argptr); + buf[ARRAYSIZE(buf) - 1] = 0; + va_end(argptr); + + LCPrintf(true, "ERROR: %s", buf); + + int *null = 0; + *null = 0; + exit(-1); +} diff --git a/revoice/src/sdk_util.cpp b/revoice/src/sdk_util.cpp index 2edd79c..f51ee96 100644 --- a/revoice/src/sdk_util.cpp +++ b/revoice/src/sdk_util.cpp @@ -1,77 +1,77 @@ -// Selected portions of dlls/util.cpp from SDK 2.1. -// Functions copied from there as needed... -// And modified to avoid buffer overflows (argh). - -/*** -* -* Copyright (c) 1999, 2000 Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -/* - -===== util.cpp ======================================================== - - Utility code. Really not optional after all. - -*/ - -#include "precompiled.h" - -//========================================================= -// UTIL_LogPrintf - Prints a logged message to console. -// Preceded by LOG: ( timestamp ) < message > -//========================================================= -void UTIL_LogPrintf(char *fmt, ...) -{ - va_list argptr; - static char string[1024]; - - va_start(argptr, fmt); - vsnprintf(string, sizeof(string), fmt, argptr); - va_end(argptr); - - // Print to server console - ALERT(at_logged, "%s", string); -} - -char *UTIL_VarArgs(char *format, ...) -{ - va_list argptr; - static char string[1024]; - - va_start(argptr, format); - vsprintf(string, format, argptr); - va_end(argptr); - - return string; -} - -void UTIL_ServerPrintf(const char *fmt, ...) -{ - // Check is null, test the demo started before than searches pointer to refs - if (&g_engfuncs == nullptr || g_engfuncs.pfnServerPrint == nullptr) - return; - - static char string[1024]; - va_list ap; - va_start(ap, fmt); - vsnprintf(string, sizeof(string), fmt, ap); - va_end(ap); - - if (strlen(string) < sizeof(string) - 2) - strcat(string, "\n"); - else - string[strlen(string) - 1] = '\n'; - - SERVER_PRINT(string); -} +// Selected portions of dlls/util.cpp from SDK 2.1. +// Functions copied from there as needed... +// And modified to avoid buffer overflows (argh). + +/*** +* +* Copyright (c) 1999, 2000 Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +/* + +===== util.cpp ======================================================== + + Utility code. Really not optional after all. + +*/ + +#include "precompiled.h" + +//========================================================= +// UTIL_LogPrintf - Prints a logged message to console. +// Preceded by LOG: ( timestamp ) < message > +//========================================================= +void UTIL_LogPrintf(char *fmt, ...) +{ + va_list argptr; + static char string[1024]; + + va_start(argptr, fmt); + vsnprintf(string, sizeof(string), fmt, argptr); + va_end(argptr); + + // Print to server console + ALERT(at_logged, "%s", string); +} + +char *UTIL_VarArgs(char *format, ...) +{ + va_list argptr; + static char string[1024]; + + va_start(argptr, format); + vsprintf(string, format, argptr); + va_end(argptr); + + return string; +} + +void UTIL_ServerPrintf(const char *fmt, ...) +{ + // Check is null, test the demo started before than searches pointer to refs + if (&g_engfuncs == nullptr || g_engfuncs.pfnServerPrint == nullptr) + return; + + static char string[1024]; + va_list ap; + va_start(ap, fmt); + vsnprintf(string, sizeof(string), fmt, ap); + va_end(ap); + + if (strlen(string) < sizeof(string) - 2) + strcat(string, "\n"); + else + string[strlen(string) - 1] = '\n'; + + SERVER_PRINT(string); +} diff --git a/revoice/version/version.cpp b/revoice/version/version.cpp index c5a6b06..5089a5f 100644 --- a/revoice/version/version.cpp +++ b/revoice/version/version.cpp @@ -1,10 +1,10 @@ -/* -* Version declaration dependency file -* -*/ - -// -// This file needed just to add the dependency and appversion.h -// -#include "precompiled.h" - +/* +* Version declaration dependency file +* +*/ + +// +// This file needed just to add the dependency and appversion.h +// +#include "precompiled.h" +