Change SDKHooks to VTable Hooks (bug 6070, r=psychonic).
This commit is contained in:
parent
ee595978f8
commit
9abac06e85
File diff suppressed because it is too large
Load Diff
@ -6,6 +6,8 @@
|
|||||||
#include <IBinTools.h>
|
#include <IBinTools.h>
|
||||||
#include <convar.h>
|
#include <convar.h>
|
||||||
#include <sh_list.h>
|
#include <sh_list.h>
|
||||||
|
#include <amtl/am-vector.h>
|
||||||
|
#include <vtable_hook_helper.h>
|
||||||
|
|
||||||
#include <iplayerinfo.h>
|
#include <iplayerinfo.h>
|
||||||
#include <shareddefs.h>
|
#include <shareddefs.h>
|
||||||
@ -106,14 +108,29 @@ class IPhysicsObject;
|
|||||||
class CDmgAccumulator;
|
class CDmgAccumulator;
|
||||||
typedef CBaseEntity CBaseCombatWeapon;
|
typedef CBaseEntity CBaseCombatWeapon;
|
||||||
|
|
||||||
class HookList
|
struct HookList
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int entity;
|
int entity;
|
||||||
SDKHookType type;
|
|
||||||
IPluginFunction *callback;
|
IPluginFunction *callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CVTableList
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CVTableList() : vtablehook(NULL)
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
~CVTableList()
|
||||||
|
{
|
||||||
|
delete vtablehook;
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
CVTableHook *vtablehook;
|
||||||
|
ke::Vector<HookList> hooks;
|
||||||
|
};
|
||||||
|
|
||||||
class IEntityListener
|
class IEntityListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -235,13 +252,13 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Functions
|
* Functions
|
||||||
*/
|
*/
|
||||||
cell_t Call(int entity, SDKHookType type, int other=-2);
|
cell_t Call(int entity, SDKHookType type, int other=INVALID_EHANDLE_INDEX);
|
||||||
cell_t Call(CBaseEntity *pEnt, SDKHookType type, int other=-2);
|
cell_t Call(CBaseEntity *pEnt, SDKHookType type, int other=INVALID_EHANDLE_INDEX);
|
||||||
cell_t Call(CBaseEntity *pEnt, SDKHookType type, CBaseEntity *pOther);
|
cell_t Call(CBaseEntity *pEnt, SDKHookType type, CBaseEntity *pOther);
|
||||||
void SetupHooks();
|
void SetupHooks();
|
||||||
|
|
||||||
HookReturn Hook(int entity, SDKHookType type, IPluginFunction *callback);
|
HookReturn Hook(int entity, SDKHookType type, IPluginFunction *pCallback);
|
||||||
void Unhook(int index);
|
void Unhook(int entity, SDKHookType type, IPluginFunction *pCallback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IServerGameDLL & IVEngineServer Hook Handlers
|
* IServerGameDLL & IVEngineServer Hook Handlers
|
||||||
@ -309,11 +326,12 @@ public:
|
|||||||
bool Hook_WeaponSwitchPost(CBaseCombatWeapon *pWeapon, int viewmodelindex);
|
bool Hook_WeaponSwitchPost(CBaseCombatWeapon *pWeapon, int viewmodelindex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RemoveEntityHooks(CBaseEntity *pEnt);
|
void Unhook(CBaseEntity *pEntity);
|
||||||
|
void Unhook(IPluginContext *pContext);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CGlobalVars *gpGlobals;
|
extern CGlobalVars *gpGlobals;
|
||||||
extern CUtlVector<HookList> g_HookList;
|
extern ke::Vector<CVTableList *> g_HookList[SDKHook_MAXHOOKS];
|
||||||
|
|
||||||
extern ICvar *icvar;
|
extern ICvar *icvar;
|
||||||
#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
|
#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
|
||||||
|
@ -93,12 +93,7 @@ cell_t Native_Unhook(IPluginContext *pContext, const cell_t *params)
|
|||||||
int entity = (int)params[1];
|
int entity = (int)params[1];
|
||||||
SDKHookType type = (SDKHookType)params[2];
|
SDKHookType type = (SDKHookType)params[2];
|
||||||
IPluginFunction *callback = pContext->GetFunctionById(params[3]);
|
IPluginFunction *callback = pContext->GetFunctionById(params[3]);
|
||||||
|
g_Interface.Unhook(entity, type, callback);
|
||||||
for(int i = g_HookList.Count() - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
if(g_HookList[i].entity == entity && g_HookList[i].type == type && g_HookList[i].callback == callback)
|
|
||||||
g_Interface.Unhook(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,16 @@ public:
|
|||||||
{
|
{
|
||||||
return (this->GetVTablePtr() == other->GetVTablePtr());
|
return (this->GetVTablePtr() == other->GetVTablePtr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator != (CVTableHook &other)
|
||||||
|
{
|
||||||
|
return (this->GetVTablePtr() != other.GetVTablePtr());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator != (CVTableHook *other)
|
||||||
|
{
|
||||||
|
return (this->GetVTablePtr() != other->GetVTablePtr());
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
void *vtableptr;
|
void *vtableptr;
|
||||||
int hookid;
|
int hookid;
|
||||||
|
Loading…
Reference in New Issue
Block a user