Ejemplo n.º 1
0
        internal static void _DoAllPostLoadInits()
        {
            Scribe.mode = LoadSaveMode.PostLoadInit;
            var hashSet    = SaveablesToPostLoad();
            var enumerator = hashSet.GetEnumerator();
            var listSet    = new List <IExposable>();

            while (enumerator.MoveNext())
            {
                listSet.Add(enumerator.Current);
            }
            listSet.Sort((x, y) =>
            {
                return((x is Thing) ? -1 : 1);
            });
            foreach (var exposable in listSet)
            {
                exposable.ExposeData();
            }
            PostLoadInitter.Clear();
            Scribe.mode = LoadSaveMode.Inactive;
        }
Ejemplo n.º 2
0
        internal static void _CheckVersionAndLoad(string path, ScribeMetaHeaderUtility.ScribeHeaderMode mode, Action loadAct)
        {
            bool mismatchWarnings;

            try
            {
                try
                {
                    Scribe.InitLoadingMetaHeaderOnly(path);
                }
                catch (Exception ex)
                {
                    Log.Warning(string.Concat(new object[4]
                    {
                        (object)"Exception loading ",
                        (object)path,
                        (object)": ",
                        (object)ex
                    }));
                }
                ScribeMetaHeaderUtility.LoadGameDataHeader(mode, false);
                mismatchWarnings = ScribeMetaHeaderUtility.TryCreateDialogsForVersionMismatchWarnings(loadAct);
                CrossRefResolver.ResolveAllCrossReferences();
                PostLoadInitter.DoAllPostLoadInits();
            }
            catch
            {
                CrossRefResolver.Clear();
                PostLoadInitter.Clear();
                throw;
            }
            Controller.Data.ResetInjectionSubController();
            if (mismatchWarnings)
            {
                return;
            }
            loadAct();
        }
Ejemplo n.º 3
0
        public static void load(ref List <Thing> thingsToLoad, string fileLocation, Thing currentSource)
        {
            Log.Message("ScribeINIT, loding from:" + fileLocation);
            Scribe.InitLoading(fileLocation);

            //Scribe.EnterNode("Stargate");

            Log.Message("DeepProfiler.Start()");
            DeepProfiler.Start("Load non-compressed things");

            // List<Thing> list2 = (List<Thing>)null;
            Log.Message("Scribe_Collections.LookList");
            Scribe_Collections.LookList <Thing>(ref thingsToLoad, "things", LookMode.Deep);
            Log.Message("List1Count:" + thingsToLoad.Count);

            Log.Message("DeepProfiler.End()");
            DeepProfiler.End();

            //Scribe.ExitNode();
            Scribe.mode = LoadSaveMode.Inactive;

            //Log.Message("list: " + thingsToLoad.Count.ToString());


            Log.Message("Exit Node");
            //Scribe.ExitNode();


            Log.Message("ResolveAllCrossReferences");
            CrossRefResolver.ResolveAllCrossReferences();


            Log.Message("DoAllPostLoadInits");
            PostLoadInitter.DoAllPostLoadInits();

            Log.Message("Return");
        }
Ejemplo n.º 4
0
        internal static void LoadAllPlayData(bool recovering = false)
        {
            if (PlayDataLoader.Loaded)
            {
                Log.Error("Loading play data when already loaded. Call ClearAllPlayData first.");
            }
            else
            {
                queueRecovering      = false;
                queueLoadAllPlayData = false;

                DeepProfiler.Start("LoadAllPlayData");
                try
                {
                    DoPlayLoad();
                }
                catch (Exception ex)
                {
                    if (!Prefs.ResetModsConfigOnCrash)
                    {
                        throw;
                    }
                    else if (recovering)
                    {
                        Log.Warning("Could not recover from errors loading play data. Giving up.");
                        throw;
                    }
                    else
                    {
                        IEnumerable <ModMetaData> activeMods = ModsConfig.ActiveModsInLoadOrder;
                        if (Enumerable.Count <ModMetaData>(activeMods) == 1 && Enumerable.First <ModMetaData>(activeMods).IsCoreMod)
                        {
                            throw;
                        }
                        else
                        {
                            Log.Warning("Caught exception while loading play data but there are active mods other than Core. Resetting mods config and trying again.\nThe exception was: " + (object)ex);
                            try
                            {
                                PlayDataLoader.ClearAllPlayData();
                            }
                            catch
                            {
                                Log.Warning("Caught exception while recovering from errors and trying to clear all play data. Ignoring it.\nThe exception was: " + (object)ex);
                            }
                            ModsConfig.Reset();
                            CrossRefLoader.Clear();
                            PostLoadInitter.Clear();
                            PlayDataLoader.LoadAllPlayData(true);
                            return;
                        }
                    }
                }
                finally
                {
                    DeepProfiler.End();
                }
                // A14 - PlayDataLoader.loaded is now private, Loaded property is getter only
                PlayDataLoader_loaded.SetValue(null, false);
                if (!recovering)
                {
                    return;
                }
                Log.Message("Successfully recovered from errors and loaded play data.");
                DelayedErrorWindowRequest.Add(Translator.Translate("RecoveredFromErrorsText"), Translator.Translate("RecoveredFromErrorsDialogTitle"));
            }
        }