Пример #1
0
        public static void ResetMPClient()
        {
            try
            {
                MySandboxGame.Static.SessionCompatHelper.FixSessionComponentObjectBuilders(World.Checkpoint, World.Sector);


                var LayerInstance = TransportLayerConstructor.Invoke(new object[] { 2 });
                var SyncInstance  = SyncLayerConstructor.Invoke(new object[] { LayerInstance });
                var instance      = ClientConstructor.Invoke(new object[] { Server, SyncInstance });
                MyMulitplayerClient = instance;



                MyMultiplayer.Static = (MyMultiplayerBase)instance;
                MyMultiplayer.Static.ExperimentalMode = MySandboxGame.Config.ExperimentalMode;
                SeamlessClient.TryShow("Successfully set MyMultiplayer.Static");
                //var m = ClientType.GetMethod("SendPlayerData", BindingFlags.Public | BindingFlags.Instance);
                //m.Invoke(MyMultiplayer.Static, new object[] { MyGameService.UserName });
                Server.GetGameTagByPrefix("gamemode");
                //typeof(MySession).GetMethod("LoadMembersFromWorld", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(MySession.Static, new object[] { LoadServer.TargetWorld, MyMultiplayer.Static });


                //MyScreenManager.CloseScreen(GUIScreenChat);
                MyHud.Chat.RegisterChat(MyMultiplayer.Static);
                //MySession.SetSpectatorPositionFromServer(SeamlessClient.PreviousPosition ?? Vector3D.Zero);
                MySession.Static.SetCameraController(MyCameraControllerEnum.SpectatorFixed);
            }
            catch (Exception ex)
            {
                SeamlessClient.TryShow("Error! " + ex.ToString());
            }
        }
        private bool NeedsUpdate(string ClientVersion, string ServerVersion)
        {
            Version Client = new Version(ClientVersion);
            Version Latest = new Version(ServerVersion);

            var result = Client.CompareTo(Latest);

            if (result > 0)
            {
                //Console.WriteLine("Client is greater");
                SeamlessClient.TryShow("Client version is greater than latest! Wow!");
                return(false);
            }
            else if (result < 0)
            {
                //Console.WriteLine("Latest is greater");
                SeamlessClient.TryShow("Client version is out-of-date!");
                return(true);
            }
            else
            {
                //Console.WriteLine("versions are equal");
                SeamlessClient.TryShow("Client is up-to-date!");
                return(false);
            }
        }
Пример #3
0
        public static void LoadMP(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession)
        {
            SeamlessClient.TryShow("Starting LoadMP!");


            //var MySessionConstructor = MySessionType.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[2] { typeof(MySyncLayer), typeof(bool) }, null);
            //MySession.Static = (MySession)MySessionConstructor.Invoke(new object[] { MyMultiplayer.Static.SyncLayer, true });
            MySession.Static.Mods            = World.Checkpoint.Mods;
            MySession.Static.Settings        = World.Checkpoint.Settings;
            MySession.Static.CurrentPath     = MyLocalCache.GetSessionSavesPath(MyUtils.StripInvalidChars(world.Checkpoint.SessionName), contentFolder: false, createIfNotExists: false);
            MySession.Static.WorldBoundaries = world.Checkpoint.WorldBoundaries;
            MySession.Static.InGameTime      = MyObjectBuilder_Checkpoint.DEFAULT_DATE;



            // MySession.Static.Players.LoadConnectedPlayers(world.Checkpoint);

            //typeof(MySession).GetMethod("PrepareBaseSession", BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(MyObjectBuilder_Checkpoint), typeof(MyObjectBuilder_Sector) }, null).Invoke(MySession.Static, new object[] { world.Checkpoint, world.Sector });

            if (MyFakes.MP_SYNC_CLUSTERTREE)
            {
                SeamlessClient.TryShow("Deserializing Clusters!");
                //MyPhysics.DeserializeClusters(world.Clusters);
            }



            //_ = world.Checkpoint.ControlledObject;
            //world.Checkpoint.ControlledObject = -1L;
            LoadOnlinePlayers(world.Checkpoint);
            LoadWorld(world.Checkpoint, world.Sector);
            SeamlessClient.TryShow("Loading World Complete!");
        }
        private void StartEntitySync()
        {
            SeamlessClient.TryShow("Requesting Player From Server");
            Sync.Players.RequestNewPlayer(Sync.MyId, 0, MyGameService.UserName, null, realPlayer: true, initialPlayer: true);
            if (MySession.Static.ControlledEntity == null && Sync.IsServer && !Sandbox.Engine.Platform.Game.IsDedicated)
            {
                MyLog.Default.WriteLine("ControlledObject was null, respawning character");
                //m_cameraAwaitingEntity = true;
                MyPlayerCollection.RequestLocalRespawn();
            }

            //typeof(MyGuiScreenTerminal).GetMethod("CreateTabs")
            MyMultiplayer.Static.OnSessionReady();
            MySession.Static.LoadDataComponents();
            //MyGuiSandbox.LoadData(false);
            //MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.HUDScreen));
            MyRenderProxy.RebuildCullingStructure();
            MyRenderProxy.CollectGarbage();

            SeamlessClient.TryShow("OnlinePlayers: " + MySession.Static.Players.GetOnlinePlayers().Count);
            SeamlessClient.TryShow("Loading Complete!");

            MyMultiplayer.Static.OnSessionReady();
            //Recreate all controls... Will fix weird gui/paint/crap
            MyGuiScreenHudSpace.Static.RecreateControls(true);
        }
Пример #5
0
        private void MyGameService_OnPingServerResponded(object sender, MyGameServerItem e)
        {
            MyGameService.OnPingServerResponded       -= MyGameService_OnPingServerResponded;
            MyGameService.OnPingServerFailedToRespond -= MyGameService_OnPingServerFailedToRespond;
            SeamlessClient.TryShow("ServerPing Successful! Attempting to connect to lobby: " + e.GameID);


            LoadServer.LoadWorldData(e, WorldRequest.DeserializeWorldData());


            MySandboxGame.Static.Invoke(delegate
            {
                StringBuilder Builder = new StringBuilder();
                Builder.AppendLine("Please be patient! Some users can spend a minute switching servers... others may be able to swtich faster. Lots of factors to consider.");
                Builder.AppendLine();
                Builder.AppendLine("Sitting in spectator is perfectly normal for a few seconds!");

                MyAPIGateway.Utilities.ShowMissionScreen("Switching Servers!", null, null, Builder.ToString(), null, "Ok!");
                //MySessionLoader.UnloadAndExitToMenu();
                UnloadCurrentServer();

                //MyJoinGameHelper.JoinGame(e, true);
                LoadServer.ResetMPClient();

                ClearEntities();
                //ReloadPatch.SeamlessSwitch = false;
            }, "SeamlessClient");
            return;
        }
        private void DeleteOLDFiles()
        {
            foreach (var OLDFile in Directory.GetFiles(PluginFolder, "*.old"))
            {
                File.Delete(OLDFile);
            }

            SeamlessClient.TryShow("Deleted all OLD update files");
        }
Пример #7
0
        private static void PingResponded(object sender, MyGameServerItem e)
        {
            //If server ping was successful we need to begin the switching proccess
            UnRegisterEvents();

            SeamlessClient.TryShow($"{e.Name} was successfully pinged!");
            SwitchServers Switcher = new SwitchServers(e, Request.DeserializeWorldData());

            Switcher.BeginSwitch();
            // LoadServer.LoadWorldData(e, Request.DeserializeWorldData());
        }
Пример #8
0
 private static void OnUserJoined(ref JoinResultMsg msg)
 {
     if (SeamlessClient.IsSwitching && msg.JoinResult == JoinResult.OK)
     {
         SeamlessClient.TryShow("User Joined! Result: " + msg.JoinResult.ToString());
         ForceClientConnection();
     }
     else if (SeamlessClient.IsSwitching && msg.JoinResult != JoinResult.OK)
     {
         SeamlessClient.TryShow("Failed to join server! Reason: " + msg.JoinResult.ToString());
         MySession.Static.Unload();
     }
 }
        private void LoadOnlinePlayers()
        {
            //Get This players ID

            MyPlayer.PlayerId?savingPlayerId = new MyPlayer.PlayerId(Sync.MyId);
            if (!savingPlayerId.HasValue)
            {
                SeamlessClient.TryShow("SavingPlayerID is null! Creating Default!");
                savingPlayerId = new MyPlayer.PlayerId(Sync.MyId);
            }
            SeamlessClient.TryShow("Saving PlayerID: " + savingPlayerId.ToString());

            Sync.Players.LoadConnectedPlayers(TargetWorld.Checkpoint, savingPlayerId);
            Sync.Players.LoadControlledEntities(TargetWorld.Checkpoint.ControlledEntities, TargetWorld.Checkpoint.ControlledObject, savingPlayerId);

            /*
             *
             *
             * SeamlessClient.TryShow("Saving PlayerID: " + savingPlayerId.ToString());
             *
             *
             *
             * foreach (KeyValuePair<MyObjectBuilder_Checkpoint.PlayerId, MyObjectBuilder_Player> item3 in TargetWorld.Checkpoint.AllPlayersData.Dictionary)
             * {
             *  MyPlayer.PlayerId playerId5 = new MyPlayer.PlayerId(item3.Key.GetClientId(), item3.Key.SerialId);
             *
             *  SeamlessClient.TryShow($"ConnectedPlayer: {playerId5.ToString()}");
             *  if (savingPlayerId.HasValue && playerId5.SteamId == savingPlayerId.Value.SteamId)
             *  {
             *      playerId5 = new MyPlayer.PlayerId(Sync.MyId, playerId5.SerialId);
             *  }
             *
             *  Patches.LoadPlayerInternal.Invoke(MySession.Static.Players, new object[] { playerId5, item3.Value, false });
             *  ConcurrentDictionary<MyPlayer.PlayerId, MyPlayer> Players = (ConcurrentDictionary<MyPlayer.PlayerId, MyPlayer>)Patches.MPlayerGPSCollection.GetValue(MySession.Static.Players);
             *  //LoadPlayerInternal(ref playerId5, item3.Value);
             *  if (Players.TryGetValue(playerId5, out MyPlayer myPlayer))
             *  {
             *      List<Vector3> value2 = null;
             *      if (TargetWorld.Checkpoint.AllPlayersColors != null && TargetWorld.Checkpoint.AllPlayersColors.Dictionary.TryGetValue(item3.Key, out value2))
             *      {
             *          myPlayer.SetBuildColorSlots(value2);
             *      }
             *      else if (TargetWorld.Checkpoint.CharacterToolbar != null && TargetWorld.Checkpoint.CharacterToolbar.ColorMaskHSVList != null && TargetWorld.Checkpoint.CharacterToolbar.ColorMaskHSVList.Count > 0)
             *      {
             *          myPlayer.SetBuildColorSlots(TargetWorld.Checkpoint.CharacterToolbar.ColorMaskHSVList);
             *      }
             *  }
             * }
             *
             */
        }
Пример #10
0
        private static void LoadClients()
        {
            try
            {
                //Remove all old players
                foreach (var Client in MySession.Static.Players.GetOnlinePlayers())
                {
                    if (Client.Id.SteamId == Sync.MyId)
                    {
                        continue;
                    }

                    SeamlessClient.TryShow("Disconnecting: " + Client.DisplayName);
                    RemovePlayerFromDictionary.Invoke(MySession.Static.Players, new object[] { Client.Id });
                }

                //Clear all exsisting clients
                foreach (var Client in Sync.Clients.GetClients().ToList())
                {
                    if (Client.SteamUserId == Sync.MyId)
                    {
                        continue;
                    }

                    Sync.Clients.RemoveClient(Client.SteamUserId);
                }


                object VirtualClientsValue = VirtualClients.GetValue(MySession.Static);

                //Re-Initilize Virtual clients
                SeamlessClient.TryShow("Initilizing Virtual Clients!");
                InitVirtualClients.Invoke(VirtualClientsValue, null);


                //Load Members from world
                SeamlessClient.TryShow("Loading Members From World!");
                LoadMembersFromWorld.Invoke(MySession.Static, new object[] { World, MyMulitplayerClient });
                foreach (var Client in World.Checkpoint.Clients)
                {
                    SeamlessClient.TryShow("Adding New Client: " + Client.Name);
                    Sync.Clients.AddClient(Client.SteamId, Client.Name);
                }
            }
            catch (Exception ex)
            {
                SeamlessClient.TryShow(ex.ToString());
            }
        }
Пример #11
0
        public void PingServerAndBeginRedirect()
        {
            if (TargetServerID == 0)
            {
                SeamlessClient.TryShow("This is not a valid server!");
                return;
            }

            SeamlessClient.TryShow("SyncMyID: " + Sync.MyId.ToString());
            SeamlessClient.TryShow("Beginning Redirect to server: " + TargetServerID);
            MyGameService.OnPingServerResponded       += MyGameService_OnPingServerResponded;
            MyGameService.OnPingServerFailedToRespond += MyGameService_OnPingServerFailedToRespond;

            MyGameService.PingServer(IPAdress);
        }
        private void ShowDialog(GithubRelease Release, GitZipFile MainReleaseFile)
        {
            StringBuilder Response = new StringBuilder();

            Response.AppendLine($"Current version: {SeamlessClient.Version} Latest: {Release.LatestVersion}");
            Response.AppendLine($"Update: {Release.Name}");
            Response.AppendLine($"Description: {Release.Description}");
            Response.AppendLine($"Size: {MainReleaseFile.Size / 1000}kb");
            Response.AppendLine();
            Response.AppendLine("Warning: If you have a version less than latest seamless will be disabled to prevent crashes!");
            Response.AppendLine("(Clicking yes should restart your game)");

            DialogResult Result = MessageBox.Show(Response.ToString(), $"Download Seamless Client Plugin Update v{ Release.LatestVersion}?", MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);

            SeamlessClient.TryShow(Response.ToString());

            if (Result == DialogResult.Yes)
            {
                SeamlessClient.TryShow("Client wants to update!");
                string DownloadPath = Path.Combine(PluginFolder, MainReleaseFile.Name);
                Client.DownloadFile(new Uri(MainReleaseFile.ZipURL), DownloadPath);

                if (!File.Exists(DownloadPath))
                {
                    SeamlessClient.TryShow("Failed to download zip!");
                    return;
                }

                if (ExtractAndReplace(DownloadPath))
                {
                    StringBuilder ErrorResponse = new StringBuilder();
                    ErrorResponse.AppendLine("There was an error during the extraction proccess! Check your logs for more information!");
                    ErrorResponse.AppendLine();
                    ErrorResponse.AppendLine("You can download manually here:");
                    ErrorResponse.AppendLine(Release.GitHubPage);
                    SeamlessClient.TryShow(ErrorResponse.ToString());
                    MessageBox.Show(ErrorResponse.ToString(), $"Failed to update plugin to v{ Release.LatestVersion}!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                    return;
                }
            }
            else
            {
                SeamlessClient.TryShow("Client skipped Update!");
                return;
            }
        }
        private bool ExtractAndReplace(string ZipPath)
        {
            try
            {
                //Start extractor
                using (ZipArchive archive = ZipFile.OpenRead(ZipPath))
                {
                    foreach (ZipArchiveEntry entry in archive.Entries)
                    {
                        string ExsistingFilePath = Path.Combine(PluginFolder, entry.Name);
                        string OldFilePath       = Path.Combine(PluginFolder, entry.Name + ".old");

                        //No need to extract to files that dont exsist
                        if (!File.Exists(ExsistingFilePath))
                        {
                            continue;
                        }

                        SeamlessClient.TryShow(ExsistingFilePath + "=>" + OldFilePath);

                        if (File.Exists(OldFilePath))
                        {
                            File.Delete(OldFilePath);
                        }

                        File.Move(ExsistingFilePath, OldFilePath);
                        entry.ExtractToFile(ExsistingFilePath, false);
                        //File.Delete(OldFilePath);
                    }
                }

                //Delete latest zip
                File.Delete(ZipPath);

                //Restart client
                SeamlessClient.TryShow("UpdateComplete!");
                SeamlessClient.RestartClientAfterUpdate();
                return(true);
            }
            catch (Exception ex)
            {
                SeamlessClient.TryShow(ex.ToString());
                return(false);
            }
        }
Пример #14
0
        private static void LoadOnlinePlayers(MyObjectBuilder_Checkpoint checkpoint)
        {
            //Get This players ID
            MyPlayer.PlayerId?savingPlayerId = new MyPlayer.PlayerId(Sync.MyId);
            if (!savingPlayerId.HasValue)
            {
                SeamlessClient.TryShow("SavingPlayerID is null! Creating Default!");
                savingPlayerId = new MyPlayer.PlayerId(Sync.MyId);
            }

            SeamlessClient.TryShow("Saving PlayerID: " + savingPlayerId.ToString());


            SeamlessClient.TryShow("Checkpoint.AllPlayers: " + checkpoint.AllPlayers.Count);
            //These both are null/empty. Server doesnt need to send them to the client
            //SeamlessClient.TryShow("Checkpoint.ConnectedPlayers: " + checkpoint.ConnectedPlayers.Dictionary.Count);
            //SeamlessClient.TryShow("Checkpoint.DisconnectedPlayers: " + checkpoint.DisconnectedPlayers.Dictionary.Count);
            SeamlessClient.TryShow("Checkpoint.AllPlayersData: " + checkpoint.AllPlayersData.Dictionary.Count);


            foreach (KeyValuePair <MyObjectBuilder_Checkpoint.PlayerId, MyObjectBuilder_Player> item3 in checkpoint.AllPlayersData.Dictionary)
            {
                MyPlayer.PlayerId playerId5 = new MyPlayer.PlayerId(item3.Key.GetClientId(), item3.Key.SerialId);
                if (savingPlayerId.HasValue && playerId5.SteamId == savingPlayerId.Value.SteamId)
                {
                    playerId5 = new MyPlayer.PlayerId(Sync.MyId, playerId5.SerialId);
                }

                LoadPlayerInternal.Invoke(MySession.Static.Players, new object[] { playerId5, item3.Value, false });
                ConcurrentDictionary <MyPlayer.PlayerId, MyPlayer> Players = (ConcurrentDictionary <MyPlayer.PlayerId, MyPlayer>)MPlayerGPSCollection.GetValue(MySession.Static.Players);
                //LoadPlayerInternal(ref playerId5, item3.Value);
                if (Players.TryGetValue(playerId5, out MyPlayer myPlayer))
                {
                    List <Vector3> value2 = null;
                    if (checkpoint.AllPlayersColors != null && checkpoint.AllPlayersColors.Dictionary.TryGetValue(item3.Key, out value2))
                    {
                        myPlayer.SetBuildColorSlots(value2);
                    }
                    else if (checkpoint.CharacterToolbar != null && checkpoint.CharacterToolbar.ColorMaskHSVList != null && checkpoint.CharacterToolbar.ColorMaskHSVList.Count > 0)
                    {
                        myPlayer.SetBuildColorSlots(checkpoint.CharacterToolbar.ColorMaskHSVList);
                    }
                }
            }
        }
        public void PingUpdateServer()
        {
            try
            {
                //Create new webclient and insert a user-agent
                Client.Headers["User-Agent"] = "SeamlessClientUpdater";

                //Grap API data for latest seamless client release
                string data = Client.DownloadString(GitHubAPILink);

                //SeamlessClient.TryShow(data);


                DataContractJsonSerializer s = new DataContractJsonSerializer(typeof(GithubRelease));

                GithubRelease Release;
                using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(data)))
                {
                    Release = (GithubRelease)s.ReadObject(stream);
                }


                if (Release == null || !TryGetMainRelease(Release.Content, out GitZipFile MainReleaseFile))
                {
                    return;
                }


                //Check if the client needs an update based off of github latest release version

                if (!NeedsUpdate(SeamlessClient.Version, Release.LatestVersion))
                {
                    return;
                }


                //Ask client if they want to update!
                ShowDialog(Release, MainReleaseFile);
            }
            catch (Exception Ex)
            {
                SeamlessClient.TryShow(Ex.ToString());
            }
        }
Пример #16
0
        public static void StartServerPing(Transfer ClientTransfer)
        {
            // We need to first ping the server to make sure its running and so we can get a connection
            Transfer = ClientTransfer;
            Request  = Transfer.WorldRequest;


            if (Transfer.TargetServerID == 0)
            {
                SeamlessClient.TryShow("This is not a valid server!");
                return;
            }



            SeamlessClient.TryShow("Beginning Redirect to server: " + Transfer.TargetServerID);
            MyGameService.OnPingServerResponded       += PingResponded;
            MyGameService.OnPingServerFailedToRespond += FailedToRespond;

            MyGameService.PingServer(Transfer.IPAdress);
        }
Пример #17
0
        private static bool GetCustomLoadingScreenPath(List <MyObjectBuilder_Checkpoint.ModItem> Mods, out string File)
        {
            File = null;
            string WorkshopDir = MyFileSystem.ModsPath;

            SeamlessClient.TryShow(WorkshopDir);
            try
            {
                SeamlessClient.TryShow("Installed Mods: " + Mods);
                foreach (var Mod in Mods)
                {
                    string SearchDir = Mod.GetPath();

                    if (!Directory.Exists(SearchDir))
                    {
                        continue;
                    }

                    var files = Directory.GetFiles(SearchDir, "*.dds", SearchOption.TopDirectoryOnly);
                    foreach (var file in files)
                    {
                        if (Path.GetFileNameWithoutExtension(file) == "CustomLoadingBackground")
                        {
                            SeamlessClient.TryShow(Mod.FriendlyName + " contains a custom loading background!");
                            File = file;
                            return(true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SeamlessClient.TryShow(ex.ToString());
            }

            SeamlessClient.TryShow("No installed custom loading screen!");
            return(false);
        }
        private void SetNewMultiplayerClient()
        {
            // Following is called when the multiplayer is set successfully to target server
            Patches.OnJoinEvent += OnJoinEvent;


            MySandboxGame.Static.SessionCompatHelper.FixSessionComponentObjectBuilders(TargetWorld.Checkpoint, TargetWorld.Sector);

            // Create constructors
            var LayerInstance = Patches.TransportLayerConstructor.Invoke(new object[] { 2 });
            var SyncInstance  = Patches.SyncLayerConstructor.Invoke(new object[] { LayerInstance });
            var instance      = Patches.ClientConstructor.Invoke(new object[] { TargetServer, SyncInstance });


            MyMultiplayer.Static = Utility.CastToReflected(instance, Patches.ClientType);
            MyMultiplayer.Static.ExperimentalMode = true;

            SeamlessClient.TryShow("Successfully set MyMultiplayer.Static");

            MyHud.Chat.RegisterChat(MyMultiplayer.Static);
            Sync.Clients.SetLocalSteamId(Sync.MyId, false, MyGameService.UserName);
            Sync.Players.RegisterEvents();
        }
Пример #19
0
        private void UnloadCurrentServer()
        {
            if (MyMultiplayer.Static != null)
            {
                MyHud.Chat.UnregisterChat(MyMultiplayer.Static);
                //OnPlayerCreated
                //OnConnectedClient

                try
                {
                    //Could throw error when there are no gps points
                    var PCollection = MySession.Static.Gpss[MySession.Static.LocalPlayerId];
                    PCollection?.Clear();
                    SeamlessClient.TryShow(PCollection.Count + "registered GPS points");
                }
                catch (Exception ex)
                {
                    SeamlessClient.TryShow(ex.ToString());
                }


                MyHud.GpsMarkers.Clear();


                MyMultiplayer.Static.ReplicationLayer.Disconnect();
                MyMultiplayer.Static.ReplicationLayer.Dispose();

                MyMultiplayer.Static.Dispose();
                MyMultiplayer.Static = null;

                //Sync.Clients.Clear();



                // MyGuiSandbox.UnloadContent();
            }
        }
Пример #20
0
        private static void LoadWorld(MyObjectBuilder_Checkpoint checkpoint, MyObjectBuilder_Sector sector)
        {
            Dictionary <ulong, AdminSettingsEnum> AdminSettingsList = (Dictionary <ulong, AdminSettingsEnum>)RemoteAdminSettings.GetValue(MySession.Static);

            AdminSettingsList.Clear();

            MySession.Static.PromotedUsers.Clear();
            MySession.Static.CreativeTools.Clear();

            MyEntities.MemoryLimitAddFailureReset();
            MySession.Static.ElapsedGameTime = new TimeSpan(checkpoint.ElapsedGameTime);
            MySession.Static.InGameTime      = checkpoint.InGameTime;
            MySession.Static.Name            = MyStatControlText.SubstituteTexts(checkpoint.SessionName);
            MySession.Static.Description     = checkpoint.Description;


            if (checkpoint.PromotedUsers != null)
            {
                MySession.Static.PromotedUsers = checkpoint.PromotedUsers.Dictionary;
            }
            else
            {
                MySession.Static.PromotedUsers = new Dictionary <ulong, MyPromoteLevel>();
            }



            foreach (KeyValuePair <MyObjectBuilder_Checkpoint.PlayerId, MyObjectBuilder_Player> item in checkpoint.AllPlayersData.Dictionary)
            {
                ulong             clientId          = item.Key.GetClientId();
                AdminSettingsEnum adminSettingsEnum = (AdminSettingsEnum)item.Value.RemoteAdminSettings;
                if (checkpoint.RemoteAdminSettings != null && checkpoint.RemoteAdminSettings.Dictionary.TryGetValue(clientId, out var value))
                {
                    adminSettingsEnum = (AdminSettingsEnum)value;
                }
                if (!MyPlatformGameSettings.IsIgnorePcuAllowed)
                {
                    adminSettingsEnum &= ~AdminSettingsEnum.IgnorePcu;
                    adminSettingsEnum &= ~AdminSettingsEnum.KeepOriginalOwnershipOnPaste;
                }


                AdminSettingsList[clientId] = adminSettingsEnum;
                if (!Sync.IsDedicated && clientId == Sync.MyId)
                {
                    AdminSettings.SetValue(MySession.Static, adminSettingsEnum);

                    //m_adminSettings = adminSettingsEnum;
                }



                if (!MySession.Static.PromotedUsers.TryGetValue(clientId, out var value2))
                {
                    value2 = MyPromoteLevel.None;
                }
                if (item.Value.PromoteLevel > value2)
                {
                    MySession.Static.PromotedUsers[clientId] = item.Value.PromoteLevel;
                }
                if (!MySession.Static.CreativeTools.Contains(clientId) && item.Value.CreativeToolsEnabled)
                {
                    MySession.Static.CreativeTools.Add(clientId);
                }
            }


            //MySession.Static.WorkshopId = checkpoint.WorkshopId;
            MySession.Static.Password = checkpoint.Password;
            MySession.Static.PreviousEnvironmentHostility = checkpoint.PreviousEnvironmentHostility;
            MySession.Static.RequiresDX = checkpoint.RequiresDX;
            MySession.Static.CustomLoadingScreenImage = checkpoint.CustomLoadingScreenImage;
            MySession.Static.CustomLoadingScreenText  = checkpoint.CustomLoadingScreenText;
            MySession.Static.CustomSkybox             = checkpoint.CustomSkybox;
            //FixIncorrectSettings(Settings);
            // MySession.Static.AppVersionFromSave = checkpoint.AppVersion;
            //MyToolbarComponent.InitCharacterToolbar(checkpoint.CharacterToolbar);
            //LoadCameraControllerSettings(checkpoint);



            SeamlessClient.TryShow("LocalPlayerID: " + MySession.Static.LocalPlayerId);
            //checkpoint.Gps.Dictionary.TryGetValue(MySession.Static.LocalPlayerId, out MyObjectBuilder_Gps GPSCollection);
            //SeamlessClient.TryShow("You have " + GPSCollection.Entries.Count + " gps points!");



            MySession.Static.Gpss = new MyGpsCollection();
            MySession.Static.Gpss.LoadGpss(checkpoint);
            MyRenderProxy.RebuildCullingStructure();
            //MySession.Static.Toolbars.LoadToolbars(checkpoint);

            Sync.Players.RespawnComponent.InitFromCheckpoint(checkpoint);
        }
Пример #21
0
 private void MyGameService_OnPingServerFailedToRespond(object sender, EventArgs e)
 {
     MyGameService.OnPingServerResponded       -= MyGameService_OnPingServerResponded;
     MyGameService.OnPingServerFailedToRespond -= MyGameService_OnPingServerFailedToRespond;
     SeamlessClient.TryShow("ServerPing failed!");
 }