From 0c56e2803ed32a1ca17567074aa021aa27cf8c0f Mon Sep 17 00:00:00 2001 From: Steve Dudenhoeffer Date: Thu, 10 May 2007 16:08:02 +0000 Subject: [PATCH] Added more virtual functions to the table, only have counter-strike disassembled currently. --- dlls/hamsandwich/DataHandler.cpp | 4 +- dlls/hamsandwich/DataHandler.h | 3 +- dlls/hamsandwich/amxx_api.cpp | 7 + dlls/hamsandwich/call_funcs.cpp | 36 +++- dlls/hamsandwich/call_funcs.h | 5 +- dlls/hamsandwich/config/hamdata.ini | 118 ++++++++++++- dlls/hamsandwich/config_parser.cpp | 6 +- dlls/hamsandwich/ham_const.h | 46 +++++ dlls/hamsandwich/hook_callbacks.cpp | 53 +++++- dlls/hamsandwich/hook_callbacks.h | 62 ++++++- dlls/hamsandwich/hook_create.cpp | 11 +- dlls/hamsandwich/hook_create.h | 5 +- dlls/hamsandwich/hook_native.cpp | 206 ++++++++++++++--------- dlls/hamsandwich/include/hamsandwich.inc | 62 ++++++- 14 files changed, 530 insertions(+), 94 deletions(-) diff --git a/dlls/hamsandwich/DataHandler.cpp b/dlls/hamsandwich/DataHandler.cpp index 87b12c24..fc11a4c7 100644 --- a/dlls/hamsandwich/DataHandler.cpp +++ b/dlls/hamsandwich/DataHandler.cpp @@ -40,8 +40,8 @@ static const char *returntypes[] = "string", "entity", "entity", - "traceresult" - "" + "traceresult", + "iteminfo" }; static cell AMX_NATIVE_CALL GetHamReturnInteger(AMX *amx, cell *params) diff --git a/dlls/hamsandwich/DataHandler.h b/dlls/hamsandwich/DataHandler.h index 5f142778..be1ae95f 100644 --- a/dlls/hamsandwich/DataHandler.h +++ b/dlls/hamsandwich/DataHandler.h @@ -15,7 +15,8 @@ enum RET_STRING, RET_CBASE, RET_ENTVAR, - RET_TRACE + RET_TRACE, + RET_ITEMINFO }; // Container for return and parameter data. // Contains a void pointer, and a flag telling what it contains. diff --git a/dlls/hamsandwich/amxx_api.cpp b/dlls/hamsandwich/amxx_api.cpp index 2188c647..748c6b43 100644 --- a/dlls/hamsandwich/amxx_api.cpp +++ b/dlls/hamsandwich/amxx_api.cpp @@ -6,6 +6,8 @@ #include "forward.h" #include "hook.h" #include "ham_const.h" +#include "hooklist.h" +#include edict_t *NEW_FirstEdict; bool NEW_Initialized; @@ -15,10 +17,15 @@ extern CVector hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL]; extern AMX_NATIVE_INFO RegisterNatives[]; extern AMX_NATIVE_INFO ReturnNatives[]; +extern hook_t hooklist[]; + int ReadConfig(void); void OnAmxxAttach(void) { + // Assert that the enum is aligned properly with the table + assert(strcmp(hooklist[Ham_NS_UpdateOnRemove].name, "ns_updateonremove")==0); + if (ReadConfig() > 0) { MF_AddNatives(RegisterNatives); diff --git a/dlls/hamsandwich/call_funcs.cpp b/dlls/hamsandwich/call_funcs.cpp index dfc83f34..a24b4833 100644 --- a/dlls/hamsandwich/call_funcs.cpp +++ b/dlls/hamsandwich/call_funcs.cpp @@ -350,7 +350,7 @@ cell Call_Void_Entvar_Float_Vector_Trace_Int(AMX *amx, cell *params) return 1; } -cell Call_Void_Float_Vector_TraceResult_Int(AMX *amx, cell *params) +cell Call_Void_Float_Vector_Trace_Int(AMX *amx, cell *params) { SETUP(4); @@ -524,3 +524,37 @@ cell Call_Void_Entvar_Float(AMX *amx, cell *params) #endif } +cell Call_Void_Int_Int_Int(AMX *amx, cell *params) +{ + SETUP(2); + + int i3=*MF_GetAmxAddr(amx, params[3]); + int i4=*MF_GetAmxAddr(amx, params[4]); + int i5=*MF_GetAmxAddr(amx, params[5]); + +#ifdef _WIN32 + reinterpret_cast(__func)(pv, 0, i3, i4, i5); +#elif defined __linux__ + reinterpret_cast(__func)(pv, i3, i4, i5); +#endif + return 1; +} + +cell Call_Void_ItemInfo(AMX *amx, cell *params) +{ + SETUP(1); + + void *ptr=reinterpret_cast(*MF_GetAmxAddr(amx, params[3])); + + if (ptr==0) + { + MF_LogError(amx, AMX_ERR_NATIVE, "Null ItemInfo handle!"); + return 0; + } +#ifdef _WIN32 + reinterpret_cast(__func)(pv, 0, ptr); +#elif defined __linux__ + reinterpret_cast(__func)(pv, ptr); +#endif + return 1; +} diff --git a/dlls/hamsandwich/call_funcs.h b/dlls/hamsandwich/call_funcs.h index ca9a503d..f5f5fef4 100644 --- a/dlls/hamsandwich/call_funcs.h +++ b/dlls/hamsandwich/call_funcs.h @@ -32,7 +32,7 @@ cell Call_Void_Cbase_Cbase_Int_Float(AMX *amx, cell *params); cell Call_Void_Entvar_Float_Vector_Trace_Int(AMX *amx, cell *params); -cell Call_Void_Float_Vector_TraceResult_Int(AMX *amx, cell *params); +cell Call_Void_Float_Vector_Trace_Int(AMX *amx, cell *params); cell Call_Str_Void(AMX *amx, cell *params); @@ -50,5 +50,8 @@ cell Call_Int_pFloat_pFloat(AMX *amx, cell *params); cell Call_Void_Entvar_Float(AMX *amx, cell *params); +cell Call_Void_Int_Int_Int(AMX *amx, cell *params); + +cell Call_Void_ItemInfo(AMX *amx, cell *params); #endif diff --git a/dlls/hamsandwich/config/hamdata.ini b/dlls/hamsandwich/config/hamdata.ini index df7f0b0b..94d76db4 100644 --- a/dlls/hamsandwich/config/hamdata.ini +++ b/dlls/hamsandwich/config/hamdata.ini @@ -51,7 +51,6 @@ spawn 2 precache 3 - cstrike_restart 4 keyvalue 5 objectcaps 8 activate 9 @@ -65,6 +64,8 @@ bloodcolor 17 tracebleed 18 istriggered 19 + mymonsterpointer 20 + mysquadmonsterpointer 21 gettogglestate 22 addpoints 23 addpointstoteam 24 @@ -103,6 +104,54 @@ illumination 57 fvisible 58 fvecvisible 59 + + player_jump 78 + player_duck 79 + player_prethink 80 + player_postthink 81 + player_getgunposition 82 + player_shouldfadeondeath 68 + player_impulsecommands 84 + player_updateclientdata 83 + + item_addtoplayer 61 + item_addduplicate 62 + item_getiteminfo 63 + item_candeploy 64 + item_candrop 65 + item_deploy 66 + item_canholster 68 + item_holster 69 + item_updateiteminfo 70 + item_preframe 71 + item_postframe 72 + item_drop 73 + item_kill 74 + item_attachtoplayer 75 + item_primaryammoindex 76 + item_secondaryammoindex 77 + item_updateclientdata 78 + item_getweaponptr 79 + item_itemslot 80 + + weapon_extractammo 81 + weapon_extractclipammo 82 + weapon_addweapon 83 + weapon_playemptysound 84 + weapon_resetemptysound 85 + weapon_sendweaponanim 86 + weapon_isusable 87 + weapon_primaryattack 88 + weapon_secondaryattack 89 + weapon_reload 90 + weapon_weaponidle 91 + weapon_retireweapon 92 + weapon_shouldweaponidle 93 + weapon_usedecrement 94 + + cstrike_restart 4 + cstrike_roundrespawn 86 + @end @section cstrike windows pev 4 @@ -110,7 +159,6 @@ spawn 0 precache 1 - cstrike_restart 2 keyvalue 3 objectcaps 6 activate 7 @@ -124,6 +172,8 @@ bloodcolor 15 tracebleed 16 istriggered 17 + mymonsterpointer 18 + mysquadmonsterpointer 19 gettogglestate 20 addpoints 21 addpointstoteam 22 @@ -162,6 +212,54 @@ illumination 55 fvisible 56 fvecvisible 57 + + player_jump 76 + player_duck 77 + player_prethink 78 + player_postthink 79 + player_getgunposition 80 + player_shouldfadeondeath 66 + player_impulsecommands 82 + player_updateclientdata 81 + + item_addtoplayer 59 + item_addduplicate 60 + item_getiteminfo 61 + item_candeploy 62 + item_candrop 63 + item_deploy 64 + item_canholster 66 + item_holster 67 + item_updateiteminfo 68 + item_preframe 69 + item_postframe 70 + item_drop 71 + item_kill 72 + item_attachtoplayer 73 + item_primaryammoindex 74 + item_secondaryammoindex 75 + item_updateclientdata 76 + item_getweaponptr 77 + item_itemslot 78 + + weapon_extractammo 79 + weapon_extractclipammo 80 + weapon_addweapon 81 + weapon_playemptysound 82 + weapon_resetemptysound 83 + weapon_sendweaponanim 84 + weapon_isusable 85 + weapon_primaryattack 86 + weapon_secondaryattack 87 + weapon_reload 88 + weapon_weaponidle 89 + weapon_retireweapon 90 + weapon_shouldweaponidle 91 + weapon_usedecrement 92 + + cstrike_restart 2 + cstrike_roundrespawn 84 + @end @section dod linux pev 0 @@ -188,6 +286,8 @@ killed 22 bloodcolor 23 tracebleed 24 + mymonsterpointer 25 + mysquadmonsterpointer 26 gettogglestate 27 addpoints 28 addpointstoteam 29 @@ -252,6 +352,8 @@ killed 20 bloodcolor 21 tracebleed 22 + mymonsterpointer 23 + mysquadmonsterpointer 24 gettogglestate 25 addpoints 26 addpointstoteam 27 @@ -313,6 +415,8 @@ bloodcolor 17 tracebleed 18 istriggered 19 + mymonsterpointer 20 + mysquadmonsterpointer 21 gettogglestate 22 addplayeritem 23 removeplayeritem 24 @@ -377,6 +481,8 @@ bloodcolor 15 tracebleed 16 istriggered 17 + mymonsterpointer 18 + mysquadmonsterpointer 19 gettogglestate 20 addplayeritem 21 removeplayeritem 22 @@ -444,6 +550,8 @@ bloodcolor 17 tracebleed 18 istriggered 19 + mymonsterpointer 20 + mysquadmonsterpointer 21 gettogglestate 22 addpoints 23 addpointstoteam 24 @@ -506,6 +614,8 @@ bloodcolor 16 tracebleed 17 istriggered 18 + mymonsterpointer 19 + mysquadmonsterpointer 20 gettogglestate 21 addpoints 22 addpointstoteam 23 @@ -570,6 +680,8 @@ bloodcolor 19 tracebleed 20 istriggered 21 + mymonsterpointer 22 + mysquadmonsterpointer 23 gettogglestate 24 addpoints 25 addpointstoteam 26 @@ -631,6 +743,8 @@ bloodcolor 17 tracebleed 18 istriggered 19 + mymonsterpointer 20 + mysquadmonsterpointer 21 gettogglestate 22 addpoints 23 addpointstoteam 24 diff --git a/dlls/hamsandwich/config_parser.cpp b/dlls/hamsandwich/config_parser.cpp index 589341ed..cd6a0d4c 100644 --- a/dlls/hamsandwich/config_parser.cpp +++ b/dlls/hamsandwich/config_parser.cpp @@ -132,7 +132,9 @@ static void trim_line(char *input) char *start=input; while ( *start==' ' || - *start=='\t') + *start=='\t' || + *start=='\r' || + *start=='\n') { start++; } @@ -149,7 +151,7 @@ static void trim_line(char *input) start+=strlen(start) - 1; - while ( start > oldinput && + while ( start >= oldinput && ( *start == '\0' || *start == ' ' || *start == '\r' || diff --git a/dlls/hamsandwich/ham_const.h b/dlls/hamsandwich/ham_const.h index 5cb737b0..24433149 100644 --- a/dlls/hamsandwich/ham_const.h +++ b/dlls/hamsandwich/ham_const.h @@ -28,6 +28,8 @@ enum Ham_BloodColor, Ham_TraceBleed, Ham_IsTriggered, + Ham_MyMonsterPointer, + Ham_MySquadMonsterPointer, Ham_GetToggleState, Ham_AddPoints, Ham_AddPointsToTeam, @@ -67,11 +69,55 @@ enum Ham_FVisible, Ham_FVecVisible, + Ham_Player_Jump, + Ham_Player_Duck, + Ham_Player_PreThink, + Ham_Player_PostThink, + Ham_Player_GetGunPosition, + Ham_Player_ShouldFadeOnDeath, + Ham_Player_ImpulseCommands, + Ham_Player_UpdateClientData, + + Ham_Item_AddToPlayer, + Ham_Item_AddDuplicate, + Ham_Item_GetItemInfo, + Ham_Item_CanDeploy, + Ham_Item_Deploy, + Ham_Item_CanHolster, + Ham_Item_Holster, + Ham_Item_UpdateItemInfo, + Ham_Item_PreFrame, + Ham_Item_PostFrame, + Ham_Item_Drop, + Ham_Item_Kill, + Ham_Item_AttachToPlayer, + Ham_Item_PrimaryAmmoIndex, + Ham_Item_SecondaryAmmoIndex, + Ham_Item_UpdateClientData, + Ham_Item_GetWeaponPtr, + Ham_Item_ItemSlot, + + Ham_Weapon_ExtractAmmo, + Ham_Weapon_ExtractClipAmmo, + Ham_Weapon_AddWeapon, + Ham_Weapon_PlayEmptySound, + Ham_Weapon_ResetEmptySound, + Ham_Weapon_SendWeaponAnim, + Ham_Weapon_IsUsable, + Ham_Weapon_PrimaryAttack, + Ham_Weapon_SecondaryAttack, + Ham_Weapon_Reload, + Ham_Weapon_WeaponIdle, + Ham_Weapon_RetireWeapon, + Ham_Weapon_ShouldWeaponIdle, + Ham_Weapon_UseDecrement, + Ham_TS_BreakableRespawn, Ham_TS_CanUsedThroughWalls, Ham_TS_RespawnWait, Ham_CS_Restart, + Ham_CS_RoundRespawn, Ham_DOD_RoundRespawn, Ham_DOD_RoundRespawnEnt, diff --git a/dlls/hamsandwich/hook_callbacks.cpp b/dlls/hamsandwich/hook_callbacks.cpp index 659cfd76..68d42433 100644 --- a/dlls/hamsandwich/hook_callbacks.cpp +++ b/dlls/hamsandwich/hook_callbacks.cpp @@ -51,6 +51,7 @@ extern bool gDoForwards; #define P_TRACE(__PARAM) __vec->push_back(new Data(RET_TRACE, (void *) (__PARAM))); #define P_PTRVECTOR(__PARAM) __vec->push_back(new Data(RET_VECTOR, (void *) (__PARAM))); #define P_PTRFLOAT(__PARAM) __vec->push_back(new Data(RET_FLOAT, (void *) (__PARAM))); +#define P_ITEMINFO(__PARAM) __vec->push_back(new Data(RET_ITEMINFO, (void *) & (__PARAM))); #define KILL_VECTOR() \ CVector::iterator end=__vec->end(); \ @@ -570,7 +571,7 @@ void Hook_Void_Entvar_Float_Vector_Trace_Int(Hook *hook, void *pthis, entvars_t POP() } -void Hook_Void_Float_Vector_TraceResult_Int(Hook *hook, void *pthis, float f1, Vector v1, TraceResult *tr1, int i1) +void Hook_Void_Float_Vector_Trace_Int(Hook *hook, void *pthis, float f1, Vector v1, TraceResult *tr1, int i1) { PUSH_VOID() @@ -833,3 +834,53 @@ void Hook_Void_Entvar_Float(Hook *hook, void *pthis, entvars_t *ev1, float f1) POP() } +void Hook_Void_Int_Int_Int(Hook *hook, void *pthis, int i1, int i2, int i3) +{ + PUSH_VOID() + + MAKE_VECTOR() + + P_INT(i1) + P_INT(i2) + P_INT(i3) + + PRE_START() + ,i1, i2, i3 + PRE_END() +#if defined _WIN32 + reinterpret_cast(hook->func)(pthis, 0, i1, i2, i3); +#elif defined __linux__ + reinterpret_cast(hook->func)(pthis, i1, i2, i3); +#endif + + POST_START() + ,i1, i2, i3 + POST_END() + + KILL_VECTOR() + POP() +} +void Hook_Void_ItemInfo(Hook *hook, void *pthis, void *iteminfo) +{ + PUSH_VOID() + + MAKE_VECTOR() + + P_ITEMINFO(iteminfo) + + PRE_START() + ,iteminfo + PRE_END() +#if defined _WIN32 + reinterpret_cast(hook->func)(pthis, 0, iteminfo); +#elif defined __linux__ + reinterpret_cast(hook->func)(pthis, iteminfo); +#endif + + POST_START() + ,iteminfo + POST_END() + + KILL_VECTOR() + POP() +} diff --git a/dlls/hamsandwich/hook_callbacks.h b/dlls/hamsandwich/hook_callbacks.h index bab95b4d..8b02a51e 100644 --- a/dlls/hamsandwich/hook_callbacks.h +++ b/dlls/hamsandwich/hook_callbacks.h @@ -2,66 +2,126 @@ #ifndef HOOK_CALLBACKS_H #define HOOK_CALLBACKS_H +// RT_ is true if the function returns void, false otherwise +// (it also would be true for large return functions such as Vector) +// PC_ is how many dwords get passed to the function (minus the "this" pointer) +// (it is one larger for large return functions such as Vector) +const bool RT_Void_Void = true; +const int PC_Void_Void = 0; void Hook_Void_Void(Hook *hook, void *pthis); +const bool RT_Int_Void = false; +const int PC_Int_Void = 0; int Hook_Int_Void(Hook *hook, void *pthis); +const bool RT_Void_Entvar = true; +const int PC_Void_Entvar = 1; void Hook_Void_Entvar(Hook *hook, void *pthis, entvars_t *entvar); +const bool RT_Void_Cbase = true; +const int PC_Void_Cbase = 1; void Hook_Void_Cbase(Hook *hook, void *pthis, void *other); +const bool RT_Int_Float_Int = false; +const int PC_Int_Float_Int = 2; int Hook_Int_Float_Int(Hook *hook, void *pthis, float f1, int i1); +const bool RT_Void_Entvar_Int = true; +const int PC_Void_Entvar_Int = 2; void Hook_Void_Entvar_Int(Hook *hook, void *ptis, entvars_t *ev1, int i1); +const bool RT_Int_Cbase = false; +const int PC_Int_Cbase = 1; int Hook_Int_Cbase(Hook *hook, void *pthis, void *cb1); +const bool RT_Void_Int_Int = true; +const int PC_Void_Int_Int = 2; void Hook_Void_Int_Int(Hook *hook, void *pthis, int i1, int i2); +const bool RT_Int_Int_Str_Int = false; +const int PC_Int_Int_Str_Int = 3; int Hook_Int_Int_Str_Int(Hook *hook, void *pthis, int i1, const char *sz1, int i2); +const bool RT_Int_Int = false; +const int PC_Int_Int = 1; int Hook_Int_Int(Hook *hook, void *pthis, int i1); +const bool RT_Int_Entvar = false; +const int PC_Int_Entvar = 1; int Hook_Int_Entvar(Hook *hook, void *pthis, entvars_t *ev1); +const bool RT_Int_Entvar_Entvar_Float_Int = false; +const int PC_Int_Entvar_Entvar_Float_Int = 4; int Hook_Int_Entvar_Entvar_Float_Int(Hook *hook, void *pthis, entvars_t *inflictor, entvars_t *attacker, float damage, int damagebits); +const bool RT_Void_Int = true; +const int PC_Void_Int = 1; void Hook_Void_Int(Hook *hook, void *pthis, int i1); +const bool RT_Void_Cbase_Cbase_Int_Float = true; +const int PC_Void_Cbase_Cbase_Int_Float = 4; void Hook_Void_Cbase_Cbase_Int_Float(Hook *hook, void *pthis, void *cb1, void *cb2, int i1, float f1); +const bool RT_Void_Entvar_Float_Vector_Trace_Int = true; +const int PC_Void_Entvar_Float_Vector_Trace_Int = 7; void Hook_Void_Entvar_Float_Vector_Trace_Int(Hook *hook, void *pthis, entvars_t *ev1, float f1, Vector v1, TraceResult *tr1, int i1); -void Hook_Void_Float_Vector_TraceResult_Int(Hook *hook, void *pthis, float f1, +const bool RT_Void_Float_Vector_Trace_Int = true; +const int PC_Void_Float_Vector_Trace_Int = 6; +void Hook_Void_Float_Vector_Trace_Int(Hook *hook, void *pthis, float f1, Vector v1, TraceResult *tr1, int i1); +const bool RT_Str_Void = false; +const int PC_Str_Void = 0; const char *Hook_Str_Void(Hook *hook, void *pthis); +const bool RT_Cbase_Void = false; +const int PC_Cbase_Void = 0; void *Hook_Cbase_Void(Hook *hook, void *pthis); +const bool RT_Vector_Void = true; +const int PC_Vector_Void = 1; void Hook_Vector_Void(Hook *hook, Vector *out, void *pthis); +const bool RT_Vector_pVector = true; +const int PC_Vector_pVector = 2; void Hook_Vector_pVector(Hook *hook, Vector *out, void *pthis, Vector *v1); +const bool RT_Int_pVector = false; +const int PC_Int_pVector = 1; int Hook_Int_pVector(Hook *hook, void *pthis, Vector *v1); +const bool RT_Void_Entvar_Float_Float = true; +const int PC_Void_Entvar_Float_Float = 3; void Hook_Void_Entvar_Float_Float(Hook *hook, void *pthis, entvars_t *ev1, float f1, float f2); +const bool RT_Int_pFloat_pFloat = false; +const int PC_Int_pFloat_pFloat = 2; int Hook_Int_pFloat_pFloat(Hook *hook, void *pthis, float *f1, float *f2); +const bool RT_Void_Entvar_Float = true; +const int PC_Void_Entvar_Float = 2; void Hook_Void_Entvar_Float(Hook *hook, void *pthis, entvars_t *ev1, float f1); +const bool RT_Void_Int_Int_Int = true; +const int PC_Void_Int_Int_Int = 3; +void Hook_Void_Int_Int_Int(Hook *hook, void *pthis, int i1, int i2, int i3); + +const bool RT_Void_ItemInfo = true; +const int PC_Void_ItemInfo = 1; +void Hook_Void_ItemInfo(Hook *hook, void *pthis, void *iteminfo); + #endif diff --git a/dlls/hamsandwich/hook_create.cpp b/dlls/hamsandwich/hook_create.cpp index e3a623ad..6ea3ceac 100644 --- a/dlls/hamsandwich/hook_create.cpp +++ b/dlls/hamsandwich/hook_create.cpp @@ -78,7 +78,7 @@ int Create_Void_Entvar_Float_Vector_Trace_Int(AMX *amx, const char *func) return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_FLOAT, FP_ARRAY, FP_CELL, FP_CELL, FP_DONE); } -int Create_Void_Float_Vector_TraceResult_Int(AMX *amx, const char *func) +int Create_Void_Float_Vector_Trace_Int(AMX *amx, const char *func) { return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_FLOAT, FP_ARRAY, FP_CELL, FP_CELL, FP_DONE); } @@ -122,4 +122,11 @@ int Create_Void_Entvar_Float(AMX *amx, const char *func) { return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_FLOAT, FP_DONE); } - +int Create_Void_Int_Int_Int(AMX *amx, const char *func) +{ + return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE); +} +int Create_Void_ItemInfo(AMX *amx, const char *func) +{ + return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL); +} diff --git a/dlls/hamsandwich/hook_create.h b/dlls/hamsandwich/hook_create.h index 26189700..286b3f56 100644 --- a/dlls/hamsandwich/hook_create.h +++ b/dlls/hamsandwich/hook_create.h @@ -32,7 +32,7 @@ int Create_Void_Cbase_Cbase_Int_Float(AMX *amx, const char *func); int Create_Void_Entvar_Float_Vector_Trace_Int(AMX *amx, const char *func); -int Create_Void_Float_Vector_TraceResult_Int(AMX *amx, const char *func); +int Create_Void_Float_Vector_Trace_Int(AMX *amx, const char *func); int Create_Str_Void(AMX *amx, const char *func); @@ -50,5 +50,8 @@ int Create_Int_pFloat_pFloat(AMX *amx, const char *func); int Create_Void_Entvar_Float(AMX *amx, const char *func); +int Create_Void_Int_Int_Int(AMX *amx, const char *func); + +int Create_Void_ItemInfo(AMX *amx, const char *func); #endif diff --git a/dlls/hamsandwich/hook_native.cpp b/dlls/hamsandwich/hook_native.cpp index bac6afd0..a5431c4d 100644 --- a/dlls/hamsandwich/hook_native.cpp +++ b/dlls/hamsandwich/hook_native.cpp @@ -25,103 +25,151 @@ bool gDoForwards=true; CVector hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL]; -#define V(__STUFF__) reinterpret_cast(Hook_##__STUFF__), Create_##__STUFF__, Call_##__STUFF__ +#define V(__KEYNAME, __STUFF__) 0, 0, __KEYNAME, RT_##__STUFF__, PC_##__STUFF__, reinterpret_cast(Hook_##__STUFF__), Create_##__STUFF__, Call_##__STUFF__ hook_t hooklist[] = { - { 0, 0, "spawn", true, 0, V(Void_Void) }, // Spawn - { 0, 0, "precache", true, 0, V(Void_Void) }, // Precache - { 0, 0, "keyvalue", true, 1, V(Void_Int) }, // Keyvalue - { 0, 0, "objectcaps", false, 0, V(Int_Void) }, // ObjectCaps - { 0, 0, "activate", true, 0, V(Void_Void) }, // Activate - { 0, 0, "setobjectcollisionbox", true, 0, V(Void_Void) }, // SetObjectCollisionBox - { 0, 0, "classify", false, 0, V(Int_Void) }, // Classify - { 0, 0, "deathnotice", true, 1, V(Void_Entvar) }, // DeathNotice - { 0, 0, "traceattack", true, 7, V(Void_Entvar_Float_Vector_Trace_Int) }, // TraceAttack - { 0, 0, "takedamage", false, 4, V(Int_Entvar_Entvar_Float_Int) }, // Takedamage - { 0, 0, "takehealth", false, 2, V(Int_Float_Int) }, // TakeHealth - { 0, 0, "killed", true, 2, V(Void_Entvar_Int) }, // Killed - { 0, 0, "bloodcolor", false, 0, V(Int_Void) }, // BloodColor - { 0, 0, "tracebleed", true, 6, V(Void_Float_Vector_TraceResult_Int) }, // TraceBleed - { 0, 0, "istriggered", false, 1, V(Int_Cbase) }, // IsTriggered - { 0, 0, "gettogglestate", false, 0, V(Int_Void) }, // GetToggleState - { 0, 0, "addpoints", true, 2, V(Void_Int_Int) }, // AddPoints - { 0, 0, "addpointstoteam", true, 2, V(Void_Int_Int) }, // AddPointsToTeam - { 0, 0, "addplayeritem", false, 1, V(Int_Cbase) }, // AddPlayerItem - { 0, 0, "removeplayeritem", false, 1, V(Int_Cbase) }, // RemovePlayerItem - { 0, 0, "giveammo", false, 3, V(Int_Int_Str_Int) }, // GiveAmmo - { 0, 0, "getdelay", false, 0, V(Int_Void) }, // GetDelay - { 0, 0, "ismoving", false, 0, V(Int_Void) }, // IsMoving - { 0, 0, "overridereset", true, 0, V(Void_Void) }, // OverrideReset - { 0, 0, "damagedecal", false, 1, V(Int_Int) }, // DamageDecal - { 0, 0, "settogglestate", true, 1, V(Void_Int) }, // SetToggleState - { 0, 0, "startsneaking", true, 0, V(Void_Void) }, // StartSneaking - { 0, 0, "stopsneaking", true, 0, V(Void_Void) }, // StopSneaking - { 0, 0, "oncontrols", false, 1, V(Int_Entvar) }, // OnControls - { 0, 0, "issneaking", false, 0, V(Int_Void) }, // IsSneaking - { 0, 0, "isalive", false, 0, V(Int_Void) }, // IsAlive - { 0, 0, "isbspmodel", false, 0, V(Int_Void) }, // IsBSPModel - { 0, 0, "reflectgauss", false, 0, V(Int_Void) }, // ReflectGauss - { 0, 0, "hastarget", false, 1, V(Int_Int) }, // HasTarget - { 0, 0, "isinworld", false, 0, V(Int_Void) }, // IsInWorld - { 0, 0, "isplayer", false, 0, V(Int_Void) }, // IsPlayer - { 0, 0, "isnetclient", false, 0, V(Int_Void) }, // IsNetClient - { 0, 0, "teamid", false, 0, V(Str_Void) }, // TeamID - { 0, 0, "getnexttarget", false, 0, V(Cbase_Void) }, // GetNextTarget - { 0, 0, "think", true, 0, V(Void_Void) }, // Think - { 0, 0, "touch", true, 1, V(Void_Cbase) }, // Touch - { 0, 0, "use", true, 4, V(Void_Cbase_Cbase_Int_Float) }, // Use - { 0, 0, "blocked", true, 1, V(Void_Cbase) }, // Blocked - { 0, 0, "respawn", false, 0, V(Cbase_Void) }, // Respawn TODO: Cbase this - { 0, 0, "updateowner", true, 0, V(Void_Void) }, // UpdateOwner - { 0, 0, "fbecomeprone", false, 0, V(Int_Void) }, // FBecomeProne + { V("spawn", Void_Void) }, + { V("precache", Void_Void) }, + { V("keyvalue", Void_Int) }, + { V("objectcaps", Int_Void) }, + { V("activate", Void_Void) }, + { V("setobjectcollisionbox", Void_Void) }, + { V("classify", Int_Void) }, + { V("deathnotice", Void_Entvar) }, + { V("traceattack", Void_Entvar_Float_Vector_Trace_Int) }, + { V("takedamage", Int_Entvar_Entvar_Float_Int) }, + { V("takehealth", Int_Float_Int) }, + { V("killed", Void_Entvar_Int) }, + { V("bloodcolor", Int_Void) }, + { V("tracebleed", Void_Float_Vector_Trace_Int) }, + { V("istriggered", Int_Cbase) }, + { V("mymonsterpointer", Cbase_Void) }, + { V("mysquadmonsterpointer", Cbase_Void) }, + { V("gettogglestate", Int_Void) }, + { V("addpoints", Void_Int_Int) }, + { V("addpointstoteam", Void_Int_Int) }, + { V("addplayeritem", Int_Cbase) }, + { V("removeplayeritem", Int_Cbase) }, + { V("giveammo", Int_Int_Str_Int) }, + { V("getdelay", Int_Void) }, + { V("ismoving", Int_Void) }, + { V("overridereset", Void_Void) }, + { V("damagedecal", Int_Int) }, + { V("settogglestate", Void_Int) }, + { V("startsneaking", Void_Void) }, + { V("stopsneaking", Void_Void) }, + { V("oncontrols", Int_Entvar) }, + { V("issneaking", Int_Void) }, + { V("isalive", Int_Void) }, + { V("isbspmodel", Int_Void) }, + { V("reflectgauss", Int_Void) }, + { V("hastarget", Int_Int) }, + { V("isinworld", Int_Void) }, + { V("isplayer", Int_Void) }, + { V("isnetclient", Int_Void) }, + { V("teamid", Str_Void) }, + { V("getnexttarget", Cbase_Void) }, + { V("think", Void_Void) }, + { V("touch", Void_Cbase) }, + { V("use", Void_Cbase_Cbase_Int_Float) }, + { V("blocked", Void_Cbase) }, + { V("respawn", Cbase_Void) }, + { V("updateowner", Void_Void) }, + { V("fbecomeprone", Int_Void) }, + { V("center", Vector_Void) }, + { V("eyeposition", Vector_Void) }, + { V("earposition", Vector_Void) }, + { V("bodytarget", Vector_pVector) }, + { V("illumination", Int_Void) }, + { V("fvisible", Int_Cbase) }, + { V("fvecvisible", Int_pVector) }, + + /** Entity specific hooks **/ + /* CBasePlayer */ + { V("player_jump", Void_Void) }, + { V("player_duck", Void_Void) }, + { V("player_prethink", Void_Void) }, + { V("player_postthink", Void_Void) }, + { V("player_getgunposition", Vector_Void) }, + { V("player_shouldfadeondeath", Int_Void) }, + { V("player_impulsecommands", Void_Void) }, + { V("player_updateclientdata", Void_Void) }, - // Vectors are over 2 registers large, so they get passed weird - { 0, 0, "center", true, 1, V(Vector_Void) }, // Center - { 0, 0, "eyeposition", true, 1, V(Vector_Void) }, // EyePosition - { 0, 0, "earposition", true, 1, V(Vector_Void) }, // EarPosition - { 0, 0, "bodytarget", true, 2, V(Vector_pVector) }, // BodyTarget - { 0, 0, "illumination", false, 0, V(Int_Void) }, // Illumination - { 0, 0, "fvisible", false, 1, V(Int_Cbase) }, // FVisible - { 0, 0, "fvecvisible", false, 1, V(Int_pVector) }, // FVecVisible + /* CBasePlayerItem */ + { V("item_addtoplayer", Int_Cbase) }, + { V("item_addduplicate", Int_Cbase) }, + { V("item_getiteminfo", Void_ItemInfo) }, + { V("item_candeploy", Int_Void) }, + { V("item_deploy", Int_Void) }, + { V("item_canholster", Int_Void) }, + { V("item_holster", Void_Int) }, + { V("item_updateiteminfo", Void_Void) }, + { V("item_preframe", Void_Void) }, + { V("item_postframe", Void_Void) }, + { V("item_drop", Void_Void) }, + { V("item_kill", Void_Void) }, + { V("item_attachtoplayer", Void_Cbase) }, + { V("item_primaryammoindex", Int_Void) }, + { V("item_secondaryammoindex", Int_Void) }, + { V("item_updateclientdata", Int_Cbase) }, + { V("item_getweaponptr", Cbase_Void) }, + { V("item_itemslot", Int_Void) }, + + /* CBasePlayerWeapon */ + { V("weapon_extractammo", Int_Cbase) }, + { V("weapon_extractclipammo", Int_Cbase) }, + { V("weapon_addweapon", Int_Void) }, + { V("weapon_playemptysound", Int_Void) }, + { V("weapon_resetemptysound", Void_Void) }, + { V("weapon_sendweaponanim", Void_Int_Int_Int) }, + { V("weapon_isusable", Int_Void) }, + { V("weapon_primaryattack", Void_Void) }, + { V("weapon_secondaryattack", Void_Void) }, + { V("weapon_reload", Void_Void) }, + { V("weapon_weaponidle", Void_Void) }, + { V("weapon_retireweapon", Void_Void) }, + { V("weapon_shouldweaponidle", Int_Void) }, + { V("weapon_usedecrement", Int_Void) }, /** Mod specific hooks **/ /* The Specialists */ - { 0, 0, "ts_breakablerespawn", false, 1, V(Int_Int) }, // TS_BreakableRespawn - { 0, 0, "ts_canusedthroughwalls", false, 0, V(Int_Void) }, // TS_CanUsedThroughWalls - { 0, 0, "ts_respawnwait", false, 0, V(Int_Void) }, // TS_RespawnWait + { V("ts_breakablerespawn", Int_Int) }, + { V("ts_canusedthroughwalls", Int_Void) }, + { V("ts_respawnwait", Int_Void) }, /* Counter-Strike */ - { 0, 0, "cstrike_restart", true, 0, V(Void_Void) }, // CS_Restart + { V("cstrike_restart", Void_Void) }, + { V("cstrike_roundrespawn", Void_Void) }, /* Day of Defeat */ - { 0, 0, "dod_roundrespawn", true, 0, V(Void_Void) }, // DOD_RoundRespawn - { 0, 0, "dod_roundrespawnent", true, 0, V(Void_Void) }, // DOD_RoundRespawnEnt - { 0, 0, "dod_roundstore", true, 0, V(Void_Void) }, // DOD_RoundStore - { 0, 0, "dod_areasetindex", true, 1, V(Void_Int) }, // DOD_AreaSetIndex - { 0, 0, "dod_areasendstatus", true, 1, V(Void_Cbase) }, // DOD_AreaSendStatus - { 0, 0, "dod_getstate", false, 0, V(Int_Void) }, // DOD_GetState - { 0, 0, "dod_getstateent", false, 1, V(Int_Cbase) }, // DOD_GetStateEnt + { V("dod_roundrespawn", Void_Void) }, + { V("dod_roundrespawnent", Void_Void) }, + { V("dod_roundstore", Void_Void) }, + { V("dod_areasetindex", Void_Int) }, + { V("dod_areasendstatus", Void_Cbase) }, + { V("dod_getstate", Int_Void) }, + { V("dod_getstateent", Int_Cbase) }, /* Team Fortress Classic */ // This next one is just a huge guess - { 0, 0, "tfc_dbgetitemname", false, 0, V(Str_Void) }, // TFC_DbGetItemName - { 0, 0, "tfc_engineeruse", false, 1, V(Int_Cbase) }, // TFC_EngineerUse - { 0, 0, "tfc_finished", true, 0, V(Void_Void) }, // TFC_Finished - { 0, 0, "tfc_empexplode", true, 3, V(Void_Entvar_Float_Float) }, // TFC_EmpExplode - { 0, 0, "tfc_calcempdmgrad", false, 2, V(Int_pFloat_pFloat) }, // TFC_CalcEmpDmgRad - { 0, 0, "tfc_takeempblast", true, 1, V(Void_Entvar) }, // TFC_TakeEmpBlast - { 0, 0, "tfc_empremove", true, 0, V(Void_Void) }, // TFC_EmpRemove - { 0, 0, "tfc_takeconcussionblast", true, 2, V(Void_Entvar_Float) }, // TFC_TakeConcussionBlast - { 0, 0, "tfc_concuss", true, 1, V(Void_Entvar) }, // TFC_Concuss + { V("tfc_dbgetitemname", Str_Void) }, + { V("tfc_engineeruse", Int_Cbase) }, + { V("tfc_finished", Void_Void) }, + { V("tfc_empexplode", Void_Entvar_Float_Float) }, + { V("tfc_calcempdmgrad", Int_pFloat_pFloat) }, + { V("tfc_takeempblast", Void_Entvar) }, + { V("tfc_empremove", Void_Void) }, + { V("tfc_takeconcussionblast", Void_Entvar_Float) }, + { V("tfc_concuss", Void_Entvar) }, /* Natural-Selection */ - { 0, 0, "ns_getpointvalue", false, 0, V(Int_Void) }, // NS_GetPointValue - { 0, 0, "ns_awardkill", true, 1, V(Void_Entvar) }, // NS_AwardKill - { 0, 0, "ns_resetentity", true, 0, V(Void_Void) }, // NS_ResetEntity - { 0, 0, "ns_updateonremove", true, 0, V(Void_Void) }, // NS_UpdateOnRemove + { V("ns_getpointvalue", Int_Void) }, + { V("ns_awardkill", Void_Entvar) }, + { V("ns_resetentity", Void_Void) }, + { V("ns_updateonremove", Void_Void) }, }; diff --git a/dlls/hamsandwich/include/hamsandwich.inc b/dlls/hamsandwich/include/hamsandwich.inc index 66c6ffea..4f6728b0 100644 --- a/dlls/hamsandwich/include/hamsandwich.inc +++ b/dlls/hamsandwich/include/hamsandwich.inc @@ -186,6 +186,8 @@ enum Ham Ham_TraceBleed, Ham_IsTriggered, + Ham_MyMonsterPointer, + Ham_MySquadMonsterPointer, Ham_GetToggleState, /** @@ -413,6 +415,57 @@ enum Ham Ham_FVisible, Ham_FVecVisible, + Ham_Player_Jump, + Ham_Player_Duck, + Ham_Player_PreThink, + Ham_Player_PostThink, + Ham_Player_GetGunPosition, + Ham_Player_ShouldFadeOnDeath, + Ham_Player_ImpulseCommands, + Ham_Player_UpdateClientData, + + /** + * Items have all the attributes of normal entities in addition to these. + */ + Ham_Item_AddToPlayer, + Ham_Item_AddDuplicate, + Ham_Item_GetItemInfo, + Ham_Item_CanDeploy, + Ham_Item_Deploy, + Ham_Item_CanHolster, + Ham_Item_Holster, + Ham_Item_UpdateItemInfo, + Ham_Item_PreFrame, + Ham_Item_PostFrame, + Ham_Item_Drop, + Ham_Item_Kill, + Ham_Item_AttachToPlayer, + Ham_Item_PrimaryAmmoIndex, + Ham_Item_SecondaryAmmoIndex, + Ham_Item_UpdateClientData, + Ham_Item_GetWeaponPtr, + Ham_Item_ItemSlot, + + + /** + * Weapons have all the attributes to Ham_Item_*, in addition to these. + */ + Ham_Weapon_ExtractAmmo, + Ham_Weapon_ExtractClipAmmo, + Ham_Weapon_AddWeapon, + Ham_Weapon_PlayEmptySound, + Ham_Weapon_ResetEmptySound, + Ham_Weapon_SendWeaponAnim, + Ham_Weapon_IsUsable, + Ham_Weapon_PrimaryAttack, + Ham_Weapon_SecondaryAttack, + Ham_Weapon_Reload, + Ham_Weapon_WeaponIdle, + Ham_Weapon_RetireWeapon, + Ham_Weapon_ShouldWeaponIdle, + Ham_Weapon_UseDecrement, + + Ham_TS_BreakableRespawn, Ham_TS_CanUsedThroughWalls, Ham_TS_RespawnWait, @@ -420,9 +473,16 @@ enum Ham /** * Description: This is called on a map reset for most map based entities. * Forward params: function(this); - * Execute params: ExecuteHam(Ham_Respawn, this); + * Execute params: ExecuteHam(Ham_CS_Restart, this); */ Ham_CS_Restart, + + /** + * Description: Respawn function for players/bots only! Do not use this on non player/bot entities! + * Forward params: function(this); + * Execute params: ExecuteHam(Ham_CS_RoundRespawn, this); + */ + Ham_CS_RoundRespawn, Ham_DOD_RoundRespawn, Ham_DOD_RoundRespawnEnt,