Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion managed/src/SwiftlyS2.Core/Modules/Engine/TraceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion managed/src/SwiftlyS2.Core/Services/CoreHookService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
28 changes: 9 additions & 19 deletions managed/src/SwiftlyS2.Core/Services/TestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
5 changes: 3 additions & 2 deletions managed/src/SwiftlyS2.Runner/Run.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ public static void Main()
{
Console.WriteLine("=================================================");

Console.WriteLine("CTakeDamageInfo Struct Layout:");
PrintStructInfo<CTakeDamageInfo>();
Console.WriteLine("CTraceFilter Struct Layout:");
PrintStructInfo<RnQueryShapeAttr_t>();
PrintStructInfo<CTraceFilter>();
}

private static void PrintStructInfo<T>() where T : struct
Expand Down
15 changes: 12 additions & 3 deletions managed/src/SwiftlyS2.Shared/Natives/Structs/CTraceFilter.cs
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
50 changes: 40 additions & 10 deletions managed/src/SwiftlyS2.Shared/Natives/Structs/RnQueryShapeAttr_t.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}
7 changes: 7 additions & 0 deletions managed/src/TestPlugin/TestPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
4 changes: 2 additions & 2 deletions plugin_files/gamedata/cs2/core/offsets.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@
"linux": 27
},
"IVEngineServer2::SetClientListening": {
"windows": 84,
"linux": 84
"windows": 91,
"linux": 91
},
"IServerGameClients::ClientCommand": {
"windows": 17,
Expand Down
2 changes: 1 addition & 1 deletion plugin_files/gamedata/cs2/core/signatures.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions src/core/entrypoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ bool SwiftlyCore::Load(BridgeKind_t kind)
auto netmessages = g_ifaceService.FetchInterface<INetMessages>(NETMESSAGES_INTERFACE_VERSION);
netmessages->Initialize();

auto voicemanager = g_ifaceService.FetchInterface<IVoiceManager>(VOICEMANAGER_INTERFACE_VERSION);
voicemanager->Initialize();

auto servercommands = g_ifaceService.FetchInterface<IServerCommands>(SERVERCOMMANDS_INTERFACE_VERSION);
servercommands->Initialize();

Expand Down Expand Up @@ -307,6 +310,9 @@ bool SwiftlyCore::Unload()
auto servercommands = g_ifaceService.FetchInterface<IServerCommands>(SERVERCOMMANDS_INTERFACE_VERSION);
servercommands->Shutdown();

auto voicemanager = g_ifaceService.FetchInterface<IVoiceManager>(VOICEMANAGER_INTERFACE_VERSION);
voicemanager->Shutdown();

if (g_pGameServerSteamAPIActivated != nullptr)
{
g_pGameServerSteamAPIActivated->Disable();
Expand Down
Binary file modified vendor/s2binlib/libs2binlib.a
Binary file not shown.
Binary file modified vendor/s2binlib/s2binlib.lib
Binary file not shown.
Loading