86 lines
1.9 KiB
SourcePawn
86 lines
1.9 KiB
SourcePawn
#include <sourcemod>
|
|
#include <sdktools>
|
|
#include <dhooks>
|
|
#pragma semicolon 1
|
|
#pragma newdecls required
|
|
|
|
#define PLUGIN_VERSION "1.0"
|
|
|
|
public Plugin myinfo =
|
|
{
|
|
name = "Fix game_ui lag",
|
|
author = "xen",
|
|
description = "Patches out game_ui code that turns off client prediction.",
|
|
version = PLUGIN_VERSION,
|
|
url = ""
|
|
}
|
|
|
|
#define NOP 0x90
|
|
|
|
Address g_iPatchAddress;
|
|
char g_aPatchRestore[32];
|
|
int g_iPatchSize;
|
|
|
|
public void OnPluginStart()
|
|
{
|
|
Handle hGameConf = LoadGameConfigFile("FixGameUILag.games");
|
|
if(!hGameConf)
|
|
{
|
|
SetFailState("Can't find FixGameUILag.games.txt gamedata.");
|
|
return;
|
|
}
|
|
|
|
// Get the start address for the signature
|
|
g_iPatchAddress = GameConfGetAddress(hGameConf, "GameUILag");
|
|
if(g_iPatchAddress == Address_Null)
|
|
{
|
|
CloseHandle(hGameConf);
|
|
SetFailState("Invalid or outdated signature for GameUILag in gamedata.");
|
|
}
|
|
|
|
// Get the offset from our address to the patch area
|
|
int iOffset = GameConfGetOffset(hGameConf, "GameUILag_Offset");
|
|
if(iOffset == -1)
|
|
{
|
|
CloseHandle(hGameConf);
|
|
SetFailState("Can't find Offset in gamedata.");
|
|
}
|
|
|
|
g_iPatchAddress += view_as<Address>(iOffset);
|
|
|
|
// Get how many bytes we want to NOP
|
|
g_iPatchSize = GameConfGetOffset(hGameConf, "GameUILag_PatchSize");
|
|
if(g_iPatchSize == -1)
|
|
{
|
|
CloseHandle(hGameConf);
|
|
SetFailState("Can't find PatchSize for GameUILag in gamedata.");
|
|
}
|
|
|
|
CloseHandle(hGameConf);
|
|
|
|
Address iAddr = g_iPatchAddress;
|
|
|
|
for(int i = 0; i < g_iPatchSize; i++)
|
|
{
|
|
// Save the current instructions so we can restore them on unload
|
|
g_aPatchRestore[i] = LoadFromAddress(iAddr, NumberType_Int8);
|
|
StoreToAddress(iAddr, NOP, NumberType_Int8);
|
|
iAddr++;
|
|
}
|
|
}
|
|
|
|
public void OnPluginEnd()
|
|
{
|
|
Address iAddr = g_iPatchAddress;
|
|
|
|
// Sanity check, because you never know
|
|
if (iAddr != Address_Null)
|
|
{
|
|
for(int i = 0; i < g_iPatchSize; i++)
|
|
{
|
|
StoreToAddress(iAddr, g_aPatchRestore[i], NumberType_Int8);
|
|
iAddr++;
|
|
}
|
|
}
|
|
}
|