mirror of
https://github.com/GAMMACASE/NoclipSpeed.git
synced 2025-12-06 18:08:39 +00:00
Add CSS compatibility (#1)
This commit is contained in:
parent
995fcbd231
commit
cdebbc96a2
@ -1,9 +1,6 @@
|
||||
# NoclipSpeed
|
||||
SourceMod plugin that allows players to change noclip speed.
|
||||
|
||||
## Note
|
||||
Only CSGO is currently supported.
|
||||
|
||||
## Requirements
|
||||
* [Dhooks with detour support](https://forums.alliedmods.net/showpost.php?p=2588686&postcount=589);
|
||||
* SourceMod 1.10 or higher.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
"Games"
|
||||
{
|
||||
"csgo"
|
||||
"#default"
|
||||
{
|
||||
"Keys"
|
||||
{
|
||||
@ -12,16 +12,6 @@
|
||||
"CBaseEntity::m_RefEHandle" "12"
|
||||
}
|
||||
|
||||
"Signatures"
|
||||
{
|
||||
"CGameMovement::FullNoClipMove"
|
||||
{
|
||||
"library" "server"
|
||||
"windows" "\x53\x8B\xDC\x83\xEC\x08\x83\xE4\xF0\x83\xC4\x04\x55\x8B\x6B\x04\x89\x6C\x24\x04\x8B\xEC\x83\xEC\x5C\x56\x8B\xF1"
|
||||
"linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\x9C\x00\x00\x00\xA1\x2A\x2A\x2A\x2A\x8B\x5D\x08\x3D\x2A\x2A\x2A\x2A"
|
||||
}
|
||||
}
|
||||
|
||||
"Offsets"
|
||||
{
|
||||
"OSType"
|
||||
@ -37,4 +27,30 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"csgo"
|
||||
{
|
||||
"Signatures"
|
||||
{
|
||||
"CGameMovement::FullNoClipMove"
|
||||
{
|
||||
"library" "server"
|
||||
"windows" "\x53\x8B\xDC\x83\xEC\x08\x83\xE4\xF0\x83\xC4\x04\x55\x8B\x6B\x04\x89\x6C\x24\x04\x8B\xEC\x83\xEC\x5C\x56\x8B\xF1"
|
||||
"linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\x9C\x00\x00\x00\xA1\x2A\x2A\x2A\x2A\x8B\x5D\x08\x3D\x2A\x2A\x2A\x2A"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"cstrike"
|
||||
{
|
||||
"Signatures"
|
||||
{
|
||||
"CGameMovement::FullNoClipMove"
|
||||
{
|
||||
"library" "server"
|
||||
"windows" "\x53\x8B\xDC\x83\xEC\x08\x83\xE4\xF0\x83\xC4\x04\x55\x8B\x6B\x04\x89\x6C\x24\x04\x8B\xEC\x83\xEC\x6C\xA1\x2A\x2A\x2A\x2A"
|
||||
"linux" "@_ZN13CGameMovement14FullNoClipMoveEff"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -20,13 +20,13 @@ public Plugin myinfo =
|
||||
#define MAX_EDICT_BITS 11
|
||||
#define MAX_EDICTS (1 << MAX_EDICT_BITS)
|
||||
|
||||
#define NUM_ENT_ENTRY_BITS (MAX_EDICT_BITS + 2)
|
||||
#define NUM_ENT_ENTRY_BITS (MAX_EDICT_BITS + 1)
|
||||
#define NUM_ENT_ENTRIES (1 << NUM_ENT_ENTRY_BITS)
|
||||
#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)
|
||||
#define ENT_ENTRY_MASK_CSGO (( 1 << NUM_SERIAL_NUM_BITS) - 1)
|
||||
#define ENT_ENTRY_MASK_CSS (NUM_ENT_ENTRIES - 1)
|
||||
|
||||
enum OSType
|
||||
{
|
||||
@ -48,8 +48,12 @@ ConVar sv_maxspeed;
|
||||
ConVar sv_friction;
|
||||
ConVar sv_noclipspeed;
|
||||
|
||||
EngineVersion gEVType;
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
gEVType = GetEngineVersion();
|
||||
|
||||
RegConsoleCmd("sm_ns", SM_NoclipSpeed, "Sets noclip speed.");
|
||||
RegConsoleCmd("sm_noclipspeed", SM_NoclipSpeed, "Sets noclip speed.");
|
||||
|
||||
@ -101,8 +105,16 @@ void SetupDhooks(GameData gd)
|
||||
ASSERT_MSG(DHookSetFromConf(dhook, gd, SDKConf_Signature, "CGameMovement::FullNoClipMove"), "Failed to find \"CGameMovement::FullNoClipMove\" signature.");
|
||||
|
||||
DHookAddParam(dhook, HookParamType_Int, .custom_register = DHookRegister_ECX);
|
||||
if(gEVType == Engine_CSGO)
|
||||
{
|
||||
DHookAddParam(dhook, HookParamType_Float, .custom_register = DHookRegister_XMM1);
|
||||
DHookAddParam(dhook, HookParamType_Float, .custom_register = DHookRegister_XMM2);
|
||||
}
|
||||
else
|
||||
{
|
||||
DHookAddParam(dhook, HookParamType_Float);
|
||||
DHookAddParam(dhook, HookParamType_Float);
|
||||
}
|
||||
|
||||
ASSERT_MSG(DHookEnableDetour(dhook, false, FullNoClipMove_Dhook), "Failed to enable \"CGameMovement::FullNoClipMove\" detour.");
|
||||
}
|
||||
@ -169,7 +181,7 @@ int EntityToBCompatRef(Address player)
|
||||
return INVALID_EHANDLE_INDEX;
|
||||
|
||||
// https://github.com/perilouswithadollarsign/cstrike15_src/blob/29e4c1fda9698d5cebcdaf1a0de4b829fa149bf8/public/basehandle.h#L137
|
||||
int entry_idx = m_RefEHandle & ENT_ENTRY_MASK;
|
||||
int entry_idx = gEVType == Engine_CSGO ? m_RefEHandle & ENT_ENTRY_MASK_CSGO : m_RefEHandle & ENT_ENTRY_MASK_CSS;
|
||||
|
||||
if(entry_idx >= MAX_EDICTS)
|
||||
return m_RefEHandle | (1 << 31);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user