public static void Load(string sessionPath, MyObjectBuilder_Checkpoint checkpoint, ulong checkpointSizeInBytes) { ProfilerShort.Begin("MySession.Static.Load"); MyLog.Default.WriteLineAndConsole("Loading session: " + sessionPath); //MyAudio.Static.Mute = true; MyLocalCache.SaveLastLoadedTime(sessionPath, DateTime.Now); MyEntityIdentifier.Reset(); ulong sectorSizeInBytes; ProfilerShort.Begin("MyLocalCache.LoadSector"); var sector = MyLocalCache.LoadSector(sessionPath, checkpoint.CurrentSector, out sectorSizeInBytes); ProfilerShort.End(); if (sector == null) { //TODO: If game - show error messagebox and return to menu // If DS console - write error to console and exit DS // If DS service - pop up silent exception (dont send report) throw new ApplicationException("Sector could not be loaded"); } ulong voxelsSizeInBytes = GetVoxelsSizeInBytes(sessionPath); #if false if ( MyFakes.DEBUG_AVOID_RANDOM_AI ) MyBBSetSampler.ResetRandomSeed(); #endif MyCubeGrid.Preload(); Static = new MySession(); Static.Mods = checkpoint.Mods; Static.Settings = checkpoint.Settings; Static.CurrentPath = sessionPath; if (Static.OnlineMode != MyOnlineModeEnum.OFFLINE) StartServerRequest(); MySandboxGame.Static.SessionCompatHelper.FixSessionComponentObjectBuilders(checkpoint, sector); Static.PrepareBaseSession(checkpoint, sector); ProfilerShort.Begin("MySession.Static.LoadWorld"); Static.LoadWorld(checkpoint, sector); ProfilerShort.End(); if (Sync.IsServer) { Static.InitializeFactions(); } Static.WorldSizeInBytes = checkpointSizeInBytes + sectorSizeInBytes + voxelsSizeInBytes; // CH: I don't think it's needed. If there are problems with missing characters, look at it //FixMissingCharacter(); MyLocalCache.SaveLastSessionInfo(sessionPath); Static.SendSessionStartStats(); Static.LogSettings(); MyHud.Notifications.Get(MyNotificationSingletons.WorldLoaded).SetTextFormatArguments(Static.Name); MyHud.Notifications.Add(MyNotificationSingletons.WorldLoaded); if (MyFakes.LOAD_UNCONTROLLED_CHARACTERS == false) Static.RemoveUncontrolledCharacters(); MyNetworkStats.Static.ClearStats(); Sync.Layer.TransportLayer.ClearStats(); Static.BeforeStartComponents(); MyLog.Default.WriteLineAndConsole("Session loaded"); ProfilerShort.End(); }