Add support for setting callback when hooking instead of on create only.

This commit is contained in:
Drifter
2018-01-27 10:08:44 -05:00
parent b14f62435c
commit cd55a5026e
5 changed files with 55 additions and 22 deletions
+4 -4
View File
@@ -54,7 +54,7 @@ public OnPluginStart()
hGetModelName = DHookCreate(offset, HookType_Entity, ReturnType_String, ThisPointer_CBaseEntity, GetModelName);
offset = GameConfGetOffset(temp, "GetMaxs");
hGetMaxs = DHookCreate(offset, HookType_Entity, ReturnType_Vector, ThisPointer_Ignore, GetMaxsPost);
hGetMaxs = DHookCreate(offset, HookType_Entity, ReturnType_Vector, ThisPointer_Ignore);
offset = GameConfGetOffset(temp, "CanUse");
hHookCanUse = DHookCreate(offset, HookType_Entity, ReturnType_Bool, ThisPointer_CBaseEntity, CanUsePost);
@@ -78,7 +78,7 @@ public OnPluginStart()
DHookAddParam(hAcceptInput, HookParamType_Int);
offset = GameConfGetOffset(temp, "GetMaxPlayerSpeed");
hGetSpeed = DHookCreate(offset, HookType_Entity, ReturnType_Float, ThisPointer_CBaseEntity, GetMaxPlayerSpeedPost);
hGetSpeed = DHookCreate(offset, HookType_Entity, ReturnType_Float, ThisPointer_CBaseEntity);
offset = GameConfGetOffset(temp, "GiveAmmo");
hGiveAmmo = DHookCreate(offset, HookType_Entity, ReturnType_Int, ThisPointer_CBaseEntity, GiveAmmo);
@@ -161,11 +161,11 @@ public OnClientPutInServer(client)
{
DHookEntity(hSetModel, false, client, RemovalCB);
DHookEntity(hHookCanUse, true, client, RemovalCB);
DHookEntity(hGetSpeed, true, client, RemovalCB);
DHookEntity(hGetSpeed, true, client, RemovalCB, GetMaxPlayerSpeedPost);
DHookEntity(hGiveAmmo, false, client);
DHookEntity(hGetModelName, true, client);
DHookEntity(hTakeDamage, false, client);
DHookEntity(hGetMaxs, true, client, RemovalCB);
DHookEntity(hGetMaxs, true, client, _ , GetMaxsPost);
DHookEntity(hBloodColor, true, client);
}
+4 -4
View File
@@ -174,7 +174,7 @@ native bool DHookRemoveEntityListener(ListenType type, ListenCB callback);
*
* @return Returns setup handle for the hook or INVALID_HANDLE.
*/
native Handle DHookCreate(int offset, HookType hooktype, ReturnType returntype, ThisPointerType thistype, DHookCallback callback);
native Handle DHookCreate(int offset, HookType hooktype, ReturnType returntype, ThisPointerType thistype, DHookCallback callback=INVALID_FUNCTION);
/* Adds param to a hook setup
*
@@ -199,7 +199,7 @@ native void DHookAddParam(Handle setup, HookParamType type, int size=-1, DHookPa
* @error Invalid setup handle, invalid entity or invalid hook type.
* @return -1 on fail a hookid on success
*/
native int DHookEntity(Handle setup, bool post, int entity, DHookRemovalCB removalcb=INVALID_FUNCTION);
native int DHookEntity(Handle setup, bool post, int entity, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION);
/* Hook gamerules
*
@@ -210,7 +210,7 @@ native int DHookEntity(Handle setup, bool post, int entity, DHookRemovalCB remov
* @error Invalid setup handle, failing to get gamerules pointer or invalid hook type.
* @return -1 on fail a hookid on success
*/
native int DHookGamerules(Handle setup, bool post, DHookRemovalCB removalcb=INVALID_FUNCTION);
native int DHookGamerules(Handle setup, bool post, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION);
/* Hook a raw pointer
*
@@ -222,7 +222,7 @@ native int DHookGamerules(Handle setup, bool post, DHookRemovalCB removalcb=INVA
* @error Invalid setup handle, invalid address or invalid hook type.
* @return -1 on fail a hookid on success
*/
native int DHookRaw(Handle setup, bool post, Address addr, DHookRemovalCB removalcb=INVALID_FUNCTION);
native int DHookRaw(Handle setup, bool post, Address addr, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION);
/* Remove hook by hook id
*