Merge pull request #73 from TorchAPI/dedi-issue-69

Multiplayer Authentication Hook Removal
This commit is contained in:
John Michael Gross
2017-08-19 01:28:38 -07:00
committed by GitHub

View File

@@ -203,19 +203,23 @@ namespace Torch.Managers
/// </summary>
private static void RemoveHandlers()
{
var eventField = typeof(GameServer).GetField("<backing_store>ValidateAuthTicketResponse", BindingFlags.NonPublic | BindingFlags.Instance);
var eventField = typeof(GameServer).GetField("<backing_store>" + nameof(SteamServerAPI.Instance.GameServer.ValidateAuthTicketResponse), BindingFlags.NonPublic | BindingFlags.Instance);
if (eventField?.GetValue(SteamServerAPI.Instance.GameServer) is MulticastDelegate eventDel)
{
foreach (var handle in eventDel.GetInvocationList())
{
if (handle.Method.Name == "GameServer_ValidateAuthTicketResponse")
{
SteamServerAPI.Instance.GameServer.ValidateAuthTicketResponse -= handle as ValidateAuthTicketResponse;
SteamServerAPI.Instance.GameServer.ValidateAuthTicketResponse -=
handle as ValidateAuthTicketResponse;
Log.Debug("Removed GameServer_ValidateAuthTicketResponse");
}
}
}
eventField = typeof(GameServer).GetField("<backing_store>UserGroupStatus", BindingFlags.NonPublic | BindingFlags.Instance);
else
Log.Warn("Unable to unhook GameServer_ValidateAuthTicketResponse from the ValidateAuthTicketResponse event");
eventField = typeof(GameServer).GetField("<backing_store>" + nameof(SteamServerAPI.Instance.GameServer.UserGroupStatus), BindingFlags.NonPublic | BindingFlags.Instance);
eventDel = eventField?.GetValue(SteamServerAPI.Instance.GameServer) as MulticastDelegate;
if (eventDel != null)
{
@@ -227,7 +231,8 @@ namespace Torch.Managers
Log.Debug("Removed GameServer_UserGroupStatus");
}
}
}
} else
Log.Warn("Unable to unhook GameServer_UserGroupStatus from the UserGroupStatusResponse event");
}
//Largely copied from SE
@@ -337,7 +342,6 @@ namespace Torch.Managers
private void UserAccepted(ulong steamId)
{
_members.Remove(steamId);
typeof(MyDedicatedServerBase).GetMethod("UserAccepted", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(MyMultiplayer.Static, new object[] {steamId});
var vm = new PlayerViewModel(steamId) {State = ConnectionState.Connected};
Log.Info($"Player {vm.Name} joined ({vm.SteamId})");