diff --git a/README.md b/README.md index 48c8967..f0ec666 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ From https://github.com/darkerz7/CS2-CustomIO 1. Adds a custom Input-Output as in CSS/CS:GO: [From cs2fixes](https://github.com/Source2ZE/CS2Fixes/blob/main/src/customio.cpp) ## Required packages: -1. [SwiftlyS2](https://github.com/swiftly-solution/swiftlys2/releases) (Min version: v1.2.0, just use beta pls) +1. [SwiftlyS2](https://github.com/swiftly-solution/swiftlys2/releases) (Compatible: v1.3.5 up to v1.4.0-beta.22) ## Installation: 1. Compile and copy cs2-CustomIO to `swiftlys2/plugins/cs2-CustomIO` folder diff --git a/cs2-CustomIO.cs b/cs2-CustomIO.cs index 60bc392..becfd15 100644 --- a/cs2-CustomIO.cs +++ b/cs2-CustomIO.cs @@ -13,7 +13,7 @@ namespace CustomIO; -[PluginMetadata(Id = "CS2 CustomIO For SW2", Version = "1.5", Name = "CustomIO SW2", Author = "DarkerZ & LynchMus", Description = "Fixes missing keyvalues from CSS/CS:GO", Website = "https://github.com/himenekocn/CS2-CustomIO-For-SW2")] +[PluginMetadata(Id = "CS2 CustomIO For SW2", Version = "1.6", Name = "CustomIO SW2", Author = "DarkerZ & LynchMus", Description = "Fixes missing keyvalues from CSS/CS:GO", Website = "https://github.com/himenekocn/CS2-CustomIO-For-SW2")] public partial class CustomIO(ISwiftlyCore core) : BasePlugin(core) { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] @@ -39,10 +39,36 @@ public override void Load(bool hotReload) { sw_iodebug = Core.ConVar.CreateOrFind("sw_iodebug", "Enable IO Debug", false); - CEntityIdentity_SetEntityName_Func = Core.Memory.GetUnmanagedFunctionByAddress(Core.GameData.GetSignature("CEntityInstance::SetEntityName")); - CBaseEntity_SetGravityScale_Func = Core.Memory.GetUnmanagedFunctionByAddress(Core.GameData.GetSignature("CBaseEntity::SetGravityScale")); - ProcessMovement_Func = Core.Memory.GetUnmanagedFunctionByAddress(Core.GameData.GetSignature("ProcessMovement")); - ProcessMovement_HookId = ProcessMovement_Func.AddHook(ProcessMovementHook); + var setEntityNamePtr = Core.GameData.GetSignature("CEntityInstance::SetEntityName"); + if (setEntityNamePtr != 0) + { + CEntityIdentity_SetEntityName_Func = Core.Memory.GetUnmanagedFunctionByAddress(setEntityNamePtr); + } + else + { + Core.Logger.LogError("Failed to resolve signature CEntityInstance::SetEntityName"); + } + + var setGravityScalePtr = Core.GameData.GetSignature("CBaseEntity::SetGravityScale"); + if (setGravityScalePtr != 0) + { + CBaseEntity_SetGravityScale_Func = Core.Memory.GetUnmanagedFunctionByAddress(setGravityScalePtr); + } + else + { + Core.Logger.LogError("Failed to resolve signature CBaseEntity::SetGravityScale"); + } + + var processMovementPtr = Core.GameData.GetSignature("ProcessMovement"); + if (processMovementPtr != 0) + { + ProcessMovement_Func = Core.Memory.GetUnmanagedFunctionByAddress(processMovementPtr); + ProcessMovement_HookId = ProcessMovement_Func.AddHook(ProcessMovementHook); + } + else + { + Core.Logger.LogError("Failed to resolve signature ProcessMovement"); + } Core.Event.OnEntityIdentityAcceptInputHook += OnEntityIdentityAcceptInputHook; Core.Event.OnClientPutInServer += OnClientPutInServer; diff --git a/cs2-CustomIO.csproj b/cs2-CustomIO.csproj index 4f730a2..75f06fb 100644 --- a/cs2-CustomIO.csproj +++ b/cs2-CustomIO.csproj @@ -18,7 +18,7 @@ - + diff --git a/resources/gamedata/signatures.jsonc b/resources/gamedata/signatures.jsonc index 5ecc294..40bac2f 100644 --- a/resources/gamedata/signatures.jsonc +++ b/resources/gamedata/signatures.jsonc @@ -1,7 +1,7 @@ { "CEntityInstance::SetEntityName": { "lib": "server", - "windows": "48 89 5C 24 10 57 48 83 EC ? 48 8B D9 4C 8B C2", + "windows": "48 89 5C 24 10 57 48 83 EC 20 48 8B D9 4C 8B C2", "linux": "55 48 89 F2 48 89 E5 41 55 41 54 53" }, "CBaseEntity::SetGravityScale": {