diff --git a/Components/ServerSwitcherComponent.cs b/Components/ServerSwitcherComponent.cs index 1fdfc65..2e0a88f 100644 --- a/Components/ServerSwitcherComponent.cs +++ b/Components/ServerSwitcherComponent.cs @@ -655,7 +655,7 @@ namespace SeamlessClient.ServerSwitching } catch (Exception ex) { - Seamless.TryShow($"An error occurred while loading GPS points! You will have an empty gps list! \n {ex.ToString()}"); + Seamless.TryShow($"An error occured while loading GPS points! You will have an empty gps list! \n {ex.ToString()}"); } diff --git a/Components/ServerSwitcherComponentOLD.cs b/Components/ServerSwitcherComponentOLD.cs index ae5e7ad..2b9f664 100644 --- a/Components/ServerSwitcherComponentOLD.cs +++ b/Components/ServerSwitcherComponentOLD.cs @@ -27,14 +27,6 @@ using Sandbox.Game; using VRage.Game.ModAPI; using VRage.Utils; using SeamlessClient.ServerSwitching; -using System.Threading; -using System.Diagnostics; -using System.Runtime.Remoting.Metadata.W3cXsd2001; -using VRage.Scripting; -using EmptyKeys.UserInterface.Generated.StoreBlockView_Bindings; -using VRage.Game.Components; -using System.CodeDom; -using VRage.Collections; namespace SeamlessClient.Components { @@ -52,7 +44,6 @@ namespace SeamlessClient.Components private static FieldInfo AdminSettings; private static FieldInfo RemoteAdminSettings; private static FieldInfo VirtualClients; - private static FieldInfo SessionComponents; private static PropertyInfo MySessionLayer; public static MyGameServerItem TargetServer { get; private set; } @@ -61,8 +52,6 @@ namespace SeamlessClient.Components public static ServerSwitcherComponentOLD Instance { get; private set; } private string OldArmorSkin { get; set; } = string.Empty; - private static Stopwatch LoadTime = new Stopwatch(); - public ServerSwitcherComponentOLD() { Instance = this; } @@ -83,9 +72,7 @@ namespace SeamlessClient.Components RemoteAdminSettings = PatchUtils.GetField(typeof(MySession), "m_remoteAdminSettings"); LoadMembersFromWorld = PatchUtils.GetMethod(typeof(MySession), "LoadMembersFromWorld"); InitVirtualClients = PatchUtils.GetMethod(PatchUtils.VirtualClientsType, "Init"); - SessionComponents = PatchUtils.GetField(typeof(MySession), "m_loadOrder"); VirtualClients = PatchUtils.GetField(typeof(MySession), "VirtualClients"); - patcher.Patch(onJoin, postfix: new HarmonyMethod(Get(typeof(ServerSwitcherComponentOLD), nameof(OnUserJoined)))); base.Patch(patcher); @@ -100,9 +87,6 @@ namespace SeamlessClient.Components //Invoke the switch event ForceClientConnection(); isSeamlessSwitching = false; - LoadTime.Stop(); - - MyAPIGateway.Utilities?.ShowMessage("Seamless", $"Loading Time: {LoadTime.Elapsed.ToString(@"s\.fff")}s"); } } @@ -113,8 +97,6 @@ namespace SeamlessClient.Components TargetServer = _TargetServer; TargetWorld = _TargetWorld; - - LoadTime.Restart(); MySandboxGame.Static.Invoke(delegate { //Set camera controller to fixed spectator @@ -178,7 +160,6 @@ namespace SeamlessClient.Components MyModAPIHelper.Initialize(); MySession.Static.LoadDataComponents(); - //MySession.Static.LoadObjectBuildersComponents(TargetWorld.Checkpoint.SessionComponents); MyModAPIHelper.Initialize(); // MySession.Static.LoadObjectBuildersComponents(TargetWorld.Checkpoint.SessionComponents); @@ -193,7 +174,7 @@ namespace SeamlessClient.Components UpdateWorldGenerator(); - UpdateSessionComponents(TargetWorld.Checkpoint.SessionComponents); + StartEntitySync(); @@ -205,12 +186,8 @@ namespace SeamlessClient.Components MyMultiplayer.Static.StartProcessingClientMessages(); //Recreate all controls... Will fix weird gui/paint/crap - MyGuiScreenHudSpace.Static?.RecreateControls(true); + MyGuiScreenHudSpace.Static.RecreateControls(true); //MySession.Static.LocalHumanPlayer.BuildArmorSkin = OldArmorSkin; - - //Pop any queued pause popup messages. Dirty way - for(int i = 0; i < 10; i++) - MySandboxGame.PausePop(); } private static void LoadOnlinePlayers() @@ -295,10 +272,6 @@ namespace SeamlessClient.Components MySession.Static.CustomLoadingScreenImage = TargetWorld.Checkpoint.CustomLoadingScreenImage; MySession.Static.CustomLoadingScreenText = TargetWorld.Checkpoint.CustomLoadingScreenText; MySession.Static.CustomSkybox = TargetWorld.Checkpoint.CustomSkybox; - MyAPIUtilities.Static.Variables = TargetWorld.Checkpoint.ScriptManagerData.variables.Dictionary; - - - try { @@ -308,7 +281,7 @@ namespace SeamlessClient.Components } catch (Exception ex) { - Seamless.TryShow($"An error occurred while loading GPS points! You will have an empty gps list! \n {ex.ToString()}"); + Seamless.TryShow($"An error occured while loading GPS points! You will have an empty gps list! \n {ex.ToString()}"); } @@ -404,11 +377,10 @@ namespace SeamlessClient.Components //Request client state batch (MyMultiplayer.Static as MyMultiplayerClientBase).RequestBatchConfirmation(); - MyMultiplayer.Static.PendingReplicablesDone += MyMultiplayer_PendingReplicableDone; + MyMultiplayer.Static.PendingReplicablesDone += MyMultiplayer_PendingReplicablesDone; //typeof(MyGuiScreenTerminal).GetMethod("CreateTabs") MySession.Static.LoadDataComponents(); - //Session.Static.LoadObjectBuildersComponents(TargetWorld.Checkpoint.SessionComponents); //MyGuiSandbox.LoadData(false); //MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.HUDScreen)); MyRenderProxy.RebuildCullingStructure(); @@ -418,13 +390,13 @@ namespace SeamlessClient.Components Seamless.TryShow("Loading Complete!"); } - private static void MyMultiplayer_PendingReplicableDone() + private static void MyMultiplayer_PendingReplicablesDone() { if (MySession.Static.VoxelMaps.Instances.Count > 0) { MySandboxGame.AreClipmapsReady = false; } - MyMultiplayer.Static.PendingReplicablesDone -= MyMultiplayer_PendingReplicableDone; + MyMultiplayer.Static.PendingReplicablesDone -= MyMultiplayer_PendingReplicablesDone; } @@ -475,7 +447,7 @@ namespace SeamlessClient.Components MySessionComponentIngameHelp component = MySession.Static.GetComponent(); component?.TryCancelObjective(); - + //Clear all old players and clients. Sync.Clients.Clear(); Sync.Players.ClearPlayers(); @@ -488,17 +460,8 @@ namespace SeamlessClient.Components MySession.Static.Gpss.RemovePlayerGpss(MySession.Static.LocalPlayerId); MyHud.GpsMarkers.Clear(); MyMultiplayer.Static.ReplicationLayer.Disconnect(); - UnloadSessionComponents(); - - MyMultiplayer.Static.ReplicationLayer.Dispose(); - - - MyMultiplayer.Static.Dispose(); - - //Clear all old players and clients. - MyMultiplayer.Static = null; //Close any respawn screens that are open @@ -519,49 +482,7 @@ namespace SeamlessClient.Components } } - private void UnloadSessionComponents() - { - List sessions = (List)SessionComponents.GetValue(MySession.Static); - foreach(var session in sessions) - { - if(session.ModContext == null) - continue; - - if (session.Initialized == false) - continue; - - - MethodInfo unload = PatchUtils.GetMethod(typeof(MySessionComponentBase), "UnloadData"); - unload.Invoke(session, null); - FieldInfo inited = PatchUtils.GetField(typeof(MySessionComponentBase), "m_initialized"); - inited.SetValue(session, false); - - - MyLog.Default.WriteLine($"{session.GetType()}"); - } - } - - static List ValidInitTypes = new List() { typeof(MyProceduralWorldGenerator), typeof(MySessionComponentSafeZones) }; - - private static void UpdateSessionComponents(List objectBuilderData) - { - - FieldInfo sessionComps = PatchUtils.GetField(typeof(MySession), "m_sessionComponents"); - CachingDictionary dict = (CachingDictionary)sessionComps.GetValue(MySession.Static); - - foreach (var entity in objectBuilderData) - { - - Type t = MySessionComponentMapping.TryGetMappedSessionComponentType(entity.GetType()); - if(dict.TryGetValue(t, out var component) & ValidInitTypes.Contains(component.GetType())) - { - component.Init(entity); - } - } - - - } diff --git a/Messages/WorldRequestData.cs b/Messages/WorldRequestData.cs index 18ade84..678b2ac 100644 --- a/Messages/WorldRequestData.cs +++ b/Messages/WorldRequestData.cs @@ -56,6 +56,7 @@ namespace SeamlessClient.Messages MyObjectBuilderSerializerKeen.SerializeXML(memoryStream, WorldData, MyObjectBuilderSerializerKeen.XmlCompression.Gzip); this.WorldData = memoryStream.ToArray(); + Log.Warn("Successfully Converted World"); } } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 21db6a3..8dd9d50 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -33,5 +33,5 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.0.8")] //Set these both to the same -[assembly: AssemblyFileVersion("2.0.0.8")] +[assembly: AssemblyVersion("2.0.0.6")] //Set these both to the same +[assembly: AssemblyFileVersion("2.0.0.6")] diff --git a/Seamless.cs b/Seamless.cs index 55d9ba3..72867e3 100644 --- a/Seamless.cs +++ b/Seamless.cs @@ -34,10 +34,10 @@ namespace SeamlessClient private List allComps = new List(); private Assembly thisAssembly => typeof(Seamless).Assembly; - private bool Initialized = false; + private bool Initilized = false; public static bool isSeamlessServer { get; private set; } = false; public static bool isDebug = false; - public static bool UseNewVersion = false; + public static bool UseNewVersion = true; @@ -47,6 +47,8 @@ namespace SeamlessClient TryShow($"Running Seamless Client Plugin v[{SeamlessVersion}]"); SeamlessPatcher = new Harmony("SeamlessClientPatcher"); GetComponents(); + + PatchComponents(SeamlessPatcher); } @@ -93,14 +95,14 @@ namespace SeamlessClient } } - private void InitializeComponents() + private void InitilizeComponents() { foreach(ComponentBase component in allComps) { try { component.Initilized(); - TryShow($"Initialized {component.GetType()}"); + TryShow($"Initilized {component.GetType()}"); }catch(Exception ex) { @@ -160,22 +162,25 @@ namespace SeamlessClient public void Update() { allComps.ForEach(x => x.Update()); - - //All this crap needs to be cleaned - if (MyAPIGateway.Multiplayer == null || MyAPIGateway.Multiplayer.MyId == MyAPIGateway.Multiplayer.ServerId) + if (MyAPIGateway.Multiplayer == null) { isSeamlessServer = false; return; } - if (!Initialized) + if (!Initilized) { MyAPIGateway.Multiplayer.RegisterSecureMessageHandler(SeamlessClientNetId, MessageHandler); - InitializeComponents(); + InitilizeComponents(); - Initialized = true; + Initilized = true; } + + IMyGameServer server = MyServiceManager.Instance.GetService(); + MySandboxGame.PausePop(); + + }