This commit is contained in:
hermansimensen 2021-03-09 21:33:40 +01:00
parent af7defac54
commit c9fd16b2a6
2 changed files with 269 additions and 0 deletions

View File

@ -0,0 +1,42 @@
"Games"
{
"csgo"
{
"Signatures"
{
"AddEvent"
{
"windows" "\x55\x8B\xEC\x83\xEC\x14\xFF\x75\x18"
"linux" "@_ZN11CEventQueue8AddEventEP11CBaseEntityPKcfS1_S1_i"
}
"AddEventTwo"
{
"windows" "\x55\x8B\xEC\x56\xE8\x2A\x2A\x2A\x2A\x8B\xF0\x85\xF6\x74\x2A\xC7\x46\x0C\xFF\xFF\xFF\xFF\xC7\x46\x10\xFF\xFF\xFF\xFF\xC7\x46\x18\xFF\xFF\xFF\xFF\xC7\x46\x1C\x00\x00\x00\x00\xC7\x46\x28\xFF\xFF\xFF\xFF\xC7\x46\x2C\x00\x00\x00\x00\xEB\x2A\x33\xF6\xA1\x2A\x2A\x2A\x2A\x8B\x4D\x08"
"linux" "@_ZN11CEventQueue8AddEventEP11CBaseEntityPKc9variant_tfS1_S1_i"
}
"AddEventThree"
{
"windows" "\x55\x8B\xEC\x56\xE8\x2A\x2A\x2A\x2A\x8B\xF0\x85\xF6\x74\x2A\xC7\x46\x0C\xFF\xFF\xFF\xFF\xC7\x46\x10\xFF\xFF\xFF\xFF\xC7\x46\x18\xFF\xFF\xFF\xFF\xC7\x46\x1C\x00\x00\x00\x00\xC7\x46\x28\xFF\xFF\xFF\xFF\xC7\x46\x2C\x00\x00\x00\x00\xEB\x2A\x33\xF6\xA1\x2A\x2A\x2A\x2A\xF3\x0F\x10\x40\x10"
"linux" "\x55\x89\xE5\x57\x56\x53\x83\xEC\x4C\x8B\x55\x08\xC7\x44\x24\x04\x38\x00\x00\x00\x8B\x45\x20\xC7\x04\x24\x2A\x2A\x2A\x2A\x8B\x4D\x1C\xF3\x0F\x10\x45\x18\x89\x55\xE0\x8B\x55\x0C\x89\x45\xE4\x8B\x45\x24\x89\x4D\xC4"
}
"AcceptInput"
{
"windows" "\x55\x8B\xEC\x83\xE4\xF8\x81\xEC\x58\x02\x00\x00\xA1\x2A\x2A\x2A\x2A"
"linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\xBC\x01\x00\x00\xA1\x2A\x2A\x2A\x2A"
}
}
}
"cstrike"
{
"Signatures"
{
"AddEventThree"
{
"windows" "\x55\x8B\xEC\x56\x57\x8B\xF9\xB9\x2A\x2A\x2A\x2A\x6A\x38\xE8\x2A\x2A\x2A\x2A\x8B\xF0\x85\xF6\x74\x2A\xC7\x46\x0C\xFF\xFF\xFF\xFF\xC7\x46\x10\xFF\xFF\xFF\xFF\xC7\x46\x18\xFF\xFF\xFF\xFF\xC7\x46\x1C\x00\x00\x00\x00\xC7\x46\x28\xFF\xFF\xFF\xFF\xC7\x46\x2C\x00\x00\x00\x00\xEB\x2A\x33\xF6\xA1\x2A\x2A\x2A\x2A\xF3\x0F\x10\x40\x0C"
"linux" "@_ZN11CEventQueue8AddEventEP11CBaseEntityPKcfS1_S1_i"
}
}
}
}

227
scripting/eventqueuefix.sp Normal file
View File

@ -0,0 +1,227 @@
//#define DEBUG
#define PLUGIN_NAME "EventQueue fix"
#define PLUGIN_AUTHOR "carnifex"
#define PLUGIN_DESCRIPTION ""
#define PLUGIN_VERSION "1.0"
#define PLUGIN_URL ""
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <dhooks>
#include <shavit>
#pragma semicolon 1
ArrayList g_aPlayerEvents[MAXPLAYERS+1];
enum struct event_t
{
char target[64];
char targetInput[64];
char variantValue[64];
float delay;
int activator;
int caller;
int outputID;
}
public Plugin myinfo =
{
name = PLUGIN_NAME,
author = PLUGIN_AUTHOR,
description = PLUGIN_DESCRIPTION,
version = PLUGIN_VERSION,
url = PLUGIN_URL
};
public void OnPluginStart()
{
LoadDHooks();
}
public void OnClientPutInServer(int client)
{
if(g_aPlayerEvents[client] == null)
{
g_aPlayerEvents[client] = new ArrayList(sizeof(event_t));
} else
{
g_aPlayerEvents[client].Clear();
}
SDKHook(client, SDKHook_PostThink, PostThink);
}
public void OnClientDisconnect(int client)
{
if(g_aPlayerEvents[client] != null)
{
g_aPlayerEvents[client].Clear();
delete g_aPlayerEvents[client];
}
}
void LoadDHooks()
{
Handle gamedataConf = LoadGameConfigFile("eventfix.games");
if(gamedataConf == null)
{
SetFailState("Failed to load eventfix gamedata");
}
/*
Handle acceptInput = DHookCreateDetour(Address_Null, CallConv_THISCALL, ReturnType_Bool, ThisPointer_CBaseEntity);
DHookSetFromConf(acceptInput, gamedataConf, SDKConf_Signature, "AcceptInput");
DHookAddParam(acceptInput, HookParamType_CharPtr);
DHookAddParam(acceptInput, HookParamType_CBaseEntity);
DHookAddParam(acceptInput, HookParamType_CBaseEntity);
DHookAddParam(acceptInput, HookParamType_Object, 20, DHookPass_ByVal|DHookPass_ODTOR|DHookPass_OCTOR|DHookPass_OASSIGNOP);
DHookAddParam(acceptInput, HookParamType_Int);
if(!DHookEnableDetour(acceptInput, false, DHook_AcceptInput))
SetFailState("Couldn't enable AcceptInput detour.");
Handle addEvent = DHookCreateDetour(Address_Null, CallConv_THISCALL, ReturnType_Void, ThisPointer_Ignore);
DHookSetFromConf(addEvent, gamedataConf, SDKConf_Signature, "AddEvent");
DHookAddParam(addEvent, HookParamType_CBaseEntity);
DHookAddParam(addEvent, HookParamType_CharPtr);
DHookAddParam(addEvent, HookParamType_Float);
DHookAddParam(addEvent, HookParamType_CBaseEntity);
DHookAddParam(addEvent, HookParamType_CBaseEntity);
DHookAddParam(addEvent, HookParamType_Int);
if(!DHookEnableDetour(addEvent, false, DHook_AddEvent))
SetFailState("Couldn't enable AddEvent detour.");
Handle addEventTwo = DHookCreateDetour(Address_Null, CallConv_THISCALL, ReturnType_Void, ThisPointer_Ignore);
DHookSetFromConf(addEventTwo, gamedataConf, SDKConf_Signature, "AddEventTwo");
DHookAddParam(addEventTwo, HookParamType_CBaseEntity);
DHookAddParam(addEventTwo, HookParamType_CharPtr);
DHookAddParam(addEventTwo, HookParamType_Object, 20, DHookPass_ByVal|DHookPass_ODTOR|DHookPass_OCTOR|DHookPass_OASSIGNOP);
DHookAddParam(addEventTwo, HookParamType_Float);
DHookAddParam(addEventTwo, HookParamType_CBaseEntity);
DHookAddParam(addEventTwo, HookParamType_CBaseEntity);
DHookAddParam(addEventTwo, HookParamType_Int);
if(!DHookEnableDetour(addEventTwo, false, DHook_AddEventTwo))
SetFailState("Couldn't enable AddEventTwo detour.");*/
Handle addEventThree = DHookCreateDetour(Address_Null, CallConv_THISCALL, ReturnType_Void, ThisPointer_Ignore);
DHookSetFromConf(addEventThree, gamedataConf, SDKConf_Signature, "AddEventThree");
DHookAddParam(addEventThree, HookParamType_CharPtr);
DHookAddParam(addEventThree, HookParamType_CharPtr);
DHookAddParam(addEventThree, HookParamType_Object, 20, DHookPass_ByVal|DHookPass_ODTOR|DHookPass_OCTOR|DHookPass_OASSIGNOP);
DHookAddParam(addEventThree, HookParamType_Float);
DHookAddParam(addEventThree, HookParamType_CBaseEntity);
DHookAddParam(addEventThree, HookParamType_CBaseEntity);
DHookAddParam(addEventThree, HookParamType_Int);
if(!DHookEnableDetour(addEventThree, false, DHook_AddEventThree))
SetFailState("Couldn't enable AddEventThree detour.");
delete gamedataConf;
}
/*
public MRESReturn DHook_AcceptInput(int pThis, Handle hReturn, Handle hParams)
{
if(DHookIsNullParam(hParams, 2))
return MRES_Ignored;
int client = DHookGetParam(hParams, 2);
char input[64];
DHookGetParamString(hParams, 1, input, 64);
char variantString[64];
DHookGetParamObjectPtrString(hParams, 4, 0, ObjectValueType_String, variantString, 64);
char args[2][64];
ExplodeString(variantString, " ", args, 2, 64);
return MRES_Ignored;
}
public MRESReturn DHook_AddEvent(Handle hParams)
{
event_t event;
int target = DHookGetParam(hParams, 1);
DHookGetParamString(hParams, 2, event.targetInput, 64);
event.delay = DHookGetParam(hParams, 3);
event.activator = DHookGetParam(hParams, 4);
event.caller = DHookGetParam(hParams, 5);
event.outputID = DHookGetParam(hParams, 6);
PrintToChatAll("AddEvent: %i, %s, %f, %i, %i, %i", target, event.targetInput, event.delay, event.activator, event.caller, event.outputID);
return MRES_Ignored;
}
public MRESReturn DHook_AddEventTwo(Handle hParams)
{
event_t event;
int target = DHookGetParam(hParams, 1);
DHookGetParamString(hParams, 2, event.targetInput, 64);
DHookGetParamObjectPtrString(hParams, 3, 0, ObjectValueType_String, event.variantValue, sizeof(event.variantValue));
event.delay = DHookGetParam(hParams, 4);
event.activator = DHookGetParam(hParams, 5);
event.caller = DHookGetParam(hParams, 6);
event.outputID = DHookGetParam(hParams, 7);
PrintToChatAll("AddEventTwo: %i, %s, %s, %f, %i, %i, %i", target, event.targetInput, event.variantValue, event.delay, event.activator, event.caller, event.outputID);
return MRES_Ignored;
}*/
public MRESReturn DHook_AddEventThree(Handle hParams)
{
if(DHookIsNullParam(hParams, 5))
return MRES_Ignored;
event_t event;
DHookGetParamString(hParams, 1, event.target, 64);
DHookGetParamString(hParams, 2, event.targetInput, 64);
DHookGetParamObjectPtrString(hParams, 3, 0, ObjectValueType_String, event.variantValue, sizeof(event.variantValue));
event.delay = DHookGetParam(hParams, 4);
event.activator = DHookGetParam(hParams, 5);
event.caller = DHookGetParam(hParams, 6);
event.outputID = DHookGetParam(hParams, 7);
#if defined DEBUG
PrintToChatAll("AddEventThree: %s, %s, %s, %f, %i, %i, %i", event.target, event.targetInput, event.variantValue, event.delay, event.activator, event.caller, event.outputID);
#endif
if(!strcmp("!activator", event.target) && (event.activator < 65 && event.activator > 0))
{
g_aPlayerEvents[event.activator].PushArray(event);
return MRES_Supercede;
}
return MRES_Ignored;
}
public void PostThink(int client)
{
for(int i = 0; i < g_aPlayerEvents[client].Length; i++)
{
event_t event;
g_aPlayerEvents[client].GetArray(i, event);
if(event.delay <= 0.0)
{
SetVariantString(event.variantValue);
AcceptEntityInput(client, event.targetInput, client, event.caller, event.outputID);
#if defined DEBUG
PrintToChat(client, "Performing output: %s", event.variantValue);
#endif
g_aPlayerEvents[client].Erase(i);
} else
{
float timescale = Shavit_GetClientTimescale(client) != -1.0 ? Shavit_GetClientTimescale(client) : Shavit_GetStyleSettingFloat(Shavit_GetBhopStyle(client), "speed");
event.delay -= GetTickInterval() * timescale;
g_aPlayerEvents[client].SetArray(i, event);
}
}
}