Fix Family Share banning.
This commit is contained in:
@@ -59,8 +59,15 @@ namespace Torch.Server.Managers
|
||||
Torch.Invoke(() =>
|
||||
{
|
||||
MyMultiplayer.Static.BanClient(steamId, banned);
|
||||
if (_gameOwnerIds.ContainsKey(steamId))
|
||||
MyMultiplayer.Static.BanClient(_gameOwnerIds[steamId], banned);
|
||||
});
|
||||
}
|
||||
|
||||
internal void RaiseClientBanned(ulong user, bool banned)
|
||||
{
|
||||
Torch.Invoke(() =>
|
||||
{
|
||||
if(_gameOwnerIds.TryGetValue(user, out ulong owner))
|
||||
MyMultiplayer.Static.BanClient(owner, banned);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using Sandbox.Engine.Multiplayer;
|
||||
using Torch.Managers.PatchManager;
|
||||
using Torch.API.Managers;
|
||||
|
||||
namespace Torch.Server.Managers
|
||||
{
|
||||
[PatchShim]
|
||||
internal static class MultiplayerManagerDedicatedPatchShim
|
||||
{
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
public static void Patch(PatchContext ctx)
|
||||
{
|
||||
ctx.GetPattern(typeof(MyDedicatedServerBase).GetMethod(nameof(MyDedicatedServerBase.BanClient))).Prefixes.Add(typeof(MultiplayerManagerDedicatedPatchShim).GetMethod(nameof(BanPrefix)));
|
||||
}
|
||||
|
||||
public static void BanPrefix(ulong userId, bool banned)
|
||||
{
|
||||
Log.Info($"Caught ban event for {userId}: {banned}");
|
||||
TorchBase.Instance.CurrentSession.Managers.GetManager<MultiplayerManagerDedicated>().RaiseClientBanned(userId, banned);
|
||||
}
|
||||
}
|
||||
}
|
@@ -224,6 +224,7 @@
|
||||
<Compile Include="Managers\MultiplayerManagerDedicated.cs" />
|
||||
<Compile Include="Managers\InstanceManager.cs" />
|
||||
<Compile Include="Managers\MultiplayerManagerDedicatedEventShim.cs" />
|
||||
<Compile Include="Managers\MultiplayerManagerDedicatedPatchShim.cs" />
|
||||
<Compile Include="NativeMethods.cs" />
|
||||
<Compile Include="Initializer.cs" />
|
||||
<Compile Include="Properties\Annotations.cs" />
|
||||
|
Reference in New Issue
Block a user