Init
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"Games"
|
||||
{
|
||||
"csgo"
|
||||
{
|
||||
"Addresses"
|
||||
{
|
||||
"GameUILag"
|
||||
{
|
||||
"signature" "CGameUI::Think"
|
||||
}
|
||||
}
|
||||
"Signatures"
|
||||
{
|
||||
"CGameUI::Think"
|
||||
{
|
||||
"library" "server"
|
||||
"windows" "\x8B\x83\x2A\x2A\x2A\x2A\x8D\x8B\x2A\x2A\x2A\x2A\x53\xFF\x90\x2A\x2A\x2A\x2A\x8B\x45\xF4\x89\x03"
|
||||
"linux" "\xC7\x44\x24\x2A\x2A\x2A\x2A\x2A\x89\x34\x24\xE8\x2A\x2A\x2A\x2A\xA1\x2A\x2A\x2A\x2A\xC7\x44\x24\x2A\x2A\x2A\x2A\x2A\x8B\x40\x10"
|
||||
}
|
||||
}
|
||||
"Offsets"
|
||||
{
|
||||
"GameUILag_Offset"
|
||||
{
|
||||
"windows" "0"
|
||||
"linux" "0"
|
||||
}
|
||||
"GameUILag_PatchSize"
|
||||
{
|
||||
"windows" "24"
|
||||
"linux" "16"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
#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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user