Compare commits

..

No commits in common. "master" and "1.0.0" have entirely different histories.

5 changed files with 28 additions and 174 deletions

View File

@ -1,6 +1,9 @@
# 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.

View File

@ -1,6 +1,6 @@
"Games"
{
"#default"
"csgo"
{
"Keys"
{
@ -12,6 +12,16 @@
"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"
@ -27,30 +37,4 @@
}
}
}
"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\x83\xEC\x4C\xA1\x2A\x2A\x2A\x2A\x8B\x5D\x08\x3D\x2A\x2A\x2A\x2A\x0F\x84\x2A\x2A\x2A\x2A\x8B\x10\x8B\x52\x3C\x81\xFA\x2A\x2A\x2A\x2A\x0F\x85\x2A\x2A\x2A\x2A\x8B\x70\x1C\x39\xC6\x0F\x84\x2A\x2A\x2A\x2A\x8B\x06\x8B\x40\x3C\x3D\x2A\x2A\x2A\x2A\x0F\x85\x2A\x2A\x2A\x2A\x8B\x7E\x1C\x39\xFE\x0F\x84\x2A\x2A\x2A\x2A\x8B\x07\x8B\x40\x3C\x3D\x2A\x2A\x2A\x2A\x0F\x85\x2A\x2A\x2A\x2A\x8B\x47\x1C"
}
}
}
"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"
}
}
}
}

View File

@ -1,54 +0,0 @@
#if defined _addressutils_included
#endinput
#endif
#define _addressutils_included
methodmap AddressBase
{
property Address Address
{
public get() { return view_as<Address>(this); }
}
}
//-==Operator overloadings
stock Address operator+(Address l, int r)
{
return l + view_as<Address>(r);
}
stock Address operator+(int l, Address r)
{
return view_as<Address>(l) + r;
}
stock Address operator-(Address l, int r)
{
return l - view_as<Address>(r);
}
stock Address operator-(int l, Address r)
{
return view_as<Address>(l) - r;
}
stock Address operator*(Address l, int r)
{
return l * view_as<Address>(r);
}
stock Address operator*(int l, Address r)
{
return view_as<Address>(l) * r;
}
stock Address operator/(Address l, int r)
{
return l / view_as<Address>(r);
}
stock Address operator/(int l, Address r)
{
return view_as<Address>(l) / r;
}
//Operator overloadings==-

View File

@ -1,58 +0,0 @@
#if defined _assertutils_included
#endinput
#endif
#define _assertutils_included
/* Compile time settings for this include. Should be defined before including this file.
* #define ASSERTUTILS_DISABLE //Disables all assertions
* #define ASSERTUTILS_FAILSTATE_FUNC //Define the name of the function that should be called when assertion is hit
*/
#if !defined SNAME
#define __SNAME ""
#else
#define __SNAME SNAME
#endif
#define ASSERT_FMT_STRING_LEN 512
#if defined ASSERTUTILS_DISABLE
#define ASSERT(%1)%2;
#define ASSERT_MSG(%1,%2)%3;
#define ASSERT_FINAL(%1)%2;
#define ASSERT_FINAL_MSG(%1,%2)%3;
#elseif defined ASSERTUTILS_FAILSTATE_FUNC
#define ASSERT(%1) if(!(%1)) ASSERTUTILS_FAILSTATE_FUNC(__SNAME..."Assertion failed: \""...#%1..."\"")
#define ASSERT_MSG(%1,%2) if(!(%1)) ASSERTUTILS_FAILSTATE_FUNC(__SNAME...%2)
#define ASSERT_FINAL(%1) if(!(%1)) SetFailState(__SNAME..."Assertion failed: \""...#%1..."\"")
#define ASSERT_FINAL_MSG(%1,%2) if(!(%1)) SetFailState(__SNAME...%2)
#else
#define ASSERT(%1) if(!(%1)) SetFailState(__SNAME..."Assertion failed: \""...#%1..."\"")
#define ASSERT_MSG(%1,%2) if(!(%1)) SetFailState(__SNAME...%2)
#define ASSERT_FINAL(%1) ASSERT(%1)
#define ASSERT_FINAL_MSG(%1,%2) ASSERT_MSG(%1,%2)
#endif
// Might be redundant as default ASSERT_MSG accept format arguments just fine.
#if 0
stock void ASSERT_FMT(bool result, char[] fmt, any ...)
{
#if !defined ASSERTUTILS_DISABLE
if(!result)
{
char buff[ASSERT_FMT_STRING_LEN];
VFormat(buff, sizeof(buff), fmt, 3);
SetFailState(__SNAME..."%s", buff);
}
#endif
}
#endif
#undef ASSERT_FMT_STRING_LEN

View File

@ -1,9 +1,7 @@
#include "sourcemod"
#include "sdktools"
#include "dhooks"
#include "glib/addressutils"
#include "glib/assertutils"
#include "glib/memutils"
#define SNAME "[NoclipSpeed] "
@ -12,7 +10,7 @@ public Plugin myinfo =
name = "NoclipSpeed",
author = "GAMMA CASE",
description = "Let's you change noclip speed.",
version = "1.1.1",
version = "1.0.0",
url = "http://steamcommunity.com/id/_GAMMACASE_/"
};
@ -22,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 + 1)
#define NUM_ENT_ENTRY_BITS (MAX_EDICT_BITS + 2)
#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 ENT_ENTRY_MASK_CSGO (( 1 << NUM_SERIAL_NUM_BITS) - 1)
#define ENT_ENTRY_MASK_CSS (NUM_ENT_ENTRIES - 1)
#define NUM_SERIAL_NUM_SHIFT_BITS (32 - NUM_SERIAL_NUM_BITS)
#define ENT_ENTRY_MASK (( 1 << NUM_SERIAL_NUM_BITS) - 1)
enum OSType
{
@ -50,14 +48,10 @@ ConVar sv_maxspeed;
ConVar sv_friction;
ConVar sv_noclipspeed;
EngineVersion gEVType;
public void OnPluginStart()
{
gEVType = GetEngineVersion();
RegConsoleCmd("sm_ns", SM_NoclipSpeed, "Sets noclip speed. Can also be used to set or change speed via argument (Examples: sm_ns 1500 or sm_ns +100)");
RegConsoleCmd("sm_noclipspeed", SM_NoclipSpeed, "Sets noclip speed. Can also be used to set or change speed via argument (Examples: sm_ns 1500 or sm_ns +100)");
RegConsoleCmd("sm_ns", SM_NoclipSpeed, "Sets noclip speed.");
RegConsoleCmd("sm_noclipspeed", SM_NoclipSpeed, "Sets noclip speed.");
gMaxAllowedNoclipFactor = CreateConVar("noclipspeed_max_factor", "35", "Max allowed factor for noclip (factor * 300 = speed)", .hasMin = true);
@ -107,16 +101,8 @@ 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);
}
DHookAddParam(dhook, HookParamType_Float, .custom_register = DHookRegister_XMM1);
DHookAddParam(dhook, HookParamType_Float, .custom_register = DHookRegister_XMM2);
ASSERT_MSG(DHookEnableDetour(dhook, false, FullNoClipMove_Dhook), "Failed to enable \"CGameMovement::FullNoClipMove\" detour.");
}
@ -183,7 +169,7 @@ int EntityToBCompatRef(Address player)
return INVALID_EHANDLE_INDEX;
// https://github.com/perilouswithadollarsign/cstrike15_src/blob/29e4c1fda9698d5cebcdaf1a0de4b829fa149bf8/public/basehandle.h#L137
int entry_idx = gEVType == Engine_CSGO ? m_RefEHandle & ENT_ENTRY_MASK_CSGO : m_RefEHandle & ENT_ENTRY_MASK_CSS;
int entry_idx = m_RefEHandle & ENT_ENTRY_MASK;
if(entry_idx >= MAX_EDICTS)
return m_RefEHandle | (1 << 31);
@ -217,18 +203,11 @@ public Action SM_NoclipSpeed(int client, int args)
float spd = StringToFloat(buff);
// NaN check in case of an invalid argument
if(spd == 0.0 || spd != spd)
{
PrintToChat(client, SNAME..."Invalid speed value specified, check your arguments!");
return Plugin_Handled;
}
gPlayerNoclipSpeed[client] = Clamp(buff[0] == '+' || buff[0] == '-' ? gPlayerNoclipSpeed[client] + NoclipUPSToFactor(spd) : NoclipUPSToFactor(spd), 0.0, gMaxAllowedNoclipFactor.FloatValue);
gPlayerNoclipSpeed[client] = Clamp(NoclipUPSToFactor(spd), 0.0, gMaxAllowedNoclipFactor.FloatValue);
Format(buff, sizeof(buff), "%f", gPlayerNoclipSpeed[client]);
sv_noclipspeed.ReplicateToClient(client, buff);
PrintToChat(client, SNAME..."Changed noclip speed to: %i u/s", RoundToNearest(NoclipFactorToUPS(gPlayerNoclipSpeed[client])));
PrintToChat(client, SNAME..."Changed noclip speed to: %.2f u/s", NoclipFactorToUPS(gPlayerNoclipSpeed[client]));
}
return Plugin_Handled;
@ -240,7 +219,7 @@ public int NoclipSpeed_Menu(Menu menu, MenuAction action, int param1, int param2
{
case MenuAction_Display:
{
menu.SetTitle("Noclip speed\n \nCurrent speed: %i\n ", RoundToNearest(NoclipFactorToUPS(gPlayerNoclipSpeed[param1])));
menu.SetTitle("Noclip speed\n \nCurrent speed: %.2f\n ", NoclipFactorToUPS(gPlayerNoclipSpeed[param1]));
}
case MenuAction_DrawItem:
@ -306,4 +285,4 @@ float Clamp(float val, float min, float max)
bool CloseEnough(float a, float b, float eps = FLT_EPSILON)
{
return FloatAbs(a - b) <= eps;
}
}