|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using System;
- using System.Reflection;
- using GameNetworkLayer.Shared;
- using HarmonyLib;
- using Svelto.Context;
- using Svelto.ECS;
-
- namespace CLre_server.API.MainServer
- {
- public class UserVerification
- {
- public static UserVerification Instance { get; internal set; }
-
- private delegate void DisconnectPlayer_VerificationFailedProto(int playerId, string error);
- private delegate void DisconnectPlayerProto(int playerId, NetworkDispatcherCode code);
-
- private readonly DisconnectPlayer_VerificationFailedProto _disconnectPlayerVerificationFailed;
- private readonly DisconnectPlayerProto _disconnectPlayer;
-
- // This doesn't seem to do actually generate a popup, but it will stop the player from loading in
- /*public void DisconnectPlayer_VerificationFailed(int playerId, string error)
- {
- _disconnectPlayerVerificationFailed(playerId, error);
- }*/
-
- public void DisconnectPlayer(int playerId, NetworkDispatcherCode code = NetworkDispatcherCode.ModVerificationFail)
- {
- _disconnectPlayer(playerId, code);
- }
-
- internal UserVerification(IQueryingEntitiesEngine uvs)
- {
- Type uvsType = AccessTools.TypeByName("User.Server.UserVerificationServer");
- _disconnectPlayerVerificationFailed =
- Utility.Reflection.MethodAsDelegate<DisconnectPlayer_VerificationFailedProto>(uvsType,
- "DisconnectPlayer_VerificationFailed",
- //parameters: new [] {typeof(int), typeof(string)},
- instance: uvs);
-
- _disconnectPlayer =
- Utility.Reflection.MethodAsDelegate<DisconnectPlayerProto>(uvsType, "DisconnectPlayer", instance: uvs);
- }
- }
-
- // This seems to think that __instance is always simply a System.Object (caused by Harmony?), which doesn't work
- /*[HarmonyPatch]
- class UserVerificationServer_Constructor_Patch
- {
-
- private static IQueryingEntitiesEngine uvs = null;
-
- [HarmonyPrefix]
- public static void BeforeMethodCall()
- {
- }
-
- [HarmonyPostfix]
- public static void AfterMethodCall(IQueryingEntitiesEngine __instance)
- {
- uvs = __instance;
- UserVerification.Instance = new UserVerification(__instance);
- }
-
- [HarmonyTargetMethod]
- public static MethodBase Target()
- {
- return AccessTools.Constructor(AccessTools.TypeByName("User.Server.UserVerificationServer"));
- }
- }*/
-
- [HarmonyPatch]
- class MainGameServer_CreatePlayerDisconnectionSequence_Patch
- {
-
- private static IQueryingEntitiesEngine uvs = null;
-
- [HarmonyPrefix]
- public static void BeforeMethodCall()
- {
- }
-
- [HarmonyPostfix]
- public static void AfterMethodCall(IQueryingEntitiesEngine userVerificationEng)
- {
- uvs = userVerificationEng;
- UserVerification.Instance = new UserVerification(userVerificationEng);
- }
-
- [HarmonyTargetMethod]
- public static MethodBase Target()
- {
- return AccessTools.Method("GameServer.GameFramework.MainGameServer:CreatePlayerDisconnectionSequence");
- }
- }
- }
|