Seamless fix
This commit is contained in:
@@ -131,7 +131,7 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
|
|
||||||
MyGuiTextures.Static.Unload();
|
MyGuiTextures.Static.Unload();
|
||||||
MySession.Static.ScriptManager.Init(checkpoint.ScriptManagerData);
|
MySession.Static.ScriptManager.Init(checkpoint.ScriptManagerData);
|
||||||
MyDefinitionManager.Static.LoadData(TargetServerMods);
|
//MyDefinitionManager.Static.LoadData(TargetServerMods);
|
||||||
PrepareBaseSession.Invoke(null, new object[] { sector });
|
PrepareBaseSession.Invoke(null, new object[] { sector });
|
||||||
|
|
||||||
|
|
||||||
|
@@ -100,10 +100,6 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
Sync.Clients.SetLocalSteamId(Sync.MyId, false, MyGameService.UserName);
|
Sync.Clients.SetLocalSteamId(Sync.MyId, false, MyGameService.UserName);
|
||||||
Sync.Players.RegisterEvents();
|
Sync.Players.RegisterEvents();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -122,68 +118,18 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
private void ForceClientConnection()
|
private void ForceClientConnection()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//Set World Settings
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SetWorldSettings();
|
SetWorldSettings();
|
||||||
|
|
||||||
|
//Load force load any connected players
|
||||||
LoadConnectedClients();
|
LoadConnectedClients();
|
||||||
LoadOnlinePlayers();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//ModLoader.ReadyModSwitch(TargetWorld.Checkpoint, TargetWorld.Sector);
|
|
||||||
MySector.InitEnvironmentSettings(TargetWorld.Sector.Environment);
|
MySector.InitEnvironmentSettings(TargetWorld.Sector.Environment);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//MethodInfo inf = typeof(MySession).GetMethod("LoadGameDefinition", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[1] { typeof(MyObjectBuilder_Checkpoint) }, null);
|
|
||||||
//inf.Invoke(MySession.Static, new object[] { TargetWorld.Checkpoint });
|
|
||||||
|
|
||||||
/*
|
|
||||||
CachingDictionary<Type, MySessionComponentBase> dic = (CachingDictionary<Type, MySessionComponentBase>)typeof(MySession).GetField("m_sessionComponents", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(MySession.Static);
|
|
||||||
|
|
||||||
foreach (var item in dic.ToList())
|
|
||||||
{
|
|
||||||
if (item.Value.ModContext != null)
|
|
||||||
dic.Remove(item.Key, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
foreach (KeyValuePair<MyModContext, HashSet<MyStringId>> item in MyScriptManager.Static.ScriptsPerMod)
|
|
||||||
{
|
|
||||||
MyStringId key = item.Value.First();
|
|
||||||
MySession.Static.RegisterComponentsFromAssembly(MyScriptManager.Static.Scripts[key], true, item.Key);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<MySessionComponentBase> dic1 = (List<MySessionComponentBase>)typeof(MySession).GetField("m_sessionComponentForDrawAsync", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(MySession.Static);
|
|
||||||
List<MySessionComponentBase> dic2 = (List<MySessionComponentBase>)typeof(MySession).GetField("m_sessionComponentForDraw", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(MySession.Static);
|
|
||||||
|
|
||||||
dic1.Clear();
|
|
||||||
dic2.Clear();
|
|
||||||
|
|
||||||
foreach (MySessionComponentBase value in dic.Values)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
if (value.ModContext == null || value.ModContext.IsBaseGame)
|
|
||||||
{
|
|
||||||
dic1.Add(value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dic2.Add(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
string text = ((!string.IsNullOrEmpty(TargetWorld.Checkpoint.CustomSkybox)) ? TargetWorld.Checkpoint.CustomSkybox : MySector.EnvironmentDefinition.EnvironmentTexture);
|
string text = ((!string.IsNullOrEmpty(TargetWorld.Checkpoint.CustomSkybox)) ? TargetWorld.Checkpoint.CustomSkybox : MySector.EnvironmentDefinition.EnvironmentTexture);
|
||||||
MyRenderProxy.PreloadTextures(new string[1] { text }, TextureType.CubeMap);
|
MyRenderProxy.PreloadTextures(new string[1] { text }, TextureType.CubeMap);
|
||||||
|
|
||||||
@@ -209,20 +155,8 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
|
|
||||||
|
|
||||||
MyHud.Chat.RegisterChat(MyMultiplayer.Static);
|
MyHud.Chat.RegisterChat(MyMultiplayer.Static);
|
||||||
|
Patches.GPSRegisterChat.Invoke(MySession.Static.Gpss, new object[] { MyMultiplayer.Static });
|
||||||
|
|
||||||
/*
|
|
||||||
foreach (MySessionComponentBase value in dic.Values)
|
|
||||||
{
|
|
||||||
|
|
||||||
if(value.ModContext != null)
|
|
||||||
{
|
|
||||||
SeamlessClient.TryShow($"{value.Definition?.ToString()} - {value.ModContext.ModName}");
|
|
||||||
value.BeforeStart();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Allow the game to start proccessing incoming messages in the buffer
|
// Allow the game to start proccessing incoming messages in the buffer
|
||||||
MyMultiplayer.Static.StartProcessingClientMessages();
|
MyMultiplayer.Static.StartProcessingClientMessages();
|
||||||
@@ -230,6 +164,8 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
//Recreate all controls... Will fix weird gui/paint/crap
|
//Recreate all controls... Will fix weird gui/paint/crap
|
||||||
MyGuiScreenHudSpace.Static.RecreateControls(true);
|
MyGuiScreenHudSpace.Static.RecreateControls(true);
|
||||||
//MySession.Static.LocalHumanPlayer.BuildArmorSkin = OldArmorSkin;
|
//MySession.Static.LocalHumanPlayer.BuildArmorSkin = OldArmorSkin;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -389,7 +325,6 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
private void LoadConnectedClients()
|
private void LoadConnectedClients()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
Patches.LoadMembersFromWorld.Invoke(MySession.Static, new object[] { TargetWorld, MyMultiplayer.Static });
|
Patches.LoadMembersFromWorld.Invoke(MySession.Static, new object[] { TargetWorld, MyMultiplayer.Static });
|
||||||
|
|
||||||
|
|
||||||
@@ -397,13 +332,9 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
object VirtualClientsValue = Patches.VirtualClients.GetValue(MySession.Static);
|
object VirtualClientsValue = Patches.VirtualClients.GetValue(MySession.Static);
|
||||||
Patches.InitVirtualClients.Invoke(VirtualClientsValue, null);
|
Patches.InitVirtualClients.Invoke(VirtualClientsValue, null);
|
||||||
|
|
||||||
/*
|
|
||||||
SeamlessClient.TryShow("Loading exsisting Members From World!");
|
//load online players
|
||||||
foreach (var Client in TargetWorld.Checkpoint.Clients)
|
LoadOnlinePlayers();
|
||||||
{
|
|
||||||
SeamlessClient.TryShow("Adding New Client: " + Client.Name);
|
|
||||||
Sync.Clients.AddClient(Client.SteamId, Client.Name);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,6 +373,7 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
MyMultiplayer.Static.PendingReplicablesDone -= MyMultiplayer_PendingReplicablesDone;
|
MyMultiplayer.Static.PendingReplicablesDone -= MyMultiplayer_PendingReplicablesDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void UpdateWorldGenerator()
|
private void UpdateWorldGenerator()
|
||||||
{
|
{
|
||||||
//This will re-init the MyProceduralWorldGenerator. (Not doing this will result in asteroids not rendering in properly)
|
//This will re-init the MyProceduralWorldGenerator. (Not doing this will result in asteroids not rendering in properly)
|
||||||
@@ -461,12 +393,9 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
Generator.Init(GeneratorSettings);
|
Generator.Init(GeneratorSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Force component to reload, re-syncing settings and seeds to the destination server
|
//Force component to reload, re-syncing settings and seeds to the destination server
|
||||||
Generator.LoadData();
|
Generator.LoadData();
|
||||||
|
|
||||||
|
|
||||||
//We need to go in and force planets to be empty areas in the generator. This is originially done on planet init.
|
//We need to go in and force planets to be empty areas in the generator. This is originially done on planet init.
|
||||||
FieldInfo PlanetInitArgs = typeof(MyPlanet).GetField("m_planetInitValues", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
FieldInfo PlanetInitArgs = typeof(MyPlanet).GetField("m_planetInitValues", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||||
foreach (var Planet in MyEntities.GetEntities().OfType<MyPlanet>())
|
foreach (var Planet in MyEntities.GetEntities().OfType<MyPlanet>())
|
||||||
|
@@ -69,6 +69,7 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
public static MethodInfo LoadPlayerInternal { get; private set; }
|
public static MethodInfo LoadPlayerInternal { get; private set; }
|
||||||
public static MethodInfo LoadMembersFromWorld { get; private set; }
|
public static MethodInfo LoadMembersFromWorld { get; private set; }
|
||||||
public static MethodInfo LoadMultiplayer { get; private set; }
|
public static MethodInfo LoadMultiplayer { get; private set; }
|
||||||
|
public static MethodInfo GPSRegisterChat { get; private set; }
|
||||||
|
|
||||||
public static MethodInfo SendPlayerData;
|
public static MethodInfo SendPlayerData;
|
||||||
|
|
||||||
@@ -118,7 +119,7 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
LoadMultiplayer = GetMethod(typeof(MySession), "LoadMultiplayer", BindingFlags.Static | BindingFlags.NonPublic);
|
LoadMultiplayer = GetMethod(typeof(MySession), "LoadMultiplayer", BindingFlags.Static | BindingFlags.NonPublic);
|
||||||
SendPlayerData = GetMethod(ClientType, "SendPlayerData", BindingFlags.Instance | BindingFlags.NonPublic);
|
SendPlayerData = GetMethod(ClientType, "SendPlayerData", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||||
UnloadProceduralWorldGenerator = GetMethod(typeof(MyProceduralWorldGenerator), "UnloadData", BindingFlags.Instance | BindingFlags.NonPublic);
|
UnloadProceduralWorldGenerator = GetMethod(typeof(MyProceduralWorldGenerator), "UnloadData", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||||
|
GPSRegisterChat = GetMethod(typeof(MyGpsCollection), "RegisterChat", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -128,7 +129,7 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
|
|
||||||
|
|
||||||
//Test patches
|
//Test patches
|
||||||
MethodInfo SetPlayerDed = GetMethod(typeof(MyPlayerCollection), "SetPlayerDeadInternal", BindingFlags.Instance | BindingFlags.NonPublic);
|
//MethodInfo SetPlayerDed = GetMethod(typeof(MyPlayerCollection), "SetPlayerDeadInternal", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -140,7 +141,7 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
Patcher.Patch(LoadingScreenDraw, prefix: new HarmonyMethod(GetPatchMethod(nameof(DrawInternal))));
|
Patcher.Patch(LoadingScreenDraw, prefix: new HarmonyMethod(GetPatchMethod(nameof(DrawInternal))));
|
||||||
Patcher.Patch(OnJoin, postfix: new HarmonyMethod(GetPatchMethod(nameof(OnUserJoined))));
|
Patcher.Patch(OnJoin, postfix: new HarmonyMethod(GetPatchMethod(nameof(OnUserJoined))));
|
||||||
Patcher.Patch(LoadingAction, prefix: new HarmonyMethod(GetPatchMethod(nameof(LoadMultiplayerSession))));
|
Patcher.Patch(LoadingAction, prefix: new HarmonyMethod(GetPatchMethod(nameof(LoadMultiplayerSession))));
|
||||||
Patcher.Patch(SetPlayerDed, prefix: new HarmonyMethod(GetPatchMethod(nameof(SetPlayerDeadInternal))));
|
//Patcher.Patch(SetPlayerDed, prefix: new HarmonyMethod(GetPatchMethod(nameof(SetPlayerDeadInternal))));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -434,73 +435,6 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
{
|
{
|
||||||
throw Ex;
|
throw Ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static bool SetPlayerDeadInternal(MyPlayerCollection __instance, bool __result, ulong playerSteamId, int playerSerialId, bool deadState, bool resetIdentity)
|
|
||||||
{
|
|
||||||
|
|
||||||
FieldInfo ControlledEntities = typeof(MyPlayerCollection).GetField("m_controlledEntities", BindingFlags.Instance | BindingFlags.NonPublic);
|
|
||||||
MethodInfo RemoveControlledEntity = typeof(MyPlayerCollection).GetMethod("RemoveControlledEntityInternal", BindingFlags.Instance | BindingFlags.NonPublic);
|
|
||||||
|
|
||||||
CachingDictionary<long, MyPlayer.PlayerId> m_controlledEntities = (CachingDictionary<long, MyPlayer.PlayerId>)ControlledEntities.GetValue(__instance);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MyPlayer.PlayerId id = new MyPlayer.PlayerId(playerSteamId, playerSerialId);
|
|
||||||
MyPlayer playerById = Sync.Players.GetPlayerById(id);
|
|
||||||
if (playerById == null)
|
|
||||||
{
|
|
||||||
__result = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (playerById.Identity == null)
|
|
||||||
{
|
|
||||||
__result = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
playerById.Identity.SetDead(resetIdentity);
|
|
||||||
if (deadState)
|
|
||||||
{
|
|
||||||
|
|
||||||
SeamlessClient.TryShow($"Player: {playerSteamId}, SerialID: {playerSerialId} deadstate: {deadState}, resetIdentity: {resetIdentity}");
|
|
||||||
|
|
||||||
playerById.Controller.TakeControl(null);
|
|
||||||
foreach (KeyValuePair<long, MyPlayer.PlayerId> controlledEntity in m_controlledEntities)
|
|
||||||
{
|
|
||||||
if (controlledEntity.Value == playerById.Id)
|
|
||||||
{
|
|
||||||
MyEntity entity = null;
|
|
||||||
MyEntities.TryGetEntityById(controlledEntity.Key, out entity);
|
|
||||||
if (entity != null)
|
|
||||||
{
|
|
||||||
//RemoveControlledEntityInternal(entity, false);
|
|
||||||
RemoveControlledEntity.Invoke(__instance, new object[] { entity, false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_controlledEntities.ApplyRemovals();
|
|
||||||
if (Sync.Clients.LocalClient != null && playerById == Sync.Clients.LocalClient.FirstPlayer)
|
|
||||||
{
|
|
||||||
MyPlayer P = Sync.Clients.LocalClient.FirstPlayer;
|
|
||||||
SeamlessClient.TryShow($"FirstPlayerName: {P.DisplayName}, ID: {P.Id.SteamId}, Serial: {P.Id.SerialId}");
|
|
||||||
SeamlessClient.TryShow(Environment.StackTrace);
|
|
||||||
MyPlayerCollection.RequestLocalRespawn();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
__result = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user