fix CSS hooking

This commit is contained in:
hermansimensen 2021-03-17 04:35:13 +01:00
parent c5d9768232
commit da9545b48e
2 changed files with 21 additions and 21 deletions

View File

@ -72,8 +72,8 @@
} }
"m_RefEHandle" "m_RefEHandle"
{ {
"windows" "32" "windows" "12"
"linux" "32" "linux" "12"
} }
} }
} }

View File

@ -15,17 +15,17 @@
#pragma semicolon 1 #pragma semicolon 1
#define MAX_EDICT_BITS 11 // How many bits to use to encode an edict.
#define MAX_EDICT_BITS 11 // # of bits needed to represent max edicts
// Max # of edicts in a level
#define MAX_EDICTS (1<<MAX_EDICT_BITS) #define MAX_EDICTS (1<<MAX_EDICT_BITS)
#define NUM_ENT_ENTRY_BITS (MAX_EDICT_BITS + 2) // Used for networking ehandles.
#define NUM_ENT_ENTRY_BITS (MAX_EDICT_BITS + 1)
#define NUM_ENT_ENTRIES (1 << NUM_ENT_ENTRY_BITS) #define NUM_ENT_ENTRIES (1 << NUM_ENT_ENTRY_BITS)
#define ENT_ENTRY_MASK (NUM_ENT_ENTRIES - 1)
#define INVALID_EHANDLE_INDEX 0xFFFFFFFF #define INVALID_EHANDLE_INDEX 0xFFFFFFFF
#define NUM_SERIAL_NUM_BITS 16 // (32 - NUM_ENT_ENTRY_BITS)
#define NUM_SERIAL_NUM_SHIFT_BITS (32 - NUM_SERIAL_NUM_BITS)
#define ENT_ENTRY_MASK (( 1 << NUM_SERIAL_NUM_BITS) - 1)
ArrayList g_aPlayerEvents[MAXPLAYERS+1]; ArrayList g_aPlayerEvents[MAXPLAYERS+1];
ArrayList g_aOutputWait[MAXPLAYERS+1]; ArrayList g_aOutputWait[MAXPLAYERS+1];
bool g_bLateLoad; bool g_bLateLoad;
@ -111,7 +111,6 @@ public void OnClientDisconnect(int client)
if(g_aPlayerEvents[client] != null) if(g_aPlayerEvents[client] != null)
{ {
g_aPlayerEvents[client].Clear(); g_aPlayerEvents[client].Clear();
delete g_aPlayerEvents[client];
} }
if(g_aOutputWait[client] != null) if(g_aOutputWait[client] != null)
@ -134,7 +133,14 @@ void LoadDHooks()
int ibuff = gamedataConf.GetOffset("m_angRotation"); int ibuff = gamedataConf.GetOffset("m_angRotation");
g_iRefOffset = ibuff + m_RefEHandleOff; g_iRefOffset = ibuff + m_RefEHandleOff;
if(GetEngineVersion() == Engine_CSS)
{
StartPrepSDKCall(SDKCall_EntityList);
}
else
{
StartPrepSDKCall(SDKCall_Static); StartPrepSDKCall(SDKCall_Static);
}
PrepSDKCall_SetFromConf(gamedataConf, SDKConf_Signature, "FindEntityByName"); PrepSDKCall_SetFromConf(gamedataConf, SDKConf_Signature, "FindEntityByName");
PrepSDKCall_SetReturnInfo(SDKType_CBaseEntity, SDKPass_Pointer); PrepSDKCall_SetReturnInfo(SDKType_CBaseEntity, SDKPass_Pointer);
PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL | VDECODE_FLAG_ALLOWWORLD); PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL | VDECODE_FLAG_ALLOWWORLD);
@ -263,7 +269,6 @@ int EntityToBCompatRef(Address player)
return entry_idx; return entry_idx;
} }
public MRESReturn DHook_AddEventThree(Handle hParams) public MRESReturn DHook_AddEventThree(Handle hParams)
{ {
event_t event; event_t event;
@ -347,7 +352,7 @@ public void ServiceEvent(event_t event)
{ {
for(int i = 0; i < 32; i++) for(int i = 0; i < 32; i++)
{ {
targetEntity = SDKCall(g_hFindEntityByName, 0, event.target, event.caller, event.activator, event.caller, NULL_STRING); targetEntity = SDKCall(g_hFindEntityByName, 0, event.target, event.caller, event.activator, event.caller, 0);
if(targetEntity != -1) if(targetEntity != -1)
{ {
AcceptEntityInput(targetEntity, event.targetInput, event.activator, event.caller, event.outputID); AcceptEntityInput(targetEntity, event.targetInput, event.activator, event.caller, event.outputID);
@ -359,7 +364,7 @@ public void ServiceEvent(event_t event)
} }
else else
{ {
targetEntity = SDKCall(g_hFindEntityByName, 0, event.target, event.caller, event.activator, event.caller, NULL_STRING); targetEntity = SDKCall(g_hFindEntityByName, 0, event.target, event.caller, event.activator, event.caller, 0);
if(targetEntity != -1) if(targetEntity != -1)
{ {
AcceptEntityInput(targetEntity, event.targetInput, event.activator, event.caller, event.outputID); AcceptEntityInput(targetEntity, event.targetInput, event.activator, event.caller, event.outputID);
@ -400,11 +405,6 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
if(event.delay <= GetTickInterval() * timescale) if(event.delay <= GetTickInterval() * timescale)
{ {
if(!IsValidEntity(event.caller))
{
event.caller = event.activator;
}
ServiceEvent(event); ServiceEvent(event);
g_aPlayerEvents[client].Erase(i); g_aPlayerEvents[client].Erase(i);
i--; i--;