Merge pull request #107 from alliedmodders/sdkhackfix
Copy SDKHooks vector instead of taking a reference.
This commit is contained in:
commit
c4a1e3c819
@ -438,6 +438,21 @@ FeatureStatus SDKHooks::GetFeatureStatus(FeatureType type, const char *name)
|
|||||||
/**
|
/**
|
||||||
* Functions
|
* Functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static void PopulateCallbackList(const ke::Vector<HookList> &source, ke::Vector<IPluginFunction *> &destination, int entity)
|
||||||
|
{
|
||||||
|
destination.ensure(8); /* Skip trivial allocations as AMTL uses length<<1. */
|
||||||
|
for (size_t iter = 0; iter < source.length(); ++iter)
|
||||||
|
{
|
||||||
|
if (source[iter].entity != entity)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
destination.append(source[iter].callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cell_t SDKHooks::Call(int entity, SDKHookType type, int other)
|
cell_t SDKHooks::Call(int entity, SDKHookType type, int other)
|
||||||
{
|
{
|
||||||
return Call(gamehelpers->ReferenceToEntity(entity), type, gamehelpers->ReferenceToEntity(other));
|
return Call(gamehelpers->ReferenceToEntity(entity), type, gamehelpers->ReferenceToEntity(other));
|
||||||
@ -461,17 +476,14 @@ cell_t SDKHooks::Call(CBaseEntity *pEnt, SDKHookType type, CBaseEntity *pOther)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ke::Vector<HookList> &pawnlist = vtablehooklist[entry]->hooks;
|
|
||||||
int entity = gamehelpers->EntityToBCompatRef(pEnt);
|
int entity = gamehelpers->EntityToBCompatRef(pEnt);
|
||||||
int other = gamehelpers->EntityToBCompatRef(pOther);
|
int other = gamehelpers->EntityToBCompatRef(pOther);
|
||||||
for (entry = 0; entry < pawnlist.length(); ++entry)
|
|
||||||
{
|
|
||||||
if (entity != pawnlist[entry].entity)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPluginFunction *callback = pawnlist[entry].callback;
|
ke::Vector<IPluginFunction *> callbackList;
|
||||||
|
PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity);
|
||||||
|
for (entry = 0; entry < callbackList.length(); ++entry)
|
||||||
|
{
|
||||||
|
IPluginFunction *callback = callbackList[entry];
|
||||||
callback->PushCell(entity);
|
callback->PushCell(entity);
|
||||||
callback->PushCell(other);
|
callback->PushCell(other);
|
||||||
|
|
||||||
@ -914,15 +926,11 @@ void SDKHooks::Hook_FireBulletsPost(const FireBulletsInfo_t &info)
|
|||||||
|
|
||||||
const char *weapon = pInfo->GetWeaponName();
|
const char *weapon = pInfo->GetWeaponName();
|
||||||
|
|
||||||
ke::Vector<HookList> &pawnlist = vtablehooklist[entry]->hooks;
|
ke::Vector<IPluginFunction *> callbackList;
|
||||||
for (entry = 0; entry < pawnlist.length(); ++entry)
|
PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity);
|
||||||
|
for (entry = 0; entry < callbackList.length(); ++entry)
|
||||||
{
|
{
|
||||||
if (entity != pawnlist[entry].entity)
|
IPluginFunction *callback = callbackList[entry];
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPluginFunction *callback = pawnlist[entry].callback;
|
|
||||||
callback->PushCell(entity);
|
callback->PushCell(entity);
|
||||||
callback->PushCell(info.m_iShots);
|
callback->PushCell(info.m_iShots);
|
||||||
callback->PushString(weapon?weapon:"");
|
callback->PushString(weapon?weapon:"");
|
||||||
@ -956,15 +964,11 @@ int SDKHooks::Hook_GetMaxHealth()
|
|||||||
|
|
||||||
cell_t res = Pl_Continue;
|
cell_t res = Pl_Continue;
|
||||||
|
|
||||||
ke::Vector<HookList> &pawnlist = vtablehooklist[entry]->hooks;
|
ke::Vector<IPluginFunction *> callbackList;
|
||||||
for (entry = 0; entry < pawnlist.length(); ++entry)
|
PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity);
|
||||||
|
for (entry = 0; entry < callbackList.length(); ++entry)
|
||||||
{
|
{
|
||||||
if (entity != pawnlist[entry].entity)
|
IPluginFunction *callback = callbackList[entry];
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPluginFunction *callback = pawnlist[entry].callback;
|
|
||||||
callback->PushCell(entity);
|
callback->PushCell(entity);
|
||||||
callback->PushCellByRef(&new_max);
|
callback->PushCellByRef(&new_max);
|
||||||
callback->Execute(&res);
|
callback->Execute(&res);
|
||||||
@ -1013,15 +1017,11 @@ int SDKHooks::Hook_OnTakeDamage(CTakeDamageInfoHack &info)
|
|||||||
|
|
||||||
cell_t res, ret = Pl_Continue;
|
cell_t res, ret = Pl_Continue;
|
||||||
|
|
||||||
ke::Vector<HookList> &pawnlist = vtablehooklist[entry]->hooks;
|
ke::Vector<IPluginFunction *> callbackList;
|
||||||
for (entry = 0; entry < pawnlist.length(); ++entry)
|
PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity);
|
||||||
|
for (entry = 0; entry < callbackList.length(); ++entry)
|
||||||
{
|
{
|
||||||
if (entity != pawnlist[entry].entity)
|
IPluginFunction *callback = callbackList[entry];
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPluginFunction *callback = pawnlist[entry].callback;
|
|
||||||
callback->PushCell(entity);
|
callback->PushCell(entity);
|
||||||
callback->PushCellByRef(&attacker);
|
callback->PushCellByRef(&attacker);
|
||||||
callback->PushCellByRef(&inflictor);
|
callback->PushCellByRef(&inflictor);
|
||||||
@ -1095,15 +1095,11 @@ int SDKHooks::Hook_OnTakeDamagePost(CTakeDamageInfoHack &info)
|
|||||||
|
|
||||||
int entity = gamehelpers->EntityToBCompatRef(pEntity);
|
int entity = gamehelpers->EntityToBCompatRef(pEntity);
|
||||||
|
|
||||||
ke::Vector<HookList> &pawnlist = vtablehooklist[entry]->hooks;
|
ke::Vector<IPluginFunction *> callbackList;
|
||||||
for (entry = 0; entry < pawnlist.length(); ++entry)
|
PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity);
|
||||||
|
for (entry = 0; entry < callbackList.length(); ++entry)
|
||||||
{
|
{
|
||||||
if (entity != pawnlist[entry].entity)
|
IPluginFunction *callback = callbackList[entry];
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPluginFunction *callback = pawnlist[entry].callback;
|
|
||||||
callback->PushCell(entity);
|
callback->PushCell(entity);
|
||||||
callback->PushCell(info.GetAttacker());
|
callback->PushCell(info.GetAttacker());
|
||||||
callback->PushCell(info.GetInflictor());
|
callback->PushCell(info.GetInflictor());
|
||||||
@ -1168,15 +1164,11 @@ bool SDKHooks::Hook_Reload()
|
|||||||
int entity = gamehelpers->EntityToBCompatRef(pEntity);
|
int entity = gamehelpers->EntityToBCompatRef(pEntity);
|
||||||
cell_t res = Pl_Continue;
|
cell_t res = Pl_Continue;
|
||||||
|
|
||||||
ke::Vector<HookList> &pawnlist = vtablehooklist[entry]->hooks;
|
ke::Vector<IPluginFunction *> callbackList;
|
||||||
for (entry = 0; entry < pawnlist.length(); ++entry)
|
PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity);
|
||||||
|
for (entry = 0; entry < callbackList.length(); ++entry)
|
||||||
{
|
{
|
||||||
if (entity != pawnlist[entry].entity)
|
IPluginFunction *callback = callbackList[entry];
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPluginFunction *callback = pawnlist[entry].callback;
|
|
||||||
callback->PushCell(entity);
|
callback->PushCell(entity);
|
||||||
callback->Execute(&res);
|
callback->Execute(&res);
|
||||||
}
|
}
|
||||||
@ -1206,15 +1198,11 @@ bool SDKHooks::Hook_ReloadPost()
|
|||||||
int entity = gamehelpers->EntityToBCompatRef(pEntity);
|
int entity = gamehelpers->EntityToBCompatRef(pEntity);
|
||||||
cell_t origreturn = META_RESULT_ORIG_RET(bool) ? 1 : 0;
|
cell_t origreturn = META_RESULT_ORIG_RET(bool) ? 1 : 0;
|
||||||
|
|
||||||
ke::Vector<HookList> &pawnlist = vtablehooklist[entry]->hooks;
|
ke::Vector<IPluginFunction *> callbackList;
|
||||||
for (entry = 0; entry < pawnlist.length(); ++entry)
|
PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity);
|
||||||
|
for (entry = 0; entry < callbackList.length(); ++entry)
|
||||||
{
|
{
|
||||||
if (entity != pawnlist[entry].entity)
|
IPluginFunction *callback = callbackList[entry];
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPluginFunction *callback = pawnlist[entry].callback;
|
|
||||||
callback->PushCell(entity);
|
callback->PushCell(entity);
|
||||||
callback->PushCell(origreturn);
|
callback->PushCell(origreturn);
|
||||||
callback->Execute(NULL);
|
callback->Execute(NULL);
|
||||||
@ -1253,15 +1241,11 @@ bool SDKHooks::Hook_ShouldCollide(int collisionGroup, int contentsMask)
|
|||||||
cell_t origRet = ((META_RESULT_STATUS >= MRES_OVERRIDE)?(META_RESULT_OVERRIDE_RET(bool)):(META_RESULT_ORIG_RET(bool))) ? 1 : 0;
|
cell_t origRet = ((META_RESULT_STATUS >= MRES_OVERRIDE)?(META_RESULT_OVERRIDE_RET(bool)):(META_RESULT_ORIG_RET(bool))) ? 1 : 0;
|
||||||
cell_t res = 0;
|
cell_t res = 0;
|
||||||
|
|
||||||
ke::Vector<HookList> &pawnlist = vtablehooklist[entry]->hooks;
|
ke::Vector<IPluginFunction *> callbackList;
|
||||||
for (entry = 0; entry < pawnlist.length(); ++entry)
|
PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity);
|
||||||
|
for (entry = 0; entry < callbackList.length(); ++entry)
|
||||||
{
|
{
|
||||||
if (entity != pawnlist[entry].entity)
|
IPluginFunction *callback = callbackList[entry];
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPluginFunction *callback = pawnlist[entry].callback;
|
|
||||||
callback->PushCell(entity);
|
callback->PushCell(entity);
|
||||||
callback->PushCell(collisionGroup);
|
callback->PushCell(collisionGroup);
|
||||||
callback->PushCell(contentsMask);
|
callback->PushCell(contentsMask);
|
||||||
@ -1301,15 +1285,11 @@ void SDKHooks::Hook_Spawn()
|
|||||||
int entity = gamehelpers->EntityToBCompatRef(pEntity);
|
int entity = gamehelpers->EntityToBCompatRef(pEntity);
|
||||||
cell_t res = Pl_Continue;
|
cell_t res = Pl_Continue;
|
||||||
|
|
||||||
ke::Vector<HookList> &pawnlist = vtablehooklist[entry]->hooks;
|
ke::Vector<IPluginFunction *> callbackList;
|
||||||
for (entry = 0; entry < pawnlist.length(); ++entry)
|
PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity);
|
||||||
|
for (entry = 0; entry < callbackList.length(); ++entry)
|
||||||
{
|
{
|
||||||
if (entity != pawnlist[entry].entity)
|
IPluginFunction *callback = callbackList[entry];
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPluginFunction *callback = pawnlist[entry].callback;
|
|
||||||
callback->PushCell(entity);
|
callback->PushCell(entity);
|
||||||
callback->Execute(&res);
|
callback->Execute(&res);
|
||||||
}
|
}
|
||||||
@ -1399,15 +1379,11 @@ void SDKHooks::Hook_TraceAttack(CTakeDamageInfoHack &info, const Vector &vecDir,
|
|||||||
int ammotype = info.GetAmmoType();
|
int ammotype = info.GetAmmoType();
|
||||||
cell_t res, ret = Pl_Continue;
|
cell_t res, ret = Pl_Continue;
|
||||||
|
|
||||||
ke::Vector<HookList> &pawnlist = vtablehooklist[entry]->hooks;
|
ke::Vector<IPluginFunction *> callbackList;
|
||||||
for (entry = 0; entry < pawnlist.length(); ++entry)
|
PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity);
|
||||||
|
for (entry = 0; entry < callbackList.length(); ++entry)
|
||||||
{
|
{
|
||||||
if (entity != pawnlist[entry].entity)
|
IPluginFunction *callback = callbackList[entry];
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPluginFunction *callback = pawnlist[entry].callback;
|
|
||||||
callback->PushCell(entity);
|
callback->PushCell(entity);
|
||||||
callback->PushCellByRef(&attacker);
|
callback->PushCellByRef(&attacker);
|
||||||
callback->PushCellByRef(&inflictor);
|
callback->PushCellByRef(&inflictor);
|
||||||
@ -1477,15 +1453,11 @@ void SDKHooks::Hook_TraceAttackPost(CTakeDamageInfoHack &info, const Vector &vec
|
|||||||
|
|
||||||
int entity = gamehelpers->EntityToBCompatRef(pEntity);
|
int entity = gamehelpers->EntityToBCompatRef(pEntity);
|
||||||
|
|
||||||
ke::Vector<HookList> &pawnlist = vtablehooklist[entry]->hooks;
|
ke::Vector<IPluginFunction *> callbackList;
|
||||||
for (entry = 0; entry < pawnlist.length(); ++entry)
|
PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity);
|
||||||
|
for (entry = 0; entry < callbackList.length(); ++entry)
|
||||||
{
|
{
|
||||||
if (entity != pawnlist[entry].entity)
|
IPluginFunction *callback = callbackList[entry];
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPluginFunction *callback = pawnlist[entry].callback;
|
|
||||||
callback->PushCell(entity);
|
callback->PushCell(entity);
|
||||||
callback->PushCell(info.GetAttacker());
|
callback->PushCell(info.GetAttacker());
|
||||||
callback->PushCell(info.GetInflictor());
|
callback->PushCell(info.GetInflictor());
|
||||||
@ -1521,15 +1493,11 @@ void SDKHooks::Hook_Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE
|
|||||||
int caller = gamehelpers->EntityToBCompatRef(pCaller);
|
int caller = gamehelpers->EntityToBCompatRef(pCaller);
|
||||||
cell_t ret = Pl_Continue;
|
cell_t ret = Pl_Continue;
|
||||||
|
|
||||||
ke::Vector<HookList> &pawnlist = vtablehooklist[entry]->hooks;
|
ke::Vector<IPluginFunction *> callbackList;
|
||||||
for (entry = 0; entry < pawnlist.length(); ++entry)
|
PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity);
|
||||||
|
for (entry = 0; entry < callbackList.length(); ++entry)
|
||||||
{
|
{
|
||||||
if (entity != pawnlist[entry].entity)
|
IPluginFunction *callback = callbackList[entry];
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPluginFunction *callback = pawnlist[entry].callback;
|
|
||||||
callback->PushCell(entity);
|
callback->PushCell(entity);
|
||||||
callback->PushCell(activator);
|
callback->PushCell(activator);
|
||||||
callback->PushCell(caller);
|
callback->PushCell(caller);
|
||||||
@ -1564,15 +1532,11 @@ void SDKHooks::Hook_UsePost(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T
|
|||||||
int activator = gamehelpers->EntityToBCompatRef(pActivator);
|
int activator = gamehelpers->EntityToBCompatRef(pActivator);
|
||||||
int caller = gamehelpers->EntityToBCompatRef(pCaller);
|
int caller = gamehelpers->EntityToBCompatRef(pCaller);
|
||||||
|
|
||||||
ke::Vector<HookList> &pawnlist = vtablehooklist[entry]->hooks;
|
ke::Vector<IPluginFunction *> callbackList;
|
||||||
for (entry = 0; entry < pawnlist.length(); ++entry)
|
PopulateCallbackList(vtablehooklist[entry]->hooks, callbackList, entity);
|
||||||
|
for (entry = 0; entry < callbackList.length(); ++entry)
|
||||||
{
|
{
|
||||||
if (entity != pawnlist[entry].entity)
|
IPluginFunction *callback = callbackList[entry];
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
IPluginFunction *callback = pawnlist[entry].callback;
|
|
||||||
callback->PushCell(entity);
|
callback->PushCell(entity);
|
||||||
callback->PushCell(activator);
|
callback->PushCell(activator);
|
||||||
callback->PushCell(caller);
|
callback->PushCell(caller);
|
||||||
|
Loading…
Reference in New Issue
Block a user