Regamedll API WIP: Added new api functions

This commit is contained in:
s1lentq 2016-04-21 07:00:02 +06:00
parent d8b12ee80b
commit 22ae6a2c59
16 changed files with 547 additions and 443 deletions

View File

@ -101,7 +101,9 @@ int CBaseAnimating::LookupSequence(const char *label)
return ::LookupSequence(pmodel, label);
}
void CBaseAnimating::ResetSequenceInfo()
LINK_HOOK_CLASS_VOID_CHAIN2(CBaseAnimating, ResetSequenceInfo)
void CBaseAnimating::__API_HOOK(ResetSequenceInfo)()
{
void *pmodel = GET_MODEL_PTR(ENT(pev));

View File

@ -493,6 +493,7 @@ public:
int LookupActivityHeaviest(int activity);
int LookupSequence(const char *label);
void ResetSequenceInfo();
void ResetSequenceInfo_();
void DispatchAnimEvents(float flFutureInterval = 0.1f); // Handle events that have happend since last time called up until X seconds into the future
float SetBoneController(int iController, float flValue = 0.0f);
void InitBoneControllers();

View File

@ -34,8 +34,6 @@
#include "game_shared/voice_gamemgr.h"
#define COM_TOKEN_LEN 1500
#define MAX_RULE_BUFFER 1024
#define MAX_VOTE_MAPS 100
#define MAX_VIP_QUEUES 5

View File

@ -5,7 +5,7 @@
*/
#ifndef HOOK_GAMEDLL
static char mp_com_token[ COM_TOKEN_LEN ];
static char mp_com_token[ 1500 ];
cvar_t *sv_clienttrace = NULL;
#endif
@ -3461,7 +3461,6 @@ BOOL CHalfLifeMultiplay::__MAKE_VHOOK(FPlayerCanRespawn)(CBasePlayer *pPlayer)
m_iNumCT = CountTeamPlayers(CT);
m_iNumTerrorist = CountTeamPlayers(TERRORIST);
if (m_iNumTerrorist > 0 && m_iNumCT > 0)
{
// If this player just connected and fadetoblack is on, then maybe

View File

@ -29,8 +29,6 @@
#include "voice_gamemgr.h"
#define COM_TOKEN_LEN 1500
#define MAX_RULE_BUFFER 1024
#define MAX_VOTE_MAPS 100
#define MAX_VIP_QUEUES 5

View File

@ -151,6 +151,11 @@
// It's usually defined to something like "__stdcall".
#else // _WIN32
#ifdef __FUNCTION__
#undef __FUNCTION__
#endif
#define __FUNCTION__ __func__
#ifndef PAGESIZE
#define PAGESIZE 4096
#endif

View File

@ -51,8 +51,8 @@ typedef IHookChain<int> IReGameHook_CBasePlayer_Classify;
typedef IHookChainRegistryClass<int, class CBasePlayer> IReGameHookRegistry_CBasePlayer_Classify;
// CBasePlayer::TraceAttack hook
typedef IVoidHookChain<struct entvars_s *, float, Vector, struct TraceResult *, int> IReGameHook_CBasePlayer_TraceAttack;
typedef IVoidHookChainRegistryClass<class CBasePlayer, struct entvars_s *, float, Vector, struct TraceResult *, int> IReGameHookRegistry_CBasePlayer_TraceAttack;
typedef IVoidHookChain<struct entvars_s *, float, Vector &, struct TraceResult *, int> IReGameHook_CBasePlayer_TraceAttack;
typedef IVoidHookChainRegistryClass<class CBasePlayer, struct entvars_s *, float, Vector &, struct TraceResult *, int> IReGameHookRegistry_CBasePlayer_TraceAttack;
// CBasePlayer::TakeDamage hook
typedef IHookChain<int, struct entvars_s *, struct entvars_s *, float, int> IReGameHook_CBasePlayer_TakeDamage;
@ -123,20 +123,53 @@ typedef IVoidHookChain<float, float, float, int> IReGameHook_CBasePlayer_Blind;
typedef IVoidHookChainRegistryClass<class CBasePlayer, float, float, float, int> IReGameHookRegistry_CBasePlayer_Blind;
// Observer_IsValidTarget hook
// CBasePlayer::Observer_IsValidTarget hook
typedef IHookChain<class CBaseEntity *, int, bool> IReGameHook_CBasePlayer_Observer_IsValidTarget;
typedef IHookChainRegistryClass<class CBaseEntity *, class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget;
// CBasePlayer::SetAnimation hook
typedef IVoidHookChain<PLAYER_ANIM> IReGameHook_CBasePlayer_SetAnimation;
typedef IVoidHookChainRegistryClass<class CBasePlayer, PLAYER_ANIM> IReGameHookRegistry_CBasePlayer_SetAnimation;
// CBasePlayer::GiveDefaultItems hook
typedef IVoidHookChain<> IReGameHook_CBasePlayer_GiveDefaultItems;
typedef IVoidHookChainRegistryClass<class CBasePlayer> IReGameHookRegistry_CBasePlayer_GiveDefaultItems;
// CBasePlayer::GiveNamedItem hook
typedef IVoidHookChain<const char *> IReGameHook_CBasePlayer_GiveNamedItem;
typedef IVoidHookChainRegistryClass<class CBasePlayer, const char *> IReGameHookRegistry_CBasePlayer_GiveNamedItem;
// CBasePlayer::AddAccount hook
typedef IVoidHookChain<int, bool> IReGameHook_CBasePlayer_AddAccount;
typedef IVoidHookChainRegistryClass<class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_AddAccount;
// CBasePlayer::GiveShield hook
typedef IVoidHookChain<bool> IReGameHook_CBasePlayer_GiveShield;
typedef IVoidHookChainRegistryClass<class CBasePlayer, bool> IReGameHookRegistry_CBasePlayer_GiveShield;
// CBaseAnimating::ResetSequenceInfo hook
typedef IVoidHookChain<> IReGameHook_CBaseAnimating_ResetSequenceInfo;
typedef IVoidHookChainRegistryClass<class CBaseAnimating> IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo;
// GetForceCamera hook
typedef IHookChain<int, class CBasePlayer *> IReGameHook_GetForceCamera;
typedef IHookChainRegistry<int, class CBasePlayer *> IReGameHookRegistry_GetForceCamera;
// PlayerBlind hook
typedef IVoidHookChain<class CBasePlayer *, struct entvars_s *, struct entvars_s *, float, float, int, Vector &> IReGameHook_PlayerBlind;
typedef IVoidHookChainRegistry<class CBasePlayer *, struct entvars_s *, struct entvars_s *, float, float, int, Vector &> IReGameHookRegistry_PlayerBlind;
// RadiusFlash_TraceLine hook
typedef IVoidHookChain<class CBasePlayer *, struct entvars_s *, struct entvars_s *, Vector &, Vector &, struct TraceResult *> IReGameHook_RadiusFlash_TraceLine;
typedef IVoidHookChainRegistry<class CBasePlayer *, struct entvars_s *, struct entvars_s *, Vector &, Vector &, struct TraceResult *> IReGameHookRegistry_RadiusFlash_TraceLine;
class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
@ -164,23 +197,38 @@ public:
virtual IReGameHookRegistry_CBasePlayer_RoundRespawn* CBasePlayer_RoundRespawn() = 0;
virtual IReGameHookRegistry_CBasePlayer_Blind* CBasePlayer_Blind() = 0;
virtual IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget* CBasePlayer_Observer_IsValidTarget() = 0;
virtual IReGameHookRegistry_CBasePlayer_SetAnimation* CBasePlayer_SetAnimation() = 0;
virtual IReGameHookRegistry_CBasePlayer_GiveDefaultItems* CBasePlayer_GiveDefaultItems() = 0;
virtual IReGameHookRegistry_CBasePlayer_GiveNamedItem* CBasePlayer_GiveNamedItem() = 0;
virtual IReGameHookRegistry_CBasePlayer_AddAccount* CBasePlayer_AddAccount() = 0;
virtual IReGameHookRegistry_CBasePlayer_GiveShield* CBasePlayer_GiveShield() = 0;
virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CBaseAnimating_ResetSequenceInfo() = 0;
virtual IReGameHookRegistry_GetForceCamera* GetForceCamera() = 0;
virtual IReGameHookRegistry_PlayerBlind* PlayerBlind() = 0;
virtual IReGameHookRegistry_RadiusFlash_TraceLine* RadiusFlash_TraceLine() = 0;
};
struct ReGameFuncs_t {
class CBaseEntity *(*UTIL_PlayerByIndex)(int playerIndex);
class ICSPlayer *(*CBASE_TO_CSPLAYER)(class CBaseEntity *pEntity);
class ICSEntity *(*CBASE_TO_CSENTITY)(CBaseEntity *pEntity);
class ICSEntity *(*CBASE_TO_CSENTITY)(class CBaseEntity *pEntity);
class ICSPlayer *(*INDEX_TO_CSPLAYER)(int iPlayerIndex);
class ICSEntity *(*INDEX_TO_CSENTITY)(int iEntityIndex);
struct edict_s *(*CREATE_NAMED_ENTITY2)(string_t iClass);
void (*ChangeString)(char *&dest, const char *source);
void (*RadiusDamage)(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType);
void (*ClearMultiDamage)();
void (*ApplyMultiDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker);
void (*AddMultiDamage)(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType);
};
class IReGameApi {

File diff suppressed because it is too large Load Diff

View File

@ -76,7 +76,7 @@ TYPEDESCRIPTION gGlobalEntitySaveData[3];
// globals gamerules
CGameRules *g_pGameRules;
char mp_com_token[ COM_TOKEN_LEN ];
char mp_com_token[ 1500 ];
cvar_t *sv_clienttrace;
// globals player.cpp

View File

@ -124,6 +124,7 @@
#endif
typedef unsigned char byte;
typedef unsigned char BYTE;
typedef unsigned short uchar16;
typedef wchar_t uchar32;
#endif // _WIN32
@ -198,12 +199,4 @@
// DLLEXPORT is defined, for convenience.
#define C_DLLEXPORT extern "C" DLLEXPORT
#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*/

View File

@ -150,6 +150,9 @@ typedef IVoidHookChainRegistryClass<class CBasePlayer, bool> IReGameHookRegistry
// CBaseAnimating::ResetSequenceInfo hook
typedef IVoidHookChain<> IReGameHook_CBaseAnimating_ResetSequenceInfo;
typedef IVoidHookChainRegistryClass<class CBaseAnimating> IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo;
@ -201,6 +204,8 @@ public:
virtual IReGameHookRegistry_CBasePlayer_AddAccount* CBasePlayer_AddAccount() = 0;
virtual IReGameHookRegistry_CBasePlayer_GiveShield* CBasePlayer_GiveShield() = 0;
virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CBaseAnimating_ResetSequenceInfo() = 0;
virtual IReGameHookRegistry_GetForceCamera* GetForceCamera() = 0;
@ -217,7 +222,13 @@ struct ReGameFuncs_t {
class ICSEntity *(*INDEX_TO_CSENTITY)(int iEntityIndex);
struct edict_s *(*CREATE_NAMED_ENTITY2)(string_t iClass);
void (*CopyString)(char *dest, const char *source);
void (*ChangeString)(char *&dest, const char *source);
void (*RadiusDamage)(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType);
void (*ClearMultiDamage)();
void (*ApplyMultiDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker);
void (*AddMultiDamage)(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType);
};
class IReGameApi {

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,12 @@ ReGameFuncs_t g_ReGameApiFuncs = {
&INDEX_TO_CSENTITY,
&CREATE_NAMED_ENTITY,
&Regamedll_CopyString_api,
&Regamedll_ChangeString_api,
&RadiusDamage_api,
&ClearMultiDamage_api,
&ApplyMultiDamage_api,
&AddMultiDamage_api,
};
IReGameHookRegistry_CBasePlayer_Spawn* CReGameHookchains::CBasePlayer_Spawn() { return &m_CBasePlayer_Spawn; }
@ -72,6 +77,8 @@ IReGameHookRegistry_CBasePlayer_AddAccount* CReGameHookchains::CBasePlayer_AddAc
IReGameHookRegistry_CBasePlayer_GiveShield* CReGameHookchains::CBasePlayer_GiveShield() { return &m_CBasePlayer_GiveShield; }
IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CReGameHookchains::CBaseAnimating_ResetSequenceInfo() { return &m_CBaseAnimating_ResetSequenceInfo; }
IReGameHookRegistry_GetForceCamera* CReGameHookchains::GetForceCamera() { return &m_GetForceCamera; }
IReGameHookRegistry_PlayerBlind* CReGameHookchains::PlayerBlind() { return &m_PlayerBlind; }
IReGameHookRegistry_RadiusFlash_TraceLine* CReGameHookchains::RadiusFlash_TraceLine() { return &m_RadiusFlash_TraceLine; }
@ -101,7 +108,7 @@ IReGameData *CReGameApi::GetGameData()
return &g_ReGameData;
}
void EXT_FUNC Regamedll_CopyString_api(char *dest, const char *source)
void EXT_FUNC Regamedll_ChangeString_api(char *&dest, const char *source)
{
size_t len = Q_strlen(source);
if (dest == nullptr || Q_strlen(dest) != len) {
@ -112,4 +119,24 @@ void EXT_FUNC Regamedll_CopyString_api(char *dest, const char *source)
Q_strcpy(dest, source);
}
void EXT_FUNC RadiusDamage_api(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType)
{
RadiusDamage(vecSrc, pevInflictor, pevAttacker, flDamage, flRadius, iClassIgnore, bitsDamageType);
}
void EXT_FUNC ClearMultiDamage_api()
{
ClearMultiDamage();
}
void EXT_FUNC ApplyMultiDamage_api(entvars_t *pevInflictor, entvars_t *pevAttacker)
{
ApplyMultiDamage(pevInflictor, pevAttacker);
}
void EXT_FUNC AddMultiDamage_api(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType)
{
AddMultiDamage(pevInflictor, pEntity, flDamage, bitsDamageType);
}
EXPOSE_SINGLE_INTERFACE(CReGameApi, IReGameApi, VRE_GAMEDLL_API_VERSION);

View File

@ -147,6 +147,11 @@ typedef IVoidHookChainRegistryClassImpl<CBasePlayer, bool> CReGameHookRegistry_C
// CBaseAnimating::ResetSequenceInfo hook
typedef IVoidHookChainClassImpl<CBaseAnimating> CRegameHook_CBaseAnimating_ResetSequenceInfo;
typedef IVoidHookChainRegistryClassImpl<CBaseAnimating> CReGameHookRegistry_CBaseAnimating_ResetSequenceInfo;
// GetForceCamera hook
typedef IHookChainImpl<int, class CBasePlayer *> CReGameHook_GetForceCamera;
typedef IHookChainRegistryImpl<int, class CBasePlayer *> CReGameHookRegistry_GetForceCamera;
@ -193,6 +198,8 @@ public:
CReGameHookRegistry_CBasePlayer_GiveShield m_CBasePlayer_GiveShield;
CReGameHookRegistry_CBaseAnimating_ResetSequenceInfo m_CBaseAnimating_ResetSequenceInfo;
CReGameHookRegistry_GetForceCamera m_GetForceCamera;
CReGameHookRegistry_PlayerBlind m_PlayerBlind;
CReGameHookRegistry_RadiusFlash_TraceLine m_RadiusFlash_TraceLine;
@ -229,7 +236,7 @@ public:
virtual IReGameHookRegistry_CBasePlayer_GiveShield* CBasePlayer_GiveShield();
virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CBaseAnimating_ResetSequenceInfo();
virtual IReGameHookRegistry_GetForceCamera* GetForceCamera();
virtual IReGameHookRegistry_PlayerBlind* PlayerBlind();
@ -251,4 +258,10 @@ public:
virtual IReGameData* GetGameData();
};
extern void Regamedll_CopyString_api(char *dest, const char *source);
void Regamedll_ChangeString_api(char *&dest, const char *source);
void RadiusDamage_api(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType);
void ClearMultiDamage_api();
void ApplyMultiDamage_api(entvars_t *pevInflictor, entvars_t *pevAttacker);
void AddMultiDamage_api(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType);

View File

@ -47,9 +47,6 @@ void Regamedll_AllocEntities(int maxEdicts)
ADD_SERVER_COMMAND("check_ent", [](){
Regamedll_MonitorEntities();
//ICSPlayer *pPlayer = CSPlayer(1);
//pPlayer->Spawn();
});
#endif
}
@ -113,7 +110,7 @@ ICSPlayer *EXT_FUNC CBASE_TO_CSPLAYER(CBaseEntity *pEntity)
ICSPlayer *EXT_FUNC INDEX_TO_CSPLAYER(int iPlayerIndex)
{
CBaseEntity *pEntity = CBaseEntity::Instance(iPlayerIndex);
CBaseEntity *pEntity = UTIL_PlayerByIndex(iPlayerIndex);
return CBASE_TO_CSPLAYER(pEntity);
}
@ -134,7 +131,7 @@ ICSEntity *EXT_FUNC CBASE_TO_CSENTITY(CBaseEntity *pEntity)
ICSEntity *EXT_FUNC INDEX_TO_CSENTITY(int iEntityIndex)
{
CBaseEntity *pEntity = CBaseEntity::Instance(iEntityIndex);
CBaseEntity *pEntity = CBaseEntity::Instance(INDEXENT(iEntityIndex));
return CBASE_TO_CSENTITY(pEntity);
}

View File

@ -149,6 +149,8 @@ public:
public:
virtual entvars_t *GetEntVars() const { return m_pEntity->pev; }
virtual CBaseEntity *GetEntity() const { return m_pEntity; }
virtual void FireBullets(int iShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker) { m_pEntity->FireBullets(iShots, vecSrc, vecDirShooting, vecSpread, flDistance, iBulletType, iTracerFreq, iDamage, pevAttacker); };
virtual Vector FireBullets3(Vector vecSrc, Vector vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand) { return m_pEntity->FireBullets3(vecSrc, vecDirShooting, vecSpread, flDistance, iPenetration, iBulletType, iDamage, flRangeModifier, pevAttacker, bPistol, shared_rand); };
};
class CCSDelay: public CCSEntity {