diff --git a/managed/src/SwiftlyS2.Core/Modules/Engine/TraceManager.cs b/managed/src/SwiftlyS2.Core/Modules/Engine/TraceManager.cs index f06e93b64..7f66d9b26 100644 --- a/managed/src/SwiftlyS2.Core/Modules/Engine/TraceManager.cs +++ b/managed/src/SwiftlyS2.Core/Modules/Engine/TraceManager.cs @@ -35,7 +35,7 @@ public static void SimpleTrace( Vector start, Vector end, RayType_t rayKind, RnQ { var filter = new CTraceFilter(true) { IterateEntities = true, - QueryShapeAttributes = new RnQueryShapeAttr_t { + QueryShapeAttributes = new RnQueryShapeAttr_t() { ObjectSetMask = objectQuery, InteractsWith = interactWith, InteractsExclude = interactExclude, diff --git a/managed/src/SwiftlyS2.Core/Services/CoreHookService.cs b/managed/src/SwiftlyS2.Core/Services/CoreHookService.cs index 59e6080ab..b4f5eea75 100644 --- a/managed/src/SwiftlyS2.Core/Services/CoreHookService.cs +++ b/managed/src/SwiftlyS2.Core/Services/CoreHookService.cs @@ -71,7 +71,7 @@ __int64 sub_1C0CD0(__int64 a1, int a2, unsigned int a3, ...) private delegate nint ExecuteCommand( nint a1, int a2, uint a3, nint a4, nint a5 ); private delegate nint ICvarFindConCommandWindows( nint pICvar, nint pRet, nint pConCommandName, int unk1 ); private delegate nint ICvarFindConCommandLinux( nint pICvar, nint pConCommandName, int unk1 ); - private delegate int CCSPlayerItemServicesCanAcquire( nint pItemServices, nint pEconItemView, nint acquireMethod, nint unk1 ); + private delegate nint CCSPlayerItemServicesCanAcquire( nint pItemServices, nint pEconItemView, int acquireMethod, nint unk1 ); private delegate byte CCSPlayerWeaponServicesCanUse( nint pWeaponServices, nint pBasePlayerWeapon ); private delegate nint CBaseEntityTouchTemplate( nint pBaseEntity, nint pOtherEntity ); private delegate void SteamServerAPIActivated( nint pServer ); diff --git a/managed/src/SwiftlyS2.Core/Services/TestService.cs b/managed/src/SwiftlyS2.Core/Services/TestService.cs index 0bbfaa19c..b85f5bac1 100644 --- a/managed/src/SwiftlyS2.Core/Services/TestService.cs +++ b/managed/src/SwiftlyS2.Core/Services/TestService.cs @@ -79,30 +79,20 @@ public void Test() public void Test2() { - core.Event.OnStartupServer += () => - { - var table = core.StringTable.FindTable("InfoPanel")!; - _ = table.GetOrAddString("motd"); - _ = table.SetStringUserData("motd", StringTableUserData.FromString("https://swiftlys2.net")); - }; - core.Event.OnClientPutInServer += (@event) => - { - var table = core.StringTable.FindTable("InfoPanel")!; - CRecipientFilter filter = new(); - filter.AddAllPlayers(); - table.ReplicateUserData("motd", StringTableUserData.FromString("https://google.com"), filter); + _ = core.Command.RegisterCommand("abc", (ctx) => { + var coords = ctx.Sender!.Pawn!.AbsOrigin; + var ps = core.PlayerManager.GetAllPlayers().Where(p => p.PlayerID != ctx.Sender!.PlayerID).ToList(); + var randomPlayer = ps.OrderBy(p => Guid.NewGuid()).FirstOrDefault(); + var trace = new CGameTrace(); + core.Trace.SimpleTrace(coords!.Value, randomPlayer!.PlayerPawn.EyePosition!.Value, RayType_t.RAY_TYPE_LINE, RnQueryObjectSet.AllGameEntities, MaskTrace.Player | MaskTrace.Solid, MaskTrace.Empty, MaskTrace.Player, CollisionGroup.Player, ref trace); + Console.WriteLine("Fraction: "+trace.Fraction); + Console.WriteLine("Distance: " + trace.Distance); + }); - }; - } - [DatamapHook(HookMode.Pre)] - public void Test2( IDHookCCSPlayerControllerInventoryUpdateThink ctx ) - { - Console.WriteLine($"IDHookCCSPlayerControllerInventoryUpdateThink -> ctx: {ctx.SchemaObject.DesignerName}"); - } // [EntityOutputHandler("*", "*")] // public void Test3( IOnEntityFireOutputHookEvent @event ) diff --git a/managed/src/SwiftlyS2.Runner/Run.cs b/managed/src/SwiftlyS2.Runner/Run.cs index a429a9a27..ca9869ec6 100644 --- a/managed/src/SwiftlyS2.Runner/Run.cs +++ b/managed/src/SwiftlyS2.Runner/Run.cs @@ -9,8 +9,9 @@ public static void Main() { Console.WriteLine("================================================="); - Console.WriteLine("CTakeDamageInfo Struct Layout:"); - PrintStructInfo(); + Console.WriteLine("CTraceFilter Struct Layout:"); + PrintStructInfo(); + PrintStructInfo(); } private static void PrintStructInfo() where T : struct diff --git a/managed/src/SwiftlyS2.Shared/Natives/Structs/CTraceFilter.cs b/managed/src/SwiftlyS2.Shared/Natives/Structs/CTraceFilter.cs index 1f21bf126..35a1550b1 100644 --- a/managed/src/SwiftlyS2.Shared/Natives/Structs/CTraceFilter.cs +++ b/managed/src/SwiftlyS2.Shared/Natives/Structs/CTraceFilter.cs @@ -1,19 +1,28 @@ using SwiftlyS2.Shared.SchemaDefinitions; -using SwiftlyS2.Shared.Schemas; using System.Runtime.InteropServices; namespace SwiftlyS2.Shared.Natives; -[StructLayout(LayoutKind.Explicit, Pack = 8, Size = 64)] +[StructLayout(LayoutKind.Explicit, Pack = 8, Size = 72)] public struct CTraceFilter { [FieldOffset(0x0)] private nint _pVTable; [FieldOffset(0x8)] public RnQueryShapeAttr_t QueryShapeAttributes; - [FieldOffset(0x38)] public bool IterateEntities; + + [FieldOffset(0x40)] + [MarshalAs(UnmanagedType.U1)] + public bool IterateEntities; + + public CTraceFilter() + { + _pVTable = CTraceFilterVTable.pCTraceFilterShouldHitFunctionCall; + QueryShapeAttributes = new RnQueryShapeAttr_t(); + } public CTraceFilter( bool checkIgnoredEntities = true ) { _pVTable = checkIgnoredEntities ? CTraceFilterVTable.pCTraceFilterShouldHitFunctionCall : CTraceFilterVTable.pCTraceFilterVTable; + QueryShapeAttributes = new RnQueryShapeAttr_t(); } internal void EnsureValid() diff --git a/managed/src/SwiftlyS2.Shared/Natives/Structs/RnQueryShapeAttr_t.cs b/managed/src/SwiftlyS2.Shared/Natives/Structs/RnQueryShapeAttr_t.cs index 0f502b034..e52935707 100644 --- a/managed/src/SwiftlyS2.Shared/Natives/Structs/RnQueryShapeAttr_t.cs +++ b/managed/src/SwiftlyS2.Shared/Natives/Structs/RnQueryShapeAttr_t.cs @@ -201,18 +201,20 @@ public enum RnQueryObjectSet : byte All = Static | AllGameEntities, }; -[StructLayout(LayoutKind.Explicit, Pack = 8, Size = 0x32)] +[StructLayout(LayoutKind.Sequential, Pack = 8)] public unsafe struct RnQueryShapeAttr_t { - [FieldOffset(0x0)] public MaskTrace InteractsWith; - [FieldOffset(0x8)] public MaskTrace InteractsExclude; - [FieldOffset(0x10)] public MaskTrace InteractsAs; - [FieldOffset(0x18)] public fixed uint EntityIdsToIgnore[2]; - [FieldOffset(0x20)] public fixed uint OwnerIdsToIgnore[2]; - [FieldOffset(0x28)] public fixed ushort HierarchyIds[2]; - [FieldOffset(0x2F)] public RnQueryObjectSet ObjectSetMask; - [FieldOffset(0x30)] public CollisionGroup CollisionGroup; - [FieldOffset(0x31)] private byte data; + public MaskTrace InteractsWith; + public MaskTrace InteractsExclude; + public MaskTrace InteractsAs; + public fixed uint EntityIdsToIgnore[2]; + public fixed uint OwnerIdsToIgnore[2]; + public fixed ushort HierarchyIds[2]; + public ushort IncludedDetailLayers; + public byte TargetDetailLayer; + public RnQueryObjectSet ObjectSetMask; + public CollisionGroup CollisionGroup; + private byte data; public bool HitSolid { get => BitFieldHelper.GetBit(ref data, 0); @@ -248,4 +250,32 @@ public bool Unknown { get => BitFieldHelper.GetBit(ref data, 6); set => BitFieldHelper.SetBit(ref data, 6, value); } + + public RnQueryShapeAttr_t() + { + InteractsWith = 0; + InteractsExclude = 0; + InteractsAs = 0; + + EntityIdsToIgnore[0] = uint.MaxValue; + EntityIdsToIgnore[1] = uint.MaxValue; + + OwnerIdsToIgnore[0] = uint.MaxValue; + OwnerIdsToIgnore[1] = uint.MaxValue; + + HierarchyIds[0] = 0; + HierarchyIds[1] = 0; + IncludedDetailLayers = ushort.MaxValue; + TargetDetailLayer = 0; + ObjectSetMask = RnQueryObjectSet.All; + CollisionGroup = CollisionGroup.Always; + + HitSolid = true; + HitSolidRequiresGenerateContacts = false; + HitTrigger = false; + ShouldIgnoreDisabledPairs = true; + IgnoreIfBothInteractWithHitboxes = false; + ForceHitEverything = false; + Unknown = true; + } } \ No newline at end of file diff --git a/managed/src/TestPlugin/TestPlugin.cs b/managed/src/TestPlugin/TestPlugin.cs index 3cd3d7275..a07156af9 100644 --- a/managed/src/TestPlugin/TestPlugin.cs +++ b/managed/src/TestPlugin/TestPlugin.cs @@ -151,6 +151,13 @@ public TestPlugin( ISwiftlyCore core ) : base(core) }; } + [Command("selfmute")] + public void SelfMuteCommand( ICommandContext context ) + { + var player = context.Sender!; + player.VoiceFlags = VoiceFlagValue.Muted; + } + [Command("be")] public void Test2Command( ICommandContext context ) { diff --git a/plugin_files/gamedata/cs2/core/offsets.jsonc b/plugin_files/gamedata/cs2/core/offsets.jsonc index ad285a393..350ea59f7 100644 --- a/plugin_files/gamedata/cs2/core/offsets.jsonc +++ b/plugin_files/gamedata/cs2/core/offsets.jsonc @@ -124,8 +124,8 @@ "linux": 27 }, "IVEngineServer2::SetClientListening": { - "windows": 84, - "linux": 84 + "windows": 91, + "linux": 91 }, "IServerGameClients::ClientCommand": { "windows": 17, diff --git a/plugin_files/gamedata/cs2/core/signatures.jsonc b/plugin_files/gamedata/cs2/core/signatures.jsonc index 1198ba19b..13e060c80 100644 --- a/plugin_files/gamedata/cs2/core/signatures.jsonc +++ b/plugin_files/gamedata/cs2/core/signatures.jsonc @@ -153,7 +153,7 @@ "CCSPlayer_ItemServices::CanAcquire": { "lib": "server", "windows": "44 89 44 24 ? 48 89 54 24 ? 48 89 4C 24 ? 55 53 56 57 41 55 41 56 41 57 48 8B EC", - "linux": "55 48 89 E5 41 57 41 56 41 55 49 89 CD 41 54 49 89 FC 53 48 89 F3 48 83 EC 78" + "linux": "55 48 89 E5 41 57 41 56 41 55 49 89 CD 41 54 49 89 FC 53 48 89" }, // Find string 'Client %d(%s) tried to send a RebroadcastSourceId msg.' which is in // a logging call. On linux search for the one which is being used in CServerSideClient. diff --git a/src/core/entrypoint.cpp b/src/core/entrypoint.cpp index a1d3fa2b7..9602fceb3 100644 --- a/src/core/entrypoint.cpp +++ b/src/core/entrypoint.cpp @@ -240,6 +240,9 @@ bool SwiftlyCore::Load(BridgeKind_t kind) auto netmessages = g_ifaceService.FetchInterface(NETMESSAGES_INTERFACE_VERSION); netmessages->Initialize(); + auto voicemanager = g_ifaceService.FetchInterface(VOICEMANAGER_INTERFACE_VERSION); + voicemanager->Initialize(); + auto servercommands = g_ifaceService.FetchInterface(SERVERCOMMANDS_INTERFACE_VERSION); servercommands->Initialize(); @@ -307,6 +310,9 @@ bool SwiftlyCore::Unload() auto servercommands = g_ifaceService.FetchInterface(SERVERCOMMANDS_INTERFACE_VERSION); servercommands->Shutdown(); + auto voicemanager = g_ifaceService.FetchInterface(VOICEMANAGER_INTERFACE_VERSION); + voicemanager->Shutdown(); + if (g_pGameServerSteamAPIActivated != nullptr) { g_pGameServerSteamAPIActivated->Disable(); diff --git a/vendor/s2binlib/libs2binlib.a b/vendor/s2binlib/libs2binlib.a index f604aec9f..9014bf9cf 100644 Binary files a/vendor/s2binlib/libs2binlib.a and b/vendor/s2binlib/libs2binlib.a differ diff --git a/vendor/s2binlib/s2binlib.lib b/vendor/s2binlib/s2binlib.lib index a277f8b4e..bc0671359 100644 Binary files a/vendor/s2binlib/s2binlib.lib and b/vendor/s2binlib/s2binlib.lib differ