Esempio n. 1
0
        public static void FinalizeLoading()
        {
            if (!loading)
            {
                Log.Error("Called FinalizeLoading() but we aren't loading");
                return;
            }

            ScribeLoader loader = Scribe.loader;

            try
            {
                Scribe.ExitNode();

                loader.curXmlParent       = null;
                loader.curParent          = null;
                loader.curPathRelToParent = null;
                loader.crossRefs.ResolveAllCrossReferences();
                loader.initer.DoAllPostLoadInits();
            }
            catch (Exception e)
            {
                Log.Error("Exception in FinalizeLoading(): " + e);
                loader.ForceStop();
                throw;
            }
            finally
            {
                loading = false;
            }
        }
Esempio n. 2
0
        public static bool Prefix(ScribeLoader __instance, string filePath)
        {
            if (!ScribeLoader_InitLoading_Patch.Enable)
            {
                return(true);
            }
            Loger.Log("ScribeLoader_InitLoadingMetaHeaderOnly_Patch Start");

            if (Scribe.mode != 0)
            {
                Log.Error("Called InitLoadingMetaHeaderOnly() but current mode is " + Scribe.mode);
                Scribe.ForceStop();
            }
            try
            {
                using (var input = new MemoryStream(ScribeLoader_InitLoading_Patch.LoadData))
                //using (StreamReader input = new StreamReader(filePath))
                {
                    using (XmlTextReader xmlTextReader = new XmlTextReader(input))
                    {
                        if (!ScribeMetaHeaderUtility.ReadToMetaElement(xmlTextReader))
                        {
                            return(false);
                        }
                        using (XmlReader reader = xmlTextReader.ReadSubtree())
                        {
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(reader);
                            XmlElement xmlElement = xmlDocument.CreateElement("root");
                            xmlElement.AppendChild(xmlDocument.DocumentElement);
                            __instance.curXmlParent = xmlElement;
                        }
                    }
                }
                Scribe.mode = LoadSaveMode.LoadingVars;
            }
            catch (Exception ex)
            {
                Log.Error("Exception while init loading meta header: " + filePath + "\n" + ex);
                __instance.ForceStop();
                throw;
            }

            Loger.Log("ScribeLoader_InitLoadingMetaHeaderOnly_Patch End");
            return(false);
        }
Esempio n. 3
0
 public static bool Prefix(ScribeLoader __instance, string filePath)
 {
     if (!Enable)
     {
         return(true);
     }
     Loger.Log("ScribeLoader_InitLoading_Patch Start");
     if (Scribe.mode != 0)
     {
         Log.Error("Called InitLoading() but current mode is " + Scribe.mode);
         Scribe.ForceStop();
     }
     if (__instance.curParent != null)
     {
         Log.Error("Current parent is not null in InitLoading");
         __instance.curParent = null;
     }
     if (__instance.curPathRelToParent != null)
     {
         Log.Error("Current path relative to parent is not null in InitLoading");
         __instance.curPathRelToParent = null;
     }
     try
     {
         using (var input = new MemoryStream(LoadData))
         //using (StreamReader input = new StreamReader(filePath))
         {
             using (XmlTextReader reader = new XmlTextReader(input))
             {
                 XmlDocument xmlDocument = new XmlDocument();
                 xmlDocument.Load(reader);
                 __instance.curXmlParent = xmlDocument.DocumentElement;
             }
         }
         Scribe.mode = LoadSaveMode.LoadingVars;
     }
     catch (Exception ex)
     {
         Log.Error("Exception while init loading file: " + filePath + "\n" + ex);
         __instance.ForceStop();
         throw;
     }
     Loger.Log("ScribeLoader_InitLoading_Patch End");
     return(false);
 }
Esempio n. 4
0
 public static void ForceStop()
 {
     mode = LoadSaveMode.Inactive;
     saver.ForceStop();
     loader.ForceStop();
 }